Skip to content

Commit

Permalink
Merge remote-tracking branch 'Peppie23/stack_lock' into 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erendrake committed Jan 10, 2015
2 parents aa06836 + 2f462a0 commit 25df2d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
32 changes: 32 additions & 0 deletions src/RemoteTech/UI/AbstractWindow.cs
Expand Up @@ -93,6 +93,7 @@ private void OnShowUI()

public virtual void Hide()
{
removeWindowCtrlLock();
Windows.Remove(mGuid);
Enabled = false;
if (mSavePosition)
Expand Down Expand Up @@ -185,6 +186,16 @@ public virtual void Draw()
onPositionChanged.Invoke();
backupPosition = Position;
}

// Set ship control lock if one rt input is in focus
if (GUI.GetNameOfFocusedControl().StartsWith("rt_"))
{
setWindowCtrlLock();
}
else
{
removeWindowCtrlLock();
}
}
}

Expand All @@ -193,5 +204,26 @@ private void storePosition()
RTSettings.Instance.savedWindowPositions.Remove(this.GetType().ToString());
RTSettings.Instance.savedWindowPositions.Add(this.GetType().ToString(), Position);
}

/// <summary>
/// Set a input lock to keep typing to this window
/// </summary>
public void setWindowCtrlLock()
{
// only if we are enabled
if (Enabled)
{
InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "RTLockControlForWindows");
}
}


/// <summary>
/// Remove the input lock
/// </summary>
public void removeWindowCtrlLock()
{
InputLockManager.RemoveControlLock("RTLockControlForWindows");
}
}
}
12 changes: 6 additions & 6 deletions src/RemoteTech/UI/AttitudeFragment.cs
Expand Up @@ -106,7 +106,7 @@ public void Draw()
float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f;
if (Event.current.Equals(Event.KeyboardEvent("return")))
{
if (GUI.GetNameOfFocusedControl().StartsWith("phr"))
if (GUI.GetNameOfFocusedControl().StartsWith("rt_phr"))
{
mPitch = Pitch.ToString();
mHeading = Heading.ToString();
Expand All @@ -117,7 +117,7 @@ public void Draw()
Confirm();
}
}
else if (GUI.GetNameOfFocusedControl() == "burn")
else if (GUI.GetNameOfFocusedControl() == "rt_burn")
{
OnBurnClick();
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public void Draw()
GUILayout.Label(new GUIContent("PIT:", "Sets pitch."), GUILayout.Width(width3));
RTUtil.Button("+", () => Pitch++);
RTUtil.Button("-", () => Pitch--);
GUI.SetNextControlName("phr1");
GUI.SetNextControlName("rt_phr1");
RTUtil.TextField(ref mPitch, GUILayout.Width(width3));
}
GUILayout.EndHorizontal();
Expand All @@ -173,7 +173,7 @@ public void Draw()
GUILayout.Label(new GUIContent("HDG:", "Sets heading."), GUILayout.Width(width3));
RTUtil.Button("+", () => Heading++);
RTUtil.Button("-", () => Heading--);
GUI.SetNextControlName("phr2");
GUI.SetNextControlName("rt_phr2");
RTUtil.TextField(ref mHeading, GUILayout.Width(width3));
}
GUILayout.EndHorizontal();
Expand All @@ -183,7 +183,7 @@ public void Draw()
GUILayout.Label(new GUIContent("RLL:", "Sets roll."), GUILayout.Width(width3));
RTUtil.Button("+", () => Roll++);
RTUtil.Button("-", () => Roll--);
GUI.SetNextControlName("phr3");
GUI.SetNextControlName("rt_phr3");
RTUtil.TextField(ref mRoll, GUILayout.Width(width3));
}
GUILayout.EndHorizontal();
Expand All @@ -197,7 +197,7 @@ public void Draw()
GUILayout.EndHorizontal();

RTUtil.HorizontalSlider(ref mThrottle, 0, 1);
GUI.SetNextControlName("burn");
GUI.SetNextControlName("rt_burn");
RTUtil.TextField(ref mDuration);

GUILayout.BeginHorizontal();
Expand Down
4 changes: 2 additions & 2 deletions src/RemoteTech/UI/QueueFragment.cs
Expand Up @@ -65,7 +65,7 @@ public QueueFragment(FlightComputer.FlightComputer fc)

public void Draw()
{
if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "xd")
if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "rt_xd")
{
RTCore.Instance.StartCoroutine(onClickAddExtraDelay());
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public void Draw()
{
GUILayout.Label(new GUIContent("Delay (+ signal): " + RTUtil.FormatDuration(mFlightComputer.TotalDelay), "Total delay including signal delay."));
GUILayout.FlexibleSpace();
GUI.SetNextControlName("xd");
GUI.SetNextControlName("rt_xd");
RTUtil.TextField(ref mExtraDelay, GUILayout.Width(45));
RTUtil.Button(new GUIContent(">", "Add extra signal delay - Example: 125, 125s, 5m20s, 1d6h20m10s"), () => RTCore.Instance.StartCoroutine(onClickAddExtraDelay()), GUILayout.Width(21), GUILayout.Height(21));
}
Expand Down

0 comments on commit 25df2d9

Please sign in to comment.