PoE window - No access

This commit is contained in:
Alexander Drozdov
2020-06-11 23:20:13 +03:00
parent 45aa74d8b4
commit 610cfd29cd
2 changed files with 20 additions and 2 deletions
+7 -1
View File
@@ -2,7 +2,7 @@ import { Rectangle, BrowserWindow, Point } from 'electron'
import { EventEmitter } from 'events'
import { logger } from './logger'
import { config } from './config'
import { overlayWindow as OW } from 'electron-overlay-window'
import { overlayWindow as OW, AttachEvent } from 'electron-overlay-window'
interface PoeWindowClass {
on(event: 'active-change', listener: (isActive: boolean) => void): this
@@ -54,6 +54,12 @@ class PoeWindowClass extends EventEmitter {
OW.attachTo(window, config.get('windowTitle'))
}
onceAttached (cb: (hasAccess: boolean | undefined) => void) {
OW.once('attach', (e: AttachEvent) => {
cb(e.hasAccess)
})
}
}
export const PoeWindow = new PoeWindowClass()
+13 -1
View File
@@ -1,5 +1,5 @@
import path from 'path'
import { BrowserWindow, ipcMain } from 'electron'
import { BrowserWindow, ipcMain, dialog } from 'electron'
import { PoeWindow } from './PoeWindow'
import { logger } from './logger'
import { OVERLAY_READY, FOCUS_CHANGE } from '@/ipc/ipc-event'
@@ -56,6 +56,18 @@ export async function createOverlayWindow () {
overlayWindow.webContents.send(FOCUS_CHANGE, { game: isActive, overlay: isInteractable })
})
PoeWindow.onceAttached((hasAccess) => {
if (hasAccess === false) {
dialog.showErrorBox(
'PoE window - No access',
// ----------------------
'Path of Exile is running with administrator rights.\n' +
'\n' +
'You need to restart Awakened PoE Trade with administrator rights.'
)
}
})
const electronReadyToShow = new Promise<void>((resolve) => {
overlayWindow!.once('ready-to-show', resolve)
})