From 88768031a5080fd62ad6d97f158b8e1093684c0c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 29 May 2016 00:36:02 +0100 Subject: [PATCH] Add BecameVisible and BecameHidden methods to ChromeLogic. --- OpenRA.Game/Widgets/Widget.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 0c58992546..f6dc0a8e2a 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -33,9 +33,23 @@ namespace OpenRA.Widgets public static void CloseWindow() { if (WindowList.Count > 0) - Root.RemoveChild(WindowList.Pop()); + { + var hidden = WindowList.Pop(); + Root.RemoveChild(hidden); + if (hidden.LogicObjects != null) + foreach (var l in hidden.LogicObjects) + l.BecameHidden(); + } + if (WindowList.Count > 0) - Root.AddChild(WindowList.Peek()); + { + var restore = WindowList.Peek(); + Root.AddChild(restore); + + if (restore.LogicObjects != null) + foreach (var l in restore.LogicObjects) + l.BecameVisible(); + } } public static Widget OpenWindow(string id) @@ -148,6 +162,8 @@ namespace OpenRA.Widgets { public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } public virtual void Tick() { } + public virtual void BecameHidden() { } + public virtual void BecameVisible() { } protected virtual void Dispose(bool disposing) { } }