diff --git a/binaries/data/mods/public/gui/common/color.js b/binaries/data/mods/public/gui/common/color.js index 473915ca87..3aeafe940c 100644 --- a/binaries/data/mods/public/gui/common/color.js +++ b/binaries/data/mods/public/gui/common/color.js @@ -130,14 +130,17 @@ function hslToRgb(h, s, l) return [r, g, b].map(n => Math.round(n * 255)); } -function colorizeHotkey(key) +function colorizeHotkey(text, hotkey) { - key = Engine.ConfigDB_GetValue("user", "hotkey." + key); + let key = Engine.ConfigDB_GetValue("user", "hotkey." + hotkey); if (!key) return ""; - return "[color=\"" + g_HotkeyColor + "\"]" + - "\\[" + key + "]" + - "[/color]"; + return sprintf(text, { + "hotkey": + "[color=\"" + g_HotkeyColor + "\"]" + + "\\[" + key + "]" + + "[/color]" + }); } diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js index d5bf5db2b6..6ebe6aac43 100644 --- a/binaries/data/mods/public/gui/session/selection_panels.js +++ b/binaries/data/mods/public/gui/session/selection_panels.js @@ -1103,7 +1103,7 @@ g_SelectionPanels.Training = { "setTooltip": function(data) { let tooltip = "[font=\"sans-bold-16\"]" + - colorizeHotkey("session.queueunit." + (data.i + 1)) + + colorizeHotkey("%(hotkey)s", "session.queueunit." + (data.i + 1)) + "[/font]"; tooltip += getEntityNamesFormatted(data.template); diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index f55ca9fc61..537899ebd2 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -312,14 +312,14 @@ function init(initData, hotloadData) function initHotkeyTooltips() { Engine.GetGUIObjectByName("idleWorkerButton").tooltip = - colorizeHotkey("selection.idleworker") + " " + + colorizeHotkey("%(hotkey)s" + " ", "selection.idleworker") + translate("Find idle worker"); Engine.GetGUIObjectByName("tradeHelp").tooltip = - translate("Select one goods as origin of the changes, then use the arrows of the target goods to make the changes.") + "\n" + - sprintf(translate("Using %(hotkey)s will put the selected resource to 100%%."), { - "hotkey": colorizeHotkey("session.fulltradeswap") - }); + translate("Select one goods as origin of the changes, then use the arrows of the target goods to make the changes.") + + colorizeHotkey( + "\n" + translate("Using %(hotkey)s will put the selected resource to 100%%."), + "session.fulltradeswap"); } function initializeMusic() diff --git a/binaries/data/mods/public/gui/session/unit_actions.js b/binaries/data/mods/public/gui/session/unit_actions.js index 1c25e5bfa6..ca29ffda8a 100644 --- a/binaries/data/mods/public/gui/session/unit_actions.js +++ b/binaries/data/mods/public/gui/session/unit_actions.js @@ -1003,11 +1003,12 @@ var g_EntityCommands = return { "tooltip": - colorizeHotkey("session.kill") + " " + - translate("Destroy the selected units or buildings.") + "\n" + - sprintf(translate("Use %(hotkey)s to avoid the confirmation dialog."), { - "hotkey": colorizeHotkey("session.noconfirmation") - }), + colorizeHotkey("%(hotkey)s" + " ", "session.kill") + + translate("Destroy the selected units or buildings.") + + colorizeHotkey( + "\n" + translate("Use %(hotkey)s to avoid the confirmation dialog."), + "session.noconfirmation" + ), "icon": "kill_small.png" }; }, @@ -1042,7 +1043,7 @@ var g_EntityCommands = return false; return { - "tooltip": colorizeHotkey("session.stop") + " " + + "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.stop") + translate("Abort the current order."), "icon": "stop.png" }; @@ -1062,7 +1063,7 @@ var g_EntityCommands = return false; return { - "tooltip": colorizeHotkey("session.garrison") + " " + + "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + translate("Order the selected units to garrison a building or unit."), "icon": "garrison.png" }; @@ -1162,7 +1163,7 @@ var g_EntityCommands = return false; return { - "tooltip": colorizeHotkey("session.guard") + " " + + "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.guard") + translate("Order the selected units to guard a building or unit."), "icon": "add-guard.png" };