TOGGLE_DELVE_GRID

This commit is contained in:
Alexander Drozdov
2020-07-25 18:01:00 +03:00
parent bfa0ab4015
commit 0fd8d8e2b1
7 changed files with 65 additions and 8 deletions
+2
View File
@@ -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'
+4
View File
@@ -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))
})
}
}
+16 -6
View File
@@ -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',
+6
View File
@@ -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
}
+11
View File
@@ -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
+17
View File
@@ -24,10 +24,27 @@
<script>
import Widget from './Widget'
import { MainProcess } from '@/ipc/main-process-bindings'
import { TOGGLE_DELVE_GRID } from '@/ipc/ipc-event'
export default {
components: { Widget },
inject: ['wm'],
props: {
config: {
type: Object,
required: true
}
},
created () {
MainProcess.addEventListener(TOGGLE_DELVE_GRID, () => {
if (this.config.wmWants === 'hide') {
this.wm.show(this.config.wmId)
} else {
this.wm.hide(this.config.wmId)
}
})
},
computed: {
anchor () {
const height = Math.round(this.wm.height * 808 / 1080)
+9 -2
View File
@@ -30,12 +30,18 @@
<hotkey-input v-model="config.wikiKey" class="w-48" />
</div>
</div>
<div class="mb-8">
<div class="mb-4">
<div class="flex">
<div class="flex-1">{{ $t('Map check') }}</div>
<hotkey-input v-model="config.mapCheckKey" class="w-48" />
</div>
</div>
<div class="mb-8">
<div class="flex">
<div class="flex-1">{{ $t('Delve grid') }}</div>
<hotkey-input v-model="config.delveGridKey" class="w-48" />
</div>
</div>
<div class="mb-8">
<div class="flex">
<div class="flex-1">{{ $t('Stash tab scrolling') }}</div>
@@ -72,7 +78,8 @@ export default {
"Overlay": "Оверлей",
"Open item on wiki": "Открыть предмет в вики",
"Map check": "Проверка карты",
"Stash tab scrolling": "Прокрутка вкладок тайника"
"Stash tab scrolling": "Прокрутка вкладок тайника",
"Delve grid": "Сетка \"Спуска\""
}
}
</i18n>