From 505a10cef652aba0a4d1c68f76acd3e74384e2af Mon Sep 17 00:00:00 2001 From: elexis Date: Tue, 8 Aug 2017 12:48:57 +0000 Subject: [PATCH] Display rallypoints in the playercolor instead of plain blue. Differential Revision: https://code.wildfiregames.com/D623 Fixes #4618 Patch By: Stan This was SVN commit r19957. --- .../templates/template_structure.xml | 3 +- .../components/CCmpRallyPointRenderer.cpp | 53 +++++++++++-------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/binaries/data/mods/public/simulation/templates/template_structure.xml b/binaries/data/mods/public/simulation/templates/template_structure.xml index 5e65547ddf..373843bc5d 100644 --- a/binaries/data/mods/public/simulation/templates/template_structure.xml +++ b/binaries/data/mods/public/simulation/templates/template_structure.xml @@ -94,8 +94,7 @@ special/rallypoint art/textures/misc/rallypoint_line.png art/textures/misc/rallypoint_line_mask.png - 0.2 - + 0.25 square round diff --git a/source/simulation2/components/CCmpRallyPointRenderer.cpp b/source/simulation2/components/CCmpRallyPointRenderer.cpp index 8f8777e9cf..85d3cb9afe 100644 --- a/source/simulation2/components/CCmpRallyPointRenderer.cpp +++ b/source/simulation2/components/CCmpRallyPointRenderer.cpp @@ -137,7 +137,6 @@ public: "0.75" "round" "square" - "" "" "default" "" @@ -153,17 +152,6 @@ public: "" "" "" - "" - "" - "0255" - "" - "" - "0255" - "" - "" - "0255" - "" - "" "" "" "0255" @@ -228,7 +216,9 @@ public: break; case MT_OwnershipChanged: { - UpdateMarkers(); // update marker variation to new player's civilization + // Update marker variation to the new player's civilization + UpdateMarkers(); + UpdateLineColor(); } break; case MT_TurnStart: @@ -349,6 +339,11 @@ private: UpdateMessageSubscriptions(); } + /** + * Helper function to set the line color to its owner's color. + */ + void UpdateLineColor(); + /** * Repositions the rally point markers; moves them outside of the world (ie. hides them), or positions them at the currently * set rally points. Also updates the actor's variation according to the entity's current owning player's civilization. @@ -451,19 +446,11 @@ void CCmpRallyPointRenderer::Init(const CParamNode& paramNode) m_LastMarkerCount = 0; m_EnableDebugNodeOverlay = false; + UpdateLineColor(); // --------------------------------------------------------------------------------------------- // load some XML configuration data (schema guarantees that all these nodes are valid) m_MarkerTemplate = paramNode.GetChild("MarkerTemplate").ToString(); - - const CParamNode& lineColor = paramNode.GetChild("LineColor"); - m_LineColor = CColor( - lineColor.GetChild("@r").ToInt()/255.f, - lineColor.GetChild("@g").ToInt()/255.f, - lineColor.GetChild("@b").ToInt()/255.f, - 1.f - ); - const CParamNode& lineDashColor = paramNode.GetChild("LineDashColor"); m_LineDashColor = CColor( lineDashColor.GetChild("@r").ToInt()/255.f, @@ -562,6 +549,28 @@ void CCmpRallyPointRenderer::UpdateMarkers() m_LastMarkerCount = m_RallyPoints.size() - 1; } + +void CCmpRallyPointRenderer::UpdateLineColor() +{ + CmpPtr cmpOwnership(GetEntityHandle()); + if (!cmpOwnership) + return; + + player_id_t owner = cmpOwnership->GetOwner(); + if (owner == INVALID_PLAYER) + return; + + CmpPtr cmpPlayerManager(GetSystemEntity()); + if (!cmpPlayerManager) + return; + + CmpPtr cmpPlayer(GetSimContext(), cmpPlayerManager->GetPlayerByID(owner)); + if (!cmpPlayer) + return; + + m_LineColor = cmpPlayer->GetColor(); +} + void CCmpRallyPointRenderer::RecomputeAllRallyPointPaths() { m_Path.clear();