summaryrefslogtreecommitdiff
path: root/trumagic.js
diff options
context:
space:
mode:
authorArman <[email protected]>2018-08-02 16:50:59 -0700
committerArman <[email protected]>2018-08-02 16:50:59 -0700
commit7d5a0696ccc642db0d14aae8677ecada40bf85d1 (patch)
tree1bbbcf2f4c4a3a733326ac2401375f8d891cb2f1 /trumagic.js
parentdialog box for adding items (diff)
downloadlauncher-7d5a0696ccc642db0d14aae8677ecada40bf85d1.tar.xz
launcher-7d5a0696ccc642db0d14aae8677ecada40bf85d1.zip
inital commit
Diffstat (limited to 'trumagic.js')
-rw-r--r--trumagic.js109
1 files changed, 109 insertions, 0 deletions
diff --git a/trumagic.js b/trumagic.js
new file mode 100644
index 0000000..8976232
--- /dev/null
+++ b/trumagic.js
@@ -0,0 +1,109 @@
+const electron = require('electron');
+const url = require('url');
+const path = require('path');
+const exec = require('child_process').exec;
+
+const {app, BrowserWindow, Menu, ipcMain} = electron;
+
+// SET ENV
+process.env.NODE_ENV = 'production';
+
+let mainWindow;
+
+// Listen for app to be ready
+app.on('ready', function() {
+ // Create new window
+ mainWindow = new BrowserWindow({
+ width: 800,
+ height: 600,
+ frame: false,
+ resizable: false,
+ titleBarStyle: 'hidden-inset'
+ });
+ // Load html into window
+ mainWindow.loadURL(url.format({
+ pathname: path.join(__dirname, 'mainWindow.html'),
+ protocol: 'file:',
+ slashes: true
+ }));
+
+ // Build menu from template
+ const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
+ // Insert Menu
+ Menu.setApplicationMenu(mainMenu)
+
+});
+
+
+// Catch quit
+ipcMain.on('app:quit', function(e) {
+ app.quit();
+});
+
+// Catch minimize
+ipcMain.on('app:minimize', function(e) {
+ mainWindow.minimize();
+});
+
+// Catch start game
+ipcMain.on('game:start', function(e) {
+ let command;
+ if (process.platform == 'darwin') {
+ command = 'wine ~/.wine/drive_c/ProgramData/Kingsisle\\ Entertainment/Wizard101/Bin/WizardGraphicalClient.exe -L login.us.wizard101.com 12000 -A English';
+ }
+ else {
+ command = 'C:\ProgramData\KingsIsle Entertainment\Wizard101\Bin\WizardGraphicalClient.exe -L login.us.wizard101.com 12000 -A English'
+ }
+
+ mainWindow.webContents.send('started');
+
+ exec(command,
+ (error, stdout, stderr) => {
+ console.log(`${stdout}`);
+ console.log(`${stderr}`);
+ if (error !== null) {
+ console.log(`exec error: ${error}`);
+ }
+ }
+ );
+});
+
+// Create menu template
+const mainMenuTemplate = [
+ {
+ label: 'File',
+ submenu: [
+ {
+ label: 'Quit',
+ accelerator: process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q',
+ click(){
+ app.quit();
+ }
+ }
+ ]
+ }
+];
+
+// If mac, add empty object to menu
+if (process.platform == 'darwin') {
+ mainMenuTemplate.unshift({});
+}
+
+// Add developer tools item if not in production
+if (process.env.NODE_ENV !== 'production') {
+ mainMenuTemplate.push({
+ label: 'Developer Tools',
+ submenu: [
+ {
+ label: 'Toggle DevTools',
+ accelerator: process.platform == 'darwin' ? 'Command+I' : 'Ctrl+I',
+ click(item, focusedWindow){
+ focusedWindow.toggleDevTools();
+ }
+ },
+ {
+ role: 'reload'
+ }
+ ]
+ });
+}