Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
erendrake committed Apr 5, 2015
2 parents 9f34102 + 8877d7f commit 1d36164
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
12 changes: 10 additions & 2 deletions InfernalRobotics/InfernalRobotics/Control/Servo/ServoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
17 changes: 14 additions & 3 deletions InfernalRobotics/InfernalRobotics/Gui/ControlsGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down
63 changes: 16 additions & 47 deletions InfernalRobotics/InfernalRobotics/Module/MuMechToggle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -68,36 +52,24 @@ 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 = "";

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Speed", guiFormat = "0.00"),
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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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()
Expand Down Expand Up @@ -409,7 +378,7 @@ public override void OnAwake()
{
minTweak = translateMin;
maxTweak = translateMax;

Events["LimitTweakableToggle"].active = false;

Fields["rotation"].guiActive = false;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1d36164

Please sign in to comment.