diff --git a/app/main.js b/app/main.js index 245d8f0..f76d0b5 100644 --- a/app/main.js +++ b/app/main.js @@ -17,13 +17,14 @@ let defaultConfig = { Plugins: {} } } +global.plugins = []; storage.getAll(function(error, data) { if (error) throw error; let merged = _.merge(defaultConfig, data); global.config = merged.Config; - global.plugins = loadPlugins(); + initPlugins(); }); app.on('ready', () => { @@ -82,6 +83,13 @@ ipcMain.on('updateConfig', (event, arg) => { }); }) +ipcMain.on('getFolderLocations', (event, arg) => { + event.returnValue = { + settings: app.getPath('userData'), + plugins: path.join(path.dirname(app.getPath('exe')), 'plugins') + }; +}) + function createWindow () { win = new BrowserWindow({ minWidth: 800, @@ -97,24 +105,28 @@ function createWindow () { })) } -function loadPlugins() { - // Initialize Plugins - let plugins = []; +function initPlugins() { const pluginDir = path.join(path.dirname(app.getPath('exe')), 'plugins'); // Check plugin folder existence - try { - fs.readdirSync(pluginDir); - } catch (err) { - if (err.code === 'ENOENT') { + fs.readdir(pluginDir, (error, files) => { + if (error && error.code === 'ENOENT') { + console.log(error) // Create the folder by copying default plugins ncp(path.join(__dirname, 'plugins'), pluginDir, err => { - console.error(err); + global.plugins = loadPlugins(); }); } else { - throw(err); + global.plugins = loadPlugins(); } - } + }); +} + +function loadPlugins() { + // Initialize Plugins + let plugins = []; + + const pluginDir = path.join(path.dirname(app.getPath('exe')), 'plugins'); // Load each plugin module in the folder fs.readdirSync(pluginDir).forEach(function (file) { diff --git a/app/pages/Information.js b/app/pages/Information.js index ba57da6..165b045 100644 --- a/app/pages/Information.js +++ b/app/pages/Information.js @@ -1,11 +1,24 @@ +const { ipcRenderer } = require('electron'); + import React from 'react'; -import { Header } from 'semantic-ui-react'; +import { Divider, Header, Input, Segment } from 'semantic-ui-react'; class Information extends React.Component { render () { + const folderLocations = ipcRenderer.sendSync('getFolderLocations'); return ( -

Information

+
+

Information

+
+ Locations +
+ + + +
) } } diff --git a/app/proxy/SWProxy.js b/app/proxy/SWProxy.js index 997a886..909de70 100644 --- a/app/proxy/SWProxy.js +++ b/app/proxy/SWProxy.js @@ -86,10 +86,14 @@ class SWProxy extends EventEmitter { srvSocket.pipe(socket); socket.pipe(srvSocket); }); - + srvSocket.on('error', (error) => { console.log('Caught server socket error.'); }); + + socket.on('error', (error) => { + console.log('Caught client socket error.'); + }); }); this.log({ type: 'info', source: 'proxy', message: `Now listening on port ${port}` }); diff --git a/package.json b/package.json index fd8d6dc..8482919 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sw-exporter", "productName": "Summoners War Exporter", - "version": "0.0.3", + "version": "0.0.4", "description": "This tool will parse intercepted data from Summoners War and extract information on the monsters and runes of the user.", "main": "./app/main.js", "scripts": { @@ -14,8 +14,9 @@ }, "build": { "productName": "Summoners War Exporter", + "appId": "com.electron.sw-exporter", "win": { - "target": "dir" + "target": ["dir"] } }, "keywords": [],