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

@@ -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)