From da546fc955ae41093b3ad9d37d34f92bc19b93b1 Mon Sep 17 00:00:00 2001 From: jabbink Date: Mon, 23 Feb 2015 17:35:01 +0100 Subject: [PATCH] Add Kill/Death ratio in statistics window closes #6858 --- .../Widgets/Logic/Ingame/ObserverStatsLogic.cs | 7 +++++++ mods/cnc/chrome/ingame-observerstats.yaml | 18 ++++++++++++++++-- mods/ra/chrome/ingame-observerstats.yaml | 18 ++++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs index 8533236410..a595c79514 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ObserverStatsLogic.cs @@ -271,6 +271,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (stats == null) return template; template.Get("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString(); template.Get("DEATHS").GetText = () => (stats.UnitsDead + stats.BuildingsDead).ToString(); + template.Get("KD_RATIO").GetText = () => KillDeathRatio(stats.UnitsKilled + stats.BuildingsKilled, stats.UnitsDead + stats.BuildingsDead); template.Get("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; diff --git a/mods/cnc/chrome/ingame-observerstats.yaml b/mods/cnc/chrome/ingame-observerstats.yaml index 3bcbae7631..8a0701160b 100644 --- a/mods/cnc/chrome/ingame-observerstats.yaml +++ b/mods/cnc/chrome/ingame-observerstats.yaml @@ -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 diff --git a/mods/ra/chrome/ingame-observerstats.yaml b/mods/ra/chrome/ingame-observerstats.yaml index 82fcd3b5eb..8973b353c8 100644 --- a/mods/ra/chrome/ingame-observerstats.yaml +++ b/mods/ra/chrome/ingame-observerstats.yaml @@ -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