From 01830115aa6dfc16fe7a0ab95d5b6559e91eaf52 Mon Sep 17 00:00:00 2001 From: Clifton M Date: Sun, 9 Oct 2016 13:29:04 -0400 Subject: [PATCH] Update to 1.2, performance enhancements, bug fixes. --- AnyRes/AnyRes.csproj | 13 +++-- AnyRes/Handler.cs | 123 +++++++++++++++++++++++++------------------ AnyRes/Presets.cs | 2 +- 3 files changed, 82 insertions(+), 56 deletions(-) diff --git a/AnyRes/AnyRes.csproj b/AnyRes/AnyRes.csproj index 85fb355..ed4e5c3 100644 --- a/AnyRes/AnyRes.csproj +++ b/AnyRes/AnyRes.csproj @@ -1,4 +1,4 @@ - + Debug @@ -33,7 +33,7 @@ - ..\..\..\Desktop\KSPData\KSPAssets.dll + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\KSPAssets.dll ..\..\..\Desktop\KSPData\KSPCore.dll @@ -42,13 +42,16 @@ ..\..\..\Desktop\KSPData\KSPUtil.dll - ..\..\..\Desktop\KSPData\Assembly-CSharp.dll + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll - ..\..\..\Desktop\KSPData\Assembly-CSharp-firstpass.dll + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp-firstpass.dll - ..\..\..\Desktop\KSPData\UnityEngine.dll + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.UI.dll diff --git a/AnyRes/Handler.cs b/AnyRes/Handler.cs index ba3aea6..38c5110 100644 --- a/AnyRes/Handler.cs +++ b/AnyRes/Handler.cs @@ -7,7 +7,7 @@ namespace AnyRes { - [KSPAddon(KSPAddon.Startup.SpaceCentre, true)] + [KSPAddon(KSPAddon.Startup.EveryScene, false)] public class AnyRes : MonoBehaviour { @@ -23,72 +23,81 @@ public class AnyRes : MonoBehaviour public bool fullScreen = true; public bool reloadScene = false; - private static ApplicationLauncherButton appLauncherButton; + private static ApplicationLauncherButton appLauncherButton = null; Presets presets; + + void Start() { - Debug.Log ("[AnyRes] Loaded"); + if (HighLogic.LoadedScene == GameScenes.SETTINGS) + { - presets = gameObject.AddComponent () as Presets; + windowEnabled = true; + anyresWinRect.x = 7; + anyresWinRect.y = 231; - //Thanks bananashavings http://forum.kerbalspaceprogram.com/index.php?/profile/156147-bananashavings/ - https://gist.github.com/bananashavings/e698f4359e1628b5d6ef - //Also thanks to Crzyrndm for the fix to that code! - if (appLauncherButton == null) { - - appLauncherButton = ApplicationLauncher.Instance.AddModApplication( - () => { windowEnabled = true; }, - () => { presets.newEnabled = false; presets.loadEnabled = false; presets.windowEnabled = false; windowEnabled = false; }, - () => { }, - () => { }, - () => { }, - () => { }, - ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.VAB, - (Texture)GameDatabase.Instance.GetTexture("AnyRes/textures/toolbar", false)); - - } - Debug.Log("[AnyRes] 1"); - - xString = GameSettings.SCREEN_RESOLUTION_WIDTH.ToString (); - yString = GameSettings.SCREEN_RESOLUTION_HEIGHT.ToString (); - fullScreen = GameSettings.FULLSCREEN; - Debug.Log("[AnyRes] 2"); - - if (HighLogic.LoadedScene == GameScenes.SETTINGS) { + } + else if (HighLogic.LoadedScene == GameScenes.EDITOR) + { - windowEnabled = true; - anyresWinRect.x = 35; - anyresWinRect.y = 99; + anyresWinRect.x = Screen.width - 272; + anyresWinRect.y = Screen.height - 231; - } else if (HighLogic.LoadedScene == GameScenes.EDITOR) { + } - anyresWinRect.x = 1008; - anyresWinRect.y = 489; + Debug.Log ("[AnyRes] Loaded"); - } else { + presets = gameObject.AddComponent () as Presets; - anyresWinRect.x = 35; - anyresWinRect.y = 99; + + //Debug.Log("[AnyRes] 1"); + + xString = GameSettings.SCREEN_RESOLUTION_WIDTH.ToString (); + yString = GameSettings.SCREEN_RESOLUTION_HEIGHT.ToString (); + fullScreen = GameSettings.FULLSCREEN; + //Debug.Log("[AnyRes] 2"); - } - DontDestroyOnLoad(this); + + //DontDestroyOnLoad(this); } public void OnDisable () { - //Destroy the button in order to create a new one. It's required with multiple scene handling, unfortunately. - ApplicationLauncher.Instance.RemoveModApplication (appLauncherButton); - appLauncherButton = null; - Debug.Log ("[AnyRes] Remove application button"); + //Destroy the button in order to create a new one. It's required with multiple scene handling, unfortunately. + if (appLauncherButton != null) + { + ApplicationLauncher.Instance.RemoveModApplication(appLauncherButton); + appLauncherButton = null; + Debug.Log("[AnyRes] Remove application button"); + } } void Update() { - if ((GameSettings.MODIFIER_KEY.GetKey() ) && Input.GetKeyDown (KeyCode.Slash)) { + //Thanks bananashavings http://forum.kerbalspaceprogram.com/index.php?/profile/156147-bananashavings/ - https://gist.github.com/bananashavings/e698f4359e1628b5d6ef + //Also thanks to Crzyrndm for the fix to that code! + //(HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.EDITOR) + if (appLauncherButton == null && (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.EDITOR)) + { + + appLauncherButton = ApplicationLauncher.Instance.AddModApplication( + () => { windowEnabled = true; }, + () => { presets.newEnabled = false; presets.loadEnabled = false; presets.windowEnabled = false; windowEnabled = false; }, + () => { }, + () => { }, + () => { }, + () => { }, + ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.VAB, + (Texture)GameDatabase.Instance.GetTexture("AnyRes/textures/toolbar", false)); + + } + + if ((GameSettings.MODIFIER_KEY.GetKey() ) && Input.GetKeyDown (KeyCode.Slash)) { windowEnabled = !windowEnabled; if (ApplicationLauncher.Ready) { @@ -108,14 +117,21 @@ void Update() { } } + + presets.windowRect.x = anyresWinRect.xMin + anyresWinRect.width; + presets.windowRect.y = anyresWinRect.yMin; + presets.loadRect.x = presets.windowRect.xMin + presets.windowRect.width; + presets.loadRect.y = presets.windowRect.yMin; + presets.newRect.x = presets.windowRect.xMin + presets.windowRect.width; + presets.newRect.y = anyresWinRect.yMin; -// Meant for debugging -// Debug.Log ("X: " + windowRect.x.ToString ()); -// Debug.Log ("Y: " + windowRect.y.ToString ()); + // Meant for debugging + // Debug.Log ("X: " + anyresWinRect.x.ToString ()); + // Debug.Log ("Y: " + anyresWinRect.y.ToString ()); - } + } void OnGUI() { @@ -140,9 +156,16 @@ void GUIActive(int windowID) { } else { - presets.windowRect = new Rect(anyresWinRect.xMin + anyresWinRect.width, anyresWinRect.yMin, 200, 100); - presets.loadRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 400); - presets.newRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 230); + //presets.windowRect = new Rect(anyresWinRect.xMin + anyresWinRect.width, anyresWinRect.yMin, 200, 100); + presets.windowRect.x = anyresWinRect.xMin + anyresWinRect.width; + presets.windowRect.y = anyresWinRect.yMin; + //presets.loadRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 400); + presets.loadRect.x = presets.windowRect.xMin + presets.windowRect.width; + presets.loadRect.y = presets.windowRect.yMin; + //presets.newRect = new Rect(presets.windowRect.xMin + presets.windowRect.width, anyresWinRect.yMin, 200, 230); + presets.newRect.x = presets.windowRect.xMin + presets.windowRect.width; + presets.newRect.y = anyresWinRect.yMin; + } } diff --git a/AnyRes/Presets.cs b/AnyRes/Presets.cs index 3325d0d..fa72e73 100644 --- a/AnyRes/Presets.cs +++ b/AnyRes/Presets.cs @@ -58,7 +58,7 @@ void OnGUI () { if (loadEnabled) { - loadRect = GUI.Window (09273, loadRect, onLoad, "Load Preset"); + loadRect = GUI.Window (09274, loadRect, onLoad, "Load Preset"); }