From b32f2d5f9daa22241a1a36a0504007d3708d7505 Mon Sep 17 00:00:00 2001 From: TriggerAu Date: Sat, 6 Aug 2016 22:58:11 +1000 Subject: [PATCH 1/4] [2.8.1.1] Beta test version for stock app replacement --- AlternateResourcePanel/ARP.cs | 2 +- AlternateResourcePanel/ARPAppLauncher.cs | 9 +++++++-- AlternateResourcePanel/ARPWindowDebug.cs | 12 ++++++++---- .../KSPAlternateResourcePanel.version | 4 ++-- AlternateResourcePanel/Properties/AssemblyInfo.cs | 4 ++-- PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt | 5 +++++ 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/AlternateResourcePanel/ARP.cs b/AlternateResourcePanel/ARP.cs index a06a971..8f86a30 100644 --- a/AlternateResourcePanel/ARP.cs +++ b/AlternateResourcePanel/ARP.cs @@ -25,7 +25,7 @@ private KSPAlternateResourcePanel() internal ARPWindowSettings windowSettings; internal ARPWindowResourceConfig windowResourceConfig; - internal Rect windowMainResetPos = new Rect(Screen.width - 381, 0, 299, 20); + internal Rect windowMainResetPos = new Rect(Screen.width - 339 - (GameSettings.UI_SCALE_APPS * 42), 0, 299, 20); //variables internal PartResourceVisibleList SelectedResources; diff --git a/AlternateResourcePanel/ARPAppLauncher.cs b/AlternateResourcePanel/ARPAppLauncher.cs index f16391d..a665e88 100644 --- a/AlternateResourcePanel/ARPAppLauncher.cs +++ b/AlternateResourcePanel/ARPAppLauncher.cs @@ -7,6 +7,7 @@ using KSP.UI.Screens; using UnityEngine; using KSPPluginFramework; +using System.Collections; namespace KSPAlternateResourcePanel { @@ -25,7 +26,7 @@ void OnGUIAppLauncherReady() if (KSPAlternateResourcePanel.settings.ButtonStyleChosen == ARPWindowSettings.ButtonStyleEnum.StockReplace) { - ReplaceStockAppButton(); + StartCoroutine(ReplaceStockAppButton()); } } } @@ -143,8 +144,12 @@ internal void DestroyAppLauncherButton() internal Boolean StockAppToBeHidden = false; internal DateTime StockAppToBeHiddenAttemptDate; - internal void ReplaceStockAppButton() + + internal IEnumerator ReplaceStockAppButton() { + while(ResourceDisplay.Instance.appLauncherButton == null || !ApplicationLauncher.Ready) + yield return null; + if (ResourceDisplay.Instance.appLauncherButton == null) { if (!StockAppToBeHidden) diff --git a/AlternateResourcePanel/ARPWindowDebug.cs b/AlternateResourcePanel/ARPWindowDebug.cs index 9b95f7c..42eb055 100644 --- a/AlternateResourcePanel/ARPWindowDebug.cs +++ b/AlternateResourcePanel/ARPWindowDebug.cs @@ -28,18 +28,22 @@ internal class ARPWindowDebug: MonoBehaviourWindowPlus internal KSPAlternateResourcePanel mbARP; internal Settings settings; - public Int32 intTest1 = 298; - public Int32 intTest2=40; + public Int32 intTest1 = 339; + public Int32 intTest2=0; public Int32 intTest3=299; public Int32 intTest4 = 20; public static Int32 intTest5 = 10; - //ApplicationLauncherButton origResButton=null; //Boolean Clicked = false; internal override void DrawWindow(int id) { - mbARP.windowMainResetPos = new Rect(Screen.width - intTest1, intTest2, intTest3, intTest4); + + ; + + + + mbARP.windowMainResetPos = new Rect(Screen.width - intTest1 - (GameSettings.UI_SCALE_APPS * 42), intTest2, intTest3, intTest4); //GUILayout.Label(Drawing.RectTest.ToString()); //GUILayout.Label(Drawing.RectTest2.ToString()); diff --git a/AlternateResourcePanel/KSPAlternateResourcePanel.version b/AlternateResourcePanel/KSPAlternateResourcePanel.version index d871906..64fa8c4 100644 --- a/AlternateResourcePanel/KSPAlternateResourcePanel.version +++ b/AlternateResourcePanel/KSPAlternateResourcePanel.version @@ -6,12 +6,12 @@ "MAJOR": 2, "MINOR": 8, "PATCH": 1, - "BUILD": 0 + "BUILD": 1 }, "KSP_VERSION": { "MAJOR": 1, "MINOR": 1, - "PATCH": 2 + "PATCH": 3 }, "KSP_VERSION_MIN": { "MAJOR": 1, diff --git a/AlternateResourcePanel/Properties/AssemblyInfo.cs b/AlternateResourcePanel/Properties/AssemblyInfo.cs index 2dad2a5..585363d 100644 --- a/AlternateResourcePanel/Properties/AssemblyInfo.cs +++ b/AlternateResourcePanel/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.8.1.0")] -[assembly: AssemblyFileVersion("2.8.1.0")] +[assembly: AssemblyVersion("2.8.1.1")] +[assembly: AssemblyFileVersion("2.8.1.1")] diff --git a/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt b/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt index 5e70753..357589a 100644 --- a/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt +++ b/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt @@ -28,6 +28,11 @@ LICENSE This work is licensed under an MIT license as outlined at the OSI site. Visit the documentation site for more details and Attribution VERSION HISTORY +Version 2.8.1.1 - KSP Version: 1.1.3 +BETA VERSION +- Attempt to fix issue with Stock buttone replacement +- Add some login for App Launcher scaling + Version 2.8.1.0 - KSP Version: 1.1.2 - Fixed issue with singe stage vessels showing no resources - Fixed issue with flow control buttons having small hitbox (Issue #83) From 3437c7494fbe8245e02d32d386cc824121c3011c Mon Sep 17 00:00:00 2001 From: TriggerAu Date: Sun, 16 Oct 2016 14:52:32 +1100 Subject: [PATCH 2/4] Basic 1.2 adjustments - now for the errors --- .../KSPAlternateResourcePanel.csproj | 22 ++++++++--------- .../SharedStuff/ToolbarWrapper.cs | 24 +++++++++++++------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/AlternateResourcePanel/KSPAlternateResourcePanel.csproj b/AlternateResourcePanel/KSPAlternateResourcePanel.csproj index e174cc2..ea3da02 100644 --- a/AlternateResourcePanel/KSPAlternateResourcePanel.csproj +++ b/AlternateResourcePanel/KSPAlternateResourcePanel.csproj @@ -44,10 +44,6 @@ False ..\..\_Versions\KSP_win_PluginTest_Minimal\KSP_Data\Managed\Assembly-CSharp.dll - - False - ..\..\_Versions\KSP_win_PluginTest_Minimal\KSP_Data\Managed\KSPUtil.dll - @@ -89,14 +85,16 @@ rem Set the Variables we need echo Finding KSP -if exist "R:\~Games\KSP_Win_PlugInTest_Minimal\KSP.exe" ( - set GAMEPATH="R:\~Games\KSP_Win_PlugInTest_Minimal" -) else if exist "D:\Programming\KSP\_Versions\KSP_win_PluginTest_Minimal\KSP.exe" ( - set GAMEPATH="D:\Programming\KSP\_Versions\KSP_Win_PlugInTest_Minimal" -) else if exist "C:\~Games\KSP_Win_PlugInTest_Minimal\KSP.exe" ( - set GAMEPATH="C:\~Games\KSP_Win_PlugInTest_Minimal -) else if exist "D:\Programming\KSP\_Versions\KSP_Win_PlugInTest\KSP.exe" ( - set GAMEPATH="D:\Programming\KSP\_Versions\KSP_win_PluginTest" +rem if exist "R:\~Games\KSP_Win_PlugInTest_Minimal\KSP.exe" ( +rem set GAMEPATH="R:\~Games\KSP_Win_PlugInTest_Minimal" +rem ) else if exist "D:\~Games\KSP_Win_PlugInTest_Minimal\KSP.exe" ( +rem set GAMEPATH="D:\~Games\KSP_Win_PlugInTest_Minimal" +rem ) else if exist "C:\~Games\KSP_Win_PlugInTest_Minimal\KSP.exe" ( +rem set GAMEPATH="C:\~Games\KSP_Win_PlugInTest_Minimal +rem ) else if exist "D:\~Games\KSP_Win_PlugInTest\KSP.exe" ( + +if exist "D:\Programming\KSP\_Versions\KSP_Win_PlugInTest\KSP.exe" ( + set GAMEPATH="D:\Programming\KSP\_Versions\KSP_Win_PlugInTest" ) else if exist "C:\~Games\KSP_Win_PlugInTest\KSP.exe" ( set GAMEPATH="C:\~Games\KSP_Win_PlugInTest" )else ( diff --git a/AlternateResourcePanel/SharedStuff/ToolbarWrapper.cs b/AlternateResourcePanel/SharedStuff/ToolbarWrapper.cs index 63f1ce8..c173593 100644 --- a/AlternateResourcePanel/SharedStuff/ToolbarWrapper.cs +++ b/AlternateResourcePanel/SharedStuff/ToolbarWrapper.cs @@ -725,13 +725,23 @@ internal ToolbarTypes() { button = new ButtonTypes(iButtonType); } - internal static Type getType(string name) { - return AssemblyLoader.loadedAssemblies - .SelectMany(a => a.assembly.GetExportedTypes()) - .SingleOrDefault(t => t.FullName == name); - } - - internal static PropertyInfo getProperty(Type type, string name) { + internal static Type getType(string name) + { + Type type = null; + AssemblyLoader.loadedAssemblies.TypeOperation(t => + { + if(t.FullName == name) + type = t; + } + ); + + if(type != null) { + return type; + } + return null; + } + + internal static PropertyInfo getProperty(Type type, string name) { return type.GetProperty(name, BindingFlags.Public | BindingFlags.Instance); } From c8be450b1e93b6ed509cdfa7fd92407941626a2a Mon Sep 17 00:00:00 2001 From: TriggerAu Date: Sun, 16 Oct 2016 15:09:05 +1100 Subject: [PATCH 3/4] Fixed 1.2 compilation issues --- AlternateResourcePanel/ARP.cs | 13 +++++-------- AlternateResourcePanel/ARPWindowDebug.cs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/AlternateResourcePanel/ARP.cs b/AlternateResourcePanel/ARP.cs index 8f86a30..13a57b8 100644 --- a/AlternateResourcePanel/ARP.cs +++ b/AlternateResourcePanel/ARP.cs @@ -557,12 +557,9 @@ internal override void RepeatingWorker() //Now loop through and update em foreach (Part p in active.parts) { - //Check each part for a control module to see if its status is Good - foreach (ModuleCommand mc in p.Modules.OfType()) - { - if (mc.State == ModuleCommand.ControlSourceState.Good && active == FlightGlobals.ActiveVessel) - blnVesselIsControllable = true; - } + //Check if its a controllable vessel + if(active == FlightGlobals.ActiveVessel && active.IsControllable) + blnVesselIsControllable = true; //is the part decoupled in the last stage Boolean DecoupledInLastStage = (p.DecoupledAt() == LastStage); @@ -586,7 +583,7 @@ internal override void RepeatingWorker() if (!settings.ShowBase && !lstResourcesLastStage.ContainsKey(pr.info.id)) { LogFormatted_DebugOnly("Adding 0 value into last stage"); - PartResource prTemp = new PartResource() { info = pr.info, amount = 0, maxAmount = 0 }; + PartResource prTemp = new PartResource(p) { info = pr.info, amount = 0, maxAmount = 0 }; lstResourcesLastStage.UpdateResource(prTemp); } } @@ -1038,7 +1035,7 @@ internal override void LateUpdate() //position the part windows if (lstPartWindows.Count > 0) { - vectVesselCOMScreen = FlightCamera.fetch.mainCamera.WorldToScreenPoint(FlightGlobals.ActiveVessel.findWorldCenterOfMass()); + vectVesselCOMScreen = FlightCamera.fetch.mainCamera.WorldToScreenPoint(FlightGlobals.ActiveVessel.CoM); DateTime dteStart = DateTime.Now; diff --git a/AlternateResourcePanel/ARPWindowDebug.cs b/AlternateResourcePanel/ARPWindowDebug.cs index 42eb055..591478e 100644 --- a/AlternateResourcePanel/ARPWindowDebug.cs +++ b/AlternateResourcePanel/ARPWindowDebug.cs @@ -85,15 +85,15 @@ internal override void DrawWindow(int id) GUILayout.Label(String.Format("Draw Settings Duration: {0:0.00}ms", mbARP.windowSettings.DrawWindowInternalDuration.TotalMilliseconds)); GUILayout.Label(String.Format("Draw Main Duration: {0:0.00}ms", mbARP.windowMain.DrawWindowInternalDuration.TotalMilliseconds)); - Boolean blnControl = false; - foreach (Part p in FlightGlobals.ActiveVessel.Parts) - { - foreach (ModuleCommand mc in p.Modules.OfType()) - { - if (mc.State == ModuleCommand.ControlSourceState.Good) - blnControl = true; - } - } + //Boolean blnControl = false; + //foreach (Part p in FlightGlobals.ActiveVessel.Parts) + //{ + // foreach (ModuleCommand mc in p.Modules.OfType()) + // { + // if (mc.State == ModuleCommand.ControlSourceState.Good) + // blnControl = true; + // } + //} //GUILayout.Label(String.Format("CommandState:{0}", blnControl)); GUILayout.Label(String.Format("vesseliscontrollable:{0}", mbARP.blnVesselIsControllable)); From 12830457201e7928428b8fef5419f5c2f683d809 Mon Sep 17 00:00:00 2001 From: TriggerAu Date: Sun, 16 Oct 2016 15:11:32 +1100 Subject: [PATCH 4/4] Version 2.9.0.0 ready --- .../KSPAlternateResourcePanel.version | 14 +++++++------- AlternateResourcePanel/Properties/AssemblyInfo.cs | 4 ++-- PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt | 3 +++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/AlternateResourcePanel/KSPAlternateResourcePanel.version b/AlternateResourcePanel/KSPAlternateResourcePanel.version index 64fa8c4..58ca449 100644 --- a/AlternateResourcePanel/KSPAlternateResourcePanel.version +++ b/AlternateResourcePanel/KSPAlternateResourcePanel.version @@ -4,23 +4,23 @@ "DOWNLOAD" : "https://github.com/TriggerAu/AlternateResourcePanel/releases", "VERSION": { "MAJOR": 2, - "MINOR": 8, - "PATCH": 1, - "BUILD": 1 + "MINOR": 9, + "PATCH": 0, + "BUILD": 0 }, "KSP_VERSION": { "MAJOR": 1, - "MINOR": 1, - "PATCH": 3 + "MINOR": 2, + "PATCH": 0 }, "KSP_VERSION_MIN": { "MAJOR": 1, - "MINOR": 1, + "MINOR": 2, "PATCH": 0 }, "KSP_VERSION_MAX": { "MAJOR": 1, - "MINOR": 1, + "MINOR": 2, "PATCH": 99 } } diff --git a/AlternateResourcePanel/Properties/AssemblyInfo.cs b/AlternateResourcePanel/Properties/AssemblyInfo.cs index 585363d..ccda2d4 100644 --- a/AlternateResourcePanel/Properties/AssemblyInfo.cs +++ b/AlternateResourcePanel/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.8.1.1")] -[assembly: AssemblyFileVersion("2.8.1.1")] +[assembly: AssemblyVersion("2.9.0.0")] +[assembly: AssemblyFileVersion("2.9.0.0")] diff --git a/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt b/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt index 357589a..d52c459 100644 --- a/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt +++ b/PlugInFiles/ReadMe-KSPAlternateResourcePanel.txt @@ -28,6 +28,9 @@ LICENSE This work is licensed under an MIT license as outlined at the OSI site. Visit the documentation site for more details and Attribution VERSION HISTORY +Version 2.9.0.0 - KSP Version: 1.2.0 +- Recompile for 1.2 + Version 2.8.1.1 - KSP Version: 1.1.3 BETA VERSION - Attempt to fix issue with Stock buttone replacement