From 59770feacfd11c62460e000d5a1dbcaf8640b7a1 Mon Sep 17 00:00:00 2001 From: Kyusung4698 Date: Wed, 18 Mar 2020 15:25:38 +0100 Subject: [PATCH 1/2] 0.6.7 - add seperate ui language (polish, traditional chinese, simplified chinese) - fix uncaught exception on alert --- CHANGELOG.md | 7 + hook.ts | 78 +- main.ts | 24 +- overlay.babel | 2762 +++++++++++++++-- src/app/app-translations.loader.ts | 27 +- .../core/service/input/shortcut.service.ts | 2 +- src/app/core/type/index.ts | 3 +- src/app/core/type/language.type.ts | 13 + src/app/data/github/index.ts | 1 - src/app/data/github/schema/releases.type.ts | 9 - .../github/service/releases-http.service.ts | 21 - .../data/poe/service/trade-http.service.ts | 6 + .../user-settings-form.component.html | 11 +- .../user-settings-form.component.ts | 2 + .../layout/page/overlay/overlay.component.ts | 12 +- .../user-settings/user-settings.component.ts | 11 +- .../service/user-settings-storage.service.ts | 4 +- .../layout/service/user-settings.service.ts | 5 +- src/app/layout/type/user-settings.type.ts | 2 + .../evaluate-search.component.html | 11 +- .../poe/provider/base-item-types.provider.ts | 3 + .../poe/provider/client-string.provider.ts | 3 + .../module/poe/provider/word.provider.ts | 3 + .../poe/service/item/item-external.service.ts | 2 + .../shared/module/poe/type/language.type.ts | 2 + src/assets/i18n/english.json | 21 +- src/assets/i18n/french.json | 21 +- src/assets/i18n/german.json | 21 +- src/assets/i18n/korean.json | 21 +- src/assets/i18n/polish.json | 171 + src/assets/i18n/portuguese.json | 21 +- src/assets/i18n/russian.json | 21 +- src/assets/i18n/simplified-chinese.json | 171 + src/assets/i18n/spanish.json | 21 +- src/assets/i18n/thai.json | 21 +- src/assets/i18n/traditional-chinese.json | 171 + src/environments/environment.prod.ts | 7 +- src/environments/environment.ts | 7 +- 38 files changed, 3367 insertions(+), 352 deletions(-) create mode 100644 src/app/core/type/language.type.ts delete mode 100644 src/app/data/github/index.ts delete mode 100644 src/app/data/github/schema/releases.type.ts delete mode 100644 src/app/data/github/service/releases-http.service.ts create mode 100644 src/assets/i18n/polish.json create mode 100644 src/assets/i18n/simplified-chinese.json create mode 100644 src/assets/i18n/traditional-chinese.json diff --git a/CHANGELOG.md b/CHANGELOG.md index f784ab7e..e4c6f68b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/hook.ts b/hook.ts index 90238694..cf48c721 100644 --- a/hook.ts +++ b/hook.ts @@ -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 { + return new Promise(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 { + 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(); + } }); } \ No newline at end of file diff --git a/main.ts b/main.ts index b3495b52..c9513de3 100644 --- a/main.ts +++ b/main.ts @@ -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'; @@ -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(); } @@ -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', @@ -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', () => { diff --git a/overlay.babel b/overlay.babel index 6e1137ac..2807425c 100644 --- a/overlay.babel +++ b/overlay.babel @@ -1,4 +1,4 @@ - +