From 65069dd2d0609a028e73b8d1475533a150e2ad6e Mon Sep 17 00:00:00 2001 From: hashashin Date: Sun, 17 Apr 2016 12:22:47 +0200 Subject: [PATCH 1/2] make it work in 1.1 --- Makefile | 4 ++-- src/Targetron.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d3d704f..1eb1318 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ APP := Targetron -VERSION := 1.4.2.1 +VERSION := 1.4.3 KSPDIR := /mnt/games/Steam/SteamApps/common/Kerbal\ Space\ Program MANAGED := ${KSPDIR}/KSP_Data/Managed @@ -27,7 +27,7 @@ info: ${TARGETS}: ${SRC_FILES} ${GMCS} -t:library -lib:${MANAGED} \ - -r:Assembly-CSharp,UnityEngine \ + -r:Assembly-CSharp,UnityEngine,KSPUtil,UnityEngine.UI \ -out:$@ $^ clean: diff --git a/src/Targetron.cs b/src/Targetron.cs index 029039f..b9f574b 100644 --- a/src/Targetron.cs +++ b/src/Targetron.cs @@ -11,7 +11,7 @@ public class Targetron : MonoBehaviour { public static GameObject GameObjectInstance; private static PluginConfiguration config; - private const String VERSION = "1.4.2.1"; + private const String VERSION = "1.4.3"; private readonly int WINDOWID_GUI = GUIUtility.GetControlID(7225, FocusType.Passive); private readonly int WINDOWID_TOOLTIP = GUIUtility.GetControlID(7226, FocusType.Passive); private readonly int WINDOWID_CONTEXT = GUIUtility.GetControlID(7227, FocusType.Passive); @@ -158,8 +158,6 @@ public void Start() pos.width = Mathf.Clamp(pos.width, minWindowWidth, maxWindowWidth); pos.height = Mathf.Clamp(pos.height, minWindowHeight, maxWindowHeight); - RenderingManager.AddToPostDrawQueue(0, OnDraw); - if (!ToolbarManager.ToolbarAvailable) return; ToolbarButton = ToolbarManager.Instance.add("Targetron", "tgbutton"); ToolbarButton.Text = "Targetron " + VERSION; @@ -191,6 +189,11 @@ private void expandWindow() pos.width = lastWidth; } + public void OnGUI() + { + OnDraw(); + } + public void Update() { if (FlightGlobals.fetch != null && FlightGlobals.fetch.vessels != null && FlightGlobals.fetch.activeVessel != null) //Check if in flight From de33da673c8a07f37abd119b3de4fa81993cc474 Mon Sep 17 00:00:00 2001 From: hashashin Date: Thu, 21 Apr 2016 21:49:22 +0200 Subject: [PATCH 2/2] fixes http://forum.kerbalspaceprogram.com/index.php?/topic/105730-10x-11-targetron-continued-bis-wathever-143-1742016/#comment-2527696 --- Makefile | 2 +- src/Targetron.cs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1eb1318..e214f3f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ APP := Targetron -VERSION := 1.4.3 +VERSION := 1.4.4 KSPDIR := /mnt/games/Steam/SteamApps/common/Kerbal\ Space\ Program MANAGED := ${KSPDIR}/KSP_Data/Managed diff --git a/src/Targetron.cs b/src/Targetron.cs index b9f574b..1593a98 100644 --- a/src/Targetron.cs +++ b/src/Targetron.cs @@ -11,7 +11,7 @@ public class Targetron : MonoBehaviour { public static GameObject GameObjectInstance; private static PluginConfiguration config; - private const String VERSION = "1.4.3"; + private const String VERSION = "1.4.4"; private readonly int WINDOWID_GUI = GUIUtility.GetControlID(7225, FocusType.Passive); private readonly int WINDOWID_TOOLTIP = GUIUtility.GetControlID(7226, FocusType.Passive); private readonly int WINDOWID_CONTEXT = GUIUtility.GetControlID(7227, FocusType.Passive); @@ -165,6 +165,25 @@ public void Start() ToolbarButton.TexturePath = "Targetron/Icons/targetron"; ToolbarButton.Visibility = new GameScenesVisibility(GameScenes.FLIGHT); ToolbarButton.OnClick += e => toggleOn = !toggleOn; + GameEvents.onVesselChange.Add(saveConfig); + } + + private void saveConfig(Vessel data) + { + if (!expand) + expandWindow(); + + config.SetValue("version", VERSION); + config.SetValue("pos", pos); + config.SetValue("expand", expand); + config.SetValue("toggleOn", toggleOn); + for (int i = 0; i < filters.Count; i++) + config.SetValue("filter" + i, filters[i].Enabled); + config.SetValue("sortMode", sortMode); + config.save(); + + if (!expand) + collapseWindow(); } //Collapses the window @@ -507,6 +526,7 @@ private void OnDestroy() //Save the expanded postion and collapse state saveConfig(); if (ToolbarButton != null) ToolbarButton.Destroy(); + GameEvents.onVesselChange.Remove(saveConfig); } //Sorts Vessels by their distance from the active vessel