From 0fd8d8e2b1dc60505e636c0c8d3d5ab2e78249cc Mon Sep 17 00:00:00 2001 From: Alexander Drozdov Date: Sat, 25 Jul 2020 18:01:00 +0300 Subject: [PATCH] TOGGLE_DELVE_GRID --- src/ipc/ipc-event.ts | 2 ++ src/ipc/main-process-bindings.ts | 4 ++++ src/ipc/types.ts | 22 ++++++++++++++++------ src/main/config.ts | 6 ++++++ src/main/shortcuts.ts | 11 +++++++++++ src/web/overlay/WidgetDelveGrid.vue | 17 +++++++++++++++++ src/web/settings/hotkeys.vue | 11 +++++++++-- 7 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/ipc/ipc-event.ts b/src/ipc/ipc-event.ts index 0b574d12..513882ad 100644 --- a/src/ipc/ipc-event.ts +++ b/src/ipc/ipc-event.ts @@ -64,3 +64,5 @@ export interface IpcOpenSystemBrowser { export const OPEN_WIKI = 'MAIN->OVERLAY::open-wiki' export const IMPORT_FILE = 'OVERLAY->MAIN::import-file' + +export const TOGGLE_DELVE_GRID = 'MAIN->OVERLAY::delve-grid' diff --git a/src/ipc/main-process-bindings.ts b/src/ipc/main-process-bindings.ts index e2bbeb27..0477509c 100644 --- a/src/ipc/main-process-bindings.ts +++ b/src/ipc/main-process-bindings.ts @@ -55,6 +55,10 @@ class MainProcessBinding extends EventTarget { electron.ipcRenderer.on(ipcEvent.OPEN_WIKI, (e, detail) => { this.dispatchEvent(new CustomEvent(ipcEvent.OPEN_WIKI, { detail })) }) + + electron.ipcRenderer.on(ipcEvent.TOGGLE_DELVE_GRID, (e) => { + this.dispatchEvent(new CustomEvent(ipcEvent.TOGGLE_DELVE_GRID)) + }) } } diff --git a/src/ipc/types.ts b/src/ipc/types.ts index c8bf4dc1..4b204261 100644 --- a/src/ipc/types.ts +++ b/src/ipc/types.ts @@ -16,6 +16,7 @@ export interface Config { overlayBackgroundClose: boolean priceCheckShowCursor: boolean mapCheckKey: string | null + delveGridKey: string | null restoreClipboard: boolean commands: Array<{ text: string @@ -66,6 +67,7 @@ export const defaultConfig: Config = { overlayBackgroundClose: true, priceCheckShowCursor: true, mapCheckKey: null, + delveGridKey: null, restoreClipboard: true, commands: [{ text: '/hideout', @@ -164,13 +166,21 @@ export const defaultConfig: Config = { } ] }, - // --- DEFAULT --- { wmId: 4, + wmType: 'delve-grid', + wmTitle: '', + wmWants: 'hide', + wmZorder: 4, + wmFlags: ['hide-on-focus', 'skip-menu'] + }, + // --- DEFAULT --- + { + wmId: 101, wmType: 'stash-search', wmTitle: 'Map rolling', wmWants: 'hide', - wmZorder: 4, + wmZorder: 101, wmFlags: ['invisible-on-blur'], anchor: { pos: 'tl', @@ -185,11 +195,11 @@ export const defaultConfig: Config = { ] }, { - wmId: 5, + wmId: 102, wmType: 'stash-search', wmTitle: 'Dump sorting', wmWants: 'hide', - wmZorder: 5, + wmZorder: 102, wmFlags: ['invisible-on-blur'], anchor: { pos: 'tl', @@ -206,11 +216,11 @@ export const defaultConfig: Config = { ] }, { - wmId: 6, + wmId: 103, wmType: 'image-strip', wmTitle: 'Cheat sheets', wmWants: 'hide', - wmZorder: 6, + wmZorder: 103, wmFlags: ['invisible-on-blur'], anchor: { pos: 'tc', diff --git a/src/main/config.ts b/src/main/config.ts index 69b387f9..219bdbcf 100644 --- a/src/main/config.ts +++ b/src/main/config.ts @@ -68,6 +68,12 @@ export const config = (() => { wmZorder: null }) + config.widgets.push({ + ...defaultConfig.widgets.find(w => w.wmType === 'delve-grid')!, + wmId: Math.max(0, ...config.widgets.map(_ => _.wmId)) + 1, + wmZorder: null + }) + config.configVersion = 3 } diff --git a/src/main/shortcuts.ts b/src/main/shortcuts.ts index 0c4565cb..5c07919b 100644 --- a/src/main/shortcuts.ts +++ b/src/main/shortcuts.ts @@ -79,6 +79,11 @@ function registerGlobal () { config.get('mapCheckKey'), mapCheck ), + shortcutCallback( + config.get('delveGridKey'), + toggleDelveGrid, + { doNotResetModKey: true } + ), ...config.get('commands') .map(command => shortcutCallback(command.hotkey, () => typeInChat(command.text)) @@ -151,6 +156,8 @@ export function setupShortcuts () { }).cb() } else if (pressed === config.get('mapCheckKey')) { shortcutCallback(pressed, mapCheck).cb() + } else if (pressed === config.get('delveGridKey')) { + shortcutCallback(pressed, toggleDelveGrid, { doNotResetModKey: true }).cb() } else { const command = config.get('commands').find(c => c.hotkey === pressed) if (command) { @@ -202,6 +209,10 @@ function openWiki (clipboard: string) { overlayWindow!.webContents.send(ipc.OPEN_WIKI, clipboard) } +function toggleDelveGrid () { + overlayWindow!.webContents.send(ipc.TOGGLE_DELVE_GRID) +} + function eventToString (e: { keycode: number, ctrlKey: boolean, altKey: boolean, shiftKey: boolean }) { const { ctrlKey, shiftKey, altKey } = e diff --git a/src/web/overlay/WidgetDelveGrid.vue b/src/web/overlay/WidgetDelveGrid.vue index 7f6376d5..015570af 100644 --- a/src/web/overlay/WidgetDelveGrid.vue +++ b/src/web/overlay/WidgetDelveGrid.vue @@ -24,10 +24,27 @@