Skip to content

Commit

Permalink
Merge pull request #4 from jinks/1.1
Browse files Browse the repository at this point in the history
1.1
  • Loading branch information
hashashin committed Apr 21, 2016
2 parents 510b994 + de33da6 commit 54b9b8a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP := Targetron
VERSION := 1.4.2.1
VERSION := 1.4.4

KSPDIR := /mnt/games/Steam/SteamApps/common/Kerbal\ Space\ Program
MANAGED := ${KSPDIR}/KSP_Data/Managed
Expand Down Expand Up @@ -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:
Expand Down
29 changes: 26 additions & 3 deletions src/Targetron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.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);
Expand Down Expand Up @@ -158,15 +158,32 @@ 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;
ToolbarButton.ToolTip = "Targetron " + VERSION;
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
Expand All @@ -191,6 +208,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
Expand Down Expand Up @@ -504,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
Expand Down

0 comments on commit 54b9b8a

Please sign in to comment.