Skip to content

Commit

Permalink
Show remaining movement points in path planning UI (#11056)
Browse files Browse the repository at this point in the history
* Show remaining movement points in path planning UI

* Use movement icon for remaining moves on path
axatin authored Jun 29, 2024
1 parent 9540607 commit 320ee8d
Showing 4 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions (1) Community Patch/Community Patch.civ5proj
Original file line number Diff line number Diff line change
@@ -1173,6 +1173,10 @@
<SubType>Lua</SubType>
<ImportIntoVFS>True</ImportIntoVFS>
</Content>
<Content Include="Core Files\CoreLua\PathHelpManager.xml">
<SubType>Lua</SubType>
<ImportIntoVFS>True</ImportIntoVFS>
</Content>
<Content Include="Core Files\CoreLua\PathHelpManager.lua">
<SubType>Lua</SubType>
<ImportIntoVFS>True</ImportIntoVFS>
11 changes: 8 additions & 3 deletions (1) Community Patch/Core Files/CoreLua/PathHelpManager.lua
Original file line number Diff line number Diff line change
@@ -29,14 +29,19 @@ Events.UIPathFinderUpdate.Add( OnPath );
-------------------------------------------------
function BuildNode( data )
local instance = m_InstanceManager:GetInstance();

local wholeturns = math.floor(data.turn/10);
local remainder = data.turn - wholeturns*10;

-- see CvDllGameContext::TEMPCalculatePathFinderUpdates
local wholeturns = math.floor(data.turn/100);
local tmp = data.turn - wholeturns*100;
local totalmovementpoints = math.floor(tmp/10);
local remainder = tmp - totalmovementpoints*10;

if ( remainder == 0) then
instance.TurnLabel:SetText( wholeturns );
instance.RemainingMoves:SetText("");
else
instance.TurnLabel:SetText( "<" .. (wholeturns+1) );
instance.RemainingMoves:SetText("[ICON_MOVES]" .. remainder .. "/" .. totalmovementpoints);
end

local plot = Map.GetPlot( data.x, data.y );
16 changes: 16 additions & 0 deletions (1) Community Patch/Core Files/CoreLua/PathHelpManager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Context>

<Instance Name="TurnIndicator" >
<WorldAnchor ID="Anchor" >

<Label Anchor="C,C" Offset="0.0" Font="TwCenMT20" FontStyle="Stroke" ColorSet="Beige_Black" ID="TurnLabel" />
<Label Anchor="C,C" Offset="0.40" Font="TwCenMT14" FontStyle="Stroke" ColorSet="Beige_Black" ID="RemainingMoves" />


</WorldAnchor>
</Instance>

<Container ID="Container" />

</Context>
11 changes: 9 additions & 2 deletions CvGameCoreDLL_Expansion2/CvDllContext.cpp
Original file line number Diff line number Diff line change
@@ -1106,9 +1106,16 @@ ICvEnumerator* CvDllGameContext::TEMPCalculatePathFinderUpdates(ICvUnit1* pHeadS
update.iX = path.vPlots[i].x;
update.iY = path.vPlots[i].y;

update.iTurnNumber = path.vPlots[i].turns * 10; //fixed point float
// Structure of iTurnNumber:
// ones digit: the remaining movement points of the unit (rounded up if not an integer)
// tens digit: the total movement points of the unit
// all higher digits: the number of turns to reach the plot

CvPlot* pPlot = GC.getMap().plotUnchecked(path.vPlots[i].x, path.vPlots[i].y);
update.iTurnNumber = path.vPlots[i].turns * 100;
update.iTurnNumber += 10 * (min(pkUnit->baseMoves(pPlot->needsEmbarkation(pkUnit)), 9));
if (path.vPlots[i].moves>0)
update.iTurnNumber += 5; //indicate that there are movement points left
update.iTurnNumber += min(((int)path.vPlots[i].moves-1)/GD_INT_GET(MOVE_DENOMINATOR)+1, 9); //movement points left

//in debug mode just use the raw number, it's actually the known cost
if (eMode==TC_DEBUG)

0 comments on commit 320ee8d

Please sign in to comment.