mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 15:54:09 +02:00
Various QOL improvements and bug fixes
This commit is contained in:
+36
-10
@@ -51,6 +51,7 @@ import {StockMarket, StockSymbols, SymbolToStockMap,
|
||||
sellStock, updateStockPlayerPosition,
|
||||
shortStock, sellShort, OrderTypes,
|
||||
PositionTypes, placeOrder, cancelOrder} from "./StockMarket/StockMarket";
|
||||
import {numeralWrapper} from "./ui/numeralFormat";
|
||||
import {post} from "./ui/postToTerminal";
|
||||
import {TextFile, getTextFile, createTextFile} from "./TextFile";
|
||||
|
||||
@@ -76,6 +77,10 @@ import {yesNoBoxClose, yesNoBoxGetYesButton,
|
||||
yesNoBoxGetNoButton, yesNoBoxCreate,
|
||||
yesNoBoxOpen} from "../utils/YesNoBox";
|
||||
|
||||
import { createElement } from "../utils/uiHelpers/createElement";
|
||||
import { createPopup } from "../utils/uiHelpers/createPopup";
|
||||
import { removeElementById } from "../utils/uiHelpers/removeElementById";
|
||||
|
||||
var hasCorporationSF = false, //Source-File 3
|
||||
hasSingularitySF = false, //Source-File 4
|
||||
hasAISF = false, //Source-File 5
|
||||
@@ -2453,6 +2458,14 @@ function NetscriptFunctions(workerScript) {
|
||||
return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
|
||||
}
|
||||
},
|
||||
nFormat : function(n, format) {
|
||||
if (workerScript.checkingRam) { return 0; }
|
||||
if (isNaN(n) || isNaN(parseFloat(n)) || typeof format !== "string") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return numeralWrapper.format(parseFloat(n), format);
|
||||
},
|
||||
getTimeSinceLastAug : function() {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getTimeSinceLastAug", CONSTANTS.ScriptGetHackTimeRamCost);
|
||||
@@ -2467,19 +2480,32 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
if (!isString(txt)) {txt = String(txt);}
|
||||
var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
|
||||
yesBtn.innerHTML = "Yes";
|
||||
noBtn.innerHTML = "No";
|
||||
|
||||
// The id for this popup will consist of the first 20 characters of the prompt string..
|
||||
// Thats hopefully good enough to be unique
|
||||
const popupId = `prompt-popup-${txt.slice(0, 20)}`;
|
||||
const textElement = createElement("p", { innerHTML: txt });
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
yesBtn.addEventListener("click", ()=>{
|
||||
yesNoBoxClose();
|
||||
resolve(true);
|
||||
const yesBtn = createElement("button", {
|
||||
class: "popup-box-button",
|
||||
innerText: "Yes",
|
||||
clickListener: () => {
|
||||
removeElementById(popupId);
|
||||
resolve(true);
|
||||
},
|
||||
});
|
||||
noBtn.addEventListener("click", ()=>{
|
||||
yesNoBoxClose();
|
||||
resolve(false);
|
||||
|
||||
const noBtn = createElement("button", {
|
||||
class: "popup-box-button",
|
||||
innerText: "No",
|
||||
clickListener: () => {
|
||||
removeElementById(popupId);
|
||||
resolve(false);
|
||||
},
|
||||
});
|
||||
yesNoBoxCreate(txt);
|
||||
|
||||
createPopup(popupId, [textElement, yesBtn, noBtn]);
|
||||
});
|
||||
},
|
||||
wget : async function(url, target, ip=workerScript.serverIp) {
|
||||
|
||||
Reference in New Issue
Block a user