Skip to content

Commit

Permalink
Fixed gauge disappearing when going on EVA and back.
Browse files Browse the repository at this point in the history
  • Loading branch information
formicant committed Dec 4, 2016
1 parent a79473a commit c6b445f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Binary file not shown.
6 changes: 5 additions & 1 deletion src/CriticalTemperatureGauge/GaugeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ public class GaugeWindow : Window

protected override GUISkin Skin => HighLogic.Skin;

private Vector2? _constWindowSize;
protected override Vector2? ConstWindowSize =>
_constWindowSize ?? (_constWindowSize = new Vector2(GaugeFrameTexture.width, 36));

protected override Rect InitialWindowRectangle =>
new Rect(
Static.Settings.GaugeWindowPosition != Vector2.zero
? Static.Settings.GaugeWindowPosition
: new Vector2((Screen.width - GaugeFrameTexture.width) / 2, 83),
new Vector2(GaugeFrameTexture.width, 36));
ConstWindowSize.Value);

/// <summary>Creates the temperature gauge window.</summary>
public GaugeWindow()
Expand Down
2 changes: 1 addition & 1 deletion src/CriticalTemperatureGauge/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1.1")]
[assembly: AssemblyVersion("1.2.1.2")]

// Use KSPAssembly to allow other DLLs to make this DLL a dependency in a
// non-hacky way in KSP. Format is (AssemblyProduct, major, minor), and it
Expand Down
7 changes: 6 additions & 1 deletion src/CriticalTemperatureGauge/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ private set
}
}

protected virtual Vector2? ConstWindowSize => null;

protected Window(int windowId, string title = "", bool hasClearBackground = false)
{
WindowId = windowId;
Expand Down Expand Up @@ -72,7 +74,10 @@ public void DrawGUI()
var backgroundColor = GUI.backgroundColor;
if(HasClearBackground)
GUI.backgroundColor = Color.clear;
WindowRectangle = GUILayout.Window(WindowId, WindowRectangle, WindowGUI, Title);
var windowRectangle = GUILayout.Window(WindowId, WindowRectangle, WindowGUI, Title);
WindowRectangle = ConstWindowSize.HasValue
? new Rect(windowRectangle.position, ConstWindowSize.Value)
: windowRectangle;
GUI.backgroundColor = backgroundColor;
}
}
Expand Down

0 comments on commit c6b445f

Please sign in to comment.