IntCollection: Removed some stray WriteLine.
IntCollection: Removed some stray WriteLine.

// //
// IntCollection.cs // IntCollection.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;
   
namespace VOID namespace VOID
{ {
public class IntCollection public class IntCollection
{ {
public static implicit operator long(IntCollection c) public static implicit operator long(IntCollection c)
{ {
return c.collection; return c.collection;
} }
   
protected long mask; protected long mask;
   
public long collection { get; protected set; } public long collection { get; protected set; }
public ushort maxCount { get; protected set; } public ushort maxCount { get; protected set; }
public ushort wordLength { get; protected set; } public ushort wordLength { get; protected set; }
   
public IntCollection (ushort wordLength = 4, long initialCollection = 0) public IntCollection (ushort wordLength = 4, long initialCollection = 0)
{ {
this.collection = initialCollection; this.collection = initialCollection;
this.wordLength = wordLength; this.wordLength = wordLength;
this.maxCount = (ushort)((sizeof(long) * 8 - 1) / wordLength); this.maxCount = (ushort)((sizeof(long) * 8 - 1) / wordLength);
this.mask = ((1 << this.wordLength) - 1); this.mask = ((1 << this.wordLength) - 1);
} }
   
public ushort this[int idx] public ushort this[int idx]
{ {
get { get {
if (idx < 0) { if (idx < 0) {
idx += this.maxCount; idx += this.maxCount;
} }
   
if (idx >= maxCount || idx < 0) { if (idx >= maxCount || idx < 0) {
throw new IndexOutOfRangeException (); throw new IndexOutOfRangeException ();
} }
   
idx *= wordLength; idx *= wordLength;
   
return (ushort)((this.collection & (this.mask << idx)) >> idx); return (ushort)((this.collection & (this.mask << idx)) >> idx);
} }
set { set {
Console.WriteLine (value);  
if (idx < 0) { if (idx < 0) {
idx += this.maxCount; idx += this.maxCount;
} }
   
if (idx >= maxCount || idx < 0) { if (idx >= maxCount || idx < 0) {
throw new IndexOutOfRangeException (); throw new IndexOutOfRangeException ();
} }
   
idx *= wordLength; idx *= wordLength;
   
long packvalue = value & this.mask; long packvalue = value & this.mask;
Console.WriteLine (packvalue);  
   
this.collection &= ~(this.mask << idx); this.collection &= ~(this.mask << idx);
this.collection |= packvalue << idx; this.collection |= packvalue << idx;
} }
} }
} }
} }
   
   
file:b/ToolbarWrapper.cs (new)
  //
  // ToolbarWrapper.cs
  //
  // Author:
  // toadicus <>
  //
  // Copyright (c) 2013 toadicus
  //
  // 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
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  using System;
 
  namespace VOID
  {
  public class ToolbarWrapper
  {
  public ToolbarWrapper()
  {
  }
  }
  }
 
 
// //
// 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;
} }
   
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(); 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 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 virtual string ValueUnitString(int digits) { public virtual string ValueUnitString(int digits) {
return Tools.MuMech_ToSI(this.ToDouble(), digits) + this.Units; return Tools.MuMech_ToSI(this.ToDouble(), digits) + this.Units;
} }
   
