Merge pull request #7529 from delftswa2014/feature/kdr_stat

Add Kill/Death ratio in statistics window
This commit is contained in:
Matthias Mailänder
2015-03-20 13:35:21 +01:00
3 changed files with 39 additions and 4 deletions

View File

@@ -271,6 +271,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (stats == null) return template; if (stats == null) return template;
template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString(); template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString();
template.Get<LabelWidget>("DEATHS").GetText = () => (stats.UnitsDead + stats.BuildingsDead).ToString(); template.Get<LabelWidget>("DEATHS").GetText = () => (stats.UnitsDead + stats.BuildingsDead).ToString();
template.Get<LabelWidget>("KD_RATIO").GetText = () => KillDeathRatio(stats.UnitsKilled + stats.BuildingsKilled, stats.UnitsDead + stats.BuildingsDead);
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount); template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount);
return template; return template;
@@ -301,6 +302,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return "$" + (world.WorldTick == 0 ? 0 : earned / (world.WorldTick / 1500.0)).ToString("F2"); return "$" + (world.WorldTick == 0 ? 0 : earned / (world.WorldTick / 1500.0)).ToString("F2");
} }
string KillDeathRatio(int killed, int dead)
{
var kdr = (float)killed / Math.Max(1.0, dead);
return kdr.ToString("F2");
}
static Color GetPowerColor(PowerState state) static Color GetPowerColor(PowerState state)
{ {
if (state == PowerState.Critical) return Color.Red; if (state == PowerState.Critical) return Color.Red;

View File

@@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
Font: Bold Font: Bold
Text: Deaths Text: Deaths
Align: Right Align: Right
Label@KD_RATIO_HEADER:
X: 615
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Kills/Deaths
Align: Right
Label@ACTIONS_MIN_HEADER: Label@ACTIONS_MIN_HEADER:
X: 655 X: 745
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@KD_RATIO:
X: 595
Y: 0
Width: 80
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN: Label@ACTIONS_MIN:
X: 635 X: 725
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM

View File

@@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
Font: Bold Font: Bold
Text: Deaths Text: Deaths
Align: Right Align: Right
Label@KD_RATIO_HEADER:
X: 625
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Kills/Deaths
Align: Right
Label@ACTIONS_MIN_HEADER: Label@ACTIONS_MIN_HEADER:
X: 665 X: 755
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@KD_RATIO:
X: 595
Y: 0
Width: 80
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN: Label@ACTIONS_MIN:
X: 635 X: 725
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM