diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..7e9a359
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,8 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: linuxgurugamer
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+custom: # Replace with a single custom sponsorship URL
diff --git a/.gitignore b/.gitignore
index bc9beab..9632972 100644
--- a/.gitignore
+++ b/.gitignore
@@ -237,3 +237,5 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
+*.dll
+.vs
diff --git a/.vs/BetterTimeWarp/v15/sqlite3/storage.ide b/.vs/BetterTimeWarp/v15/sqlite3/storage.ide
new file mode 100644
index 0000000..6090308
Binary files /dev/null and b/.vs/BetterTimeWarp/v15/sqlite3/storage.ide differ
diff --git a/BetterTimeWarp.sln b/BetterTimeWarp.sln
new file mode 100644
index 0000000..ece6b08
--- /dev/null
+++ b/BetterTimeWarp.sln
@@ -0,0 +1,45 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35312.102
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterTimeWarp", "BetterTimeWarp\BetterTimeWarp.csproj", "{4B05E220-5E03-4B86-8896-B407D71F6A99}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EED9A79F-353B-4B90-82CC-5993F6309EB2}"
+ ProjectSection(SolutionItems) = preProject
+ BetterTimeWarp.version = BetterTimeWarp.version
+ buildRelease.bat = buildRelease.bat
+ Changelog.txt = Changelog.txt
+ deploy.bat = deploy.bat
+ disabledjenkins-173.txt = disabledjenkins-173.txt
+ jenkins.txt = jenkins.txt
+ Readme.md = Readme.md
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterTimeWarp-1.7.3", "BetterTimeWarp\BetterTimeWarp-1.7.3.csproj", "{62D14DDB-989F-4A68-B0E1-116205567669}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4B05E220-5E03-4B86-8896-B407D71F6A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4B05E220-5E03-4B86-8896-B407D71F6A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4B05E220-5E03-4B86-8896-B407D71F6A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4B05E220-5E03-4B86-8896-B407D71F6A99}.Release|Any CPU.Build.0 = Release|Any CPU
+ {62D14DDB-989F-4A68-B0E1-116205567669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {62D14DDB-989F-4A68-B0E1-116205567669}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {62D14DDB-989F-4A68-B0E1-116205567669}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {62D14DDB-989F-4A68-B0E1-116205567669}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {810F748F-F815-46ED-896D-AE3FDB527D8B}
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = BetterTimeWarp.csproj
+ EndGlobalSection
+EndGlobal
diff --git a/BetterTimeWarp.version b/BetterTimeWarp.version
new file mode 100644
index 0000000..3e46df0
--- /dev/null
+++ b/BetterTimeWarp.version
@@ -0,0 +1,30 @@
+{
+ "NAME": "BetterTimeWarpContinued",
+ "URL": "https://raw.githubusercontent.com/linuxgurugamer/BetterTimeWarpContinued/refs/heads/master/BetterTimeWarp.version",
+ "DOWNLOAD": "https://github.com/linuxgurugamer/BetterTimeWarpContinued/releases",
+ "GITHUB": {
+ "USERNAME": "linuxgurugamer",
+ "REPOSITORY": "BetterTimeWarpContinued"
+ },
+ "VERSION": {
+ "MAJOR": 2,
+ "MINOR": 3,
+ "PATCH": 14,
+ "BUILD": 1
+ },
+ "KSP_VERSION": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 4
+ },
+ "KSP_VERSION_MIN": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 0
+ },
+ "KSP_VERSION_MAX": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 99
+ }
+}
diff --git a/.gitattributes b/BetterTimeWarp/.gitattributes
similarity index 100%
rename from .gitattributes
rename to BetterTimeWarp/.gitattributes
diff --git a/BetterTimeWarp/.vs/BetterTimeWarp/v15/sqlite3/storage.ide b/BetterTimeWarp/.vs/BetterTimeWarp/v15/sqlite3/storage.ide
new file mode 100644
index 0000000..d62d3ab
Binary files /dev/null and b/BetterTimeWarp/.vs/BetterTimeWarp/v15/sqlite3/storage.ide differ
diff --git a/BetterTimeWarp/.vs/config/applicationhost.config b/BetterTimeWarp/.vs/config/applicationhost.config
new file mode 100644
index 0000000..b42cd34
--- /dev/null
+++ b/BetterTimeWarp/.vs/config/applicationhost.config
@@ -0,0 +1,1030 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BetterTimeWarp/AssemblyVersion.173.cs b/BetterTimeWarp/AssemblyVersion.173.cs
new file mode 100644
index 0000000..560aaea
--- /dev/null
+++ b/BetterTimeWarp/AssemblyVersion.173.cs
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ // This code was generated by a tool. Any changes made manually will be lost
+ // the next time this code is regenerated.
+ //
+
+ using System.Reflection;
+
+ [assembly: AssemblyVersion("2.3.11.6")]
\ No newline at end of file
diff --git a/BetterTimeWarp/AssemblyVersion.173.tt b/BetterTimeWarp/AssemblyVersion.173.tt
new file mode 100644
index 0000000..02f7c19
--- /dev/null
+++ b/BetterTimeWarp/AssemblyVersion.173.tt
@@ -0,0 +1,99 @@
+<#@ template debug="false" hostspecific="true" language="C#" #>
+<#@ import namespace="System.IO" #>
+<#@ output extension=".cs" #>
+
+<#@ assembly name="EnvDTE" #><# /* This assembly provides access to Visual Studio project properties. */ #>
+<#
+
+ // Instructions
+ // 1. Add a new Text Template to the project
+ // 2. Copy this file into the new template
+ // 3. Update the string: versionfile with the complete path to the .version file
+ // 4. Remove the following line from the file AssemblyInfo.cs (usually located in the "Property" folder inside your C# project):
+ // [assembly: AssemblyFileVersion("1.0.0.0")]
+ // 5. Add the following to the PreBuild steps:
+ // set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
+ //
+ // if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
+ //
+ // %textTemplatingPath% "$(ProjectDir)AssemblyVersion.tt"
+
+ int major = 0;
+ int minor = 0;
+ int build = 0;
+ int patch = 0;
+ bool versionSection = false;
+ int i = 0;
+ int i2 = 0;
+ string s;
+
+ // For Visual Studio / MSBuild Build-Time Template Resolution
+ string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";
+
+ //
+ // Update the following with the name of the .version file which is in the root directory
+ //
+ string versionfile = RootDirectory + "BetterTimeWarp.173.version";
+
+ if (!File.Exists(versionfile))
+ {
+ Write("File: " + versionfile + " missing\n");
+ }
+
+ try
+ {
+ foreach (var line in File.ReadAllLines(versionfile))
+ {
+ if (line != null)
+ {
+ if (!versionSection)
+ {
+ if (line.Contains("\"VERSION\""))
+ versionSection = true;
+ }
+ else
+ {
+ if (line.Contains("}"))
+ versionSection = false;
+ i = line.IndexOf(":");
+ i2 = line.IndexOf(",");
+ if (i2 == -1)
+ i2 = line.Length;
+ if (i >= 0 && i2 >= 0)
+ {
+ s = line.Substring(i + 1, i2 - i - 1);
+
+ if (line.Contains("MAJOR"))
+ Int32.TryParse(s, out major);
+
+ if (line.Contains("MINOR"))
+ Int32.TryParse(s, out minor);
+
+ if (line.Contains("PATCH"))
+ Int32.TryParse(s, out patch);
+
+ if (line.Contains("BUILD"))
+ Int32.TryParse(s, out build);
+ }
+ }
+ }
+ }
+
+ }
+ catch
+ {
+ major = 1;
+ minor = 0;
+ patch = 0;
+ build = 0;
+ }
+ //Write("File done");
+
+ #>
+ // This code was generated by a tool. Any changes made manually will be lost
+ // the next time this code is regenerated.
+ //
+
+ using System.Reflection;
+
+ [assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
\ No newline at end of file
diff --git a/BetterTimeWarp/AssemblyVersion.cs b/BetterTimeWarp/AssemblyVersion.cs
new file mode 100644
index 0000000..7185b6a
--- /dev/null
+++ b/BetterTimeWarp/AssemblyVersion.cs
@@ -0,0 +1,9 @@
+
+ // This code was generated by a tool. Any changes made manually will be lost
+ // the next time this code is regenerated.
+ //
+
+ using System.Reflection;
+
+ [assembly: AssemblyVersion("2.3.12.9")]
+ [assembly: AssemblyFileVersion("2.3.12.9")]
diff --git a/BetterTimeWarp/AssemblyVersion.tt b/BetterTimeWarp/AssemblyVersion.tt
new file mode 100644
index 0000000..8167261
--- /dev/null
+++ b/BetterTimeWarp/AssemblyVersion.tt
@@ -0,0 +1,100 @@
+<#@ template debug="false" hostspecific="true" language="C#" #>
+<#@ import namespace="System.IO" #>
+<#@ output extension=".cs" #>
+
+<#@ assembly name="EnvDTE" #><# /* This assembly provides access to Visual Studio project properties. */ #>
+<#
+
+ // Instructions
+ // 1. Add a new Text Template to the project
+ // 2. Copy this file into the new template
+ // 3. Update the string: versionfile with the complete path to the .version file
+ // 4. Remove the following line from the file AssemblyInfo.cs (usually located in the "Property" folder inside your C# project):
+ // [assembly: AssemblyFileVersion("1.0.0.0")]
+ // 5. Add the following to the PreBuild steps:
+ // set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
+ //
+ // if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
+ //
+ // %textTemplatingPath% "$(ProjectDir)AssemblyVersion.tt"
+
+ int major = 0;
+ int minor = 0;
+ int build = 0;
+ int patch = 0;
+ bool versionSection = false;
+ int i = 0;
+ int i2 = 0;
+ string s;
+
+ // For Visual Studio / MSBuild Build-Time Template Resolution
+ string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";
+
+ //
+ // Update the following with the name of the .version file which is in the root directory
+ //
+ string versionfile = RootDirectory + "BetterTimeWarp.version";
+
+ if (!File.Exists(versionfile))
+ {
+ Write("File: " + versionfile + " missing\n");
+ }
+
+ try
+ {
+ foreach (var line in File.ReadAllLines(versionfile))
+ {
+ if (line != null)
+ {
+ if (!versionSection)
+ {
+ if (line.Contains("\"VERSION\""))
+ versionSection = true;
+ }
+ else
+ {
+ if (line.Contains("}"))
+ versionSection = false;
+ i = line.IndexOf(":");
+ i2 = line.IndexOf(",");
+ if (i2 == -1)
+ i2 = line.Length;
+ if (i >= 0 && i2 >= 0)
+ {
+ s = line.Substring(i + 1, i2 - i - 1);
+
+ if (line.Contains("MAJOR"))
+ Int32.TryParse(s, out major);
+
+ if (line.Contains("MINOR"))
+ Int32.TryParse(s, out minor);
+
+ if (line.Contains("PATCH"))
+ Int32.TryParse(s, out patch);
+
+ if (line.Contains("BUILD"))
+ Int32.TryParse(s, out build);
+ }
+ }
+ }
+ }
+
+ }
+ catch
+ {
+ major = 1;
+ minor = 0;
+ patch = 0;
+ build = 0;
+ }
+ //Write("File done");
+
+ #>
+ // This code was generated by a tool. Any changes made manually will be lost
+ // the next time this code is regenerated.
+ //
+
+ using System.Reflection;
+
+ [assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
+ [assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
diff --git a/BetterTimeWarp/BetterTimeWarp-1.7.3.csproj b/BetterTimeWarp/BetterTimeWarp-1.7.3.csproj
new file mode 100644
index 0000000..43f1c1d
--- /dev/null
+++ b/BetterTimeWarp/BetterTimeWarp-1.7.3.csproj
@@ -0,0 +1,104 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {62D14DDB-989F-4A68-B0E1-116205567669}
+ Library
+ BetterTimeWarp
+ BetterTimeWarp
+ 1.0.0.0
+ false
+ v3.5
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+ full
+ true
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+ True
+ True
+ AssemblyVersion.173.tt
+
+
+
+
+
+
+
+
+
+
+
+ TextTemplatingFileGenerator
+ AssemblyVersion.173.cs
+
+
+
+
+
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll
+
+
+
+ R:\KSP_1.7.3_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll
+
+
+
+
+
+set textTemplatingPath="%25ProgramFiles(x86)%25\Microsoft Visual Studio\2017\Community\Common7\IDE\texttransform.exe"
+
+
+
+%25textTemplatingPath%25 "$(ProjectDir)AssemblyVersion.173.tt"
+
+
+
+
+start /D D:\Users\jbb\github\BetterTimeWarp /WAIT deploy.bat $(TargetDir) $(TargetFileName)
+
+if $(ConfigurationName) == Release (
+ start /D D:\Users\jbb\github\BetterTimeWarp /WAIT buildRelease.bat $(TargetDir) $(TargetFileName)
+)
+
+
+
\ No newline at end of file
diff --git a/BetterTimeWarp/BetterTimeWarp.cs b/BetterTimeWarp/BetterTimeWarp.cs
index 9a7bf75..b48ceb6 100644
--- a/BetterTimeWarp/BetterTimeWarp.cs
+++ b/BetterTimeWarp/BetterTimeWarp.cs
@@ -1,724 +1,1025 @@
+using ClickThroughFix;
+using CommNet;
+using KSP.UI.Screens;
+using KSP.UI.Screens.Flight;
using System;
-using System.Linq;
using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using ToolbarControl_NS;
using UnityEngine;
namespace BetterTimeWarp
{
- public class BetterTimeWarp : MonoBehaviour
- {
- public static BetterTimeWarp Instance;
- public static TimeWarpRates StandardWarp = new TimeWarpRates("Standard Warp", new float[]{1f, 5f, 10f, 50f, 100f, 1000f, 10000f, 100000f}, false);
- public static TimeWarpRates StandardPhysWarp = new TimeWarpRates("Standard Physics Warp", new float[]{1f, 2f, 3f, 4f}, true);
- public static bool isEnabled = true;
- public static ConfigNode SettingsNode;
-
- public List customWarps = new List ();
- public static bool ShowUI = true;
-
- public static bool UIOpen
- {
- get
- {
- return Instance.windowOpen;
- }
- set
- {
- Instance.windowOpen = value;
- }
- }
- public ApplicationLauncherButton Button;
- private static bool hasFalsedRecently = false;
- private static bool isHovering = false;
- private static bool hasAdded = false;
-
- static Texture2D upArrow;
- static Texture2D downArrow;
-
- public void Start()
- {
- if (!isEnabled)
- {
- Debug.LogError ("[BetterTimeWarp]: enabled = false in settings, disabling BetterTimeWarp");
- DestroyImmediate (this);
- return;
- }
-
- this.skin = HighLogic.Skin;
-
- LoadCustomWarpRates ();
-
- SetWarpRates (CurrentWarp, false);
- SetWarpRates (CurrentPhysWarp, false);
-
- windowStyle = new GUIStyle(skin.window);
- windowStyle.padding.left = 5;
- windowStyle.padding.right = 5;
- windowStyle.padding.top = 5;
- windowStyle.padding.bottom = 5;
- smallButtonStyle = new GUIStyle (skin.button);
- smallButtonStyle.stretchHeight = false;
- smallButtonStyle.fixedHeight = 20f;
-
- smallScrollBar = new GUIStyle (skin.verticalScrollbar);
- smallScrollBar.fixedWidth = 8f;
- hSmallScrollBar = new GUIStyle (skin.horizontalScrollbar);
- hSmallScrollBar.fixedHeight = 0f;
-
- upArrow = GameDatabase.Instance.GetTexture ("BetterTimeWarp/Icons/up", false);
- downArrow = GameDatabase.Instance.GetTexture ("BetterTimeWarp/Icons/down", false);
-
- upContent = new GUIContent ("", upArrow, "");
- downContent = new GUIContent ("", downArrow, "");
- buttonContent = downContent;
-
- GameEvents.onGameStateSave.Add (SaveSettingsAndCrap);
-
- //add the toolbar button to non-flight scenes
- if(!hasAdded)
- {
- var buttonTexture = GameDatabase.Instance.GetTexture ("BetterTimeWarp/Icons/application", false);
- Button = ApplicationLauncher.Instance.AddModApplication (
- new RUIToggleButton.OnTrue(delegate
- {
- BetterTimeWarp.UIOpen = true;
- }),
- new RUIToggleButton.OnFalse(delegate
- {
- if(!isHovering)
- BetterTimeWarp.UIOpen = false;
-
- /*
- * this fixes some finicky button behaviour, it just prevents the OnHover/OnHoverOut events
- * from being automatically called after clicking it to false
- */
- if(isHovering)
- hasFalsedRecently = true;
- }),
- new RUIToggleButton.OnHover(delegate
- {
- if(!hasFalsedRecently)
- BetterTimeWarp.UIOpen = true;
- isHovering = true;
-
- //reset finicky button fix so it can run again
- hasFalsedRecently = false;
- }),
- new RUIToggleButton.OnHoverOut(delegate
- {
- isHovering = false;
- //only hide it if we haven't clicked
- if(Button.State != RUIToggleButton.ButtonState.TRUE && !hasFalsedRecently)
- {
- BetterTimeWarp.UIOpen = false;
- }
- }),
- null, null, ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.TRACKSTATION, buttonTexture
- );
- ApplicationLauncher.Instance.EnableMutuallyExclusive (Button);
- hasAdded = true;
- }
- }
- void OnDestroy()
- {
- GameEvents.onGameStateSave.Remove (SaveSettingsAndCrap);
- }
- void SaveSettingsAndCrap(ConfigNode node) //lel
- {
- SaveCustomWarpRates ();
- }
- void CreateRectangles()
- {
- if (HighLogic.LoadedSceneIsFlight)
- {
- quikWindowRect = new Rect (153f * ScreenSafeUI.PixelRatio, 20f, 200f, 410f);
- advWindowRect = new Rect (153f * ScreenSafeUI.PixelRatio, 20f, 420f, 410f);
- physSettingsRect = new Rect (153f * ScreenSafeUI.PixelRatio, 430f, 420f, 220f);
- }
- else
- {
- quikWindowRect = new Rect ((Screen.width - 205f), 40f, 200f, 410f);
- advWindowRect = new Rect ((Screen.width - 425f), 40f, 420f, 410f);
- physSettingsRect = new Rect ((Screen.width - 425f), 450f, 420f, 220f);
- }
- }
-
- //physics settings
- public bool ScaleCameraSpeed = true;
- public bool UseLosslessPhysics = false;
- public float LosslessUpperThreshold = 2f;
-
- GUISkin skin;
-
- Rect advWindowRect = new Rect();
- Rect physSettingsRect = new Rect();
- GUIContent buttonContent;
- GUIContent upContent;
- GUIContent downContent;
-
- bool advWindowOpen = false;
- bool windowOpen = false;
- Rect quikWindowRect = new Rect();
- GUIStyle windowStyle;
- GUIStyle smallButtonStyle;
- GUIStyle smallScrollBar;
- GUIStyle hSmallScrollBar;
-
- public void OnGUI()
- {
- if (HighLogic.LoadedScene == GameScenes.LOADINGBUFFER)
- return;
-
- if (ShowUI)
- {
- GUI.skin = skin;
-
- CreateRectangles ();
-
- //flight
- if (HighLogic.LoadedSceneIsFlight)
- {
- windowOpen = GUI.Toggle (new Rect (153f * ScreenSafeUI.PixelRatio, 0f, 20f, 20f), windowOpen, buttonContent, skin.button);
- }
- if (windowOpen)
- {
- if(!advWindowOpen)
- GUI.Window (60371, quikWindowRect, QuikWarpWindow, "", windowStyle);
- else
- {
- GUI.Window (60372, advWindowRect, TimeWarpWindow, "", windowStyle);
- if (showPhysicsSettings)
- {
- GUI.Window (60373, physSettingsRect, PhysicsSettingsWindow, "", windowStyle);
- }
- }
-
- buttonContent = upContent;
- }
- else
- buttonContent = downContent;
- }
- }
-
- bool editToggle = false;
- Vector2 scrollPos = new Vector2 (0f, 0f);
- Vector2 scrollPos2 = new Vector2 (0f, 0f);
-
- string warpName = "Name";
- bool physics = false;
- string w1 = "10";
- string w2 = "100";
- string w3 = "1000";
- string w4 = "10000";
- string w5 = "100000";
- string w6 = "1000000";
- string w7 = "10000000";
-
- TimeWarpRates currentRates = StandardWarp;
- int selected = 0;
-
- TimeWarpRates CurrentWarp;
- TimeWarpRates CurrentPhysWarp;
- int currWarpIndex = 0;
- int currPhysIndex = 0;
-
- List warpNames = new List ();
- TimeWarpRates[] warpRates = new TimeWarpRates[]{};
- List physNames = new List ();
- TimeWarpRates[] physRates = new TimeWarpRates[]{};
- void Update()
- {
- warpNames.Clear ();
- physNames.Clear ();
- warpRates = customWarps.Where (r => !r.Physics).ToArray();
- physRates = customWarps.Where (r => r.Physics).ToArray();
-
- foreach (var rates in customWarps)
- {
- string sB = "";
- string sA = "";
- if (rates == CurrentWarp || rates == CurrentPhysWarp)
- {
- sB = "";
- sA = "";
- }
-
- if (rates.Physics)
- physNames.Add (sB + rates.Name + sA);
- else
- warpNames.Add (sB + rates.Name + sA);
- }
-
- names = warpNames.Concat (physNames).ToArray();
-
- //make camera speed not change with time warp
- if(ScaleCameraSpeed && Time.timeScale < 1f)
- FlightCamera.fetch.SetDistanceImmediate (FlightCamera.fetch.Distance);
-
- var mouse = Mouse.screenPos;
- if ((windowOpen && !advWindowOpen && quikWindowRect.Contains (mouse)) ||
- (windowOpen && advWindowOpen && advWindowRect.Contains (mouse)) ||
- (windowOpen && advWindowOpen && showPhysicsSettings && physSettingsRect.Contains (mouse))
- )
- {
- InputLockManager.SetControlLock (ControlTypes.CAMERACONTROLS | ControlTypes.ALL_SHIP_CONTROLS, "BetterTimeWarp_UIHover_Lock");
- }
- else
- InputLockManager.RemoveControlLock ("BetterTimeWarp_UIHover_Lock");
- }
-
- public void QuikWarpWindow(int id)
- {
- GUILayout.BeginVertical ();
-
- scrollPos = GUILayout.BeginScrollView (scrollPos, false, false, hSmallScrollBar, smallScrollBar);
-
- currWarpIndex = GUILayout.SelectionGrid (currWarpIndex, warpNames.ToArray(), 1, smallButtonStyle);
- GUILayout.Space (20f);
- currPhysIndex = GUILayout.SelectionGrid (currPhysIndex, physNames.ToArray(), 1, smallButtonStyle);
-
- if (warpRates [currWarpIndex] != CurrentWarp)
- {
- SetWarpRates (warpRates [currWarpIndex]);
- }
- if (physRates [currPhysIndex] != CurrentPhysWarp)
- {
- SetWarpRates (physRates [currPhysIndex]);
- }
-
- GUILayout.EndScrollView ();
-
- if (GUILayout.Button ("Advanced"))
- {
- advWindowOpen = true;
- }
-
- GUILayout.EndVertical ();
- }
-
- bool showPhysicsSettings = false;
- string labelColor = "#b7fe00";
-
- string[] names = new string[]{};
- public void TimeWarpWindow(int id)
- {
- GUILayout.BeginHorizontal ();
- GUILayout.BeginVertical ();
-
- scrollPos = GUILayout.BeginScrollView (scrollPos);
-
- editToggle = GUILayout.Toggle (editToggle, "Create", skin.button);
- selected = GUILayout.SelectionGrid (selected, names, 1, smallButtonStyle);
- currentRates = customWarps.Find (r => r.Name == names [selected] || names[selected].Split('<', '>').Contains(r.Name));
- if (currentRates == null)
- currentRates = StandardWarp;
-
- GUILayout.EndScrollView ();
-
- GUILayout.EndVertical ();
-
- GUILayout.BeginVertical ();
- scrollPos2 = GUILayout.BeginScrollView (scrollPos2);
-
- if (editToggle)
- {
- GUILayout.BeginVertical (GUILayout.ExpandHeight(true));
-
- bool canExport = true;
- warpName = GUILayout.TextField (warpName);
- w1 = GUILayout.TextField (w1);
- w2 = GUILayout.TextField (w2);
- w3 = GUILayout.TextField (w3);
- if (!physics)
- {
- w4 = GUILayout.TextField (w4);
- w5 = GUILayout.TextField (w5);
- w6 = GUILayout.TextField (w6);
- w7 = GUILayout.TextField (w7);
- }
- physics = GUILayout.Toggle (physics, "Physics Warp?");
-
- GUILayout.EndVertical ();
-
- if (GUILayout.Button ("Save"))
- {
- float[] rates;
- if (physics)
- rates = new float[4];
- else
- rates = new float[8];
-
- rates [0] = 1f;
- float pw1;
- if(float.TryParse(w1, out pw1))
- rates [1] = pw1;
- else
- canExport = false;
- float pw2;
- if(float.TryParse(w2, out pw2))
- rates [2] = pw2;
- else
- canExport = false;
- float pw3;
- if(float.TryParse(w3, out pw3))
- rates [3] = pw3;
- else
- canExport = false;
- if (!physics)
- {
- float pw4;
- if (float.TryParse (w4, out pw4))
- rates [4] = pw4;
- else
- canExport = false;
- float pw5;
- if (float.TryParse (w5, out pw5))
- rates [5] = pw5;
- else
- canExport = false;
- float pw6;
- if (float.TryParse (w6, out pw6))
- rates [6] = pw6;
- else
- canExport = false;
- float pw7;
- if (float.TryParse (w7, out pw7))
- rates [7] = pw7;
- else
- canExport = false;
- }
- if (canExport)
- {
- TimeWarpRates timeWarpRates = new TimeWarpRates (warpName, rates, physics);
- customWarps.Add (timeWarpRates);
- SaveCustomWarpRates ();
- editToggle = false;
- //SetWarpRates (timeWarpRates);
- warpName = "Name";
- physics = false;
- w1 = "10";
- w2 = "100";
- w3 = "1000";
- w4 = "10000";
- w5 = "100000";
- w6 = "1000000";
- w7 = "10000000";
- }
- else
- {
- PopupDialog.SpawnPopupDialog ("Error", "Cannot save because there are non-numbers in the editing fields", "Ok", false, skin);
- }
- }
- if (GUILayout.Button ("Cancel", smallButtonStyle))
- {
- editToggle = false;
- warpName = "Name";
- physics = false;
- w1 = "10";
- w2 = "100";
- w3 = "1000";
- w4 = "10000";
- w5 = "100000";
- w6 = "1000000";
- w7 = "10000000";
- }
- }
- else
- {
- GUILayout.BeginVertical (GUILayout.ExpandHeight(true));
- GUILayout.Label ("1: " + currentRates.Rates [0].ToString () + "x");
- GUILayout.Label ("2: " + currentRates.Rates [1].ToString () + "x");
- GUILayout.Label ("3: " + currentRates.Rates [2].ToString () + "x");
- GUILayout.Label ("4: " + currentRates.Rates [3].ToString () + "x");
- if (!currentRates.Physics)
- {
- GUILayout.Label ("5: " + currentRates.Rates [4].ToString () + "x");
- GUILayout.Label ("6: " + currentRates.Rates [5].ToString () + "x");
- GUILayout.Label ("7: " + currentRates.Rates [6].ToString () + "x");
- GUILayout.Label ("8: " + currentRates.Rates [7].ToString () + "x");
- }
- GUILayout.EndVertical ();
-
- GUILayout.Space (15f);
- if (GUILayout.Button ("Select"))
- {
- SetWarpRates (currentRates);
- }
- if (currentRates != StandardWarp && currentRates != StandardPhysWarp && GUILayout.Button ("Edit", smallButtonStyle))
- {
- if (currentRates != StandardWarp && currentRates != StandardPhysWarp)
- {
- if(!currentRates.Physics)
- SetWarpRates (StandardWarp, false);
- else
- SetWarpRates (StandardPhysWarp, false);
- customWarps.Remove (currentRates);
- editToggle = true;
- warpName = currentRates.Name;
- physics = currentRates.Physics;
- w1 = currentRates.Rates[1].ToString();
- w2 = currentRates.Rates[2].ToString();
- w3 = currentRates.Rates[3].ToString();
- if (!physics)
- {
- w4 = currentRates.Rates[4].ToString();
- w5 = currentRates.Rates[5].ToString();
- w6 = currentRates.Rates[6].ToString();
- w7 = currentRates.Rates[7].ToString();
- }
- selected = 0;
- }
- else
- {
- PopupDialog.SpawnPopupDialog ("Better Time Warp", "Cannot edit standard warp rates", "Ok", true, skin);
- }
- }
- if (currentRates != StandardWarp && currentRates != StandardPhysWarp && GUILayout.Button ("Delete", smallButtonStyle))
- {
- if (currentRates != StandardWarp && currentRates != StandardPhysWarp)
- {
- customWarps.Remove (currentRates);
- selected = 0;
- SaveCustomWarpRates ();
- PopupDialog.SpawnPopupDialog ("Better Time Warp", "Deleted " + currentRates.Name + " time warp rates", "Ok", true, skin);
- SetWarpRates (StandardWarp, false);
- }
- else
- {
- PopupDialog.SpawnPopupDialog ("Better Time Warp", "Cannot delete standard warp rates", "Ok", true, skin);
- }
- }
- }
- GUILayout.EndScrollView ();
- GUILayout.EndVertical ();
-
- GUILayout.EndHorizontal ();
-
- GUILayout.BeginHorizontal();
- if (GUILayout.Button ("Simple", GUILayout.ExpandWidth(true)))
- {
- advWindowOpen = false;
- }
- showPhysicsSettings = GUILayout.Toggle (showPhysicsSettings, "Physics Settings", skin.button, GUILayout.ExpandWidth(true));
- GUILayout.EndHorizontal();
- }
-
- Vector2 physSettingsScroll = new Vector2(0f, 0f);
-
- string[] toolbar = new string[]{"1", "1/2", "1/3", "1/4"};
- public void PhysicsSettingsWindow(int id)
- {
- physSettingsScroll = GUILayout.BeginScrollView (physSettingsScroll);
-
- ScaleCameraSpeed = GUILayout.Toggle (ScaleCameraSpeed, "Scale Camera Speed");
- GUILayout.Label ("Removes the time based smoothing of the camera so that it doesn't lag at really low warp");
- GUILayout.Space (5f);
-
- UseLosslessPhysics = GUILayout.Toggle (UseLosslessPhysics, "Use Lossless Physics Experimental!");
- GUILayout.Label ("Increases the physics simulation rate so that you can maintain accurate physics at high warp");
- GUILayout.Label ("Note: Lossless Physics causes extreme lag above 50-100x time warp, depending on your computer. You have been warned!");
- GUILayout.Space (5f);
- GUILayout.Label ("Lossless Physics Accuracy:");
- GUILayout.Label ("1/2 is recommended, but if you have a weaker computer then 1/3 or 1/4 will be easier on your CPU.");
- GUILayout.BeginHorizontal (skin.box);
- LosslessUpperThreshold = (float)(GUILayout.Toolbar ((int)(LosslessUpperThreshold - 1f), toolbar, smallButtonStyle, GUILayout.ExpandWidth(true)) + 1);
- GUILayout.EndHorizontal ();
- GUILayout.Space (10f);
-
- GUILayout.Label ("Physics Timestep: " + Time.fixedDeltaTime + "s");
- GUILayout.Label ("Physics Timescale: " + Time.timeScale + "x");
-
- GUILayout.EndScrollView ();
- }
- void FixedUpdate()
- {
- if (UseLosslessPhysics && Time.timeScale < 100f)
- {
- if (Time.timeScale >= LosslessUpperThreshold)
- Time.fixedDeltaTime = LosslessUpperThreshold * 0.02f;
- }
- }
-
- public void SetWarpRates(TimeWarpRates rates, bool message = true)
- {
- if (TimeWarp.fetch != null)
- {
- if (TimeWarp.fetch.warpRates.Length == rates.Rates.Length && !rates.Physics)
- {
- TimeWarp.fetch.warpRates = rates.Rates;
- CurrentWarp = rates;
-
- for (var i = 0; i < warpRates.Length; i++)
- {
- var r = warpRates [i];
- if (r == rates)
- {
- currWarpIndex = i;
- }
- }
-
- print ("[BetterTimeWarp]: Set time warp rates to " + rates.ToString());
- if (message)
- ScreenMessages.PostScreenMessage (new ScreenMessage ("New time warp rates: " + rates.Name, 3f, ScreenMessageStyle.UPPER_CENTER), false);
- return;
- }
- else if (TimeWarp.fetch.physicsWarpRates.Length == rates.Rates.Length && rates.Physics)
- {
- TimeWarp.fetch.physicsWarpRates = rates.Rates;
- CurrentPhysWarp = rates;
-
- for (var i = 0; i < physRates.Length; i++)
- {
- var r = physRates [i];
- if (r == rates)
- {
- currPhysIndex = i;
- }
- }
-
- print ("[BetterTimeWarp]: Set time warp rates to " + rates.ToString());
- if (message)
- ScreenMessages.PostScreenMessage (new ScreenMessage ("New physic warp rates: " + rates.Name, 3f, ScreenMessageStyle.UPPER_CENTER), false);
- return;
- }
- return;
- }
- Debug.LogWarning ("[BetterTimeWarp]: Failed to set warp rates");
-
- //reset it to standard in case of failiure
- if (rates.Physics)
- {
- for (var i = 0; i < physRates.Length; i++)
- {
- var r = physRates [i];
- if (r == StandardPhysWarp)
- {
- currPhysIndex = i;
- CurrentPhysWarp = StandardPhysWarp;
- }
- }
- }
- else
- {
- for (var i = 0; i < warpRates.Length; i++)
- {
- var r = warpRates [i];
- if (r == StandardWarp)
- {
- currWarpIndex = i;
- CurrentWarp = StandardWarp;
- }
- }
- }
- }
-
- private void LoadCustomWarpRates()
- {
- if (!SettingsNode.HasNode ("BetterTimeWarp"))
- SettingsNode.AddNode ("BetterTimeWarp");
- var node = SettingsNode.GetNode ("BetterTimeWarp");
-
- if (!SettingsNode.HasNode ("BetterTimeWarp"))
- SettingsNode.AddNode ("BetterTimeWarp");
-
- if (node.HasValue ("ScaleCameraSpeed"))
- ScaleCameraSpeed = bool.Parse (node.GetValue ("ScaleCameraSpeed"));
- if (node.HasValue ("UseLosslessPhysics"))
- UseLosslessPhysics = bool.Parse (node.GetValue ("UseLosslessPhysics"));
- if (node.HasValue ("LosslessUpperThreshold"))
- LosslessUpperThreshold = float.Parse (node.GetValue ("LosslessUpperThreshold"));
-
- customWarps.Clear ();
- customWarps.Add (StandardWarp);
- customWarps.Add (StandardPhysWarp);
-
- foreach (ConfigNode cNode in node.GetNodes("CustomWarpRate"))
- {
- string name = cNode.GetValue ("name");
- bool physics = bool.Parse (cNode.GetValue("physics"));
- float[] rates;
- if (physics)
- rates = new float[4];
- else
- rates = new float[8];
- rates [0] = 1f;
- rates [1] = float.Parse(cNode.GetValue ("warpRate1"));
- rates [2] = float.Parse(cNode.GetValue ("warpRate2"));
- rates [3] = float.Parse(cNode.GetValue ("warpRate3"));
- if (!physics)
- {
- rates [4] = float.Parse (cNode.GetValue ("warpRate4"));
- rates [5] = float.Parse (cNode.GetValue ("warpRate5"));
- rates [6] = float.Parse (cNode.GetValue ("warpRate6"));
- rates [7] = float.Parse (cNode.GetValue ("warpRate7"));
- }
- customWarps.Add (new TimeWarpRates(name, rates, physics));
- }
-
- //populate the seperate arrays
- warpRates = customWarps.Where (r => !r.Physics).ToArray();
- physRates = customWarps.Where (r => r.Physics).ToArray();
-
- //load selected rates
- string currentTimeWarp = StandardWarp.Name;
- string currentPhysWarp = StandardPhysWarp.Name;
-
- if (node.HasValue ("CurrentTimeWarp"))
- currentTimeWarp = node.GetValue ("CurrentTimeWarp");
- if (node.HasValue ("CurrentPhysWarp"))
- currentPhysWarp = node.GetValue ("CurrentPhysWarp");
-
- if (warpRates.Where (w => w.Name == currentTimeWarp).Count () > 0)
- CurrentWarp = warpRates.Where (w => w.Name == currentTimeWarp).First();
- if (physRates.Where (w => w.Name == currentPhysWarp).Count () > 0)
- CurrentPhysWarp = physRates.Where (w => w.Name == currentPhysWarp).First();
-
- if (CurrentWarp == null)
- CurrentWarp = StandardWarp;
- if (CurrentPhysWarp == null)
- CurrentPhysWarp = StandardPhysWarp;
- }
- private void SaveCustomWarpRates()
- {
- if (!SettingsNode.HasNode ("BetterTimeWarp"))
- SettingsNode.AddNode ("BetterTimeWarp");
-
- ConfigNode node = SettingsNode.GetNode ("BetterTimeWarp");
-
- node.SetValue ("ScaleCameraSpeed", ScaleCameraSpeed.ToString (), true);
- node.SetValue ("UseLosslessPhysics", UseLosslessPhysics.ToString (), true);
- node.SetValue ("LosslessUpperThreshold", LosslessUpperThreshold.ToString (), true);
-
- node.RemoveNodes ("CustomWarpRate");
- foreach (var rates in customWarps)
- {
- if (rates != StandardWarp && rates != StandardPhysWarp)
- {
- ConfigNode rateNode = new ConfigNode ("CustomWarpRate");
- rateNode.AddValue ("name", rates.Name);
- rateNode.AddValue ("warpRate1", rates.Rates [1]);
- rateNode.AddValue ("warpRate2", rates.Rates [2]);
- rateNode.AddValue ("warpRate3", rates.Rates [3]);
- if (!rates.Physics)
- {
- rateNode.AddValue ("warpRate4", rates.Rates [4]);
- rateNode.AddValue ("warpRate5", rates.Rates [5]);
- rateNode.AddValue ("warpRate6", rates.Rates [6]);
- rateNode.AddValue ("warpRate7", rates.Rates [7]);
- }
- rateNode.AddValue ("physics", rates.Physics);
- node.AddNode (rateNode);
- }
- }
-
- if (CurrentWarp == null)
- CurrentWarp = StandardWarp;
- if (CurrentPhysWarp == null)
- CurrentPhysWarp = StandardPhysWarp;
-
- node.SetValue ("CurrentTimeWarp", CurrentWarp.Name, true);
- node.SetValue ("CurrentPhysWarp", CurrentPhysWarp.Name, true);
- }
- }
+ [KSPAddon(KSPAddon.Startup.SpaceCentre, true)]
+ public class BetterTimeWarp : MonoBehaviour
+ {
+
+ public static BetterTimeWarp Instance;
+
+ public static TimeWarpRates StandardWarp = new TimeWarpRates("Standard Warp", new float[] { 1f, 5f, 10f, 50f, 100f, 1000f, 10000f, 100000f }, false, true, 4);
+ public static TimeWarpRates StandardPhysWarp = new TimeWarpRates("Standard Physics Warp", new float[] { 1f, 2f, 3f, 4f }, true, false, 4);
+ public static ConfigNode SettingsNode;
+
+ public List customWarps = new List();
+ public static bool ShowUI = true;
+
+ public bool UIOpen
+ {
+ get
+ {
+ return windowOpen;
+ }
+ set
+ {
+ windowOpen = value;
+ }
+ }
+
+ static ToolbarControl toolbarControl;
+
+ private static bool hasAdded = false;
+
+ static Texture2D upArrow;
+ static Texture2D downArrow;
+
+ public void Start()
+ {
+ DontDestroyOnLoad(this);
+ if (HighLogic.LoadedScene != GameScenes.SPACECENTER &&
+ HighLogic.LoadedScene != GameScenes.FLIGHT &&
+ HighLogic.LoadedScene != GameScenes.TRACKSTATION)
+ return;
+ Instance = this;
+ this.skin = HighLogic.Skin;
+
+ LoadCustomWarpRates();
+
+ SetWarpRates(CurrentWarp, false);
+ SetWarpRates(CurrentPhysWarp, false);
+ InitW();
+ windowStyle = new GUIStyle(skin.window);
+ windowStyle.padding.left = 5;
+ windowStyle.padding.right = 5;
+ windowStyle.padding.top = 5;
+ windowStyle.padding.bottom = 5;
+ smallButtonStyle = new GUIStyle(skin.button);
+ smallButtonStyle.stretchHeight = false;
+ smallButtonStyle.fixedHeight = 20f;
+
+ smallScrollBar = new GUIStyle(skin.verticalScrollbar);
+ smallScrollBar.fixedWidth = 8f;
+ hSmallScrollBar = new GUIStyle(skin.horizontalScrollbar);
+ hSmallScrollBar.fixedHeight = 0f;
+
+ upArrow = GameDatabase.Instance.GetTexture("BetterTimeWarp/Icons/up", false);
+ downArrow = GameDatabase.Instance.GetTexture("BetterTimeWarp/Icons/down", false);
+
+ upContent = new GUIContent("", upArrow, "");
+ downContent = new GUIContent("", downArrow, "");
+ buttonContent = downContent;
+ CreateRectangles();
+ GameEvents.onGameStateSave.Add(SaveSettingsAndCrap);
+ GameEvents.onTimeWarpRateChanged.Add(onTimeWarpRateChanged);
+ GameEvents.onPartUnpack.Add(onPartUnpack);
+ GameEvents.onLevelWasLoadedGUIReady.Add(onLevelWasLoadedGUIReady);
+
+
+ //add the toolbar button to non-flight scenes
+ if (toolbarControl == null && !hasAdded && HighLogic.CurrentGame.Parameters.CustomParams().enabled && !HighLogic.CurrentGame.Parameters.CustomParams().hideButton)
+ {
+ if (!HighLogic.CurrentGame.Parameters.CustomParams().hideButtonInFlight || HighLogic.LoadedScene != GameScenes.FLIGHT)
+ {
+
+ toolbarControl = gameObject.AddComponent();
+ toolbarControl.AddToAllToolbars(OnTrue, OnFalse,
+ ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.TRACKSTATION |
+ ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW,
+ MODID,
+ "betterTimeWarpButton",
+ "BetterTimeWarp/Icons/application_38",
+ "BetterTimeWarp/Icons/application_24",
+ MODNAME
+ );
+
+ hasAdded = true;
+ }
+ }
+ }
+
+ internal const string MODID = "BetterTimeWarp_NS";
+ internal const string MODNAME = "Better Time Warp";
+
+ void OnTrue()
+ {
+ UIOpen = true;
+ }
+ void OnFalse()
+ {
+ UIOpen = false;
+ }
+ void onLevelWasLoadedGUIReady(GameScenes scene)
+ {
+ CreateRectangles();
+ //currWarpIndex = 0;
+ //currPhysIndex = 0;
+ //SetWarpRates(warpRates[currWarpIndex]);
+ //if (warpRates[currWarpIndex] != CurrentWarp)
+ {
+ SetWarpRates(warpRates[currWarpIndex]);
+ }
+ // if (physRates[currPhysIndex] != CurrentPhysWarp)
+ {
+ SetWarpRates(physRates[currPhysIndex]);
+ }
+
+ }
+
+ void OnDestroy()
+ {
+ GameEvents.onGameStateSave.Remove(SaveSettingsAndCrap);
+ GameEvents.onTimeWarpRateChanged.Remove(onTimeWarpRateChanged);
+ GameEvents.onPartUnpack.Remove(onPartUnpack);
+ GameEvents.onLevelWasLoadedGUIReady.Remove(onLevelWasLoadedGUIReady);
+ removeLauncherButtons();
+ }
+
+ void SaveSettingsAndCrap(ConfigNode node) //lel
+ {
+ SaveCustomWarpRates();
+ }
+
+ public void removeLauncherButtons()
+ {
+ if (toolbarControl != null)
+ {
+ toolbarControl.OnDestroy();
+ Destroy(toolbarControl);
+ toolbarControl = null;
+ }
+ }
+
+ void InitW()
+ {
+ w[1] = "10";
+ w[2] = "100";
+ w[3] = "1000";
+ w[4] = "10000";
+ w[5] = "100000";
+ w[6] = "1000000";
+ w[7] = "10000000";
+ }
+ List resourceConverterParts = new List();
+
+ // When coming out of warp, fix issue with ResourceConverter
+ void onPartUnpack(Part p)
+ {
+ Log.Info("Unpacking part: " + p.partInfo.name);
+ if (resourceConverterParts.Contains(p))
+ {
+ resourceConverterParts.Remove(p);
+ foreach (PartModule tmpPM in p.Modules)
+ {
+
+ // Find all modules of type BaseConvertor
+ // If !IsActivated, then
+ // set lastUpdateTime = Planetarium.GetUniversalTime();
+ // lastUpdateTime is a protected field, so Reflection was needed to fix this
+
+ switch (tmpPM.moduleName)
+ {
+ case "FissionReactor":
+ case "KFAPUController":
+ case "ModuleResourceConverter":
+ ModuleResourceConverter tmpGen = (ModuleResourceConverter)tmpPM;
+ Log.Info("Module: " + tmpGen.moduleName + " IsActivated: " + tmpGen.IsActivated.ToString());
+ // if (!tmpGen.IsActivated)
+ {
+ FieldInfo fi = tmpGen.GetType().GetField("lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (fi != null)
+ {
+ Log.Info("Updating lastUpdateTime");
+ fi.SetValue(tmpGen, Planetarium.GetUniversalTime());
+ }
+ else
+ Log.Info("Unable to get pointer to lastUpdateTime");
+ }
+
+ break;
+
+ }
+ }
+ }
+ }
+
+
+ static int lastWarpRateIdx = 0;
+ void onTimeWarpRateChanged()
+ {
+ if (TimeWarp.fetch != null)
+ {
+ if (lastWarpRateIdx > 0 && TimeWarp.fetch.warpRates[TimeWarp.fetch.current_rate_index] > 1)
+ {
+ foreach (var v in FlightGlobals.fetch.vesselsLoaded)
+ {
+ foreach (var p in v.Parts)
+ {
+ foreach (PartModule tmpPM in p.Modules)
+ {
+
+ // Find all modules of type BaseConvertor which are inactive
+
+ switch (tmpPM.moduleName)
+ {
+ case "FissionReactor":
+ case "KFAPUController":
+ case "ModuleResourceConverter":
+ ModuleResourceConverter tmpGen = (ModuleResourceConverter)tmpPM;
+ Log.Info("Module: " + tmpGen.moduleName + " IsActivated: " + tmpGen.IsActivated.ToString());
+ if (!tmpGen.IsActivated)
+ {
+ if (!resourceConverterParts.Contains(p))
+ resourceConverterParts.Add(p);
+ }
+ else
+ {
+ if (resourceConverterParts.Contains(p))
+ {
+ resourceConverterParts.Remove(p);
+ FieldInfo fi = tmpGen.GetType().GetField("lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (fi != null)
+ {
+ Log.Info("Updating lastUpdateTime");
+ fi.SetValue(tmpGen, Planetarium.GetUniversalTime());
+ }
+ else
+ Log.Info("Unable to get pointer to lastUpdateTime");
+ }
+ }
+ break;
+
+ }
+ }
+ }
+ }
+ }
+ //CheatOptions.InfiniteElectricity = false;CheatOptions.InfiniteElectricity = false;
+ lastWarpRateIdx = TimeWarp.fetch.current_rate_index;
+ if (currentRates.DisableECAtHighWarp )
+ {
+ if (TimeWarp.fetch.current_rate_index > currentRates.ecIndexDisable)
+ {
+ if (!CheatOptions.InfiniteElectricity)
+ {
+ CheatOptions.InfiniteElectricity = true;
+ autoDisable = true;
+ ScreenMessages.PostScreenMessage("Disabling EC Usage", 5);
+ }
+ }
+ else
+ {
+ if (autoDisable)
+ {
+ CheatOptions.InfiniteElectricity = false;
+ autoDisable = false;
+ ScreenMessages.PostScreenMessage("Enabling EC Usage", 5);
+ }
+ }
+ }
+ }
+ }
+
+ const float quickWidth = 200f;
+ const float quickHeight = 410f;
+
+ const float advWidth = 420f;
+ const float advHeight = quickHeight;
+
+ const float physWidth = 420f;
+ const float physHeight = 220f;
+
+ void CreateRectangles()
+ {
+ if (HighLogic.LoadedSceneIsFlight)
+ {
+ float x = 210f;
+ quikWindowRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, 35f, quickWidth, quickHeight);
+ advWindowRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, 35f, advWidth, advHeight);
+ physSettingsRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, 445f, physWidth, physHeight);
+ }
+ else
+ {
+ if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
+ {
+ float x = 140;
+ float y = 58f;
+
+ quikWindowRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, y, quickWidth, quickHeight);
+ advWindowRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, y, advWidth, advHeight);
+ physSettingsRect = new Rect(GameSettings.UI_SCALE * x /* * ScreenSafeUI.PixelRatio */, y + 410f, physWidth, physHeight);
+
+ }
+ else
+ {
+ quikWindowRect = new Rect((Screen.width - 205f), 40f, quickWidth, quickHeight);
+ advWindowRect = new Rect((Screen.width - 425f), 40f, advWidth, advHeight);
+ physSettingsRect = new Rect((Screen.width - 425f), 450f, physWidth, physHeight);
+ }
+ }
+ }
+
+ //physics settings
+ public bool ScaleCameraSpeed = true;
+ public bool UseLosslessPhysics = false;
+ public float LosslessUpperThreshold = 2f;
+
+ GUISkin skin;
+
+ Rect advWindowRect = new Rect();
+ Rect physSettingsRect = new Rect();
+ GUIContent buttonContent;
+ GUIContent upContent;
+ GUIContent downContent;
+
+ bool advWindowOpen = false;
+ bool windowOpen = false;
+ Rect quikWindowRect = new Rect();
+ GUIStyle windowStyle;
+ GUIStyle smallButtonStyle;
+ GUIStyle smallScrollBar;
+ GUIStyle hSmallScrollBar;
+
+ public void OnGUI()
+ {
+ if ((HighLogic.LoadedScene != GameScenes.SPACECENTER &&
+ HighLogic.LoadedScene != GameScenes.FLIGHT &&
+ HighLogic.LoadedScene != GameScenes.TRACKSTATION)
+ || !HighLogic.CurrentGame.Parameters.CustomParams().enabled)
+ return;
+
+ if (ShowUI)
+ {
+ GUI.skin = skin;
+
+ //flight
+ if ((HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.SPACECENTER)
+ && !HighLogic.CurrentGame.Parameters.CustomParams().hideDropdownButtonInFlight)
+ {
+ const float ICON_WIDTH = 28;
+ const float ICON_BASE = 203f + 80; // 32f added for KSP 1.12
+
+ float y = ICON_BASE;
+ float x = 0;
+ var tu = TelemetryUpdate.Instance;
+
+ if (tu != null && CommNetScenario.CommNetEnabled)
+ {
+ if (tu.arrow_icon != null && tu.arrow_icon.sprite != tu.BLK && tu.arrow_icon.gameObject.activeSelf) y += ICON_WIDTH;
+
+ if (FlightGlobals.ActiveVessel.connection != null && FlightGlobals.ActiveVessel.connection.ControlPath.First != null && FlightGlobals.ActiveVessel.connection.ControlPath.Last != null && FlightGlobals.ActiveVessel.connection.ControlPath.Last.hopType != FlightGlobals.ActiveVessel.connection.ControlPath.First.hopType)
+ {
+ if (tu.firstHop_icon != null && tu.firstHop_icon.sprite != tu.BLK && tu.firstHop_icon.gameObject.activeSelf) y += ICON_WIDTH;
+ }
+ if (tu.lastHop_icon != null && tu.lastHop_icon.sprite != tu.BLK && tu.lastHop_icon.gameObject.activeSelf) y += ICON_WIDTH;
+ if (tu.control_icon != null && tu.control_icon.sprite != tu.BLK && tu.control_icon.gameObject.activeSelf) y += ICON_WIDTH;
+ if (tu.signal_icon != null && tu.signal_icon.sprite != tu.BLK && tu.signal_icon.gameObject.activeSelf) y += ICON_WIDTH;
+ if (tu.modeButton != null && tu.modeButton.gameObject.activeSelf) y += ICON_WIDTH;
+ }
+ // if only a single icon, then adjustment needed
+ if (y == ICON_BASE + ICON_WIDTH)
+ y += 12;
+ float widthAndHeight = 20f;
+ float scale = 1f;
+ if (GameSettings.UI_SCALE != 1f || GameSettings.UI_SCALE_TIME != 1f)
+ {
+ scale = GameSettings.UI_SCALE * GameSettings.UI_SCALE_TIME;
+ widthAndHeight *= scale;
+ }
+ if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
+ {
+ x = 24f;
+ y += 56f;
+ }
+ if (buttonContent != null)
+ {
+ var b = GUI.Toggle(new Rect(scale * y, x, widthAndHeight, widthAndHeight), windowOpen, buttonContent, skin.button);
+ if (b != windowOpen)
+ {
+ windowOpen = b;
+ }
+ }
+ }
+
+ if (windowOpen)
+ {
+ if (!advWindowOpen)
+ quikWindowRect = ClickThruBlocker.GUILayoutWindow(60371, quikWindowRect, QuikWarpWindow, "", windowStyle);
+ else
+ {
+ advWindowRect = ClickThruBlocker.GUILayoutWindow(60372, advWindowRect, TimeWarpWindow, "", windowStyle);
+ if (showPhysicsSettings)
+ {
+ physSettingsRect = ClickThruBlocker.GUILayoutWindow(60373, physSettingsRect, PhysicsSettingsWindow, "", windowStyle);
+ }
+ }
+
+ buttonContent = upContent;
+ }
+ else
+ buttonContent = downContent;
+ }
+ }
+
+ bool editToggle = false;
+ Vector2 scrollPos = new Vector2(0f, 0f);
+ Vector2 scrollPos2 = new Vector2(0f, 0f);
+
+ string warpName = "Name";
+ bool physics = false;
+ bool disableECAtHighWarp = false;
+ int ecIndexDisable = 7;
+ internal bool autoDisable = false;
+
+ TimeWarpRates currentRates = StandardWarp;
+ int selected = 0;
+
+ TimeWarpRates CurrentWarp;
+ TimeWarpRates CurrentPhysWarp;
+ int currWarpIndex = 0;
+ int currPhysIndex = 0;
+
+ List warpNames = new List();
+ TimeWarpRates[] warpRates = new TimeWarpRates[] { };
+ List physNames = new List();
+ TimeWarpRates[] physRates = new TimeWarpRates[] { };
+
+ void Update()
+ {
+ warpNames.Clear();
+ physNames.Clear();
+ warpRates = customWarps.Where(r => !r.Physics).ToArray();
+ physRates = customWarps.Where(r => r.Physics).ToArray();
+
+ foreach (var rates in customWarps)
+ {
+ string sB = "";
+ string sA = "";
+ if (rates == CurrentWarp || rates == CurrentPhysWarp)
+ {
+ sB = "";
+ sA = "";
+ }
+
+ if (rates.Physics)
+ physNames.Add(sB + rates.Name + sA);
+ else
+ warpNames.Add(sB + rates.Name + sA);
+ }
+
+ names = warpNames.Concat(physNames).ToArray();
+
+ //make camera speed not change with time warp
+ if (ScaleCameraSpeed && Time.timeScale < 1f)
+ FlightCamera.fetch.SetDistanceImmediate(FlightCamera.fetch.Distance);
+
+ var mouse = Mouse.screenPos;
+ if ((windowOpen && !advWindowOpen && quikWindowRect.Contains(mouse)) ||
+ (windowOpen && advWindowOpen && advWindowRect.Contains(mouse)) ||
+ (windowOpen && advWindowOpen && showPhysicsSettings && physSettingsRect.Contains(mouse))
+ )
+ {
+ InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.ALL_SHIP_CONTROLS, "BetterTimeWarp_UIHover_Lock");
+ }
+ else
+ InputLockManager.RemoveControlLock("BetterTimeWarp_UIHover_Lock");
+ }
+
+ bool lockWindow()
+ {
+ if (HighLogic.LoadedScene == GameScenes.FLIGHT && HighLogic.CurrentGame.Parameters.CustomParams().lockWindowPosInFlight)
+ return true;
+ if (HighLogic.LoadedScene != GameScenes.FLIGHT && HighLogic.CurrentGame.Parameters.CustomParams().lockWindowPos)
+ return true;
+ return false;
+ }
+
+ public void QuikWarpWindow(int id)
+ {
+ GUILayout.BeginVertical();
+
+ scrollPos = GUILayout.BeginScrollView(scrollPos, false, false, hSmallScrollBar, smallScrollBar);
+
+ currWarpIndex = GUILayout.SelectionGrid(currWarpIndex, warpNames.ToArray(), 1, smallButtonStyle);
+ GUILayout.Space(20f);
+ currPhysIndex = GUILayout.SelectionGrid(currPhysIndex, physNames.ToArray(), 1, smallButtonStyle);
+
+ if (warpRates[currWarpIndex] != CurrentWarp)
+ {
+ SetWarpRates(warpRates[currWarpIndex]);
+ }
+ if (physRates[currPhysIndex] != CurrentPhysWarp)
+ {
+ SetWarpRates(physRates[currPhysIndex]);
+ }
+
+ GUILayout.EndScrollView();
+
+ if (GUILayout.Button("Advanced"))
+ {
+ advWindowOpen = true;
+ }
+
+ GUILayout.EndVertical();
+ if (!lockWindow())
+ GUI.DragWindow();
+ }
+
+ bool showPhysicsSettings = false;
+ string labelColor = "#b7fe00";
+
+ string[] w = new string[8];
+
+ string[] names = new string[] { };
+
+ public void TimeWarpWindow(int id)
+ {
+ using (new GUILayout.HorizontalScope())
+ {
+ using (new GUILayout.VerticalScope())
+ {
+ scrollPos = GUILayout.BeginScrollView(scrollPos);
+
+ editToggle = GUILayout.Toggle(editToggle, "Create", skin.button);
+ selected = GUILayout.SelectionGrid(selected, names, 1, smallButtonStyle);
+
+ currentRates = customWarps.Find(r => r.Name == names[selected] ||
+ (names[selected].Contains("<") && names[selected].Split('<', '>')[2] == r.Name)
+ );
+
+ if (currentRates == null)
+ currentRates = StandardWarp;
+
+ GUILayout.EndScrollView();
+ }
+
+ using (new GUILayout.VerticalScope())
+ {
+ scrollPos2 = GUILayout.BeginScrollView(scrollPos2);
+
+ if (editToggle)
+ {
+ bool canExport = true;
+
+ using (new GUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
+ {
+ warpName = GUILayout.TextField(warpName);
+
+ for (int i = 1; i < 8; i++)
+ {
+ if (i < 4 || !physics)
+ {
+ using (new GUILayout.HorizontalScope())
+ {
+ GUILayout.Label($"{i}. ", GUILayout.Width(20));
+ w[i] = GUILayout.TextField(w[i]);
+ }
+ }
+ }
+ physics = GUILayout.Toggle(physics, "Physics Warp?");
+ if (!physics)
+ {
+ disableECAtHighWarp = GUILayout.Toggle(disableECAtHighWarp, new GUIContent("Disable EC usage", "Disable EC usage at high warp rates"));
+ using (new GUILayout.HorizontalScope())
+ {
+ GUILayout.Label("Disable Index: ");
+ if (GUILayout.Button("<") && ecIndexDisable > 1)
+ ecIndexDisable--;
+ GUILayout.Label(ecIndexDisable.ToString());
+ if (GUILayout.Button(">") && ecIndexDisable < 7)
+ ecIndexDisable++;
+ }
+ }
+ }
+ if (GUILayout.Button("Save"))
+ {
+ float[] rates;
+ if (physics)
+ rates = new float[4];
+ else
+ rates = new float[8];
+
+ rates[0] = 1f;
+
+ float pw;
+ for (int i = 1; i < 8; i++)
+ {
+ if (i < 4 || !physics)
+ {
+ if (float.TryParse(w[i], out pw))
+ rates[i] = pw;
+ else
+ canExport = false;
+ }
+ }
+
+ if (canExport)
+ {
+ TimeWarpRates timeWarpRates = new TimeWarpRates(warpName, rates, physics, disableECAtHighWarp, ecIndexDisable);
+ customWarps.Add(timeWarpRates);
+ SaveCustomWarpRates();
+ editToggle = false;
+ //SetWarpRates (timeWarpRates);
+ warpName = "Name";
+ physics = false;
+ InitW();
+ }
+ else
+ {
+ //PopupDialog.SpawnPopupDialog (new MultiOptionDialog("Cannot save because there are non-numbers in the editing fields", "Error", null), false, null);
+ var dialog = new MultiOptionDialog("btw1", "Cannot save because there are non-numbers in the editing fields", "Error", HighLogic.UISkin, new DialogGUIBase[] {
+ new DialogGUIButton ("OK", () => { })
+ });
+ PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, true);
+ }
+ //save the settings, so if they have been regenerated, it exsists and wont cause errors
+ BetterTimeWarp.SettingsNode.Save(BetterTimeWarpInitializer.BTW_CFG_FILE);
+ }
+ if (GUILayout.Button("Cancel", smallButtonStyle))
+ {
+ editToggle = false;
+ warpName = "Name";
+ physics = false;
+ InitW();
+ }
+ }
+ else
+ {
+ GUILayout.BeginVertical(GUILayout.ExpandHeight(true));
+ for (int i = 1; i <= 8; i++)
+ {
+ if (i <= 4 || !currentRates.Physics)
+ {
+ var f = currentRates.Rates[i - 1];
+ GUILayout.Label("" + i.ToString() + ": " + f.ToString(TimeWarpRates.rateFmt(f)) + "x");
+ }
+ }
+ GUILayout.EndVertical();
+
+ GUILayout.Space(15f);
+ if (GUILayout.Button("Select"))
+ {
+ SetWarpRates(currentRates);
+ }
+ if (currentRates != StandardWarp && currentRates != StandardPhysWarp && GUILayout.Button("Edit", smallButtonStyle))
+ {
+ if (currentRates != StandardWarp && currentRates != StandardPhysWarp)
+ {
+ if (!currentRates.Physics)
+ SetWarpRates(StandardWarp, false);
+ else
+ SetWarpRates(StandardPhysWarp, false);
+ customWarps.Remove(currentRates);
+ editToggle = true;
+ warpName = currentRates.Name;
+ physics = currentRates.Physics;
+ disableECAtHighWarp = currentRates.DisableECAtHighWarp;
+ ecIndexDisable = currentRates.ecIndexDisable;
+
+ for (int i = 1; i < 8; i++)
+ {
+ if (i < 4 || !physics)
+ w[i] = currentRates.Rates[i].ToString(TimeWarpRates.rateFmt(currentRates.Rates[i]));
+ }
+ selected = 0;
+ }
+ else
+ {
+ //PopupDialog.SpawnPopupDialog (new MultiOptionDialog("Cannot edit standard warp rates", "Better Time Warp", null), true, null);
+
+ var dialog = new MultiOptionDialog("btw2", "Cannot edit standard warp rates", "Better Time Warp", HighLogic.UISkin, new DialogGUIBase[] {
+ new DialogGUIButton ("OK", () => { })
+ });
+ PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, true);
+
+ }
+ }
+ if (currentRates != StandardWarp && currentRates != StandardPhysWarp && GUILayout.Button("Delete", smallButtonStyle))
+ {
+ if (currentRates != StandardWarp && currentRates != StandardPhysWarp)
+ {
+ customWarps.Remove(currentRates);
+ selected = 0;
+ SaveCustomWarpRates();
+ // PopupDialog.SpawnPopupDialog (new MultiOptionDialog("Deleted " + currentRates.Name + " time warp rates", "Better Time Warp", null), true, null);
+
+
+
+ var dialog = new MultiOptionDialog("btw3", "Deleted " + currentRates.Name + " time warp rates", "Better Time Warp", HighLogic.UISkin, new DialogGUIBase[] {
+ new DialogGUIButton ("OK", () => {
+ // winState = winContent.close;
+ })
+ });
+ PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, true);
+ // winState = winContent.dialog;
+
+
+
+
+ SetWarpRates(StandardWarp, false);
+ }
+ else
+ {
+ //PopupDialog.SpawnPopupDialog (new MultiOptionDialog("Cannot delete standard warp rates", "Better Time Warp", null), true, null);
+
+ var dialog = new MultiOptionDialog("btw4", "Cannot delete standard warp rates", "Better Time Warp", HighLogic.UISkin, new DialogGUIBase[] {
+ new DialogGUIButton ("OK", () => { })
+ });
+ PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, true);
+
+ }
+ }
+ }
+ GUILayout.EndScrollView();
+ }
+
+ }
+
+ using (new GUILayout.HorizontalScope())
+ {
+ if (GUILayout.Button("Simple", GUILayout.ExpandWidth(true)))
+ {
+ advWindowOpen = false;
+ }
+ showPhysicsSettings = GUILayout.Toggle(showPhysicsSettings, "Physics Settings", skin.button, GUILayout.ExpandWidth(true));
+ }
+ if (!lockWindow())
+ GUI.DragWindow();
+ }
+
+ Vector2 physSettingsScroll = new Vector2(0f, 0f);
+
+ string[] toolbar = new string[] { "1", "1/2", "1/3", "1/4" };
+ public void PhysicsSettingsWindow(int id)
+ {
+ physSettingsScroll = GUILayout.BeginScrollView(physSettingsScroll);
+
+ ScaleCameraSpeed = GUILayout.Toggle(ScaleCameraSpeed, "Scale Camera Speed");
+ GUILayout.Label("Removes the time based smoothing of the camera so that it doesn't lag at really low warp");
+ GUILayout.Space(5f);
+
+ UseLosslessPhysics = GUILayout.Toggle(UseLosslessPhysics, "Use Lossless Physics Experimental!");
+ GUILayout.Label("Increases the physics simulation rate so that you can maintain accurate physics at high warp");
+ GUILayout.Label("Note: Lossless Physics causes extreme lag above 50-100x time warp, depending on your computer. You have been warned!");
+ GUILayout.Space(5f);
+ GUILayout.Label("Lossless Physics Accuracy:");
+ GUILayout.Label("1/2 is recommended, but if you have a weaker computer then 1/3 or 1/4 will be easier on your CPU.");
+ GUILayout.BeginHorizontal(skin.box);
+ LosslessUpperThreshold = (float)(GUILayout.Toolbar((int)(LosslessUpperThreshold - 1f), toolbar, smallButtonStyle, GUILayout.ExpandWidth(true)) + 1);
+ GUILayout.EndHorizontal();
+ GUILayout.Space(10f);
+
+ GUILayout.Label("Physics Timestep: " + Time.fixedDeltaTime + "s");
+ GUILayout.Label("Physics Timescale: " + Time.timeScale + "x");
+ GUILayout.Label("Lossless Upper Threshold: " + LosslessUpperThreshold.ToString("N3") + "x");
+
+ GUILayout.EndScrollView();
+ if (!lockWindow())
+ GUI.DragWindow();
+ }
+
+ void FixedUpdate()
+ {
+ if (TimeWarp.fetch != null && TimeWarp.fetch.Mode == TimeWarp.Modes.HIGH && UseLosslessPhysics && Time.timeScale < 100f)
+ {
+ if (Time.timeScale == 1f)
+ {
+ Time.fixedDeltaTime = 0.02f;
+
+ //ScreenMessages.PostScreenMessage("1 Setting Time.fixedDeltaTime to " + Time.fixedDeltaTime.ToString("N4"), 5);
+ Planetarium.fetch.fixedDeltaTime = Time.fixedDeltaTime;
+ Time.maximumDeltaTime = GameSettings.PHYSICS_FRAME_DT_LIMIT;
+
+ }
+ else
+ {
+ if (Time.timeScale >= LosslessUpperThreshold)
+ {
+ Time.fixedDeltaTime = LosslessUpperThreshold * 0.02f;
+ //ScreenMessages.PostScreenMessage("2 Setting Time.fixedDeltaTime to " + Time.fixedDeltaTime.ToString("N4"), 5);
+ Planetarium.fetch.fixedDeltaTime = Time.fixedDeltaTime;
+ Time.maximumDeltaTime = Time.fixedDeltaTime;
+ }
+ else
+ {
+ Time.fixedDeltaTime = Time.timeScale * 0.02f;
+ //ScreenMessages.PostScreenMessage("3 Setting Time.fixedDeltaTime to " + Time.fixedDeltaTime.ToString("N4"), 5);
+
+ Planetarium.fetch.fixedDeltaTime = Time.fixedDeltaTime;
+ Time.maximumDeltaTime = Time.fixedDeltaTime;
+ }
+ }
+
+ float v = Mathf.Clamp((Mathf.Round(Time.fixedDeltaTime * 100f) / 100f), 0.02f, 0.35f);
+ if (v != GameSettings.PHYSICS_FRAME_DT_LIMIT)
+ {
+ GameSettings.PHYSICS_FRAME_DT_LIMIT = v;
+ GameSettings.SaveSettings();
+ }
+ }
+ }
+
+ public void SetWarpRates(TimeWarpRates rates, bool message = true)
+ {
+ if (TimeWarp.fetch != null)
+ {
+ if (TimeWarp.fetch.warpRates.Length == rates.Rates.Length && !rates.Physics)
+ {
+ TimeWarp.fetch.warpRates = rates.Rates;
+ CurrentWarp = rates;
+
+ for (var i = 0; i < warpRates.Length; i++)
+ {
+ var r = warpRates[i];
+ if (r == rates)
+ {
+ currWarpIndex = i;
+ }
+ }
+
+ Log.Info("Set time warp rates to " + rates.ToString());
+ if (message)
+ ScreenMessages.PostScreenMessage(new ScreenMessage("New time warp rates: " + rates.Name, 3f, ScreenMessageStyle.UPPER_CENTER));
+ return;
+ }
+ else if (TimeWarp.fetch.physicsWarpRates.Length == rates.Rates.Length && rates.Physics)
+ {
+ TimeWarp.fetch.physicsWarpRates = rates.Rates;
+ CurrentPhysWarp = rates;
+
+ for (var i = 0; i < physRates.Length; i++)
+ {
+ var r = physRates[i];
+ if (r == rates)
+ {
+ currPhysIndex = i;
+ }
+ }
+
+ Log.Info("Set time warp rates to " + rates.ToString());
+ if (message)
+ ScreenMessages.PostScreenMessage(new ScreenMessage("New physic warp rates: " + rates.Name, 3f, ScreenMessageStyle.UPPER_CENTER));
+ return;
+ }
+ return;
+ }
+ Log.Warning("Failed to set warp rates");
+
+ }
+
+ private void LoadCustomWarpRates()
+ {
+ Log.Info("LoadCustomWarpRates A1");
+ if (BetterTimeWarp.SettingsNode == null)
+ BetterTimeWarp.SettingsNode = new ConfigNode();
+ if (!SettingsNode.HasNode("BetterTimeWarp"))
+ SettingsNode.AddNode("BetterTimeWarp");
+ var node = SettingsNode.GetNode("BetterTimeWarp");
+
+ if (!SettingsNode.HasNode("BetterTimeWarp"))
+ SettingsNode.AddNode("BetterTimeWarp");
+
+ if (node.HasValue("ScaleCameraSpeed"))
+ ScaleCameraSpeed = bool.Parse(node.GetValue("ScaleCameraSpeed"));
+ if (node.HasValue("UseLosslessPhysics"))
+ UseLosslessPhysics = bool.Parse(node.GetValue("UseLosslessPhysics"));
+ if (node.HasValue("LosslessUpperThreshold"))
+ LosslessUpperThreshold = float.Parse(node.GetValue("LosslessUpperThreshold"));
+
+ customWarps.Clear();
+ customWarps.Add(StandardWarp);
+ customWarps.Add(StandardPhysWarp);
+
+ foreach (ConfigNode cNode in node.GetNodes("CustomWarpRate"))
+ {
+ string name = cNode.GetValue("name");
+ bool physics = bool.Parse(cNode.GetValue("physics"));
+ bool disable = false;
+ if (node.HasValue("DisableECAtHighWarp"))
+ {
+
+ string str = cNode.GetValue("DisableECAtHighWarp");
+ try
+ {
+ disable = bool.Parse(str);
+ }
+ catch (Exception e)
+ {
+ Log.Error("DisableECAtHighWarp: " + str);
+ }
+ }
+ else
+ disable = false;
+ if (node.HasValue("ecIndexDisable"))
+ {
+ string str = cNode.GetValue("ecIndexDisable");
+ Log.Info("ecIndexDisable: " + str);
+ try
+ {
+ ecIndexDisable = int.Parse(str);
+ }
+ catch (Exception ex)
+ {
+ Log.Error("ecIndexDisable value: " + str);
+ }
+
+ }
+ float[] rates;
+ if (physics)
+ rates = new float[4];
+ else
+ rates = new float[8];
+ rates[0] = 1f;
+ for (int i = 1; i < 8; i++)
+ {
+ if (i < 4 || !physics)
+ {
+ string str = cNode.GetValue("warpRate" + i.ToString());
+ rates[i] = float.Parse(cNode.GetValue("warpRate" + i.ToString()));
+ }
+ }
+ customWarps.Add(new TimeWarpRates(name, rates, physics, disable, 4));
+ }
+
+ //populate the seperate arrays
+ warpRates = customWarps.Where(r => !r.Physics).ToArray();
+ physRates = customWarps.Where(r => r.Physics).ToArray();
+
+ //load selected rates
+ string currentTimeWarp = StandardWarp.Name;
+ string currentPhysWarp = StandardPhysWarp.Name;
+
+ if (node.HasValue("CurrentTimeWarp"))
+ currentTimeWarp = node.GetValue("CurrentTimeWarp");
+ if (node.HasValue("CurrentPhysWarp"))
+ currentPhysWarp = node.GetValue("CurrentPhysWarp");
+
+ if (warpRates.Where(w => w.Name == currentTimeWarp).Count() > 0)
+ CurrentWarp = warpRates.Where(w => w.Name == currentTimeWarp).First();
+ if (physRates.Where(w => w.Name == currentPhysWarp).Count() > 0)
+ CurrentPhysWarp = physRates.Where(w => w.Name == currentPhysWarp).First();
+
+ if (CurrentWarp == null)
+ {
+ CurrentWarp = StandardWarp;
+ Log.Info("CurrentWarp set to StandardWarp 2");
+ }
+ if (CurrentPhysWarp == null)
+ CurrentPhysWarp = StandardPhysWarp;
+ }
+
+ private void SaveCustomWarpRates()
+ {
+ if (!SettingsNode.HasNode("BetterTimeWarp"))
+ SettingsNode.AddNode("BetterTimeWarp");
+
+ ConfigNode node = SettingsNode.GetNode("BetterTimeWarp");
+
+ node.SetValue("ScaleCameraSpeed", ScaleCameraSpeed.ToString(), true);
+ node.SetValue("UseLosslessPhysics", UseLosslessPhysics.ToString(), true);
+ node.SetValue("LosslessUpperThreshold", LosslessUpperThreshold.ToString(), true);
+
+ node.RemoveNodes("CustomWarpRate");
+ foreach (var rates in customWarps)
+ {
+ if (rates != StandardWarp && rates != StandardPhysWarp)
+ {
+ ConfigNode rateNode = new ConfigNode("CustomWarpRate");
+ rateNode.AddValue("name", rates.Name);
+ for (int i = 1; i < 8; i++)
+ {
+ if (i < 4 || !rates.Physics)
+ {
+ rateNode.AddValue("warpRate" + i.ToString(), rates.Rates[i].ToString(TimeWarpRates.rateFmt(rates.Rates[i])));
+ }
+ }
+ rateNode.AddValue("physics", rates.Physics);
+ rateNode.AddValue("DisableECAtHighWarp", rates.DisableECAtHighWarp);
+ rateNode.AddValue("ecIndexDisable", rates.ecIndexDisable);
+ node.AddNode(rateNode);
+ }
+ }
+
+ if (CurrentWarp == null)
+ {
+ CurrentWarp = StandardWarp;
+ Log.Info("CurrentWarp set to StandardWarp 3");
+ }
+ if (CurrentPhysWarp == null)
+ CurrentPhysWarp = StandardPhysWarp;
+
+ node.SetValue("CurrentTimeWarp", CurrentWarp.Name, true);
+ node.SetValue("CurrentPhysWarp", CurrentPhysWarp.Name, true);
+ }
+ }
}
diff --git a/BetterTimeWarp/BetterTimeWarp.csproj b/BetterTimeWarp/BetterTimeWarp.csproj
index afcb5a7..ac4bfdb 100644
--- a/BetterTimeWarp/BetterTimeWarp.csproj
+++ b/BetterTimeWarp/BetterTimeWarp.csproj
@@ -1,5 +1,5 @@
-
-
+
+
Debug
AnyCPU
@@ -8,26 +8,22 @@
{4B05E220-5E03-4B86-8896-B407D71F6A99}
Library
BetterTimeWarp
- BetterTimeWarp
+ BetterTimeWarpCont
1.0.0.0
false
- v3.5
+ v4.7.2
+
true
- full
+ portable
false
bin\Debug
DEBUG;
prompt
4
+ false
false
-
-
-
-
-
-
full
@@ -35,22 +31,78 @@
bin\Release
prompt
4
+ false
false
+ DEBUG
+
+ True
+ True
+ AssemblyVersion.tt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
-
- ..\..\..\References\1.0.5\Assembly-CSharp.dll
+
+ False
+ $(KSPDIR)\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll
-
- ..\..\..\References\1.0.5\UnityEngine.dll
+
+
+ $(KSPDIR)\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll
-
-
-
-
+
+ TextTemplatingFileGenerator
+ AssemblyVersion.cs
+
+
+
+rem "$(DevEnvDir)\texttransform.exe" "$(ProjectDir)AssemblyVersion.tt"
+
+
+
+set KSPDIR=$(KSPDIR)
+
+IF "%25KSPDIR%25"=="" (
+
+ ECHO Configuration error - KSPDIR not specified in project.
+
+ ECHO Either set KSPDIR environment variable or edit BetterLoadSaveGame.Common.props
+
+ PAUSE
+
+ GOTO DONE
+
+)
+
+start /D $(SolutionDir) /WAIT deploy.bat $(TargetDir) $(TargetFileName) $(TargetName)
+
+if $(ConfigurationName) == Release (
+
+ start /D $(SolutionDir) /WAIT buildRelease.bat $(TargetDir) $(TargetFileName) $(TargetName)
+
+)
+
\ No newline at end of file
diff --git a/BetterTimeWarp/BetterTimeWarp.csproj.orig b/BetterTimeWarp/BetterTimeWarp.csproj.orig
new file mode 100644
index 0000000..81aef41
--- /dev/null
+++ b/BetterTimeWarp/BetterTimeWarp.csproj.orig
@@ -0,0 +1,101 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {4B05E220-5E03-4B86-8896-B407D71F6A99}
+ Library
+ BetterTimeWarp
+ BetterTimeWarp
+ 1.0.0.0
+ false
+ v3.5
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+ false
+
+
+
+
+
+
+
+
+ full
+ true
+ bin\Release
+ prompt
+ 4
+ false
+
+
+
+ True
+ True
+ AssemblyVersion.tt
+
+
+
+
+
+
+
+
+
+
+ TextTemplatingFileGenerator
+ AssemblyVersion.cs
+
+
+
+
+
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll
+
+
+
+ R:\KSP_1.7.3_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.dll
+
+
+ False
+ R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll
+
+
+
+
+
+set textTemplatingPath="%25ProgramFiles(x86)%25\Microsoft Visual Studio\2017\Community\Common7\IDE\texttransform.exe"
+
+%25textTemplatingPath%25 "$(ProjectDir)AssemblyVersion.tt"
+
+
+
+
+start /D D:\Users\jbb\github\BetterTimeWarp /WAIT deploy.bat $(TargetDir) $(TargetFileName)
+
+if $(ConfigurationName) == Release (
+ start /D D:\Users\jbb\github\BetterTimeWarp /WAIT buildRelease.bat $(TargetDir) $(TargetFileName)
+)
+
+
+
\ No newline at end of file
diff --git a/BetterTimeWarp/BetterTimeWarp.sln b/BetterTimeWarp/BetterTimeWarp.sln
deleted file mode 100644
index c9867cd..0000000
--- a/BetterTimeWarp/BetterTimeWarp.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterTimeWarp", "BetterTimeWarp.csproj", "{4B05E220-5E03-4B86-8896-B407D71F6A99}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4B05E220-5E03-4B86-8896-B407D71F6A99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4B05E220-5E03-4B86-8896-B407D71F6A99}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4B05E220-5E03-4B86-8896-B407D71F6A99}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4B05E220-5E03-4B86-8896-B407D71F6A99}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = BetterTimeWarp.csproj
- EndGlobalSection
-EndGlobal
diff --git a/BetterTimeWarp/Initialization.cs b/BetterTimeWarp/Initialization.cs
index 38aa7db..92d31be 100644
--- a/BetterTimeWarp/Initialization.cs
+++ b/BetterTimeWarp/Initialization.cs
@@ -1,95 +1,137 @@
using System;
-using System.Collections.Generic;
using UnityEngine;
namespace BetterTimeWarp
{
- [KSPAddon(KSPAddon.Startup.MainMenu, true)]
- public class BetterTimeWarpInitializer : MonoBehaviour
- {
- static bool started = false;
- public void Start()
- {
- //only call this once at the beginning of the game
- if (!started)
- {
- DontDestroyOnLoad (this);
-
- //load the settings
- BetterTimeWarp.SettingsNode = ConfigNode.Load (KSPUtil.ApplicationRootPath + "GameData/BetterTimeWarp/Settings.dat");
-
- //if the settings are not found, regenerate them
- if (BetterTimeWarp.SettingsNode == null)
- {
- ConfigNode node = new ConfigNode ();
- node.AddValue ("enabled", "true");
- BetterTimeWarp.SettingsNode = node;
- }
- if (!BetterTimeWarp.SettingsNode.HasValue ("enabled"))
- {
- BetterTimeWarp.SettingsNode.AddValue ("enabled", "true");
- }
-
- //if enabled = false is in the config, disable the mod
- bool isEnabled = true;
- if (bool.TryParse (BetterTimeWarp.SettingsNode.GetValue ("enabled"), out isEnabled))
- {
- BetterTimeWarp.isEnabled = isEnabled;
- }
- if (!isEnabled)
- {
- Debug.LogError ("[BetterTimeWarp]: enabled = false in settings, disabling BetterTimeWarp");
- return;
- }
- //save the settings, so if they have been regenerated, it exsists and wont cause errors
- BetterTimeWarp.SettingsNode.Save (KSPUtil.ApplicationRootPath + "GameData/BetterTimeWarp/Settings.dat");
-
- //subscribe to the events so that the settings save and the UI can hide/show
- GameEvents.onGameStateSaved.Add (SaveSettings);
- GameEvents.onShowUI.Add (ShowUI);
- GameEvents.onHideUI.Add (HideUI);
-
- //make the physical time warp warning not pop up
- GameSettings.SHOW_PWARP_WARNING = false;
-
- //give every celestial body new time warp altitude limits
- foreach (CelestialBody body in FlightGlobals.Bodies)
- {
- body.timeWarpAltitudeLimits = new float[]{ 0f, 0f, 0f, 0f, 0f, 0f, 100000f, 2000000f };
- }
-
- GameEvents.onLevelWasLoadedGUIReady.Add (OnLevelLoaded);
-
- started = true;
- }
- }
-
- private void OnLevelLoaded(GameScenes scene)
- {
- //call this every scene that needs BetterTimeWarp
- if (scene == GameScenes.FLIGHT || scene == GameScenes.SPACECENTER || scene == GameScenes.TRACKSTATION)
- {
- BetterTimeWarp.Instance = gameObject.AddComponent ();
- }
- }
-
- //called whenever the game autosaves/quicksaves
- void SaveSettings (Game game)
- {
- BetterTimeWarp.SettingsNode.Save (KSPUtil.ApplicationRootPath + "GameData/BetterTimeWarp/Settings.dat", "BetterTimeWarp: Automatically saved at date " + System.DateTime.Now.ToString());
- Debug.Log ("[BetterTimeWarp]: Settings saved");
- BetterTimeWarp.SettingsNode = ConfigNode.Load (KSPUtil.ApplicationRootPath + "GameData/BetterTimeWarp/Settings.dat");
- }
-
- //these are called when F2 is pressed to hide/show the UI
- void ShowUI()
- {
- BetterTimeWarp.ShowUI = true;
- }
- void HideUI()
- {
- BetterTimeWarp.ShowUI = false;
- }
- }
+ [KSPAddon(KSPAddon.Startup.MainMenu, true)]
+ public class BetterTimeWarpInitializer : MonoBehaviour
+ {
+
+ const string CfgPath = "BetterTimeWarp/PluginData";
+
+ public static String ROOT_PATH;
+ private static String CONFIG_BASE_FOLDER;
+ private static String BTW_BASE_FOLDER;
+ public static String BTW_CFG_FILE;
+ private static String BTW_DEFAULT_CFG_FILE;
+
+ static bool started = false;
+ public void Start()
+ {
+ //only call this once at the beginning of the game
+ if (!started)
+ {
+ ROOT_PATH = KSPUtil.ApplicationRootPath;
+ CONFIG_BASE_FOLDER = ROOT_PATH + "GameData/";
+ BTW_BASE_FOLDER = CONFIG_BASE_FOLDER + "BetterTimeWarp/";
+ BTW_CFG_FILE = BTW_BASE_FOLDER + "PluginData/BetterTimeWarp.cfg";
+ BTW_DEFAULT_CFG_FILE = BTW_BASE_FOLDER + "PluginData/BetterTimeWarp_Defaults.cfg";
+
+ DontDestroyOnLoad(this);
+ ConfigNode node;
+ //load the settings
+ Log.Info("Cfg file: " + BTW_CFG_FILE);
+ if (System.IO.File.Exists(BTW_CFG_FILE))
+ {
+
+ BetterTimeWarp.SettingsNode = ConfigNode.Load(BTW_CFG_FILE);
+ Log.Info("Config loaded");
+ }
+ else
+ {
+ BetterTimeWarp.SettingsNode = ConfigNode.Load(BTW_DEFAULT_CFG_FILE);
+ Log.Info("Default configs loaded");
+ }
+
+ //if the settings are not found, regenerate them
+ if (BetterTimeWarp.SettingsNode == null)
+ BetterTimeWarp.SettingsNode = new ConfigNode();
+
+ if (!BetterTimeWarp.SettingsNode.HasNode("BetterTimeWarp"))
+ BetterTimeWarp.SettingsNode.AddNode("BetterTimeWarp");
+
+ node = BetterTimeWarp.SettingsNode.GetNode("BetterTimeWarp");
+
+ //save the settings, so if they have been regenerated, it exsists and wont cause errors
+ BetterTimeWarp.SettingsNode.Save(BTW_CFG_FILE);
+
+ //subscribe to the events so that the settings save and the UI can hide/show
+ GameEvents.onGameStateSaved.Add(SaveSettings);
+ GameEvents.onGameStateLoad.Add(onGameStateLoad);
+ GameEvents.onLevelWasLoaded.Add(onLevelWasLoaded);
+ GameEvents.onShowUI.Add(ShowUI);
+ GameEvents.onHideUI.Add(HideUI);
+
+ //make the physical time warp warning not pop up
+ GameSettings.SHOW_PWARP_WARNING = false;
+
+ //give every celestial body new time warp altitude limits
+ foreach (CelestialBody body in FlightGlobals.Bodies)
+ {
+ body.timeWarpAltitudeLimits = new float[] { 0f, 0f, 0f, 0f, 0f, 0f, 100000f, 2000000f };
+ }
+
+ // GameEvents.onLevelWasLoadedGUIReady.Add (OnLevelLoaded);
+
+ started = true;
+ }
+ }
+
+ void OnDestroy()
+ {
+ GameEvents.onGameStateSaved.Remove(SaveSettings);
+ GameEvents.onGameStateLoad.Remove(onGameStateLoad);
+ GameEvents.onLevelWasLoaded.Remove(onLevelWasLoaded);
+
+
+ GameEvents.onShowUI.Remove(ShowUI);
+ GameEvents.onHideUI.Remove(HideUI);
+ }
+
+ private void onGameStateLoad(ConfigNode data)
+ {
+ Log.Info("onGameStateLoad: Interval = " + GameSettings.AUTOSAVE_INTERVAL / 60.0 + " min");
+
+ HighLogic.CurrentGame.Parameters.CustomParams().StockAutosaveInterval =
+ (int)(GameSettings.AUTOSAVE_INTERVAL / 60.0);
+ HighLogic.CurrentGame.Parameters.CustomParams().StockAutosaveShortInterval =
+ (int)GameSettings.AUTOSAVE_SHORT_INTERVAL;
+ }
+
+#if true
+ private void onLevelWasLoaded(GameScenes scene)
+ {
+ //call this every scene that needs BetterTimeWarp
+ if (scene == GameScenes.FLIGHT || scene == GameScenes.SPACECENTER || scene == GameScenes.TRACKSTATION)
+ {
+ BetterTimeWarp.Instance = gameObject.AddComponent();
+ if (BetterTimeWarp.Instance != null && BetterTimeWarp.Instance.autoDisable)
+ {
+ CheatOptions.InfiniteElectricity = false;
+ BetterTimeWarp.Instance.autoDisable = false;
+ ScreenMessages.PostScreenMessage("Enabling EC Usage", 5);
+ }
+
+ }
+ }
+#endif
+ //called whenever the game autosaves/quicksaves
+ void SaveSettings(Game game)
+ {
+ BetterTimeWarp.SettingsNode.Save(BTW_CFG_FILE, "BetterTimeWarp: Automatically saved at date " + System.DateTime.Now.ToString());
+ Debug.Log("[BetterTimeWarp]: Settings saved");
+ BetterTimeWarp.SettingsNode = ConfigNode.Load(BTW_CFG_FILE);
+ }
+
+ //these are called when F2 is pressed to hide/show the UI
+ void ShowUI()
+ {
+ BetterTimeWarp.ShowUI = true;
+ }
+ void HideUI()
+ {
+ BetterTimeWarp.ShowUI = false;
+ }
+ }
}
diff --git a/BetterTimeWarp/InstallChecker.cs b/BetterTimeWarp/InstallChecker.cs
new file mode 100644
index 0000000..991184a
--- /dev/null
+++ b/BetterTimeWarp/InstallChecker.cs
@@ -0,0 +1,99 @@
+/**
+ * Based on the InstallChecker from the Kethane mod for Kerbal Space Program.
+ * https://github.com/Majiir/Kethane/blob/b93b1171ec42b4be6c44b257ad31c7efd7ea1702/Plugin/InstallChecker.cs
+ *
+ * Original is (C) Copyright Majiir.
+ * CC0 Public Domain (http://creativecommons.org/publicdomain/zero/1.0/)
+ * http://forum.kerbalspaceprogram.com/threads/65395-CompatibilityChecker-Discussion-Thread?p=899895&viewfull=1#post899895
+ *
+ * This file has been modified extensively and is released under the same license.
+ */
+using System;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using UnityEngine;
+
+namespace BetterTimeWarp
+{
+ [KSPAddon(KSPAddon.Startup.Instantly, true)]
+ internal class Startup : MonoBehaviour
+ {
+ private void Start()
+ {
+ string v = "n/a";
+ AssemblyTitleAttribute attributes = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false);
+ string title = attributes?.Title;
+ if (title == null)
+ {
+ title = "TitleNotAvailable";
+ }
+ v = Assembly.GetExecutingAssembly().FullName;
+ if (v == null)
+ {
+ v = "VersionNotAvailable";
+ }
+ Debug.Log("[" + title + "] Version " + v);
+ }
+ }
+
+ [KSPAddon(KSPAddon.Startup.MainMenu, true)]
+ internal class InstallChecker : MonoBehaviour
+ {
+ internal const string MODNAME = "Better Time Warp";
+ internal const string FOLDERNAME = "BetterTimeWarp";
+ internal const string EXPECTEDPATH = FOLDERNAME + "/Plugins";
+
+ protected void Start()
+ {
+ // Search for this mod's DLL existing in the wrong location. This will also detect duplicate copies because only one can be in the right place.
+ var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
+ if (assemblies.Any())
+ {
+ var badPaths = assemblies.Select(a => a.path).Select(p => Uri.UnescapeDataString(new Uri(Path.GetFullPath(KSPUtil.ApplicationRootPath)).MakeRelativeUri(new Uri(p)).ToString().Replace('/', Path.DirectorySeparatorChar)));
+ PopupDialog.SpawnPopupDialog
+ (
+ new Vector2(0.5f, 0.5f),
+ new Vector2(0.5f, 0.5f),
+ "test",
+ "Incorrect " + MODNAME + " Installation",
+ MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + FOLDERNAME + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray()),
+ "OK",
+ false,
+ HighLogic.UISkin
+ );
+ Debug.Log("Incorrect " + MODNAME + " Installation: " + MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + EXPECTEDPATH + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray())
+
+ );
+
+ }
+
+ //// Check for Module Manager
+ //if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
+ //{
+ // PopupDialog.SpawnPopupDialog("Missing Module Manager",
+ // modName + " requires the Module Manager mod in order to function properly.\n\nPlease download from http://forum.kerbalspaceprogram.com/threads/55219 and copy to the KSP/GameData/ directory.",
+ // "OK", false, HighLogic.Skin);
+ //}
+
+ CleanupOldVersions();
+ }
+
+ /*
+ * Tries to fix the install if it was installed over the top of a previous version
+ */
+ void CleanupOldVersions()
+ {
+ try
+ {
+ }
+ catch (Exception ex)
+ {
+ Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
+ "Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);
+
+ }
+ }
+ }
+}
+
diff --git a/BetterTimeWarp/Log.cs b/BetterTimeWarp/Log.cs
new file mode 100644
index 0000000..99f3ada
--- /dev/null
+++ b/BetterTimeWarp/Log.cs
@@ -0,0 +1,142 @@
+using System;
+using System.Collections;
+using System.Diagnostics;
+
+
+namespace BetterTimeWarp
+{
+
+
+ public static class Log
+ {
+ public enum LEVEL
+ {
+ OFF = 0,
+ ERROR = 1,
+ WARNING = 2,
+ INFO = 3,
+ DETAIL = 4,
+ TRACE = 5
+ };
+
+ public static LEVEL level = LEVEL.INFO;
+
+ private static readonly String PREFIX = "BetterTimeWarp" + ": ";
+
+ public static LEVEL GetLevel()
+ {
+ return level;
+ }
+
+ public static void SetLevel(LEVEL level)
+ {
+ UnityEngine.Debug.Log("log level " + level);
+ Log.level = level;
+ }
+
+ public static LEVEL GetLogLevel()
+ {
+ return level;
+ }
+
+ private static bool IsLevel(LEVEL level)
+ {
+ return level == Log.level;
+ }
+
+ public static bool IsLogable(LEVEL level)
+ {
+ return level <= Log.level;
+ }
+
+ public static void Trace(String msg)
+ {
+ if (IsLogable(LEVEL.TRACE))
+ {
+ UnityEngine.Debug.Log(PREFIX + msg);
+ }
+ }
+
+ public static void Detail(String msg)
+ {
+ if (IsLogable(LEVEL.DETAIL))
+ {
+ UnityEngine.Debug.Log(PREFIX + msg);
+ }
+ }
+
+ [ConditionalAttribute("DEBUG")]
+ public static void Info(String msg)
+ {
+ if (IsLogable(LEVEL.INFO))
+ {
+ UnityEngine.Debug.Log(PREFIX + msg);
+ }
+ }
+
+ [ConditionalAttribute("DEBUG")]
+ public static void Test(String msg)
+ {
+ //if (IsLogable(LEVEL.INFO))
+ {
+ UnityEngine.Debug.LogWarning(PREFIX + "TEST:" + msg);
+ }
+ }
+
+ static Stack funcStack = new Stack();
+
+ [ConditionalAttribute("DEBUG")]
+ public static void PushStackInfo(string funcName, string msg)
+ {
+ funcStack.Push(funcName);
+ // if (Debug_Level_1_Active)
+ Log.Info(msg);
+ }
+
+ [ConditionalAttribute("DEBUG")]
+ public static void PopStackInfo(string msg)
+ {
+ if (funcStack.Count > 0)
+ {
+ string f = (string)funcStack.Pop();
+ }
+ else
+ Log.Info("Pop failed, no values on stack");
+ //if (Debug_Level_1_Active)
+ Log.Info(msg);
+ }
+ [ConditionalAttribute("DEBUG")]
+ public static void ShowStackInfo()
+ {
+ int cnt = 0;
+ Log.Info("Stack size: " + funcStack.Count.ToString());
+ foreach (var obj in funcStack)
+ {
+ Log.Info("Stack[" + cnt.ToString() + "] = " + (string)obj);
+ cnt++;
+ }
+ }
+
+ public static void Warning(String msg)
+ {
+ if (IsLogable(LEVEL.WARNING))
+ {
+ UnityEngine.Debug.LogWarning(PREFIX + msg);
+ }
+ }
+
+ public static void Error(String msg)
+ {
+ if (IsLogable(LEVEL.ERROR))
+ {
+ UnityEngine.Debug.LogError(PREFIX + msg);
+ }
+ }
+
+ public static void Exception(Exception e)
+ {
+ Log.Error("exception caught: " + e.GetType() + ": " + e.Message);
+ }
+
+ }
+}
diff --git a/BetterTimeWarp/Properties/AssemblyInfo.cs b/BetterTimeWarp/Properties/AssemblyInfo.cs
index 047d7e5..eeb9918 100644
--- a/BetterTimeWarp/Properties/AssemblyInfo.cs
+++ b/BetterTimeWarp/Properties/AssemblyInfo.cs
@@ -14,10 +14,12 @@
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion ("2.1.0.0")]
-[assembly: KSPAssembly("BetterTimeWarp", 2, 1)]
+//[assembly: AssemblyVersion ("2.1.0.0")]
+//[assembly: KSPAssembly("BetterTimeWarp", 2, 1)]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
+[assembly: KSPAssemblyDependency("ClickThroughBlocker", 1, 0)]
+[assembly: KSPAssemblyDependency("ToolbarController", 1, 0)]
\ No newline at end of file
diff --git a/BetterTimeWarp/RegisterToolbar.cs b/BetterTimeWarp/RegisterToolbar.cs
new file mode 100644
index 0000000..21b6e9f
--- /dev/null
+++ b/BetterTimeWarp/RegisterToolbar.cs
@@ -0,0 +1,21 @@
+using UnityEngine;
+using CommNet;
+using KSP.UI.Screens;
+using KSP.UI.Screens.Flight;
+
+using System.Reflection;
+using ClickThroughFix;
+using ToolbarControl_NS;
+
+
+namespace BetterTimeWarp
+{
+ [KSPAddon(KSPAddon.Startup.MainMenu, true)]
+ public class RegisterToolbar : MonoBehaviour
+ {
+ void Start()
+ {
+ ToolbarControl.RegisterMod(BetterTimeWarp.MODID, BetterTimeWarp.MODNAME);
+ }
+ }
+}
\ No newline at end of file
diff --git a/BetterTimeWarp/Settings.cs b/BetterTimeWarp/Settings.cs
new file mode 100644
index 0000000..e888cfc
--- /dev/null
+++ b/BetterTimeWarp/Settings.cs
@@ -0,0 +1,140 @@
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using UnityEngine;
+using System;
+
+// http://forum.kerbalspaceprogram.com/index.php?/topic/147576-modders-notes-for-ksp-12/#comment-2754813
+// search for "Mod integration into Stock Settings
+
+namespace BetterTimeWarp
+{
+ public class BTWCustomParams : GameParameters.CustomParameterNode
+ {
+ public override string Title { get { return "Better Time Warp"; } }
+ public override GameParameters.GameMode GameMode { get { return GameParameters.GameMode.ANY; } }
+ public override string Section { get { return "Better Time Warp"; } }
+ public override string DisplaySection { get { return "Better Time Warp"; } }
+ public override int SectionOrder { get { return 1; } }
+ public override bool HasPresets { get { return true; } }
+
+ [GameParameters.CustomParameterUI("Mod Enabled?",
+ toolTip ="Changing this requires restarting the game")]
+ public bool enabled = true;
+
+ [GameParameters.CustomParameterUI("Always hide the button?")]
+ public bool hideButton = false;
+
+ [GameParameters.CustomParameterUI("Hide the button in the flight scene?")]
+ public bool hideButtonInFlight = true;
+
+ [GameParameters.CustomParameterUI("Hide the dropdown button in the flight scene?")]
+ public bool hideDropdownButtonInFlight = false;
+
+ [GameParameters.CustomParameterUI("Lock window positions in flight?")]
+ public bool lockWindowPosInFlight = true;
+
+ [GameParameters.CustomParameterUI("Lock window positions (other than flight)?")]
+ public bool lockWindowPos = true;
+
+ public override void SetDifficultyPreset(GameParameters.Preset preset)
+ { }
+ public override bool Enabled(MemberInfo member, GameParameters parameters)
+ {
+ if (member.Name == "hideButtonInFlight" && hideButton)
+ {
+ hideButtonInFlight = true;
+ return false;
+ }
+ return true;
+ }
+ public override bool Interactible(MemberInfo member, GameParameters parameters)
+ {
+ return true;
+ }
+ public override IList ValidValues(MemberInfo member)
+ {
+ return null;
+ }
+ }
+
+
+ public class BTWCustomParams2 : GameParameters.CustomParameterNode
+ {
+ public override string Title { get { return "Better Time Warp"; } }
+ public override GameParameters.GameMode GameMode { get { return GameParameters.GameMode.ANY; } }
+ public override string Section { get { return "Better Time Warp"; } }
+ public override string DisplaySection { get { return "Better Time Warp"; } }
+ public override int SectionOrder { get { return 2; } }
+ public override bool HasPresets { get { return false; } }
+
+ [GameParameters.CustomStringParameterUI("Stock autosave settings (persistent.sfs)", toolTip = "", lines = 2)]
+ public string note1 = "";
+
+ [GameParameters.CustomIntParameterUI("Autosave Interval (min)",
+ toolTip =
+ "Interval for autosave to persistent.sfs.\n"+
+ "It shrinks with the Physics Time Warp",
+ minValue = 1, maxValue = 180, stepSize = 1)]
+ public int StockAutosaveInterval = 5;
+
+ [GameParameters.CustomIntParameterUI("Autosave Short Interval (sec)",
+ toolTip =
+ "That's the time interval for another attempt at saving,\n" +
+ "in case the first attempt fails. If the auto save fails,\n" +
+ "it will continuously retry on that interval until it's able to save again.",
+ minValue = 10, maxValue = 1800, stepSize = 10)]
+ public int StockAutosaveShortInterval = 30;
+
+ [GameParameters.CustomParameterUI("Reset Intervals to Default",
+ toolTip = "Reset autosave intervals and write to settings.cfg")]
+ public bool ResetStockIntervalSettings = false;
+
+ [GameParameters.CustomParameterUI("Write Intervals to settings.cfg",
+ toolTip = "Don't forget to write changed intervals to settings.cfg")]
+ public bool WriteStockIntervalSettings = false;
+
+ public void ResetSettings()
+ {
+ StockAutosaveInterval = 5;
+ StockAutosaveShortInterval = 30;
+
+ WriteSettings();
+ }
+ public void WriteSettings()
+ {
+ GameSettings.AUTOSAVE_INTERVAL = StockAutosaveInterval * 60;
+ GameSettings.AUTOSAVE_SHORT_INTERVAL = StockAutosaveShortInterval;
+ GameSettings.SaveSettings();
+ string message = String.Format("Intervals are updated: {0} min, {1} sec",
+ GameSettings.AUTOSAVE_INTERVAL / 60, GameSettings.AUTOSAVE_SHORT_INTERVAL);
+ Log.Info(message);
+ ScreenMessages.PostScreenMessage(message);
+ }
+ public override bool Enabled(MemberInfo member, GameParameters parameters)
+ {
+ return true;
+ }
+ public override bool Interactible(MemberInfo member, GameParameters parameters)
+ {
+ if (member.Name == nameof(ResetStockIntervalSettings) && ResetStockIntervalSettings)
+ {
+ ResetSettings();
+ ResetStockIntervalSettings = false;
+ }
+ if (member.Name == nameof(WriteStockIntervalSettings) && WriteStockIntervalSettings)
+ {
+ WriteSettings();
+ WriteStockIntervalSettings = false;
+ }
+ return true;
+ }
+ public override IList ValidValues(MemberInfo member)
+ {
+ return null;
+ }
+ }
+}
diff --git a/BetterTimeWarp/TimeWarpRates.cs b/BetterTimeWarp/TimeWarpRates.cs
index 2ca822a..5affa6c 100644
--- a/BetterTimeWarp/TimeWarpRates.cs
+++ b/BetterTimeWarp/TimeWarpRates.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
namespace BetterTimeWarp
@@ -9,25 +10,35 @@ public class TimeWarpRates
public string Name;
public float[] Rates;
public bool Physics;
+ public bool DisableECAtHighWarp;
+ public int ecIndexDisable;
- public TimeWarpRates(string name, float[] rates, bool physics)
+ public TimeWarpRates(string name, float[] rates, bool physics, bool disable, int ecIndexDisable)
{
this.Name = name;
this.Rates = rates;
this.Physics = physics;
+ this.DisableECAtHighWarp = disable;
+ this.ecIndexDisable = ecIndexDisable;
}
public TimeWarpRates()
{
}
+
+ public static string rateFmt(float f)
+ {
+
+ if (f < 1000)
+ return "";
+ else
+ return "N0";
+
+ }
public override string ToString ()
{
- string ratesString = "";
- foreach (float f in this.Rates)
- {
- ratesString += f.ToString () + ", ";
- }
- ratesString.Remove (ratesString.Length - 3);
+ var rates = Rates.Select(z => z.ToString(rateFmt(z)));
+ String ratesString = String.Join(", ", rates);
return this.Name + " - " + ratesString;
}
}
diff --git a/Changelog.txt b/Changelog.txt
new file mode 100644
index 0000000..d34d246
--- /dev/null
+++ b/Changelog.txt
@@ -0,0 +1,167 @@
+2.3.0
+ Initial release
+
+2.3.1
+ Changed settings file to live in PluginData as a true .cfg file
+ Fixed "enabled" setting in cfg file to be in a node
+ Updated link in Readme.md file
+
+2.3.2
+ Renamed Settings.dat to BetterTimeWarp.cfg (forgot to rename the file)
+
+2.3.3
+ Moved enabled setting into standard system settings
+ Fixed window from staying open on the main menu
+ Made windows movable
+ Changed mod activation from gameObject.AddComponent (); to using the [KSPAddon(KSPAddon.Startup.FlightAndKSC | KSPAddon.Startup.TrackingStation, false)]
+ Added setting to hide button in all scenes
+ Added setting to hide button in flight
+ Added setting to lock window positions in Flight
+ Added setting to lock window positions everywhere else
+ Fixed dialogs which didn't have an OK button
+
+2.3.4
+ Fixed the dropdown icon from covering up the Commnet icons
+
+2.3.5
+ Fixed button not appearing on map view and in tracking screen
+ Fixed dropdown location when Kerbal is on EVA
+ Fixed dropdown location when Commnet is not active
+ Added option to disable dropdown in settings
+
+2.3.5.1
+ Added check for relay when adjusting dropdown
+
+2.3.5.2
+ Changed checks from circumstances to seeing if the icons are being displayed.
+ Fixed nullrefs when Commnet not enabled in flight scene
+
+2.3.5.3
+ Fixed nullrefs which were occuring during startup
+
+2.3.5.4
+ Removed some log spam
+
+2.3.6
+ Fixed nullrefs in orbit when no control
+
+2.3.6.1
+ Fixed nullref when no comms are available, affected positioning of dropdown button
+
+2.3.6.2
+ Replaced "s" button with icons
+
+2.3.6.3
+ Fixed Physicless warp so that all use the same timestep
+
+2.3.7
+ Fixed dropdown offset for when no probe control
+ Fixed issue when timewarping >stock max, Inactive Resource Converters could use fuel more rapidly
+
+2.3.7.1
+ Now looks at all vesselsLoaded when fixing the ResourceConverter problem
+
+2.3.7.3
+ Fixed display of very large values to not use scientific notation
+ Fixed issue where sometimes, with high warp, vessels using the ResourceConverter were being unpacked after the fix for the high warp issue was done. Thanks to forum user @eech for helping to test this.
+ Added code to deal with someone turning on a ResourceConverter while in warp
+ Changed code from being started every scene to only being started at the spacecenter, and set not to destroy
+ Renamed config file in release to defaults, will not overwrite existing configs after this release
+
+2.3.7.4
+ Fixed mod not saving custom values
+
+2.3.8
+ updated for 1.3
+ Updated dialog calls for new 1.3 parameter
+ Added DisplaySection function, will need to localize it
+
+2.3.9
+ updated fo 1.3.1
+
+2.3.9.1
+ Updated build scripts
+
+2.3.10
+ updated for 1.4.1
+ Added support for ToolbarControl
+ Added support for ClickThroughBlocker
+
+2.3.10.1
+ Updated for all 1.4
+ Updated to use updated ToolbarControl
+ Removed blizzy options
+
+2.3.10.2
+ Version bump for 1.5 rebuild
+
+2.3.11
+ Bug fix for lossless physics causing issues, both after warp is done and while warp was in progress
+ Removed max version from .version file
+
+2.3.11.1
+ Fixed stupid bug which caused nullrefs in the editor
+
+2.3.11.3
+ Fixed log spam caused when saving game settings
+
+2.3.11.4
+ Version bump for 1.7.2
+
+2.3.12
+ Added InstallChecker
+ Updated AssemblyVersion.tt
+ Rebuild for 1.8
+
+2.3.12.1
+ Updated MiniAVC to 1.4.0
+
+2.3.12.2
+ Updated MiniAVC.dll to 1.4.0.2 to fix a nasty CTD
+
+2.3.12.3
+ Really did the MiniAVC update
+
+2.3.11.7 for KSP 1.6.1-1.7.3
+
+2.3.12.4 for KSP 1.8+
+ Fixed issue with selected timewarp being reset upon scene change
+
+
+2.3.11.9 for KSP 1.6.1-1.7.3 && 2.3.12.5 for KSP 1.8
+ Fixed initialization of vars to be initialized in Start() rather than the instantiator
+
+2.3.12.6
+ Rebuild and version bump to fix CKAN, dropping builds for 1.7.3
+
+2.3.12.7
+ Renamed BetterTimeWarp-1.8.0.version file back to normal : BetterTimeWarp.version
+ Moved dropdown button over 32 pixels for 1.12
+
+2.3.12.8
+ Renamed the 1.8 to normal
+ Moved RegisterToolbar into it's own file
+ Moved drop-down button to the right to avoid a conflict with the new alarm clock
+
+2.3.12.9
+ Added AssemblyFileVersion
+
+2.3.13
+ Thanks to user @yalov for these:
+ new Default Warp Rates
+ Physics Warp 1, 4, 8, 12
+ add AUTOSAVE_INTERVAL and AUTOSAVE_SHORT_INTERVAL to settings
+ fix rounding
+ add new Default CustomWarpRates: Five Warp, Soft Physics Warp, Physics Warp 6-10, Physics Warp 15-30
+
+2.3.13.1
+ Updated version file to use github for new version info
+ Copied webpage to Readme.md file
+ Minor variable change for better readability
+
+2.3.14
+ Added option to enable infinite EC when timewarp gets too high
+ Added dropdown to spacecenter
+
+2.3.14.1
+ Fix bug where multiple buttons were being added to the toolbar after each scene change
\ No newline at end of file
diff --git a/GameData/BetterTimeWarp/BetterTimeWarp.dll b/GameData/BetterTimeWarp/BetterTimeWarp.dll
deleted file mode 100644
index c3aeecf..0000000
Binary files a/GameData/BetterTimeWarp/BetterTimeWarp.dll and /dev/null differ
diff --git a/GameData/BetterTimeWarp/BetterTimeWarp.version b/GameData/BetterTimeWarp/BetterTimeWarp.version
new file mode 100644
index 0000000..10d0c14
--- /dev/null
+++ b/GameData/BetterTimeWarp/BetterTimeWarp.version
@@ -0,0 +1,30 @@
+{
+ "NAME": "BetterTimeWarpContinued",
+ "URL": "https://raw.githubusercontent.com/linuxgurugamer/BetterTimeWarpContinued/refs/heads/master/BetterTimeWarp.version",
+ "DOWNLOAD": "https://github.com/linuxgurugamer/BetterTimeWarpContinued/releases",
+ "GITHUB": {
+ "USERNAME": "linuxgurugamer",
+ "REPOSITORY": "BetterTimeWarpContinued"
+ },
+ "VERSION": {
+ "MAJOR": 2,
+ "MINOR": 3,
+ "PATCH": 14,
+ "BUILD": 0
+ },
+ "KSP_VERSION": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 4
+ },
+ "KSP_VERSION_MIN": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 0
+ },
+ "KSP_VERSION_MAX": {
+ "MAJOR": 1,
+ "MINOR": 12,
+ "PATCH": 99
+ }
+}
diff --git a/GameData/BetterTimeWarp/Icons/Thumbs.db b/GameData/BetterTimeWarp/Icons/Thumbs.db
deleted file mode 100644
index 796a0c4..0000000
Binary files a/GameData/BetterTimeWarp/Icons/Thumbs.db and /dev/null differ
diff --git a/GameData/BetterTimeWarp/Icons/application_24.png b/GameData/BetterTimeWarp/Icons/application_24.png
new file mode 100644
index 0000000..8990da1
Binary files /dev/null and b/GameData/BetterTimeWarp/Icons/application_24.png differ
diff --git a/GameData/BetterTimeWarp/Icons/application.png b/GameData/BetterTimeWarp/Icons/application_38.png
similarity index 100%
rename from GameData/BetterTimeWarp/Icons/application.png
rename to GameData/BetterTimeWarp/Icons/application_38.png
diff --git a/GameData/BetterTimeWarp/License.txt b/GameData/BetterTimeWarp/License.txt
new file mode 100644
index 0000000..81d8ca5
--- /dev/null
+++ b/GameData/BetterTimeWarp/License.txt
@@ -0,0 +1,6 @@
+GNU GENERAL PUBLIC LICENSE
+
+Full License: https://gnu.org/licenses/gpl-3.0.txt
+
+NOTE: Software is provided as is, meaning that you run it at your own risk. I (the author) is not liable for any harm done to your computer.
+
diff --git a/GameData/BetterTimeWarp/PluginData/BetterTimeWarp_Defaults.cfg b/GameData/BetterTimeWarp/PluginData/BetterTimeWarp_Defaults.cfg
new file mode 100644
index 0000000..8866782
--- /dev/null
+++ b/GameData/BetterTimeWarp/PluginData/BetterTimeWarp_Defaults.cfg
@@ -0,0 +1,61 @@
+enabled = true
+BetterTimeWarp
+{
+ ScaleCameraSpeed = True
+ UseLosslessPhysics = False
+ LosslessUpperThreshold = 2
+ CurrentTimeWarp = Standard Warp
+ CurrentPhysWarp = Standard Physics Warp
+
+ // Standard: 5,10,50,100,1000,10000,100000
+
+ CustomWarpRate
+ {
+ name = Five Warp
+ warpRate1 = 5
+ warpRate2 = 25
+ warpRate3 = 125
+ warpRate4 = 1,000
+ warpRate5 = 10,000
+ warpRate6 = 100,000
+ warpRate7 = 1,000,000
+ physics = False
+ }
+ CustomWarpRate
+ {
+ name = Hyper Warp
+ warpRate1 = 10
+ warpRate2 = 100
+ warpRate3 = 1000
+ warpRate4 = 10000
+ warpRate5 = 100000
+ warpRate6 = 1000000
+ warpRate7 = 10000000
+ physics = False
+ }
+
+ CustomWarpRate
+ {
+ name = Soft Physics Warp
+ warpRate1 = 1.25
+ warpRate2 = 1.5
+ warpRate3 = 1.75
+ physics = True
+ }
+ CustomWarpRate
+ {
+ name = Physics Warp 4-12
+ warpRate1 = 4
+ warpRate2 = 8
+ warpRate3 = 12
+ physics = True
+ }
+ CustomWarpRate
+ {
+ name = Slow-Mo
+ warpRate1 = 0.5
+ warpRate2 = 0.25
+ warpRate3 = 0.1
+ physics = True
+ }
+}
diff --git a/GameData/BetterTimeWarp/Readme.md b/GameData/BetterTimeWarp/Readme.md
new file mode 100644
index 0000000..431be7f
--- /dev/null
+++ b/GameData/BetterTimeWarp/Readme.md
@@ -0,0 +1,17 @@
+#Better Time Warp
+
+Forum thread: http://forum.kerbalspaceprogram.com/index.php?/topic/154935-*
+
+BetterTimeWarp is a mod for Kerbal Space Program that enables customized time warping.
+
+To install:
+
+1. Merge GameData folder with the one in your KSP folder
+2. Done!
+
+
+Instructions
+
+You can access the UI in one of two ways, either by clicking the B button on the toolbar, or , in the flight scene, clicking the down button at the top, right next to the clock (in 1.2.2, it is right now on top of the probe-control icon, will be fixed)
+
+Once the UI is opened,
\ No newline at end of file
diff --git a/GameData/BetterTimeWarp/Settings.dat b/GameData/BetterTimeWarp/Settings.dat
deleted file mode 100644
index c77d938..0000000
--- a/GameData/BetterTimeWarp/Settings.dat
+++ /dev/null
@@ -1,29 +0,0 @@
-enabled = true
-BetterTimeWarp
-{
- ScaleCameraSpeed = True
- UseLosslessPhysics = False
- LosslessUpperThreshold = 2
- CurrentTimeWarp = Standard Warp
- CurrentPhysWarp = Standard Physics Warp
- CustomWarpRate
- {
- name = Hyper Warp
- warpRate1 = 10
- warpRate2 = 100
- warpRate3 = 1000
- warpRate4 = 10000
- warpRate5 = 100000
- warpRate6 = 1000000
- warpRate7 = 1E+07
- physics = False
- }
- CustomWarpRate
- {
- name = Slow-Mo
- warpRate1 = 0.5
- warpRate2 = 0.25
- warpRate3 = 0.1
- physics = True
- }
-}
diff --git a/Readme.md b/Readme.md
index 02880a2..6ddb42d 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,10 +1,77 @@
#Better Time Warp
-Forum thread: forum.kerbalspaceprogram.com/threads/85926
+Forum thread: http://forum.kerbalspaceprogram.com/index.php?/topic/154935-*
BetterTimeWarp is a mod for Kerbal Space Program that enables customized time warping.
To install:
1. Merge GameData folder with the one in your KSP folder
-2. Done!
\ No newline at end of file
+2. Done!
+
+
+=============================
+This is a continuation of the Better Time Warp mod originally made by @MrHappyFace, who hasn't been around since Sept. 3. The original thread can be found here:http://forum.kerbalspaceprogram.com/index.php?/topic/77565-*
+
+This first post is mostly copied from the original thread
+
+Availability
+
+Download: http://spacedock.info/mod/1162/BetterTimeWarpContinued
+Source:https://github.com/linuxgurugamer/BetterTimeWarp
+License: GPLv3
+The new version for KSP 1.4.1 has new dependencies
+
+New Dependencies
+
+Click Through Blocker
+ToolbarController
+CKAN has been updated to install the dependencies, if needed.
+
+Basic GUI:
+
+http://i.imgur.com/hkJmQxT.png
+
+
+
+Advanced GUI with Settings:
+
+http://i.imgur.com/7DJrzKZ.png
+
+Gifs:
+
+Without Lossless Physics Warp: http://gfycat.com/ObedientFlawedArctichare
+
+With Lossless Physics Warp: http://gfycat.com/DeepSkeletalKoala
+
+1,000,000x time warp in low orbit: http://gfycat.com/GrandNervousGoldfinch
+
+
+
+Better Time Warp is HappyFaceIndustries' first mod, which adds the ability to customize your time warp.
+
+It has many of the same features as Time Control, and WarpUnlocker, but with a stylish UI and customization features.
+
+Features:
+
+
+
+Customizable physics and regular (On-Rails) warp
+Lower-than-1 physics warp can be used to help with laggy, high part ships. It is also pretty good for cinematics
+0x time warp can be used to freeze time
+Great for ion engines! 1 hour burn completed in 3 minutes at 20x physical warp.
+Higher warp settings can be used in lower orbits
+Lossless Physics, meaning that you can keep accurate physics simulation even at high physical time warp. Note that strange things can happen when doing that, and is not recommended, see bugs below
+Non-Intrusive UI, which can be disabled using F2
+Can be enabled/disabled in the settings file, without uninstalling or deleting
+Self regenerating settings file
+Persistent time warp selections
+Works in space center and tracking station
+All planets get the same altitude limits for time warp: 0m for 1-1000, 100,000m for 10,000x, and 2,000,000m for 100,000x
+
+
+Bugs:
+
+Physics warp below x0.1 or above x100 is kind of buggy
+Rarely, if using low (less than 0.1) physics warp on EVA, your kerbal will go flying off at about 7x light speed
+More will be added to this list as they are found.
diff --git a/jenkins.txt b/jenkins.txt
new file mode 100644
index 0000000..cf4dd93
--- /dev/null
+++ b/jenkins.txt
@@ -0,0 +1,56 @@
+#
+# This file contains several types of information:
+#
+# 0 KSP version, if not the current
+# 1 Mod install directory, version file to use when building zip file
+# 2 Project definitions
+# 3 Files to copy, source, dest
+# 4 Directory to copy, sourcedir, destdir
+# 5 Add ModuleManager to GameData
+# 6 Spacedock.info mod id
+# 7 Additional folders in the GameData to be included in the final zip
+# 8 Additional mods to include, will copy into GameData and will be included in zip
+
+# Special case if files are in the GameData directory itself
+# Special Case: 7:GameData
+
+#
+# All paths are relative to the top git folder of the repo
+#
+# and must use forward slashes
+#
+
+# 0:KSPVersion
+#0:1.7.3
+
+# 1:GAMEDIR, VERSIONFILE [, GITHUBREPO ]
+1:BetterTimeWarp, BetterTimeWarp.version
+
+# 2:PROJNAME, PROJFILE, VERSIONFILE, PLUGINSFOLDER
+2:BetterTimeWarp,BetterTimeWarp/BetterTimeWarp.csproj,BetterTimeWarp.version,GameData/BetterTimeWarp/Plugins
+
+# 3:SOURCEFILE, DESTDIR
+3:BetterTimeWarp.version,GameData/BetterTimeWarp
+3:License.txt,GameData/BetterTimeWarp
+3:Readme.md,GameData/BetterTimeWarp
+
+# 4:SOURCDIR, DESTDIR
+#4:Textures,GameData/ManeuverQueue/Textures
+
+# 5:ModuleManager
+# 5:ModuleManager
+
+# 6:mod_id
+#6:1272
+
+# 7: AdditionalFolders in the GameData, 1 per line
+# Special case if files are in the GameData directory itself
+# Special Case: 7:GameData
+#7:ConnectedLivingSpace
+
+# 8: AdditionalMods to include
+#8:ConnectedLivingSpace
+
+#
+# End of file
+#