Skip to content

Commit

Permalink
Added ability to control the part from EVA'd Kerbal
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxgurugamer committed Dec 17, 2023
1 parent a03d7df commit f327099
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 121 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,6 @@ Taken over by LinuxGurugamer here

1.9.17
Fixed memory leaks in several modules where GameEvents were being used and not released

1.10.0
Added ability to control the part from EVA'd Kerbal
4 changes: 2 additions & 2 deletions GameData/SmartParts/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Klockheed Martian Engine Manufacture - Smart Parts Pack
--------------------------------------------------------------

Visit the official forum thread for more information: http://forum.kerbalspaceprogram.com/threads/64227
Visit the official forum thread for more information: https://forum.kerbalspaceprogram.com/index.php?/topic/151340-14x-smart-parts-continued/


Source: https://github.com/BrettWebb/KerbalSmartParts
Source: https://github.com/linuxgurugamer/KerbalSmartParts

Parts:

Expand Down
4 changes: 2 additions & 2 deletions GameData/SmartParts/SmartParts.version
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"VERSION": {
"MAJOR": 1,
"MINOR": 9,
"PATCH": 17,
"MINOR": 10,
"PATCH": 0,
"BUILD": 0
},
"KSP_VERSION": {
Expand Down
4 changes: 2 additions & 2 deletions SmartParts.version
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"VERSION": {
"MAJOR": 1,
"MINOR": 9,
"PATCH": 17,
"MINOR": 10,
"PATCH": 0,
"BUILD": 0
},
"KSP_VERSION": {
Expand Down
8 changes: 4 additions & 4 deletions SmartParts/Altimeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public class Altimeter : SmartSensorModuleBase
#region Fields


[KSPField(isPersistant = true, guiActive = true, guiName = "Kilometers", guiFormat = "F0", guiUnits = "km"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiName = "Kilometers", guiFormat = "F0", guiUnits = "km"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 0f, maxValue = 1000f, incrementLarge = 100f, incrementSmall = 25f, incrementSlide = 1f)]
public float kilometerHeight = 0;

[KSPField(isPersistant = true, guiActive = true, guiName = "Meters", guiFormat = "F0", guiUnits = "m"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiName = "Meters", guiFormat = "F0", guiUnits = "m"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 0f, maxValue = 1000f, incrementLarge = 100f, incrementSmall = 25f, incrementSlide = 1f)]
public float meterHeight = 0;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
UI_ChooseOption(options = new string[] { "All", "Ascent", "Descent" })]
public string direction = "All";


[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Use AGL"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Use AGL"),
UI_Toggle(disabledText = "False", enabledText = "True")]
public bool useAGL = true;
#endregion
Expand Down
4 changes: 2 additions & 2 deletions SmartParts/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

using System.Reflection;

[assembly: AssemblyVersion("1.9.17.0")]
[assembly: AssemblyFileVersion("1.9.17.0")]
[assembly: AssemblyVersion("1.10.0.0")]
[assembly: AssemblyFileVersion("1.10.0.0")]
6 changes: 3 additions & 3 deletions SmartParts/DPLD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ class DPLD : SmartSensorModuleBase
#region Fields


[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
UI_ChooseOption(options = new string[] { "KSC loss", "Total Loss", "Initialized" })]
//UI_ChooseOption(options = new string[] { "KSC loss", "Total Comm Loss", "Network Initialized" })]
public string actionMode = "KSC loss";


