Map exploration counter for summary screen
This was SVN commit r8679.
This commit is contained in:
parent
333492b4a9
commit
e4d356c3bf
@ -77,6 +77,7 @@ function init(data)
|
||||
getGUIObjectByName("playerName1Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
|
||||
getGUIObjectByName("civCentresBuiltHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("enemyCivCentresDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("mapExplorationHeading").size = left + " 6 " + (left + width) + " 100%"; left += width;
|
||||
|
||||
var left = 50;
|
||||
getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
|
||||
@ -122,6 +123,7 @@ function init(data)
|
||||
|
||||
var civCentresBuilt = getGUIObjectByName("civCentresBuilt["+i+"]");
|
||||
var enemyCivCentresDestroyed = getGUIObjectByName("enemyCivCentresDestroyed["+i+"]");
|
||||
var mapExploration = getGUIObjectByName("mapExploration["+i+"]");
|
||||
|
||||
var foodGathered = getGUIObjectByName("foodGathered["+i+"]");
|
||||
var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");
|
||||
@ -146,6 +148,7 @@ function init(data)
|
||||
var left = 240;
|
||||
civCentresBuilt.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
enemyCivCentresDestroyed.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
mapExploration.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
var size = getGUIObjectByName("playerBox1["+i+"]").size;
|
||||
size.right = left + 10;
|
||||
getGUIObjectByName("playerBox1["+i+"]").size = size;
|
||||
@ -170,6 +173,7 @@ function init(data)
|
||||
|
||||
civCentresBuilt.caption = playerState.statistics.civCentresBuilt;
|
||||
enemyCivCentresDestroyed.caption = playerState.statistics.enemyCivCentresDestroyed;
|
||||
mapExploration.caption = playerState.statistics.percentMapExplored + "%";
|
||||
|
||||
foodGathered.caption = playerState.statistics.resourcesGathered.food;
|
||||
vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ?
|
||||
|
@ -108,7 +108,9 @@
|
||||
<object name="enemyCivCentresDestroyedHeading" type="text" text_align="center" font="serif-bold-14" >
|
||||
Enemy civ centres destroyed
|
||||
</object>
|
||||
|
||||
<object name="mapExplorationHeading" type="text" text_align="center" font="serif-bold-14" >
|
||||
Map exploration
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object size="0 65 100% 100%-50">
|
||||
@ -119,6 +121,7 @@
|
||||
<object name="civIcon1[n]" type="image" size="208 0 240 32"/>
|
||||
<object name="civCentresBuilt[n]" type="text" text_align="center" />
|
||||
<object name="enemyCivCentresDestroyed[n]" type="text" text_align="center" />
|
||||
<object name="mapExploration[n]" type="text" text_align="center" />
|
||||
</object>
|
||||
</repeat>
|
||||
</object>
|
||||
|
@ -39,7 +39,8 @@ StatisticsTracker.prototype.GetStatistics = function()
|
||||
"civCentresBuilt": this.civCentresBuilt,
|
||||
"enemyCivCentresDestroyed": this.enemyCivCentresDestroyed,
|
||||
"resourcesGathered": this.resourcesGathered,
|
||||
"treasuresCollected": this.treasuresCollected
|
||||
"treasuresCollected": this.treasuresCollected,
|
||||
"percentMapExplored": this.GetPercentMapExplored()
|
||||
};
|
||||
};
|
||||
|
||||
@ -116,4 +117,11 @@ StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
|
||||
return this.treasuresCollected++;
|
||||
};
|
||||
|
||||
StatisticsTracker.prototype.GetPercentMapExplored = function()
|
||||
{
|
||||
var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
||||
return cmpRangeManager.GetPercentMapExplored(cmpPlayer.GetPlayerID());
|
||||
};
|
||||
|
||||
Engine.RegisterComponentType(IID_StatisticsTracker, "StatisticsTracker", StatisticsTracker);
|
||||
|
@ -68,6 +68,7 @@ AddMock(100, IID_StatisticsTracker, {
|
||||
"vegetarianFood": 0,
|
||||
},
|
||||
"treasuresCollected": 0,
|
||||
"percentMapExplored": 10,
|
||||
};
|
||||
},
|
||||
IncreaseTrainedUnitsCounter: function() { return 1; },
|
||||
@ -106,6 +107,7 @@ AddMock(101, IID_StatisticsTracker, {
|
||||
"vegetarianFood": 0,
|
||||
},
|
||||
"treasuresCollected": 0,
|
||||
"percentMapExplored": 10,
|
||||
};
|
||||
},
|
||||
IncreaseTrainedUnitsCounter: function() { return 1; },
|
||||
@ -174,6 +176,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
||||
vegetarianFood: 0,
|
||||
},
|
||||
treasuresCollected: 0,
|
||||
percentMapExplored: 10,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -202,6 +205,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
||||
vegetarianFood: 0,
|
||||
},
|
||||
treasuresCollected: 0,
|
||||
percentMapExplored: 10,
|
||||
},
|
||||
}
|
||||
],
|
||||
|
@ -581,8 +581,6 @@ public:
|
||||
m_DebugOverlayLines.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Update all currently-enabled active queries.
|
||||
*/
|
||||
@ -1173,6 +1171,26 @@ private:
|
||||
LosUpdateHelperIncremental(owner, visionRange, from, to);
|
||||
}
|
||||
}
|
||||
|
||||
virtual i32 GetPercentMapExplored(player_id_t playerId)
|
||||
{
|
||||
i32 exploredVertices = 0;
|
||||
i32 overallVisibleVertices = 0;
|
||||
CLosQuerier los(playerId, m_LosState, m_TerrainVerticesPerSide);
|
||||
|
||||
for (i32 j = 0; j < m_TerrainVerticesPerSide; j++)
|
||||
{
|
||||
for (i32 i = 0; i < m_TerrainVerticesPerSide; i++)
|
||||
{
|
||||
if (!LosIsOffWorld(i, j))
|
||||
{
|
||||
overallVisibleVertices++;
|
||||
exploredVertices += (i32)los.IsExplored(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return exploredVertices * 100 / overallVisibleVertices;
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_COMPONENT_TYPE(RangeManager)
|
||||
|
@ -46,4 +46,5 @@ DEFINE_INTERFACE_METHOD_1("SetLosRevealAll", void, ICmpRangeManager, SetLosRevea
|
||||
DEFINE_INTERFACE_METHOD_2("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, int)
|
||||
DEFINE_INTERFACE_METHOD_1("SetLosCircular", void, ICmpRangeManager, SetLosCircular, bool)
|
||||
DEFINE_INTERFACE_METHOD_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular)
|
||||
DEFINE_INTERFACE_METHOD_1("GetPercentMapExplored", i32, ICmpRangeManager, GetPercentMapExplored, player_id_t)
|
||||
END_INTERFACE_WRAPPER(RangeManager)
|
||||
|
@ -19,8 +19,8 @@
|
||||
#define INCLUDED_ICMPRANGEMANAGER
|
||||
|
||||
#include "simulation2/system/Interface.h"
|
||||
|
||||
#include "simulation2/helpers/Position.h"
|
||||
#include "simulation2/helpers/Player.h"
|
||||
|
||||
#include "graphics/Terrain.h" // for CELL_SIZE
|
||||
|
||||
@ -258,6 +258,11 @@ public:
|
||||
*/
|
||||
virtual bool GetLosCircular() = 0;
|
||||
|
||||
/**
|
||||
* Get percent map explored statistics for specified player
|
||||
*/
|
||||
virtual i32 GetPercentMapExplored(player_id_t playerId) = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(RangeManager)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user