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:
Martin Fournier
2022-01-03 10:32:01 -05:00
parent bdef14b029
commit 6d8df6744e
3 changed files with 54 additions and 1 deletions
+11 -1
View File
@@ -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,
}