This commit is contained in:
Olivier Gagnon 2021-08-23 02:09:49 -04:00
parent b148b2f0b5
commit 6d2b8b4f6f
16 changed files with 106 additions and 80 deletions

File diff suppressed because one or more lines are too long

@ -2444,6 +2444,12 @@ input[type="checkbox"] {
border: 1px solid #fff;
background-color: #000; }
.log-box-button:hover,
.log-box-button:focus {
color: var(--my-font-color);
text-decoration: none;
cursor: pointer; }
.dialog-box-content {
z-index: 2;
background-color: var(--my-background-color);

@ -3,6 +3,26 @@
Changelog
=========
v0.52.8 - 2021-07-23 Fixing the previous patch tbh ROUND 2 (hydroflame)
-------------------------------------------
** Script editor **
* Correctly reloads old script when clicking "Script Editor"
* No longer jumps to the end of the text for no reason.
** Hash upgrades **
* Fixed an issue where the default option would say ecorp but was really
foodnstuff
** Misc. **
* The "Delete all active script" button under the options has a clearer
description.
* Removed some debug console.log
* nerf noodle bar
v0.52.7 - 2021-07-21 Fixing the previous patch tbh (hydroflame)
-------------------------------------------

@ -66,7 +66,7 @@ documentation_title = '{0} Documentation'.format(project)
# The short X.Y version.
version = '0.52'
# The full version, including alpha/beta/rc tags.
release = '0.52.7'
release = '0.52.8'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

@ -581,10 +581,12 @@
Copy Save data to Clipboard
</button>
<button id="debug-delete-scripts-link" class="a-link-button tooltip">
Delete all active scripts
Force kill all active scripts
<span class="tooltiptextleft">
Forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page.
using this, save the game and then reload the page. This is different then normal kill in that normal kill
will tell the script to shut down while force kill just removes the references to it (and it should crash on it's own).
This will not remove the files on your computer. Just forcefully kill all running instance of all scripts.
</span>
</button>
<button id="debug-soft-reset" class="a-link-button tooltip">

@ -129,5 +129,5 @@
"watch": "webpack --watch --mode production",
"watch:dev": "webpack --watch --mode development"
},
"version": "0.52.7"
"version": "0.52.8"
}

@ -26,18 +26,8 @@ export function Console(props: IProps): React.ReactElement {
// TODO: Figure out how to actually make the scrolling work correctly.
function scrollToBottom(): void {
function isMaxed(): boolean {
if(!lastRef.current) return false;
const oldTop = lastRef.current.scrollTop;
if(!lastRef.current) return;
lastRef.current.scrollTop = lastRef.current.scrollHeight;
const maxed = oldTop === lastRef.current.scrollTop;
lastRef.current.scrollTop = oldTop;
return maxed;
}
if(lastRef.current) {
if(isMaxed())
lastRef.current.scrollTop = lastRef.current.scrollHeight;
}
}
function rerender(): void {

@ -6,7 +6,7 @@
import { IMap } from "./types";
export const CONSTANTS: IMap<any> = {
Version: "0.52.7",
Version: "0.52.8",
// Speed (in ms) at which the main loop is updated
_idleSpeed: 200,
@ -228,32 +228,24 @@ export const CONSTANTS: IMap<any> = {
TotalNumBitNodes: 24,
LatestUpdate: `
v0.52.7 - 2021-07-21 Fixing the previous patch tbh (hydroflame)
v0.52.8 - 2021-07-23 Fixing the previous patch tbh ROUND 2 (hydroflame)
-------------------------------------------
** Netscript **
** Script editor **
* API BREAKING CHANGE: getActionEstimatedSuccessChance now returns a pair of
value to reflect the UI changes. I'm very sorry.
* Correctly reloads old script when clicking "Script Editor"
* No longer jumps to the end of the text for no reason.
** Bladeburner **
** Hash upgrades **
* General actions now display time required.
* Recruitment now displays success chance.
* All other success chance now display a range instead of a single value
The real value is guaranteed to be within that range.
* Fixed an issue where the default option would say ecorp but was really
foodnstuff
** Misc. **
* Fix tutorial not working after Monaco upate
* Fix logbox logs not taking up the whole logbox
* Fix script editor shortcut (ctrl+b)
* Fix Corporation popup appearing in the wrong order, hiding one of them
* Fix error when loading Corp
* Fix logbox dragging (smoother now)
* Fix logbox name collision
* Fix logbox allowing to open the same box multiple times
* Fix netscript write.
* The "Delete all active script" button under the options has a clearer
description.
* Removed some debug console.log
* nerf noodle bar
`,

@ -502,7 +502,7 @@ class DevMenuComponent extends Component {
modifyBladeburnerRank(modify) {
return function(rank) {
if (Player.bladeburner) {
Player.bladeburner.changeRank(rank*modify);
Player.bladeburner.changeRank(Player, rank*modify);
}
}
}
@ -514,7 +514,7 @@ class DevMenuComponent extends Component {
addTonsBladeburnerRank() {
if (Player.bladeburner) {
Player.bladeburner.changeRank(tonsP);
Player.bladeburner.changeRank(Player, tonsP);
}
}

@ -23,7 +23,7 @@ class HashUpgrade extends React.Component {
super(props);
this.state = {
selectedServer: "foodnstuff",
selectedServer: "ecorp",
}
this.changeTargetServer = this.changeTargetServer.bind(this);

@ -82,7 +82,6 @@ BitburnerSaveObject.prototype.getSaveString = function() {
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
this.MessagesSave = JSON.stringify(Messages);
this.StockMarketSave = JSON.stringify(StockMarket);
console.log(JSON.stringify(Settings));
this.SettingsSave = JSON.stringify(Settings);
this.FconfSettingsSave = JSON.stringify(FconfSettings);
this.VersionSave = JSON.stringify(CONSTANTS.Version);

@ -18,8 +18,8 @@ export class PositionTracker {
const position = this.positions.get(filename);
if (!position) {
return {
row: 0,
column: 0,
row: -1,
column: -1,
};
}
return position;

@ -23,6 +23,7 @@ import { libSource } from "../NetscriptDefinitions";
import { NetscriptFunctions } from "../../NetscriptFunctions";
import { WorkerScript } from "../../Netscript/WorkerScript";
import { Settings } from "../../Settings/Settings";
import { GetServerByHostname } from "../../Server/ServerHelpers";
import {
iTutorialNextStep,
ITutorial,
@ -69,16 +70,33 @@ interface IProps {
// https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages
// https://github.com/threehams/typescript-error-guide/blob/master/stories/components/Editor.tsx#L11-L39
// These variables are used to reload a script when it's clicked on. Because we
// won't have references to the old script.
let lastFilename = "";
let lastServer = "";
let lastCode = "";
let lastPosition: monaco.Position | null = null;
export function Root(props: IProps): React.ReactElement {
const editorRef = useRef<IStandaloneCodeEditor | null>(null);
const [filename, setFilename] = useState(props.filename);
const [code, setCode] = useState<string>(props.code);
const [ram, setRAM] = useState('');
const [filename, setFilename] = useState(props.filename ? props.filename : lastFilename);
const [code, setCode] = useState<string>(props.code ? props.code : lastCode);
const [ram, setRAM] = useState('RAM: ???');
const [options, setOptions] = useState<Options>({
theme: Settings.MonacoTheme,
insertSpaces: Settings.MonacoInsertSpaces,
});
// store the last known state in case we need to restart without nano.
useEffect(() => {
if(props.filename === "") return;
if(lastFilename === "")
lastServer = props.player.getCurrentServer().hostname;
lastFilename = props.filename;
lastCode = props.code;
lastPosition = null;
}, []);
function save(): void {
if(editorRef.current !== null) {
const position = editorRef.current.getPosition();
@ -89,6 +107,7 @@ export function Root(props: IProps): React.ReactElement {
});
}
}
lastPosition = null;
// TODO(hydroflame): re-enable the tutorial.
if (ITutorial.isRunning && ITutorial.currStep === iTutorialSteps.TerminalTypeScript) {
@ -103,19 +122,20 @@ export function Root(props: IProps): React.ReactElement {
}
//Save the script
const s = props.player.getCurrentServer();
for (let i = 0; i < s.scripts.length; i++) {
if (filename == s.scripts[i].filename) {
s.scripts[i].saveScript(code, props.player.currentServer, props.player.getCurrentServer().scripts);
const server = GetServerByHostname(lastServer);
if(server === null) throw new Error('Server should not be null but it is.');
for (let i = 0; i < server.scripts.length; i++) {
if (filename == server.scripts[i].filename) {
server.scripts[i].saveScript(code, lastServer, server.scripts);
props.engine.loadTerminalContent();
return iTutorialNextStep();
}
}
// If the current script does NOT exist, create a new one
let script = new Script();
script.saveScript(code, props.player.currentServer, props.player.getCurrentServer().scripts);
s.scripts.push(script);
const script = new Script();
script.saveScript(code, lastServer, server.scripts);
server.scripts.push(script);
return iTutorialNextStep();
}
@ -130,7 +150,8 @@ export function Root(props: IProps): React.ReactElement {
return;
}
const s = props.player.getCurrentServer();
const server = GetServerByHostname(lastServer);
if(server === null) throw new Error('Server should not be null but it is.');
if (filename === ".fconf") {
try {
parseFconfSettings(code);
@ -140,9 +161,9 @@ export function Root(props: IProps): React.ReactElement {
}
} else if (isScriptFilename(filename)) {
//If the current script already exists on the server, overwrite it
for (let i = 0; i < s.scripts.length; i++) {
if (filename == s.scripts[i].filename) {
s.scripts[i].saveScript(code, props.player.currentServer, props.player.getCurrentServer().scripts);
for (let i = 0; i < server.scripts.length; i++) {
if (filename == server.scripts[i].filename) {
server.scripts[i].saveScript(code, lastServer, server.scripts);
props.engine.loadTerminalContent();
return;
}
@ -150,18 +171,18 @@ export function Root(props: IProps): React.ReactElement {
//If the current script does NOT exist, create a new one
const script = new Script();
script.saveScript(code, props.player.currentServer, props.player.getCurrentServer().scripts);
s.scripts.push(script);
script.saveScript(code, lastServer, server.scripts);
server.scripts.push(script);
} else if (filename.endsWith(".txt")) {
for (let i = 0; i < s.textFiles.length; ++i) {
if (s.textFiles[i].fn === filename) {
s.textFiles[i].write(code);
for (let i = 0; i < server.textFiles.length; ++i) {
if (server.textFiles[i].fn === filename) {
server.textFiles[i].write(code);
props.engine.loadTerminalContent();
return;
}
}
const textFile = new TextFile(filename, code);
s.textFiles.push(textFile);
server.textFiles.push(textFile);
} else {
dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or " +
" or text file (.txt)")
@ -179,6 +200,7 @@ export function Root(props: IProps): React.ReactElement {
}
function onFilenameChange(event: React.ChangeEvent<HTMLInputElement>): void {
lastFilename = filename;
setFilename(event.target.value);
}
@ -202,6 +224,10 @@ export function Root(props: IProps): React.ReactElement {
function updateCode(newCode?: string): void {
if(newCode === undefined) return;
lastCode = newCode;
if(editorRef.current !== null) {
lastPosition = editorRef.current.getPosition();
}
setCode(newCode);
}
@ -252,7 +278,10 @@ export function Root(props: IProps): React.ReactElement {
editorRef.current = editor;
if(editorRef.current === null) return;
const position = CursorPositions.getCursor(filename);
if(position.row !== -1)
editorRef.current.setPosition({lineNumber: position.row, column: position.column});
else if(lastPosition !== null)
editorRef.current.setPosition({lineNumber: lastPosition.lineNumber, column: lastPosition.column+1});
editorRef.current.focus();
}

@ -227,8 +227,6 @@ const Engine = {
},
indexedDb: undefined,
lastFilename: '',
lastFilenameServer: '',
// Time variables (milliseconds unix epoch time)
_lastUpdate: new Date().getTime(),
@ -254,17 +252,6 @@ const Engine = {
Engine.Display.scriptEditorContent.style.display = "block";
routing.navigateTo(Page.ScriptEditor);
if(filename !== "") {
this.lastFilename = filename;
this.lastFilenameServer = Player.getCurrentServer().hostname;
} else if(this.lastFilename !== '') {
const scripts = GetServerByHostname(this.lastFilenameServer).scripts.filter(x => x.filename === this.lastFilename);
if(scripts.length === 1) {
filename = this.lastFilename;
code = scripts[0].code;
}
}
ReactDOM.render(
<ScriptEditorRoot filename={filename} code={code} player={Player} engine={this} />,
Engine.Display.scriptEditorContent,

@ -594,10 +594,12 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
Copy Save data to Clipboard
</button>
<button id="debug-delete-scripts-link" class="a-link-button tooltip">
Delete all active scripts
Force kill all active scripts
<span class="tooltiptextleft">
Forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page.
using this, save the game and then reload the page. This is different then normal kill in that normal kill
will tell the script to shut down while force kill just removes the references to it (and it should crash on it's own).
This will not remove the files on your computer. Just forcefully kill all running instance of all scripts.
</span>
</button>
<button id="debug-soft-reset" class="a-link-button tooltip">

@ -71,7 +71,6 @@ function ScriptLogPopup(props: IProps): React.ReactElement {
event.preventDefault();
let x = event.clientX;
let y = event.clientY;
console.log(props.container.clientWidth);
let left = props.container.offsetLeft+props.container.clientWidth/2;
let top = props.container.offsetTop+props.container.clientWidth/5;
function mouseMove(event: MouseEvent): void {