Show hotkeys in the tooltips of six buttons.
This was SVN commit r18252.
This commit is contained in:
parent
39bf451d49
commit
6162c6388f
@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Used to highlight hotkeys in tooltip descriptions.
|
||||
*/
|
||||
var g_HotkeyColor = "255 251 131";
|
||||
|
||||
/**
|
||||
* Concatenate integer color values to a string (for use in GUI objects)
|
||||
*
|
||||
@ -124,3 +129,15 @@ function hslToRgb(h, s, l)
|
||||
|
||||
return [r, g, b].map(n => Math.round(n * 255));
|
||||
}
|
||||
|
||||
function colorizeHotkey(key)
|
||||
{
|
||||
key = Engine.ConfigDB_GetValue("user", "hotkey." + key);
|
||||
|
||||
if (!key)
|
||||
return "";
|
||||
|
||||
return "[color=\"" + g_HotkeyColor + "\"]" +
|
||||
"\\[" + key + "]" +
|
||||
"[/color]";
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
<!-- Idle Worker Button -->
|
||||
<object size="100%-80 100%-80 100%-5 100%-5">
|
||||
<object type="button"
|
||||
name="idleWorkerButton"
|
||||
tooltip_style="sessionToolTip"
|
||||
hotkey="selection.idleworker"
|
||||
>
|
||||
<translatableAttribute id="tooltip">Find idle worker</translatableAttribute>
|
||||
<action on="Press">if (g_HasIdleWorker) findIdleUnit(g_WorkerTypes);</action>
|
||||
<action on="MouseEnter">if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle-highlight.png";</action>
|
||||
<action on="MouseLeave">if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle.png";</action>
|
||||
|
@ -1102,10 +1102,9 @@ g_SelectionPanels.Training = {
|
||||
},
|
||||
"setTooltip": function(data)
|
||||
{
|
||||
var tooltip = "";
|
||||
var key = Engine.ConfigDB_GetValue("user", "hotkey.session.queueunit." + (data.i + 1));
|
||||
if (key)
|
||||
tooltip += "[color=\"255 251 131\"][font=\"sans-bold-16\"]\\[" + key + "][/font][/color] ";
|
||||
let tooltip = "[font=\"sans-bold-16\"]" +
|
||||
colorizeHotkey("session.queueunit." + (data.i + 1)) +
|
||||
"[/font]";
|
||||
|
||||
tooltip += getEntityNamesFormatted(data.template);
|
||||
tooltip += getVisibleEntityClassesFormatted(data.template);
|
||||
@ -1130,7 +1129,11 @@ g_SelectionPanels.Training = {
|
||||
if (data.template.speed)
|
||||
tooltip += "\n" + getSpeedTooltip(data.template);
|
||||
}
|
||||
tooltip += "[color=\"255 251 131\"]" + formatBatchTrainingString(data.buildingsCountToTrainFullBatch, data.fullBatchSize, data.remainderBatch) + "[/color]";
|
||||
|
||||
tooltip += "[color=\"" + g_HotkeyColor + "\"]" +
|
||||
formatBatchTrainingString(data.buildingsCountToTrainFullBatch, data.fullBatchSize, data.remainderBatch) +
|
||||
"[/color]";
|
||||
|
||||
if (!data.technologyEnabled)
|
||||
{
|
||||
var techName = getEntityNames(GetTechnologyData(data.template.requiredTechnology));
|
||||
|
@ -289,6 +289,8 @@ function init(initData, hotloadData)
|
||||
if (Engine.IsAtlasRunning())
|
||||
Engine.GetGUIObjectByName("menuExitButton").enabled = false;
|
||||
|
||||
initHotkeyTooltips();
|
||||
|
||||
if (hotloadData)
|
||||
g_Selection.selected = hotloadData.selection;
|
||||
|
||||
@ -307,6 +309,19 @@ function init(initData, hotloadData)
|
||||
//setTimeout(function() { reportPerformance(60); }, 60000);
|
||||
}
|
||||
|
||||
function initHotkeyTooltips()
|
||||
{
|
||||
Engine.GetGUIObjectByName("idleWorkerButton").tooltip =
|
||||
colorizeHotkey("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")
|
||||
});
|
||||
}
|
||||
|
||||
function initializeMusic()
|
||||
{
|
||||
initMusic();
|
||||
|
@ -32,7 +32,6 @@
|
||||
</object>
|
||||
</repeat>
|
||||
<object name="tradeHelp" size="100%-24 4 100% 28" enabled="false" type="button" style="StoneButton" tooltip_style="sessionToolTipBold">
|
||||
<translatableAttribute id="tooltip">Select one goods as origin of the changes, then use the arrows of the target goods to make the changes (using Shift to select will put the selected resource to 100%).</translatableAttribute>
|
||||
<object size="20% 15% 80% 75%" type="image" ghost="true" sprite="iconInfoWhite"/>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -1001,9 +1001,13 @@ var g_EntityCommands =
|
||||
"icon": "kill_small_disabled.png"
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
"tooltip": translate("Delete"),
|
||||
"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")
|
||||
}),
|
||||
"icon": "kill_small.png"
|
||||
};
|
||||
},
|
||||
@ -1038,7 +1042,8 @@ var g_EntityCommands =
|
||||
return false;
|
||||
|
||||
return {
|
||||
"tooltip": translate("Stop"),
|
||||
"tooltip": colorizeHotkey("session.stop") + " " +
|
||||
translate("Abort the current order."),
|
||||
"icon": "stop.png"
|
||||
};
|
||||
},
|
||||
@ -1057,7 +1062,8 @@ var g_EntityCommands =
|
||||
return false;
|
||||
|
||||
return {
|
||||
"tooltip": translate("Garrison"),
|
||||
"tooltip": colorizeHotkey("session.garrison") + " " +
|
||||
translate("Order the selected units to garrison a building or unit."),
|
||||
"icon": "garrison.png"
|
||||
};
|
||||
},
|
||||
@ -1156,7 +1162,8 @@ var g_EntityCommands =
|
||||
return false;
|
||||
|
||||
return {
|
||||
"tooltip": translate("Guard"),
|
||||
"tooltip": colorizeHotkey("session.guard") + " " +
|
||||
translate("Order the selected units to guard a building or unit."),
|
||||
"icon": "add-guard.png"
|
||||
};
|
||||
},
|
||||
@ -1343,4 +1350,3 @@ function someGuarding(entities)
|
||||
return entState && entState.unitAI && entState.unitAI.isGuarding;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user