public virtual string ValueUnitString(int digits, int MinMagnitude, int MaxMagnitude) public virtual string ValueUnitString(int digits, int MinMagnitude, int MaxMagnitude)
{ {
return Tools.MuMech_ToSI(this.ToDouble(), digits, MinMagnitude, MaxMagnitude) + this.Units; 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 int DoGUIHorizontal(int digits, bool precisionButton = true) public virtual int DoGUIHorizontal(int digits, bool precisionButton = true)
{ {
if (precisionButton) if (precisionButton)
{ {
return this.DoGUIHorizontalPrec(digits); return this.DoGUIHorizontalPrec(digits);
} }
   
GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
GUILayout.Label(this.Label + " (P" + digits + "):", GUILayout.ExpandWidth(true)); GUILayout.Label(this.Label + ":", GUILayout.ExpandWidth(true));
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.Label(this.ValueUnitString(digits), GUILayout.ExpandWidth(false)); GUILayout.Label(this.ValueUnitString(digits), GUILayout.ExpandWidth(false));
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
return digits; return digits;
} }
   
public virtual int DoGUIHorizontalPrec(int digits) public virtual int DoGUIHorizontalPrec(int digits)
{ {
float magnitude; float magnitude;
float magLimit; float magLimit;
   
magnitude = (float)Math.Log10(Math.Abs(this.ToDouble())); magnitude = (float)Math.Log10(Math.Abs(this.ToDouble()));
   
magLimit = Mathf.Max(magnitude, 6f); magLimit = Mathf.Max(magnitude, 6f);
magLimit = Mathf.Round((float)Math.Ceiling(magLimit / 3f) * 3f); magLimit = Mathf.Round((float)Math.Ceiling(magLimit / 3f) * 3f);
   
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(3, int.MinValue, (int)magnitude - digits), GUILayout.ExpandWidth(false)); GUILayout.Label(this.ValueUnitString(3, int.MinValue, (int)magnitude - digits), GUILayout.ExpandWidth(false));
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
   
if (Event.current.type == EventType.mouseUp) if (Event.current.type == EventType.mouseUp)
{ {
Rect lastRect = GUILayoutUtility.GetLastRect(); Rect lastRect = GUILayoutUtility.GetLastRect();
if (lastRect.Contains(Event.current.mousePosition)) if (lastRect.Contains(Event.current.mousePosition))
{ {
if (Event.current.button == 0) if (Event.current.button == 0)
{ {
digits = (digits + 3) % (int)magLimit; digits = (digits + 3) % (int)magLimit;
} }
else if (Event.current.button == 1) else if (Event.current.button == 1)
{ {
digits = (digits - 3) % (int)magLimit; digits = (digits - 3) % (int)magLimit;
if (digits < 0) if (digits < 0)
{ {
digits = (int)magLimit - 3; digits = (int)magLimit - 3;
} }
} }
} }
} }
   
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 () public override double ToDouble ()
{ {
return this.Value; 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 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 () public override double ToDouble ()
{ {
return (double)this.Value; 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 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 () public override double ToDouble ()
{ {
return (double)this.Value; 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 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_Orbital : VOID_WindowModule public class VOID_Orbital : VOID_WindowModule
{ {
[AVOID_SaveValue("toggleExtended")] [AVOID_SaveValue("toggleExtended")]
protected VOID_SaveValue<bool> toggleExtended = false; protected VOID_SaveValue<bool> toggleExtended = false;
   
[AVOID_SaveValue("precisionValues")] [AVOID_SaveValue("precisionValues")]
protected long _precisionValues = 230584300921369395; protected long _precisionValues = 230584300921369395;
protected IntCollection precisionValues; protected IntCollection precisionValues;
   
protected VOID_StrValue primaryName = new VOID_StrValue ( protected VOID_StrValue primaryName = new VOID_StrValue (
VOIDLabels.void_primary, VOIDLabels.void_primary,
new Func<string> (() => VOID_Core.Instance.vessel.mainBody.name) new Func<string> (() => VOID_Core.Instance.vessel.mainBody.name)
); );
   
protected VOID_DoubleValue orbitAltitude = new VOID_DoubleValue ( protected VOID_DoubleValue orbitAltitude = new VOID_DoubleValue (
"Altitude (ASL)", "Altitude (ASL)",
new Func<double> (() => VOID_Core.Instance.vessel.orbit.altitude), new Func<double> (() => VOID_Core.Instance.vessel.orbit.altitude),
"m" "m"
); );
   
protected VOID_DoubleValue orbitVelocity = new VOID_DoubleValue ( protected VOID_DoubleValue orbitVelocity = new VOID_DoubleValue (
VOIDLabels.void_velocity, VOIDLabels.void_velocity,
new Func<double> (() => VOID_Core.Instance.vessel.orbit.vel.magnitude), new Func<double> (() => VOID_Core.Instance.vessel.orbit.vel.magnitude),
"m/s" "m/s"
); );
   
protected VOID_DoubleValue orbitApoAlt = new VOID_DoubleValue( protected VOID_DoubleValue orbitApoAlt = new VOID_DoubleValue(
VOIDLabels.void_apoapsis, VOIDLabels.void_apoapsis,
new Func<double>(() => VOID_Core.Instance.vessel.orbit.ApA), new Func<double>(() => VOID_Core.Instance.vessel.orbit.ApA),
"m" "m"
); );
   
protected VOID_DoubleValue oribtPeriAlt = new VOID_DoubleValue( protected VOID_DoubleValue oribtPeriAlt = new VOID_DoubleValue(
VOIDLabels.void_periapsis, VOIDLabels.void_periapsis,
new Func<double>(() => VOID_Core.Instance.vessel.orbit.PeA), new Func<double>(() => VOID_Core.Instance.vessel.orbit.PeA),
"m" "m"
); );
   
protected VOID_StrValue timeToApo = new VOID_StrValue( protected VOID_StrValue timeToApo = new VOID_StrValue(
"Time to Apoapsis", "Time to Apoapsis",
new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.timeToAp)) new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.timeToAp))
); );
   
protected VOID_StrValue timeToPeri = new VOID_StrValue( protected VOID_StrValue timeToPeri = new VOID_StrValue(
"Time to Apoapsis", "Time to Periapsis",
new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.timeToPe)) new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.timeToPe))
); );
   
protected VOID_DoubleValue orbitInclination = new VOID_DoubleValue( protected VOID_DoubleValue orbitInclination = new VOID_DoubleValue(
"Inclination", "Inclination",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.inclination), new Func<double>(() => VOID_Core.Instance.vessel.orbit.inclination),
"°" "°"
); );
   
protected VOID_DoubleValue gravityAccel = new VOID_DoubleValue( protected VOID_DoubleValue gravityAccel = new VOID_DoubleValue(
"Gravity", "Gravity",
delegate() delegate()
{ {
double orbitRadius = VOID_Core.Instance.vessel.mainBody.Radius + double orbitRadius = VOID_Core.Instance.vessel.mainBody.Radius +
VOID_Core.Instance.vessel.mainBody.GetAltitude(VOID_Core.Instance.vessel.findWorldCenterOfMass()); VOID_Core.Instance.vessel.mainBody.GetAltitude(VOID_Core.Instance.vessel.findWorldCenterOfMass());
return (VOID_Core.Constant_G * VOID_Core.Instance.vessel.mainBody.Mass) / return (VOID_Core.Constant_G * VOID_Core.Instance.vessel.mainBody.Mass) /
Math.Pow(orbitRadius, 2); Math.Pow(orbitRadius, 2);
}, },
"m/s²" "m/s²"
); );
   
protected VOID_StrValue orbitPeriod = new VOID_StrValue( protected VOID_StrValue orbitPeriod = new VOID_StrValue(
"Period", "Period",
new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.period)) new Func<string>(() => Tools.ConvertInterval(VOID_Core.Instance.vessel.orbit.period))
); );
   
