Show rank icon above status bars
Reviewed by: bb Fixes: #5005 Differential Revision: https://code.wildfiregames.com/D717 This was SVN commit r21076.
This commit is contained in:
parent
2bfb580415
commit
776899c254
@ -364,6 +364,7 @@ woundedunithotkeythreshold = 33 ; The wounded unit hotkey considers the select
|
||||
attackrange = true ; Display attack range overlays of selected defensive structures
|
||||
aurasrange = true ; Display aura range overlays of selected units and structures
|
||||
healrange = true ; Display heal range overlays of selected units
|
||||
rankabovestatusbar = true ; Show rank icons above status bars
|
||||
respoptooltipsort = 0 ; Sorting players in the resources and population tooltip by value (0 - no sort, -1 - ascending, 1 - descending)
|
||||
|
||||
[gui.session.minimap]
|
||||
|
@ -128,6 +128,12 @@
|
||||
"tooltip": "Display the healing range of selected units (can also be toggled in-game with the hotkey).",
|
||||
"config": "gui.session.healrange"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"label": "Rank icon above status bar",
|
||||
"tooltip": "Show rank icons above status bars",
|
||||
"config": "gui.session.rankabovestatusbar"
|
||||
},
|
||||
{
|
||||
"type": "dropdown",
|
||||
"label": "Sort resources and population tooltip",
|
||||
|
@ -9,7 +9,7 @@
|
||||
<object type="image" sprite="ModernFade"/>
|
||||
|
||||
<!-- Settings Window -->
|
||||
<object name="options" type="image" style="ModernDialog" size="50%-350 50%-330 50%+350 50%+330">
|
||||
<object name="options" type="image" style="ModernDialog" size="50%-350 50%-332 50%+350 50%+332">
|
||||
|
||||
<object style="ModernLabelText" type="text" size="50%-128 -16 50%+128 16">
|
||||
<translatableAttribute id="caption">Game Options</translatableAttribute>
|
||||
|
@ -14,8 +14,13 @@ function _setHighlight(ents, alpha, selected)
|
||||
|
||||
function _setStatusBars(ents, enabled)
|
||||
{
|
||||
if (ents.length)
|
||||
Engine.GuiInterfaceCall("SetStatusBars", { "entities": ents, "enabled": enabled });
|
||||
if (!ents.length)
|
||||
return;
|
||||
Engine.GuiInterfaceCall("SetStatusBars", {
|
||||
"entities": ents,
|
||||
"enabled": enabled,
|
||||
"showRank": Engine.ConfigDB_GetValue("user", "gui.session.rankabovestatusbar") == "true"
|
||||
});
|
||||
}
|
||||
|
||||
function _setMotionOverlay(ents, enabled)
|
||||
|
@ -84,7 +84,7 @@ function displaySingle(entState)
|
||||
Engine.GetGUIObjectByName("rankIcon").tooltip = sprintf(translate("%(rank)s Rank"), {
|
||||
"rank": translateWithContext("Rank", entState.identity.rank)
|
||||
});
|
||||
Engine.GetGUIObjectByName("rankIcon").sprite = getRankIconSprite(entState);
|
||||
Engine.GetGUIObjectByName("rankIcon").sprite = "stretched:session/icons/ranks/" + entState.identity.rank + ".png";
|
||||
Engine.GetGUIObjectByName("rankIcon").hidden = false;
|
||||
}
|
||||
else
|
||||
@ -476,20 +476,6 @@ function updateSelectionDetails()
|
||||
updateGarrisonHealthBar(entStates[0], g_Selection.toList());
|
||||
}
|
||||
|
||||
function getRankIconSprite(entState)
|
||||
{
|
||||
if (entState.identity.rank == "Elite")
|
||||
return "stretched:session/icons/rank3.png";
|
||||
|
||||
if (entState.identity.rank == "Advanced")
|
||||
return "stretched:session/icons/rank2.png";
|
||||
|
||||
if (entState.identity.classes.indexOf("CitizenSoldier") != -1)
|
||||
return "stretched:session/icons/rank1.png";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function tradingGainString(gain, owner)
|
||||
{
|
||||
// Translation: Used in the trading gain tooltip
|
||||
|
@ -1292,7 +1292,8 @@ function recalculateStatusBarDisplay(remove = false)
|
||||
|
||||
Engine.GuiInterfaceCall("SetStatusBars", {
|
||||
"entities": entities,
|
||||
"enabled": g_ShowAllStatusBars && !remove
|
||||
"enabled": g_ShowAllStatusBars && !remove,
|
||||
"showRank": Engine.ConfigDB_GetValue("user", "gui.session.rankabovestatusbar") == "true"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ GuiInterface.prototype.SetStatusBars = function(player, cmd)
|
||||
let cmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars);
|
||||
if (!cmpStatusBars)
|
||||
continue;
|
||||
cmpStatusBars.SetEnabled(cmd.enabled);
|
||||
cmpStatusBars.SetEnabled(cmd.enabled, cmd.showRank);
|
||||
|
||||
let cmpAuras = Engine.QueryInterface(ent, IID_Auras);
|
||||
if (!cmpAuras)
|
||||
|
@ -26,11 +26,13 @@ StatusBars.prototype.Sprites = [
|
||||
"CaptureBar",
|
||||
"HealthBar",
|
||||
"AuraIcons",
|
||||
];
|
||||
"RankIcon"
|
||||
];
|
||||
|
||||
StatusBars.prototype.Init = function()
|
||||
{
|
||||
this.enabled = false;
|
||||
this.showRank = false;
|
||||
this.auraSources = new Map();
|
||||
};
|
||||
|
||||
@ -48,13 +50,14 @@ StatusBars.prototype.Deserialize = function(data)
|
||||
this.auraSources = data.auraSources;
|
||||
};
|
||||
|
||||
StatusBars.prototype.SetEnabled = function(enabled)
|
||||
StatusBars.prototype.SetEnabled = function(enabled, showRank)
|
||||
{
|
||||
// Quick return if no change
|
||||
if (enabled == this.enabled)
|
||||
if (enabled == this.enabled && showRank == this.showRank)
|
||||
return;
|
||||
|
||||
this.enabled = enabled;
|
||||
this.showRank = showRank;
|
||||
|
||||
// Update the displayed sprites
|
||||
this.RegenerateSprites();
|
||||
@ -269,4 +272,24 @@ StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset)
|
||||
return iconSize + this.template.BarHeight / 2;
|
||||
};
|
||||
|
||||
StatusBars.prototype.AddRankIcon = function(cmpOverlayRenderer, yoffset)
|
||||
{
|
||||
if (!this.enabled || !this.showRank)
|
||||
return 0;
|
||||
|
||||
let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
|
||||
if (!cmpIdentity || !cmpIdentity.GetRank())
|
||||
return 0;
|
||||
|
||||
let iconSize = +this.template.BarWidth / 2;
|
||||
cmpOverlayRenderer.AddSprite(
|
||||
"art/textures/ui/session/icons/ranks/" + cmpIdentity.GetRank() + ".png",
|
||||
{ "x": -iconSize / 2, "y": yoffset },
|
||||
{ "x": iconSize / 2, "y": iconSize + yoffset },
|
||||
{ "x": 0, "y": +this.template.HeightOffset + 0.1, "z": 0 },
|
||||
g_NaturalColor);
|
||||
|
||||
return iconSize + this.template.BarHeight / 2;
|
||||
};
|
||||
|
||||
Engine.RegisterComponentType(IID_StatusBars, "StatusBars", StatusBars);
|
||||
|
Loading…
Reference in New Issue
Block a user