Merge pull request #6397 from obrakmann/cnc-stats

Enable viewing game stats after the game ends
This commit is contained in:
Matthias Mailänder
2014-09-06 13:52:16 +02:00
9 changed files with 545 additions and 45 deletions

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
Action ShowLeaveRestartDialog = () =>
{
gameRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs());
};
world.GameOver += ShowLeaveRestartDialog;
}

View File

@@ -9,32 +9,42 @@
#endregion
using System.Linq;
using OpenRA.Network;
using OpenRA.Traits;
using OpenRA.Widgets;
using OpenRA.Mods.RA;
namespace OpenRA.Mods.RA.Widgets
{
class LeaveMapLogic
{
[ObjectCreator.UseCtor]
public LeaveMapLogic(Widget widget, OrderManager orderManager, World world)
public LeaveMapLogic(Widget widget, World world)
{
widget.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
var panelName = "LEAVE_RESTART_SIMPLE";
var panelName = "LEAVE_MAP_SIMPLE";
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
var showObjectives = iop != null && iop.PanelName != null && world.LocalPlayer != null;
if (showObjectives)
panelName = "LEAVE_RESTART_FULL";
panelName = "LEAVE_MAP_FULL";
var showStats = false;
var dialog = widget.Get<ContainerWidget>(panelName);
dialog.IsVisible = () => true;
dialog.IsVisible = () => !showStats;
widget.IsVisible = () => Ui.CurrentWindow() == null;
var statsButton = dialog.Get<ButtonWidget>("STATS_BUTTON");
statsButton.OnClick = () =>
{
showStats = true;
Game.LoadWidget(world, "INGAME_OBSERVERSTATS_BG", Ui.Root, new WidgetArgs()
{
{ "onExit", () => showStats = false }
});
};
var leaveButton = dialog.Get<ButtonWidget>("LEAVE_BUTTON");
leaveButton.OnClick = () =>
{

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Action ShowLeaveRestartDialog = () =>
{
ingameRoot.RemoveChildren();
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
Game.LoadWidget(world, "LEAVE_MAP_WIDGET", Ui.Root, new WidgetArgs());
};
world.GameOver += ShowLeaveRestartDialog;
}

View File

@@ -68,7 +68,7 @@ Container@SKIRMISH_STATS:
X: 15
Y: 105
Width: 482
Height: 250
Height: 255
ItemSpacing: 5
Children:
Container@PLAYER_TEMPLATE:

View File

@@ -1,4 +1,4 @@
Container@LEAVE_RESTART_WIDGET:
Container@LEAVE_MAP_WIDGET:
Logic: LeaveMapLogic
Children:
Image@EVA:
@@ -18,14 +18,14 @@ Container@LEAVE_RESTART_WIDGET:
Width: WINDOW_RIGHT
Height: WINDOW_BOTTOM
Background: shellmapborder
Container@LEAVE_RESTART_SIMPLE
Container@LEAVE_MAP_SIMPLE
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 370
Height: 125
Visible: False
Children:
Background@LEAVE_RESTART_SIMPLE_BG:
Background@LEAVE_MAP_SIMPLE_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 35
Background: panel-black
@@ -51,22 +51,21 @@ Container@LEAVE_RESTART_WIDGET:
Height: 35
Font: Bold
Text: Leave
Button@RESTART_BUTTON:
X: 150
Button@STATS_BUTTON:
X: PARENT_RIGHT - WIDTH
Y: PARENT_BOTTOM - 1
Width: 140
Height: 35
Font: Bold
Text: Restart
Visible: false
Container@LEAVE_RESTART_FULL:
Text: Statistics
Container@LEAVE_MAP_FULL:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 512
Height: 410
Visible: False
Children:
Background@LEAVE_RESTART_BG:
Background@LEAVE_MAP_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 35
Background: panel-black
@@ -86,13 +85,12 @@ Container@LEAVE_RESTART_WIDGET:
Height: 35
Font: Bold
Text: Leave
Button@RESTART_BUTTON:
Button@STATS_BUTTON:
X: 150
Y: PARENT_BOTTOM - 1
Width: 140
Height: 35
Font: Bold
Text: Restart
Visible: false
Text: Statistics
Container@OBJECTIVES:

View File

@@ -0,0 +1,495 @@
Background@INGAME_OBSERVERSTATS_BG:
Logic: ObserverStatsLogic
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 940
Height: 500
Children:
Background@BACKGROUND:
Width: PARENT_RIGHT
Background: panel-black
Height: PARENT_BOTTOM - 35
Children:
Label@TITLE:
X: 0
Y: 0-25
Width: PARENT_RIGHT
Font: BigBold
Align: Center
Contrast: True
Text: Statistics
DropDownButton@STATS_DROPDOWN:
X: PARENT_RIGHT-200
Y: 15
Width: 185
Height: 25
Font: Bold
Container@BASIC_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 75
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@CASH_HEADER:
X: 235
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Cash
Label@EARNED_MIN_HEADER:
X: 315
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned/min
Label@POWER_HEADER:
X: 415
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Power
Label@KILLS_HEADER:
X: 495
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Kills
Align: Right
Label@DEATHS_HEADER:
X: 555
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Deaths
Align: Right
Label@ACTIONS_MIN_HEADER:
X: 655
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Actions/min
Align: Right
Container@ECONOMY_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 75
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@CASH_HEADER:
X: 235
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Cash
Label@EARNED_MIN_HEADER:
X: 315
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned/min
Label@EARNED_THIS_MIN_HEADER:
X: 415
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned this min
Label@ASSETS_HEADER:
X: 555
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Assets
Label@EARNED_HEADER:
X: 635
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned
Label@SPENT_HEADER:
X: 715
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Spent
Label@HARVESTERS_HEADER:
X: 795
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Harvesters
Align: Right
Container@PRODUCTION_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 75
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@PRODUCTION_HEADER:
X: 235
Y: 40
Width: 320
Height: 25
Font: Bold
Text: Production
Label@SUPPORT_POWERS_HEADER:
X: 555
Y: 40
Width: 320
Height: 25
Font: Bold
Text: Support Powers
Container@COMBAT_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 75
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@CONTROL_HEADER:
X: 235
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Control
Label@KILLS_COST_HEADER:
X: 315
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Kills
Label@DEATHS_COST_HEADER:
X: 395
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Deaths
Label@UNITS_KILLED_HEADER:
X: 495
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Units Killed
Align: Right
Label@UNITS_DEAD_HEADER:
X: 595
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Units Lost
Align: Right
Label@BUILDINGS_KILLED_HEADER:
X: 715
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Bldg Killed
Align: Right
Label@BUILDINGS_DEAD_HEADER:
X: 815
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Bldg Lost
Align: Right
Container@EARNED_THIS_MIN_GRAPH_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@EARNED_THIS_MIN_HEADER:
X: 0
Y: 40
Width: PARENT_RIGHT
Height: 25
Font: Bold
Text: Earnings received each minute
Align: Center
ScrollPanel@PLAYER_STATS_PANEL:
X: 15
Y: 70
Width: PARENT_RIGHT-30
Height: PARENT_BOTTOM-35-50
ItemSpacing: 5
Children:
ScrollItem@TEAM_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Label@TEAM:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Font: Bold
ScrollItem@BASIC_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@CASH:
X: 215
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@EARNED_MIN:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@POWER:
X: 395
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@KILLS:
X: 475
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@DEATHS:
X: 535
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN:
X: 635
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
ScrollItem@ECONOMY_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@CASH:
X: 215
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@EARNED_MIN:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@EARNED_THIS_MIN:
X: 395
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@ASSETS:
X: 535
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@EARNED:
X: 615
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@SPENT:
X: 695
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@HARVESTERS:
X: 775
Y: 0
Width: 60
Height: PARENT_BOTTOM
Align: Right
ScrollItem@PRODUCTION_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
ObserverProductionIcons@PRODUCTION_ICONS:
X: 215
Y: 0
Width: 320
Height: PARENT_BOTTOM
ObserverSupportPowerIcons@SUPPORT_POWER_ICONS:
X: 535
Y: 0
Width: 320
Height: PARENT_BOTTOM
ScrollItem@COMBAT_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@CONTROL:
X: 215
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@KILLS_COST:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@DEATHS_COST:
X: 375
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@UNITS_KILLED:
X: 475
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@UNITS_DEAD:
X: 575
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@BUILDINGS_KILLED:
X: 695
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@BUILDINGS_DEAD:
X: 795
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Container@EARNED_THIS_MIN_GRAPH_TEMPLATE:
X: 10
Y: 10
Width: PARENT_RIGHT-100
Height: PARENT_BOTTOM-60
Children:
LineGraph@EARNED_THIS_MIN_GRAPH:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
ValueFormat: ${0}
XAxisValueFormat: {0}
YAxisValueFormat: ${0:F0}
XAxisSize: 20
YAxisSize: 10
XAxisLabel: m
YAxisLabel: $
LabelFont: TinyBold
AxisFont: Bold
Button@CLOSE:
X: 0
Y: PARENT_BOTTOM - 36
Width: 140
Height: 35
Text: Close
Key: escape
Font: Bold

View File

@@ -95,6 +95,7 @@ ChromeLayout:
mods/cnc/chrome/ingame-infoobjectives.yaml
mods/cnc/chrome/ingame-infostats.yaml
mods/cnc/chrome/ingame-leavemap.yaml
mods/cnc/chrome/ingame-observerstats.yaml
mods/cnc/chrome/music.yaml
mods/cnc/chrome/settings.yaml
mods/cnc/chrome/credits.yaml

View File

@@ -1,4 +1,4 @@
Container@LEAVE_RESTART_WIDGET:
Container@LEAVE_MAP_WIDGET:
Logic: LeaveMapLogic
Children:
Background@BORDER:
@@ -13,14 +13,14 @@ Container@LEAVE_RESTART_WIDGET:
Align: Right
Font: Regular
Contrast: True
Container@LEAVE_RESTART_SIMPLE
Container@LEAVE_MAP_SIMPLE
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 370
Height: 175
Visible: False
Children:
Background@LEAVE_RESTART_SIMPLE_BG:
Background@LEAVE_MAP_SIMPLE_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
@@ -38,29 +38,28 @@ Container@LEAVE_RESTART_WIDGET:
Height: 65
Text: Press 'Leave' to return to the main menu.
Align: Center
Button@RESTART_BUTTON:
Button@STATS_BUTTON:
X: 20
Y: PARENT_BOTTOM - 45
Width: 140
Height: 25
Font: Bold
Text: Restart
Visible: false
Text: Statistics
Button@LEAVE_BUTTON:
X: (PARENT_RIGHT - WIDTH) / 2
X: PARENT_RIGHT - WIDTH - 20
Y: PARENT_BOTTOM - 45
Width: 140
Height: 25
Font: Bold
Text: Leave
Container@LEAVE_RESTART_FULL:
Container@LEAVE_MAP_FULL:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 522
Height: 470
Visible: False
Children:
Background@LEAVE_RESTART_BG:
Background@LEAVE_MAP_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
@@ -72,14 +71,13 @@ Container@LEAVE_RESTART_WIDGET:
Font: Bold
Align: Center
Text: The game has ended
Button@RESTART_BUTTON:
Button@STATS_BUTTON:
X: PARENT_RIGHT - 2 * (WIDTH + 20)
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Font: Bold
Text: Restart
Visible: false
Text: Statistics
Button@LEAVE_BUTTON:
X: PARENT_RIGHT - WIDTH - 20
Y: PARENT_BOTTOM - 45

View File

@@ -1,4 +1,4 @@
Container@LEAVE_RESTART_WIDGET:
Container@LEAVE_MAP_WIDGET:
Logic: LeaveMapLogic
Children:
Background@BORDER:
@@ -20,14 +20,14 @@ Container@LEAVE_RESTART_WIDGET:
Align: Center
Font: Regular
Contrast: True
Container@LEAVE_RESTART_SIMPLE
Container@LEAVE_MAP_SIMPLE
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 370
Height: 175
Visible: False
Children:
Background@LEAVE_RESTART_SIMPLE_BG:
Background@LEAVE_MAP_SIMPLE_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
@@ -45,29 +45,28 @@ Container@LEAVE_RESTART_WIDGET:
Height: 65
Text: Press 'Leave' to return to the main menu.
Align: Center
Button@RESTART_BUTTON:
Button@STATS_BUTTON:
X: 20
Y: PARENT_BOTTOM - 45
Width: 140
Height: 25
Font: Bold
Text: Restart
Visible: false
Text: Statistics
Button@LEAVE_BUTTON:
X: (PARENT_RIGHT - WIDTH) / 2
X: PARENT_RIGHT - WIDTH - 20
Y: PARENT_BOTTOM - 45
Width: 140
Height: 25
Font: Bold
Text: Leave
Container@LEAVE_RESTART_FULL:
Container@LEAVE_MAP_FULL:
X: (WINDOW_RIGHT - WIDTH) / 2
Y: (WINDOW_BOTTOM - HEIGHT) / 2
Width: 522
Height: 470
Visible: False
Children:
Background@LEAVE_RESTART_BG:
Background@LEAVE_MAP_BG:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
@@ -79,14 +78,13 @@ Container@LEAVE_RESTART_WIDGET:
Font: Bold
Align: Center
Text: The game has ended
Button@RESTART_BUTTON:
Button@STATS_BUTTON:
X: PARENT_RIGHT - 2 * (WIDTH + 20)
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Font: Bold
Text: Restart
Visible: false
Text: Statistics
Button@LEAVE_BUTTON:
X: PARENT_RIGHT - WIDTH - 20
Y: PARENT_BOTTOM - 45