Add end game dialog
This commit is contained in:
@@ -51,6 +51,11 @@ namespace OpenRA.Widgets
|
||||
return window;
|
||||
}
|
||||
|
||||
public static Widget CurrentWindow()
|
||||
{
|
||||
return WindowList.Count > 0 ? WindowList.Peek() : null;
|
||||
}
|
||||
|
||||
public static T LoadWidget<T>(string id, Widget parent, WidgetArgs args) where T : Widget
|
||||
{
|
||||
var widget = LoadWidget(id, parent, args) as T;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA;
|
||||
@@ -43,6 +44,13 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
|
||||
void InitRootWidgets()
|
||||
{
|
||||
Game.LoadWidget(world, "CHAT_PANEL", gameRoot, new WidgetArgs());
|
||||
|
||||
Action ShowLeaveRestartDialog = () =>
|
||||
{
|
||||
gameRoot.IsVisible = () => false;
|
||||
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
|
||||
};
|
||||
world.GameOver += ShowLeaveRestartDialog;
|
||||
}
|
||||
|
||||
void InitObserverWidgets()
|
||||
|
||||
@@ -377,6 +377,7 @@
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoBriefingLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoObjectivesLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\GameInfoStatsLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\LeaveMapLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\IrcLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\KickClientLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\ModBrowserLogic.cs" />
|
||||
|
||||
70
OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs
Normal file
70
OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#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)
|
||||
{
|
||||
widget.Get<LabelWidget>("VERSION_LABEL").Text = Game.modData.Manifest.Mod.Version;
|
||||
|
||||
var panelName = "LEAVE_RESTART_SIMPLE";
|
||||
|
||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||
var showObjectives = iop != null && iop.PanelName != null && world.LocalPlayer != null;
|
||||
|
||||
if (showObjectives)
|
||||
panelName = "LEAVE_RESTART_FULL";
|
||||
|
||||
var dialog = widget.Get<ContainerWidget>(panelName);
|
||||
var fmvPlayer = Ui.Root.GetOrNull<BackgroundWidget>("FMVPLAYER");
|
||||
dialog.IsVisible = () => true;
|
||||
widget.IsVisible = () => fmvPlayer == null || fmvPlayer != Ui.CurrentWindow();
|
||||
|
||||
var leaveButton = dialog.Get<ButtonWidget>("LEAVE_BUTTON");
|
||||
leaveButton.OnClick = () =>
|
||||
{
|
||||
leaveButton.Disabled = true;
|
||||
var mpe = world.WorldActor.TraitOrDefault<MenuPaletteEffect>();
|
||||
|
||||
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave",
|
||||
world.LocalPlayer == null ? null : world.LocalPlayer.Country.Race);
|
||||
|
||||
var exitDelay = 1200;
|
||||
if (mpe != null)
|
||||
{
|
||||
Game.RunAfterDelay(exitDelay, () => mpe.Fade(MenuPaletteEffect.EffectType.Black));
|
||||
exitDelay += 40 * mpe.Info.FadeLength;
|
||||
}
|
||||
|
||||
Game.RunAfterDelay(exitDelay, () =>
|
||||
{
|
||||
Game.Disconnect();
|
||||
Ui.ResetAll();
|
||||
Game.LoadShellMap();
|
||||
});
|
||||
};
|
||||
|
||||
if (showObjectives)
|
||||
{
|
||||
var objectivesContainer = dialog.Get<ContainerWidget>("OBJECTIVES");
|
||||
Game.LoadWidget(world, iop.PanelName, objectivesContainer, new WidgetArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
@@ -26,6 +27,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
|
||||
|
||||
Game.LoadWidget(world, "CHAT_PANEL", ingameRoot, new WidgetArgs());
|
||||
|
||||
Action ShowLeaveRestartDialog = () =>
|
||||
{
|
||||
ingameRoot.IsVisible = () => false;
|
||||
Game.LoadWidget(world, "LEAVE_RESTART_WIDGET", Ui.Root, new WidgetArgs());
|
||||
};
|
||||
world.GameOver += ShowLeaveRestartDialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
98
mods/cnc/chrome/ingame-leavemap.yaml
Normal file
98
mods/cnc/chrome/ingame-leavemap.yaml
Normal file
@@ -0,0 +1,98 @@
|
||||
Container@LEAVE_RESTART_WIDGET:
|
||||
Logic: LeaveMapLogic
|
||||
Children:
|
||||
Image@EVA:
|
||||
X: WINDOW_RIGHT-128-43
|
||||
Y: 43
|
||||
Width: 128
|
||||
Height: 64
|
||||
ImageCollection: logos
|
||||
ImageName: eva
|
||||
Label@VERSION_LABEL:
|
||||
X: WINDOW_RIGHT-128-43
|
||||
Y: 115
|
||||
Width: 128
|
||||
Align: Center
|
||||
Contrast: true
|
||||
Background@BORDER:
|
||||
Width: WINDOW_RIGHT
|
||||
Height: WINDOW_BOTTOM
|
||||
Background: shellmapborder
|
||||
Container@LEAVE_RESTART_SIMPLE
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 370
|
||||
Height: 125
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_SIMPLE_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM - 35
|
||||
Background: panel-black
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
X: 0
|
||||
Y: 0 - 25
|
||||
Width: PARENT_RIGHT
|
||||
Font: BigBold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Contrast: True
|
||||
Label@BLURB:
|
||||
X: 15
|
||||
Y: (PARENT_BOTTOM - HEIGHT) / 2
|
||||
Width: PARENT_RIGHT - 30
|
||||
Text: Press 'Leave' to return to the main menu.
|
||||
Align: Center
|
||||
Button@LEAVE_BUTTON:
|
||||
X: 0
|
||||
Y: PARENT_BOTTOM - 1
|
||||
Width: 140
|
||||
Height: 35
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Button@RESTART_BUTTON:
|
||||
X: 150
|
||||
Y: PARENT_BOTTOM - 1
|
||||
Width: 140
|
||||
Height: 35
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Container@LEAVE_RESTART_FULL:
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 512
|
||||
Height: 410
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM - 35
|
||||
Background: panel-black
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
X: 0
|
||||
Y: 0 - 25
|
||||
Width: PARENT_RIGHT
|
||||
Font: BigBold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Contrast: True
|
||||
Button@LEAVE_BUTTON:
|
||||
X: 0
|
||||
Y: PARENT_BOTTOM - 1
|
||||
Width: 140
|
||||
Height: 35
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Button@RESTART_BUTTON:
|
||||
X: 150
|
||||
Y: PARENT_BOTTOM - 1
|
||||
Width: 140
|
||||
Height: 35
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Container@OBJECTIVES:
|
||||
|
||||
@@ -94,6 +94,7 @@ ChromeLayout:
|
||||
mods/cnc/chrome/ingame-infobriefing.yaml
|
||||
mods/cnc/chrome/ingame-infoobjectives.yaml
|
||||
mods/cnc/chrome/ingame-infostats.yaml
|
||||
mods/cnc/chrome/ingame-leavemap.yaml
|
||||
mods/cnc/chrome/music.yaml
|
||||
mods/cnc/chrome/settings.yaml
|
||||
mods/cnc/chrome/credits.yaml
|
||||
|
||||
92
mods/d2k/chrome/ingame-leavemap.yaml
Normal file
92
mods/d2k/chrome/ingame-leavemap.yaml
Normal file
@@ -0,0 +1,92 @@
|
||||
Container@LEAVE_RESTART_WIDGET:
|
||||
Logic: LeaveMapLogic
|
||||
Children:
|
||||
Background@BORDER:
|
||||
X: 0 - 15
|
||||
Y: 0 - 15
|
||||
Width: WINDOW_RIGHT + 30
|
||||
Height: WINDOW_BOTTOM + 30
|
||||
Background: mainmenu-border
|
||||
Label@VERSION_LABEL:
|
||||
X: WINDOW_RIGHT - 10
|
||||
Y: WINDOW_BOTTOM - 20
|
||||
Align: Right
|
||||
Font: Regular
|
||||
Contrast: True
|
||||
Container@LEAVE_RESTART_SIMPLE
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 370
|
||||
Height: 175
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_SIMPLE_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
Y: 20
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Label@BLURB:
|
||||
X: 15
|
||||
Y: 50
|
||||
Width: PARENT_RIGHT - 30
|
||||
Height: 65
|
||||
Text: Press 'Leave' to return to the main menu.
|
||||
Align: Center
|
||||
Button@RESTART_BUTTON:
|
||||
X: 20
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 140
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Button@LEAVE_BUTTON:
|
||||
X: (PARENT_RIGHT - WIDTH) / 2
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 140
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Container@LEAVE_RESTART_FULL:
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 522
|
||||
Height: 470
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
X: 20
|
||||
Y: 20
|
||||
Width: PARENT_RIGHT - 40
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Button@RESTART_BUTTON:
|
||||
X: PARENT_RIGHT - 2 * (WIDTH + 20)
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 120
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Button@LEAVE_BUTTON:
|
||||
X: PARENT_RIGHT - WIDTH - 20
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 120
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Container@OBJECTIVES:
|
||||
Y: 40
|
||||
|
||||
@@ -70,6 +70,7 @@ ChromeLayout:
|
||||
mods/ra/chrome/ingame-observerstats.yaml
|
||||
mods/d2k/chrome/ingame-player.yaml
|
||||
mods/ra/chrome/ingame-debug.yaml
|
||||
mods/d2k/chrome/ingame-leavemap.yaml
|
||||
mods/d2k/chrome/mainmenu.yaml
|
||||
mods/ra/chrome/settings.yaml
|
||||
mods/ra/chrome/credits.yaml
|
||||
|
||||
99
mods/ra/chrome/ingame-leavemap.yaml
Normal file
99
mods/ra/chrome/ingame-leavemap.yaml
Normal file
@@ -0,0 +1,99 @@
|
||||
Container@LEAVE_RESTART_WIDGET:
|
||||
Logic: LeaveMapLogic
|
||||
Children:
|
||||
Background@BORDER:
|
||||
X: 0 - 15
|
||||
Y: 0 - 15
|
||||
Width: WINDOW_RIGHT + 30
|
||||
Height: WINDOW_BOTTOM + 30
|
||||
Background: mainmenu-border
|
||||
Image@LOGO:
|
||||
X: WINDOW_RIGHT - 296
|
||||
Y: 30
|
||||
ImageCollection: logos
|
||||
ImageName: logo
|
||||
Label@VERSION_LABEL:
|
||||
X: WINDOW_RIGHT - 296
|
||||
Y: 296 - 20
|
||||
Width: 296 - 20
|
||||
Height: 25
|
||||
Align: Center
|
||||
Font: Regular
|
||||
Contrast: True
|
||||
Container@LEAVE_RESTART_SIMPLE
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 370
|
||||
Height: 175
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_SIMPLE_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
Y: 20
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Label@BLURB:
|
||||
X: 15
|
||||
Y: 50
|
||||
Width: PARENT_RIGHT - 30
|
||||
Height: 65
|
||||
Text: Press 'Leave' to return to the main menu.
|
||||
Align: Center
|
||||
Button@RESTART_BUTTON:
|
||||
X: 20
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 140
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Button@LEAVE_BUTTON:
|
||||
X: (PARENT_RIGHT - WIDTH) / 2
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 140
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Container@LEAVE_RESTART_FULL:
|
||||
X: (WINDOW_RIGHT - WIDTH) / 2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT) / 2
|
||||
Width: 522
|
||||
Height: 470
|
||||
Visible: False
|
||||
Children:
|
||||
Background@LEAVE_RESTART_BG:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@GAME_ENDED_LABEL:
|
||||
X: 20
|
||||
Y: 20
|
||||
Width: PARENT_RIGHT - 40
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Align: Center
|
||||
Text: The game has ended
|
||||
Button@RESTART_BUTTON:
|
||||
X: PARENT_RIGHT - 2 * (WIDTH + 20)
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 120
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Restart
|
||||
Visible: false
|
||||
Button@LEAVE_BUTTON:
|
||||
X: PARENT_RIGHT - WIDTH - 20
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 120
|
||||
Height: 25
|
||||
Font: Bold
|
||||
Text: Leave
|
||||
Container@OBJECTIVES:
|
||||
Y: 40
|
||||
|
||||
@@ -78,6 +78,7 @@ ChromeLayout:
|
||||
mods/ra/chrome/ingame-infobriefing.yaml
|
||||
mods/ra/chrome/ingame-infoobjectives.yaml
|
||||
mods/ra/chrome/ingame-infostats.yaml
|
||||
mods/ra/chrome/ingame-leavemap.yaml
|
||||
mods/ra/chrome/ingame-menu.yaml
|
||||
mods/ra/chrome/ingame-observer.yaml
|
||||
mods/ra/chrome/ingame-observerstats.yaml
|
||||
|
||||
@@ -112,6 +112,7 @@ ChromeLayout:
|
||||
mods/ra/chrome/ingame-observerstats.yaml
|
||||
mods/ts/chrome/ingame-player.yaml
|
||||
mods/ra/chrome/ingame-debug.yaml
|
||||
mods/ra/chrome/ingame-leavemap.yaml
|
||||
mods/ra/chrome/mainmenu.yaml
|
||||
mods/ra/chrome/settings.yaml
|
||||
mods/ra/chrome/credits.yaml
|
||||
|
||||
Reference in New Issue
Block a user