Skip to content

Commit

Permalink
Merge pull request #571 from MOARdV/master
Browse files Browse the repository at this point in the history
RPM v0.27.0 release
  • Loading branch information
MOARdV authored Jun 23, 2016
2 parents fa9c57d + 76ec1e4 commit ca53362
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 28 deletions.
6 changes: 3 additions & 3 deletions GameData/JSI/RasterPropMonitor/RasterPropMonitor.version
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"DOWNLOAD": "https://github.com/Mihara/RasterPropMonitor/releases",
"VERSION": {
"MAJOR": 0,
"MINOR": 26,
"MINOR": 27,
"PATCH": 0
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 1,
"PATCH": 2
"PATCH": 3
},
"KSP_VERSION_MIN":
{
"MAJOR": 1,
"MINOR": 1,
"PATCH": 2
"PATCH": 3
},
}
1 change: 1 addition & 0 deletions RasterPropMonitor/Core/RPMGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace JSI
/// </summary>
internal static class RPMGlobals
{
internal static readonly string configFileName = "GameData/JSI/RasterPropMonitor/Plugins/PluginData/rpm-config.cfg";
internal const float KelvinToCelsius = -273.15f;
internal const float MetersToFeet = 3.2808399f;
internal const float MetersPerSecondToKnots = 1.94384449f;
Expand Down
51 changes: 30 additions & 21 deletions RasterPropMonitor/Core/UtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public static void ReseatKerbalInPart(this Kerbal thatKerbal) {
public static bool ActiveKerbalIsLocal(this Part thisPart)
{
Kerbal thatKerbal = CameraManager.Instance.IVACameraActiveKerbal;
if(thatKerbal != null)
if (thatKerbal != null)
{
return thatKerbal.InPart == thisPart;
}
Expand Down Expand Up @@ -470,7 +470,7 @@ public static int CurrentActiveSeat(this Part thisPart)
public static Kerbal FindCurrentKerbal(this Part thisPart)
{
Kerbal activeKerbal = CameraManager.Instance.IVACameraActiveKerbal;
if(activeKerbal != null)
if (activeKerbal != null)
{
return (activeKerbal.InPart == thisPart) ? activeKerbal : null;
}
Expand Down Expand Up @@ -587,9 +587,9 @@ public static void AnnoyUser(object caller)
public static JSIFlashModule InstallFlashModule(Part part, float flashRate)
{
JSIFlashModule[] loadedModules = part.GetComponents<JSIFlashModule>();
for(int i=0; i<loadedModules.Length; ++i)
for (int i = 0; i < loadedModules.Length; ++i)
{
if(loadedModules[i].flashRate == flashRate)
if (loadedModules[i].flashRate == flashRate)
{
return loadedModules[i];
}
Expand Down Expand Up @@ -1372,12 +1372,12 @@ public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
/// <returns>The complex variable, or null</returns>
internal static IComplexVariable InstantiateComplexVariable(ConfigNode node, RasterPropMonitorComputer rpmComp)
{
if(node == null)
if (node == null)
{
throw new ArgumentNullException("node was null. how did that happen?");
}

switch(node.name)
switch (node.name)
{
case "RPM_CUSTOM_VARIABLE":
return new CustomVariable(node, rpmComp);
Expand All @@ -1389,7 +1389,7 @@ internal static IComplexVariable InstantiateComplexVariable(ConfigNode node, Ras
return new SelectVariable(node, rpmComp);
}

throw new ArgumentException("Unrecognized complex variable "+node.name);
throw new ArgumentException("Unrecognized complex variable " + node.name);
}

/// <summary>
Expand Down Expand Up @@ -1705,12 +1705,21 @@ private void Awake()
throw new Exception("RPMShaderLoader: GameDatabase is not ready. Unable to continue.");
}

var rpmSettings = GameDatabase.Instance.GetConfigNodes("RasterPropMonitorSettings");
if (rpmSettings.Length > 0)
ConfigNode rpmSettings = ConfigNode.Load(KSPUtil.ApplicationRootPath + RPMGlobals.configFileName);
// rpmSettings points at the base node. I need to step into that node to access my settings.
if (rpmSettings != null && rpmSettings.CountNodes > 0)
{
rpmSettings = rpmSettings.GetNode("RasterPropMonitorSettings");
}
else
{
rpmSettings = null;
}

if (rpmSettings != null)
{
// Really, there should be only one
bool enableLogging = false;
if (rpmSettings[0].TryGetValue("DebugLogging", ref enableLogging))
if (rpmSettings.TryGetValue("DebugLogging", ref enableLogging))
{
RPMGlobals.debugLoggingEnabled = enableLogging;
JUtil.LogInfo(this, "Set debugLoggingEnabled to {0}", enableLogging);
Expand All @@ -1721,7 +1730,7 @@ private void Awake()
}

bool showVariableCallCount = false;
if (rpmSettings[0].TryGetValue("ShowCallCount", ref showVariableCallCount))
if (rpmSettings.TryGetValue("ShowCallCount", ref showVariableCallCount))
{
// call count doesn't write anything if enableLogging is false
RPMGlobals.debugShowVariableCallCount = showVariableCallCount && RPMGlobals.debugLoggingEnabled;
Expand All @@ -1732,23 +1741,23 @@ private void Awake()
}

int defaultRefresh = RPMGlobals.defaultRefreshRate;
if (rpmSettings[0].TryGetValue("DefaultRefreshRate", ref defaultRefresh))
if (rpmSettings.TryGetValue("DefaultRefreshRate", ref defaultRefresh))
{
RPMGlobals.defaultRefreshRate = Math.Max(defaultRefresh, 1);
}

int minRefresh = RPMGlobals.minimumRefreshRate;
if (rpmSettings[0].TryGetValue("MinimumRefreshRate", ref minRefresh))
if (rpmSettings.TryGetValue("MinimumRefreshRate", ref minRefresh))
{
RPMGlobals.minimumRefreshRate = Math.Max(minRefresh, 1);
}

RPMGlobals.debugShowOnly.Clear();
string showOnlyConcat = string.Empty;
if (rpmSettings[0].TryGetValue("ShowOnly", ref showOnlyConcat) && !string.IsNullOrEmpty(showOnlyConcat))
if (rpmSettings.TryGetValue("ShowOnly", ref showOnlyConcat) && !string.IsNullOrEmpty(showOnlyConcat))
{
string[] showOnly = showOnlyConcat.Split('|');
for(int i=0; i<showOnly.Length; ++i)
for (int i = 0; i < showOnly.Length; ++i)
{
RPMGlobals.debugShowOnly.Add(showOnly[i].Trim());
}
Expand Down Expand Up @@ -1784,11 +1793,11 @@ private IEnumerator LoadRasterPropMonitorValues()
{
JUtil.LogMessage(this, "CelestialBody {0} is index {1}", bodies[i].bodyName, bodies[i].flightGlobalsIndex);
}

RPMGlobals.customVariables.Clear();

ConfigNode[] nodes = GameDatabase.Instance.GetConfigNodes("RPM_CUSTOM_VARIABLE");
for (int i=0; i<nodes.Length; ++i)
for (int i = 0; i < nodes.Length; ++i)
{

try
Expand Down Expand Up @@ -2066,14 +2075,14 @@ private bool RegisterWithModuleManager()
.SelectMany(t => t)
.FirstOrDefault(t => t.FullName == "ModuleManager.MMPatchLoader");

if(mmPatchLoader == null)
if (mmPatchLoader == null)
{
return false;
}

MethodInfo addPostPatchCallback = mmPatchLoader.GetMethod("addPostPatchCallback", BindingFlags.Static | BindingFlags.Public);

if(addPostPatchCallback == null)
if (addPostPatchCallback == null)
{
return false;
}
Expand All @@ -2092,7 +2101,7 @@ private bool RegisterWithModuleManager()

addPostPatchCallback.Invoke(null, args);
}
catch(Exception e)
catch (Exception e)
{
JUtil.LogMessage(this, "addPostPatchCallback threw {0}", e);
return false;
Expand Down
2 changes: 1 addition & 1 deletion RasterPropMonitor/Handlers/JSIMechJeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ private void UpdateDeltaVStats(object activeJeb)
{
object stagestats = GetComputerModule(activeJeb, "MechJebModuleStageStats");

requestUpdate(stagestats, new object[] { this });
requestUpdate(stagestats, new object[] { this, false });

int atmStatsLength = 0, vacStatsLength = 0;

Expand Down
8 changes: 5 additions & 3 deletions RasterPropMonitor/Handlers/JSIPrimaryFlightDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public bool RenderPFD(RenderTexture screen, float aspect)
Vector3 velocityVesselOrbitUnit = comp.Prograde;
Vector3 radialPlus = comp.RadialOut;
Vector3 normalPlus = comp.NormalPlus;
// stockNavBall.relativeGymbal * (stockNavBall.progradeVector.localRotation * stockNavBall.progradeVector.right == gymbal * velocityVesselOrbitUnit
// But... Same is true for stockNavBall.normalVector and stockNavBall.radialOutVector

MoveMarker(markerPrograde, velocityVesselOrbitUnit, gymbal);
MoveMarker(markerRetrograde, -velocityVesselOrbitUnit, gymbal);
Expand Down Expand Up @@ -434,9 +436,9 @@ public void Start()
{
stockNavBall = UnityEngine.Object.FindObjectOfType<KSP.UI.Screens.Flight.NavBall>();
}
catch(Exception e)
catch (Exception e)
{
JUtil.LogErrorMessage(this, "Unable to fetch the NavBall object: {0}",e);
JUtil.LogErrorMessage(this, "Unable to fetch the NavBall object: {0}", e);
// Set up a bogus one so there's no null derefs.
stockNavBall = new NavBall();
}
Expand All @@ -461,7 +463,7 @@ public void Start()
ballCamera.transform.LookAt(navBallPosition, Vector3.up);

navBall = GameDatabase.Instance.GetModel(navBallModel.EnforceSlashes());
if(navBall == null)
if (navBall == null)
{
JUtil.LogErrorMessage(this, "Failed to load navball model {0}", navBallModel);
// Early return here - if we don't even have a navball, this module is pointless.
Expand Down

0 comments on commit ca53362

Please sign in to comment.