1
0
forked from 0ad/0ad

Add brief explanations to the tooltips of the alert buttons.

For a bit of added clarity.

Patch by: @abian
Differential revision: https://code.wildfiregames.com/D5095
Fixes #6850

This was SVN commit r27886.
This commit is contained in:
Freagarach 2023-10-13 09:34:51 +00:00
parent 29b57026a6
commit a54dbf4bfd
3 changed files with 23 additions and 5 deletions

View File

@ -63,10 +63,22 @@ g_SelectionPanels.Alert = {
case "raise":
data.icon.sprite = "stretched:session/icons/bell_level1.png";
data.button.tooltip = translate("Raise an alert!");
if (data.unitEntStates.every(state => MatchesClassList(["FemaleCitizen"], state.alertRaiser?.classes)))
data.button.tooltip += "\n" + bodyFont(translate("Alert nearby Female Citizens to seek refuge."));
else if (data.unitEntStates.every(state => MatchesClassList(["Trader"], state.alertRaiser?.classes)))
data.button.tooltip += "\n" + bodyFont(translate("Alert nearby Traders to seek refuge."));
else
data.button.tooltip += "\n" + bodyFont(translate("Alert nearby vulnerable units to seek refuge."));
break;
case "end":
data.button.tooltip = translate("End of alert.");
data.icon.sprite = "stretched:session/icons/bell_level0.png";
data.button.tooltip = translate("End the alert.");
if (data.unitEntStates.every(state => MatchesClassList(["FemaleCitizen"], state.alertRaiser?.classes)))
data.button.tooltip += "\n" + bodyFont(translate("Unload nearby Female Citizens."));
else if (data.unitEntStates.every(state => MatchesClassList(["Trader"], state.alertRaiser?.classes)))
data.button.tooltip += "\n" + bodyFont(translate("Unload nearby Traders."));
else
data.button.tooltip += "\n" + bodyFont(translate("Unload nearby vulnerable units."));
break;
}
data.button.enabled = controlsPlayer(data.player);
@ -961,8 +973,7 @@ g_SelectionPanels.Stance = {
let unitIds = data.unitEntStates.map(state => state.id);
data.button.onPress = function() { performStance(unitIds, data.item); };
data.button.tooltip = getStanceDisplayName(data.item) + "\n" +
"[font=\"sans-13\"]" + getStanceTooltip(data.item) + "[/font]";
data.button.tooltip = getStanceDisplayName(data.item) + "\n" + bodyFont(getStanceTooltip(data.item));
data.guiSelection.hidden = !Engine.GuiInterfaceCall("IsStanceSelected", {
"ents": unitIds,

View File

@ -17,10 +17,15 @@ AlertRaiser.prototype.Init = function()
this.lastTime = 0;
};
AlertRaiser.prototype.GetTargetClasses = function()
{
return this.template.List._string;
};
AlertRaiser.prototype.UnitFilter = function(unit)
{
let cmpIdentity = Engine.QueryInterface(unit, IID_Identity);
return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), this.template.List._string);
return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), this.GetTargetClasses());
};
AlertRaiser.prototype.RaiseAlert = function()

View File

@ -464,7 +464,9 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
let cmpAlertRaiser = Engine.QueryInterface(ent, IID_AlertRaiser);
if (cmpAlertRaiser)
ret.alertRaiser = true;
ret.alertRaiser = {
"classes": cmpAlertRaiser.GetTargetClasses()
};
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
ret.visibility = cmpRangeManager.GetLosVisibility(ent, player);