Add tribute stats to the summary screen. Patch by alpha123. Fixes #1831.
This was SVN commit r13149.
This commit is contained in:
parent
14f1917a34
commit
5cbd9f0314
@ -85,6 +85,8 @@ function init(data)
|
||||
var left = 50;
|
||||
var width = 100;
|
||||
var playerNameHeadingWidth = 200;
|
||||
// Special cased to make the (Sent / Received) part fit
|
||||
var tributesWidth = 121;
|
||||
getGUIObjectByName("playerName0Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
|
||||
getGUIObjectByName("economyScoreHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("militaryScoreHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
@ -98,7 +100,7 @@ function init(data)
|
||||
getGUIObjectByName("enemyUnitsKilledHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("buildingsConstructedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("buildingsLostHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("enemyBuildingsDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("enemyBuildingsDestroyedHeading").size = left + " 6 " + (left + width) + " 100%"; left += width;
|
||||
|
||||
left = 50;
|
||||
getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
|
||||
@ -115,6 +117,7 @@ function init(data)
|
||||
getGUIObjectByName("metalGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("treasuresCollectedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
|
||||
getGUIObjectByName("resourcesTributedHeading").size = left + " 16 " + (left + tributesWidth) + " 100%"; left += tributesWidth;
|
||||
|
||||
left = 50;
|
||||
getGUIObjectByName("playerName4Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
|
||||
@ -176,6 +179,7 @@ function init(data)
|
||||
var metalGathered = getGUIObjectByName("metalGathered["+i+"]");
|
||||
var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");
|
||||
var treasuresCollected = getGUIObjectByName("treasuresCollected["+i+"]");
|
||||
var resourcesTributed = getGUIObjectByName("resourcesTributed["+i+"]");
|
||||
|
||||
var exchangedFood = getGUIObjectByName("exchangedFood["+i+"]");
|
||||
var exchangedWood = getGUIObjectByName("exchangedWood["+i+"]");
|
||||
@ -222,6 +226,7 @@ function init(data)
|
||||
metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
treasuresCollected.size = left + " 2 " + (left + width) + " 100%"; left += width;
|
||||
resourcesTributed.size = left + " 2 " + (left + tributesWidth) + " 100%"; left += tributesWidth;
|
||||
size = getGUIObjectByName("playerBox3["+i+"]").size;
|
||||
size.right = left + 10;
|
||||
getGUIObjectByName("playerBox3["+i+"]").size = size;
|
||||
@ -259,15 +264,17 @@ function init(data)
|
||||
const BOUGHT_COLOR = '[color="255 213 213"]';
|
||||
foodGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.food + "[/color] / " +
|
||||
BOUGHT_COLOR + (playerState.statistics.resourcesUsed.food - playerState.statistics.resourcesSold.food) + "[/color]";
|
||||
woodGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.wood + "[/color] / " +
|
||||
woodGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.wood + "[/color] / " +
|
||||
BOUGHT_COLOR + (playerState.statistics.resourcesUsed.wood - playerState.statistics.resourcesSold.wood) + "[/color]";
|
||||
stoneGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.stone + "[/color] / " +
|
||||
stoneGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.stone + "[/color] / " +
|
||||
BOUGHT_COLOR + (playerState.statistics.resourcesUsed.stone - playerState.statistics.resourcesSold.stone) + "[/color]";
|
||||
metalGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.metal + "[/color] / " +
|
||||
metalGathered.caption = SOLD_COLOR + playerState.statistics.resourcesGathered.metal + "[/color] / " +
|
||||
BOUGHT_COLOR + (playerState.statistics.resourcesUsed.metal - playerState.statistics.resourcesSold.metal) + "[/color]";
|
||||
vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ?
|
||||
(playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%";
|
||||
treasuresCollected.caption = playerState.statistics.treasuresCollected;
|
||||
resourcesTributed.caption = SOLD_COLOR + playerState.statistics.tributesSent + "[/color] / " +
|
||||
BOUGHT_COLOR + playerState.statistics.tributesReceived + "[/color]";
|
||||
|
||||
exchangedFood.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.food
|
||||
+ '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.food + '[/color]';
|
||||
|
@ -116,7 +116,7 @@
|
||||
</repeat>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
</object>
|
||||
<object name="unitsBuildingsPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true">
|
||||
|
||||
<object size="0 0 100% 100%-50">
|
||||
@ -141,7 +141,6 @@
|
||||
<object name="enemyBuildingsDestroyedHeading" type="text" style="CenteredTabLabelText">
|
||||
Enemy buildings destroyed
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
||||
<object size="0 65 100% 100%-50">
|
||||
@ -219,6 +218,9 @@
|
||||
<object name="treasuresCollectedHeading" type="text" style="CenteredTabLabelText">
|
||||
Treasures collected
|
||||
</object>
|
||||
<object name="resourcesTributedHeading" type="text" style="CenteredTabLabelText">
|
||||
Tributes (Sent / Received)
|
||||
</object>
|
||||
</object>
|
||||
|
||||
<object size="0 65 100% 100%-50">
|
||||
@ -233,6 +235,7 @@
|
||||
<object name="metalGathered[n]" type="text" style="CenteredLabelText"/>
|
||||
<object name="vegetarianRatio[n]" type="text" style="CenteredLabelText"/>
|
||||
<object name="treasuresCollected[n]" type="text" style="CenteredLabelText"/>
|
||||
<object name="resourcesTributed[n]" type="text" style="CenteredLabelText"/>
|
||||
</object>
|
||||
</repeat>
|
||||
</object>
|
||||
|
@ -539,6 +539,14 @@ Player.prototype.TributeResource = function(player, amounts)
|
||||
this.resourceCount[type] -= amounts[type];
|
||||
|
||||
cmpPlayer.AddResources(amounts);
|
||||
|
||||
var total = Object.keys(amounts).reduce(function (sum, type){ return sum + amounts[type]; }, 0);
|
||||
var cmpOurStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker);
|
||||
if (cmpOurStatisticsTracker)
|
||||
cmpOurStatisticsTracker.IncreaseTributesSentCounter(total);
|
||||
var cmpTheirStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker);
|
||||
if (cmpTheirStatisticsTracker)
|
||||
cmpTheirStatisticsTracker.IncreaseTributesReceivedCounter(total);
|
||||
// TODO: notify the receiver
|
||||
}
|
||||
// else not enough resources... TODO: send gui notification
|
||||
|
@ -46,6 +46,8 @@ StatisticsTracker.prototype.Init = function()
|
||||
"metal": 0,
|
||||
"stone": 0
|
||||
};
|
||||
this.tributesSent = 0;
|
||||
this.tributesReceived = 0;
|
||||
this.tradeIncome = 0;
|
||||
this.treasuresCollected = 0;
|
||||
};
|
||||
@ -69,6 +71,8 @@ StatisticsTracker.prototype.GetStatistics = function()
|
||||
"resourcesUsed": this.resourcesUsed,
|
||||
"resourcesSold": this.resourcesSold,
|
||||
"resourcesBought": this.resourcesBought,
|
||||
"tributesSent": this.tributesSent,
|
||||
"tributesReceived": this.tributesReceived,
|
||||
"tradeIncome": this.tradeIncome,
|
||||
"treasuresCollected": this.treasuresCollected,
|
||||
"percentMapExplored": this.GetPercentMapExplored()
|
||||
@ -106,7 +110,7 @@ StatisticsTracker.prototype.KilledEntity = function(targetEntity)
|
||||
var targetIsCivCentre = cmpTargetEntityIdentity.HasClass("CivCentre");
|
||||
|
||||
var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership);
|
||||
|
||||
|
||||
// Don't increase counters if target player is gaia (player 0)
|
||||
if (cmpTargetOwnership.GetOwner() != 0)
|
||||
{
|
||||
@ -202,6 +206,16 @@ StatisticsTracker.prototype.IncreaseResourcesBoughtCounter = function(type, amou
|
||||
this.resourcesBought[type] += amount;
|
||||
}
|
||||
|
||||
StatisticsTracker.prototype.IncreaseTributesSentCounter = function(amount)
|
||||
{
|
||||
this.tributesSent += amount;
|
||||
}
|
||||
|
||||
StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount)
|
||||
{
|
||||
this.tributesReceived += amount;
|
||||
}
|
||||
|
||||
StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount)
|
||||
{
|
||||
this.tradeIncome += amount;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_unit_support_healer">
|
||||
<Identity>
|
||||
<Civ>hele</Civ>
|
||||
<Civ>pers</Civ>
|
||||
<SelectionGroupName>units/pers_support_healer_b</SelectionGroupName>
|
||||
<GenericName>Median Magus</GenericName>
|
||||
<SpecificName>Maguš Mada</SpecificName>
|
||||
|
Loading…
Reference in New Issue
Block a user