Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -364,6 +364,7 @@ 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] Index: ps/trunk/binaries/data/mods/public/gui/options/options.json =================================================================== --- ps/trunk/binaries/data/mods/public/gui/options/options.json +++ ps/trunk/binaries/data/mods/public/gui/options/options.json @@ -129,6 +129,12 @@ "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", "tooltip": "Dynamically sort players in the resources and population tooltip by value.", Index: ps/trunk/binaries/data/mods/public/gui/options/options.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/options/options.xml +++ ps/trunk/binaries/data/mods/public/gui/options/options.xml @@ -9,7 +9,7 @@ - + Game Options Index: ps/trunk/binaries/data/mods/public/gui/session/selection.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection.js @@ -14,8 +14,13 @@ 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) Index: ps/trunk/binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection_details.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection_details.js @@ -84,7 +84,7 @@ 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 @@ 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 Index: ps/trunk/binaries/data/mods/public/gui/session/session.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.js +++ ps/trunk/binaries/data/mods/public/gui/session/session.js @@ -1292,7 +1292,8 @@ Engine.GuiInterfaceCall("SetStatusBars", { "entities": entities, - "enabled": g_ShowAllStatusBars && !remove + "enabled": g_ShowAllStatusBars && !remove, + "showRank": Engine.ConfigDB_GetValue("user", "gui.session.rankabovestatusbar") == "true" }); } Index: ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -823,7 +823,7 @@ 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) Index: ps/trunk/binaries/data/mods/public/simulation/components/StatusBars.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/StatusBars.js +++ ps/trunk/binaries/data/mods/public/simulation/components/StatusBars.js @@ -26,11 +26,13 @@ "CaptureBar", "HealthBar", "AuraIcons", - ]; + "RankIcon" +]; StatusBars.prototype.Init = function() { this.enabled = false; + this.showRank = false; this.auraSources = new Map(); }; @@ -48,13 +50,14 @@ 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 @@ 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);