diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index da5bbff285..545d89beae 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -77,7 +77,6 @@
-
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs
deleted file mode 100644
index d4c03a05d1..0000000000
--- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs
+++ /dev/null
@@ -1,133 +0,0 @@
-#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.Drawing;
-using System.Linq;
-using OpenRA.Mods.RA;
-using OpenRA.Mods.RA.Buildings;
-using OpenRA.Mods.RA.Widgets;
-using OpenRA.Traits;
-using OpenRA.Widgets;
-
-namespace OpenRA.Mods.Cnc.Widgets.Logic
-{
- public class CncIngameChromeLogic
- {
- readonly Widget ingameRoot;
- readonly World world;
-
- [ObjectCreator.UseCtor]
- public CncIngameChromeLogic(Widget widget, World world)
- {
- this.world = world;
- ingameRoot = widget.Get("INGAME_ROOT");
- var playerRoot = ingameRoot.Get("PLAYER_ROOT");
-
- // Observer
- if (world.LocalPlayer == null)
- InitObserverWidgets(world, playerRoot);
- else
- InitPlayerWidgets(world, playerRoot);
-
- Game.LoadWidget(world, "CHAT_PANEL", ingameRoot, new WidgetArgs());
- }
-
- public void OptionsClicked()
- {
- var cachedPause = world.PredictedPaused;
-
- ingameRoot.IsVisible = () => false;
- if (world.LobbyInfo.IsSinglePlayer)
- world.SetPauseState(true);
-
- Game.LoadWidget(world, "INGAME_MENU", Ui.Root, new WidgetArgs()
- {
- { "onExit", () =>
- {
- ingameRoot.IsVisible = () => true;
- if (world.LobbyInfo.IsSinglePlayer)
- world.SetPauseState(cachedPause);
- }
- }
- });
- }
-
- public void InitObserverWidgets(World world, Widget playerRoot)
- {
- var observerWidgets = Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
- observerWidgets.Get("OPTIONS_BUTTON").OnClick = OptionsClicked;
- }
-
- public void InitPlayerWidgets(World world, Widget playerRoot)
- {
- // Real player
- var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
- playerWidgets.IsVisible = () => true;
-
- var sidebarRoot = playerWidgets.Get("SIDEBAR_BACKGROUND");
- var powerManager = world.LocalPlayer.PlayerActor.Trait();
- var playerResources = world.LocalPlayer.PlayerActor.Trait();
- sidebarRoot.Get("CASH").GetText = () =>
- "${0}".F(playerResources.DisplayCash + playerResources.DisplayResources);
-
- playerWidgets.Get("OPTIONS_BUTTON").OnClick = OptionsClicked;
-
- var radarEnabled = false;
- var cachedRadarEnabled = false;
- sidebarRoot.Get("RADAR_MINIMAP").IsEnabled = () => radarEnabled;
-
- var sidebarTicker = playerWidgets.Get("SIDEBAR_TICKER");
- sidebarTicker.OnTick = () =>
- {
- // Update radar bin
- radarEnabled = world.ActorsWithTrait()
- .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
-
- if (radarEnabled != cachedRadarEnabled)
- Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
- cachedRadarEnabled = radarEnabled;
-
- // Switch to observer mode after win/loss
- if (world.LocalPlayer.WinState != WinState.Undefined)
- Game.RunAfterTick(() =>
- {
- playerRoot.RemoveChildren();
- InitObserverWidgets(world, playerRoot);
- });
- };
-
- var siloBar = playerWidgets.Get("SILOBAR");
- siloBar.GetProvided = () => playerResources.ResourceCapacity;
- siloBar.GetUsed = () => playerResources.Resources;
- siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
- siloBar.GetBarColor = () =>
- {
- if (playerResources.Resources == playerResources.ResourceCapacity)
- return Color.Red;
- if (playerResources.Resources >= 0.8 * playerResources.ResourceCapacity)
- return Color.Orange;
- return Color.LimeGreen;
- };
-
- var powerBar = playerWidgets.Get("POWERBAR");
- powerBar.GetProvided = () => powerManager.PowerProvided;
- powerBar.GetUsed = () => powerManager.PowerDrained;
- powerBar.TooltipFormat = "Power Usage: {0}/{1}";
- powerBar.GetBarColor = () =>
- {
- if (powerManager.PowerState == PowerState.Critical)
- return Color.Red;
- if (powerManager.PowerState == PowerState.Low)
- return Color.Orange;
- return Color.LimeGreen;
- };
- }
- }
-}
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 710b5fb3a9..7476d751cd 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -535,6 +535,13 @@
+
+
+
+
+
+
+
@@ -579,4 +586,7 @@ cd "$(SolutionDir)thirdparty/"
copy "FuzzyLogicLibrary.dll" "$(SolutionDir)"
cd "$(SolutionDir)"
+
+
+
\ No newline at end of file
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameCashCounterLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameCashCounterLogic.cs
new file mode 100644
index 0000000000..02fe191188
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameCashCounterLogic.cs
@@ -0,0 +1,28 @@
+#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 OpenRA.Traits;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.Cnc.Widgets.Logic
+{
+ public class IngameCashCounterLogic
+ {
+ [ObjectCreator.UseCtor]
+ public IngameCashCounterLogic(Widget widget, World world)
+ {
+ var playerResources = world.LocalPlayer.PlayerActor.Trait();
+ var cash = widget.Get("CASH");
+ var label = cash.Text;
+
+ cash.GetText = () => label.F(playerResources.DisplayCash + playerResources.DisplayResources);
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerBarLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerBarLogic.cs
new file mode 100644
index 0000000000..7fcd05e897
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerBarLogic.cs
@@ -0,0 +1,38 @@
+#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.Drawing;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class IngamePowerBarLogic
+ {
+ [ObjectCreator.UseCtor]
+ public IngamePowerBarLogic(Widget widget, World world)
+ {
+ var powerManager = world.LocalPlayer.PlayerActor.Trait();
+ var powerBar = widget.Get("POWERBAR");
+
+ powerBar.GetProvided = () => powerManager.PowerProvided;
+ powerBar.GetUsed = () => powerManager.PowerDrained;
+ powerBar.TooltipFormat = "Power Usage: {0}/{1}";
+ powerBar.GetBarColor = () =>
+ {
+ if (powerManager.PowerState == PowerState.Critical)
+ return Color.Red;
+ if (powerManager.PowerState == PowerState.Low)
+ return Color.Orange;
+ return Color.LimeGreen;
+ };
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs
new file mode 100644
index 0000000000..cd241e3f32
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngamePowerCounterLogic.cs
@@ -0,0 +1,27 @@
+#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 OpenRA.Mods.RA.Buildings;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class IngamePowerCounterLogic
+ {
+ [ObjectCreator.UseCtor]
+ public IngamePowerCounterLogic(Widget widget, World world)
+ {
+ var powerManager = world.LocalPlayer.PlayerActor.Trait();
+ var power = widget.Get("POWER");
+
+ power.GetText = () => powerManager.PowerProvided == 1000000 ? "inf" : powerManager.ExcessPower.ToString();
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameRadarDisplayLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameRadarDisplayLogic.cs
new file mode 100644
index 0000000000..81dbcec523
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameRadarDisplayLogic.cs
@@ -0,0 +1,38 @@
+#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.Mods.RA.Widgets;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class IngameRadarDisplayLogic
+ {
+ [ObjectCreator.UseCtor]
+ public IngameRadarDisplayLogic(Widget widget, World world)
+ {
+ var radarEnabled = false;
+ var cachedRadarEnabled = false;
+ widget.Get("RADAR_MINIMAP").IsEnabled = () => radarEnabled;
+
+ var ticker = widget.Get("RADAR_TICKER");
+ ticker.OnTick = () =>
+ {
+ radarEnabled = world.ActorsWithTrait()
+ .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
+
+ if (radarEnabled != cachedRadarEnabled)
+ Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
+ cachedRadarEnabled = radarEnabled;
+ };
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameSiloBarLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameSiloBarLogic.cs
new file mode 100644
index 0000000000..ea35b15a8c
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/IngameSiloBarLogic.cs
@@ -0,0 +1,40 @@
+#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.Drawing;
+using OpenRA.Traits;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class IngameSiloBarLogic
+ {
+ [ObjectCreator.UseCtor]
+ public IngameSiloBarLogic(Widget widget, World world)
+ {
+ var playerResources = world.LocalPlayer.PlayerActor.Trait();
+ var siloBar = widget.Get("SILOBAR");
+
+ siloBar.GetProvided = () => playerResources.ResourceCapacity;
+ siloBar.GetUsed = () => playerResources.Resources;
+ siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
+ siloBar.GetBarColor = () =>
+ {
+ if (playerResources.Resources == playerResources.ResourceCapacity)
+ return Color.Red;
+
+ if (playerResources.Resources >= 0.8 * playerResources.ResourceCapacity)
+ return Color.Orange;
+
+ return Color.LimeGreen;
+ };
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs
new file mode 100644
index 0000000000..201007bd86
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs
@@ -0,0 +1,31 @@
+#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 OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets.Logic
+{
+ public class LoadIngamePlayerOrObserverUILogic
+ {
+ [ObjectCreator.UseCtor]
+ public LoadIngamePlayerOrObserverUILogic(Widget widget, World world)
+ {
+ var ingameRoot = widget.Get("INGAME_ROOT");
+ var playerRoot = ingameRoot.Get("PLAYER_ROOT");
+
+ if (world.LocalPlayer == null)
+ Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
+ else
+ Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
+
+ Game.LoadWidget(world, "CHAT_PANEL", ingameRoot, new WidgetArgs());
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs
index 5bae5362b1..2896773497 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs
@@ -42,6 +42,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Widget optionsBG = null;
optionsBG = Game.LoadWidget(world, "INGAME_OPTIONS_BG", Ui.Root, new WidgetArgs
{
+ { "transient", false },
{ "onExit", () =>
{
optionsBG.Visible = false;
@@ -52,6 +53,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
});
+ optionsBG.Visible = false;
+
gameRoot.Get("INGAME_OPTIONS_BUTTON").OnClick = () =>
{
optionsBG.Visible ^= true;
diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs
index 678a3ef6ec..d9770ab592 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
class IngameMenuLogic
{
[ObjectCreator.UseCtor]
- public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
+ public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer, bool transient)
{
var resumeDisabled = false;
var mpe = world.WorldActor.TraitOrDefault();
@@ -71,8 +71,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
var resumeButton = widget.Get("RESUME");
- resumeButton.OnClick = () => onExit();
resumeButton.IsDisabled = () => resumeDisabled;
+ resumeButton.OnClick = () =>
+ {
+ if (transient)
+ {
+ Ui.CloseWindow();
+ Ui.Root.RemoveChild(widget);
+ }
+
+ onExit();
+ };
widget.Get("SURRENDER").OnClick = () =>
{
diff --git a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs
index 3826a02773..55c4b08ba1 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/OrderButtonsChromeLogic.cs
@@ -15,9 +15,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
public class OrderButtonsChromeLogic
{
+ readonly World world;
+ readonly Widget ingameRoot;
+ bool disableSystemButtons;
+
[ObjectCreator.UseCtor]
public OrderButtonsChromeLogic(Widget widget, World world)
{
+ this.world = world;
+ ingameRoot = Ui.Root.Get("INGAME_ROOT");
+
+ // Order Buttons
var sell = widget.GetOrNull("SELL_BUTTON");
if (sell != null)
{
@@ -45,6 +53,43 @@ namespace OpenRA.Mods.RA.Widgets.Logic
power.GetKey = _ => Game.Settings.Keys.PowerDownKey;
BindOrderButton(world, power, "power");
}
+
+ // System buttons
+ var options = widget.GetOrNull("OPTIONS_BUTTON");
+ if (options != null)
+ {
+ options.IsDisabled = () => disableSystemButtons;
+ options.OnClick = () => OpenMenuPanel(options);
+ }
+
+ }
+
+ void OpenMenuPanel(MenuButtonWidget button)
+ {
+ disableSystemButtons = true;
+ var cachedPause = world.PredictedPaused;
+
+ if (button.HideIngameUI)
+ ingameRoot.IsVisible = () => false;
+
+ if (button.Pause && world.LobbyInfo.IsSinglePlayer)
+ world.SetPauseState(true);
+
+ Game.LoadWidget(world, button.MenuContainer, Ui.Root, new WidgetArgs()
+ {
+ { "transient", true },
+ { "onExit", () =>
+ {
+ if (button.HideIngameUI)
+ ingameRoot.IsVisible = () => true;
+
+ if (button.Pause && world.LobbyInfo.IsSinglePlayer)
+ world.SetPauseState(cachedPause);
+
+ disableSystemButtons = false;
+ }
+ }
+ });
}
static void BindOrderButton(World world, ButtonWidget w, string icon)
diff --git a/OpenRA.Mods.RA/Widgets/MenuButtonWidget.cs b/OpenRA.Mods.RA/Widgets/MenuButtonWidget.cs
new file mode 100644
index 0000000000..7b72d94fee
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/MenuButtonWidget.cs
@@ -0,0 +1,33 @@
+#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 OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets
+{
+ public class MenuButtonWidget : ButtonWidget
+ {
+ public readonly string MenuContainer = "INGAME_MENU";
+ public readonly bool Pause = true;
+ public readonly bool HideIngameUI = true;
+
+ [ObjectCreator.UseCtor]
+ public MenuButtonWidget(Ruleset modRules)
+ : base(modRules) { }
+
+ protected MenuButtonWidget(MenuButtonWidget other)
+ : base(other)
+ {
+ MenuContainer = other.MenuContainer;
+ Pause = other.Pause;
+ HideIngameUI = other.HideIngameUI;
+ }
+ }
+}
diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml
index b81bcb853a..ec2f763e19 100644
--- a/mods/cnc/chrome/ingame.yaml
+++ b/mods/cnc/chrome/ingame.yaml
@@ -1,5 +1,5 @@
Container@INGAME_ROOT:
- Logic: CncIngameChromeLogic
+ Logic: LoadIngamePlayerOrObserverUILogic
Children:
LogicTicker@DISCONNECT_WATCHER:
Logic: DisconnectWatcherLogic
@@ -196,7 +196,7 @@ Container@PLAYER_WIDGETS:
Height: 240
Background: panel-black
Children:
- Button@OPTIONS_BUTTON:
+ MenuButton@OPTIONS_BUTTON:
Key: escape
X: 22
Y: 0-24
@@ -258,12 +258,16 @@ Container@PLAYER_WIDGETS:
Background: panel-gray
Children:
Radar@RADAR_MINIMAP:
+ Logic: IngameRadarDisplayLogic
X: 1
Y: 1
Width: PARENT_RIGHT-2
Height: PARENT_BOTTOM-2
WorldInteractionController: INTERACTION_CONTROLLER
+ Children:
+ LogicTicker@RADAR_TICKER:
Background@POWERBAR_PANEL:
+ Logic: IngamePowerBarLogic
X: 4
Y: 5
Width: 10
@@ -279,6 +283,7 @@ Container@PLAYER_WIDGETS:
TooltipTemplate: SIMPLE_TOOLTIP
IndicatorImage: indicator-left
Background@SILOBAR_PANEL:
+ Logic: IngameSiloBarLogic
X: 180
Y: 5
Width: 10
@@ -294,11 +299,13 @@ Container@PLAYER_WIDGETS:
TooltipTemplate: SIMPLE_TOOLTIP
IndicatorImage: indicator-right
Label@CASH:
+ Logic: IngameCashCounterLogic
Y: 170
Width: PARENT_RIGHT
Height: 25
Align: Center
Font: Bold
+ Text: ${0}
Container@PRODUCTION_TYPES:
X: 12
Y: 197