VesselInfo: Changed resource mass line to new combat stage/total resource mass.
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -39,7 +39,7 @@
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("0.11.0.*")]
+[assembly: AssemblyVersion("0.12.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
--- a/VOID.csproj
+++ b/VOID.csproj
@@ -9,6 +9,7 @@
<RootNamespace>VOID</RootNamespace>
<AssemblyName>VOID</AssemblyName>
<CodePage>65001</CodePage>
+ <UseMSBuildEngine>False</UseMSBuildEngine>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReleaseVersion>0.11</ReleaseVersion>
--- a/VOID_Core.cs
+++ b/VOID_Core.cs
@@ -81,7 +81,7 @@
* Fields
* */
protected string VoidName = "VOID";
- protected string VoidVersion = "0.11.0";
+ protected string VoidVersion;
protected bool _factoryReset = false;
@@ -992,6 +992,10 @@
{
this._Name = "VOID Core";
+ System.Version version = this.GetType().Assembly.GetName().Version;
+
+ this.VoidVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.MajorRevision);
+
this._Active.value = true;
this._skinName = this.defaultSkin;
--- a/VOID_HUDAdvanced.cs
+++ b/VOID_HUDAdvanced.cs
@@ -134,7 +134,7 @@
VOID_Data.vesselAngularVelocity.ToSIString(2)
);
- if (VOID_Data.stageNominalThrust != 0)
+ if (VOID_Data.stageNominalThrust != 0d)
{
leftHUD.AppendFormat(
string.Intern("Thrust Offset: {0}\n"),
@@ -239,7 +239,7 @@
this.leftHUDPos.value = GUI.Window(
VOID_Core.Instance.windowID,
this.leftHUDPos,
- this.leftHUDWindow,
+ VOID_Tools.GetWindowHandler(this.leftHUDWindow),
GUIContent.none,
GUIStyle.none
);
@@ -249,7 +249,7 @@
this.rightHUDPos.value = GUI.Window(
VOID_Core.Instance.windowID,
this.rightHUDPos,
- this.rightHUDWindow,
+ VOID_Tools.GetWindowHandler(this.rightHUDWindow),
GUIContent.none,
GUIStyle.none
);
@@ -589,6 +589,11 @@
}
double interval = (node.UT - currentNodeBurnDuration) - Planetarium.GetUniversalTime();
+
+ if (double.IsNaN(interval))
+ {
+ return string.Intern("NaN");
+ }
int sign = Math.Sign(interval);
interval = Math.Abs(interval);
--- a/VOID_Tools.cs
+++ b/VOID_Tools.cs
@@ -28,6 +28,7 @@
using KSP;
using System;
+using System.Collections.Generic;
using UnityEngine;
namespace VOID
@@ -256,6 +257,39 @@
}
#endregion
+ private static Dictionary<int, GUI.WindowFunction> functionCache;
+ public static UnityEngine.GUI.WindowFunction GetWindowHandler(Action<int> func)
+ {
+ if (functionCache == null)
+ {
+ functionCache = new Dictionary<int, GUI.WindowFunction>();
+ }
+
+ int hashCode = func.GetHashCode();
+
+ if (!functionCache.ContainsKey(hashCode))
+ {
+ functionCache[hashCode] = delegate (int id)
+ {
+ try
+ {
+ func(id);
+ }
+ catch (ArgumentException ex)
+ {
+ Debug.LogWarning(
+ string.Format("[{0}]: ArgumentException caught during window call.", func.Target.GetType().Name)
+ );
+ #if DEBUG
+ Debug.LogException(ex);
+ #endif
+ }
+ };
+ }
+
+ return functionCache[hashCode];
+ }
+
/// <summary>
/// Converts the interval given in seconds to a human-friendly
/// time period in [years], [days], hours, minutes, and seconds.
--- a/VOID_VesselInfo.cs
+++ b/VOID_VesselInfo.cs
@@ -66,7 +66,7 @@
VOID_Data.totalMass.DoGUIHorizontal ("F3");
- VOID_Data.resourceMass.DoGUIHorizontal ("F3");
+ VOID_Data.comboResourceMass.DoGUIHorizontal ();
VOID_Data.stageDeltaV.DoGUIHorizontal (3, false);
@@ -128,6 +128,28 @@
return SimManager.LastStage.totalMass - SimManager.LastStage.totalBaseMass;
},
"tons"
+ );
+
+ public static readonly VOID_DoubleValue stageResourceMass = new VOID_DoubleValue(
+ "Resource Mass (Current Stage)",
+ delegate()
+ {
+ if (SimManager.LastStage == null)
+ {
+ return double.NaN;
+ }
+
+ return SimManager.LastStage.mass - SimManager.LastStage.baseMass;
+ },
+ "tons"
+ );
+
+ public static readonly VOID_StrValue comboResourceMass = new VOID_StrValue(
+ "Resource Mass (curr / total)",
+ delegate()
+ {
+ return string.Format("{0} / {1}", stageResourceMass.ValueUnitString(), resourceMass.ValueUnitString());
+ }
);
public static readonly VOID_DoubleValue stageDeltaV = new VOID_DoubleValue(