Merge pull request #6397 from obrakmann/cnc-stats
Enable viewing game stats after the game ends
This commit is contained in:
@@ -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 = () =>
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user