Skip to content

Commit

Permalink
Merge pull request #310 from MOARdV/master
Browse files Browse the repository at this point in the history
Changes for v0.21.2
  • Loading branch information
MOARdV committed Jul 20, 2015
2 parents 833b366 + 2c75bdd commit d7a43fe
Show file tree
Hide file tree
Showing 22 changed files with 577 additions and 203 deletions.
4 changes: 4 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Frequently Asked Questions about RasterPropMonitor

### Can you make RPM work outside the command pod / on pop-up screens?

No. RasterPropMonitor was designed to provide an interactive IVA experience. It can not be used to run "monitors" placed outside the craft, and it can not be used to draw on windows/overlays either. There are no plans to change that. The license for RPM is very open, so if someone wants to use RPM as a basis to make something similar for outside-of-IVA use, they're more than welcome to try.

### Where is the IVA for X?

RasterPropMonitor is intended to be a toolkit for IVA makers. It includes updated IVAs for most Squad pods, as well as a handful of other pods, but most of those IVAs were included to demonstrate some of the RPM features. If your favorite / preferred / currently-being-used IVA does not have an RPM-enhanced version, it's probably because no one has offered to share one that can be included in RPM. The developers of RPM have to prioritize their time, and maintaining and expanding the features of the plugin will almost always take priority over creating new IVAs.
Expand Down
2 changes: 1 addition & 1 deletion GameData/JSI/RPMPodPatches/BasicMFD/pa_HUDPFD.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

