Merge branch 'dev' into feat/add-vim-mode

This commit is contained in:
Billy Vong 2021-12-17 12:38:16 -05:00
commit cdd85c09e1
14 changed files with 118 additions and 45 deletions

36
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -7,6 +7,8 @@ if (greenworks.init()) {
console.log("Steam API has failed to initialize."); console.log("Steam API has failed to initialize.");
} }
console.log(greenworks.shutdown);
const debug = false; const debug = false;
function createWindow(killall) { function createWindow(killall) {
@ -45,6 +47,7 @@ function createWindow(killall) {
greenworks.activateAchievement(ach, () => undefined); greenworks.activateAchievement(ach, () => undefined);
} }
}, 1000); }, 1000);
win.achievementsIntervalID = intervalID;
// Create the Application's main menu // Create the Application's main menu
Menu.setApplicationMenu( Menu.setApplicationMenu(
@ -74,6 +77,7 @@ function createWindow(killall) {
{ {
label: "reload & kill all scripts", label: "reload & kill all scripts",
click: () => { click: () => {
setStopProcessHandler(app, win, false);
if (intervalID) clearInterval(intervalID); if (intervalID) clearInterval(intervalID);
win.webContents.forcefullyCrashRenderer(); win.webContents.forcefullyCrashRenderer();
win.close(); win.close();
@ -109,8 +113,35 @@ function createWindow(killall) {
}, },
]), ]),
); );
return win;
}
function setStopProcessHandler(app, window, enabled) {
const clearWindowHandler = () => {
if (window.achievementsIntervalID) {
clearInterval(window.achievementsIntervalID);
}
window = null;
};
const stopProcessHandler = () => {
if (process.platform !== "darwin") {
app.quit();
process.exit(0);
}
};
if (enabled) {
window.on("closed", clearWindowHandler);
app.on("window-all-closed", stopProcessHandler);
} else {
window.removeListener("closed", clearWindowHandler);
app.removeListener("window-all-closed", stopProcessHandler);
}
} }
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow(false); const win = createWindow(false);
setStopProcessHandler(app, win, true);
}); });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -110,6 +110,6 @@
"watch": "webpack --watch --mode production", "watch": "webpack --watch --mode production",
"watch:dev": "webpack --watch --mode development", "watch:dev": "webpack --watch --mode development",
"electron": "cp -r electron/* .package && cp index.html .package && cp main.bundle.js .package && cp dist/vendor.bundle.js .package/dist/ && cp -r dist/ext .package/dist/ && electron-packager .package bitburner --all --out .build --overwrite --icon .package/icon.png", "electron": "cp -r electron/* .package && cp index.html .package && cp main.bundle.js .package && cp dist/vendor.bundle.js .package/dist/ && cp -r dist/ext .package/dist/ && electron-packager .package bitburner --all --out .build --overwrite --icon .package/icon.png",
"allbuild": "npm run build && npm run electron && git add --all && git commit --amend --no-edit" "allbuild": "npm run build && npm run electron && git add --all && git commit --amend --no-edit && git push -f -u origin dev"
} }
} }

@ -1,2 +1,2 @@
// Defined by webpack on startup or compilation // Defined by webpack on startup or compilation
declare const __COMMIT_HASH__: string; declare let __COMMIT_HASH__: string;

