Skip to content

Commit

Permalink
Add electron-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Fay committed Oct 7, 2017
1 parent a3ba4d2 commit 68061d5
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
dist/
npm-debug.log

npm-debug.log
.DS_Store
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added assets/img/icone.ico
Binary file not shown.
File renamed without changes
File renamed without changes
16 changes: 12 additions & 4 deletions main.js → electron/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {dialog, BrowserWindow, app, ipcMain, Tray} = require('electron')
const autoUpdater = require("electron-updater").autoUpdater
const Puissance4 = require('./puissance4');
const minMaxWorker = require('child_process').fork(`${__dirname}/minmax`);

Expand All @@ -7,21 +8,21 @@ let browserWindow, tray, game;
const createBrowserWindow = () => {
browserWindow = new BrowserWindow();
browserWindow.maximize();
browserWindow.loadURL(`file://${__dirname}/client/index.html`);
browserWindow.loadURL(`file://${__dirname}/../app/index.html`);
}

const createTray = () => {
tray = new Tray(`${__dirname}/client/img/red.png`);
tray = new Tray(`${__dirname}/../assets/img/red.png`);
tray.setToolTip('A vous de jouer.');
}

const updateTray = (event) => {
let image, tooltip;
if (event === 'humanMoved') {
image = `${__dirname}/client/img/yellow.png`
image = `${__dirname}/../assets/img/yellow.png`
tooltip = 'A Electron de jouer';
} else {
image = `${__dirname}/client/img/red.png`
image = `${__dirname}/../assets/img/red.png`
tooltip = 'A vous de jouer';
}
tray.setImage(image);
Expand Down Expand Up @@ -58,12 +59,19 @@ const emitGameUpdate = (event) => {
app.on('ready', () => {
createBrowserWindow();
createTray();
autoUpdater.checkForUpdates();
});

app.on('window-all-closed', () => {
app.quit();
});

autoUpdater.on('update-downloaded', (info) => {
setTimeout(() => {
autoUpdater.quitAndInstall();
}, 5000)
})

minMaxWorker.on('message', (move) => {
game.updateBoard(move, 2);
game.checkWin();
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "electron-puissance4",
"version": "1.0.0",
"description": "Jeu de puissance 4 réalisé avec Electron",
"main": "main.js",
"author": "Guillaume Fay",
"license": "ISC",
"dependencies": {
"electron-updater": "2.10.1"
}
}
File renamed without changes.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "electron-puissance4",
"version": "1.0.0",
"description": "Jeu de puissance 4 réalisé avec Electron",
"main": "main.js",
"main": "electron/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dist": "electron-builder"
"dist": "electron-builder --mac --win --x64"
},
"author": "Guillaume Fay",
"license": "ISC",
Expand All @@ -19,7 +19,10 @@
"productName": "Puissance 4",
"mac": {
"category": "public.app-category.games",
"icon": "client/img/icone.icns"
"icon": "assets/img/icone.icns"
},
"win": {
"icon": "assets/img/icone.ico"
}
}
}

0 comments on commit 68061d5

Please sign in to comment.