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_HotkeyTag = { "color": "255 251 131" }; | ||||
/** | |||||
* Used to highlight hotkeys in tooltip descriptions. | |||||
*/ | |||||
var g_IncompatibleTag = { "color": "96 96 96" }; | |||||
/** | /** | ||||
* 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} | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | function colorizeHotkey(text, hotkey) | ||||
let key = Engine.ConfigDB_GetValue("user", "hotkey." + hotkey); | let key = Engine.ConfigDB_GetValue("user", "hotkey." + hotkey); | ||||
if (!key || key.toLowerCase() == "unused") | if (!key || key.toLowerCase() == "unused") | ||||
key = sprintf(translate("Unassigned hotkey: %(hotkeyName)s"), { | key = sprintf(translate("Unassigned hotkey: %(hotkeyName)s"), { | ||||
"hotkeyName": hotkey | "hotkeyName": hotkey | ||||
}); | }); | ||||
return sprintf(text, { | return sprintf(text, { | ||||
"hotkey": setStringTags("\\[" + key + "]", g_HotkeyTags) | "hotkey": setStringTags("\\[" + key + "]", g_HotkeyTag) | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* 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) | ||||
{ | { | ||||
return sprintf(string || translate("Press %(hotkey)s to autocomplete player names."), { | return sprintf(string || translate("Press %(hotkey)s to autocomplete player names."), { | ||||
"hotkey": | "hotkey": | ||||
setStringTags("\\[" + translateWithContext("hotkey", "Tab") + "]", g_HotkeyTags) | setStringTags("\\[" + translateWithContext("hotkey", "Tab") + "]", g_HotkeyTag) | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Adds grey font if savegame/replay is not compatible. | * Adds grey font if savegame/replay is not compatible. | ||||
*/ | */ | ||||
function compatibilityColor(text, isCompatible) | function compatibilityColor(text, isCompatible) | ||||
{ | { | ||||
return isCompatible ? text : coloredText(text, "96 96 96"); | return isCompatible ? text : setStringTags(text, g_IncompatibleTag); | ||||
} | } |
Wildfire Games · Phabricator