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 @@ -151,6 +151,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) + }); +} + /** * Converts an armor level into the actual reduction percentage */ Index: binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- binaries/data/mods/public/gui/session/selection_details.js +++ binaries/data/mods/public/gui/session/selection_details.js @@ -139,11 +139,13 @@ captureSection.size = showResource ? sectionPosMiddle.size : sectionPosBottom.size; resourceSection.size = showResource ? sectionPosBottom.size : sectionPosMiddle.size; } - else + else if (showResource) { captureSection.size = sectionPosBottom.size; resourceSection.size = sectionPosTop.size; } + else + captureSection.size = sectionPosTop.size; // CapturePoints captureSection.hidden = !entState.capturePoints; 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 @@ -906,6 +906,45 @@ [resumeGame, leaveGame]); } +function updatePanelEntityBars(panelEnt, slot) +{ + let healthSection = Engine.GetGUIObjectByName("panelEntityHealthSection[" + slot + "]"); + let captureSection = Engine.GetGUIObjectByName("panelEntityCaptureSection[" + slot + "]"); + + healthSection.hidden = !panelEnt.health; + captureSection.hidden = !panelEnt.capture; + + if (!healthSection.hidden) + updateGUIStatusBar("panelEntityHealthBar[" + slot + "]", panelEnt.health.currentHitpoints, panelEnt.health.maxHitpoints); + + if (!captureSection.hidden) + { + updateGUICaptureStatusBar("panelEntityCaptureBar[" + slot + "]", panelEnt.capture.currentCapturePoints, panelEnt.capture.maxCapturePoints, panelEnt.player); + + if (healthSection.hidden) + captureSection.size = Engine.GetGUIObjectByName("panelEntitySectionPosTop[" + slot + "]").size; + } +} + +function updateGUICaptureStatusBar(nameOfBar, points, totalPoints, owner) +{ + let setCaptureBarPart = function(player, startSize) { + let captureBar = Engine.GetGUIObjectByName(nameOfBar + "[" + player + "]"); + let size = captureBar.size; + size.rleft = startSize; + size.rright = startSize + 100 * points[player] / totalPoints; + captureBar.size = size; + captureBar.sprite = "color:" + rgbToGuiColor(g_DisplayedPlayerColors[player]); + captureBar.hidden = false; + return size.rright; + }; + + let size = setCaptureBarPart(owner, 0); + for (let i in points) + if (i != owner) + size = setCaptureBarPart(i, size); +} + /** * updates a status bar on the GUI * nameOfBar: name of the bar @@ -963,19 +1002,30 @@ { panelEnt = { "ent": ent, - "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 = {}; + if (panelEntState.capturePoints) + panelEnt.capture = {}; g_PanelEntities.push(panelEnt); } panelEnt.tooltip = createPanelEntityTooltip(panelEntState, template); - panelEnt.previousHitpoints = panelEnt.currentHitpoints; - panelEnt.currentHitpoints = panelEntState.hitpoints; - panelEnt.maxHitpoints = panelEntState.maxHitpoints; + panelEnt.player = panelEntState.player; + + if (panelEnt.health) + panelEnt.health = { + "previousHitpoints": panelEnt.health.currentHitpoints, + "currentHitpoints": panelEntState.hitpoints, + "maxHitpoints": panelEntState.maxHitpoints + }; + if (panelEnt.capture) + panelEnt.capture = { + "previousCapturePoints": panelEnt.capture.currentCapturePoints ? panelEnt.capture.currentCapturePoints[panelEnt.player] : 0, + "currentCapturePoints": panelEntState.capturePoints, + "maxCapturePoints": panelEntState.maxCapturePoints + }; } let panelEntIndex = ent => g_PanelEntityOrder.findIndex(entClass => @@ -991,6 +1041,7 @@ return [ getPanelEntNameTooltip, getCurrentHealthTooltip, + getCurrentCaptureTooltip, getAttackTooltip, getArmorTooltip, getEntityTooltip, @@ -1024,7 +1075,7 @@ let panelEntButton = Engine.GetGUIObjectByName("panelEntityButton[" + slot + "]"); panelEntButton.tooltip = panelEnt.tooltip; - updateGUIStatusBar("panelEntityHealthBar[" + slot + "]", panelEnt.currentHitpoints, panelEnt.maxHitpoints); + updatePanelEntityBars(panelEnt, slot); if (panelEnt.slot === undefined) { @@ -1035,8 +1086,14 @@ panelEnt.slot = slot; } - // If the health of the panelEnt changed since the last update, trigger the animation. - if (panelEnt.previousHitpoints > panelEnt.currentHitpoints) + + + let panelEntBackground = Engine.GetGUIObjectByName("panelEntityBackground[" + slot + "]"); + panelEntBackground.sprite = panelEnt.player != 0 ? getPlayerHighlightColor(panelEnt.player) : ""; + + // If the health or capture points of the panelEnt has decreased since the last update, trigger blinking. + if (panelEnt.health && panelEnt.health.previousHitpoints > panelEnt.health.currentHitpoints || + panelEnt.capture && panelEnt.capture.previousCapturePoints > 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 @@ -1,15 +1,21 @@