Index: binaries/data/mods/public/gui/common/color.js =================================================================== --- binaries/data/mods/public/gui/common/color.js +++ binaries/data/mods/public/gui/common/color.js @@ -3,6 +3,8 @@ */ var g_HotkeyTags = { "color": "255 251 131" }; +var g_UnavaibleHotkeyTags = { "color": "153 153 153", "font": "sans-13" }; + /** * Concatenate integer color values to a string (for use in GUI objects) * @@ -175,15 +177,16 @@ // TODO: Be more efficient in retrieving the mapping(s) for a specific hotkey let key = Engine.GetHotkeyMap()[hotkey]; - if (!key) - key = sprintf(translate("Unassigned hotkey: %(hotkeyName)s"), { - "hotkeyName": hotkey + if (!key || !formatHotkeyCombinations(key)) + return sprintf(text, { + "hotkey": setStringTags("\\[" + + translate("Unassigned hotkey:") + + translateWithContext("hotkey metadata", getReadableHotkeyName(hotkey)) + + "]", g_UnavaibleHotkeyTags) }); - else - key = formatHotkeyCombinations(key); return sprintf(text, { - "hotkey": setStringTags("\\[" + key + "]", g_HotkeyTags) + "hotkey": setStringTags("\\[" + formatHotkeyCombinations(key) + "]", g_HotkeyTags) }); } Index: binaries/data/mods/public/gui/common/hotkeys.js =================================================================== --- binaries/data/mods/public/gui/common/hotkeys.js +++ binaries/data/mods/public/gui/common/hotkeys.js @@ -3,6 +3,8 @@ */ var g_ScancodesMap; +var g_HotkeyNames = new Map(); + function hotkeySort(a, b) { const specialKeys = ["Shift", "Alt", "Ctrl", "Super"]; @@ -37,3 +39,23 @@ combs.sort((a, b) => a.length - b.length || a - b); return translateScancodes ? combs.join(", ") : combs; } + +function getHotkeyFiles() +{ + return Engine.ListDirectoryFiles("gui/hotkeys/spec/", "*.json"); +} + +function getReadableHotkeyName(key) +{ + if (!g_HotkeyNames.size) + for (let file of getHotkeyFiles()) + { + let data = Engine.ReadJSONFile(file); + if (data.mapped_hotkeys) + for (let cat in data.mapped_hotkeys) + for (let hotkey in data.mapped_hotkeys[cat]) + g_HotkeyNames.set(hotkey, data.mapped_hotkeys[cat][hotkey].name); + } + + return g_HotkeyNames.get(key); +} Index: binaries/data/mods/public/gui/hotkeys/HotkeyMetadata.js =================================================================== --- binaries/data/mods/public/gui/hotkeys/HotkeyMetadata.js +++ binaries/data/mods/public/gui/hotkeys/HotkeyMetadata.js @@ -14,7 +14,7 @@ parseSpec() { - let files = this.getFiles(); + let files = getHotkeyFiles(); let hotkey_i = 0; let categories = { [this.DEFAULT_CATEGORY]: { @@ -59,11 +59,6 @@ this.categories[key] = categories[key]; // TODO: validate that categories exist. } - - getFiles() - { - return Engine.ListDirectoryFiles("gui/hotkeys/spec/", "*.json"); - } } HotkeyMetadata.prototype.DefaultCategoryString = markForTranslation("Other Hotkeys"); Index: binaries/data/mods/public/gui/hotkeys/HotkeyPicker.js =================================================================== --- binaries/data/mods/public/gui/hotkeys/HotkeyPicker.js +++ binaries/data/mods/public/gui/hotkeys/HotkeyPicker.js @@ -113,7 +113,8 @@ .filter(name => name != this.name).map(translate); if (conflicts.length) Engine.GetGUIObjectByName("conflicts[" + i + "]").caption = - coloredText(translate("May conflict with: "), "255 153 0") + conflicts.join(", "); + coloredText(translate("May conflict with: "), "255 153 0") + + conflicts.map(x => translateWithContext("hotkey metadata", getReadableHotkeyName(x))).join(", "); } // Gray out buttons when entering an input so it's obvious clicking on them will do nothing. Engine.GetGUIObjectByName("hotkeyPickerReset").enabled = this.enteringInput == -1;