Skip to content

Commit

Permalink
0.6.7
Browse files Browse the repository at this point in the history
- add seperate ui language (polish, traditional chinese, simplified chinese)
- fix uncaught exception on alert
  • Loading branch information
Kyusung4698 committed Mar 18, 2020
1 parent 3bc7dfb commit 59770fe
Show file tree
Hide file tree
Showing 38 changed files with 3,367 additions and 352 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.6.7 (2020-03-18)

- add traditional chinese support
- add simplified chinese support
- add seperate ui language (polish)
- fix uncaught exception on alert

## 0.6.6 (2020-03-17)

- add dps mod range (#294)
Expand Down
78 changes: 44 additions & 34 deletions hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,44 +104,54 @@ export function off(event: 'change' | 'wheel') {
}
}

export function register(): void {
import('iohook').then(x => {
const iohook = x.default;
iohook.start();

activeCheckSubscription = activeCheck$.pipe(
throttleTime(500, undefined, {
trailing: true,
leading: false
})
).subscribe(() => {
checkActive();
});

iohook.on('keydown', onKeydown);
iohook.on('keyup', onKeyup);
iohook.on('mousewheel', onMousewheel);
iohook.on('mouseup', onMouseclick);
}).catch(() => {
alert('Failed to import iohook. Please make sure you have vc_redist installed.');
});
export function register(): Promise<boolean> {
return new Promise<boolean>(async (resolve) => {
try {
const iohook = (await import('iohook')).default;
iohook.start();

activeCheckSubscription = activeCheck$.pipe(
throttleTime(500, undefined, {
trailing: true,
leading: false
})
).subscribe(() => {
checkActive();
});

iohook.on('keydown', onKeydown);
iohook.on('keyup', onKeyup);
iohook.on('mousewheel', onMousewheel);
iohook.on('mouseup', onMouseclick);
resolve(true);
}
catch (error) {
console.error('An unexpected error occured while registering iohook', error);
resolve(false);
}
})
}

export function unregister(): void {
import('iohook').then(x => {
const iohook = x.default;
export function unregister(): Promise<void> {
return new Promise(async (resolve, reject) => {
try {
const iohook = (await import('iohook')).default;

iohook.off('keydown', onKeydown);
iohook.off('keyup', onKeyup);
iohook.off('mousewheel', onMousewheel);
iohook.off('mouseup', onMouseclick);
iohook.off('keydown', onKeydown);
iohook.off('keyup', onKeyup);
iohook.off('mousewheel', onMousewheel);
iohook.off('mouseup', onMouseclick);

if (activeCheckSubscription) {
activeCheckSubscription.unsubscribe();
}
if (activeCheckSubscription) {
activeCheckSubscription.unsubscribe();
}

iohook.stop();
}).catch(() => {
alert('Failed to import iohook. Please make sure you have vc_redist installed.');
iohook.stop();
resolve();
}
catch (error) {
console.error('An unexpected error occured while unregistering iohook', error);
reject();
}
});
}
24 changes: 17 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AutoLaunch from 'auto-launch';
import { app, BrowserWindow, Display, ipcMain, Menu, MenuItem, MenuItemConstructorOptions, screen, systemPreferences, Tray } from 'electron';
import { app, BrowserWindow, dialog, Display, ipcMain, Menu, MenuItem, MenuItemConstructorOptions, screen, systemPreferences, Tray } from 'electron';
import * as log from 'electron-log';
import { autoUpdater } from 'electron-updater';
import * as fs from 'fs';
Expand All @@ -13,7 +13,9 @@ if (!app.requestSingleInstanceLock()) {
}

if (process.platform === 'win32' && !systemPreferences.isAeroGlassEnabled()) {
alert('Aero needs to be enabled.')
dialog.showErrorBox(
'Aero is required to run PoE Overlay',
'Aero is currently disabled. Please enable Aero and try again.');
app.exit();
}

Expand Down Expand Up @@ -149,7 +151,7 @@ autoUpdater.on('update-available', () => {
title: 'New update available',
content: 'A new update is available. Will be automatically downloaded unless otherwise specified.',
});
if (!autoUpdater.autoDownload && !downloadItem) {
if (!autoUpdater.autoDownload && !downloadItem) {
downloadItem = new MenuItem({
label: 'Download Update',
type: 'normal',
Expand Down Expand Up @@ -381,10 +383,18 @@ try {
app.on('ready', () => {
/* delay create window in order to support transparent windows at linux. */
setTimeout(() => {
hook.register();
createWindow();
createTray();
}, 1000);
hook.register().then(success => {
if (!success) {
dialog.showErrorBox(
'Iohook is required to run PoE Overlay',
'Iohook could not be loaded. Please make sure you have vc_redist installed and try again.');
app.quit();
} else {
createWindow();
createTray();
}
});
}, 300);
});

app.on('window-all-closed', () => {
Expand Down
Loading

0 comments on commit 59770fe

Please sign in to comment.