mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Add ns.ui.getGameInfo() to retrieve game version
Returns { version, commit, platform }
This commit is contained in:
parent
8b69fd7faa
commit
07403eaaaa
@ -368,6 +368,7 @@ export const RamCosts: IMap<any> = {
|
|||||||
getStyles: 0,
|
getStyles: 0,
|
||||||
setStyles: 0,
|
setStyles: 0,
|
||||||
resetStyles: 0,
|
resetStyles: 0,
|
||||||
|
getGameInfo: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
heart: {
|
heart: {
|
||||||
|
@ -2,11 +2,13 @@ import { INetscriptHelper } from "./INetscriptHelper";
|
|||||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||||
import { IStyleSettings, UserInterface as IUserInterface, UserInterfaceTheme } from "../ScriptEditor/NetscriptDefinitions";
|
import { GameInfo, IStyleSettings, UserInterface as IUserInterface, UserInterfaceTheme } from "../ScriptEditor/NetscriptDefinitions";
|
||||||
import { Settings } from "../Settings/Settings";
|
import { Settings } from "../Settings/Settings";
|
||||||
import { ThemeEvents } from "../ui/React/Theme";
|
import { ThemeEvents } from "../ui/React/Theme";
|
||||||
import { defaultTheme } from "../Settings/Themes";
|
import { defaultTheme } from "../Settings/Themes";
|
||||||
import { defaultStyles } from "../Settings/Styles";
|
import { defaultStyles } from "../Settings/Styles";
|
||||||
|
import { CONSTANTS } from "../Constants";
|
||||||
|
import { hash } from "../hash/hash";
|
||||||
|
|
||||||
export function NetscriptUserInterface(
|
export function NetscriptUserInterface(
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
@ -84,6 +86,19 @@ export function NetscriptUserInterface(
|
|||||||
Settings.styles = { ...defaultStyles };
|
Settings.styles = { ...defaultStyles };
|
||||||
ThemeEvents.emit();
|
ThemeEvents.emit();
|
||||||
workerScript.log("ui.resetStyles", () => `Reinitialized styles to default`);
|
workerScript.log("ui.resetStyles", () => `Reinitialized styles to default`);
|
||||||
|
},
|
||||||
|
|
||||||
|
getGameInfo: function (): GameInfo {
|
||||||
|
helper.updateDynamicRam("getGameInfo", getRamCost(player, "ui", "getGameInfo"));
|
||||||
|
const version = CONSTANTS.VersionString;
|
||||||
|
const commit = hash();
|
||||||
|
const platform = (navigator.userAgent.toLowerCase().indexOf(" electron/") > -1) ? 'Steam' : 'Browser';
|
||||||
|
|
||||||
|
const gameInfo = {
|
||||||
|
version, commit, platform,
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
17
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -4065,6 +4065,13 @@ interface UserInterface {
|
|||||||
* RAM cost: cost: 0 GB
|
* RAM cost: cost: 0 GB
|
||||||
*/
|
*/
|
||||||
resetStyles(): void;
|
resetStyles(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current game information (version, commit, ...)
|
||||||
|
* @remarks
|
||||||
|
* RAM cost: 0 GB
|
||||||
|
*/
|
||||||
|
getGameInfo(): GameInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6573,3 +6580,13 @@ interface IStyleSettings {
|
|||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
lineHeight: number;
|
lineHeight: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Game Information
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
interface GameInfo {
|
||||||
|
version: string;
|
||||||
|
commit: string;
|
||||||
|
platform: string;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user