VOID_VesselInfo: Cleaned things up by using Engineer.VesselSimulator.
VOID_VesselInfo: Cleaned things up by using Engineer.VesselSimulator.

file:a/VOID.csproj (deleted)
<?xml version="1.0" encoding="utf-8"?>  
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">  
<PropertyGroup>  
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>  
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>  
<ProductVersion>10.0.0</ProductVersion>  
<SchemaVersion>2.0</SchemaVersion>  
<ProjectGuid>{45ACC1CC-942C-4A66-BFC7-8BE375938B18}</ProjectGuid>  
<OutputType>Library</OutputType>  
<RootNamespace>VOID</RootNamespace>  
<AssemblyName>VOID</AssemblyName>  
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>  
</PropertyGroup>  
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">  
<DebugSymbols>true</DebugSymbols>  
<DebugType>full</DebugType>  
<Optimize>false</Optimize>  
<OutputPath>bin\Debug</OutputPath>  
<DefineConstants>DEBUG; TRACE</DefineConstants>  
<ErrorReport>prompt</ErrorReport>  
<WarningLevel>4</WarningLevel>  
<ConsolePause>false</ConsolePause>  
<CustomCommands>  
<CustomCommands>  
<Command type="AfterBuild" command="/usr/bin/cp -fv ${ProjectDir}/bin/Debug/VOID.dll /mnt/games/ssd/KSP_linux/GameData/VOID/Plugins/" />  
<Command type="AfterBuild" command="/usr/bin/cp -fv ${ProjectDir}/bin/Debug/VOID.dll /mnt/zeetha/srv/default/htdocs/KSP/VOID/" />  
</CustomCommands>  
</CustomCommands>  
</PropertyGroup>  
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">  
<Optimize>true</Optimize>  
<OutputPath>bin\Release</OutputPath>  
<ErrorReport>prompt</ErrorReport>  
<WarningLevel>4</WarningLevel>  
<ConsolePause>false</ConsolePause>  
<DefineConstants>TRACE</DefineConstants>  
<CustomCommands>  
<CustomCommands>  
<Command type="AfterBuild" command="/usr/bin/cp -fv ${ProjectDir}/bin/Release/VOID.dll /mnt/games/ssd/KSP_linux/GameData/VOID/Plugins/" />  
</CustomCommands>  
</CustomCommands>  
</PropertyGroup>  
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />  
<ItemGroup>  
<Compile Include="Tools.cs" />  
<Compile Include="IVOID_Module.cs" />  
<Compile Include="VOIDFlightMaster.cs" />  
<Compile Include="VOID_Core.cs" />  
<Compile Include="VOID_Module.cs" />  
<Compile Include="VOID_HUD.cs" />  
<Compile Include="VOID_SaveValue.cs" />  
<Compile Include="VOID_Orbital.cs" />  
<Compile Include="VOID_SurfAtmo.cs" />  
<Compile Include="VOID_VesselInfo.cs" />  
<Compile Include="VOID_Transfer.cs" />  
<Compile Include="VOID_CBInfoBrowser.cs" />  
<Compile Include="VOID_Rendezvous.cs" />  
<Compile Include="VOID_VesselRegister.cs" />  
<Compile Include="VOID_DataLogger.cs" />  
<Compile Include="VOID_EditorCore.cs" />  
<Compile Include="VOID_EditorHUD.cs" />  
<Compile Include="IntCollection.cs" />  
<Compile Include="VOID_DataValue.cs" />  
</ItemGroup>  
<ItemGroup>  
<Reference Include="Assembly-CSharp">  
<HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>  
<Private>False</Private>  
</Reference>  
<Reference Include="UnityEngine">  
<HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\UnityEngine.dll</HintPath>  
<Private>False</Private>  
</Reference>  
<Reference Include="System">  
<HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\System.dll</HintPath>  
<Private>False</Private>  
</Reference>  
</ItemGroup>  
<ItemGroup>  
<ProjectReference Include="..\Engineer.Extensions\Engineer.Extensions.csproj">  
<Project>{2FCF882B-0771-4649-8D04-81D7AA76A486}</Project>  
<Name>Engineer.Extensions</Name>  
</ProjectReference>  
<ProjectReference Include="..\VesselSimulator\VesselSimulator.csproj">  
<Project>{30FD6C0B-D36E-462F-B0FF-F0FAC9C666CF}</Project>  
<Name>VesselSimulator</Name>  
</ProjectReference>  
</ItemGroup>  
<ProjectExtensions>  
<MonoDevelop>  
<Properties>  
<Policies>  
<StandardHeader Text=" &#xA; ${FileName}&#xA; &#xA; Author:&#xA; ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA; Copyright (c) ${Year} ${CopyrightHolder}&#xA;&#xA; This program is free software: you can redistribute it and/or modify&#xA; it under the terms of the GNU General Public License as published by&#xA; the Free Software Foundation, either version 3 of the License, or&#xA; (at your option) any later version.&#xA;&#xA; This program is distributed in the hope that it will be useful,&#xA; but WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the&#xA; GNU General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU General Public License&#xA; along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;." IncludeInNewFiles="True" />  
</Policies>  
</Properties>  
</MonoDevelop>  
</ProjectExtensions>  
</Project>  
// //
// VOID_DataValue.cs // VOID_DataValue.cs
// //
// Author: // Author:
// toadicus <> // toadicus <>
// //
// Copyright (c) 2013 toadicus // Copyright (c) 2013 toadicus
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System; using System;
using UnityEngine; using UnityEngine;
   