protected VOID_DoubleValue semiMajorAxis = new VOID_DoubleValue( protected VOID_DoubleValue semiMajorAxis = new VOID_DoubleValue(
"Semi-Major Axis", "Semi-Major Axis",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.semiMajorAxis), new Func<double>(() => VOID_Core.Instance.vessel.orbit.semiMajorAxis),
"m" "m"
); );
   
protected VOID_DoubleValue eccentricity = new VOID_DoubleValue( protected VOID_DoubleValue eccentricity = new VOID_DoubleValue(
"Eccentricity", "Eccentricity",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.eccentricity), new Func<double>(() => VOID_Core.Instance.vessel.orbit.eccentricity),
"" ""
); );
   
protected VOID_DoubleValue meanAnomaly = new VOID_DoubleValue( protected VOID_DoubleValue meanAnomaly = new VOID_DoubleValue(
"Mean Anomaly", "Mean Anomaly",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.meanAnomaly * 180d / Math.PI), new Func<double>(() => VOID_Core.Instance.vessel.orbit.meanAnomaly * 180d / Math.PI),
"°" "°"
); );
   
protected VOID_DoubleValue trueAnomaly = new VOID_DoubleValue( protected VOID_DoubleValue trueAnomaly = new VOID_DoubleValue(
"True Anomaly", "True Anomaly",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.trueAnomaly), new Func<double>(() => VOID_Core.Instance.vessel.orbit.trueAnomaly),
"°" "°"
); );
   
protected VOID_DoubleValue eccAnomaly = new VOID_DoubleValue( protected VOID_DoubleValue eccAnomaly = new VOID_DoubleValue(
"Eccentric Anomaly", "Eccentric Anomaly",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.eccentricAnomaly * 180d / Math.PI), new Func<double>(() => VOID_Core.Instance.vessel.orbit.eccentricAnomaly * 180d / Math.PI),
"°" "°"
); );
   
protected VOID_DoubleValue longitudeAscNode = new VOID_DoubleValue( protected VOID_DoubleValue longitudeAscNode = new VOID_DoubleValue(
"Long. Ascending Node", "Long. Ascending Node",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.LAN), new Func<double>(() => VOID_Core.Instance.vessel.orbit.LAN),
"°" "°"
); );
   
protected VOID_DoubleValue argumentPeriapsis = new VOID_DoubleValue( protected VOID_DoubleValue argumentPeriapsis = new VOID_DoubleValue(
"Argument of Periapsis", "Argument of Periapsis",
new Func<double>(() => VOID_Core.Instance.vessel.orbit.argumentOfPeriapsis), new Func<double>(() => VOID_Core.Instance.vessel.orbit.argumentOfPeriapsis),
"°" "°"
); );
   
