mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 20:37:05 +02:00
Add toasts & terminal funcs to electron app
Attach functions to the window object so that the wrapper can executeJs to display messages to the player
This commit is contained in:
+11
-1
@@ -93,6 +93,16 @@ async function exportSave(window) {
|
||||
.executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true);
|
||||
}
|
||||
|
||||
async function writeTerminal(window, message, type = null) {
|
||||
await window.webContents
|
||||
.executeJavaScript(`window.appNotifier.terminal("${message}", "${type}");`, true)
|
||||
}
|
||||
|
||||
async function writeToast(window, message, type = "info", duration = 2000) {
|
||||
await window.webContents
|
||||
.executeJavaScript(`window.appNotifier.toast("${message}", "${type}", ${duration});`, true)
|
||||
}
|
||||
|
||||
function openExternal(url) {
|
||||
shell.openExternal(url);
|
||||
global.app_playerOpenedExternalLink = true;
|
||||
@@ -101,5 +111,5 @@ function openExternal(url) {
|
||||
module.exports = {
|
||||
reloadAndKill, showErrorBox, exportSave,
|
||||
attachUnresponsiveAppHandler, detachUnresponsiveAppHandler,
|
||||
openExternal,
|
||||
openExternal, writeTerminal, writeToast,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user