Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/color.js
/** | /** | ||||
* Used to highlight hotkeys in tooltip descriptions. | * Used to highlight hotkeys in tooltip descriptions. | ||||
*/ | */ | ||||
var g_HotkeyTags = { "color": "255 251 131" }; | 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) | * Concatenate integer color values to a string (for use in GUI objects) | ||||
* | * | ||||
* @param {Object} color | * @param {Object} color | ||||
* @param {number} alpha | * @param {number} alpha | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function rgbToGuiColor(color, alpha) | function rgbToGuiColor(color, alpha) | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | function hslToRgb(h, s, l) | ||||
return [r, g, b].map(n => Math.round(n * 255)); | return [r, g, b].map(n => Math.round(n * 255)); | ||||
} | } | ||||
function colorizeHotkey(text, hotkey) | function colorizeHotkey(text, hotkey) | ||||
{ | { | ||||
// TODO: Be more efficient in retrieving the mapping(s) for a specific hotkey | // TODO: Be more efficient in retrieving the mapping(s) for a specific hotkey | ||||
let key = Engine.GetHotkeyMap()[hotkey]; | let key = Engine.GetHotkeyMap()[hotkey]; | ||||
if (!key) | if (!key || !formatHotkeyCombinations(key)) | ||||
key = sprintf(translate("Unassigned hotkey: %(hotkeyName)s"), { | return sprintf(text, { | ||||
"hotkeyName": hotkey | "hotkey": setStringTags("\\[" + | ||||
translate("Unassigned hotkey:") + | |||||
wraitii: I don't think you need the context on this one to be honest | |||||
translateWithContext("hotkey metadata", getReadableHotkeyName(hotkey)) + | |||||
"]", g_UnavaibleHotkeyTags) | |||||
}); | }); | ||||
else | |||||
key = formatHotkeyCombinations(key); | |||||
Not Done Inline ActionsI think you can go with !formatHotkeyCombinations(key) here wraitii: I think you can go with `!formatHotkeyCombinations(key)` here | |||||
Not Done Inline ActionsIn fact, the check would more appropriately be if (!key?.length) I think wraitii: In fact, the check would more appropriately be `if (!key?.length)` I think | |||||
return sprintf(text, { | return sprintf(text, { | ||||
"hotkey": setStringTags("\\[" + key + "]", g_HotkeyTags) | "hotkey": setStringTags("\\[" + formatHotkeyCombinations(key) + "]", g_HotkeyTags) | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* The autocomplete hotkey is hardcoded in SDLK_TAB of CInput.cpp, | * The autocomplete hotkey is hardcoded in SDLK_TAB of CInput.cpp, | ||||
* as we don't want hotkeys interfering with typing text. | * as we don't want hotkeys interfering with typing text. | ||||
*/ | */ | ||||
function colorizeAutocompleteHotkey(string) | function colorizeAutocompleteHotkey(string) | ||||
Show All 14 Lines |
Wildfire Games · Phabricator
I don't think you need the context on this one to be honest