forked from 0ad/0ad
Properly handle the case of removed hotkeys in 6162c6388f
, refs #3051.
This was SVN commit r18253.
This commit is contained in:
parent
6162c6388f
commit
16bad4ee07
@ -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]"
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -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"
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user