[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Lights On")]
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Lights On", guiActiveUnfocused=true)]
public void doLightsOn()
{
lightsOn();
}
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Lights Off")]
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Lights Off", guiActiveUnfocused = true)]
public void doLightsOff()
{
lightsOff();
Expand Down
4 changes: 2 additions & 2 deletions SmartParts/FuelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace Lib
{
public class FuelController : SmartSensorModuleBase
{
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Flow enabled")]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Flow enabled")]
bool flowEnabled = false;

public override void OnStart(PartModule.StartState state) {
this.part.fuelCrossFeed = flowEnabled;
}

[KSPEvent(guiName = "Toggle Crossfeed", guiActiveEditor = true, guiActive = true)]
[KSPEvent(guiName = "Toggle Crossfeed", guiActiveEditor = true, guiActive = true, guiActiveUnfocused = true)]
public void toggleCrossfeed() {
flowEnabled = !flowEnabled;
this.part.fuelCrossFeed = flowEnabled;
Expand Down
8 changes: 4 additions & 4 deletions SmartParts/ProxSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ class ProxSensor : SmartSensorModuleBase

#region Fields

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Channel"), UI_FloatRange(minValue = 1f, maxValue = 20f, stepIncrement = 1f)]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Channel"), UI_FloatRange(minValue = 1f, maxValue = 20f, stepIncrement = 1f)]
public float channel = 1;

[KSPField(isPersistant = true, guiActiveEditor = true, guiActive = true, guiName = "Distance", guiFormat = "F0", guiUnits = "m"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActiveEditor = true, guiActive = true, guiName = "Distance", guiFormat = "F0", guiUnits = "m"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 0f, maxValue = 2000f, incrementLarge = 250f, incrementSmall = 25f, incrementSlide = 1f)]
public float meterDistance = 0;


[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
UI_ChooseOption(options = new string[] { "Both", "Approach", "Departure" })]
public string direction = "Both";



/* DEBUG CODE
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Get Count")]
[KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Get Count", guiActiveUnfocused=true)]
public void getCount() {
Log.Info("Debug v1");
Log.Info("Current Listener Count");
Expand Down
14 changes: 7 additions & 7 deletions SmartParts/RadioControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ internal static class Channel

public class RadioControl : SmartSensorModuleBase
{
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Sync. Head."),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Sync. Head."),
UI_Toggle(disabledText = "Disabled", enabledText = "Enabled")]
private bool enableSync = false;
private int updateCounter = 0;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Channel"), UI_FloatRange(minValue = 1f, maxValue = 20f, stepIncrement = 1f)]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Channel"), UI_FloatRange(minValue = 1f, maxValue = 20f, stepIncrement = 1f)]
public float channel = 1;


Expand Down Expand Up @@ -153,7 +153,7 @@ public void transmit_Gear(KSPActionParam param)
transmitCommand(16);
}

[KSPEvent(guiName = "Transmit Command", guiActive = true)]
[KSPEvent(guiName = "Transmit Command", guiActive = true, guiActiveUnfocused = true)]
public void transmit_GUI()
{
if (AGXInterface.AGExtInstalled())
Expand All @@ -166,7 +166,7 @@ public void transmit_GUI()
}
}

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Throttle"), UI_FloatRange(minValue = 0f, maxValue = 1f, stepIncrement = 0.05f)]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Throttle"), UI_FloatRange(minValue = 0f, maxValue = 1f, stepIncrement = 0.05f)]
public float throttle = 1;


Expand All @@ -176,7 +176,7 @@ public void transmit_ThrottleAG(KSPActionParam param)
transmitThrottle();
}

[KSPEvent(guiName = "Transmit Throttle", guiActive = true)]
[KSPEvent(guiName = "Transmit Throttle", guiActive = true, guiActiveUnfocused = true)]
public void transmit_Throttle()
{
transmitThrottle();
Expand All @@ -188,7 +188,7 @@ public void transmit_pro_rotationAG(KSPActionParam param)
transmitRotation(this.vessel.GetTransform().rotation, true);
}

[KSPEvent(guiName = "Match Heading", guiActive = true)]
[KSPEvent(guiName = "Match Heading", guiActive = true, guiActiveUnfocused = true)]
public void transmit_pro_rotation()
{
transmitRotation(this.vessel.GetTransform().rotation, true);
Expand All @@ -200,7 +200,7 @@ public void transmit_rotateTowards (KSPActionParam param)
transmitRotationTo (vessel.findWorldCenterOfMass(), true);
}
[KSPEvent(guiName = "Head to vessel", guiActive = true)]
[KSPEvent(guiName = "Head to vessel", guiActive = true, guiActiveUnfocused=true)]
public void transmit_rotateTowardsAG ()
{
transmitRotationTo (vessel.findWorldCenterOfMass(), true);
Expand Down
10 changes: 5 additions & 5 deletions SmartParts/SmartOrbit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ public class SmartOrbit : SmartSensorModuleBase

#region Fields

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Element"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Element"),
UI_ChooseOption(options = new string[] { "Apoapsis", "Periapsis" })]
public string element = "Apoapsis";

[KSPField(isPersistant = false, guiActive = true, guiName = "Altitude", guiFormat = "N3", guiUnits = "km")]
[KSPField(guiActiveUnfocused=true,isPersistant = false, guiActive = true, guiName = "Altitude", guiFormat = "N3", guiUnits = "km")]
private double displayAlt = 0;

[KSPField(isPersistant = true, guiActive = true, guiName = "Kilometers", guiFormat = "F0", guiUnits = "km"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiName = "Kilometers", guiFormat = "F0", guiUnits = "km"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 0f, maxValue = 1000f, incrementLarge = 100f, incrementSmall = 25f, incrementSlide = 1f)]
public float kilometerHeight = 0;

[KSPField(isPersistant = true, guiActive = true, guiName = "Meters", guiFormat = "F0", guiUnits = "m"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiName = "Meters", guiFormat = "F0", guiUnits = "m"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 0f, maxValue = 1000f, incrementLarge = 100f, incrementSmall = 25f, incrementSlide = 1f)]
public float meterHeight = 0;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Trigger on"),
UI_ChooseOption(options = new string[] { "All", "Increasing", "Decreasing" })]
public string direction = "All";

Expand Down
16 changes: 8 additions & 8 deletions SmartParts/SmartSRB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ namespace Lib
{
class SmartSRBBase : SmartSensorModuleBase
{
[KSPField(isPersistant = true, guiActive = true, guiName = "SRB TWR %", guiFormat = "F0", guiUnits = "%"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiName = "SRB TWR %", guiFormat = "F0", guiUnits = "%"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 100f, maxValue = 150f, incrementSlide = 1f)]
public float StagePercentageMass = 100;

[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Trigger on Flameout"), UI_Toggle()]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Trigger on Flameout"), UI_Toggle()]
public bool triggerOnFlameout = true;

[KSPField(isPersistant = false, guiActive = true, guiName = "SRB TWR", guiFormat = "F2")]
[KSPField(guiActiveUnfocused=true,isPersistant = false, guiActive = true, guiName = "SRB TWR", guiFormat = "F2")]
private double displayTWR = 0;

[KSPField(guiActive = false, guiName = "Fire next update")]
[KSPField(guiActiveUnfocused=true,guiActive = false, guiName = "Fire next update")]
private Boolean fireNextupdate = false;

#region Variables
Expand Down Expand Up @@ -287,15 +287,15 @@ void OnDestroy()

class EmbeddedSmartSRB : SmartSRBBase
{
[KSPField(isPersistant = false)]
[KSPField(guiActiveUnfocused=true,isPersistant = false)]
public string guiGroup = "EmbededSmartSRB";
[KSPField(isPersistant = false)]
[KSPField(guiActiveUnfocused=true,isPersistant = false)]
public string guiGroupDisplayName = "Smart SRB";

[KSPField(isPersistant = true)]
[KSPField(guiActiveUnfocused=true,isPersistant = true)]
public bool isResearched = false;

[KSPField(isPersistant = false)]
[KSPField(guiActiveUnfocused=true,isPersistant = false)]
public string researchPartName = "km_smart_srb";

public override void OnStart(StartState state)
Expand Down
10 changes: 5 additions & 5 deletions SmartParts/SmartSensorModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class SmartSensorModuleBase : PartModule


#region Fields
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Group"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Group"),
UI_ChooseOption(
options = new String[] {
"0",
Expand Down Expand Up @@ -67,7 +67,7 @@ public class SmartSensorModuleBase : PartModule
public string group = "0";

//AGXGroup shows if AGX installed and hides Group above
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false, guiName = "Group"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = false, guiActiveEditor = false, guiName = "Group"),
UI_ChooseOption(
options = new String[] {
"0",
Expand All @@ -93,17 +93,17 @@ public class SmartSensorModuleBase : PartModule
public string agxGroupType = "0";

// AGX Action groups, use own slider if selected, only show this field if AGXGroup above is 1
[KSPField(isPersistant = true, guiActiveEditor = false, guiActive = false, guiName = "Group:", guiFormat = "N0"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActiveEditor = false, guiActive = false, guiName = "Group:", guiFormat = "N0"),
UI_FloatEdit(scene = UI_Scene.All, minValue = 1f, maxValue = 250f, incrementLarge = 75f, incrementSmall = 25f, incrementSlide = 1f)]
public float agxGroupNum = 1;

// following not for: RadioControl
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Active"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Active"),
UI_Toggle(disabledText = "False", enabledText = "True")]
public bool isArmed = true;

// following not for: Stager, Timer
[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Auto Reset"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = false, guiName = "Auto Reset"),
UI_Toggle(disabledText = "False", enabledText = "True")]
public bool autoReset = false;
#endregion
Expand Down
24 changes: 12 additions & 12 deletions SmartParts/Speedometer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,42 @@ public class Speedometer : SmartSensorModuleBase
const float HIGH_MAXSPEED = 5000;
#region Fields

[KSPField(isPersistant = true, guiActiveEditor = true, guiActive = true, guiName = "Speed", guiFormat = "F0", guiUnits = "m/s"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActiveEditor = true, guiActive = true, guiName = "Speed", guiFormat = "F0", guiUnits = "m/s"),
UI_FloatEdit(scene = UI_Scene.All, minValue = -LOW_MAXSPEED, maxValue = LOW_MAXSPEED, incrementLarge = 100f, incrementSmall = 10f, incrementSlide = 1f)]
public float meterPerSecondSpeed = 0;

[KSPField(isPersistant = true, guiActiveEditor = false, guiActive = false, guiName = "Speed", guiFormat = "F0", guiUnits = "m/s"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActiveEditor = false, guiActive = false, guiName = "Speed", guiFormat = "F0", guiUnits = "m/s"),
UI_FloatEdit(scene = UI_Scene.All, minValue = -HIGH_MAXSPEED, maxValue = HIGH_MAXSPEED, incrementLarge = 500f, incrementSmall = 50f, incrementSlide = 5f)]
public float meterPerSecondSpeedHigh = 0;

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Trigger on"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Trigger on"),
UI_ChooseOption(options = new string[] { "All", "Increasing", "Decreasing" })]
public string direction = "All";

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Speed mode"),
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Speed mode"),
UI_ChooseOption(options = new string[] { "Surface", "Horizontal", "Vertical", "Orbital" })]
public string speedMode = "Surface";

[KSPField(guiActive = true, guiName = "Speed")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Speed")]
public double speed = 0;
[KSPField(guiActive = true, guiName = "Last speed")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Last speed")]
private double lastSpeed = 0;

[KSPField(guiActive = true, guiName = "Speed increasing")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Speed increasing")]
private Boolean isSpeedIncreasing = false;

[KSPField(guiActive = true, guiName = "Passing threshold")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Passing threshold")]
private Boolean isPassingThreshold = false;

[KSPField(guiActive = true, guiName = "Fire next update")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Fire next update")]
private Boolean fireNextupdate = false;

[KSPField(guiActive = true, guiName = "Group last update")]
[KSPField(guiActiveUnfocused=true,guiActive = true, guiName = "Group last update")]
private string groupLastUpdate = "0";

#endregion
#region Events
[KSPEvent(guiName = "Toggle max speed", guiActiveEditor = true)]
[KSPEvent(guiName = "Toggle max speed", guiActiveEditor = true, guiActiveUnfocused = true)]
public void doToggleMaxSpeed()
{
maxSpeedLow = !maxSpeedLow;
Expand All @@ -72,7 +72,7 @@ void UpdateToggleMaxSpeedgui()
Events["doToggleMaxSpeed"].guiName = "Toggle max speed (currently: " + HIGH_MAXSPEED + ")";
}

[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false, guiName = "Active")]
[KSPField(guiActiveUnfocused=true,isPersistant = true, guiActive = false, guiActiveEditor = false, guiName = "Active")]
bool maxSpeedLow = true;

[KSPAction("Activate Detection")]
Expand Down
Loading

0 comments on commit f327099

Please sign in to comment.