Some tweaks to string formatting, mostly in VOID_DataValue. Also mulling some changes to the way VOID_DataValues work.
[VOID.git] / VOID_CareerStatus.cs
blob:a/VOID_CareerStatus.cs -> blob:b/VOID_CareerStatus.cs
--- a/VOID_CareerStatus.cs
+++ b/VOID_CareerStatus.cs
@@ -26,33 +26,30 @@
 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+// TODO: Remove ToadicusTools. prefixes after refactor is done.
+
 using KSP;
 using System;
 using System.Text;
-using ToadicusTools;
+
+using ToadicusTools.Text;
 using UnityEngine;
 
 namespace VOID
 {
 	[VOID_Scenes(GameScenes.FLIGHT, GameScenes.EDITOR, GameScenes.SPACECENTER)]
 	[VOID_GameModes(Game.Modes.CAREER, Game.Modes.SCIENCE_SANDBOX)]
-	public class VOID_CareerStatus : VOID_WindowModule
+	public class VOID_CareerStatus : VOID_SingletonWindow<VOID_CareerStatus>
 	{
-		public static VOID_CareerStatus Instance
-		{
-			get;
-			private set;
-		}
-
 		public static string formatDelta(double delta, string numberFormat)
 		{
 			if (delta > 0)
 			{
-				return string.Format("<color='lime'>{0}↑</color>", delta.ToString(numberFormat, Tools.SIFormatter));
+				return string.Format("<color='lime'>{0}↑</color>", delta.ToString(numberFormat, SIFormatProvider.SIFormatter));
 			}
 			else if (delta < 0)
 			{
-				return string.Format("<color='red'>{0}↓</color>", delta.ToString(numberFormat, Tools.SIFormatter));
+				return string.Format("<color='red'>{0}↓</color>", delta.ToString(numberFormat, SIFormatProvider.SIFormatter));
 			}
 			else
 			{
@@ -122,7 +119,7 @@
 		{
 			get
 			{
-				Tools.PostDebugMessage(
+				ToadicusTools.Logging.PostDebugMessage(
 					this,
 					"Checking init state:" +
 					"\n\tcurrentFunds={0}" +
@@ -151,7 +148,7 @@
 			base.DrawGUI();
 		}
 
-		public override void ModuleWindow(int _)
+		public override void ModuleWindow(int id)
 		{
 			GUILayout.BeginVertical();
 
@@ -178,7 +175,7 @@
 
 			GUILayout.EndVertical();
 
-			GUI.DragWindow();
+			base.ModuleWindow(id);
 		}
 
 		// TODO: Update event handlers to do something useful with the new "reasons" parameter.
@@ -207,7 +204,7 @@
 
 		private void initCurrencies()
 		{
-			Tools.PostDebugMessage(
+			ToadicusTools.Logging.PostDebugMessage(
 				this,
 				"Initializing currencies." +
 				"\n\tFunding.Instance={0}" +
@@ -233,8 +230,6 @@
 		 * */
 		public VOID_CareerStatus() : base()
 		{
-			VOID_CareerStatus.Instance = this;
-
 			this.Name = "Career Status";
 
 			GameEvents.OnFundsChanged.Add(this.onFundsChange);
@@ -244,11 +239,11 @@
 
 			bool texturesLoaded;
 
-			texturesLoaded = IOTools.LoadTexture(out this.fundsIconGreen, "VOID/Textures/fundsgreen.png", 10, 18);
-			texturesLoaded &= IOTools.LoadTexture(out this.fundsIconRed, "VOID/Textures/fundsred.png", 10, 18);
-			texturesLoaded &= IOTools.LoadTexture(out this.reputationIconGreen, "VOID/Textures/repgreen.png", 16, 18);
-			texturesLoaded &= IOTools.LoadTexture(out this.reputationIconRed, "VOID/Textures/repred.png", 16, 18);
-			texturesLoaded &= IOTools.LoadTexture(out this.scienceIcon, "VOID/Textures/science.png", 16, 18);
+			texturesLoaded = ToadicusTools.IOTools.LoadTexture(out this.fundsIconGreen, "VOID/Textures/fundsgreen.png", 10, 18);
+			texturesLoaded &= ToadicusTools.IOTools.LoadTexture(out this.fundsIconRed, "VOID/Textures/fundsred.png", 10, 18);
+			texturesLoaded &= ToadicusTools.IOTools.LoadTexture(out this.reputationIconGreen, "VOID/Textures/repgreen.png", 16, 18);
+			texturesLoaded &= ToadicusTools.IOTools.LoadTexture(out this.reputationIconRed, "VOID/Textures/repred.png", 16, 18);
+			texturesLoaded &= ToadicusTools.IOTools.LoadTexture(out this.scienceIcon, "VOID/Textures/science.png", 16, 18);
 
 			this.fundsContent = new GUIContent();
 			this.repContent = new GUIContent();
@@ -266,14 +261,19 @@
 			this.currentReputation = float.NaN;
 		}
 
-		~VOID_CareerStatus()
+		public override void Dispose()
 		{
 			GameEvents.OnFundsChanged.Remove(this.onFundsChange);
 			GameEvents.OnReputationChanged.Remove(this.onRepChange);
 			GameEvents.OnScienceChanged.Remove(this.onScienceChange);
 			GameEvents.onGameStateLoad.Remove(this.onGameStateLoad);
 
-			VOID_CareerStatus.Instance = null;
+			base.Dispose();
+		}
+
+		~VOID_CareerStatus()
+		{
+			this.Dispose();
 		}
 	}
 }