protected VOID_DoubleValue localSiderealLongitude = new VOID_DoubleValue( protected VOID_DoubleValue localSiderealLongitude = new VOID_DoubleValue(
"Local Sidereal Longitude", "Local Sidereal Longitude",
new Func<double>(() => Tools.FixDegreeDomain( new Func<double>(() => Tools.FixDegreeDomain(
VOID_Core.Instance.vessel.longitude + VOID_Core.Instance.vessel.orbit.referenceBody.rotationAngle)), VOID_Core.Instance.vessel.longitude + VOID_Core.Instance.vessel.orbit.referenceBody.rotationAngle)),
"°" "°"
); );
   
public VOID_Orbital() public VOID_Orbital()
{ {
this._Name = "Orbital Information"; this._Name = "Orbital Information";
   
this.WindowPos.x = Screen.width - 520f; this.WindowPos.x = Screen.width - 520f;
this.WindowPos.y = 250f; this.WindowPos.y = 250f;
} }
   
public override void ModuleWindow(int _) public override void ModuleWindow(int _)
{ {
base.ModuleWindow (_); base.ModuleWindow (_);
   
int idx = 0; int idx = 0;
   
GUILayout.BeginVertical(); GUILayout.BeginVertical();
   
this.primaryName.DoGUIHorizontal (); this.primaryName.DoGUIHorizontal ();
   
this.precisionValues [idx]= (ushort)this.orbitAltitude.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.orbitAltitude.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.precisionValues [idx]= (ushort)this.orbitVelocity.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.orbitVelocity.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.precisionValues [idx]= (ushort)this.orbitApoAlt.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.orbitApoAlt.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.timeToApo.DoGUIHorizontal(); this.timeToApo.DoGUIHorizontal();
   
this.precisionValues [idx]= (ushort)this.oribtPeriAlt.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.oribtPeriAlt.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.timeToPeri.DoGUIHorizontal(); this.timeToPeri.DoGUIHorizontal();
   
this.orbitInclination.DoGUIHorizontal("F3"); this.orbitInclination.DoGUIHorizontal("F3");
   
this.precisionValues [idx]= (ushort)this.gravityAccel.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.gravityAccel.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.toggleExtended.value = GUILayout.Toggle(this.toggleExtended, "Extended info"); this.toggleExtended.value = GUILayout.Toggle(this.toggleExtended, "Extended info");
   
if (this.toggleExtended) if (this.toggleExtended)
{ {
this.orbitPeriod.DoGUIHorizontal(); this.orbitPeriod.DoGUIHorizontal();
   
this.precisionValues [idx]= (ushort)this.semiMajorAxis.DoGUIHorizontal (this.precisionValues [idx]); this.precisionValues [idx]= (ushort)this.semiMajorAxis.DoGUIHorizontal (this.precisionValues [idx]);
idx++; idx++;
   
this.eccentricity.DoGUIHorizontal("F4"); this.eccentricity.DoGUIHorizontal("F4");
   
this.meanAnomaly.DoGUIHorizontal("F3"); this.meanAnomaly.DoGUIHorizontal("F3");
   
this.trueAnomaly.DoGUIHorizontal("F3"); this.trueAnomaly.DoGUIHorizontal("F3");
   
this.eccAnomaly.DoGUIHorizontal("F3"); this.eccAnomaly.DoGUIHorizontal("F3");
   
this.longitudeAscNode.DoGUIHorizontal("F3"); this.longitudeAscNode.DoGUIHorizontal("F3");
   
this.argumentPeriapsis.DoGUIHorizontal("F3"); this.argumentPeriapsis.DoGUIHorizontal("F3");
   
this.localSiderealLongitude.DoGUIHorizontal("F3"); this.localSiderealLongitude.DoGUIHorizontal("F3");
} }
   
GUILayout.EndVertical(); GUILayout.EndVertical();
GUI.DragWindow(); GUI.DragWindow();
} }
   
public override void LoadConfig () public override void LoadConfig ()
{ {
base.LoadConfig (); base.LoadConfig ();
   
this.precisionValues = new IntCollection (4, this._precisionValues); this.precisionValues = new IntCollection (4, this._precisionValues);
} }
   
public override void _SaveToConfig (KSP.IO.PluginConfiguration config) public override void _SaveToConfig (KSP.IO.PluginConfiguration config)
{ {
this._precisionValues = this.precisionValues.collection; this._precisionValues = this.precisionValues.collection;
   
base._SaveToConfig (config); base._SaveToConfig (config);
} }
} }
} }