mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-21 12:15:47 +00:00
remove CLOSE_SETTINGS_WINDOW
This commit is contained in:
@@ -3,8 +3,6 @@ export const PUSH_CONFIG = 'push-config'
|
||||
|
||||
export const PRICE_CHECK_HIDE = 'OVERLAY->MAIN::price-check-hide'
|
||||
|
||||
export const CLOSE_SETTINGS_WINDOW = 'close-settings-window'
|
||||
|
||||
export const UPDATE_AVAILABLE = 'update-available'
|
||||
export interface IpcUpdateInfo {
|
||||
auto: boolean
|
||||
|
||||
@@ -126,12 +126,6 @@ class MainProcessBinding extends EventTarget {
|
||||
}
|
||||
}
|
||||
|
||||
closeSettingsWindow (config?: Config) {
|
||||
if (electron) {
|
||||
electron.ipcRenderer.send(ipcEvent.CLOSE_SETTINGS_WINDOW, config)
|
||||
}
|
||||
}
|
||||
|
||||
stashSearch (text: string) {
|
||||
if (electron) {
|
||||
electron.ipcRenderer.send(ipcEvent.STASH_SEARCH, { text })
|
||||
|
||||
+7
-14
@@ -2,8 +2,7 @@ import Store from 'electron-store'
|
||||
import { dialog, ipcMain, app } from 'electron'
|
||||
import isDeepEq from 'fast-deep-equal'
|
||||
import { Config, defaultConfig } from '@/ipc/types'
|
||||
import { GET_CONFIG, PUSH_CONFIG, CLOSE_SETTINGS_WINDOW } from '@/ipc/ipc-event'
|
||||
import { overlayWindow } from './overlay-window'
|
||||
import { GET_CONFIG, PUSH_CONFIG } from '@/ipc/ipc-event'
|
||||
import { logger } from './logger'
|
||||
import { LogWatcher } from './LogWatcher'
|
||||
import { ItemCheckWidget } from '@/web/overlay/interfaces'
|
||||
@@ -14,13 +13,7 @@ export function setupConfigEvents () {
|
||||
e.returnValue = config.store
|
||||
})
|
||||
ipcMain.on(PUSH_CONFIG, (e, cfg: Config) => {
|
||||
batchUpdateConfig(cfg, false)
|
||||
})
|
||||
ipcMain.on(CLOSE_SETTINGS_WINDOW, (e, cfg: Config | undefined) => {
|
||||
if (cfg != null) {
|
||||
loadAndCacheGameCfg()
|
||||
batchUpdateConfig(cfg, true)
|
||||
}
|
||||
batchUpdateConfig(cfg)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -46,18 +39,18 @@ export const config = (() => {
|
||||
return store
|
||||
})()
|
||||
|
||||
export function batchUpdateConfig (newCfg: Config, push = true) {
|
||||
export function batchUpdateConfig (newCfg: Config) {
|
||||
const oldCfg = config.store
|
||||
Object.setPrototypeOf(oldCfg, Object.prototype)
|
||||
if (!isDeepEq(newCfg, oldCfg)) {
|
||||
config.store = newCfg
|
||||
logger.verbose('Saved', { source: 'config', push })
|
||||
if (push) {
|
||||
overlayWindow!.webContents.send(PUSH_CONFIG, newCfg)
|
||||
}
|
||||
logger.verbose('Saved.', { source: 'config' })
|
||||
if (oldCfg.clientLog !== newCfg.clientLog) {
|
||||
LogWatcher.start()
|
||||
}
|
||||
if (oldCfg.gameConfig !== newCfg.gameConfig) {
|
||||
loadAndCacheGameCfg()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -10,13 +10,17 @@ export interface GameConfig {
|
||||
highlightKey: string | null
|
||||
}
|
||||
|
||||
const defaultConfig = (): GameConfig => ({
|
||||
highlightKey: 'Alt'
|
||||
})
|
||||
|
||||
export let gameConfig: GameConfig | null = null
|
||||
export function loadAndCache () {
|
||||
gameConfig = readConfig()
|
||||
return gameConfig
|
||||
}
|
||||
|
||||
export function readConfig (): GameConfig | null {
|
||||
export function readConfig (): GameConfig {
|
||||
let filePath = appConfig.get('gameConfig')
|
||||
|
||||
if (!filePath) {
|
||||
@@ -25,7 +29,8 @@ export function readConfig (): GameConfig | null {
|
||||
fs.accessSync(filePath)
|
||||
appConfig.set('gameConfig', filePath)
|
||||
} catch {
|
||||
return null
|
||||
logger.error('Failed to find game configuration file in the default location. Default values will be used instead.', { source: 'game-config', file: filePath })
|
||||
return defaultConfig()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,21 +40,24 @@ export function readConfig (): GameConfig | null {
|
||||
const parsed = ini.parse(contents)
|
||||
|
||||
return {
|
||||
highlightKey: parseConfigHotkey(parsed.ACTION_KEYS?.highlight || '')
|
||||
highlightKey: parseConfigHotkey(parsed.ACTION_KEYS?.highlight)
|
||||
}
|
||||
} catch {
|
||||
logger.error('Failed to read file', { source: 'game-config', file: filePath })
|
||||
return null
|
||||
logger.error('Failed to read game configuration file. Default values will be used instead.', { source: 'game-config', file: filePath })
|
||||
return defaultConfig()
|
||||
}
|
||||
}
|
||||
|
||||
function parseConfigHotkey (cgfKey: string): string | null {
|
||||
const [keyMain, keyMod] = cgfKey.split(' ')
|
||||
function parseConfigHotkey (cfgKey?: string): string | null {
|
||||
if (!cfgKey) return null
|
||||
|
||||
const [keyMain, keyMod] = cfgKey.split(' ')
|
||||
|
||||
let key1: string
|
||||
if (CodeToKey[keyMain]) {
|
||||
key1 = CodeToKey[keyMain]
|
||||
} else {
|
||||
logger.error('Failed to read key.', { source: 'game-config', key: cfgKey })
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -62,6 +70,7 @@ function parseConfigHotkey (cgfKey: string): string | null {
|
||||
} else if (keyMod === '3') {
|
||||
key2 = 'Alt'
|
||||
} else {
|
||||
logger.error('Failed to read modifier key.', { source: 'game-config', key: cfgKey })
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import { defineComponent, shallowRef, computed, Component, PropType, nextTick, i
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Config } from '@/web/Config'
|
||||
import type { Widget, WidgetManager } from '../overlay/interfaces'
|
||||
import { MainProcess } from '@/ipc/main-process-bindings'
|
||||
import SettingsHotkeys from './hotkeys.vue'
|
||||
import SettingsChat from './chat.vue'
|
||||
import SettingsGeneral from './general.vue'
|
||||
@@ -96,11 +95,10 @@ export default defineComponent({
|
||||
t,
|
||||
save () {
|
||||
wm.hide(props.config.wmId)
|
||||
MainProcess.closeSettingsWindow(JSON.parse(JSON.stringify(Config.store)))
|
||||
Config.saveConfig()
|
||||
},
|
||||
cancel () {
|
||||
wm.hide(props.config.wmId)
|
||||
MainProcess.closeSettingsWindow()
|
||||
},
|
||||
menusItems,
|
||||
selectedComponent
|
||||
|
||||
Reference in New Issue
Block a user