mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Merge branch 'dev' of https://github.com/danielyxie/bitburner into dev
This commit is contained in:
commit
e6959bfaad
@ -11,6 +11,7 @@
|
||||
/* Remove default <button> styling */
|
||||
button {
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.a-link-button,
|
||||
|
@ -53,26 +53,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
#interactive-tutorial-exit {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#interactive-tutorial-back {
|
||||
margin-right: 20%;
|
||||
float: right;
|
||||
}
|
||||
*/
|
||||
#interactive-tutorial-exit {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#interactive-tutorial-back {
|
||||
float: left;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#interactive-tutorial-next {
|
||||
float: right;
|
||||
padding: 4px;
|
||||
}
|
||||
|
2
dist/engine.bundle.js
vendored
2
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
22
dist/engine.css
vendored
22
dist/engine.css
vendored
@ -482,7 +482,8 @@ a:visited {
|
||||
*/
|
||||
/* Remove default <button> styling */
|
||||
button {
|
||||
border: none; }
|
||||
border: none;
|
||||
background-color: transparent; }
|
||||
|
||||
.a-link-button,
|
||||
.std-button {
|
||||
@ -1530,26 +1531,19 @@ button {
|
||||
text-decoration: none;
|
||||
cursor: pointer; }
|
||||
|
||||
/*
|
||||
#interactive-tutorial-exit {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#interactive-tutorial-back {
|
||||
margin-right: 20%;
|
||||
float: right;
|
||||
}
|
||||
*/
|
||||
#interactive-tutorial-exit {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0; }
|
||||
left: 0;
|
||||
padding: 4px; }
|
||||
|
||||
#interactive-tutorial-back {
|
||||
float: left; }
|
||||
float: left;
|
||||
padding: 4px; }
|
||||
|
||||
#interactive-tutorial-next {
|
||||
float: right; }
|
||||
float: right;
|
||||
padding: 4px; }
|
||||
|
||||
/* COLORS */
|
||||
/* Attributes */
|
||||
|
2
dist/vendor.bundle.js
vendored
2
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
34
index.html
34
index.html
@ -721,8 +721,8 @@
|
||||
<!-- Log Box -->
|
||||
<div id="log-box-container">
|
||||
<div id="log-box-content">
|
||||
<span id="log-box-close" class="popup-box-button"> Close </span>
|
||||
<span id="log-box-kill-script" class="popup-box-button">Kill Script</span>
|
||||
<button id="log-box-close" class="popup-box-button"> Close </button>
|
||||
<button id="log-box-kill-script" class="popup-box-button">Kill Script</button>
|
||||
<p id="log-box-text-header"> </p>
|
||||
<p id="log-box-text"> </p>
|
||||
</div>
|
||||
@ -732,8 +732,8 @@
|
||||
<div id="yes-no-box-container" class="popup-box-container">
|
||||
<div id="yes-no-box-content" class="popup-box-content">
|
||||
<p id="yes-no-box-text"> </p>
|
||||
<span id="yes-no-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="yes-no-box-no" class="popup-box-button"> No </span>
|
||||
<button id="yes-no-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="yes-no-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -742,8 +742,8 @@
|
||||
<div id="yes-no-text-input-box-content" class="popup-box-content">
|
||||
<p id="yes-no-text-input-box-text"> </p>
|
||||
<input type="text" id="yes-no-text-input-box-input" pattern="[a-zA-Z0-9-_]" maxlength="30"/>
|
||||
<span id="yes-no-text-input-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="yes-no-text-input-box-no" class="popup-box-button"> No </span>
|
||||
<button id="yes-no-text-input-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="yes-no-text-input-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -756,8 +756,8 @@
|
||||
Would you like to join? <br/> <br/>
|
||||
Warning: Joining this faction may prevent you from joining other factions during this run!
|
||||
</p>
|
||||
<span id="faction-invitation-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="faction-invitation-box-no" class="popup-box-button"> No </span>
|
||||
<button id="faction-invitation-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="faction-invitation-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -766,9 +766,9 @@
|
||||
<div id="infiltration-box-content" class="popup-box-content">
|
||||
<p id="infiltration-box-text"> </p>
|
||||
|
||||
<span id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </span> <br/><br/>
|
||||
<button id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </button> <br/><br/>
|
||||
<select id="infiltration-faction-select"> </select> <br/>
|
||||
<span id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </span>
|
||||
<button id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -781,7 +781,7 @@
|
||||
<div id="work-in-progress-container" class="generic-fullscreen-container">
|
||||
<p id="work-in-progress-text"> </p>
|
||||
|
||||
<span id="work-in-progress-cancel-button"> Cancel Work </span>
|
||||
<button id="work-in-progress-cancel-button"> Cancel Work </button>
|
||||
</div>
|
||||
|
||||
<!-- Red Pill Container -->
|
||||
@ -796,9 +796,9 @@
|
||||
<div id="interactive-tutorial-wrapper">
|
||||
<div id="interactive-tutorial-container">
|
||||
<p id="interactive-tutorial-text"> </p>
|
||||
<span id="interactive-tutorial-exit"> Exit Tutorial </span>
|
||||
<span id="interactive-tutorial-next"> Next </span>
|
||||
<span id="interactive-tutorial-back"> Back </span>
|
||||
<button id="interactive-tutorial-exit"> Exit Tutorial </button>
|
||||
<button id="interactive-tutorial-next"> Next </button>
|
||||
<button id="interactive-tutorial-back"> Back </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -837,8 +837,8 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="character-quick-options">
|
||||
<span id="character-overview-save-button">Save Game</span>
|
||||
<span id="character-overview-options-button">Options</span>
|
||||
<button id="character-overview-save-button">Save Game</button>
|
||||
<button id="character-overview-options-button">Options</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -851,7 +851,7 @@
|
||||
<!-- Game Options -->
|
||||
<div id="game-options-container" class="popup-box-container">
|
||||
<div id="game-options-content" class="game-options-box">
|
||||
<span id="game-options-close-button">×</span>
|
||||
<button id="game-options-close-button">×</button>
|
||||
<h1> Game Options </h1>
|
||||
<br/>
|
||||
<div id="game-options-left-panel">
|
||||
|
@ -54,14 +54,13 @@ export async function executeJSScript(scripts = [], workerScript) {
|
||||
//
|
||||
// - script -- the script for whom we are getting a URL.
|
||||
// - scripts -- all the scripts available on this server
|
||||
// - envHeader -- the preamble that goes at the start of every NSJS script.
|
||||
// - seen -- The modules above this one -- to prevent mutual dependency.
|
||||
//
|
||||
// TODO We don't make any effort to cache a given module when it is imported at
|
||||
// different parts of the tree. That hasn't presented any problem with during
|
||||
// testing, but it might be an idea for the future. Would require a topo-sort
|
||||
// then url-izing from leaf-most to root-most.
|
||||
function _getScriptUrls(script, scripts, seen) {
|
||||
export function _getScriptUrls(script, scripts, seen) {
|
||||
// Inspired by: https://stackoverflow.com/a/43834063/91401
|
||||
const urlStack = [];
|
||||
seen.push(script);
|
||||
@ -90,7 +89,8 @@ function _getScriptUrls(script, scripts, seen) {
|
||||
// The top url in the stack is the replacement import file for this script.
|
||||
urlStack.push(...urls);
|
||||
return [prefix, urls[urls.length - 1], suffix].join('');
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// If we successfully transformed the code, create a blob url for it and
|
||||
|
@ -24,8 +24,7 @@ import {iTutorialSteps, iTutorialNextStep,
|
||||
ITutorial} from "./InteractiveTutorial";
|
||||
import {evaluateImport} from "./NetscriptEvaluator";
|
||||
import {NetscriptFunctions} from "./NetscriptFunctions";
|
||||
import {addWorkerScript,
|
||||
WorkerScript} from "./NetscriptWorker";
|
||||
import {addWorkerScript, WorkerScript} from "./NetscriptWorker";
|
||||
import {Player} from "./Player";
|
||||
import {AllServers, processSingleServerGrowth} from "./Server";
|
||||
import {Settings} from "./Settings";
|
||||
@ -240,7 +239,7 @@ function scriptEditorInit() {
|
||||
}
|
||||
|
||||
//Updates RAM usage in script
|
||||
function updateScriptEditorContent() {
|
||||
async function updateScriptEditorContent() {
|
||||
var filename = document.getElementById("script-editor-filename").value;
|
||||
if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !isScriptFilename(filename)) {
|
||||
scriptEditorRamText.innerText = "N/A";
|
||||
@ -249,7 +248,7 @@ function updateScriptEditorContent() {
|
||||
var editor = ace.edit('javascript-editor');
|
||||
var code = editor.getValue();
|
||||
var codeCopy = code.repeat(1);
|
||||
var ramUsage = calculateRamUsage(codeCopy);
|
||||
var ramUsage = await calculateRamUsage(codeCopy);
|
||||
if (ramUsage !== -1) {
|
||||
scriptEditorRamText.innerText = "RAM: " + numeralWrapper.format(ramUsage, '0.00') + " GB";
|
||||
} else {
|
||||
@ -402,9 +401,9 @@ Script.prototype.saveScript = function() {
|
||||
}
|
||||
|
||||
//Updates how much RAM the script uses when it is running.
|
||||
Script.prototype.updateRamUsage = function() {
|
||||
Script.prototype.updateRamUsage = async function() {
|
||||
var codeCopy = this.code.repeat(1);
|
||||
var res = calculateRamUsage(codeCopy);
|
||||
var res = await calculateRamUsage(codeCopy);
|
||||
if (res !== -1) {
|
||||
this.ramUsage = roundToTwo(res);
|
||||
}
|
||||
@ -422,7 +421,7 @@ const memCheckGlobalKey = ".__GLOBAL__";
|
||||
// Calcluates the amount of RAM a script uses. Uses parsing and AST walking only,
|
||||
// rather than NetscriptEvaluator. This is useful because NetscriptJS code does
|
||||
// not work under NetscriptEvaluator.
|
||||
function parseOnlyRamCalculate(server, code, workerScript) {
|
||||
async function parseOnlyRamCalculate(server, code, workerScript) {
|
||||
try {
|
||||
// Maps dependent identifiers to their dependencies.
|
||||
//
|
||||
@ -465,11 +464,27 @@ function parseOnlyRamCalculate(server, code, workerScript) {
|
||||
// Get the code from the server.
|
||||
const nextModule = parseQueue.shift();
|
||||
|
||||
const script = server.getScript(nextModule);
|
||||
if (!script) return -1; // No such script on the server.
|
||||
let code;
|
||||
if (nextModule.startsWith("https://")) {
|
||||
try {
|
||||
const module = await eval('import(nextModule)');
|
||||
code = "";
|
||||
for (const prop in module) {
|
||||
if (typeof module[prop] === 'function') {
|
||||
code += module[prop].toString() + ";\n";
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(`Error dynamically importing module from ${nextModule} for RAM calculations: ${e}`);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
const script = server.getScript(nextModule);
|
||||
if (!script) return -1; // No such script on the server.
|
||||
code = script.code;
|
||||
}
|
||||
|
||||
// Not sure why we always take copies, but let's do that here too.
|
||||
parseCode(script.code.repeat(1), nextModule);
|
||||
parseCode(code, nextModule);
|
||||
}
|
||||
|
||||
// Finally, walk the reference map and generate a ram cost. The initial set of keys to scan
|
||||
@ -551,7 +566,7 @@ function parseOnlyRamCalculate(server, code, workerScript) {
|
||||
return ram;
|
||||
|
||||
} catch (error) {
|
||||
//console.info("parse or eval error: ", error);
|
||||
// console.info("parse or eval error: ", error);
|
||||
// This is not unexpected. The user may be editing a script, and it may be in
|
||||
// a transitory invalid state.
|
||||
return -1;
|
||||
@ -688,7 +703,7 @@ function parseOnlyCalculateDeps(code, currentModule) {
|
||||
return {dependencyMap: dependencyMap, additionalModules: additionalModules};
|
||||
}
|
||||
|
||||
function calculateRamUsage(codeCopy) {
|
||||
async function calculateRamUsage(codeCopy) {
|
||||
//Create a temporary/mock WorkerScript and an AST from the code
|
||||
var currServ = Player.getCurrentServer();
|
||||
var workerScript = new WorkerScript({
|
||||
@ -700,7 +715,7 @@ function calculateRamUsage(codeCopy) {
|
||||
workerScript.serverIp = currServ.ip;
|
||||
|
||||
try {
|
||||
return parseOnlyRamCalculate(currServ, codeCopy, workerScript);
|
||||
return await parseOnlyRamCalculate(currServ, codeCopy, workerScript);
|
||||
} catch (e) {
|
||||
console.log("Failed to parse ram using new method. Falling back.", e);
|
||||
}
|
||||
@ -862,7 +877,6 @@ function scriptCalculateOfflineProduction(runningScriptObj) {
|
||||
var thisUpdate = new Date().getTime();
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds
|
||||
console.log("Offline for " + timePassed + " seconds");
|
||||
|
||||
//Calculate the "confidence" rating of the script's true production. This is based
|
||||
//entirely off of time. We will arbitrarily say that if a script has been running for
|
||||
|
@ -725,8 +725,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<!-- Log Box -->
|
||||
<div id="log-box-container">
|
||||
<div id="log-box-content">
|
||||
<span id="log-box-close" class="popup-box-button"> Close </span>
|
||||
<span id="log-box-kill-script" class="popup-box-button">Kill Script</span>
|
||||
<button id="log-box-close" class="popup-box-button"> Close </button>
|
||||
<button id="log-box-kill-script" class="popup-box-button">Kill Script</button>
|
||||
<p id="log-box-text-header"> </p>
|
||||
<p id="log-box-text"> </p>
|
||||
</div>
|
||||
@ -736,8 +736,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<div id="yes-no-box-container" class="popup-box-container">
|
||||
<div id="yes-no-box-content" class="popup-box-content">
|
||||
<p id="yes-no-box-text"> </p>
|
||||
<span id="yes-no-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="yes-no-box-no" class="popup-box-button"> No </span>
|
||||
<button id="yes-no-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="yes-no-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -746,8 +746,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<div id="yes-no-text-input-box-content" class="popup-box-content">
|
||||
<p id="yes-no-text-input-box-text"> </p>
|
||||
<input type="text" id="yes-no-text-input-box-input" pattern="[a-zA-Z0-9-_]" maxlength="30" />
|
||||
<span id="yes-no-text-input-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="yes-no-text-input-box-no" class="popup-box-button"> No </span>
|
||||
<button id="yes-no-text-input-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="yes-no-text-input-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -760,8 +760,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
Would you like to join? <br /> <br />
|
||||
Warning: Joining this faction may prevent you from joining other factions during this run!
|
||||
</p>
|
||||
<span id="faction-invitation-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="faction-invitation-box-no" class="popup-box-button"> No </span>
|
||||
<button id="faction-invitation-box-yes" class="popup-box-button"> Yes </button>
|
||||
<button id="faction-invitation-box-no" class="popup-box-button"> No </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -770,9 +770,9 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<div id="infiltration-box-content" class="popup-box-content">
|
||||
<p id="infiltration-box-text"> </p>
|
||||
|
||||
<span id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </span> <br /><br />
|
||||
<button id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </button> <br /><br />
|
||||
<select id="infiltration-faction-select"> </select> <br />
|
||||
<span id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </span>
|
||||
<button id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -785,7 +785,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<div id="work-in-progress-container" class="generic-fullscreen-container">
|
||||
<p id="work-in-progress-text"> </p>
|
||||
|
||||
<span id="work-in-progress-cancel-button"> Cancel Work </span>
|
||||
<button id="work-in-progress-cancel-button"> Cancel Work </button>
|
||||
</div>
|
||||
|
||||
<!-- Red Pill Container -->
|
||||
@ -800,9 +800,9 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<div id="interactive-tutorial-wrapper">
|
||||
<div id="interactive-tutorial-container">
|
||||
<p id="interactive-tutorial-text"> </p>
|
||||
<span id="interactive-tutorial-exit"> Exit Tutorial </span>
|
||||
<span id="interactive-tutorial-next"> Next </span>
|
||||
<span id="interactive-tutorial-back"> Back </span>
|
||||
<button id="interactive-tutorial-exit"> Exit Tutorial </button>
|
||||
<button id="interactive-tutorial-next"> Next </button>
|
||||
<button id="interactive-tutorial-back"> Back </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -841,8 +841,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
</table>
|
||||
</div>
|
||||
<div class="character-quick-options">
|
||||
<span id="character-overview-save-button">Save Game</span>
|
||||
<span id="character-overview-options-button">Options</span>
|
||||
<button id="character-overview-save-button">Save Game</button>
|
||||
<button id="character-overview-options-button">Options</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -855,7 +855,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
||||
<!-- Game Options -->
|
||||
<div id="game-options-container" class="popup-box-container">
|
||||
<div id="game-options-content" class="game-options-box">
|
||||
<span id="game-options-close-button">×</span>
|
||||
<button id="game-options-close-button">×</button>
|
||||
<h1> Game Options </h1>
|
||||
<br />
|
||||
<div id="game-options-left-panel">
|
||||
|
Loading…
Reference in New Issue
Block a user