@ -55,6 +55,7 @@ import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { KEY } from "../../utils/helpers/keyCodes"; import { KEY } from "../../utils/helpers/keyCodes";
import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot"; import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot";
import { InvitationsSeen } from "../../Faction/ui/FactionsRoot"; import { InvitationsSeen } from "../../Faction/ui/FactionsRoot";
import { hash } from "../../hash/hash";
const openedMixin = (theme: Theme): CSSObject => ({ const openedMixin = (theme: Theme): CSSObject => ({
width: theme.spacing(31), width: theme.spacing(31),
@ -338,11 +339,13 @@ export function SidebarRoot(props: IProps): React.ReactElement {
<ListItemIcon> <ListItemIcon>
{!open ? <ChevronRightIcon color="primary" /> : <ChevronLeftIcon color="primary" />} {!open ? <ChevronRightIcon color="primary" /> : <ChevronLeftIcon color="primary" />}
</ListItemIcon> </ListItemIcon>
<ListItemText primary={ <ListItemText
<Tooltip title={__COMMIT_HASH__}> primary={
<Typography>Bitburner v{CONSTANTS.VersionString}</Typography> <Tooltip title={hash()}>
<Typography>Bitburner v{CONSTANTS.VersionString}</Typography>
</Tooltip> </Tooltip>
} /> }
/>
</ListItem> </ListItem>
<Divider /> <Divider />
<List> <List>

@ -69,6 +69,7 @@ import { top } from "./commands/top";
import { unalias } from "./commands/unalias"; import { unalias } from "./commands/unalias";
import { weaken } from "./commands/weaken"; import { weaken } from "./commands/weaken";
import { wget } from "./commands/wget"; import { wget } from "./commands/wget";
import { hash } from "../hash/hash";
export class Terminal implements ITerminal { export class Terminal implements ITerminal {
// Flags to determine whether the player is currently running a hack or an analyze // Flags to determine whether the player is currently running a hack or an analyze
@ -77,7 +78,9 @@ export class Terminal implements ITerminal {
commandHistory: string[] = []; commandHistory: string[] = [];
commandHistoryIndex = 0; commandHistoryIndex = 0;
outputHistory: (Output | Link | RawOutput)[] = [new Output(`Bitburner v${CONSTANTS.VersionString} (${__COMMIT_HASH__})`, "primary")]; outputHistory: (Output | Link | RawOutput)[] = [
new Output(`Bitburner v${CONSTANTS.VersionString} (${hash()})`, "primary"),
];
// True if a Coding Contract prompt is opened // True if a Coding Contract prompt is opened
contractOpen = false; contractOpen = false;
@ -555,7 +558,7 @@ export class Terminal implements ITerminal {
} }
clear(): void { clear(): void {
this.outputHistory = [new Output(`Bitburner v${CONSTANTS.VersionString} (${__COMMIT_HASH__})`, "primary")]; this.outputHistory = [new Output(`Bitburner v${CONSTANTS.VersionString} (${hash()})`, "primary")];
TerminalEvents.emit(); TerminalEvents.emit();
TerminalClearEvents.emit(); TerminalClearEvents.emit();
} }
@ -668,6 +671,12 @@ export class Terminal implements ITerminal {
return; return;
} }
break; break;
case iTutorialSteps.TerminalHackingMechanics:
if (commandArray.length !== 1 || !["grow", "weaken", "hack"].includes(commandArray[0] + "")) {
this.error("Bad command. Please follow the tutorial");
return;
}
break;
case iTutorialSteps.TerminalGoHome: case iTutorialSteps.TerminalGoHome:
if (commandArray.length == 1 && commandArray[0] == "home") { if (commandArray.length == 1 && commandArray[0] == "home") {
iTutorialNextStep(); iTutorialNextStep();

@ -20,7 +20,7 @@ const useStyles = makeStyles((theme: Theme) =>
margin: theme.spacing(0), margin: theme.spacing(0),
}, },
input: { input: {
backgroundColor: "#000", backgroundColor: theme.colors.backgroundprimary,
}, },
nopadding: { nopadding: {
padding: theme.spacing(0), padding: theme.spacing(0),

@ -1,20 +1,28 @@
import React from "react"; import React, { useState } from "react";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Link from "@mui/material/Link"; import Link from "@mui/material/Link";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import { ConfirmationModal } from "../../ui/React/ConfirmationModal";
interface IProps { interface IProps {
reactivateTutorial: () => void; reactivateTutorial: () => void;
} }
export function TutorialRoot(props: IProps): React.ReactElement { export function TutorialRoot(props: IProps): React.ReactElement {
const [confirmResetOpen, setConfirmResetOpen] = useState(false);
return ( return (
<> <>
<Typography variant="h4">Tutorial / Documentation</Typography> <Typography variant="h4">Tutorial / Documentation</Typography>
<Box m={2}> <Box m={2}>
<Button onClick={props.reactivateTutorial}>Soft reset and Restart tutorial</Button> <Button onClick={() => setConfirmResetOpen(true)}>Soft reset and Restart tutorial</Button>
<ConfirmationModal
open={confirmResetOpen}
onClose={() => setConfirmResetOpen(false)}
onConfirm={props.reactivateTutorial}
confirmationText={"This will reset all your stats to 1 and money to 1k. Are you sure?"}
/>
<Link <Link
color="primary" color="primary"
target="_blank" target="_blank"
@ -94,6 +102,14 @@ export function TutorialRoot(props: IProps): React.ReactElement {
<Link color="primary" target="_blank" href="https://bitburner.readthedocs.io/en/latest/shortcuts.html"> <Link color="primary" target="_blank" href="https://bitburner.readthedocs.io/en/latest/shortcuts.html">
<Typography>Keyboard Shortcuts</Typography> <Typography>Keyboard Shortcuts</Typography>
</Link> </Link>
<br />
<Link
color="primary"
target="_blank"
href="https://bitburner.readthedocs.io/en/latest/netscript/netscriptlearntoprogram.html#netscript-1-0-vs-netscript-2-0"
>
<Typography>NS1 vs NS1 (or .script vs .js)</Typography>
</Link>
</Box> </Box>
</> </>
); );

8
src/hash/hash.ts Normal file

@ -0,0 +1,8 @@
export function hash(): string {
try {
if (__COMMIT_HASH__) {
return __COMMIT_HASH__;
}
} catch (err) {}
return "DEV";
}

@ -12,6 +12,7 @@ import { CopyableText } from "../React/CopyableText";
import ListItem from "@mui/material/ListItem"; import ListItem from "@mui/material/ListItem";
import EqualizerIcon from "@mui/icons-material/Equalizer"; import EqualizerIcon from "@mui/icons-material/Equalizer";
import LastPageIcon from "@mui/icons-material/LastPage"; import LastPageIcon from "@mui/icons-material/LastPage";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import HelpIcon from "@mui/icons-material/Help"; import HelpIcon from "@mui/icons-material/Help";
import AccountTreeIcon from "@mui/icons-material/AccountTree"; import AccountTreeIcon from "@mui/icons-material/AccountTree";
import StorageIcon from "@mui/icons-material/Storage"; import StorageIcon from "@mui/icons-material/Storage";
@ -58,6 +59,9 @@ export function InteractiveTutorialRoot(): React.ReactElement {
<br /> <br />
<br /> <br />
This tutorial will show you the basics of the game. You may skip the tutorial at any time. This tutorial will show you the basics of the game. You may skip the tutorial at any time.
<br />
<br />
You can also click the eye symbol <VisibilityOffIcon /> to temporarily hide this tutorial.
</Typography> </Typography>
</> </>
), ),
@ -287,7 +291,9 @@ export function InteractiveTutorialRoot(): React.ReactElement {
The amount of money on a server is not limitless. So, if you constantly hack a server and deplete its money, The amount of money on a server is not limitless. So, if you constantly hack a server and deplete its money,
then you will encounter diminishing returns in your hacking. You will need to use{" "} then you will encounter diminishing returns in your hacking. You will need to use{" "}
<Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> grow"}</Typography> <Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> grow"}</Typography>
and <Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> weaken"}</Typography> which tricks the company into adding money to their server and{" "}
<Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> weaken"}</Typography>
which increases the speed of hack and grow.
</Typography> </Typography>
), ),
canNext: true, canNext: true,
@ -345,10 +351,6 @@ export function InteractiveTutorialRoot(): React.ReactElement {
continuously hack the n00dles server. continuously hack the n00dles server.
<br /> <br />
<br /> <br />
If you're an intermediate programmer you should use ns2 instead. It is much faster and offers more
possibilities.
<br />
<br />
To save and close the script editor, press the button in the bottom left, or press ctrl + b. To save and close the script editor, press the button in the bottom left, or press ctrl + b.
</Typography> </Typography>
</> </>
@ -447,7 +449,11 @@ export function InteractiveTutorialRoot(): React.ReactElement {
<br /> <br />
<br /> <br />
If you know even a little bit of programming it is highly recommended you use NS2 instead. You will enjoy If you know even a little bit of programming it is highly recommended you use NS2 instead. You will enjoy
the game much more. the game much more. NS1 files end with .script and are a subset of javascript. NS2 files end with .js and
are full speed native javascript.
<br />
<br />
You can learn more about the difference between them later in the documentation.
<br /> <br />
<br /> <br />
For now, let's move on to something else! For now, let's move on to something else!

@ -15,6 +15,7 @@ import { GameRoot } from "./GameRoot";
import { CONSTANTS } from "../Constants"; import { CONSTANTS } from "../Constants";
import { ActivateRecoveryMode } from "./React/RecoveryRoot"; import { ActivateRecoveryMode } from "./React/RecoveryRoot";
import { hash } from "../hash/hash";
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
@ -69,7 +70,9 @@ export function LoadingScreen(): React.ReactElement {
<CircularProgress size={150} color="primary" /> <CircularProgress size={150} color="primary" />
</Grid> </Grid>
<Grid item> <Grid item>
<Typography variant="h3">Loading Bitburner v{CONSTANTS.VersionString} ({__COMMIT_HASH__})</Typography> <Typography variant="h3">
Loading Bitburner v{CONSTANTS.VersionString} ({hash()})
</Typography>
</Grid> </Grid>
{show && ( {show && (
<Grid item> <Grid item>

@ -44,10 +44,7 @@ module.exports = (env, argv) => {
// Get the current commit hash to inject into the app // Get the current commit hash to inject into the app
// https://stackoverflow.com/a/38401256 // https://stackoverflow.com/a/38401256
const commitHash = require('child_process') const commitHash = require("child_process").execSync("git rev-parse --short HEAD").toString().trim();
.execSync('git rev-parse --short HEAD')
.toString()
.trim();
return { return {
plugins: [ plugins: [
@ -113,7 +110,7 @@ module.exports = (env, argv) => {
}, },
}), }),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
__COMMIT_HASH__: JSON.stringify(commitHash) __COMMIT_HASH__: JSON.stringify(commitHash || "DEV"),
}), }),
// In dev mode, use a faster method of create sourcemaps // In dev mode, use a faster method of create sourcemaps
// while keeping lines/columns accurate // while keeping lines/columns accurate