Generally changed GUILayout.Toggle to GUITools.Toggle, because the former apparently sucks.
[VOID.git] / API / VOID_HUDModule.cs
blob:a/API/VOID_HUDModule.cs -> blob:b/API/VOID_HUDModule.cs
--- a/API/VOID_HUDModule.cs
+++ b/API/VOID_HUDModule.cs
@@ -56,11 +56,11 @@
 			{
 				if (this._colorIndex >= this.textColors.Count - 1)
 				{
-					this._colorIndex = 0;
+					this._colorIndex.value = 0;
 					return;
 				}
 
-				this._colorIndex = value;
+				this._colorIndex.value = value;
 			}
 		}
 
@@ -72,7 +72,7 @@
 
 		public VOID_HUDModule() : base()
 		{
-			this._colorIndex = 0;
+			this._colorIndex = (VOID_SaveValue<int>)0;
 
 			this.textColors = new List<Color>();
 
@@ -86,7 +86,7 @@
 			this.textColors.Add(Color.cyan);
 			this.textColors.Add(Color.magenta);
 
-			this.positionsLocked = true;
+			this.positionsLocked = (VOID_SaveValue<bool>)true;
 
 			this.Windows = new List<HUDWindow>();
 		}
@@ -104,10 +104,13 @@
 				SimManager.RequestSimulation();
 			}
 
-			foreach (HUDWindow window in this.Windows)
-			{
+			HUDWindow window;
+			for (int idx = 0; idx < this.Windows.Count; idx++)
+			{
+				window = this.Windows[idx];
+
 				window.WindowPos = GUILayout.Window(
-					this.core.windowID,
+					this.core.WindowID,
 					window.WindowPos,
 					VOID_Tools.GetWindowHandler(window.WindowFunction),
 					GUIContent.none,
@@ -127,13 +130,16 @@
 
 			if (GUILayout.Button(string.Intern("Reset HUD Positions"), GUILayout.ExpandWidth(false)))
 			{
-				foreach (HUDWindow window in this.Windows)
+				HUDWindow window;
+				for (int idx = 0; idx < this.Windows.Count; idx++)
 				{
+					window = this.Windows[idx];
+
 					window.WindowPos = new Rect(window.defaultWindowPos);
 				}
 			}
 
-			this.positionsLocked = GUITools.Toggle(this.positionsLocked, "Lock HUD Positions");
+			this.positionsLocked.value = GUITools.Toggle(this.positionsLocked, "Lock HUD Positions");
 		}
 
 		public override void LoadConfig()
@@ -143,8 +149,11 @@
 			var config = KSP.IO.PluginConfiguration.CreateForType<VOID_HUDModule>();
 			config.load();
 
-			foreach (HUDWindow window in this.Windows)
-			{
+			HUDWindow window;
+			for (int idx = 0; idx < this.Windows.Count; idx++)
+			{
+				window = this.Windows[idx];
+
 				string saveName = string.Format("{0}_{1}", this.GetType().Name, window.WindowName);
 				Rect loadedPos = config.GetValue(saveName, window.defaultWindowPos);
 
@@ -152,12 +161,15 @@
 			}
 		}
 
-		public override void _SaveToConfig(KSP.IO.PluginConfiguration config)
-		{
-			base._SaveToConfig(config);
-
-			foreach (HUDWindow window in this.Windows)
-			{
+		public override void Save(KSP.IO.PluginConfiguration config)
+		{
+			base.Save(config);
+
+			HUDWindow window;
+			for (int idx = 0; idx < this.Windows.Count; idx++)
+			{
+				window = this.Windows[idx];
+
 				string saveName = string.Format("{0}_{1}", this.GetType().Name, window.WindowName);
 				config.SetValue(saveName, window.WindowPos);
 			}