namespace VOID namespace VOID
{ {
public interface IVOID_DataValue public interface IVOID_DataValue
{ {
void Refresh(); void Refresh();
string ValueUnitString(); string ValueUnitString();
void DoGUIHorizontal(); void DoGUIHorizontal();
} }
   
public class VOID_DataValue<T> : IVOID_DataValue public class VOID_DataValue<T> : IVOID_DataValue
{ {
/* /*
* Static Members * Static Members
* */ * */
public static implicit operator T(VOID_DataValue<T> v) public static implicit operator T(VOID_DataValue<T> v)
{ {
return (T)v.Value; return (T)v.Value;
} }
   
/* /*
* Instance Members * Instance Members
* */ * */
/* /*
* Fields * Fields
* */ * */
protected T cache; protected T cache;
protected Func<T> ValueFunc; protected Func<T> ValueFunc;
   
/* /*
* Properties * Properties
* */ * */
public string Label { get; protected set; } public string Label { get; protected set; }
public string Units { get; protected set; } public string Units { get; protected set; }
   
public T Value { public T Value {
get { get {
return (T)this.cache; return (T)this.cache;
} }
} }
   
/* /*
* Methods * Methods
* */ * */
public VOID_DataValue(string Label, Func<T> ValueFunc, string Units = "") public VOID_DataValue(string Label, Func<T> ValueFunc, string Units = "")
{ {
this.Label = Label; this.Label = Label;
this.Units = Units; this.Units = Units;
this.ValueFunc = ValueFunc; this.ValueFunc = ValueFunc;
this.cache = this.ValueFunc.Invoke ();  
} }
   
public void Refresh() public void Refresh()
{ {
this.cache = this.ValueFunc.Invoke (); this.cache = this.ValueFunc.Invoke ();
} }
   
public T GetFreshValue() public T GetFreshValue()
{ {
this.Refresh (); this.Refresh ();
return (T)this.cache; return (T)this.cache;
} }
   
public string ValueUnitString() { public string ValueUnitString() {
return this.Value.ToString() + this.Units; return this.Value.ToString() + this.Units;
} }
   
public virtual void DoGUIHorizontal() public virtual void DoGUIHorizontal()
{ {
GUILayout.BeginHorizontal (GUILayout.ExpandWidth (true)); GUILayout.BeginHorizontal (GUILayout.ExpandWidth (true));
GUILayout.Label (this.Label + ":"); GUILayout.Label (this.Label + ":");
GUILayout.FlexibleSpace (); GUILayout.FlexibleSpace ();
GUILayout.Label (this.ValueUnitString(), GUILayout.ExpandWidth (false)); GUILayout.Label (this.ValueUnitString(), GUILayout.ExpandWidth (false));
GUILayout.EndHorizontal (); GUILayout.EndHorizontal ();
} }
   
public override string ToString() public override string ToString()
{ {
return string.Format ( return string.Format (
"{0}: {1}{2}", "{0}: {1}{2}",
this.Label, this.Label,
this.Value.ToString (), this.Value.ToString (),
this.Units this.Units
); );
} }
} }
   
internal interface IVOID_NumericValue internal interface IVOID_NumericValue
{ {
  double ToDouble();
string ToString(string format); string ToString(string format);
string ToSIString(int digits, int MinMagnitude, int MaxMagnitude); string ToSIString(int digits, int MinMagnitude, int MaxMagnitude);
} }
   
public abstract class VOID_NumValue<T> : VOID_DataValue<T>, IVOID_NumericValue public abstract class VOID_NumValue<T> : VOID_DataValue<T>, IVOID_NumericValue
{ {
public VOID_NumValue(string Label, Func<T> ValueFunc, string Units = "") : base(Label, ValueFunc, Units) {} public VOID_NumValue(string Label, Func<T> ValueFunc, string Units = "") : base(Label, ValueFunc, Units) {}
   
  public abstract double ToDouble();
public abstract string ToString(string Format); public abstract string ToString(string Format);
public abstract string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue); public abstract string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue);
   
public abstract string ValueUnitString(string format); public abstract string ValueUnitString(string format);
public abstract string ValueUnitString(ushort digits);  
  public virtual string ValueUnitString(ushort digits) {
  return Tools.MuMech_ToSI(this.ToDouble(), digits) + this.Units;
  }
   
  public virtual string ValueUnitString(ushort digits, int MinMagnitude, int MaxMagnitude)
  {
  return Tools.MuMech_ToSI(this.ToDouble(), digits, MinMagnitude, MaxMagnitude) + this.Units;
  }
   
public virtual void DoGUIHorizontal(string format) public virtual void DoGUIHorizontal(string format)
{ {
GUILayout.BeginHorizontal (GUILayout.ExpandWidth (true)); GUILayout.BeginHorizontal (GUILayout.ExpandWidth (true));
GUILayout.Label (this.Label + ":"); GUILayout.Label (this.Label + ":");
GUILayout.FlexibleSpace (); GUILayout.FlexibleSpace ();
GUILayout.Label (this.ValueUnitString(format), GUILayout.ExpandWidth (false)); GUILayout.Label (this.ValueUnitString(format), GUILayout.ExpandWidth (false));
GUILayout.EndHorizontal (); GUILayout.EndHorizontal ();
} }
   
public virtual ushort DoGUIHorizontal(ushort digits) public virtual ushort DoGUIHorizontal(ushort digits, bool precisionButton = true)
{ {
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
GUILayout.Label(this.Label + ":", GUILayout.ExpandWidth(true)); GUILayout.Label(this.Label + ":", GUILayout.ExpandWidth(true));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(this.ValueUnitString(digits), GUILayout.ExpandWidth(false)); if (precisionButton)
if (GUILayout.Button ("P")) { {
digits = (ushort)((digits + 3) % 15); float magnitude = (float)Math.Log10(Math.Abs(this.ToDouble()));
  GUILayout.Label(this.ValueUnitString(3, int.MinValue, (int)magnitude - digits), GUILayout.ExpandWidth(false));
  if (GUILayout.Button(digits.ToString()))
  {
  float magLimit = Math.Max(magnitude, 6f);
  magLimit = (float)Math.Ceiling(magLimit / 3f) * 3f;
  if (Event.current.button == 0)
  {
  digits = (ushort)((digits + 3) % (int)magLimit);
  }
  else if (Event.current.button == 1)
  {
  digits = (ushort)((digits - 3) % (int)magLimit);
  }
  }
  }
  else
  {
  GUILayout.Label(this.ValueUnitString(digits), GUILayout.ExpandWidth(false));
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
return digits; return digits;
} }
   
} }
   
public class VOID_DoubleValue : VOID_NumValue<double>, IVOID_NumericValue public class VOID_DoubleValue : VOID_NumValue<double>, IVOID_NumericValue
{ {
public VOID_DoubleValue(string Label, Func<double> ValueFunc, string Units) : base(Label, ValueFunc, Units) {} public VOID_DoubleValue(string Label, Func<double> ValueFunc, string Units) : base(Label, ValueFunc, Units) {}
   
  public override double ToDouble ()
  {
  return this.Value;
  }
   
public override string ToString(string format) public override string ToString(string format)
{ {
return string.Format ( return string.Format (
"{0}: {1}{2}", "{0}: {1}{2}",
this.Label, this.Label,
this.Value.ToString (format), this.Value.ToString (format),
this.Units this.Units
); );
} }
   
public override string ValueUnitString(string format) { public override string ValueUnitString(string format) {
return this.Value.ToString(format) + this.Units; return this.Value.ToString(format) + this.Units;
} }
   
public override string ValueUnitString(ushort digits) {  
return Tools.MuMech_ToSI(this.Value, digits) + this.Units;  
}  
   
public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue) public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue)
{ {
return string.Format ( return string.Format (
"{0}{1}", "{0}{1}",
Tools.MuMech_ToSI (this.Value, digits, MinMagnitude, MaxMagnitude), Tools.MuMech_ToSI (this.Value, digits, MinMagnitude, MaxMagnitude),
this.Units this.Units
); );
} }
} }
public class VOID_FloatValue : VOID_NumValue<float>, IVOID_NumericValue public class VOID_FloatValue : VOID_NumValue<float>, IVOID_NumericValue
{ {
public VOID_FloatValue(string Label, Func<float> ValueFunc, string Units) : base(Label, ValueFunc, Units) {} public VOID_FloatValue(string Label, Func<float> ValueFunc, string Units) : base(Label, ValueFunc, Units) {}
   
  public override double ToDouble ()
  {
  return (double)this.Value;
  }
   
public override string ValueUnitString(string format) { public override string ValueUnitString(string format) {
return this.Value.ToString(format) + this.Units; return this.Value.ToString(format) + this.Units;
} }
   
public override string ValueUnitString(ushort digits) {  
return Tools.MuMech_ToSI((double)this.Value, digits) + this.Units;  
}  
   
public override string ToString(string format) public override string ToString(string format)
{ {
return string.Format ( return string.Format (
"{0}: {1}{2}", "{0}: {1}{2}",
this.Label, this.Label,
this.Value.ToString (format), this.Value.ToString (format),
this.Units this.Units
); );
} }
   
public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue) public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue)
{ {
return string.Format ( return string.Format (
"{0}{1}", "{0}{1}",
Tools.MuMech_ToSI ((double)this.Value, digits, MinMagnitude, MaxMagnitude), Tools.MuMech_ToSI ((double)this.Value, digits, MinMagnitude, MaxMagnitude),
this.Units this.Units
); );
} }
} }
public class VOID_IntValue : VOID_NumValue<int>, IVOID_NumericValue public class VOID_IntValue : VOID_NumValue<int>, IVOID_NumericValue
{ {
public VOID_IntValue(string Label, Func<int> ValueFunc, string Units) : base(Label, ValueFunc, Units) {} public VOID_IntValue(string Label, Func<int> ValueFunc, string Units) : base(Label, ValueFunc, Units) {}
   
  public override double ToDouble ()
  {
  return (double)this.Value;
  }
   
public override string ValueUnitString(string format) { public override string ValueUnitString(string format) {
return this.Value.ToString(format) + this.Units; return this.Value.ToString(format) + this.Units;
} }
   
public override string ValueUnitString(ushort digits) {  
return Tools.MuMech_ToSI((double)this.Value, digits) + this.Units;  
}  
   
public override string ToString(string format) public override string ToString(string format)
{ {
return string.Format ( return string.Format (
"{0}: {1}{2}", "{0}: {1}{2}",
this.Label, this.Label,
this.Value.ToString (format), this.Value.ToString (format),
this.Units this.Units
); );
} }
   
public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue) public override string ToSIString(int digits = 3, int MinMagnitude = 0, int MaxMagnitude = int.MaxValue)
{ {
return string.Format ( return string.Format (
"{0}{1}", "{0}{1}",
Tools.MuMech_ToSI ((double)this.Value, digits, MinMagnitude, MaxMagnitude), Tools.MuMech_ToSI ((double)this.Value, digits, MinMagnitude, MaxMagnitude),
this.Units this.Units
); );
} }
} }
   
   
public class VOID_StrValue : VOID_DataValue<string> public class VOID_StrValue : VOID_DataValue<string>
{ {
public VOID_StrValue(string Label, Func<string> ValueFunc) : base(Label, ValueFunc, "") {} public VOID_StrValue(string Label, Func<string> ValueFunc) : base(Label, ValueFunc, "") {}
} }
} }
   
   
// //
// VOID_Orbital.cs // VOID_Orbital.cs
// //
// Author: // Author:
// toadicus <> // toadicus <>
// //
// Copyright (c) 2013 toadicus // Copyright (c) 2013 toadicus
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using KSP; using KSP;
using System; using System;
using UnityEngine; using UnityEngine;
   
