Skip to content

Commit

Permalink
Close #792 (Persistent saving of Flight Computer window position)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSP-TaxiService committed May 22, 2019
1 parent ebf01dd commit 9c7929d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions GameData/RemoteTech/Default_Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ RemoteTechSettings
DirectConnectionColor = 0,0.749,0.952,1
SignalRelayEnabled = False
IgnoreLineOfSight = False
FCWinPosX = 100
FCWinPosY = 100
GroundStations
{
STATION
Expand Down
2 changes: 2 additions & 0 deletions src/RemoteTech/RTSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class Settings
[Persistent] public Color DirectConnectionColor = new Color(0, 0.749f, 0.952f, 1); //TODO: remove two new values after some significant time - 7 Nov 2017
[Persistent] public bool SignalRelayEnabled = false;
[Persistent] public bool IgnoreLineOfSight;
[Persistent] public float FCWinPosX;
[Persistent] public float FCWinPosY;
[Persistent(collectionIndex = "STATION")] public List<MissionControlSatellite> GroundStations;
[Persistent(collectionIndex = "PRESETS")] public List<string> PreSets;

Expand Down
7 changes: 7 additions & 0 deletions src/RemoteTech/UI/FlightComputerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public FlightComputerWindow(FlightComputer.FlightComputer fc)

public override void Show()
{
Position.x= RTSettings.Instance.FCWinPosX;
Position.y = RTSettings.Instance.FCWinPosY;

base.Show();
mFlightComputer.OnActiveCommandAbort += mAttitude.Reset;
mFlightComputer.OnNewCommandPop += mAttitude.getActiveFlightMode;
Expand All @@ -65,6 +68,10 @@ public override void Show()

public override void Hide()
{
RTSettings.Instance.FCWinPosX = Position.x;
RTSettings.Instance.FCWinPosY = Position.y;
//RTSettings.Instance.Save(); //overkill

mFlightComputer.OnActiveCommandAbort -= mAttitude.Reset;
mFlightComputer.OnNewCommandPop -= mAttitude.getActiveFlightMode;
base.Hide();
Expand Down

0 comments on commit 9c7929d

Please sign in to comment.