diff --git a/Images/CopyIcon.pdn b/Images/CopyIcon.pdn
deleted file mode 100644
index f3cbbcf..0000000
Binary files a/Images/CopyIcon.pdn and /dev/null differ
diff --git a/Images/PNG/img_BarBlue.png b/Images/PNG/img_BarBlue.png
deleted file mode 100644
index 4b2cef5..0000000
Binary files a/Images/PNG/img_BarBlue.png and /dev/null differ
diff --git a/Images/PNG/img_BarBlue_Back.png b/Images/PNG/img_BarBlue_Back.png
deleted file mode 100644
index ae0da0c..0000000
Binary files a/Images/PNG/img_BarBlue_Back.png and /dev/null differ
diff --git a/Images/PNG/img_DropDown.png b/Images/PNG/img_DropDown.png
deleted file mode 100644
index 0076b1b..0000000
Binary files a/Images/PNG/img_DropDown.png and /dev/null differ
diff --git a/Images/PNG/img_PanelBack.png b/Images/PNG/img_PanelBack.png
deleted file mode 100644
index 1e56504..0000000
Binary files a/Images/PNG/img_PanelBack.png and /dev/null differ
diff --git a/Images/PNG/img_PorkChopAxis.png b/Images/PNG/img_PorkChopAxis.png
deleted file mode 100644
index 57e29e9..0000000
Binary files a/Images/PNG/img_PorkChopAxis.png and /dev/null differ
diff --git a/Images/PNG/img_SelectedDV.png b/Images/PNG/img_SelectedDV.png
deleted file mode 100644
index 7d1ec28..0000000
Binary files a/Images/PNG/img_SelectedDV.png and /dev/null differ
diff --git a/Images/PNG/img_SelectedPoint.png b/Images/PNG/img_SelectedPoint.png
deleted file mode 100644
index b3ae989..0000000
Binary files a/Images/PNG/img_SelectedPoint.png and /dev/null differ
diff --git a/Images/PNG/img_SelectedXAxis.png b/Images/PNG/img_SelectedXAxis.png
deleted file mode 100644
index 969798e..0000000
Binary files a/Images/PNG/img_SelectedXAxis.png and /dev/null differ
diff --git a/Images/PNG/img_SelectedYAxis.png b/Images/PNG/img_SelectedYAxis.png
deleted file mode 100644
index 3433bfd..0000000
Binary files a/Images/PNG/img_SelectedYAxis.png and /dev/null differ
diff --git a/Images/PNG/img_SeparatorHorizontal.png b/Images/PNG/img_SeparatorHorizontal.png
deleted file mode 100644
index 559c127..0000000
Binary files a/Images/PNG/img_SeparatorHorizontal.png and /dev/null differ
diff --git a/Images/PNG/img_SeparatorVertical.png b/Images/PNG/img_SeparatorVertical.png
deleted file mode 100644
index 495e08a..0000000
Binary files a/Images/PNG/img_SeparatorVertical.png and /dev/null differ
diff --git a/Images/PNG/img_buttonCalendar.png b/Images/PNG/img_buttonCalendar.png
deleted file mode 100644
index a7220ba..0000000
Binary files a/Images/PNG/img_buttonCalendar.png and /dev/null differ
diff --git a/Images/PNG/img_buttonChevronDown.png b/Images/PNG/img_buttonChevronDown.png
deleted file mode 100644
index a0457d8..0000000
Binary files a/Images/PNG/img_buttonChevronDown.png and /dev/null differ
diff --git a/Images/PNG/img_buttonChevronUp.png b/Images/PNG/img_buttonChevronUp.png
deleted file mode 100644
index 681258e..0000000
Binary files a/Images/PNG/img_buttonChevronUp.png and /dev/null differ
diff --git a/Images/PNG/img_buttonCopy.png b/Images/PNG/img_buttonCopy.png
deleted file mode 100644
index 09b8956..0000000
Binary files a/Images/PNG/img_buttonCopy.png and /dev/null differ
diff --git a/Images/PNG/img_buttonSettings.png b/Images/PNG/img_buttonSettings.png
deleted file mode 100644
index 3c264d9..0000000
Binary files a/Images/PNG/img_buttonSettings.png and /dev/null differ
diff --git a/Images/PNG/img_buttonSettingsAttention.png b/Images/PNG/img_buttonSettingsAttention.png
deleted file mode 100644
index 40b3750..0000000
Binary files a/Images/PNG/img_buttonSettingsAttention.png and /dev/null differ
diff --git a/Images/PNG/tex_Box.png b/Images/PNG/tex_Box.png
deleted file mode 100644
index c6b8f6e..0000000
Binary files a/Images/PNG/tex_Box.png and /dev/null differ
diff --git a/Images/PNG/tex_BoxUnity.png b/Images/PNG/tex_BoxUnity.png
deleted file mode 100644
index 97634c2..0000000
Binary files a/Images/PNG/tex_BoxUnity.png and /dev/null differ
diff --git a/Images/SelectedPoint.svg b/Images/SelectedPoint.svg
deleted file mode 100644
index 2ee1fb3..0000000
--- a/Images/SelectedPoint.svg
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
diff --git a/Images/ToolbarIcons/TWPIcon.png b/Images/ToolbarIcons/TWPIcon.png
deleted file mode 100644
index 7be0183..0000000
Binary files a/Images/ToolbarIcons/TWPIcon.png and /dev/null differ
diff --git a/Images/ToolbarIcons/TWPIconBig.png b/Images/ToolbarIcons/TWPIconBig.png
deleted file mode 100644
index df7daf0..0000000
Binary files a/Images/ToolbarIcons/TWPIconBig.png and /dev/null differ
diff --git a/Images/img_PorkChopAxis-292x292.png b/Images/img_PorkChopAxis-292x292.png
deleted file mode 100644
index 57e29e9..0000000
Binary files a/Images/img_PorkChopAxis-292x292.png and /dev/null differ
diff --git a/Images/img_PorkChopAxis-308x308.png b/Images/img_PorkChopAxis-308x308.png
deleted file mode 100644
index 0eb6700..0000000
Binary files a/Images/img_PorkChopAxis-308x308.png and /dev/null differ
diff --git a/Images/img_PorkChopAxis-Orig.png b/Images/img_PorkChopAxis-Orig.png
deleted file mode 100644
index 9877b03..0000000
Binary files a/Images/img_PorkChopAxis-Orig.png and /dev/null differ
diff --git a/Images/img_PorkChopAxis.png b/Images/img_PorkChopAxis.png
deleted file mode 100644
index 0eb6700..0000000
Binary files a/Images/img_PorkChopAxis.png and /dev/null differ
diff --git a/Images/img_PorkChopExample.png b/Images/img_PorkChopExample.png
deleted file mode 100644
index 386d98b..0000000
Binary files a/Images/img_PorkChopExample.png and /dev/null differ
diff --git a/Images/img_PorkChopGrid.pdn b/Images/img_PorkChopGrid.pdn
deleted file mode 100644
index 9644b90..0000000
Binary files a/Images/img_PorkChopGrid.pdn and /dev/null differ
diff --git a/Images/img_PorkChopGrid.png b/Images/img_PorkChopGrid.png
deleted file mode 100644
index 0eb6700..0000000
Binary files a/Images/img_PorkChopGrid.png and /dev/null differ
diff --git a/Images/img_PorkChopLegend.png b/Images/img_PorkChopLegend.png
deleted file mode 100644
index 0f0f456..0000000
Binary files a/Images/img_PorkChopLegend.png and /dev/null differ
diff --git a/Images/img_SelectedDV.png b/Images/img_SelectedDV.png
deleted file mode 100644
index 7d1ec28..0000000
Binary files a/Images/img_SelectedDV.png and /dev/null differ
diff --git a/Images/img_SelectedPoint.png b/Images/img_SelectedPoint.png
deleted file mode 100644
index b3ae989..0000000
Binary files a/Images/img_SelectedPoint.png and /dev/null differ
diff --git a/Images/img_SelectedXAxis.png b/Images/img_SelectedXAxis.png
deleted file mode 100644
index 969798e..0000000
Binary files a/Images/img_SelectedXAxis.png and /dev/null differ
diff --git a/Images/img_SelectedYAxis.png b/Images/img_SelectedYAxis.png
deleted file mode 100644
index 3433bfd..0000000
Binary files a/Images/img_SelectedYAxis.png and /dev/null differ
diff --git a/Images/img_dvLegend.png b/Images/img_dvLegend.png
deleted file mode 100644
index 1801eed..0000000
Binary files a/Images/img_dvLegend.png and /dev/null differ
diff --git a/KSPDateTimeUnitTests/KSPDateTimeUnitTests.csproj b/KSPDateTimeUnitTests/KSPDateTimeUnitTests.csproj
deleted file mode 100644
index 0fbb402..0000000
--- a/KSPDateTimeUnitTests/KSPDateTimeUnitTests.csproj
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}
- Library
- Properties
- KSPDateTimeUnitTests
- KSPDateTimeUnitTests
- v4.8
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {942b92f0-c682-424e-814e-c2ddd1e84e2f}
- TransferWindowPlanner
-
-
-
-
-
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/KSPDateTimeUnitTests/Properties/AssemblyInfo.cs b/KSPDateTimeUnitTests/Properties/AssemblyInfo.cs
deleted file mode 100644
index bff27c7..0000000
--- a/KSPDateTimeUnitTests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("KSPDateTimeUnitTests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("KSPDateTimeUnitTests")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("66da5f46-d647-407a-ab1e-e800f24ad604")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// 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.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/KSPDateTimeUnitTests/UnitTest1.cs b/KSPDateTimeUnitTests/UnitTest1.cs
deleted file mode 100644
index c74bf33..0000000
--- a/KSPDateTimeUnitTests/UnitTest1.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-using System.Collections.Generic;
-
-using TransferWindowPlanner;
-using KSPPluginFramework;
-
-namespace KSPDateTimeUnitTests
-{
- [TestClass]
- public class UnitTest1
- {
- [TestMethod]
- public void TestDateTime()
- {
- KSPDateTime dt2 = new KSPDateTime(235, 1);
-
- Double DateUT = 301.123;
-
- KSPDateTime dt = new KSPDateTime(DateUT);
-
- Assert.AreEqual(5, dt.Minute);
- Assert.AreEqual(1, dt.Second);
- Assert.AreEqual(123, dt.Millisecond);
- Assert.AreEqual(0, dt.Hour);
- Assert.AreEqual(1, dt.DayOfYear);
- Assert.AreEqual(1, dt.Year);
-
- dt = dt.AddMilliSeconds(456);
- Assert.AreEqual(5, dt.Minute);
- Assert.AreEqual(1, dt.Second);
- Assert.AreEqual(579, dt.Millisecond);
-
- dt = new KSPDateTime(2, 50, 0, 6, 8,456);
- Assert.AreEqual(6, dt.Minute);
- Assert.AreEqual(8, dt.Second);
- Assert.AreEqual(456, dt.Millisecond);
- Assert.AreEqual(2, dt.Year,"Hello");
- Assert.AreEqual(50, dt.DayOfYear);
-
- }
-
- [TestMethod]
- public void TestEarthDateTime()
- {
- KSPDateStructure.SetEarthCalendar();
- Double DateUT = 301.123;
- KSPDateTime dt = new KSPDateTime(DateUT);
- //Console.Write(dt.Day);
-
- Assert.AreEqual(5, dt.Minute);
- Assert.AreEqual(1, dt.Second);
- Assert.AreEqual(123, dt.Millisecond);
- Assert.AreEqual(0, dt.Hour);
- Assert.AreEqual(1, dt.DayOfYear);
- Assert.AreEqual(1951, dt.Year);
-
- dt = dt.AddMilliSeconds(456);
- Assert.AreEqual(5, dt.Minute);
- Assert.AreEqual(1, dt.Second);
- Assert.AreEqual(579, dt.Millisecond);
-
- //dt.Second = 68;
- //Assert.AreEqual(6, dt.Minute);
- //Assert.AreEqual(8, dt.Second);
- //Assert.AreEqual(456, dt.Millisecond);
-
-
- //dt.Year = 1969;
- //Assert.AreEqual(1969, dt.Year, "Hello");
- //dt.DayOfYear = 50;
- //Assert.AreEqual(50, dt.DayOfYear);
-
- //KSPDateTimeStructure.SetCalendarTypeEarth(1951,1,1);
- //dt = new KSPDateTime(1951, 50, 10, 20, 30);
- //Assert.AreEqual(2, dt.Month);
- //Assert.AreEqual(19, dt.Day);
-
- }
-
-
- [TestMethod]
- public void TestMonths()
- {
- KSPDateStructure.SetCustomCalendar();
-
- //empty months structure
- KSPDateTime dt = new KSPDateTime(1, 100);
- Assert.AreEqual(0, dt.Month);
- Assert.AreEqual(100, dt.Day);
-
- //set up some months
- KSPDateStructure.Months.Add(new KSPMonth("Billtember", 200));
- KSPDateStructure.Months.Add(new KSPMonth("Jebuary", 265));
-
- Assert.AreEqual(1, dt.Month);
- Assert.AreEqual(100, dt.Day);
- dt = dt.AddDays(100);
- Assert.AreEqual(1, dt.Month);
- Assert.AreEqual(200, dt.Day);
- dt = dt.AddDays(100);
- Assert.AreEqual(2, dt.Month);
- dt = dt.AddDays(100);
- }
-
- [TestMethod]
- public void TestFormats()
- {
- KSPDateTime dt = new KSPDateTime(1, 100);
-
- KSPDateStructure.Months = new List();
-
- Assert.AreEqual("100/00/0001", dt.ToString("dd/MM/yyyy"));
-
- Assert.AreEqual("Year 1, Day 100 - 0h, 0m",dt.ToString());
-
-
- KSPDateStructure.SetEarthCalendar();
- Assert.AreEqual("25/01/1951", dt.ToString("dd/MM/yyyy"));
-
-
- dt = new KSPDateTime(1951,100);
- Assert.AreEqual("10/04/1951",dt.ToString("dd/MM/yyyy"));
-
- Assert.AreEqual("Hello there 1951",String.Format("Hello there {0:yyyy}",dt));
-
-
-
-
- }
-
- }
-}
diff --git a/KSPDateTimeUnitTests/packages.config b/KSPDateTimeUnitTests/packages.config
deleted file mode 100644
index 6541924..0000000
--- a/KSPDateTimeUnitTests/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/PluginFiles/ReadMe-TransferWindowPlanner.txt b/PluginFiles/ReadMe-TransferWindowPlanner.txt
index 2e2b42e..786af67 100644
--- a/PluginFiles/ReadMe-TransferWindowPlanner.txt
+++ b/PluginFiles/ReadMe-TransferWindowPlanner.txt
@@ -27,6 +27,11 @@ LICENSE
This work is licensed under an MIT license as outlined at the OSI site. Visit the documentation site for more details and Attribution
VERSION HISTORY
+
+Version 1.9.1.2 - KSP Version: 1.12.5
+- [VerrPower] Add GUI scale input in settings, clamped to 1.0-3.0 and rounded to one decimal place
+- [VerrPower] Rework the settings window to use fixed IMGUI rendering, preventing collapse/flicker while opening or dragging
+
Version 1.9.1.1 - KSP Version: 1.12.5
- [Nazfib] Update KAC wrapper
diff --git a/README.md b/README.md
index 62063c3..648822a 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,9 @@ Forum Thread: [Transfer Window Planner](http://forum.kerbalspaceprogram.com/thre
Author: TriggerAu
LaunchWindowPlanner Forum Thread: [KSP Launch Window Planner (WEBAPP)](http://forum.kerbalspaceprogram.com/threads/33023-WEB-APP-Launch-Window-Planner)
+UI Scaling
+The settings window includes a GUI Scale input under General Properties. Values are clamped to 1.0-3.0 and rounded to one decimal place. The settings window uses fixed IMGUI rendering so it remains stable while opening and dragging.
+
Licensing
Plugin Code License provided in project LICENSE file
-All AlexMun's code is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_US)
\ No newline at end of file
+All AlexMun's code is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_US)
diff --git a/TransferWindowPlanner/DateAndTimeTests.playlist b/TransferWindowPlanner/DateAndTimeTests.playlist
deleted file mode 100644
index e1d2ba6..0000000
--- a/TransferWindowPlanner/DateAndTimeTests.playlist
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/TransferWindowPlanner/Framework/MonoBehaviourWindow.cs b/TransferWindowPlanner/Framework/MonoBehaviourWindow.cs
index 7b4fbc3..f7fcb3e 100644
--- a/TransferWindowPlanner/Framework/MonoBehaviourWindow.cs
+++ b/TransferWindowPlanner/Framework/MonoBehaviourWindow.cs
@@ -92,6 +92,7 @@ internal override void OnAwake()
/// Window position on screen, is fed in to the Window routine and the resulting position after GUILayout is what you read
///
internal Rect WindowRect;
+ internal Single GuiScale = 1.0f;
private Boolean _WindowMoveEventsEnabled=false;
public Boolean WindowMoveEventsEnabled
@@ -229,12 +230,17 @@ internal override void Update()
///
private void DrawGUI()
{
+ Matrix4x4 matrixDefault = GUI.matrix;
+ Single guiScale = Mathf.Clamp(GuiScale, 1.0f, 3.0f);
+
//this sets the skin on each draw loop
GUI.skin = SkinsLibrary.CurrentSkin;
//keep the window locked to the screen if its supposed to be
if (ClampToScreen)
- WindowRect = WindowRect.ClampToScreen(ClampToScreenOffset);
+ WindowRect = WindowRect.ClampToScreen(ClampToScreenOffset, guiScale);
+
+ GUI.matrix = Matrix4x4.Scale(new Vector3(guiScale, guiScale, 1.0f)) * matrixDefault;
//Are we using a custom style of the skin style for the window
if (WindowStyle == null)
@@ -271,6 +277,8 @@ private void DrawGUI()
//Draw the tooltip of its there to be drawn
if (TooltipsEnabled)
DrawToolTip();
+
+ GUI.matrix = matrixDefault;
}
public event WindowMoveHandler onWindowMoveStarted;
@@ -465,4 +473,4 @@ private void SetTooltipText()
}
#endregion
}
-}
\ No newline at end of file
+}
diff --git a/TransferWindowPlanner/Settings.cs b/TransferWindowPlanner/Settings.cs
index da624db..8c533e9 100644
--- a/TransferWindowPlanner/Settings.cs
+++ b/TransferWindowPlanner/Settings.cs
@@ -27,6 +27,7 @@ internal Settings(String FilePath)
[Persistent] internal DisplaySkin SelectedSkin = DisplaySkin.Default;
+ [Persistent] internal Single GuiScale = 1.0f;
internal Boolean BlizzyToolbarIsAvailable = false;
@@ -62,6 +63,15 @@ internal enum DisplaySkin
[Description("Unity/KSP Buttons")] UnityWKSPButtons
}
+ internal static Single NormalizeGuiScale(Single value)
+ {
+ if (Single.IsNaN(value) || Single.IsInfinity(value))
+ value = 1.0f;
+
+ value = Mathf.Clamp(value, 1.0f, 3.0f);
+ return (Single)(Math.Floor(value * 10.0f + 0.5f) / 10.0f);
+ }
+
[Persistent] internal TWP_KACWrapper.KACWrapper.KACAPI.AlarmActionEnum KACAlarmAction = TWP_KACWrapper.KACWrapper.KACAPI.AlarmActionEnum.KillWarp;
[Persistent] internal Double AlarmMargin = 24;
diff --git a/TransferWindowPlanner/TWP.cs b/TransferWindowPlanner/TWP.cs
index 0ea1dca..25f93c6 100644
--- a/TransferWindowPlanner/TWP.cs
+++ b/TransferWindowPlanner/TWP.cs
@@ -219,6 +219,26 @@ private void InitWindows()
windowSettingsBlockoutExtra.mbTWP = this;
InitDebugWindow();
+ ApplyWindowGuiScale();
+ }
+
+ internal void ApplyWindowGuiScale()
+ {
+ Single guiScale = Settings.NormalizeGuiScale(settings.GuiScale);
+ settings.GuiScale = guiScale;
+
+ if (windowMain != null)
+ windowMain.GuiScale = guiScale;
+ if (windowSettings != null)
+ windowSettings.GuiScale = guiScale;
+ if (windowSettingsBlockout != null)
+ windowSettingsBlockout.GuiScale = guiScale;
+ if (windowSettingsBlockoutExtra != null)
+ windowSettingsBlockoutExtra.GuiScale = guiScale;
+#if DEBUG
+ if (windowDebug != null)
+ windowDebug.GuiScale = guiScale;
+#endif
}
#region Toolbar Stuff
@@ -400,7 +420,12 @@ internal void RemoveInputLock()
private Boolean MouseOverWindow(Rect WindowRect, Boolean WindowVisible)
{
- return WindowVisible && WindowRect.Contains(Event.current.mousePosition);
+ Single guiScale = Settings.NormalizeGuiScale(settings.GuiScale);
+ Vector2 mousePosition = Event.current.mousePosition;
+ if (guiScale != 1.0f)
+ mousePosition = new Vector2(mousePosition.x / guiScale, mousePosition.y / guiScale);
+
+ return WindowVisible && WindowRect.Contains(mousePosition);
}
}
diff --git a/TransferWindowPlanner/TWPWindow.cs b/TransferWindowPlanner/TWPWindow.cs
index 07a0537..083c199 100644
--- a/TransferWindowPlanner/TWPWindow.cs
+++ b/TransferWindowPlanner/TWPWindow.cs
@@ -297,6 +297,7 @@ internal override void DrawWindow(int id)
//if its changed then affect the window size
if (ShowMinimized)
{
+ mbTWP.windowSettings.Visible = false;
WindowRect.x = WindowRect.x + WindowRect.width - 320;
WindowRect.width = 350;
@@ -314,6 +315,7 @@ internal override void DrawWindow(int id)
//Close button
if (GUI.Button(new Rect(WindowRect.width - 32, 2, 30, 20), "X", "ButtonSettings"))
{
+ mbTWP.windowSettings.Visible = false;
//Visible = false;
if(TransferWindowPlanner.settings.ButtonStyleToDisplay== Settings.ButtonStyleEnum.Launcher)
{
@@ -323,20 +325,8 @@ internal override void DrawWindow(int id)
Visible = false;
}
- //Set the settings window pos
- if (mbTWP.windowSettings.Visible)
- {
- mbTWP.windowSettings.WindowRect.y = WindowRect.y;
- if (ShowMinimized)
- {
- mbTWP.windowSettings.WindowRect.x = WindowRect.x + WindowRect.width;
- }
- else
- {
- mbTWP.windowSettings.WindowRect.x = WindowRect.x + WindowRect.width - mbTWP.windowSettings.WindowRect.width;
- }
- }
- mbTWP.windowSettingsBlockout.Visible = mbTWP.windowSettingsBlockoutExtra.Visible = mbTWP.windowSettings.Visible && !ShowMinimized;
+ mbTWP.windowSettingsBlockout.Visible = false;
+ mbTWP.windowSettingsBlockoutExtra.Visible = false;
//Now draw the window
if (ShowMinimized)
@@ -377,7 +367,12 @@ internal override void DrawWindow(int id)
//close the settings window if we click elsewhere
if (!ShowMinimized && Event.current.type == EventType.MouseDown)
{
- if (!mbTWP.windowSettings.WindowRect.Contains(Event.current.mousePosition))
+ Rect settingsRectInMainWindow = new Rect(
+ mbTWP.windowSettings.WindowRect.x - WindowRect.x,
+ mbTWP.windowSettings.WindowRect.y - WindowRect.y,
+ mbTWP.windowSettings.WindowRect.width,
+ mbTWP.windowSettings.WindowRect.height);
+ if (!settingsRectInMainWindow.Contains(Event.current.mousePosition))
mbTWP.windowSettings.Visible = false;
}
@@ -857,13 +852,6 @@ internal void ResetWindow()
internal override void OnGUIEvery()
{
- //close the settings window if we click elsewhere
- if (!ShowMinimized && Event.current.type == EventType.MouseDown)
- {
- if (!mbTWP.windowSettings.WindowRect.Contains(Event.current.mousePosition))
- mbTWP.windowSettings.Visible = false;
- }
-
base.OnGUIEvery();
}
diff --git a/TransferWindowPlanner/TWPWindowSettings.cs b/TransferWindowPlanner/TWPWindowSettings.cs
index d932c92..4465af6 100644
--- a/TransferWindowPlanner/TWPWindowSettings.cs
+++ b/TransferWindowPlanner/TWPWindowSettings.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Collections.Generic;
+using System;
using System.ComponentModel;
-using System.Linq;
-using System.Text;
+using System.Globalization;
using KSP;
using UnityEngine;
@@ -12,8 +10,8 @@
namespace TransferWindowPlanner
{
- [WindowInitials(TooltipsEnabled=true,Visible=false,DragEnabled=false,Caption="TWP Settings")]
- class TWPWindowSettings:MonoBehaviourWindowPlus
+ [WindowInitials(TooltipsEnabled = true, Visible = false, DragEnabled = true, Caption = "TWP Settings")]
+ class TWPWindowSettings : MonoBehaviourWindowPlus
{
internal TransferWindowPlanner mbTWP;
internal Settings settings;
@@ -23,60 +21,64 @@ class TWPWindowSettings:MonoBehaviourWindowPlus
private DropDownList ddlSettingsButtonStyle;
internal DropDownList ddlSettingsCalendar;
- internal Int32 WindowWidth = 360;
- internal Int32 WindowHeight = 200;
+ private String strGuiScale;
+ private String strAlarmMargin;
+ private String strEarthYear;
+ private String strEarthMonth;
+ private String strEarthDay;
+
+ internal Int32 WindowWidth = 380;
+ internal Int32 WindowHeight = 280;
internal enum SettingsTabs
{
[Description("General Properties")] General,
[Description("Alarm Clock Integration")] AlarmIntegration,
[Description("Calendar Control")] Calendar,
- //[Description("Styling/Visuals")] Styling,
- [Description("About...")] About,
+ [Description("About...")] About,
}
-
+
internal override void OnAwake()
{
base.OnAwake();
- //WindowRect = new Rect(mbTWP.windowMain.WindowRect.x + mbTWP.windowMain.WindowRect.width, mbTWP.windowMain.WindowRect.y, 300, 200);
- WindowRect = new Rect(0, 0, WindowWidth, WindowHeight);
settings = TransferWindowPlanner.settings;
-
+ WindowRect = new Rect(0, 0, WindowWidth, WindowHeight);
TooltipMouseOffset = new Vector2d(-10, 10);
ddlSettingsTab = new DropDownList(KSPPluginFramework.EnumExtensions.ToEnumDescriptions(), this);
ddlSettingsSkin = new DropDownList(KSPPluginFramework.EnumExtensions.ToEnumDescriptions(), (Int32)settings.SelectedSkin, this);
ddlSettingsSkin.OnSelectionChanged += ddlSettingsSkin_SelectionChanged;
+
ddlSettingsButtonStyle = new DropDownList(KSPPluginFramework.EnumExtensions.ToEnumDescriptions(), (Int32)settings.ButtonStyleChosen, this);
ddlSettingsButtonStyle.OnSelectionChanged += ddlSettingsButtonStyle_OnSelectionChanged;
+
ddlSettingsCalendar = new DropDownList(KSPPluginFramework.EnumExtensions.ToEnumDescriptions(), this);
- //NOTE:Pull out the custom option for now
ddlSettingsCalendar.Items.Remove(CalendarTypeEnum.Custom.Description());
ddlSettingsCalendar.OnSelectionChanged += ddlSettingsCalendar_OnSelectionChanged;
-
+
ddlManager.AddDDL(ddlSettingsCalendar);
ddlManager.AddDDL(ddlSettingsButtonStyle);
ddlManager.AddDDL(ddlSettingsSkin);
ddlManager.AddDDL(ddlSettingsTab);
onWindowVisibleChanged += TWPWindowSettings_onWindowVisibleChanged;
+ SyncInputFields();
+ UpdateWindowSize();
}
-
void TWPWindowSettings_onWindowVisibleChanged(MonoBehaviourWindow sender, bool NewVisibleState)
{
- if (NewVisibleState)
- {
- if (settings.VersionAttentionFlag)
- ddlSettingsTab.SelectedIndex = (Int32)SettingsTabs.About;
- else
- ddlSettingsTab.SelectedIndex = (Int32)SettingsTabs.General;
+ if (!NewVisibleState)
+ return;
- //reset the flag
- settings.VersionAttentionFlag = false;
- }
+ ddlSettingsTab.SelectedIndex = settings.VersionAttentionFlag ? (Int32)SettingsTabs.About : (Int32)SettingsTabs.General;
+ settings.VersionAttentionFlag = false;
+
+ SyncInputFields();
+ UpdateWindowSize();
+ PositionAtRootDefault();
}
internal override void OnGUIOnceOnly()
@@ -85,6 +87,72 @@ internal override void OnGUIOnceOnly()
ddlManager.DropDownSeparators = new GUIContentWithStyle("", Styles.styleSeparatorV);
}
+ internal override void OnGUIEvery()
+ {
+ UpdateWindowSize();
+ DragRect = new Rect(0, 0, WindowWidth - 34, 24);
+
+ if (Visible && blnFlightUIVisible && !(HighLogic.LoadedScene == GameScenes.FLIGHT && PauseMenu.isOpen))
+ DrawFixedSettingsGUI();
+
+ ddlManager.CloseOnOutsideClicks();
+ }
+
+ private void DrawFixedSettingsGUI()
+ {
+ Matrix4x4 matrixDefault = GUI.matrix;
+ Int32 depthDefault = GUI.depth;
+ Single guiScale = Mathf.Clamp(GuiScale, 1.0f, 3.0f);
+
+ try
+ {
+ GUI.skin = SkinsLibrary.CurrentSkin;
+
+ if (ClampToScreen)
+ WindowRect = WindowRect.ClampToScreen(ClampToScreenOffset, guiScale);
+
+ GUI.matrix = Matrix4x4.Scale(new Vector3(guiScale, guiScale, 1.0f)) * matrixDefault;
+ GUI.depth = -100;
+
+ if (WindowStyle == null)
+ WindowRect = GUI.Window(WindowID, WindowRect, DrawFixedSettingsWindowInternal, WindowCaption);
+ else
+ WindowRect = GUI.Window(WindowID, WindowRect, DrawFixedSettingsWindowInternal, WindowCaption, WindowStyle);
+ }
+ finally
+ {
+ GUI.depth = depthDefault;
+ GUI.matrix = matrixDefault;
+ }
+ }
+
+ private void DrawFixedSettingsWindowInternal(Int32 id)
+ {
+ DrawWindowPre(id);
+ DrawWindow(id);
+ DrawWindowPost(id);
+
+ if (DragEnabled)
+ {
+ if (DragRect.height == 0 && DragRect.width == 0)
+ GUI.DragWindow();
+ else
+ GUI.DragWindow(DragRect);
+ }
+ }
+
+ internal void PositionAtRootDefault()
+ {
+ if (mbTWP == null || mbTWP.windowMain == null)
+ return;
+
+ WindowRect = new Rect(
+ mbTWP.windowMain.WindowRect.x + mbTWP.windowMain.WindowRect.width - WindowWidth,
+ mbTWP.windowMain.WindowRect.y,
+ WindowWidth,
+ WindowHeight);
+ }
+
void ddlSettingsSkin_SelectionChanged(DropDownList sender, int OldIndex, int NewIndex)
{
settings.SelectedSkin = (Settings.DisplaySkin)NewIndex;
@@ -96,27 +164,33 @@ void ddlSettingsCalendar_OnSelectionChanged(DropDownList sender, int OldIndex, i
{
settings.SelectedCalendar = (CalendarTypeEnum)NewIndex;
settings.Save();
+
switch (settings.SelectedCalendar)
{
- case CalendarTypeEnum.KSPStock: KSPDateStructure.SetKSPStockCalendar(); break;
+ case CalendarTypeEnum.KSPStock:
+ KSPDateStructure.SetKSPStockCalendar();
+ break;
case CalendarTypeEnum.Earth:
KSPDateStructure.SetEarthCalendar(settings.EarthEpoch);
+ SyncEarthEpochInputs();
break;
- case CalendarTypeEnum.Custom:
+ case CalendarTypeEnum.Custom:
KSPDateStructure.SetCustomCalendar();
break;
- default: KSPDateStructure.SetKSPStockCalendar(); break;
+ default:
+ KSPDateStructure.SetKSPStockCalendar();
+ break;
}
+
+ UpdateWindowSize();
mbTWP.windowMain.ResetWindow();
}
-
void ddlSettingsButtonStyle_OnSelectionChanged(MonoBehaviourWindowPlus.DropDownList sender, int OldIndex, int NewIndex)
{
settings.ButtonStyleChosen = (Settings.ButtonStyleEnum)NewIndex;
settings.Save();
- //destroy Old Objects
switch ((Settings.ButtonStyleEnum)OldIndex)
{
case Settings.ButtonStyleEnum.Toolbar:
@@ -127,7 +201,6 @@ void ddlSettingsButtonStyle_OnSelectionChanged(MonoBehaviourWindowPlus.DropDownL
break;
}
- //Create New ones
switch ((Settings.ButtonStyleEnum)NewIndex)
{
case Settings.ButtonStyleEnum.Toolbar:
@@ -138,312 +211,313 @@ void ddlSettingsButtonStyle_OnSelectionChanged(MonoBehaviourWindowPlus.DropDownL
break;
}
}
+
internal override void DrawWindow(int id)
{
- if (GUI.Button(new Rect(WindowRect.width - 32, 2, 30, 20), "X", "ButtonSettings"))
+ UpdateWindowSize();
+
+ if (GUI.Button(new Rect(WindowWidth - 32, 2, 30, 20), "X", "ButtonSettings"))
{
Visible = false;
+ return;
}
- GUILayout.BeginVertical();
-
- if (SkinsLibrary.CurrentSkin.name != "Default")
- GUILayout.Space(5);
- GUILayout.BeginHorizontal();
- GUILayout.Label("Settings Section", Styles.styleTextHeading, GUILayout.Width(120));
- GUILayout.Space(5);
- ddlSettingsTab.DrawButton();
- GUILayout.Space(4);
- GUILayout.EndHorizontal();
+ GUI.Label(new Rect(10, 30, 118, 20), "Settings Section", Styles.styleTextHeading);
+ DrawDropDown(new Rect(132, 28, WindowWidth - 150, 24), ddlSettingsTab);
switch ((SettingsTabs)ddlSettingsTab.SelectedIndex)
{
case SettingsTabs.General:
- DrawWindow_General();
- WindowHeight = 206;
+ DrawGeneral();
break;
case SettingsTabs.AlarmIntegration:
- DrawWindow_Alarm();
- WindowHeight = 206;
+ DrawAlarm();
break;
case SettingsTabs.Calendar:
- DrawWindow_Calendar();
- WindowHeight = 206;
+ DrawCalendar();
break;
case SettingsTabs.About:
- DrawWindow_About();
- WindowHeight = 285;
+ DrawAbout();
break;
}
- GUILayout.EndVertical();
-
- WindowRect.width = WindowWidth;
- WindowRect.height = WindowHeight;
}
- //Int32 intBlizzyToolbarMissingHeight = 0;
- private void DrawWindow_General()
+ private void DrawGeneral()
{
- //Styling
- GUILayout.BeginHorizontal(Styles.styleSettingsArea, GUILayout.Height(54));
-
- GUILayout.BeginVertical(GUILayout.Width(60));
- GUILayout.Space(2); //to even up the text
- GUILayout.Label("Styling:", Styles.styleTextHeading);
- GUILayout.Label("Button:", Styles.styleTextHeading);
- GUILayout.EndVertical();
-
- GUILayout.BeginVertical();
- ddlSettingsSkin.DrawButton();
-
- ddlSettingsButtonStyle.DrawButton();
-
- //intBlizzyToolbarMissingHeight = 0;
- if (!settings.BlizzyToolbarIsAvailable)
+ Rect styleBox = new Rect(10, 62, WindowWidth - 20, 68);
+ GUI.Box(styleBox, "", Styles.styleSettingsArea);
+ GUI.Label(new Rect(20, 72, 70, 20), "Styling:", Styles.styleTextHeading);
+ GUI.Label(new Rect(20, 98, 70, 20), "Button:", Styles.styleTextHeading);
+ DrawDropDown(new Rect(92, 70, WindowWidth - 112, 22), ddlSettingsSkin);
+ DrawDropDown(new Rect(92, 96, WindowWidth - 112, 22), ddlSettingsButtonStyle);
+
+ if (!settings.BlizzyToolbarIsAvailable && settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Toolbar)
{
- if (settings.ButtonStyleChosen == Settings.ButtonStyleEnum.Toolbar)
- {
- if (GUILayout.Button(new GUIContent("Not Installed. Click for Toolbar Info", "Click to open your browser and find out more about the Common Toolbar"), Styles.styleTextCenterGreen))
- Application.OpenURL("https://forum.kerbalspaceprogram.com/index.php?/topic/161857--");
- //intBlizzyToolbarMissingHeight = 18;
- }
- //if (DrawToggle(ref settings.UseBlizzyToolbarIfAvailable, new GUIContent("Use Common Toolbar", "Choose to use the Common Toolbar or the native KSP ARP button"), Styles.styleToggle))
- //{
- // if (settings.BlizzyToolbarIsAvailable)
- // {
- // if (settings.UseBlizzyToolbarIfAvailable)
- // mbARP.btnToolbar = mbARP.InitToolbarButton();
- // else
- // mbARP.DestroyToolbarButton(mbARP.btnToolbar);
- // }
- // settings.Save();
- //}
+ if (GUI.Button(new Rect(92, 122, WindowWidth - 112, 22), new GUIContent("Not Installed. Click for Toolbar Info", "Click to open your browser and find out more about the Common Toolbar"), Styles.styleTextCenterGreen))
+ Application.OpenURL("https://forum.kerbalspaceprogram.com/index.php?/topic/161857--");
}
- GUILayout.EndVertical();
- GUILayout.EndHorizontal();
+ GUI.Label(new Rect(10, 140, 90, 20), "GUI Scale:", Styles.styleTextHeading);
+ strGuiScale = GUI.TextField(new Rect(100, 138, 58, 22), strGuiScale ?? "", Styles.styleTextField);
+ GUI.Label(new Rect(164, 140, 16, 20), "x", Styles.styleTextHeading);
+ if (GUI.Button(new Rect(184, 138, 50, 22), "Set"))
+ ApplyGuiScaleInput();
- GUILayout.Label("Click Through Protection", Styles.styleTextHeading);
- GUILayout.BeginVertical(Styles.styleSettingsArea);
- if (DrawToggle(ref settings.ClickThroughProtect_KSC, "Prevent in Space Center", Styles.styleToggle)) {
+ GUI.Label(new Rect(10, 170, 220, 20), "Click Through Protection", Styles.styleTextHeading);
+ GUI.Box(new Rect(10, 192, WindowWidth - 20, 82), "", Styles.styleSettingsArea);
+ if (DrawToggleRect(new Rect(20, 198, 260, 18), ref settings.ClickThroughProtect_KSC, "Prevent in Space Center", Styles.styleToggle))
+ {
if (!settings.ClickThroughProtect_KSC && HighLogic.LoadedScene == GameScenes.SPACECENTER)
mbTWP.RemoveInputLock();
settings.Save();
}
- if (DrawToggle(ref settings.ClickThroughProtect_Editor, "Prevent in Editors", Styles.styleToggle)) {
- if (!settings.ClickThroughProtect_Editor && (HighLogic.LoadedScene == GameScenes.EDITOR))
+ if (DrawToggleRect(new Rect(20, 218, 260, 18), ref settings.ClickThroughProtect_Editor, "Prevent in Editors", Styles.styleToggle))
+ {
+ if (!settings.ClickThroughProtect_Editor && HighLogic.LoadedScene == GameScenes.EDITOR)
mbTWP.RemoveInputLock();
settings.Save();
}
- if (DrawToggle(ref settings.ClickThroughProtect_Flight, "Prevent in Flight", Styles.styleToggle)) {
+ if (DrawToggleRect(new Rect(20, 238, 260, 18), ref settings.ClickThroughProtect_Flight, "Prevent in Flight", Styles.styleToggle))
+ {
if (!settings.ClickThroughProtect_Flight && HighLogic.LoadedScene == GameScenes.FLIGHT)
mbTWP.RemoveInputLock();
settings.Save();
}
- if (DrawToggle(ref settings.ClickThroughProtect_Tracking, "Prevent in Tracking Station", Styles.styleToggle)) {
+ if (DrawToggleRect(new Rect(20, 258, 280, 18), ref settings.ClickThroughProtect_Tracking, "Prevent in Tracking Station", Styles.styleToggle))
+ {
if (!settings.ClickThroughProtect_Tracking && HighLogic.LoadedScene == GameScenes.TRACKSTATION)
mbTWP.RemoveInputLock();
settings.Save();
}
- GUILayout.EndVertical();
}
- private void DrawWindow_Alarm()
+ private void DrawAlarm()
{
- GUILayout.BeginVertical(Styles.styleSettingsArea);
- GUILayout.Label("Alarm Clock Options", Styles.styleTextHeading);
+ GUI.Box(new Rect(10, 62, WindowWidth - 20, WindowHeight - 72), "", Styles.styleSettingsArea);
+ GUI.Label(new Rect(20, 72, 180, 20), "Alarm Clock Options", Styles.styleTextHeading);
- GUILayout.BeginHorizontal();
- GUILayout.Label("Margin", Styles.styleText,GUILayout.Width(85));
- if (DrawTextBox(ref settings.AlarmMargin))
- settings.Save();
- GUILayout.Label("(hours)", Styles.styleTextYellow, GUILayout.Width(50));
- GUILayout.EndHorizontal();
+ GUI.Label(new Rect(20, 100, 75, 20), "Margin", Styles.styleText);
+ strAlarmMargin = GUI.TextField(new Rect(96, 98, 78, 22), strAlarmMargin ?? "", Styles.styleTextField);
+ GUI.Label(new Rect(182, 100, 50, 20), "(hours)", Styles.styleTextYellow);
+ if (GUI.Button(new Rect(238, 98, 42, 22), "Set"))
+ ApplyAlarmMarginInput();
if (!TWP_KACWrapper.KACWrapper.AssemblyExists)
{
- GUILayout.Label("KAC is not installed, using the stock alarm clock app");
+ GUI.Label(new Rect(20, 132, WindowWidth - 40, 20), "KAC is not installed, using the stock alarm clock app");
+ return;
+ }
+
+ if (DrawToggleRect(new Rect(20, 132, 220, 20), ref settings.ForceUseStockAlarmClock, "Use stock alarm clock", Styles.styleToggle))
+ settings.Save();
+
+ if (settings.ForceUseStockAlarmClock)
+ return;
+
+ if (TWP_KACWrapper.KACWrapper.NeedUpgrade)
+ {
+ if (GUI.Button(new Rect(20, 160, WindowWidth - 40, 24), new GUIContent("You need a newer version of KAC", "Click to open your browser and download a newer Kerbal Alarm Clock"), Styles.styleTextCenterGreen))
+ Application.OpenURL("https://forum.kerbalspaceprogram.com/index.php?/topic/22809--");
+ }
+ else if (!TWP_KACWrapper.KACWrapper.InstanceExists)
+ {
+ GUI.Label(new Rect(20, 160, WindowWidth - 40, 20), "KAC is not loaded in this scene, so we can't configure", Styles.styleTextGreen);
+ GUI.Label(new Rect(20, 180, WindowWidth - 40, 20), "the integration options", Styles.styleTextGreen);
}
else
{
- if (DrawToggle(ref settings.ForceUseStockAlarmClock, "Use stock alarm clock", Styles.styleToggle))
- settings.Save();
-
- if (settings.ForceUseStockAlarmClock)
- {
- // Nothing further to configure.
- }
- else if (TWP_KACWrapper.KACWrapper.NeedUpgrade)
- {
- if (GUILayout.Button(new GUIContent("You need a newer version of KAC", "Click to open your browser and download a newer Kerbal Alarm Clock"), Styles.styleTextCenterGreen))
- Application.OpenURL("https://forum.kerbalspaceprogram.com/index.php?/topic/22809--");
- }
- else if (!TWP_KACWrapper.KACWrapper.InstanceExists)
- {
- GUILayout.Label("KAC is not loaded in this scene, so we can't configure", Styles.styleTextGreen);
- GUILayout.Label("the integration options", Styles.styleTextGreen);
- GUILayout.Space(10);
- GUILayout.Label("You can access these in scenes where KAC is visible", Styles.styleTextGreen);
- GUILayout.Space(10);
- GUILayout.Label("Go on... Move along... Nothing to see...", Styles.styleTextGreen);
- }
- else
+ DrawLayoutArea(new Rect(20, 158, WindowWidth - 40, 44), () =>
{
- if (KACWrapper.KAC.DrawAlarmActionChoice(ref settings.KACAlarmAction, "Action:", 90 , 38))
+ if (KACWrapper.KAC.DrawAlarmActionChoice(ref settings.KACAlarmAction, "Action:", 90, 38))
settings.Save();
- }
+ });
}
- GUILayout.EndVertical();
}
- private void DrawWindow_Calendar()
+ private void DrawCalendar()
{
- //Update Check Area
- GUILayout.Label("General Settings", Styles.styleTextHeading);
-
- GUILayout.BeginVertical(Styles.styleSettingsArea);
-
- GUILayout.BeginHorizontal();
- GUILayout.BeginVertical(GUILayout.Width(60));
- GUILayout.Space(2); //to even up the text
- GUILayout.Label("Calendar:", Styles.styleTextHeading);
- GUILayout.EndVertical();
-
- GUILayout.BeginVertical();
- ddlSettingsCalendar.DrawButton();
- GUILayout.EndVertical();
- GUILayout.EndHorizontal();
- if (DrawToggle(ref settings.ShowCalendarToggle, "Show Calendar Toggle in Main Window", Styles.styleToggle))
+ GUI.Label(new Rect(10, 62, 160, 20), "General Settings", Styles.styleTextHeading);
+ GUI.Box(new Rect(10, 84, WindowWidth - 20, 58), "", Styles.styleSettingsArea);
+ GUI.Label(new Rect(20, 94, 70, 20), "Calendar:", Styles.styleTextHeading);
+ DrawDropDown(new Rect(94, 92, WindowWidth - 112, 22), ddlSettingsCalendar);
+
+ if (DrawToggleRect(new Rect(20, 118, 280, 20), ref settings.ShowCalendarToggle, "Show Calendar Toggle in Main Window", Styles.styleToggle))
settings.Save();
- GUILayout.EndVertical();
- if (settings.SelectedCalendar == CalendarTypeEnum.Earth)
- {
- GUILayout.Label("Earth Settings", Styles.styleTextHeading);
- GUILayout.BeginVertical(Styles.styleSettingsArea);
+ if (settings.SelectedCalendar != CalendarTypeEnum.Earth)
+ return;
- GUILayout.BeginHorizontal();
- GUILayout.Label("Earth Epoch:");
+ GUI.Label(new Rect(10, 152, 160, 20), "Earth Settings", Styles.styleTextHeading);
+ GUI.Box(new Rect(10, 174, WindowWidth - 20, 72), "", Styles.styleSettingsArea);
+ GUI.Label(new Rect(20, 184, 82, 20), "Earth Epoch:");
+ strEarthYear = GUI.TextField(new Rect(104, 182, 54, 22), strEarthYear ?? "", Styles.styleTextField);
+ strEarthMonth = GUI.TextField(new Rect(164, 182, 38, 22), strEarthMonth ?? "", Styles.styleTextField);
+ strEarthDay = GUI.TextField(new Rect(208, 182, 38, 22), strEarthDay ?? "", Styles.styleTextField);
- String strYear, strMonth, strDay;
- strYear = KSPDateStructure.CustomEpochEarth.Year.ToString();
- strMonth = KSPDateStructure.CustomEpochEarth.Month.ToString();
- strDay = KSPDateStructure.CustomEpochEarth.Day.ToString();
- if (TWPWindow.DrawYearMonthDay(ref strYear, ref strMonth, ref strDay))
- {
- try
- {
- KSPDateStructure.SetEarthCalendar(strYear.ToInt32(), strMonth.ToInt32(), strDay.ToInt32());
- settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("yyyy-MM-dd");
- settings.Save();
- mbTWP.windowMain.ResetWindow();
- }
- catch (Exception)
- {
- LogFormatted("Unable to set the Epoch date using the values provided-{0}-{1}-{2}", strYear, strMonth, strDay);
- }
- }
-
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- if (GUILayout.Button("Reset Earth Epoch"))
- {
- KSPDateStructure.SetEarthCalendar();
- settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("1951-01-01");
- settings.Save();
- }
- GUILayout.EndHorizontal();
+ if (GUI.Button(new Rect(254, 182, 42, 22), "Set"))
+ ApplyEarthEpochInput();
- GUILayout.EndVertical();
+ if (GUI.Button(new Rect(WindowWidth - 154, 214, 136, 22), "Reset Earth Epoch"))
+ {
+ KSPDateStructure.SetEarthCalendar();
+ settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("yyyy-MM-dd");
+ SyncEarthEpochInputs();
+ settings.Save();
+ mbTWP.windowMain.ResetWindow();
}
-
- //if RSS not installed and RSS chosen...
-
- ///section for custom stuff
}
- private void DrawWindow_About()
+
+ private void DrawAbout()
{
- //Update Check Area
- GUILayout.Label("Version Check", Styles.styleTextHeading);
-
- GUILayout.BeginVertical(Styles.styleSettingsArea);
- GUILayout.BeginHorizontal();
- GUILayout.BeginVertical();
- GUILayout.Space(3);
- if (DrawToggle(ref settings.DailyVersionCheck, "Check Version Daily", Styles.styleToggle))
+ GUI.Label(new Rect(10, 62, 160, 20), "Version Check", Styles.styleTextHeading);
+ GUI.Box(new Rect(10, 84, WindowWidth - 20, 116), "", Styles.styleSettingsArea);
+
+ if (DrawToggleRect(new Rect(20, 92, 170, 20), ref settings.DailyVersionCheck, "Check Version Daily", Styles.styleToggle))
settings.Save();
- GUILayout.EndVertical();
- GUILayout.FlexibleSpace();
- if (GUILayout.Button("Check Version Now"))
+
+ if (GUI.Button(new Rect(WindowWidth - 154, 92, 136, 22), "Check Version Now"))
{
settings.VersionCheck(mbTWP, true);
- //Hide the flag as we already have the window open;
settings.VersionAttentionFlag = false;
}
- GUILayout.EndHorizontal();
-
- GUILayout.BeginHorizontal();
- GUILayout.BeginVertical(GUILayout.Width(200));
- GUILayout.Space(4);
- GUILayout.Label("Last Check Attempt:");
- GUILayout.Label("Current Version:");
- GUILayout.Label("Last Version from Web:");
- GUILayout.EndVertical();
- GUILayout.BeginVertical();
- GUILayout.Label(settings.VersionCheckDate_AttemptString, Styles.styleTextGreen);
- GUILayout.Label(settings.Version, Styles.styleTextGreen);
+
+ GUI.Label(new Rect(20, 124, 150, 20), "Last Check Attempt:");
+ GUI.Label(new Rect(20, 144, 150, 20), "Current Version:");
+ GUI.Label(new Rect(20, 164, 150, 20), "Last Version from Web:");
+ GUI.Label(new Rect(176, 124, WindowWidth - 196, 20), settings.VersionCheckDate_AttemptString, Styles.styleTextGreen);
+ GUI.Label(new Rect(176, 144, WindowWidth - 196, 20), settings.Version, Styles.styleTextGreen);
if (settings.VersionCheckRunning)
{
Int32 intDots = Convert.ToInt32(Math.Truncate(DateTime.Now.Millisecond / 250d)) + 1;
- GUILayout.Label(String.Format("{0} Checking", new String('.', intDots)), Styles.styleTextYellowBold);
+ GUI.Label(new Rect(176, 164, WindowWidth - 196, 20), String.Format("{0} Checking", new String('.', intDots)), Styles.styleTextYellowBold);
}
else
{
- if (settings.VersionAvailable)
- GUILayout.Label(String.Format("{0} @ {1}", settings.VersionWeb, settings.VersionCheckDate_SuccessString), Styles.styleTextYellowBold);
- else
- GUILayout.Label(String.Format("{0} @ {1}", settings.VersionWeb, settings.VersionCheckDate_SuccessString), Styles.styleTextGreen);
+ GUIStyle style = settings.VersionAvailable ? Styles.styleTextYellowBold : Styles.styleTextGreen;
+ GUI.Label(new Rect(176, 164, WindowWidth - 196, 20), String.Format("{0} @ {1}", settings.VersionWeb, settings.VersionCheckDate_SuccessString), style);
}
- GUILayout.EndVertical();
- GUILayout.EndHorizontal();
if (settings.VersionAvailable)
{
- GUILayout.BeginHorizontal();
- GUILayout.Space(80);
- if (GUILayout.Button("Updated Version Available - Click Here", Styles.styleTextYellowBold))
+ if (GUI.Button(new Rect(70, 176, WindowWidth - 140, 22), "Updated Version Available - Click Here", Styles.styleTextYellowBold))
Application.OpenURL("https://github.com/Nazfib/TransferWindowPlanner/releases");
- GUILayout.EndHorizontal();
}
- GUILayout.EndVertical();
-
-
- //About Area
- GUILayout.BeginVertical(Styles.styleSettingsArea);
- GUILayout.BeginHorizontal();
- GUILayout.BeginVertical();
- //GUILayout.Label("Written by:", Styles.styleStageTextHead);
- //GUILayout.Label("Documentation and Links:", Styles.styleTextHeading);
- GUILayout.Label("GitHub Page:", Styles.styleTextHeading);
- //GUILayout.Label("Forum Page:", Styles.styleTextHeading);
- GUILayout.EndVertical();
-
- GUILayout.BeginVertical();
- //GUILayout.Label("Trigger Au",KACResources.styleContent);
- //if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
- // Application.OpenURL("http://triggerau.github.io/TransferWindowPlanner/");
- if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
+
+ GUI.Box(new Rect(10, 214, WindowWidth - 20, 48), "", Styles.styleSettingsArea);
+ GUI.Label(new Rect(20, 228, 100, 20), "GitHub Page:", Styles.styleTextHeading);
+ if (GUI.Button(new Rect(128, 226, 120, 22), "Click Here", Styles.styleTextCenterGreen))
Application.OpenURL("http://github.com/Nazfib/TransferWindowPlanner/");
- //if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
- // Application.OpenURL("http://forum.kerbalspaceprogram.com/threads/93115-Transfer-Window-Planner");
+ }
- GUILayout.EndVertical();
+ private void DrawDropDown(Rect rect, DropDownList ddl)
+ {
+ ddl.SetListBoxOffset(new Vector2(rect.x, rect.y));
+ GUILayout.BeginArea(rect);
+ ddl.DrawButton();
+ GUILayout.EndArea();
+ }
- GUILayout.EndHorizontal();
+ private void DrawLayoutArea(Rect rect, Action draw)
+ {
+ GUILayout.BeginArea(rect);
+ draw();
+ GUILayout.EndArea();
+ }
- GUILayout.EndVertical();
+ private Boolean DrawToggleRect(Rect rect, ref Boolean value, String text, GUIStyle style)
+ {
+ Boolean oldValue = value;
+ value = GUI.Toggle(rect, value, text, style);
+ return oldValue != value;
+ }
+
+ private void UpdateWindowSize()
+ {
+ WindowHeight = GetWindowHeightForSelectedTab();
+ WindowRect.width = WindowWidth;
+ WindowRect.height = WindowHeight;
+ WindowOptions = new GUILayoutOption[] {
+ GUILayout.Width(WindowWidth),
+ GUILayout.Height(WindowHeight)
+ };
+ }
+
+ private Int32 GetWindowHeightForSelectedTab()
+ {
+ switch ((SettingsTabs)ddlSettingsTab.SelectedIndex)
+ {
+ case SettingsTabs.General:
+ return 280;
+ case SettingsTabs.AlarmIntegration:
+ return 220;
+ case SettingsTabs.Calendar:
+ return settings.SelectedCalendar == CalendarTypeEnum.Earth ? 255 : 150;
+ case SettingsTabs.About:
+ return 285;
+ default:
+ return 280;
+ }
+ }
+
+ private void SyncInputFields()
+ {
+ strGuiScale = Settings.NormalizeGuiScale(settings.GuiScale).ToString("0.0", CultureInfo.InvariantCulture);
+ strAlarmMargin = settings.AlarmMargin.ToString(CultureInfo.InvariantCulture);
+ SyncEarthEpochInputs();
+ }
+
+ private void SyncEarthEpochInputs()
+ {
+ strEarthYear = KSPDateStructure.CustomEpochEarth.Year.ToString();
+ strEarthMonth = KSPDateStructure.CustomEpochEarth.Month.ToString();
+ strEarthDay = KSPDateStructure.CustomEpochEarth.Day.ToString();
+ }
+
+ private void ApplyGuiScaleInput()
+ {
+ Single parsed;
+ if (!Single.TryParse(strGuiScale, NumberStyles.Float, CultureInfo.InvariantCulture, out parsed) &&
+ !Single.TryParse(strGuiScale, out parsed))
+ {
+ parsed = settings.GuiScale;
+ }
+
+ settings.GuiScale = Settings.NormalizeGuiScale(parsed);
+ strGuiScale = settings.GuiScale.ToString("0.0", CultureInfo.InvariantCulture);
+ settings.Save();
+ mbTWP.ApplyWindowGuiScale();
+ }
+
+ private void ApplyAlarmMarginInput()
+ {
+ Double parsed;
+ if (!Double.TryParse(strAlarmMargin, NumberStyles.Float, CultureInfo.InvariantCulture, out parsed) &&
+ !Double.TryParse(strAlarmMargin, out parsed))
+ {
+ strAlarmMargin = settings.AlarmMargin.ToString(CultureInfo.InvariantCulture);
+ return;
+ }
+
+ settings.AlarmMargin = parsed;
+ strAlarmMargin = settings.AlarmMargin.ToString(CultureInfo.InvariantCulture);
+ settings.Save();
+ }
+
+ private void ApplyEarthEpochInput()
+ {
+ try
+ {
+ KSPDateStructure.SetEarthCalendar(strEarthYear.ToInt32(), strEarthMonth.ToInt32(), strEarthDay.ToInt32());
+ settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("yyyy-MM-dd");
+ SyncEarthEpochInputs();
+ settings.Save();
+ mbTWP.windowMain.ResetWindow();
+ }
+ catch (Exception)
+ {
+ LogFormatted("Unable to set the Epoch date using the values provided-{0}-{1}-{2}", strEarthYear, strEarthMonth, strEarthDay);
+ }
}
}
}
diff --git a/TransferWindowPlanner/TransferWindowPlanner.csproj b/TransferWindowPlanner/TransferWindowPlanner.csproj
index f8df682..5898fe9 100644
--- a/TransferWindowPlanner/TransferWindowPlanner.csproj
+++ b/TransferWindowPlanner/TransferWindowPlanner.csproj
@@ -23,35 +23,35 @@
- $(KSPDir)\KSP_Data\Managed\Assembly-CSharp.dll
+ $(KSPDir)\KSP_x64_Data\Managed\Assembly-CSharp.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.AnimationModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.AnimationModule.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.CoreModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.ImageConversionModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.ImageConversionModule.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.IMGUIModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.IMGUIModule.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.TextRenderingModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.TextRenderingModule.dll
False
- $(KSPDir)\KSP_Data\Managed\UnityEngine.UnityWebRequestModule.dll
+ $(KSPDir)\KSP_x64_Data\Managed\UnityEngine.UnityWebRequestModule.dll
False
diff --git a/TransferWindowPlanner/TransferWindowPlanner.sln b/TransferWindowPlanner/TransferWindowPlanner.sln
deleted file mode 100644
index d8c32a9..0000000
--- a/TransferWindowPlanner/TransferWindowPlanner.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransferWindowPlanner", "TransferWindowPlanner.csproj", "{942B92F0-C682-424E-814E-C2DDD1E84E2F}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KSPDateTimeUnitTests", "..\KSPDateTimeUnitTests\KSPDateTimeUnitTests.csproj", "{5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {942B92F0-C682-424E-814E-C2DDD1E84E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {942B92F0-C682-424E-814E-C2DDD1E84E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {942B92F0-C682-424E-814E-C2DDD1E84E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {942B92F0-C682-424E-814E-C2DDD1E84E2F}.Release|Any CPU.Build.0 = Release|Any CPU
- {5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5EB393E9-C2DA-469B-AAC6-E89032EFB4D4}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/TransferWindowPlanner/TransferWindowPlanner.version b/TransferWindowPlanner/TransferWindowPlanner.version
deleted file mode 100644
index e9aee56..0000000
--- a/TransferWindowPlanner/TransferWindowPlanner.version
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "NAME": "Transfer Window Planner",
- "URL": "https://raw.githubusercontent.com/Nazfib/TransferWindowPlanner/master/TransferWindowPlanner/TransferWindowPlanner.version",
- "DOWNLOAD" : "https://github.com/Nazfib/TransferWindowPlanner/releases",
- "VERSION": {
- "MAJOR": 1,
- "MINOR": 9,
- "PATCH": 1,
- "BUILD": 1
- },
- "KSP_VERSION": {
- "MAJOR": 1,
- "MINOR": 12,
- "PATCH": 5
- },
- "KSP_VERSION_MIN": {
- "MAJOR": 1,
- "MINOR": 12,
- "PATCH": 0
- },
- "KSP_VERSION_MAX": {
- "MAJOR": 1,
- "MINOR": 12,
- "PATCH": 99
- }
-}