Merge pull request #7529 from delftswa2014/feature/kdr_stat
Add Kill/Death ratio in statistics window
This commit is contained in:
@@ -271,6 +271,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (stats == null) return template;
|
||||
template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).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);
|
||||
|
||||
return template;
|
||||
@@ -301,6 +302,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
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)
|
||||
{
|
||||
if (state == PowerState.Critical) return Color.Red;
|
||||
|
||||
@@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
|
||||
Font: Bold
|
||||
Text: Deaths
|
||||
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:
|
||||
X: 655
|
||||
X: 745
|
||||
Y: 40
|
||||
Width: 40
|
||||
Height: 25
|
||||
@@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
|
||||
Width: 40
|
||||
Height: PARENT_BOTTOM
|
||||
Align: Right
|
||||
Label@KD_RATIO:
|
||||
X: 595
|
||||
Y: 0
|
||||
Width: 80
|
||||
Height: PARENT_BOTTOM
|
||||
Align: Right
|
||||
Label@ACTIONS_MIN:
|
||||
X: 635
|
||||
X: 725
|
||||
Y: 0
|
||||
Width: 40
|
||||
Height: PARENT_BOTTOM
|
||||
|
||||
@@ -74,8 +74,16 @@ Background@INGAME_OBSERVERSTATS_BG:
|
||||
Font: Bold
|
||||
Text: Deaths
|
||||
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:
|
||||
X: 665
|
||||
X: 755
|
||||
Y: 40
|
||||
Width: 40
|
||||
Height: 25
|
||||
@@ -317,8 +325,14 @@ Background@INGAME_OBSERVERSTATS_BG:
|
||||
Width: 40
|
||||
Height: PARENT_BOTTOM
|
||||
Align: Right
|
||||
Label@KD_RATIO:
|
||||
X: 595
|
||||
Y: 0
|
||||
Width: 80
|
||||
Height: PARENT_BOTTOM
|
||||
Align: Right
|
||||
Label@ACTIONS_MIN:
|
||||
X: 635
|
||||
X: 725
|
||||
Y: 0
|
||||
Width: 40
|
||||
Height: PARENT_BOTTOM
|
||||
|
||||
Reference in New Issue
Block a user