diff --git a/InfernalRobotics/InfernalRobotics/Control/Servo/MechanismBase.cs b/InfernalRobotics/InfernalRobotics/Control/Servo/MechanismBase.cs index aa3dc8b2..5617a127 100644 --- a/InfernalRobotics/InfernalRobotics/Control/Servo/MechanismBase.cs +++ b/InfernalRobotics/InfernalRobotics/Control/Servo/MechanismBase.cs @@ -84,7 +84,10 @@ public float AccelerationLimit public bool IsAxisInverted { get { return rawServo.invertAxis; } - set { rawServo.invertAxis = value; } + set { + rawServo.invertAxis = value; + rawServo.Events["InvertAxisToggle"].guiName = rawServo.invertAxis ? "Un-invert Axis" : "Invert Axis"; + } } public abstract float DefaultSpeed { get; } diff --git a/InfernalRobotics/InfernalRobotics/Control/Servo/ServoInput.cs b/InfernalRobotics/InfernalRobotics/Control/Servo/ServoInput.cs index d214fd9e..323117b9 100644 --- a/InfernalRobotics/InfernalRobotics/Control/Servo/ServoInput.cs +++ b/InfernalRobotics/InfernalRobotics/Control/Servo/ServoInput.cs @@ -14,13 +14,21 @@ public ServoInput(MuMechToggle rawServo) public string Forward { get { return rawServo.forwardKey; } - set { rawServo.forwardKey = value; } + set + { + rawServo.forwardKey = value.ToLower(); + rawServo.rotateKey = rawServo.translateKey = rawServo.forwardKey; + } } public string Reverse { get { return rawServo.reverseKey; } - set { rawServo.reverseKey = value; } + set + { + rawServo.reverseKey = value.ToLower(); + rawServo.revRotateKey = rawServo.revTranslateKey = rawServo.reverseKey; + } } } } \ No newline at end of file diff --git a/InfernalRobotics/InfernalRobotics/Gui/ControlsGUI.cs b/InfernalRobotics/InfernalRobotics/Gui/ControlsGUI.cs index ff93ffb7..c776e164 100644 --- a/InfernalRobotics/InfernalRobotics/Gui/ControlsGUI.cs +++ b/InfernalRobotics/InfernalRobotics/Gui/ControlsGUI.cs @@ -403,8 +403,9 @@ private void ControlWindow(int windowID) servo.Preset.MovePrev(); } SetTooltipText(); + var rowHeight = GUILayout.Height(BUTTON_HEIGHT); - ShowPresets(associatedServo, buttonStyle,rowHeight); + ShowPresets(servo, buttonStyle, rowHeight); SetTooltipText(); if (GUILayout.Button(new GUIContent(TextureLoader.NextIcon, "Next Preset"), buttonStyle, GUILayout.Width(22), GUILayout.Height(BUTTON_HEIGHT))) @@ -828,18 +829,28 @@ private void EditorWindow(int windowID) } GUILayout.Label("Spd: ", GUILayout.Width(30), rowHeight); - tmpMin = GUILayout.TextField(string.Format("{0:#0.0##}", servo.Mechanism.SpeedLimit), GUILayout.Width(40), rowHeight); + tmpMin = GUILayout.TextField(string.Format("{0:#0.0##}", servo.Mechanism.SpeedLimit), GUILayout.Width(30), rowHeight); if (float.TryParse(tmpMin, out tmpValue)) { servo.Mechanism.SpeedLimit = tmpValue; } GUILayout.Label("Acc: ", GUILayout.Width(30), rowHeight); - tmpMin = GUILayout.TextField(string.Format("{0:#0.0##}", servo.Mechanism.AccelerationLimit), GUILayout.Width(40), rowHeight); + tmpMin = GUILayout.TextField(string.Format("{0:#0.0##}", servo.Mechanism.AccelerationLimit), GUILayout.Width(30), rowHeight); if (float.TryParse(tmpMin, out tmpValue)) { servo.Mechanism.AccelerationLimit = tmpValue; } + + bool servoInverted = servo.Mechanism.IsAxisInverted; + + servoInverted = GUILayout.Toggle(servoInverted, + servoInverted ? new GUIContent(TextureLoader.InvertedIcon, "Un-invert Axis") : new GUIContent(TextureLoader.NoninvertedIcon, "Invert Axis"), + buttonStyle, GUILayout.Width(28), rowHeight); + + SetTooltipText(); + servo.Mechanism.IsAxisInverted = servoInverted; + } if (isEditor) diff --git a/InfernalRobotics/InfernalRobotics/Module/MuMechToggle.cs b/InfernalRobotics/InfernalRobotics/Module/MuMechToggle.cs index 698b7179..67dfa2c3 100644 --- a/InfernalRobotics/InfernalRobotics/Module/MuMechToggle.cs +++ b/InfernalRobotics/InfernalRobotics/Module/MuMechToggle.cs @@ -25,30 +25,14 @@ public class MuMechToggle : PartModule [KSPField(isPersistant = true)] public float customSpeed = 1; [KSPField(isPersistant = true)] - public string forwardKey - { - get { return forwardKeyStore; } - set - { - forwardKeyStore = value.ToLower(); - rotateKey = translateKey = forwardKey; - } - } - + public string forwardKey; + [KSPField(isPersistant = true)] public bool freeMoving = false; [KSPField(isPersistant = true)] public string groupName = ""; [KSPField(isPersistant = true)] - public bool invertAxis - { - get { return invertAxisStore; } - set - { - invertAxisStore = value; - Events["InvertAxisToggle"].guiName = invertAxis ? "Invert Axis is On" : "Invert Axis is Off"; - TweakIsDirty = true; - } - } + public bool invertAxis; + [KSPField(isPersistant = true)] public bool isMotionLock; [KSPField(isPersistant = true)] public bool limitTweakable = false; [KSPField(isPersistant = true)] public bool limitTweakableFlag = false; @@ -68,28 +52,16 @@ public bool invertAxis public float soundSet = .5f; [KSPField(isPersistant = true)] - public string revRotateKey - { - get { return reverseRotateKeyStore; } - set { reverseRotateKeyStore = value.ToLower(); } - } - + public string revRotateKey; + [KSPField(isPersistant = true)] - public string reverseKey - { - get { return reverseKeyStore; } - set - { - reverseKeyStore = value.ToLower(); - revRotateKey = revTranslateKey = reverseKey; - } - } + public string reverseKey; [KSPField(isPersistant = true)] public string rotateKey = ""; [KSPField(isPersistant = true)] public bool rotateLimits = false; [KSPField(isPersistant = true)] public float rotateMax = 360; [KSPField(isPersistant = true)] public float rotateMin = 0; - [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Rotation:")] public float rotation = 0; + [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Rotation")] public float rotation = 0; [KSPField(isPersistant = false, guiActive = false, guiActiveEditor = false)] public float rotationDelta = 0; [KSPField(isPersistant = true)] public string servoName = ""; @@ -97,7 +69,7 @@ public string reverseKey UI_FloatEdit(minValue = 0f, incrementSlide = 0.05f, incrementSmall=0.5f, incrementLarge=1f)] public float speedTweak = 1f; - [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Accel", guiFormat = "0.00"), + [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Acceleration", guiFormat = "0.00"), UI_FloatEdit(minValue = 0.05f, incrementSlide = 0.05f, incrementSmall=0.5f, incrementLarge=1f)] public float accelTweak = 4f; @@ -151,11 +123,7 @@ public string reverseKey [KSPField(isPersistant = false)] public string translateModel = "on"; private SoundSource motorSound; - private string reverseKeyStore; - private string reverseRotateKeyStore; - private string forwardKeyStore; - private bool invertAxisStore; - + public MuMechToggle() { Interpolator = new Interpolator(); @@ -234,13 +202,13 @@ private Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) return myAssembly; } - [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Rotate Limits are Off", active = false)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Engage Limits", active = false)] public void LimitTweakableToggle() { if (!rotateJoint) return; limitTweakableFlag = !limitTweakableFlag; - Events["LimitTweakableToggle"].guiName = limitTweakableFlag ? "Rotate Limits are On" : "Rotate Limits are Off"; + Events["LimitTweakableToggle"].guiName = limitTweakableFlag ? "Disengage Limits" : "Engage Limits"; if (limitTweakableFlag) { @@ -258,10 +226,11 @@ public void LimitTweakableToggle() TweakIsDirty = true; } - [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Invert Axis is Off")] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "Invert Axis")] public void InvertAxisToggle() { invertAxis = !invertAxis; + Events["InvertAxisToggle"].guiName = invertAxis ? "Un-invert Axis" : "Invert Axis"; } public bool IsSymmMaster() @@ -409,7 +378,7 @@ public override void OnAwake() { minTweak = translateMin; maxTweak = translateMax; - + Events["LimitTweakableToggle"].active = false; Fields["rotation"].guiActive = false; @@ -541,7 +510,7 @@ private void SetupMinMaxTweaks() ((UI_FloatEdit)Fields["minTweak"].uiControlFlight).incrementSlide = GetStepIncrement(); ((UI_FloatEdit)Fields["maxTweak"].uiControlFlight).incrementSlide = GetStepIncrement(); } - bool showTweakables = (limitTweakableFlag && !freeMoving); + bool showTweakables = (translateJoint || (limitTweakableFlag && !freeMoving)); Fields["minTweak"].guiActive = showTweakables; Fields["minTweak"].guiActiveEditor = showTweakables; Fields["maxTweak"].guiActive = showTweakables;