Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/hotkeys/HotkeysPage.js
Show All 36 Lines | class HotkeysPage | ||||
setupHotkeyData() | setupHotkeyData() | ||||
{ | { | ||||
let hotkeydata = Engine.GetHotkeyMap(); | let hotkeydata = Engine.GetHotkeyMap(); | ||||
this.hotkeys = hotkeydata; | this.hotkeys = hotkeydata; | ||||
let categories = clone(this.metadata.categories); | let categories = clone(this.metadata.categories); | ||||
for (let name in categories) | for (let name in categories) | ||||
categories[name].hotkeys = []; | categories[name].hotkeys = []; | ||||
// Add hotkeys defined in the metadata but not in the C++ map. | |||||
for (let hotkeyName in this.metadata.hotkeys) | |||||
if (!this.hotkeys[hotkeyName]) | |||||
this.hotkeys[hotkeyName] = []; | |||||
for (let hotkeyName in this.hotkeys) | for (let hotkeyName in this.hotkeys) | ||||
{ | { | ||||
if (this.metadata.hotkeys[hotkeyName]) | if (this.metadata.hotkeys[hotkeyName]) | ||||
for (let cat of this.metadata.hotkeys[hotkeyName].categories) | for (let cat of this.metadata.hotkeys[hotkeyName].categories) | ||||
categories[cat].hotkeys.push(hotkeyName); | categories[cat].hotkeys.push(hotkeyName); | ||||
else | else | ||||
categories[this.metadata.DEFAULT_CATEGORY].hotkeys.push(hotkeyName); | categories[this.metadata.DEFAULT_CATEGORY].hotkeys.push(hotkeyName); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | messageBox( | ||||
Engine.ReloadHotkeys(); | Engine.ReloadHotkeys(); | ||||
this.saveButton.enabled = false; | this.saveButton.enabled = false; | ||||
this.setupHotkeyData(); | this.setupHotkeyData(); | ||||
this.setupHotkeyList(); | this.setupHotkeyList(); | ||||
} | } | ||||
]); | ]); | ||||
} | } | ||||
saveUserHotkeys() | saveUserHotkeys() | ||||
{ | { | ||||
for (let hotkey in this.hotkeys) | for (let hotkey in this.hotkeys) | ||||
Engine.ConfigDB_RemoveValue("user", "hotkey." + hotkey); | Engine.ConfigDB_RemoveValue("user", "hotkey." + hotkey); | ||||
Engine.ReloadHotkeys(); | Engine.ReloadHotkeys(); | ||||
let defaultData = Engine.GetHotkeyMap(); | let defaultData = Engine.GetHotkeyMap(); | ||||
for (let hotkey in this.hotkeys) | for (let hotkey in this.hotkeys) | ||||
{ | { | ||||
let keymap = formatHotkeyCombinations(this.hotkeys[hotkey], false); | let keymap = formatHotkeyCombinations(this.hotkeys[hotkey], false); | ||||
if (keymap.join("") !== formatHotkeyCombinations(defaultData[hotkey], false).join("")) | if (keymap.join("") !== formatHotkeyCombinations(defaultData[hotkey], false).join("")) | ||||
Engine.ConfigDB_CreateValues("user", "hotkey." + hotkey, keymap); | Engine.ConfigDB_CreateValues("user", "hotkey." + hotkey, keymap); | ||||
} | } | ||||
Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | Engine.ConfigDB_WriteFile("user", "config/user.cfg"); | ||||
Engine.ReloadHotkeys(); | Engine.ReloadHotkeys(); | ||||
} | } | ||||
nani: I'm not sure how the hotkey handling goes in this class, but isn't this function here the cause… | |||||
wraitiiAuthorUnsubmitted Done Inline ActionsThe hotkeys are still deleted in user.cfg, but they're still shown in the editor so long as they appear in a JSON spec file (which they should be to have a nice tooltip & name (& be translatable)). wraitii: The hotkeys are still deleted in user.cfg, but they're still shown in the editor so long as… | |||||
} | } | ||||
function init() | function init() | ||||
{ | { | ||||
let hotkeyPage = new HotkeysPage(new HotkeyMetadata()); | let hotkeyPage = new HotkeysPage(new HotkeyMetadata()); | ||||
} | } |
Wildfire Games · Phabricator
I'm not sure how the hotkey handling goes in this class, but isn't this function here the cause of the non-default hotkeys being deleted, how does this diff fix this?