Index: binaries/data/mods/public/gui/common/tooltips.js =================================================================== --- binaries/data/mods/public/gui/common/tooltips.js +++ binaries/data/mods/public/gui/common/tooltips.js @@ -179,6 +179,18 @@ }); } +function getCurrentCaptureTooltip(entState, label) +{ + if (!entState.maxCapturePoints) + return ""; + + return sprintf(translate("%(captureLabel)s %(current)s / %(max)s"), { + "captureLabel": headerFont(label || translate("Capture points:")), + "current": Math.round(entState.capturePoints[entState.player]), + "max": Math.round(entState.maxCapturePoints) + }); +} + function attackRateDetails(template, type) { // Either one arrow shot by UnitAI, Index: binaries/data/mods/public/gui/session/session.js =================================================================== --- binaries/data/mods/public/gui/session/session.js +++ binaries/data/mods/public/gui/session/session.js @@ -1029,19 +1029,38 @@ { panelEnt = { "ent": ent, + "player": panelEntState.player, "tooltip": undefined, - "sprite": "stretched:session/portraits/" + template.icon, - "maxHitpoints": undefined, - "currentHitpoints": panelEntState.hitpoints, - "previousHitpoints": undefined + "sprite": "stretched:session/portraits/" + template.icon }; + if (panelEntState.hitpoints) + panelEnt.health = { + "maxHitpoints": undefined, + "currentHitpoints": panelEntState.hitpoints, + "previousHitpoints": undefined + }; + if (panelEntState.capturePoints) + panelEnt.capture = { + "maxCapturePoints": undefined, + "currentCapturePoints": panelEntState.capturePoints, + "previousCapturePoints": undefined + }; g_PanelEntities.push(panelEnt); } panelEnt.tooltip = createPanelEntityTooltip(panelEntState, template); - panelEnt.previousHitpoints = panelEnt.currentHitpoints; - panelEnt.currentHitpoints = panelEntState.hitpoints; - panelEnt.maxHitpoints = panelEntState.maxHitpoints; + if (panelEnt.health) + panelEnt.health = { + "previousHitpoints": panelEnt.health.currentHitpoints, + "currentHitpoints": panelEntState.hitpoints, + "maxHitpoints": panelEntState.maxHitpoints + }; + if (panelEnt.capture) + panelEnt.capture = { + "previousCapturePoints": panelEnt.capture.currentCapturePoints, + "currentCapturePoints": panelEntState.capturePoints, + "maxCapturePoints": panelEntState.maxCapturePoints + }; } let panelEntIndex = ent => g_PanelEntityOrder.findIndex(entClass => @@ -1057,6 +1076,7 @@ return [ getPanelEntNameTooltip, getCurrentHealthTooltip, + getCurrentCaptureTooltip, getAttackTooltip, getArmorTooltip, getEntityTooltip, @@ -1090,7 +1110,37 @@ let panelEntButton = Engine.GetGUIObjectByName("panelEntityButton[" + slot + "]"); panelEntButton.tooltip = panelEnt.tooltip; - updateGUIStatusBar("panelEntityHealthBar[" + slot + "]", panelEnt.currentHitpoints, panelEnt.maxHitpoints); + if (panelEnt.health) + { + Engine.GetGUIObjectByName("panelEntityHealthSection[" + slot + "]").hidden = false; + updateGUIStatusBar("panelEntityHealthBar[" + slot + "]", panelEnt.health.currentHitpoints, panelEnt.health.maxHitpoints); + } + + if (panelEnt.capture) + { + Engine.GetGUIObjectByName("panelEntityCaptureSection[" + slot + "]").hidden = false; + + let setCaptureBarPart = function(playerID, startSize) { + let unitCaptureBar = Engine.GetGUIObjectByName("panelEntity[" + slot + "].CaptureBar[" + playerID + "]"); + let sizeObj = unitCaptureBar.size; + sizeObj.rleft = startSize; + + let size = 100 * Math.max(0, Math.min(1, panelEnt.capture.currentCapturePoints[playerID] / panelEnt.capture.maxCapturePoints)); + sizeObj.rright = startSize + size; + unitCaptureBar.size = sizeObj; + unitCaptureBar.sprite = "color:" + rgbToGuiColor(g_DisplayedPlayerColors[playerID], 128); + unitCaptureBar.hidden = false; + return startSize + size; + }; + + // first handle the owner's points, to keep those points on the left for clarity + let size = setCaptureBarPart(panelEnt.player, 0); + + for (let i in panelEnt.capture.currentCapturePoints) + if (i != panelEnt.player) + size = setCaptureBarPart(i, size); + + } if (panelEnt.slot === undefined) { @@ -1102,7 +1152,12 @@ } // If the health of the panelEnt changed since the last update, trigger the animation. - if (panelEnt.previousHitpoints > panelEnt.currentHitpoints) + if (panelEnt.health && panelEnt.health.previousHitpoints > panelEnt.health.currentHitpoints) + startColorFade("panelEntityHitOverlay[" + slot + "]", 100, 0, + colorFade_attackUnit, true, smoothColorFadeRestart_attackUnit); + + // If the capture points of the panelEnt changed since the last update, trigger the animation. + if (panelEnt.capture && panelEnt.capture.previousCapturePoints[panelEnt.player] > panelEnt.capture.currentCapturePoints[panelEnt.player]) startColorFade("panelEntityHitOverlay[" + slot + "]", 100, 0, colorFade_attackUnit, true, smoothColorFadeRestart_attackUnit); Index: binaries/data/mods/public/gui/session/session_objects/panel_entities.xml =================================================================== --- binaries/data/mods/public/gui/session/session_objects/panel_entities.xml +++ binaries/data/mods/public/gui/session/session_objects/panel_entities.xml @@ -9,7 +9,7 @@