Utility methods for window decoration.
Utility methods for window decoration.

--- a/API/VOID_Module.cs
+++ b/API/VOID_Module.cs
@@ -407,6 +407,10 @@
 
 	public abstract class VOID_WindowModule : VOID_Module
 	{
+		protected static GUIContent closeButton;
+
+		protected static Dictionary<int, Action<int>> DecoratedWindows;
+
 		[AVOID_SaveValue("WindowPos")]
 		protected Rect WindowPos;
 		protected float defWidth;
@@ -414,7 +418,17 @@
 
 		protected string inputLockName;
 
-		private GUIContent closeButton;
+		protected virtual Action<int> DecoratedWindow
+		{
+			get
+			{
+				return VOID_WindowModule.DecorateWindow(
+					this.ModuleWindow,
+					this.WindowPos,
+					(bool active) => { this.toggleActive = active; }
+				);
+			}
+		}
 
 		public VOID_WindowModule() : base()
 		{
@@ -505,31 +519,61 @@
 			}
 		}
 
-		private void DecoratedWindow(int id)
-		{
-			this.ModuleWindow(id);
-
-			if (this.closeButton == null)
-			{
-				this.closeButton = new GUIContent("X");
-			}
-
-			Rect closeRect = GUILayoutUtility.GetRect(
-				this.closeButton,
-				this.core.Skin.button,
-				GUILayout.ExpandWidth(false)
-			);
-
-			closeRect.x = this.WindowPos.width - closeRect.width - this.core.Skin.button.margin.right;
-			closeRect.y = this.core.Skin.button.margin.top;
-
-			GUI.Button(closeRect, closeButton, this.core.Skin.button);
-
-			if (Event.current.type == EventType.repaint && Input.GetMouseButtonUp(0))
-			{
-				if (closeRect.Contains(Event.current.mousePosition))
-				{
-					this.toggleActive = false;
+		public static Action<int> DecorateWindow(Action<int> func, Rect windowRect, Callback<bool> callBack)
+		{
+			if (DecoratedWindows == null)
+			{
+				DecoratedWindows = new Dictionary<int, Action<int>>();
+			}
+
+			int hashCode = func.GetHashCode();
+
+			if (!DecoratedWindows.ContainsKey(hashCode))
+			{
+				DecoratedWindows[hashCode] = delegate(int id)
+				{
+					func(id);
+
+					if (closeButton == null)
+					{
+						closeButton = new GUIContent("X");
+					}
+
+					Rect closeRect = GUILayoutUtility.GetRect(
+						closeButton,
+						VOID_Data.Core.Skin.button,
+						GUILayout.ExpandWidth(false)
+					);
+
+					closeRect.x = windowRect.width - closeRect.width - VOID_Data.Core.Skin.button.margin.right;
+					closeRect.y = VOID_Data.Core.Skin.button.margin.top;
+
+					GUI.Button(closeRect, closeButton, VOID_Data.Core.Skin.button);
+
+					if (Event.current.type == EventType.repaint && Input.GetMouseButtonUp(0))
+					{
+						if (closeRect.Contains(Event.current.mousePosition))
+						{
+							callBack(false);
+						}
+					}
+				};
+			}
+
+			return DecoratedWindows[hashCode];
+		}
+
+		public static void UncacheWindow(Action<int> func)
+		{
+			if (DecoratedWindows != null)
+			{
+				int hashCode = func.GetHashCode();
+
+				if (DecoratedWindows.ContainsKey(hashCode))
+				{
+					VOID_Tools.UncacheWindow(DecoratedWindows[hashCode]);
+
+					DecoratedWindows.Remove(hashCode);
 				}
 			}
 		}

--- a/Tools/VOID_Tools.cs
+++ b/Tools/VOID_Tools.cs
@@ -363,6 +363,19 @@
 			}
 
 			return functionCache[hashCode];
+		}
+
+		public static void UncacheWindow(Action<int> func)
+		{
+			if (functionCache != null)
+			{
+				int hashCode = func.GetHashCode();
+
+				if (functionCache.ContainsKey(hashCode))
+				{
+					functionCache.Remove(hashCode);
+				}
+			}
 		}
 
 		/// <summary>

--- a/VOIDCore_Generic.cs
+++ b/VOIDCore_Generic.cs
@@ -392,7 +392,12 @@
 				_mainWindowPos = GUILayout.Window(
 					this.windowID,
 					_mainWindowPos,
-					VOID_Tools.GetWindowHandler(this.VOIDMainWindow),
+					VOID_Tools.GetWindowHandler(
+						VOID_WindowModule.DecorateWindow(
+							this.VOIDMainWindow,
+							_mainWindowPos,
+							(bool active) => { this.mainGuiMinimized = !active; }
+						)),
 					string.Join(" ", new string[] { this.VoidName, this.VoidVersion }),
 					GUILayout.Width(250f),
 					GUILayout.Height(50f),
@@ -422,7 +427,11 @@
 				_configWindowPos = GUILayout.Window(
 					this.windowID,
 					_configWindowPos,
-					VOID_Tools.GetWindowHandler(this.VOIDConfigWindow),
+					VOID_Tools.GetWindowHandler(VOID_WindowModule.DecorateWindow(
+						this.VOIDConfigWindow,
+						_configWindowPos,
+						(bool active) => { this.configWindowMinimized = !active; }
+					)),
 					string.Join(" ", new string[] { this.VoidName, "Configuration" }),
 					GUILayout.Width(250),
 					GUILayout.Height(50)