mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 05:33:54 +01:00
v0.28.0 Changed - Integrate ACE editor
This commit is contained in:
parent
fd2642cfe9
commit
b17f89eba7
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
Changelog.txt
|
||||
Netburner.txt
|
||||
README.md
|
||||
README.md
|
||||
/node_modules
|
@ -40,6 +40,7 @@
|
||||
-moz-box-shadow: 1px 1px 3px #000;
|
||||
-webkit-box-shadow: 1px 1px 3px #000;
|
||||
box-shadow: 1px 1px 3px #000;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
#interactive-tutorial-exit {
|
||||
@ -65,4 +66,3 @@
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,42 @@
|
||||
}
|
||||
|
||||
/* Script Editor */
|
||||
#script-editor-container {
|
||||
background-color:transparent;
|
||||
}
|
||||
#javascript-editor {
|
||||
margin: 10px;
|
||||
|
||||
height: 80%;
|
||||
width: 100%;
|
||||
margin-left: 6px;
|
||||
|
||||
padding-left: 6px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
z-index: 1;
|
||||
font-family: 'Lucida Console', 'Lucida Sans Unicode', 'Fira Mono', 'Consolas', 'Courier New', Courier, monospace, 'Times New Roman';
|
||||
}
|
||||
|
||||
#javascript-editor textarea {
|
||||
color: var(--my-font-color);
|
||||
}
|
||||
|
||||
.ace_line,
|
||||
.ace_line * {
|
||||
color: var(--my-font-color);
|
||||
background-color:transparent;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
.ace_text-input {
|
||||
font-size:16px;
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
/* This temp element is used for auto adjusting filename field */
|
||||
.tmp-element {
|
||||
visibility: hidden;
|
||||
@ -56,6 +92,7 @@
|
||||
#script-editor-wrapper {
|
||||
height:100%;
|
||||
width: 70%;
|
||||
background:transparent;
|
||||
}
|
||||
|
||||
#script-editor-filename-wrapper {
|
||||
@ -103,28 +140,6 @@
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#script-editor-text {
|
||||
color: var(--my-font-color);
|
||||
height: 80%;
|
||||
width: 100%;
|
||||
margin-left: 6px;
|
||||
|
||||
padding-left: 6px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
/* Active scripts */
|
||||
.active-scripts-list {
|
||||
list-style-type: none;
|
||||
@ -261,6 +276,7 @@
|
||||
box-shadow: 1px 1px 3px #000;
|
||||
margin: 4px;
|
||||
padding: 4px;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
.active-scripts-button:hover,
|
||||
|
@ -29,6 +29,7 @@
|
||||
padding: 2px;
|
||||
margin: 6px;
|
||||
border: 1px solid white;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
.popup-box-button:hover,
|
||||
@ -43,6 +44,12 @@
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#yes-no-text-input-box-input {
|
||||
color: var(--my-font-color);
|
||||
border: 1px solid white;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
.dialog-box-container,
|
||||
#log-box-container {
|
||||
display: block;
|
||||
@ -94,20 +101,6 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Purchase server box */
|
||||
#purchase-server-box-container {
|
||||
transition: opacity 400ms ease-in;
|
||||
}
|
||||
|
||||
#purchase-server-box-input {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Purchase Augmentation Box */
|
||||
#purchase-augmentation-box-container {
|
||||
transition: opacity 400ms ease-in;
|
||||
}
|
||||
|
||||
/* Faction invitation box */
|
||||
#faction-invitation-box-container {
|
||||
transition: opacity 400ms ease-in;
|
||||
|
@ -1,20 +1,20 @@
|
||||
/** This removes all padding and margins as well as
|
||||
setting a default font size and family for the page **/
|
||||
|
||||
|
||||
:root{
|
||||
--my-font-color: #66ff33;
|
||||
--my-background-color: #000000;
|
||||
--my-highlight-color: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 16px;
|
||||
font-family: 'Lucida Console', 'Lucida Sans Unicode', 'Fira Mono', 'Consolas', 'Courier New', Courier, monospace, 'Times New Roman';
|
||||
/*background-color: #252527;*/
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--my-background-color);
|
||||
}
|
||||
|
||||
@ -41,6 +41,10 @@ span {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
#entire-game-container {
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
/* Disable border highlight on elements */
|
||||
input:focus,
|
||||
textarea:focus,
|
||||
@ -346,6 +350,7 @@ a:link, a:visited {
|
||||
-webkit-box-shadow: 1px 1px 3px #000;
|
||||
box-shadow: 1px 1px 3px #000;
|
||||
height: 22px;
|
||||
background-color:black;
|
||||
}
|
||||
|
||||
#character-overview-save-button:hover,
|
||||
|
21130
dist/bundle.js
vendored
21130
dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
35
index.html
35
index.html
@ -89,6 +89,24 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="script-editor-container" class="generic-menupage-container">
|
||||
<div id="script-editor-wrapper">
|
||||
|
||||
<div id="script-editor-filename-wrapper">
|
||||
<p id="script-editor-filename-tag"> <strong style="background-color:#555;">Script name: </strong></p>
|
||||
<input id="script-editor-filename" type="text" maxlength="30" tabindex="1"> </input>
|
||||
</div>
|
||||
|
||||
<div id="javascript-editor"></div>
|
||||
|
||||
<div id="script-editor-buttons-wrapper">
|
||||
<span id="script-editor-save-and-close-button" class="a-link-button">Save & Close (Ctrl + b)</span>
|
||||
<p id="script-editor-status-text"> </p>
|
||||
<a id="script-editor-netscript-doc-button" class="a-link-button" href="https://bitburner.wikia.com/wiki/Netscript" target="_blank"> Netscript Documentation </a>
|
||||
</div>
|
||||
</div> <!-- End wrapper -->
|
||||
</div>
|
||||
|
||||
<!-- Terminal page -->
|
||||
<div id="terminal-container">
|
||||
<table id="terminal">
|
||||
@ -108,23 +126,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Script editor -->
|
||||
<div id="script-editor-container" class="generic-menupage-container">
|
||||
<div id="script-editor-wrapper">
|
||||
<div id="script-editor-filename-wrapper">
|
||||
<p id="script-editor-filename-tag"> <strong style="background-color:#555;">Script name: </strong></p>
|
||||
<input id="script-editor-filename" type="text" maxlength="30" tabindex="1"> </input>
|
||||
</div>
|
||||
<textarea id="script-editor-text" tabindex="2" autofocus> </textarea>
|
||||
<div id="script-editor-buttons-wrapper">
|
||||
<span id="script-editor-save-and-close-button" class="a-link-button">Save & Close (Ctrl + b)</span>
|
||||
<p id="script-editor-status-text"> </p>
|
||||
<a id="script-editor-netscript-doc-button" class="a-link-button" href="https://bitburner.wikia.com/wiki/Netscript" target="_blank"> Netscript Documentation </a>
|
||||
</div>
|
||||
</div>
|
||||
<p> <br><br> </p>
|
||||
</div>
|
||||
|
||||
<!-- Active scripts info page -->
|
||||
<div id="active-scripts-container" class="generic-menupage-container">
|
||||
<p id="active-scripts-text"> This page displays a list of all of your scripts that are currently running across every machine. It also
|
||||
|
@ -1,5 +1,5 @@
|
||||
let CONSTANTS = {
|
||||
Version: "0.28.0",
|
||||
Version: "0.28.1",
|
||||
|
||||
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||
@ -395,7 +395,8 @@ let CONSTANTS = {
|
||||
"any server, regardless of where the script is running. This command requires root access to the target server, but " +
|
||||
"there is no required hacking level to run the command. Returns " +
|
||||
"0.1. Works offline at a slower rate<br> Example: weaken('foodnstuff');<br><br>" +
|
||||
"<i>print(x)</i> <br>Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ). <br><br>" +
|
||||
"<i>print(x)</i><br>Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ). <br><br>" +
|
||||
"<i>tprint(x)</i><br>Prints a value or a variable to the Terminal<br><br>" +
|
||||
"<i>clearLog()</i><br>Clears the script's logs. <br><br>" +
|
||||
"<i>scan(hostname/ip)</i><br>Returns an array containing the hostnames of all servers that are one node away from the specified server. " +
|
||||
"The argument must be a string containing the IP or hostname of the target server. The hostnames in the returned array are strings.<br><br>" +
|
||||
@ -858,6 +859,9 @@ let CONSTANTS = {
|
||||
"World Stock Exchange account and TIX API Access<br>",
|
||||
|
||||
LatestUpdate:
|
||||
"v0.28.1<br>" +
|
||||
"-The script editor now uses the open-source Ace editor, which provides a much better experience when coding!<br>" +
|
||||
"-Added tprint() Netscript function<br><br>" +
|
||||
"v0.28.0<br>" +
|
||||
"-Added BitNode-4: The Singularity<br>" +
|
||||
"-Added BitNode-11: The Big Crash<br>" +
|
||||
|
@ -23,6 +23,7 @@ import {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols,
|
||||
sellStock, updateStockPrices, displayStockMarketContent,
|
||||
updateStockTicker, updateStockPlayerPosition,
|
||||
Stock} from "./StockMarket.js";
|
||||
import {post} from "./Terminal.js";
|
||||
|
||||
import {WorkerScript, workerScripts,
|
||||
killWorkerScript, NetscriptPorts} from "./NetscriptWorker.js";
|
||||
@ -223,6 +224,12 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
workerScript.scriptRef.log(args.toString());
|
||||
},
|
||||
tprint : function(args) {
|
||||
if (args === undefined || args === null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
|
||||
}
|
||||
post(workerScript.scriptRef.filename + ": " + args.toString());
|
||||
},
|
||||
clearLog : function() {
|
||||
workerScript.scriptRef.clearLog();
|
||||
},
|
||||
@ -1696,4 +1703,4 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
}
|
||||
|
||||
export {NetscriptFunctions, initSingularitySFFlags};
|
||||
export {NetscriptFunctions, initSingularitySFFlags, hasSingularitySF};
|
||||
|
@ -1513,7 +1513,7 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
|
||||
//Cancels the player's current "work" assignment and gives the proper rewards
|
||||
//Used only for Singularity functions, so no popups are created
|
||||
PlayerObject.prototype.singularityStopWork = function() {
|
||||
if (!this.isWorking) {return null;}
|
||||
if (!this.isWorking) {return "";}
|
||||
var res; //Earnings text for work
|
||||
switch (this.workType) {
|
||||
case CONSTANTS.WorkTypeStudyClass:
|
||||
|
@ -1,3 +1,7 @@
|
||||
var ace = require('brace');
|
||||
require('brace/mode/javascript');
|
||||
require('brace/theme/monokai');
|
||||
|
||||
import {CONSTANTS} from "./Constants.js";
|
||||
import {Engine} from "./engine.js";
|
||||
import {iTutorialSteps, iTutorialNextStep,
|
||||
@ -47,14 +51,12 @@ document.addEventListener("DOMContentLoaded", scriptEditorInit, false);
|
||||
|
||||
//Updates line number and RAM usage in script
|
||||
function updateScriptEditorContent() {
|
||||
var txt = $("#script-editor-text")[0];
|
||||
var lineNum = txt.value.substr(0, txt.selectionStart).split("\n").length;
|
||||
|
||||
var code = document.getElementById("script-editor-text").value;
|
||||
var editor = ace.edit('javascript-editor');
|
||||
var code = editor.getValue();
|
||||
var codeCopy = code.repeat(1);
|
||||
var ramUsage = calculateRamUsage(codeCopy);
|
||||
document.getElementById("script-editor-status-text").innerText =
|
||||
"Line Number: " + lineNum + ", RAM: " + formatNumber(ramUsage, 2).toString() + "GB";
|
||||
"RAM: " + formatNumber(ramUsage, 2).toString() + "GB";
|
||||
}
|
||||
|
||||
//Define key commands in script editor (ctrl o to save + close, etc.)
|
||||
@ -75,7 +77,8 @@ function saveAndCloseScriptEditor() {
|
||||
dialogBoxCreate("Leave the script name as 'foodnstuff'!");
|
||||
return;
|
||||
}
|
||||
var code = document.getElementById("script-editor-text").value;
|
||||
var editor = ace.edit('javascript-editor');
|
||||
var code = editor.getValue();
|
||||
code = code.replace(/\s/g, "");
|
||||
if (code.indexOf("while(true){hack('foodnstuff');}") == -1) {
|
||||
dialogBoxCreate("Please copy and paste the code from the tutorial!");
|
||||
@ -134,7 +137,8 @@ function Script() {
|
||||
Script.prototype.saveScript = function() {
|
||||
if (Engine.currentPage == Engine.Page.ScriptEditor) {
|
||||
//Update code and filename
|
||||
var code = document.getElementById("script-editor-text").value;
|
||||
var editor = ace.edit('javascript-editor');
|
||||
var code = editor.getValue();
|
||||
this.code = code.replace(/^\s+|\s+$/g, '');
|
||||
|
||||
var filename = document.getElementById("script-editor-filename").value + ".script";
|
||||
|
@ -1,3 +1,9 @@
|
||||
var ace = require('brace');
|
||||
require('brace/mode/javascript');
|
||||
require('brace/theme/monokai');
|
||||
require('brace/theme/terminal');
|
||||
require('brace/theme/twilight');
|
||||
|
||||
import {dialogBoxCreate} from "../utils/DialogBox.js";
|
||||
import {gameOptionsBoxOpen, gameOptionsBoxClose}from "../utils/GameOptions.js";
|
||||
import {clearEventListeners} from "../utils/HelperFunctions.js";
|
||||
@ -30,7 +36,8 @@ import {initLiterature} from "./Literature.js";
|
||||
import {Locations, displayLocationContent,
|
||||
initLocationButtons} from "./Location.js";
|
||||
import {checkForMessagesToSend, initMessages} from "./Message.js";
|
||||
import {initSingularitySFFlags} from "./NetscriptFunctions.js";
|
||||
import {initSingularitySFFlags,
|
||||
hasSingularitySF} from "./NetscriptFunctions.js";
|
||||
import {updateOnlineScriptTimes,
|
||||
runScriptsLoop} from "./NetscriptWorker.js";
|
||||
import {Player} from "./Player.js";
|
||||
@ -180,9 +187,6 @@ let Engine = {
|
||||
|
||||
//Character info
|
||||
characterInfo: null,
|
||||
|
||||
//Script editor text
|
||||
scriptEditorText: null,
|
||||
},
|
||||
|
||||
//Current page status
|
||||
@ -232,11 +236,12 @@ let Engine = {
|
||||
loadScriptEditorContent: function(filename = "", code = "") {
|
||||
Engine.hideAllContent();
|
||||
Engine.Display.scriptEditorContent.style.visibility = "visible";
|
||||
var editor = ace.edit('javascript-editor');
|
||||
if (filename != "") {
|
||||
document.getElementById("script-editor-filename").value = filename;
|
||||
document.getElementById("script-editor-text").value = code;
|
||||
editor.setValue(code);
|
||||
}
|
||||
document.getElementById("script-editor-text").focus();
|
||||
editor.focus();
|
||||
updateScriptEditorContent();
|
||||
Engine.currentPage = Engine.Page.ScriptEditor;
|
||||
document.getElementById("create-script-menu-link").classList.add("active");
|
||||
@ -1013,6 +1018,13 @@ let Engine = {
|
||||
},
|
||||
|
||||
load: function() {
|
||||
//Load script editor
|
||||
var editor = ace.edit('javascript-editor');
|
||||
editor.getSession().setMode('ace/mode/javascript');
|
||||
editor.setTheme('ace/theme/monokai');
|
||||
document.getElementById('javascript-editor').style.fontSize='16px';
|
||||
editor.setOption("showPrintMargin", false);
|
||||
|
||||
//Initialize main menu accordion panels to all start as "open"
|
||||
var terminal = document.getElementById("terminal-tab");
|
||||
var createScript = document.getElementById("create-script-tab");
|
||||
@ -1271,9 +1283,6 @@ let Engine = {
|
||||
//Init Location buttons
|
||||
initLocationButtons();
|
||||
|
||||
//Script editor
|
||||
Engine.Display.scriptEditorText = document.getElementById("script-editor-text");
|
||||
|
||||
//Tutorial buttons
|
||||
Engine.Clickables.tutorialNetworkingButton = document.getElementById("tutorial-networking-link");
|
||||
Engine.Clickables.tutorialNetworkingButton.addEventListener("click", function() {
|
||||
@ -1292,7 +1301,12 @@ let Engine = {
|
||||
|
||||
Engine.Clickables.tutorialNetscriptButton = document.getElementById("tutorial-netscript-link");
|
||||
Engine.Clickables.tutorialNetscriptButton.addEventListener("click", function() {
|
||||
Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText);
|
||||
if (Player.bitNodeN === 4 || hasSingularitySF) {
|
||||
Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText + CONSTANTS.TutorialSingularityFunctionsText);
|
||||
} else {
|
||||
Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Engine.Clickables.tutorialTravelingButton = document.getElementById("tutorial-traveling-link");
|
||||
|
Loading…
Reference in New Issue
Block a user