mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2025-10-30 14:17:55 +00:00
let people debug hotkeys better
This commit is contained in:
@@ -5,7 +5,7 @@ export interface HostConfig {
|
||||
gameConfig: string | null
|
||||
stashScroll: boolean
|
||||
overlayKey: string
|
||||
logLevel: string
|
||||
logKeys: boolean
|
||||
windowTitle: string
|
||||
language: string
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ app.on('ready', async () => {
|
||||
const shortcuts = await Shortcuts.create(logger, overlay, poeWindow, gameConfig, eventPipe)
|
||||
eventPipe.onEventAnyClient('CLIENT->MAIN::update-host-config', (cfg) => {
|
||||
overlay.updateOpts(cfg.overlayKey, cfg.windowTitle)
|
||||
shortcuts.updateActions(cfg.shortcuts, cfg.stashScroll, cfg.restoreClipboard, cfg.language)
|
||||
shortcuts.updateActions(cfg.shortcuts, cfg.stashScroll, cfg.logKeys, cfg.restoreClipboard, cfg.language)
|
||||
gameLogWatcher.restart(cfg.clientLog)
|
||||
gameConfig.readConfig(cfg.gameConfig)
|
||||
appUpdater.checkAtStartup()
|
||||
|
||||
@@ -18,6 +18,7 @@ const UiohookToName = Object.fromEntries(Object.entries(UiohookKey).map(([k, v])
|
||||
export class Shortcuts {
|
||||
private actions: ShortcutAction[] = []
|
||||
private stashScroll = false
|
||||
private logKeys = false
|
||||
private areaTracker: WidgetAreaTracker
|
||||
private clipboard: HostClipboard
|
||||
|
||||
@@ -62,13 +63,15 @@ export class Shortcuts {
|
||||
}
|
||||
})
|
||||
|
||||
// uIOhook.on('keydown', (e) => {
|
||||
// const pressed = eventToString(e)
|
||||
// this.logger.write(`debug [Shortcuts] Keydown ${pressed}`)
|
||||
// })
|
||||
// uIOhook.on('keyup', (e) => {
|
||||
// this.logger.write(`debug [Shortcuts] Keyup ${UiohookToName[e.keycode] || 'unknown'}`)
|
||||
// })
|
||||
uIOhook.on('keydown', (e) => {
|
||||
if (!this.logKeys) return
|
||||
const pressed = eventToString(e)
|
||||
this.logger.write(`debug [Shortcuts] Keydown ${pressed}`)
|
||||
})
|
||||
uIOhook.on('keyup', (e) => {
|
||||
if (!this.logKeys) return
|
||||
this.logger.write(`debug [Shortcuts] Keyup ${UiohookToName[e.keycode] || 'not_supported_key'}`)
|
||||
})
|
||||
|
||||
uIOhook.on('wheel', (e) => {
|
||||
if (!e.ctrlKey || !this.poeWindow.isActive || !this.stashScroll) return
|
||||
@@ -83,8 +86,15 @@ export class Shortcuts {
|
||||
})
|
||||
}
|
||||
|
||||
updateActions (actions: ShortcutAction[], stashScroll: boolean, restoreClipboard: boolean, language: string) {
|
||||
updateActions (
|
||||
actions: ShortcutAction[],
|
||||
stashScroll: boolean,
|
||||
logKeys: boolean,
|
||||
restoreClipboard: boolean,
|
||||
language: string
|
||||
) {
|
||||
this.stashScroll = stashScroll
|
||||
this.logKeys = logKeys
|
||||
this.clipboard.updateOptions(restoreClipboard)
|
||||
this.ocrWorker.updateOptions(language)
|
||||
|
||||
@@ -237,7 +247,7 @@ function eventToString (e: { keycode: number, ctrlKey: boolean, altKey: boolean,
|
||||
const { ctrlKey, shiftKey, altKey } = e
|
||||
|
||||
let code = UiohookToName[e.keycode]
|
||||
if (!code) return 'unknown'
|
||||
if (!code) return 'not_supported_key'
|
||||
|
||||
if (code === 'Shift' || code === 'Alt' || code === 'Ctrl') return code
|
||||
|
||||
|
||||
@@ -291,7 +291,8 @@
|
||||
"poe_log_file" :"PoE log file",
|
||||
"poe_cfg_file" :"PoE config file",
|
||||
"restore_clipboard" :"Restore clipboard",
|
||||
"show_overlay_ready" :"Show a notification when the Overlay detects a PoE window"
|
||||
"show_overlay_ready" :"Show a notification when the Overlay detects a PoE window",
|
||||
"debug_hotkeys": "Record all key presses"
|
||||
},
|
||||
"price_check": {
|
||||
"name": "Price check",
|
||||
|
||||
@@ -105,7 +105,7 @@ export interface Config {
|
||||
clientLog: string | null
|
||||
gameConfig: string | null
|
||||
windowTitle: string
|
||||
logLevel: string
|
||||
logKeys: boolean
|
||||
accountName: string
|
||||
stashScroll: boolean
|
||||
language: 'en' | 'ru' | 'cmn-Hant'
|
||||
@@ -150,7 +150,7 @@ export const defaultConfig = (): Config => ({
|
||||
clientLog: null,
|
||||
gameConfig: null,
|
||||
windowTitle: 'Path of Exile',
|
||||
logLevel: 'warn',
|
||||
logKeys: false,
|
||||
accountName: '',
|
||||
stashScroll: true,
|
||||
language: 'en',
|
||||
@@ -374,7 +374,7 @@ function upgradeConfig (_config: Config): Config {
|
||||
|
||||
if (config.configVersion < 6) {
|
||||
config.widgets.find(w => w.wmType === 'price-check')!
|
||||
.showRateLimitState = (config.logLevel === 'debug')
|
||||
.showRateLimitState = ((config as any).logLevel === 'debug')
|
||||
config.widgets.find(w => w.wmType === 'price-check')!
|
||||
.apiLatencySeconds = 2
|
||||
|
||||
@@ -528,6 +528,10 @@ function upgradeConfig (_config: Config): Config {
|
||||
config.configVersion = 16
|
||||
}
|
||||
|
||||
if (config.logKeys === undefined) {
|
||||
config.logKeys = false
|
||||
}
|
||||
|
||||
return config as unknown as Config
|
||||
}
|
||||
|
||||
@@ -653,7 +657,7 @@ function getConfigForHost (): HostConfig {
|
||||
gameConfig: config.gameConfig,
|
||||
stashScroll: config.stashScroll,
|
||||
overlayKey: config.overlayKey,
|
||||
logLevel: config.logLevel,
|
||||
logKeys: config.logKeys,
|
||||
windowTitle: config.windowTitle,
|
||||
language: config.language
|
||||
}
|
||||
|
||||
@@ -12,10 +12,14 @@
|
||||
:id="`widget-${widget.wmId}`"
|
||||
:is="`widget-${widget.wmType}`" />
|
||||
</template>
|
||||
<pre v-if="showLogs"
|
||||
class="widget-default-style p-4 mx-auto mt-6 overflow-hidden"
|
||||
style="max-width: 38rem; z-index: 999; position: absolute; left: 0; right: 0;"
|
||||
>{{ logs }}</pre>
|
||||
<loading-animation />
|
||||
<div v-if="showEditingNotification"
|
||||
class="widget-default-style p-6 bg-blue-600 mx-auto text-center text-base mt-6"
|
||||
style="min-width: 30rem; z-index: 999; width: fit-content; position: absolute; left: 0; right: 0;">
|
||||
style="min-width: 30rem; z-index: 998; width: fit-content; position: absolute; left: 0; right: 0;">
|
||||
<i18n-t keypath="reopen_settings">
|
||||
<span class="bg-blue-800 rounded px-1">{{ overlayKey }}</span>
|
||||
</i18n-t>
|
||||
@@ -293,6 +297,15 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
function sliceLastLines (text: string, numLines: number) {
|
||||
let lfIndex = text.length - 1
|
||||
for (let i = 0; i < numLines; i++) {
|
||||
lfIndex = text.lastIndexOf('\n', lfIndex - 1)
|
||||
if (lfIndex === -1) return text
|
||||
}
|
||||
return text.slice(lfIndex + 1)
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
return {
|
||||
@@ -303,6 +316,8 @@ export default defineComponent({
|
||||
handleBackgroundClick,
|
||||
isVisible,
|
||||
overlayKey: computed(() => AppConfig().overlayKey),
|
||||
get showLogs () { return !active.value && AppConfig().logKeys },
|
||||
logs: computed(() => sliceLastLines(Host.logs.value, 11)),
|
||||
showEditingNotification: computed(() => !active.value && showEditingNotification.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
<template>
|
||||
<div class="max-w-md p-2">
|
||||
<div class="mb-2">
|
||||
<div class="flex-1 mb-1">{{ t('Log level') }}</div>
|
||||
<div class="mb-4 flex gap-x-4">
|
||||
<ui-radio v-model="logLevel" value="warn">Warn</ui-radio>
|
||||
<ui-radio v-model="logLevel" value="silly">Debug</ui-radio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<div class="flex-1 mb-1">{{ t('Log') }}</div>
|
||||
<pre class="mb-4 bg-gray-900 rounded p-2">{{ logs }}</pre>
|
||||
<div class="layout-column">
|
||||
<div class="p-2 shadow">
|
||||
<ui-checkbox v-model="logKeys">{{ t('settings.debug_hotkeys') }}</ui-checkbox>
|
||||
</div>
|
||||
<pre class="p-2 overflow-y-scroll flex-1">{{ logs }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -29,7 +22,7 @@ export default defineComponent({
|
||||
return {
|
||||
t,
|
||||
logs: Host.logs,
|
||||
logLevel: configModelValue(() => props.config, 'logLevel')
|
||||
logKeys: configModelValue(() => props.config, 'logKeys')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user