Fix observer buttons.

This commit is contained in:
Paul Chote
2014-07-19 17:57:01 +12:00
parent f9fcded77c
commit d88b27745b
8 changed files with 61 additions and 15 deletions

View File

@@ -78,8 +78,16 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
{
var observerWidgets = Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
Game.LoadWidget(world, "OBSERVER_STATS", observerWidgets, new WidgetArgs());
observerWidgets.Get<ButtonWidget>("INGAME_STATS_BUTTON").OnClick = () => gameRoot.Get("OBSERVER_STATS").Visible ^= true;
Widget observerstats = null;
observerstats = Game.LoadWidget(world, "INGAME_OBSERVERSTATS_BG", observerWidgets, new WidgetArgs
{
{ "transient", false },
{ "onExit", () => observerstats.Visible = false }
});
observerstats.Visible = false;
var statsButton = observerWidgets.Get<ButtonWidget>("OBSERVER_STATS_BUTTON");
statsButton.OnClick = () => observerstats.Visible ^= true;
}
enum RadarBinState { Closed, BinAnimating, RadarAnimating, Open };
@@ -90,7 +98,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
Widget diplomacy = null;
diplomacy = Game.LoadWidget(world, "INGAME_DIPLOMACY_BG", playerWidgets, new WidgetArgs
{
{ "transient", true },
{ "transient", false },
{ "onExit", () => diplomacy.Visible = false }
});
diplomacy.Visible = false;
@@ -104,7 +112,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic
Widget cheats = null;
cheats = Game.LoadWidget(world, "INGAME_DEBUG_BG", playerWidgets, new WidgetArgs
{
{ "transient", true },
{ "transient", false },
{ "onExit", () => cheats.Visible = false }
});
cheats.Visible = false;

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
WorldRenderer worldRenderer;
[ObjectCreator.UseCtor]
public ObserverStatsLogic(World world, WorldRenderer worldRenderer, Widget widget)
public ObserverStatsLogic(World world, WorldRenderer worldRenderer, Widget widget, Action onExit, bool transient)
{
this.world = world;
this.worldRenderer = worldRenderer;
@@ -136,6 +136,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ClearStats();
DisplayStats(BasicStats);
var close = widget.GetOrNull<ButtonWidget>("CLOSE");
if (close != null)
{
close.OnClick = () =>
{
if (transient)
{
Ui.CloseWindow();
Ui.Root.RemoveChild(widget);
}
onExit();
};
}
}
void ClearStats()

View File

@@ -78,6 +78,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
debug.IsDisabled = () => disableSystemButtons;
debug.OnClick = () => OpenMenuPanel(debug);
}
var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON");
if (stats != null)
{
stats.IsDisabled = () => disableSystemButtons;
stats.OnClick = () => OpenMenuPanel(stats);
}
}
void OpenMenuPanel(MenuButtonWidget button)

View File

@@ -59,7 +59,8 @@ Container@INGAME_ROOT:
Container@OBSERVER_WIDGETS:
Children:
Button@OPTIONS_BUTTON:
MenuButton@OPTIONS_BUTTON:
Logic: OrderButtonsChromeLogic
Key: escape
X: WINDOW_RIGHT-202
Y: 5

View File

@@ -1,6 +1,6 @@
Container@OBSERVER_WIDGETS:
Children:
Button@INGAME_STATS_BUTTON:
Button@OBSERVER_STATS_BUTTON:
X: 162
Y: 0
Width: 160

View File

@@ -1,4 +1,5 @@
Container@OBSERVER_WIDGETS:
Logic: OrderButtonsChromeLogic
Children:
Container@GAME_TIMER_BLOCK:
Logic: GameTimerLogic
@@ -19,7 +20,10 @@ Container@OBSERVER_WIDGETS:
Align: Center
Font: Bold
Contrast: true
Button@INGAME_OPTIONS_BUTTON:
MenuButton@OPTIONS_BUTTON:
MenuContainer: INGAME_OPTIONS_BG
HideIngameUI: false
Pause: false
X: 0
Y: 0
Width: 160
@@ -27,7 +31,10 @@ Container@OBSERVER_WIDGETS:
Text: Options (ESC)
Font: Bold
Key: escape
Button@INGAME_STATS_BUTTON:
MenuButton@OBSERVER_STATS_BUTTON:
MenuContainer: INGAME_OBSERVERSTATS_BG
HideIngameUI: false
Pause: false
X: 162
Y: 0
Width: 160

View File

@@ -1,15 +1,14 @@
Container@OBSERVER_STATS:
Background@INGAME_OBSERVERSTATS_BG:
Logic: ObserverStatsLogic
X: 25
Y: 50
Width: 950
Height: 500
Visible: false
Children:
Background@BACKGROUND:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Background: dialog
Children:
Container@BACKGROUND:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 35
Children:
Label@TITLE:
X: 0
@@ -486,4 +485,11 @@ Container@OBSERVER_STATS:
YAxisLabel: $
LabelFont: TinyBold
AxisFont: Bold
Button@CLOSE:
X: PARENT_RIGHT - 145
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Text: Close
Key: escape
Font: Bold

View File

@@ -108,6 +108,7 @@ Container@PLAYER_WIDGETS:
Logic: AddRaceSuffixLogic
MenuContainer: INGAME_DEBUG_BG
HideIngameUI: false
Pause: false
Key: f2
X: 128
Width: 28
@@ -126,6 +127,7 @@ Container@PLAYER_WIDGETS:
Logic: AddRaceSuffixLogic
MenuContainer: INGAME_DIPLOMACY_BG
HideIngameUI: false
Pause: false
Key: f1
X: 160
Width: 28