namespace VOID namespace VOID
{ {
public class VOID_SurfAtmo : VOID_WindowModule public class VOID_SurfAtmo : VOID_WindowModule
{ {
  [AVOID_SaveValue("precisionValues")]
  protected long _precisionValues = 230584300921369395;
  protected IntCollection precisionValues;
   
  protected VOID_DoubleValue trueAltitude = new VOID_DoubleValue(
  "Altitude (true)",
  delegate()
  {
  double alt_true = VOID_Core.Instance.vessel.orbit.altitude - VOID_Core.Instance.vessel.terrainAltitude;
  // HACK: This assumes that on worlds with oceans, all water is fixed at 0 m,
  // and water covers the whole surface at 0 m.
  if (VOID_Core.Instance.vessel.terrainAltitude < 0 && VOID_Core.Instance.vessel.mainBody.ocean )
  alt_true = VOID_Core.Instance.vessel.orbit.altitude;
  return alt_true;
  },
  "m"
  );
   
  protected VOID_StrValue surfLatitude = new VOID_StrValue(
  "Latitude",
  new Func<string> (() => Tools.GetLatitudeString(VOID_Core.Instance.vessel))
  );
   
  protected VOID_StrValue surfLongitude = new VOID_StrValue(
  "Longitude",
  new Func<string> (() => Tools.GetLongitudeString(VOID_Core.Instance.vessel))
  );
   
  protected VOID_StrValue vesselHeading = new VOID_StrValue(
  "Heading",
  delegate()
  {
  double heading = Tools.MuMech_get_heading(VOID_Core.Instance.vessel);
  string cardinal = Tools.get_heading_text(heading);
   
  return string.Format(
  "{0}° {1}",
  heading.ToString("F2"),
  cardinal
  );
  }
  );
   
  protected VOID_DoubleValue terrainElevation = new VOID_DoubleValue(
  "Terrain elevation",
  new Func<double> (() => VOID_Core.Instance.vessel.terrainAltitude),
  "m"
  );
   
  protected VOID_DoubleValue surfVelocity = new VOID_DoubleValue(
  "Surface velocity",
  new Func<double> (() => VOID_Core.Instance.vessel.srf_velocity.magnitude),
  "m/s"
  );
   
  protected VOID_DoubleValue vertVelocity = new VOID_DoubleValue(
  "Vertical speed",
  new Func<double> (() => VOID_Core.Instance.vessel.verticalSpeed),
  "m/s"
  );
   
  protected VOID_DoubleValue horzVelocity = new VOID_DoubleValue(
  "Horizontal speed",
  new Func<double> (() => VOID_Core.Instance.vessel.horizontalSrfSpeed),
  "m/s"
  );
   
  protected VOID_FloatValue temperature = new VOID_FloatValue(
  "Temperature",
  new Func<float> (() => VOID_Core.Instance.vessel.flightIntegrator.getExternalTemperature()),
  "°C"
  );
   
  protected VOID_DoubleValue atmDensity = new VOID_DoubleValue (
  "Atmosphere Density",
  new Func<double> (() => VOID_Core.Instance.vessel.atmDensity * 1000f),
  "g/m³"
  );
   
  protected VOID_DoubleValue atmPressure = new VOID_DoubleValue (
  "Pressure",
  new Func<double> (() => VOID_Core.Instance.vessel.staticPressure),
  "atm"
  );
   
  protected VOID_FloatValue atmLimit = new VOID_FloatValue(
  "Atmosphere Limit",
  new Func<float> (() => VOID_Core.Instance.vessel.mainBody.maxAtmosphereAltitude),
  "m"
  );
   
  protected VOID_StrValue currBiome = new VOID_StrValue(
  "Biome",
  new Func<string> (() => Tools.Toadicus_GetAtt(VOID_Core.Instance.vessel).name)
  );
   
public VOID_SurfAtmo() public VOID_SurfAtmo()
{ {
this._Name = "Surface & Atmospheric Information"; this._Name = "Surface & Atmospheric Information";
   
this.WindowPos.x = Screen.width - 260f; this.WindowPos.x = Screen.width - 260f;
this.WindowPos.y = 85; this.WindowPos.y = 85;
} }
   
public override void ModuleWindow(int _) public override void ModuleWindow(int _)
{ {
  base.ModuleWindow (_);
   
  int idx = 0;
   
GUILayout.BeginVertical(); GUILayout.BeginVertical();
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.trueAltitude.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Altitude (true):"); idx++;
double alt_true = vessel.orbit.altitude - vessel.terrainAltitude;  
// HACK: This assumes that on worlds with oceans, all water is fixed at 0 m, and water covers the whole surface at 0 m.  
if (vessel.terrainAltitude < 0 && vessel.mainBody.ocean ) alt_true = vessel.orbit.altitude;  
GUILayout.Label(Tools.MuMech_ToSI(alt_true) + "m", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal ();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.surfLatitude.DoGUIHorizontal ();
GUILayout.Label("Latitude:");  
GUILayout.Label(Tools.GetLatitudeString(vessel), GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.surfLongitude.DoGUIHorizontal ();
GUILayout.Label("Longitude:");  
GUILayout.Label(Tools.GetLongitudeString(vessel), GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.vesselHeading.DoGUIHorizontal ();
GUILayout.Label("Heading:");  
GUILayout.Label(Tools.MuMech_get_heading(vessel).ToString("F2") + "° " + Tools.get_heading_text(Tools.MuMech_get_heading(vessel)), GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.terrainElevation.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Terrain elevation:"); idx++;
GUILayout.Label(Tools.MuMech_ToSI(vessel.terrainAltitude) + "m", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.surfVelocity.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Surface velocity:"); idx++;
GUILayout.Label(Tools.MuMech_ToSI(vessel.srf_velocity.magnitude) + "m/s", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.vertVelocity.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Vertical speed:"); idx++;
GUILayout.Label(Tools.MuMech_ToSI(vessel.verticalSpeed) + "m/s", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.horzVelocity.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Horizontal speed:"); idx++;
GUILayout.Label(Tools.MuMech_ToSI(vessel.horizontalSrfSpeed) + "m/s", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.temperature.DoGUIHorizontal ("F2");
GUILayout.Label("Temperature:");  
GUILayout.Label(vessel.flightIntegrator.getExternalTemperature().ToString("F2") + "° C", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.atmDensity.DoGUIHorizontal (3);
GUILayout.Label("Atmosphere density:");  
GUILayout.Label(Tools.MuMech_ToSI(vessel.atmDensity * 1000) + "g/m³", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.atmPressure.DoGUIHorizontal ("F2");
GUILayout.Label("Pressure:");  
GUILayout.Label(vessel.staticPressure.ToString("F2") + " atms", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.precisionValues [idx] = this.atmLimit.DoGUIHorizontal (this.precisionValues [idx]);
GUILayout.Label("Atmosphere limit:"); idx++;
GUILayout.Label("≈ " + Tools.MuMech_ToSI(vessel.mainBody.maxAtmosphereAltitude) + "m", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
// Toadicus edit: added Biome // Toadicus edit: added Biome
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.currBiome.DoGUIHorizontal ();
GUILayout.Label("Biome:");  
GUILayout.Label(Tools.Toadicus_GetAtt(vessel).name, VOID_Core.Instance.LabelStyles["right"]);  
GUILayout.EndHorizontal();  
   
GUILayout.EndVertical(); GUILayout.EndVertical();
GUI.DragWindow(); GUI.DragWindow();
} }
   
  public override void LoadConfig ()
  {
  base.LoadConfig ();
   
  this.precisionValues = new IntCollection (4, this._precisionValues);
  }
   
  public override void _SaveToConfig (KSP.IO.PluginConfiguration config)
  {
  this._precisionValues = this.precisionValues.collection;
   
  base._SaveToConfig (config);
  }
} }
} }
// //
// VOID_Orbital.cs // VOID_Orbital.cs
// //
// Author: // Author:
// toadicus <> // toadicus <>
// //
// Copyright (c) 2013 toadicus // Copyright (c) 2013 toadicus
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using KSP; using KSP;
using System; using System;
  using System.Collections.Generic;
using UnityEngine; using UnityEngine;
  using Engineer.VesselSimulator;
   
namespace VOID namespace VOID
{ {
public class VOID_VesselInfo : VOID_WindowModule public class VOID_VesselInfo : VOID_WindowModule
{ {
[AVOID_SaveValue("toggleExtended")] [AVOID_SaveValue("toggleExtended")]
protected VOID_SaveValue<bool> toggleExtended = false; protected VOID_SaveValue<bool> toggleExtended = false;
   
public VOID_VesselInfo() protected VOID_DoubleValue geeForce = new VOID_DoubleValue(
  "G-force",
  new Func<double>(() => VOID_Core.Instance.vessel.geeForce),
  "gees"
  );
   
  protected VOID_IntValue partCount = new VOID_IntValue(
  "Parts",
  new Func<int>(() => VOID_Core.Instance.vessel.Parts.Count),
  ""
  );
   
  protected VOID_DoubleValue totalMass = new VOID_DoubleValue(
  "Total Mass",
  new Func<double>(() => VOID_Core.Instance.vessel.GetTotalMass()),
  "tons"
  );
   
  protected VOID_DoubleValue resourceMass = new VOID_DoubleValue(
  "Resource Mass",
  delegate()
  {
  double rscMass = 0;
  foreach (Part part in VOID_Core.Instance.vessel.Parts)
  {
  rscMass += part.GetResourceMass();
  }
  return rscMass;
  },
  "tons"
  );
   
  protected VOID_DoubleValue stageDeltaV = new VOID_DoubleValue(
  "DeltaV (Current Stage)",
  delegate()
  {
  if (SimManager.Instance.Stages == null ||
  SimManager.Instance.Stages.Length <= Staging.lastStage
  )
  return double.NaN;
  return SimManager.Instance.Stages[Staging.lastStage].deltaV;
  },
  "m/s"
  );
   
  protected VOID_DoubleValue totalDeltaV = new VOID_DoubleValue(
  "DeltaV (Total)",
  delegate()
  {
  if (SimManager.Instance.Stages == null)
  return double.NaN;
  return SimManager.Instance.LastStage.totalDeltaV;
  },
  "m/s"
  );
   
  protected VOID_FloatValue mainThrottle = new VOID_FloatValue(
  "Throttle",
  new Func<float>(() => VOID_Core.Instance.vessel.ctrlState.mainThrottle * 100f),
  "%"
  );
   
  protected VOID_StrValue currmaxThrust = new VOID_StrValue(
  "Thrust (curr/max)",
  delegate()
  {
  if (SimManager.Instance.Stages == null)
  return "N/A";
   
  double currThrust = SimManager.Instance.LastStage.actualThrust;
  double maxThrust = SimManager.Instance.LastStage.thrust;
   
  return string.Format(
  "{0} / {1}",
  currThrust.ToString("F1"),
  maxThrust.ToString("F1")
  );
  }
  );
   
  protected VOID_StrValue currmaxThrustWeight = new VOID_StrValue(
  "T:W (curr/max)",
  delegate()
  {
  if (SimManager.Instance.Stages == null)
  return "N/A";
   
  double currThrust = SimManager.Instance.LastStage.actualThrust;
  double maxThrust = SimManager.Instance.LastStage.thrust;
  double mass = VOID_Core.Instance.vessel.GetTotalMass();
  double gravity = VOID_Core.Instance.vessel.mainBody.gravParameter /
  Math.Pow(
  VOID_Core.Instance.vessel.mainBody.Radius + VOID_Core.Instance.vessel.altitude,
  2
  );
  double weight = mass * gravity;
   
  return string.Format(
  "{0} / {1}",
  (currThrust / weight).ToString("F2"),
  (maxThrust / weight).ToString("F2")
  );
  }
  );
   
  protected VOID_DoubleValue surfaceThrustWeight = new VOID_DoubleValue(
  "Max T:W @ surface",
  delegate()
  {
  if (SimManager.Instance.Stages == null)
  return double.NaN;
   
  double maxThrust = SimManager.Instance.LastStage.thrust;
  double mass = VOID_Core.Instance.vessel.GetTotalMass();
  double gravity = (VOID_Core.Constant_G * VOID_Core.Instance.vessel.mainBody.Mass) /
  Math.Pow(VOID_Core.Instance.vessel.mainBody.Radius, 2);
  double weight = mass * gravity;
   
  return maxThrust / weight;
  },
  ""
  );
   
  public VOID_VesselInfo() : base()
{ {
this._Name = "Vessel Information"; this._Name = "Vessel Information";
   
this.WindowPos.x = Screen.width - 260; this.WindowPos.x = Screen.width - 260;
this.WindowPos.y = 450; this.WindowPos.y = 450;
} }
   
public override void ModuleWindow(int _) public override void ModuleWindow(int _)
{ {
  base.ModuleWindow (_);
   
if ((TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate)) if ((TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate))
{ {
Engineer.VesselSimulator.SimManager.Instance.RequestSimulation(); SimManager.Instance.RequestSimulation();
} }
   
Engineer.VesselSimulator.Stage[] stages = Engineer.VesselSimulator.SimManager.Instance.Stages; Stage[] stages = SimManager.Instance.Stages;
   
GUILayout.BeginVertical(); GUILayout.BeginVertical();
   
GUILayout.Label( GUILayout.Label(
vessel.vesselName, vessel.vesselName,
VOID_Core.Instance.LabelStyles["center_bold"], VOID_Core.Instance.LabelStyles["center_bold"],
GUILayout.ExpandWidth(true)); GUILayout.ExpandWidth(true));
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); this.geeForce.DoGUIHorizontal ("F2");
GUILayout.Label("G-force:");  
GUILayout.Label(vessel.geeForce.ToString("F2") + " gees", GUILayout.ExpandWidth(false)); this.partCount.DoGUIHorizontal ();
GUILayout.EndHorizontal();  
  this.totalMass.DoGUIHorizontal ("F1");
int num_parts = 0;  
double total_mass = vessel.GetTotalMass(); this.resourceMass.DoGUIHorizontal ("F1");
double resource_mass = 0;  
double max_thrust = 0; this.stageDeltaV.DoGUIHorizontal (3, false);
double final_thrust = 0;  
  this.totalDeltaV.DoGUIHorizontal (3, false);
foreach (Part p in vessel.parts)  
{ this.mainThrottle.DoGUIHorizontal ("F0");
num_parts++;  
resource_mass += p.GetResourceMass(); this.currmaxThrust.DoGUIHorizontal ();
   
foreach (PartModule pm in p.Modules) this.currmaxThrustWeight.DoGUIHorizontal ();
{  
if ((pm.moduleName == "ModuleEngines") && this.surfaceThrustWeight.DoGUIHorizontal ("F2");
((p.State == PartStates.ACTIVE) ||  
((Staging.CurrentStage > Staging.lastStage) && (p.inverseStage == Staging.lastStage)))  
)  
{  
max_thrust += ((ModuleEngines)pm).maxThrust;  
final_thrust += ((ModuleEngines)pm).finalThrust;  
}  
}  
}  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Parts:");  
GUILayout.Label(num_parts.ToString("F0"), GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Total mass:");  
GUILayout.Label(total_mass.ToString("F1") + " tons", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Resource mass:");  
GUILayout.Label(resource_mass.ToString("F1") + " tons", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
if (stages.Length > Staging.lastStage)  
{  
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("DeltaV (Current Stage):");  
GUILayout.Label(  
Tools.MuMech_ToSI(stages[Staging.lastStage].deltaV).ToString() + "m/s",  
GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
}  
   
if (stages.Length > 0)  
{  
double totalDeltaV = 0d;  
   
for (int i = 0; i < stages.Length; ++i)  
{  
totalDeltaV += stages [i].deltaV;  
}  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("DeltaV (Total):");  
GUILayout.Label(Tools.MuMech_ToSI(totalDeltaV).ToString() + "m/s", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
}  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Throttle:");  
GUILayout.Label((vessel.ctrlState.mainThrottle * 100f).ToString("F0") + "%", GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Thrust (curr/max):");  
GUILayout.Label(  
final_thrust.ToString("F1") +  
" / " + max_thrust.ToString("F1") + " kN",  
GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
double gravity = vessel.mainBody.gravParameter / Math.Pow(vessel.mainBody.Radius + vessel.altitude, 2);  
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("T:W (curr/max):");  
GUILayout.Label(  
(final_thrust / (total_mass * gravity)).ToString("F2") +  
" / " + (max_thrust / (total_mass * gravity)).ToString("F2"),  
GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
double g_ASL = (VOID_Core.Constant_G * vessel.mainBody.Mass) / Math.Pow(vessel.mainBody.Radius, 2);  
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));  
GUILayout.Label("Max T:W @ surface:");  
GUILayout.Label((max_thrust / (total_mass * g_ASL)).ToString("F2"), GUILayout.ExpandWidth(false));  
GUILayout.EndHorizontal();  
   
GUILayout.EndVertical(); GUILayout.EndVertical();
GUI.DragWindow(); GUI.DragWindow();
} }
} }
} }