PRS: {1:SIP8}Pa ASL: {0:SIP6}m $&$ ALTITUDE DYNAMICPRESSURE
PRS: {1,7:0.000}kPa ASL: {0:SIP6}m $&$ ALTITUDE DYNAMICPRESSURE
ATM: {0,5:00.0%} TER: {1:SIP6}m $&$ ATMOSPHEREDEPTH TERRAINHEIGHT
[@y-3][@x2]{0,6:000.0}° $&$ HEADING
[@y4] [hw]{0:SIP6}m/s[/hw] [hw]{1:SIP6}m[/hw] $&$ VERTSPEED RADARALTOCEAN
Expand Down
2 changes: 1 addition & 1 deletion GameData/JSI/RasterPropMonitor/RasterPropMonitor.version
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"VERSION": {
"MAJOR": 0,
"MINOR": 21,
"PATCH": 1
"PATCH": 2
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion RasterPropMonitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Global
$36.inheritsSet = Mono
$36.inheritsScope = text/plain
$36.scope = text/plain
version = 0.21.1
version = 0.21.2
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 5 additions & 4 deletions RasterPropMonitor/Auxiliary modules/JSIActionGroupSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class JSIActionGroupSwitch : InternalModule
public bool initialState = false;
[KSPField]
public int switchGroupIdentifier = -1;
[KSPField]
public int refreshRate = 60;
// Neater.
private static readonly Dictionary<string, KSPActionGroup> groupList = new Dictionary<string, KSPActionGroup> {
{ "gear",KSPActionGroup.Gear },
Expand Down Expand Up @@ -88,7 +90,6 @@ public class JSIActionGroupSwitch : InternalModule
private string persistentVarName;
private Light[] lightObjects;
private FXGroup audioOutput;
private const int lightCheckRate = 60;
private int lightCheckCountdown;
private RasterPropMonitorComputer comp;
private bool startupComplete;
Expand Down Expand Up @@ -211,7 +212,7 @@ public void Start()
case "plugin":
persistentVarName = string.Empty;
comp = RasterPropMonitorComputer.Instantiate(internalProp);
comp.UpdateRefreshRates(lightCheckRate, lightCheckRate);
comp.UpdateDataRefreshRate(refreshRate);

foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("PROP"))
{
Expand Down Expand Up @@ -268,7 +269,7 @@ public void Start()
if (comp == null)
{
comp = RasterPropMonitorComputer.Instantiate(internalProp);
comp.UpdateRefreshRates(lightCheckRate, lightCheckRate);
comp.UpdateDataRefreshRate(refreshRate);
}

if (!string.IsNullOrEmpty(masterVariableName))
Expand Down Expand Up @@ -569,7 +570,7 @@ public override void OnUpdate()
lightCheckCountdown--;
if (lightCheckCountdown <= 0)
{
lightCheckCountdown = lightCheckRate;
lightCheckCountdown = refreshRate;
forcedShutdown |= currentState && comp.ProcessVariable("SYSR_ELECTRICCHARGE", -1).MassageToDouble() < 0.01d;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Start()
{
if (needsElectricCharge) {
comp = RasterPropMonitorComputer.Instantiate(internalProp);
comp.UpdateRefreshRates(soundCheckRate, soundCheckRate);
comp.UpdateDataRefreshRate(soundCheckRate);
electricChargeReserve = (double)comp.ProcessVariable("SYSR_ELECTRICCHARGE", -1);
}
audioOutput = new FXGroup("RPM" + internalModel.internalName + vessel.id);
Expand Down
52 changes: 30 additions & 22 deletions RasterPropMonitor/Auxiliary modules/JSIPropTextureShift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,41 @@

namespace JSI
{
public class JSIPropTextureShift: InternalModule
{
[KSPField]
public string transformToShift = "";
[KSPField]
public string layerToShift = "_MainTex";
[KSPField]
public float x;
[KSPField]
public float y;
public class JSIPropTextureShift : InternalModule
{
[KSPField]
public string transformToShift = "";
[KSPField]
public string layerToShift = "_MainTex";
[KSPField]
public float x;
[KSPField]
public float y;

public void Start()
{
var shiftval = new Vector2(x, y);
Material shifted = internalProp.FindModelTransform(transformToShift).renderer.material;
if (shifted != null)
public void Start()
{
var shiftval = new Vector2(x, y);

Transform xform = internalProp.FindModelTransform(transformToShift);
if (xform.renderer != null && xform.renderer.material != null)
{
foreach (string layer in layerToShift.Split())
// MOARdV TODO: Accessing and changing .material causes it to
// become a copy, according to Unity. Must destroy it. Which
// means this method can't self-destruct; it must use OnDestroy.
Material shifted = xform.renderer.material;
if (shifted != null)
{
shifted.SetTextureOffset(layer, shiftval + shifted.GetTextureOffset(layer));
foreach (string layer in layerToShift.Split())
{
shifted.SetTextureOffset(layer, shiftval + shifted.GetTextureOffset(layer));
}
}
else
{
JUtil.LogErrorMessage(this, "Unable to find transform {0} to shift in prop {1}", transformToShift, internalProp.propName);
}
}
else
{
JUtil.LogErrorMessage(this, "Unable to find transform {0} to shift in prop {1}", transformToShift, internalProp.propName);
}
Destroy(this);
}
}
}
}
2 changes: 2 additions & 0 deletions RasterPropMonitor/Auxiliary modules/JSIVariableAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void Start()
{
alwaysActive |= thatSet.alwaysActive;
}
RasterPropMonitorComputer comp = RasterPropMonitorComputer.Instantiate(internalProp);
comp.UpdateDataRefreshRate(refreshRate);
startupComplete = true;
}
catch
Expand Down
103 changes: 54 additions & 49 deletions RasterPropMonitor/Auxiliary modules/JSIVariableLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,63 @@

namespace JSI
{
public class JSIVariableLabel: InternalModule
{
[KSPField]
public string labelText = "<=0=>$&$ALTITUDE";
[KSPField]
public string transformName;
[KSPField]
public float fontSize = 0.008f;
[KSPField]
public int refreshRate = 10;
[KSPField]
public bool oneshot;
private bool oneshotComplete;
private InternalText textObj;
private Transform textObjTransform;
private RasterPropMonitorComputer comp;
private int updateCountdown;
// Annoying as it is, that is the only font actually available to InternalComponents for some bizarre reason,
// even though I'm pretty sure there are quite a few other fonts in there.
private const string fontName = "Arial";
private string sourceString;
public class JSIVariableLabel : InternalModule
{
[KSPField]
public string labelText = "<=0=>$&$ALTITUDE";
[KSPField]
public string transformName;
[KSPField]
public float fontSize = 0.008f;
[KSPField]
public int refreshRate = 10;
[KSPField]
public bool oneshot;
private bool oneshotComplete;
private InternalText textObj;
private Transform textObjTransform;
private RasterPropMonitorComputer comp;
private int updateCountdown;
// Annoying as it is, that is the only font actually available to InternalComponents for some bizarre reason,
// even though I'm pretty sure there are quite a few other fonts in there.
private const string fontName = "Arial";
private string sourceString;

public void Start()
{
comp = RasterPropMonitorComputer.Instantiate(internalProp);
textObjTransform = internalProp.FindModelTransform(transformName);
textObj = InternalComponents.Instance.CreateText(fontName, fontSize, textObjTransform, string.Empty);
// Force oneshot if there's no variables:
oneshot |= !labelText.Contains("$&$");
sourceString = labelText.UnMangleConfigText();
}
public void Start()
{
comp = RasterPropMonitorComputer.Instantiate(internalProp);
textObjTransform = internalProp.FindModelTransform(transformName);
textObj = InternalComponents.Instance.CreateText(fontName, fontSize, textObjTransform, string.Empty);
// Force oneshot if there's no variables:
oneshot |= !labelText.Contains("$&$");
sourceString = labelText.UnMangleConfigText();
if (!oneshot)
{
comp.UpdateDataRefreshRate(refreshRate);
}
}

private bool UpdateCheck()
{
if (updateCountdown <= 0) {
updateCountdown = refreshRate;
return true;
}
updateCountdown--;
return false;
}
private bool UpdateCheck()
{
if (updateCountdown <= 0)
{
updateCountdown = refreshRate;
return true;
}
updateCountdown--;
return false;
}

public override void OnUpdate()
{
if (oneshotComplete && oneshot)
return;
if (!JUtil.VesselIsInIVA(vessel) || !UpdateCheck())
return;
public override void OnUpdate()
{
if (oneshotComplete && oneshot)
return;
if (!JUtil.VesselIsInIVA(vessel) || !UpdateCheck())
return;

textObj.text.Text = StringProcessor.ProcessString(sourceString, comp, internalProp.propID);
oneshotComplete = true;
}
}
textObj.text.Text = StringProcessor.ProcessString(sourceString, comp, internalProp.propID);
oneshotComplete = true;
}
}
}

Loading

0 comments on commit d7a43fe

Please sign in to comment.