diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt b/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt
index d8c420a..4f49a49 100644
--- a/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt
+++ b/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt
@@ -1,4 +1,10 @@
-V0.22.1.0 "KSP 1.1.2 Update"
+V0.22.2.0 "Bug Fixes"
+Fixed bug with Icons not loading on Linux.
+Efficiency clean-up on code modules (speed and memory use).
+Fix bug where DeepFreeze is not maintaining and updating Vessel Information for Vessels with Freezer parts, causing Exceptions in the log and vessels not
+appearing in the Vessel List in the DeepFreeze GUI window.
+Moved Config.cfg file from Plugins to /Plugins/PluginData to prevent resetting Module Manager cache every time you change a setting.
+V0.22.1.0 "KSP 1.1.2 Update"
Fixed portrait camera issues.
Fixed On-Screen messages for Kerbal Name when in Alternate - Cryopod Camera mode.
Fixed spacing (scroll lists) in the DeepFreeze GUI menus.
diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version b/Distribution/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version
index a0dbf4c..ce4b59f 100644
--- a/Distribution/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version
+++ b/Distribution/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version
@@ -2,8 +2,8 @@
"NAME":"DeepFreeze Continued...",
"URL":"http://ksp-avc.cybutek.net/version.php?id=183",
"DOWNLOAD":"http://spacedock.info/mod/142/DeepFreeze%20Continued...",
-"VERSION":{"MAJOR":0,"MINOR":22,"PATCH":1,"BUILD":0},
+"VERSION":{"MAJOR":0,"MINOR":22,"PATCH":2,"BUILD":0},
"KSP_VERSION":{"MAJOR":1,"MINOR":1,"PATCH":2},
-"KSP_VERSION_MIN":{"MAJOR":1,"MINOR":1,"PATCH":1},
+"KSP_VERSION_MIN":{"MAJOR":1,"MINOR":1,"PATCH":2},
"KSP_VERSION_MAX":{"MAJOR":1,"MINOR":1,"PATCH":2}
}
\ No newline at end of file
diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_bundle.xml b/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_bundle.xml
deleted file mode 100644
index 24df987..0000000
--- a/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_bundle.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- JPLRepo
- KSPedia Screens for the DeepFreeze mod.
-
-
-
-
-
-
-
-
-
- squadcore
-
-
\ No newline at end of file
diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_kspedia.xml b/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_kspedia.xml
deleted file mode 100644
index 06e9e99..0000000
--- a/Distribution/GameData/REPOSoftTech/DeepFreeze/KSPedia/deepfreeze_kspedia.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
- DeepFreeze
- DeepFreezeMain
-
-
-
- Parts
- DeepFreezeParts
-
-
-
-
- Settings
- DeepFreezeSettings
-
-
-
-
- VesselMenu
- DeepFreezeVesselMenu
-
-
-
-
- KACMenu
- DeepFreezeKACMenu
-
-
-
-
-
-
-
-
- deepfreeze
- Assets/KSPedia/DeepFreezeVesselMenu.prefab
-
-
-
-
- The vessel Menu - Shown by clicking the DeepFreeze Icon.
-The top half of the screen shows you all known Vessels that contain DeepFreeze Freezer parts.
-If you have set EC usage and/or Temperature usage settings on in the settings menu you will see the Temperature and/or the current EC status of each part in this menu.
-
-
- EC and Tmp Status Values are colour coded.
-If you have Remote Tech mod installed you will also see the Remote Tech status.
-If you have Kerbal Alarm Clock installed any Alarms associated with a vessel will show an Alarms Button (see the Alarms KSPedia entry).
-LastUpd - Indicates the last time the vessel was active and had it's EC and temperature actively updated.
-TimeRem - Is approx. time remaining for EC based on current Freezer usage.
-In the bottom half of the window will be a list of all Kerbals that are on-board a known Freezer in flight. Freeze & Thaw buttons will appear and allow you to Freeze or thaw your kerbals.
-
-
- Lots of information is displayed about your Freezer in the part right click menu. You can also access the Vessel Menu and Freeze and Thaw your kerbals from here.
-
-
-
-
-
- deepfreeze
- Assets/KSPedia/DeepFreezeSettings.prefab
-
-
-
-
- The Settings Menu Options In Order:
-- If ElectricCharge is required to run Freezers when there are frozen kerbals.
-- If on running out of EC or over Temp freezers will kill frozen kerbals.
-- If previous is on kerbals will become comatose for this period of time instead of being killed.
-- If on frozen kerbals will be thawed out automatically when vessels are recovered.
-- If previous is on the cost of funds to thaw each frozen kerbal automatically.
-- The amount of ElectricCharge to thaw or freeze a kerbal in flight.
-- The amount of Glykerol required to freeze a kerbal in flight.
-- If on Temperature regulation of freezer parts is required.
-- If previous is on the minimum temperature a freezer must have (internal) in order to freeze a kerbal successfully (temperature can be seen via the DeepFreeze vessel window or via the part right click menu).
-- The maximum temperature a freezer can be to maintain frozen kerbals.
-- The amount of heat generated by a Cryopod during a thaw or freeze process.
-- The amount of heat generated by the Freezer to maintain each frozen kerbal inside.
-- If on Temperatures in menus are shown in Kelvin, if off temperatures are show in Celcius.
-- If on Stock application launcher Icon is used. If off (and you have it installed) the Toolbar Mod Icons will be used.
-- If on strip lights in Freezers (that have them) will animate.
-- Spam the log with lots of debug messages (use for capturing logs for reporting problems).
-- If on you get lots of tooltips on every DeepFreeze menu item.
-
-
-
-
-
- deepfreeze
- Assets/KSPedia/DeepFreezeParts.prefab
-
-
-
-
- DeepFreeze
-
-
- The CRY-0300 has animated doors and the CRY-0300R is transparent (with RasterPropMonitor installed). Both can hold One Kerbal and are equipped with one Cryopod. The CRY-0300R can be radially attached.
-
-
- All DeepFreeze Freezers come with a built-in Glykerol storage tank of various capacities. But the Radial Glykerol Tank allows you to bring along extra Glykerol if required.
-
-
- The CRY-1300 is a 2.5M Freezer with three Cryopod (kerbal) capacity.
-
-
- The CRY-2300 is a 2.5M Freeze with ten Cryopod (kerbal) capacity.
-
-
- The CRY-5000 (4 Cryopod) and the X200 Glykerol Container are actually distributed as part of the KPBS Mod but are DeepFreeze parts (and dependant) made to fit-in and be part of KPBS mod.
-
-
-
-
-
- deepfreeze
- Assets/KSPedia/DeepFreezeMain.prefab
-
-
-
-
- DeepFreeze
-
-
- DeepFreeze is a Mod that allows you to Freeze Kerbals using the magic of Glykerol and Electricity. Whilst frozen Kerbals will not consume any resources (from Life Support Mods).
-
-
- DeepFreeze Freezer Parts come in a variety of sizes. From the CRY-0300 and CRY-0300R Single Kerbal Freezers right up to the 10 kerbal capacity CRY-2300.
-
-
- The GUI Window allows easy access to monitor all your vessels equiped with DeepFreezer parts and buttons to freeze and thaw your Kerbals.
-
-
-
-
-
- deepfreeze
- Assets/KSPedia/DeepFreezeKACMenu.prefab
-
-
-
-
- The DeepFreeze Alarms Menu is available if you have also installed the Kerbal Alarm Clock Mod. It can be accessed from the DeepFreeze Vessel Menu (Alarms button at the bottom of the window) at the Space Center or in flight (alarms buttons appear next to the vessels in the list (only if the vessel already has at least one KAC Alarm defined within Kerbal Alarm Clock mod itself.
-
-
- Once you have defined a Kerbal Alarm Clock Alarm that is attached to one of your Deepfreeze equipped vessels you can access the Alarms Menu.
-All Alarms will be shown for a vessel when selected and you can then modify each alarm.
-For each Alarm you are able to define Thaw and/or Freeze commands for each Kerbal on-board.
-When the KAC alarm is triggered any DeepFreeze commands you have assigned will be executed at that time.
-NB: If you have the Remote Tech mod installed you are only able to modify the DeepFreeze commands that are attached to a KAC alarm IF you have active Remote Tech control of that vessel. You do not need control of the vessel for the commands, once defined, to execute when the alarm is triggered.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg b/Distribution/GameData/REPOSoftTech/DeepFreeze/Plugins/PluginData/Config.cfg
similarity index 100%
rename from Distribution/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg
rename to Distribution/GameData/REPOSoftTech/DeepFreeze/Plugins/PluginData/Config.cfg
diff --git a/Source/DFEditorFilter.cs b/Source/DFEditorFilter.cs
index ce6ee3b..f1dcb73 100644
--- a/Source/DFEditorFilter.cs
+++ b/Source/DFEditorFilter.cs
@@ -20,6 +20,8 @@
using KSP.UI.Screens;
using RUI.Icons.Selectable;
using UnityEngine;
+using System.Reflection;
+using System.Linq;
namespace DF
{
@@ -46,7 +48,25 @@ private void Awake()
{
Debug.Log("DFEditorFilter Awake");
GameEvents.onGUIEditorToolbarReady.Add(SubCategories);
- //ModuleManager.MMPatchLoader.addPostPatchCallback(DFMMCallBack);
+ /*
+ //Attempt to add Module Manager callback - find the base type
+ System.Type MMType = AssemblyLoader.loadedAssemblies
+ .Select(a => a.assembly.GetExportedTypes())
+ .SelectMany(t => t)
+ .FirstOrDefault(t => t.FullName == "ModuleManager.MMPatchLoader");
+ if (MMType != null)
+ {
+ MethodInfo MMPatchLoaderInstanceMethod = MMType.GetMethod("get_Instance", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
+ if (MMPatchLoaderInstanceMethod != null)
+ {
+ object actualMM = MMPatchLoaderInstanceMethod.Invoke(null,
+ BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static, null, null, null);
+ MethodInfo MMaddPostPatchCallbackMethod = MMType.GetMethod("addPostPatchCallback", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
+ if (actualMM != null && MMaddPostPatchCallbackMethod != null)
+ MMaddPostPatchCallbackMethod.Invoke(actualMM, new object[] { this.DFMMCallBack() });
+ }
+
+ }*/
DFMMCallBack();
//load the icons
icon_DeepFreeze_Editor.LoadImage(File.ReadAllBytes("GameData/REPOSoftTech/DeepFreeze/Icons/DeepFreezeEditor.png"));
@@ -54,7 +74,7 @@ private void Awake()
Debug.Log("DFEditorFilter Awake Complete");
}
- public void DFMMCallBack()
+ public bool DFMMCallBack()
{
Debug.Log("DFEDitorFilter DFMMCallBack");
avPartItems.Clear();
@@ -68,6 +88,7 @@ public void DFMMCallBack()
}
}
Debug.Log("DFEDitorFilter DFMMCallBack end");
+ return true;
}
private bool EditorItemsFilter(AvailablePart avPart)
diff --git a/Source/DFEnums.cs b/Source/DFEnums.cs
new file mode 100644
index 0000000..c1a4fbe
--- /dev/null
+++ b/Source/DFEnums.cs
@@ -0,0 +1,32 @@
+/*
+ * DeepFreeze Continued...
+ * (C) Copyright 2015, Jamie Leighton
+ *
+ * Kerbal Space Program is Copyright(C) 2013 Squad.See http://kerbalspaceprogram.com/. This
+ * project is in no way associated with nor endorsed by Squad.
+ *
+ * This file is part of JPLRepo's DeepFreeze (continued...) - a Fork of DeepFreeze. Original Author of DeepFreeze is 'scottpaladin' on the KSP Forums.
+ * This File was not part of the original Deepfreeze but was written by Jamie Leighton.
+ * (C) Copyright 2015, Jamie Leighton
+ *
+ * Continues to be licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 4.0)
+ * creative commons license.See
+ * for full details.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace DF
+{
+ public enum DoorState
+ {
+ OPEN,
+ CLOSED,
+ OPENING,
+ CLOSING,
+ UNKNOWN
+ }
+}
diff --git a/Source/DFExtDoorMgr.cs b/Source/DFExtDoorMgr.cs
new file mode 100644
index 0000000..5f433f0
--- /dev/null
+++ b/Source/DFExtDoorMgr.cs
@@ -0,0 +1,93 @@
+/*
+ * DeepFreeze Continued...
+ * (C) Copyright 2015, Jamie Leighton
+ *
+ * Kerbal Space Program is Copyright(C) 2013 Squad.See http://kerbalspaceprogram.com/. This
+ * project is in no way associated with nor endorsed by Squad.
+ *
+ * This file is part of JPLRepo's DeepFreeze (continued...) - a Fork of DeepFreeze. Original Author of DeepFreeze is 'scottpaladin' on the KSP Forums.
+ * This File was not part of the original Deepfreeze but was written by Jamie Leighton.
+ * (C) Copyright 2015, Jamie Leighton
+ *
+ * Continues to be licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 4.0)
+ * creative commons license.See
+ * for full details.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using RSTUtils;
+
+namespace DF
+{
+ public class DFExtDoorMgr : InternalModule
+ {
+ private DeepFreezer Freezer;
+
+ public override void OnUpdate()
+ {
+ base.OnUpdate();
+ if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && FlightGlobals.ActiveVessel != null)
+ {
+ if (Freezer == null)
+ {
+ Freezer = part.FindModuleImplementing();
+ Utilities.Log_Debug("DFExtDoorMgr OnUpdate Set part " + part.name);
+ }
+ }
+ }
+
+ public void ButtonExtDoor(bool state)
+ {
+ if (Freezer == null)
+ {
+ Freezer = part.FindModuleImplementing();
+ Utilities.Log_Debug("DFExtDoorMgr buttonExtDoorState set part " + part.name);
+ }
+ if (Freezer == null) return; // If freezer is still null just return
+ if (!Freezer.ExternalDoorActive) return; // if freezer doesn't have an external door just return.
+
+ if (Freezer._externaldoorstate == DoorState.OPEN)
+ {
+ //Door is open so we trigger a closedoor.
+ Freezer.eventCloseDoors();
+ Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired triggerred eventCloseDoors");
+ }
+ else
+ {
+ if (Freezer._externaldoorstate == DoorState.CLOSED)
+ {
+ //Door is closed so we trigger a opendoor.
+ Freezer.eventOpenDoors();
+ Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired triggerred eventOpenDoors");
+ }
+ else
+ {
+ // door already opening or closing...
+ Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired but door state is opening, closing or unknown");
+ }
+ }
+ }
+
+ public bool ButtonExtDoorState()
+ {
+ // Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoorState fired");
+ if (Freezer == null)
+ {
+ Freezer = part.FindModuleImplementing();
+ Utilities.Log_Debug("DFExtDoorMgr buttonExtDoorState set part " + part.name);
+ }
+ if (Freezer == null) return false; // if freezer still null return false
+ if (!Freezer.ExternalDoorActive) return false; // if freezer doesn't have an external door just return.
+ if (Freezer._externaldoorstate == DoorState.CLOSED || Freezer._externaldoorstate == DoorState.CLOSING || Freezer._externaldoorstate == DoorState.UNKNOWN)
+ {
+ Utilities.Log_Debug("DFExtDoorMgr Door is closed or closing or unknown return state false");
+ return false;
+ }
+ Utilities.Log_Debug("DFExtDoorMgr Door is open or opening return state true");
+ return true;
+ }
+ }
+}
diff --git a/Source/DFInstallFix.cs b/Source/DFInstallFix.cs
deleted file mode 100644
index 26a88de..0000000
--- a/Source/DFInstallFix.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * DFInstallFix.cs
- *
- *
- * Kerbal Space Program is Copyright (C) 2013 Squad. See http://kerbalspaceprogram.com/. This
- * project is in no way associated with nor endorsed by Squad.
- *
- * This file is part of JPLRepo's DeepFreeze (continued...) - a Fork of DeepFreeze. Original Author of DeepFreeze is 'scottpaladin' on the KSP Forums.
- * This File was not part of the original Deepfreeze but was written by Jamie Leighton.
- * (C) Copyright 2015, Jamie Leighton
- *
- * Continues to be licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 4.0)
- * creative commons license. See
- * for full details.
- *
- */
-
-namespace DF
-{
- public class DFInstallFix
- {
- private const string configNodeName = "DFFixes";
-
- public bool fixtimecounts { get; set; }
-
- internal DFInstallFix()
- {
- fixtimecounts = false;
- }
-
- //Settings Functions Follow
-
- internal void Load(ConfigNode node)
- {
- if (node.HasNode(configNodeName))
- {
- ConfigNode DFsettingsNode = node.GetNode(configNodeName);
-
- fixtimecounts = Utilities.GetNodeValue(DFsettingsNode, "fixtimecounts", fixtimecounts);
- }
- }
-
- internal void Save(ConfigNode node)
- {
- ConfigNode settingsNode;
- if (node.HasNode(configNodeName))
- {
- settingsNode = node.GetNode(configNodeName);
- settingsNode.ClearData();
- }
- else
- {
- settingsNode = node.AddNode(configNodeName);
- }
-
- settingsNode.AddValue("fixtimecounts", false);
- }
- }
-}
\ No newline at end of file
diff --git a/Source/DFIntMemory.cs b/Source/DFIntMemory.cs
index d255d25..0516fa9 100644
--- a/Source/DFIntMemory.cs
+++ b/Source/DFIntMemory.cs
@@ -66,6 +66,22 @@ public VslFrzrCams(Transform frzrcamTransform, InternalModel frzrcamModel, int f
//private bool refreshPortraits; // set to true after a vessel coupling has occurred, a timer waits 3 secnds then refreshes the portraits cams.
//private double refreshPortraitsTimer; // the timer for the previous var
private int AllVslsErrorCount; //stop log spam
+ private List ComakeysToDelete = new List();
+ private List> comaKerbals = new List>();
+ private double currentTime, lastFixedUpdateTime, checkVesselUpdateTime, checkVesselComaTime;
+ private List TmpDpFrzrActVsl = new List();
+ private List unknownkerbals = new List();
+ private List crewkerbals = new List();
+ private List allVessels = new List();
+ private List vesselsToDelete = new List();
+ private List partsToDelete = new List();
+ private Dictionary knownVessels = new Dictionary();
+ private Guid vesselId;
+ private Vessel vessel;
+ private int crewCapacity;
+ private VesselInfo vesselInfo;
+ private PartInfo partInfo;
+ private List DpFrzrLoadedVsl = new List();
protected DFIntMemory()
{
@@ -105,7 +121,7 @@ private void Awake()
private void Start()
{
- Utilities.Log_Debug("DFIntMemory startup");
+ Utilities.Log_Debug("DFIntMemory startup");
ChkUnknownFrozenKerbals();
ChkActiveFrozenKerbals();
DeepFreeze.Instance.DFgameSettings.DmpKnownFznKerbals();
@@ -129,6 +145,10 @@ private void Start()
{
RTWrapper.InitTRWrapper();
}
+ currentTime = Planetarium.GetUniversalTime();
+ lastFixedUpdateTime = currentTime;
+ vesselInfo = new VesselInfo("testVessel", currentTime);
+ partInfo = new PartInfo(Guid.Empty, "testPart", currentTime);
}
private void OnDestroy()
@@ -363,7 +383,12 @@ private void Update()
private void FixedUpdate()
{
if (HighLogic.LoadedSceneIsEditor || Time.timeSinceLevelLoad < 5f) return; //Wait 5 seconds on level load before executing
+ currentTime = Planetarium.GetUniversalTime();
+ //We only update every THREE seconds.
+ if (currentTime - lastFixedUpdateTime < 3f)
+ return;
+ lastFixedUpdateTime = currentTime;
//Check if the active vessel has changed and if so, process.
if (HighLogic.LoadedSceneIsFlight)
{
@@ -376,7 +401,9 @@ private void FixedUpdate()
try
{
if (DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Any())
+ {
CheckComaUpdate();
+ }
}
catch (Exception ex)
{
@@ -413,8 +440,9 @@ private void FixedUpdate()
private void CheckComaUpdate()
{
// Check the knownfrozenkerbals for any tourists kerbals (IE: Comatose) if their time is up and reset them if it is.
- var keysToDelete = new List();
- List> comaKerbals = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Where(e => e.Value.type == ProtoCrewMember.KerbalType.Tourist).ToList();
+ ComakeysToDelete.Clear();
+ //comaKerbals.Clear();
+ comaKerbals = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Where(e => e.Value.type == ProtoCrewMember.KerbalType.Tourist).ToList();
foreach (KeyValuePair comaKerbal in comaKerbals)
{
if (comaKerbal.Value.type == ProtoCrewMember.KerbalType.Tourist)
@@ -425,7 +453,7 @@ private void CheckComaUpdate()
if (crew != null)
{
DeepFreeze.Instance.setComatoseKerbal(crew, ProtoCrewMember.KerbalType.Crew);
- keysToDelete.Add(comaKerbal.Key);
+ ComakeysToDelete.Add(comaKerbal.Key);
}
else
{
@@ -434,16 +462,17 @@ private void CheckComaUpdate()
}
}
}
- keysToDelete.ForEach(id => DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(id));
+ ComakeysToDelete.ForEach(id => DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(id));
}
private void ChkUnknownFrozenKerbals()
{
// Check the roster list for any unknown dead kerbals (IE: Frozen) that were not in the save file and add them.
- List unknownkerbals = HighLogic.CurrentGame.CrewRoster.Unowned.ToList();
+ //unknownkerbals.Clear();
+ unknownkerbals = HighLogic.CurrentGame.CrewRoster.Unowned.ToList();
if (unknownkerbals != null)
{
- Utilities.Log("There are " + unknownkerbals.Count() + " unknownKerbals in the game roster.");
+ Utilities.Log("There are " + unknownkerbals.Count + " unknownKerbals in the game roster.");
foreach (ProtoCrewMember CrewMember in unknownkerbals)
{
if (CrewMember.rosterStatus == ProtoCrewMember.RosterStatus.Dead)
@@ -478,7 +507,8 @@ private void ChkUnknownFrozenKerbals()
internal void ChkActiveFrozenKerbals()
{
// Check the roster list for any crew kerbals that we think are frozen but aren't any more and delete them.
- List crewkerbals = HighLogic.CurrentGame.CrewRoster.Crew.ToList();
+ //crewkerbals.Clear();
+ crewkerbals = HighLogic.CurrentGame.CrewRoster.Crew.ToList();
if (crewkerbals != null)
{
Utilities.Log("There are " + crewkerbals.Count() + " crew Kerbals in the game roster.");
@@ -557,7 +587,7 @@ internal void onVesselCreate(Vessel vessel)
if (HighLogic.LoadedSceneIsFlight)
{
Utilities.Log_Debug("OnVesselCreate activevessel " + FlightGlobals.ActiveVessel.id + " parametervesselid " + vessel.id);
- List TmpDpFrzrActVsl = vessel.FindPartModulesImplementing();
+ TmpDpFrzrActVsl = vessel.FindPartModulesImplementing();
foreach (DeepFreezer frzr in TmpDpFrzrActVsl)
{
//Find the part in KnownFreezerParts and update the GUID
@@ -681,7 +711,7 @@ private void resetFreezerCams()
{
ActFrzrCams.Clear();
lastFrzrCam = 0;
- Utilities.Log_Debug("ActVslHasDpFrezer " + ActVslHasDpFrezr + " #ofFrzrs " + DpFrzrActVsl.Count());
+ Utilities.Log_Debug("ActVslHasDpFrezer " + ActVslHasDpFrezr + " #ofFrzrs " + DpFrzrActVsl.Count);
foreach (DeepFreezer Frzr in DpFrzrActVsl)
{
if (Frzr.part.internalModel != null)
@@ -722,11 +752,13 @@ private void CheckVslUpdate()
// Called every fixed update from fixedupdate - Check for vessels that have been deleted and remove from Dictionary
// also updates current active vessel details/settings
// adds new vessel if current active vessel is not known and updates it's details/settings
- double currentTime = Planetarium.GetUniversalTime();
- List allVessels = FlightGlobals.Vessels;
- var vesselsToDelete = new List();
- var partsToDelete = new List();
- var knownVessels = DeepFreeze.Instance.DFgameSettings.knownVessels;
+ //double currentTime = Planetarium.GetUniversalTime();
+ //allVessels.Clear();
+ vesselsToDelete.Clear();
+ partsToDelete.Clear();
+ //knownVessels.Clear();
+ allVessels = FlightGlobals.Vessels;
+ knownVessels = DeepFreeze.Instance.DFgameSettings.knownVessels;
Utilities.Log_Debug("CheckVslUpdate start");
//* Update known vessels.
foreach (var entry in knownVessels)
@@ -735,14 +767,14 @@ private void CheckVslUpdate()
{
Utilities.Log("knownvessels id = " + entry.Key + " Name = " + entry.Value.vesselName);
}
- Utilities.Log_Debug("knownvessels id = " + entry.Key + " Name = " + entry.Value.vesselName);
- Guid vesselId = entry.Key;
+ Utilities.Log_Debug("knownvessels id = " + entry.Key + " Name = " + entry.Value.vesselName);
+ vesselId = entry.Key;
VesselInfo vesselInfo = entry.Value;
- Vessel vessel = null;
+ vessel = null;
try
{
if (AllVslsErrorCount < 5)
- vessel = allVessels.Find(v => v.id == vesselId);
+ vessel = allVessels.FirstOrDefault(v => v.id == vesselId);
else
continue;
}
@@ -787,7 +819,7 @@ private void CheckVslUpdate()
if (vessel.loaded)
{
UpdateVesselInfo(vesselInfo, vessel, currentTime);
- int crewCapacity = UpdateVesselCounts(vesselInfo, vessel, currentTime);
+ crewCapacity = UpdateVesselCounts(vesselInfo, vessel, currentTime);
if (!vessel.FindPartModulesImplementing().Any())
{
Utilities.Log_Debug("Deleting vessel " + vesselInfo.vesselName + " - no freezer parts anymore");
@@ -805,7 +837,7 @@ private void CheckVslUpdate()
// If vessel is Not ActiveVessel and has a Transparent Pod reset the Cryopods.
if (FlightGlobals.ActiveVessel != vessel)
{
- List DpFrzrLoadedVsl = new List();
+ DpFrzrLoadedVsl.Clear();
DpFrzrLoadedVsl = vessel.FindPartModulesImplementing();
foreach (DeepFreezer frzr in DpFrzrLoadedVsl)
{
@@ -840,9 +872,9 @@ private void CheckVslUpdate()
if (!knownVessels.ContainsKey(vessel.id) && vessel.FindPartModulesImplementing().Any())
{
Utilities.Log("New vessel: " + vessel.vesselName + " (" + vessel.id + ")");
- VesselInfo vesselInfo = new VesselInfo(vessel.vesselName, currentTime);
+ vesselInfo.vesselName = vessel.vesselName;
UpdateVesselInfo(vesselInfo, vessel, currentTime);
- int crewCapacity = UpdateVesselCounts(vesselInfo, vessel, currentTime);
+ crewCapacity = UpdateVesselCounts(vesselInfo, vessel, currentTime);
knownVessels[vessel.id] = vesselInfo;
}
}
@@ -877,16 +909,26 @@ private void UpdateVesselInfo(VesselInfo vesselInfo, Vessel vessel, double curre
vesselInfo.lastUpdate = Planetarium.GetUniversalTime();
vesselInfo.hibernating = false;
vesselInfo.hasextDoor = false;
- List DpFrzrLoadedVsl = new List();
+ vesselInfo.hasextPod = false;
+ DpFrzrLoadedVsl.Clear();
DpFrzrLoadedVsl = vessel.FindPartModulesImplementing();
foreach (DeepFreezer frzr in DpFrzrLoadedVsl)
{
// do we have a known part? If not add it
- PartInfo partInfo;
if (!DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(frzr.part.flightID, out partInfo))
{
Utilities.Log("New Freezer Part: " + frzr.name + "(" + frzr.part.flightID + ")" + " (" + vessel.id + ")");
partInfo = new PartInfo(vessel.id, frzr.name, currentTime);
+ //partInfo.vesselID = vessel.id;
+ //partInfo.PartName = frzr.name;
+ partInfo.hibernating = false;
+ partInfo.ECWarning = false;
+ partInfo.TempWarning = false;
+ partInfo.lastUpdate = currentTime;
+ partInfo.crewMembers.Clear();
+ partInfo.crewMemberTraits.Clear();
+
+
partInfo.hasextDoor = frzr.ExternalDoorActive;
partInfo.hasextPod = frzr.isPodExternal;
partInfo.numSeats = frzr.FreezerSize;
@@ -939,7 +981,7 @@ private int UpdateVesselCounts(VesselInfo vesselInfo, Vessel vessel, double curr
{
// save current toggles to current vesselinfo
// Utilities.Log_Debug("UpdateVesselCounts " + vessel.id);
- int crewCapacity = 0;
+ crewCapacity = 0;
vesselInfo.ClearAmounts(); // numCrew = 0; numOccupiedParts = 0; numseats = 0;
foreach (Part part in vessel.parts)
{
@@ -948,11 +990,11 @@ private int UpdateVesselCounts(VesselInfo vesselInfo, Vessel vessel, double curr
{
Utilities.Log_Debug("part:" + part.name + " Has Freezer");
//first Update the PartInfo counts
- PartInfo partInfo;
+
if (DeepFreeze.Instance.DFgameSettings.knownFreezerParts.TryGetValue(freezer.part.flightID, out partInfo))
{
partInfo.numCrew = freezer.part.protoModuleCrew.Count;
- partInfo.numFrznCrew = freezer.DFIStoredCrewList.Count();
+ partInfo.numFrznCrew = freezer.DFIStoredCrewList.Count;
}
//Now update the VesselInfo counts
crewCapacity += freezer.FreezerSize;
diff --git a/Source/DFWrapper.cs b/Source/DFWrapper.cs
deleted file mode 100644
index 2360556..0000000
--- a/Source/DFWrapper.cs
+++ /dev/null
@@ -1,742 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-// TODO: Change this namespace to something specific to your plugin here.
-//EG:
-// namespace MyPlugin_KACWrapper
-namespace DeepFreezeWrapper
-{
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // BELOW HERE SHOULD NOT BE EDITED - this links to the loaded DeepFreeze module without requiring a Hard Dependancy
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- ///
- /// The Wrapper class to access DeepFreeze from another plugin
- ///
- public class DFWrapper
- {
- protected static System.Type DFType;
- protected static System.Type KerbalInfoType;
- protected static System.Type DeepFreezerType;
- protected static System.Type FrznCrewMbrType;
- protected static Object actualDF = null;
-
- ///
- /// This is the DeepFreeze object
- ///
- /// SET AFTER INIT
- ///
- public static DFAPI DeepFreezeAPI;
-
- ///
- /// Whether we found the DeepFreeze assembly in the loadedassemblies.
- ///
- /// SET AFTER INIT
- ///
- public static Boolean AssemblyExists { get { return (DFType != null); } }
-
- ///
- /// Whether we managed to hook the running Instance from the assembly.
- ///
- /// SET AFTER INIT
- ///
- public static Boolean InstanceExists { get { return (DeepFreezeAPI != null); } }
-
- ///
- /// Whether we managed to wrap all the methods/functions from the instance.
- ///
- /// SET AFTER INIT
- ///
- private static Boolean _DFWrapped;
-
- ///
- /// Whether the object has been wrapped and the APIReady flag is set in the real DeepFreeze
- ///
- public static Boolean APIReady { get { return _DFWrapped && DeepFreezeAPI.APIReady; } }
-
- ///
- /// This method will set up the DeepFreeze object and wrap all the methods/functions
- ///
- ///
- /// Bool indicating success of call
- ///
- public static Boolean InitDFWrapper()
- {
- try
- {
- //reset the internal objects
- _DFWrapped = false;
- actualDF = null;
- DeepFreezeAPI = null;
- LogFormatted("Attempting to Grab DeepFreeze Types...");
-
- //find the base type
- DFType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "DF.DeepFreeze");
-
- if (DFType == null)
- {
- return false;
- }
-
- LogFormatted("DeepFreeze Version:{0}", DFType.Assembly.GetName().Version.ToString());
-
- //now the KerbalInfo Type
- KerbalInfoType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "DF.KerbalInfo");
-
- if (KerbalInfoType == null)
- {
- return false;
- }
-
- //now the DeepFreezer (partmodule) Type
- DeepFreezerType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "DF.DeepFreezer");
-
- if (DeepFreezerType == null)
- {
- return false;
- }
-
- //now the FrznCrewMbr Type
- FrznCrewMbrType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "DF.FrznCrewMbr");
-
- if (FrznCrewMbrType == null)
- {
- return false;
- }
-
- //now grab the running instance
- LogFormatted("Got Assembly Types, grabbing Instance");
- try
- {
- actualDF = DFType.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
- }
- catch (Exception)
- {
- LogFormatted("No Instance found - most likely you have an old DeepFreeze installed");
- return false;
- }
- if (actualDF == null)
- {
- LogFormatted("Failed grabbing Instance");
- return false;
- }
-
- //If we get this far we can set up the local object and its methods/functions
- LogFormatted("Got Instance, Creating Wrapper Objects");
- DeepFreezeAPI = new DFAPI(actualDF);
- _DFWrapped = true;
- return true;
- }
- catch (Exception ex)
- {
- LogFormatted("Unable to setup InitDFWrapper Reflection");
- LogFormatted("Exception: {0}", ex);
- _DFWrapped = false;
- return false;
- }
- }
-
- ///
- /// The API Class that is an analogue of the real DeepFreeze. This lets you access all the API-able properties and Methods of the DeepFreeze
- ///
- public class DFAPI
- {
- internal DFAPI(Object a)
- {
- try
- {
- //store the actual object
- actualDFAPI = a;
-
- //these sections get and store the reflection info and actual objects where required. Later in the properties we then read the values from the actual objects
- //for events we also add a handler
- //Object tstfrozenkerbals = DFType.GetField("FrozenKerbals", BindingFlags.Public | BindingFlags.Static).GetValue(null);
-
- LogFormatted("Getting APIReady Object");
- APIReadyField = DFType.GetField("APIReady", BindingFlags.Public | BindingFlags.Static);
- LogFormatted("Success: " + (APIReadyField != null).ToString());
-
- LogFormatted("Getting FrozenKerbals Object");
- FrozenKerbalsMethod = DFType.GetMethod("get_FrozenKerbals", BindingFlags.Public | BindingFlags.Instance);
- actualFrozenKerbals = FrozenKerbalsMethod.Invoke(actualDFAPI, null);
- LogFormatted("Success: " + (actualFrozenKerbals != null).ToString());
- }
- catch (Exception ex)
- {
- LogFormatted("Unable to Instantiate DFAPI object using Reflection");
- LogFormatted("Exception: {0}", ex);
- }
- }
-
- private Object actualDFAPI;
-
- private FieldInfo APIReadyField;
- ///
- /// Whether the APIReady flag is set in the real KAC
- ///
- ///
- /// Bool Indicating if DeepFreeze is ready for API calls
- ///
- public bool APIReady
- {
- get
- {
- if (APIReadyField == null)
- return false;
-
- return (Boolean)APIReadyField.GetValue(null);
- }
- }
-
- #region Frozenkerbals
-
- private Object actualFrozenKerbals;
- private MethodInfo FrozenKerbalsMethod;
-
- ///
- /// The dictionary of Frozen Kerbals that are currently active in game
- ///
- ///
- /// Dictionary of Frozen Kerbals
- ///
- internal Dictionary FrozenKerbals
- {
- get
- {
- if (FrozenKerbalsMethod == null)
- return null;
- //Object tstfrozenkerbals = DFType.GetField("FrozenKerbals", BindingFlags.Public | BindingFlags.Static).GetValue(null);
- FieldInfo gamesettingsfield = DFType.GetField("DFgameSettings", BindingFlags.Instance | BindingFlags.NonPublic);
- Object gamesettings = gamesettingsfield.GetValue(actualDFAPI);
- actualFrozenKerbals = FrozenKerbalsMethod.Invoke(actualDFAPI, null);
- Dictionary returnvalue = new Dictionary();
- returnvalue = ExtractFrozenKerbalDict(actualFrozenKerbals);
- return returnvalue;
- }
- }
-
- ///
- /// This converts the actualFrozenKerbals actual object to a new dictionary for consumption
- ///
- ///
- /// Dictionary of Frozen Kerbals
- private Dictionary ExtractFrozenKerbalDict(Object actualFrozenKerbals)
- {
- Dictionary DictToReturn = new Dictionary();
- try
- {
- foreach (var item in (IDictionary)actualFrozenKerbals)
- {
- var typeitem = item.GetType();
- PropertyInfo[] itemprops = typeitem.GetProperties(BindingFlags.Instance | BindingFlags.Public);
- string itemkey = (string)itemprops[0].GetValue(item, null);
- object itemvalue = (object)itemprops[1].GetValue(item, null);
- KerbalInfo itemkerbalinfo = new KerbalInfo(itemvalue);
- DictToReturn[itemkey] = itemkerbalinfo;
- }
- }
- catch (Exception ex)
- {
- LogFormatted("Unable to extract FrozenKerbals Dictionary: {0}", ex.Message);
- }
- return DictToReturn;
- }
-
- #endregion Frozenkerbals
- }
-
- #region DeepFreezerPart
-
- ///
- /// The Class that is an analogue of the real DeepFreezer PartModule. This lets you access all the API-able properties and Methods of the DeepFreezer
- ///
- public class DeepFreezer
- {
- internal DeepFreezer(Object a)
- {
- actualDeepFreezer = a;
- //Fields available from Freezer part
- crewXferTOActiveMethod = DeepFreezerType.GetMethod("get_DFIcrewXferTOActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- crewXferTOActive = getcrewXferTOActive;
- crewXferFROMActiveMethod = DeepFreezerType.GetMethod("get_DFIcrewXferFROMActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- crewXferFROMActive = getcrewXferFROMActive;
- FreezerSizeMethod = DeepFreezerType.GetMethod("get_DFIFreezerSize", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- FreezerSize = getFreezerSize;
- TotalFrozenMethod = DeepFreezerType.GetMethod("get_DFITotalFrozen", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- TotalFrozen = getTotalFrozen;
- FreezerSpaceMethod = DeepFreezerType.GetMethod("get_DFIFreezerSpace", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- FreezerSpace = getFreezerSpace;
- PartFullMethod = DeepFreezerType.GetMethod("get_DFIPartFull", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- PartFull = getPartFull;
- IsFreezeActiveMethod = DeepFreezerType.GetMethod("get_DFIIsFreezeActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- IsFreezeActive = getIsFreezeActive;
- IsThawActiveMethod = DeepFreezerType.GetMethod("get_DFIIsThawActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- IsThawActive = getIsThawActive;
- FreezerOutofECMethod = DeepFreezerType.GetMethod("get_DFIFreezerOutofEC", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- FreezerOutofEC = getFreezerOutofEC;
- FrzrTmpMethod = DeepFreezerType.GetMethod("get_DFIFrzrTmp", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- FrzrTmp = getFrzrTmp;
- StoredCrewListMethod = DeepFreezerType.GetMethod("get_DFIStoredCrewList", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- actualStoredCrewList = StoredCrewListMethod.Invoke(actualDeepFreezer, null);
-
- //Methods
- LogFormatted("Getting beginFreezeKerbalMethod Method");
- beginFreezeKerbalMethod = DeepFreezerType.GetMethod("beginFreezeKerbal", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (beginFreezeKerbalMethod != null).ToString());
-
- LogFormatted("Getting beginThawKerbalMethod Method");
- beginThawKerbalMethod = DeepFreezerType.GetMethod("beginThawKerbal", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (beginThawKerbalMethod != null).ToString());
- }
-
- private Object actualDeepFreezer;
-
- #region DeepFreezerFieldMethods
-
- ///
- /// True if a crewXfter TO this DeepFreezer part is currently active
- ///
- public bool crewXferTOActive;
-
- private MethodInfo crewXferTOActiveMethod;
-
- private bool getcrewXferTOActive
- {
- get { return (bool)crewXferTOActiveMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// True if a crewXfter FROM this DeepFreezer part is currently active
- ///
- public bool crewXferFROMActive;
-
- private MethodInfo crewXferFROMActiveMethod;
-
- private bool getcrewXferFROMActive
- {
- get { return (bool)crewXferFROMActiveMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// The number of cryopods in this DeepFreezer
- ///
- public int FreezerSize;
-
- private MethodInfo FreezerSizeMethod;
-
- private int getFreezerSize
- {
- get { return (int)FreezerSizeMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// The number of currently frozen Kerbals in this DeepFreezer
- ///
- public int TotalFrozen;
-
- private MethodInfo TotalFrozenMethod;
-
- private int getTotalFrozen
- {
- get { return (int)TotalFrozenMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// The number of empty cryopods in this DeepFreezer
- ///
- public int FreezerSpace;
-
- private MethodInfo FreezerSpaceMethod;
-
- private int getFreezerSpace
- {
- get { return (int)FreezerSpaceMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// True if all the cryopods are taken in this DeepFreezer (includes, frozen and thawed kerbals).
- ///
- public bool PartFull;
-
- private MethodInfo PartFullMethod;
-
- private bool getPartFull
- {
- get { return (bool)PartFullMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// True if a Freeze kerbal event is currently active in this DeepFreezer
- ///
- public bool IsFreezeActive;
-
- private MethodInfo IsFreezeActiveMethod;
-
- private bool getIsFreezeActive
- {
- get { return (bool)IsFreezeActiveMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// True if a Thaw kerbal event is currently active in this DeepFreezer
- ///
- public bool IsThawActive;
-
- private MethodInfo IsThawActiveMethod;
-
- private bool getIsThawActive
- {
- get { return (bool)IsThawActiveMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// True if this DeepFreezer is currently out of Electric Charge
- ///
- public bool FreezerOutofEC;
-
- private MethodInfo FreezerOutofECMethod;
-
- private bool getFreezerOutofEC
- {
- get { return (bool)FreezerOutofECMethod.Invoke(actualDeepFreezer, null); }
- }
-
- ///
- /// The current freezer temperature status of this DeepFreezer
- ///
- public FrzrTmpStatus FrzrTmp;
-
- private MethodInfo FrzrTmpMethod;
-
- private FrzrTmpStatus getFrzrTmp
- {
- get { return (FrzrTmpStatus)FrzrTmpMethod.Invoke(actualDeepFreezer, null); }
- }
-
- private Object actualStoredCrewList;
- private MethodInfo StoredCrewListMethod;
-
- ///
- /// a List of all Frozen Crew in this DeepFreezer
- ///
- public FrznCrewList StoredCrewList
- {
- get { return ExtractStoredCrewList(actualStoredCrewList); }
- }
-
- ///
- /// This converts the StoredCrewList actual object to a new List for consumption
- ///
- ///
- ///
- private FrznCrewList ExtractStoredCrewList(Object actualStoredCrewList)
- {
- FrznCrewList ListToReturn = new FrznCrewList();
- try
- {
- //iterate each "value" in the dictionary
-
- foreach (var item in (IList)actualStoredCrewList)
- {
- FrznCrewMbr r1 = new FrznCrewMbr(item);
- ListToReturn.Add(r1);
- }
- }
- catch (Exception ex)
- {
- LogFormatted("Arrggg: {0}", ex.Message);
- //throw ex;
- //
- }
- return ListToReturn;
- }
-
- #endregion DeepFreezerFieldMethods
-
- #region DeepFreezerMethods
-
- private MethodInfo beginFreezeKerbalMethod;
-
- ///
- /// Begin the Freezing of a Kerbal
- ///
- /// ProtoCrewMember that you want frozen
- /// Bool indicating success of call
- public bool beginFreezeKerbal(ProtoCrewMember CrewMember)
- {
- try
- {
- beginFreezeKerbalMethod.Invoke(actualDeepFreezer, new System.Object[] { CrewMember });
- return true;
- }
- catch (Exception ex)
- {
- LogFormatted("Arrggg: {0}", ex.Message);
- return false;
- }
- }
-
- private MethodInfo beginThawKerbalMethod;
-
- ///
- /// Begin the Thawing of a Kerbal
- ///
- /// string containing the name of the kerbal you want thawed
- /// Bool indicating success of call
- public bool beginThawKerbal(string frozenkerbal)
- {
- try
- {
- beginThawKerbalMethod.Invoke(actualDeepFreezer, new System.Object[] { frozenkerbal });
- return true;
- }
- catch (Exception ex)
- {
- LogFormatted("Arrggg: {0}", ex.Message);
- return false;
- }
- }
-
- #endregion DeepFreezerMethods
- }
-
- public enum FrzrTmpStatus
- {
- OK = 0,
- WARN = 1,
- RED = 2,
- }
-
- ///
- /// The Class that is an analogue of the real FrznCrewMbr as part of the StoredCrewList field in the DeepFreezer PartModule.
- ///
- public class FrznCrewMbr
- {
- internal FrznCrewMbr(Object a)
- {
- actualFrznCrewMbr = a;
- CrewNameMethod = FrznCrewMbrType.GetMethod("get_CrewName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- CrewName = getCrewName;
- SeatIdxMethod = FrznCrewMbrType.GetMethod("get_SeatIdx", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- SeatIdx = getSeatIdx;
- VesselIDMethod = FrznCrewMbrType.GetMethod("get_VesselID", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- VesselID = getVesselID;
- VesselNameMethod = FrznCrewMbrType.GetMethod("get_VesselName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
- VesselName = getVesselName;
- }
-
- private Object actualFrznCrewMbr;
-
-
- ///
- /// Crew Members Name
- ///
- public string CrewName;
-
- private MethodInfo CrewNameMethod;
-
- private string getCrewName
- {
- get { return (string)CrewNameMethod.Invoke(actualFrznCrewMbr, null); }
- }
-
- ///
- /// Seat Index for Crew member
- ///
- public int SeatIdx;
-
- private MethodInfo SeatIdxMethod;
-
- private int getSeatIdx
- {
- get { return (int)SeatIdxMethod.Invoke(actualFrznCrewMbr, null); }
- }
-
- ///
- /// Vessel ID
- ///
- public Guid VesselID;
-
- private MethodInfo VesselIDMethod;
-
- private Guid getVesselID
- {
- get { return (Guid)VesselIDMethod.Invoke(actualFrznCrewMbr, null); }
- }
-
- ///
- /// Vessel Name
- ///
- public string VesselName;
-
- private MethodInfo VesselNameMethod;
-
- private string getVesselName
- {
- get { return (string)VesselNameMethod.Invoke(actualFrznCrewMbr, null); }
- }
- }
-
- public class FrznCrewList : List
- {
- }
-
- #endregion DeepFreezerPart
-
- ///
- /// The Value Class of the FrozenCrewList Dictionary that is an analogue of the real FrozenKerbals Dictionary in the DeepFreezer Class.
- ///
- public class KerbalInfo
- {
- internal KerbalInfo(Object a)
- {
- actualFrozenKerbalInfo = a;
- lastUpdateField = KerbalInfoType.GetField("lastUpdate");
- statusField = KerbalInfoType.GetField("status");
- typeField = KerbalInfoType.GetField("type");
- vesselIDField = KerbalInfoType.GetField("vesselID");
- vesselNameField = KerbalInfoType.GetField("vesselName");
- partIDField = KerbalInfoType.GetField("partID");
- seatIdxField = KerbalInfoType.GetField("seatIdx");
- seatNameField = KerbalInfoType.GetField("seatName");
- experienceTraitNameField = KerbalInfoType.GetField("experienceTraitName");
- }
-
- private Object actualFrozenKerbalInfo;
-
- private FieldInfo lastUpdateField;
-
- ///
- /// last time the FrozenKerbalInfo was updated
- ///
- public double lastUpdate
- {
- get { return (double)lastUpdateField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo statusField;
-
- ///
- /// RosterStatus of the frozen kerbal
- ///
- public ProtoCrewMember.RosterStatus status
- {
- get { return (ProtoCrewMember.RosterStatus)statusField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo typeField;
-
- ///
- /// KerbalType of the frozen kerbal
- ///
- public ProtoCrewMember.KerbalType type
- {
- get { return (ProtoCrewMember.KerbalType)typeField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo vesselIDField;
-
- ///
- /// Guid of the vessel the frozen kerbal is aboard
- ///
- public Guid vesselID
- {
- get { return (Guid)vesselIDField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo vesselNameField;
-
- ///
- /// Name of the vessel the frozen kerbal is aboard
- ///
- public string vesselName
- {
- get { return (string)vesselNameField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo partIDField;
-
- ///
- /// partID of the vessel part the frozen kerbal is aboard
- ///
- public uint partID
- {
- get { return (uint)partIDField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo seatIdxField;
-
- ///
- /// seat index that the frozen kerbal is in
- ///
- public int seatIdx
- {
- get { return (int)seatIdxField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo seatNameField;
-
- ///
- /// seat name that the frozen kerbal is in
- ///
- public string seatName
- {
- get { return (string)seatNameField.GetValue(actualFrozenKerbalInfo); }
- }
-
- private FieldInfo experienceTraitNameField;
-
- ///
- /// name of the experience trait for the frozen kerbal
- ///
- public string experienceTraitName
- {
- get { return (string)experienceTraitNameField.GetValue(actualFrozenKerbalInfo); }
- }
- }
-
- #region Logging Stuff
-
- ///
- /// Some Structured logging to the debug file - ONLY RUNS WHEN DLL COMPILED IN DEBUG MODE
- ///
- /// Text to be printed - can be formatted as per String.format
- /// Objects to feed into a String.format
- [System.Diagnostics.Conditional("DEBUG")]
- internal static void LogFormatted_DebugOnly(String Message, params Object[] strParams)
- {
- LogFormatted(Message, strParams);
- }
-
- ///
- /// Some Structured logging to the debug file
- ///
- /// Text to be printed - can be formatted as per String.format
- /// Objects to feed into a String.format
- internal static void LogFormatted(String Message, params Object[] strParams)
- {
- Message = String.Format(Message, strParams);
- String strMessageLine = String.Format("{0},{2}-{3},{1}",
- DateTime.Now, Message, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name,
- System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
- UnityEngine.Debug.Log(strMessageLine);
- }
-
- #endregion Logging Stuff
- }
-}
\ No newline at end of file
diff --git a/Source/DFtoolbar.png b/Source/DFtoolbar.png
deleted file mode 100644
index 2a89f57..0000000
Binary files a/Source/DFtoolbar.png and /dev/null differ
diff --git a/Source/DeepFreeze.cs b/Source/DeepFreeze.cs
index 5d211e6..7fc3469 100644
--- a/Source/DeepFreeze.cs
+++ b/Source/DeepFreeze.cs
@@ -51,7 +51,7 @@ public DeepFreeze()
APIReady = false;
DFsettings = new DFSettings();
DFgameSettings = new DFGameSettings();
- globalConfigFilename = Path.Combine(_AssemblyFolder, "Config.cfg").Replace("\\", "/");
+ globalConfigFilename = Path.Combine(_AssemblyFolder, "PluginData/Config.cfg").Replace("\\", "/");
Utilities.Log("globalConfigFilename = " + globalConfigFilename);
DeepFreezeEventAdd();
}
@@ -413,13 +413,13 @@ internal static String _AssemblyName
/// Full Path of the executing Assembly
///
internal static String _AssemblyLocation
- { get { return Assembly.GetExecutingAssembly().Location; } }
+ { get { return Assembly.GetExecutingAssembly().Location.Replace("\\", "/"); } }
///
/// Folder containing the executing Assembly
///
internal static String _AssemblyFolder
- { get { return Path.GetDirectoryName(_AssemblyLocation); } }
+ { get { return Path.GetDirectoryName(_AssemblyLocation).Replace("\\", "/"); } }
#endregion Assembly/Class Information
}
diff --git a/Source/DeepFreeze.csproj b/Source/DeepFreeze.csproj
index 2b4f415..6ef209f 100644
--- a/Source/DeepFreeze.csproj
+++ b/Source/DeepFreeze.csproj
@@ -50,6 +50,10 @@
..\..\KSPDLLs\Assembly-UnityScript-firstpass.dll
+
+ False
+ ..\..\KSPDLLs\KSPAssets.dll
+
..\..\KSPDLLs\KSPUtil.dll
@@ -69,14 +73,25 @@
+
+ AppLauncherToolBarExtension.cs
+
+
+ RectExtentions.cs
+
RSTutilities.cs
+
+ ToolBarManager.cs
+
+
+
@@ -154,7 +169,6 @@
-
diff --git a/Source/DeepFreeze.sln b/Source/DeepFreeze.sln
deleted file mode 100644
index 947cb61..0000000
--- a/Source/DeepFreeze.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepFreeze", "DeepFreeze.csproj", "{A4B40FD9-3062-4913-9C6D-1980FA813B9B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {A4B40FD9-3062-4913-9C6D-1980FA813B9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A4B40FD9-3062-4913-9C6D-1980FA813B9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A4B40FD9-3062-4913-9C6D-1980FA813B9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A4B40FD9-3062-4913-9C6D-1980FA813B9B}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Source/DeepFreezeEvents.cs b/Source/DeepFreezeEvents.cs
deleted file mode 100644
index 954156b..0000000
--- a/Source/DeepFreezeEvents.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * DeepFreezerPart.cs
- *
- *
- * Kerbal Space Program is Copyright (C) 2013 Squad. See http://kerbalspaceprogram.com/. This
- * project is in no way associated with nor endorsed by Squad.
- *
- * This file is part of Jamie Leighton's Fork of DeepFreeze. Original Author of DeepFreeze is 'scottpaladin' on the KSP Forums.
- * The original DeepFreeze was licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 4.0)
- * This File was part of the original Deepfreeze but has been heavily modified and re-written by Jamie Leighton.
- * (C) Copyright 2015, Jamie Leighton
- *
- * Which is licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 4.0)
- * creative commons license. See
- * for full details.
- *
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine;
-
-namespace DF
-{
- [KSPAddon(KSPAddon.Startup.SpaceCentre, false)]
- internal class DeepFreezeEvents :MonoBehaviour
- {
- public static DeepFreezeEvents instance = new DeepFreezeEvents();
- public bool eventAdded;
- private const float costToThawKerbal = 10000f;
-
- public DeepFreezeEvents()
- {
- Debug.Log("DeepFreezeEvents Constructor");
- eventAdded = false;
- Debug.Log("DeepFreezeEvnts.Start called");
- if (!DeepFreezeEvents.instance.eventAdded)
- {
- DeepFreezeEvents.instance.DeepFreezeEventAdd();
- Debug.Log("!DeepFreezeEvents.instance.eventAdded");
- }
- else
- Debug.Log("DeepFreezeEvents.instance.eventAdded");
- }
-
- public void DeepFreezeEventAdd()
- {
- Debug.Log("DeepFreezeEvents DeepFreezeEventAdd");
- //GameEvents.OnVesselRecoveryRequested.Add(this.OnVesselRecoveryRequested);
- GameEvents.onVesselRecovered.Add(this.onVesselRecovered);
- GameEvents.onVesselTerminated.Add(this.onVesselTerminated);
- GameEvents.onVesselWillDestroy.Add(this.onVesselWillDestroy);
- eventAdded = true;
- Debug.Log("DeepFreezeEvents DeepFreezeEventAdd ended");
- }
- /*
- public void OnVesselRecoveryRequested(Vessel vessel)
- {
- Debug.Log("DeepFreezeEvents OnVesselRecoveryRequested");
- if (vessel.FindPartModulesImplementing().Count > 0 && DeepFreeze.Instance.DFsettings.AutoRecoverFznKerbals)
- {
- foreach (DeepFreezer freezer in vessel.FindPartModulesImplementing())
- {
- freezer.part.CrewCapacity = freezer.StoredCrewList.Count;
- foreach (var crewmember in freezer.StoredCrewList)
- {
- foreach (ProtoCrewMember kerbal in HighLogic.CurrentGame.CrewRoster.Crew)
- {
- if (kerbal.name == crewmember.CrewName)
- {
- kerbal.type = ProtoCrewMember.KerbalType.Crew;
- kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
- freezer.part.AddCrewmember(kerbal);
- Debug.Log("DeepFreezeEvents Crew Added" + kerbal.name);
- }
- }
- }
- }
- }
- }
- */
- public void onVesselRecovered(ProtoVessel vessel)
- {
- Debug.Log("DeepFreezeEvents onVesselRecovered " + vessel.vesselID);
- this.Log_Debug("AutoRecover is ON");
- foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals)
- {
- if (kerbal.Value.vesselID == vessel.vesselID)
- {
- if (DeepFreeze.Instance.DFsettings.AutoRecoverFznKerbals)
- {
- Debug.Log("Calling ThawFrozen Crew to thaw FrozenCrew " + kerbal.Key);
- ThawFrozenCrew(kerbal.Key, vessel.vesselID);
- }
- else
- {
- Debug.Log("DeepFreeze AutoRecovery of frozen kerbals is set to off. Must be thawed manually.");
-
- Debug.Log("DeepFreezeEvents frozenkerbal =" + kerbal.Key);
- ProtoCrewMember realkerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(b => b.name == kerbal.Key);
- if (realkerbal != null)
- {
- realkerbal.type = ProtoCrewMember.KerbalType.Unowned;
- realkerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
- this.Log_Debug("Kerbal " + realkerbal.name + " " + realkerbal.type + " " + realkerbal.rosterStatus);
- ScreenMessages.PostScreenMessage(kerbal.Key + " was stored frozen at KSC.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
- }
- }
- }
- }
- }
-
- public void onVesselTerminated(ProtoVessel vessel)
- {
- Debug.Log("DeepFreezeEvents onVesselTerminated " + vessel.vesselID);
- foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals)
- {
- if (kerbal.Value.vesselID == vessel.vesselID)
- {
- KillFrozenCrew(kerbal.Key);
- }
- }
- }
-
- public void onVesselWillDestroy(Vessel vessel)
- {
- Debug.Log("DeepFreezeEvents onVesselWillDestroy");
- foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals)
- {
- if (kerbal.Value.vesselID == vessel.id)
- {
- KillFrozenCrew(kerbal.Key);
- }
- }
- }
-
- public void ThawFrozenCrew(String FrozenCrew, Guid vesselID)
- {
- Debug.Log("DeepFreezeEvents ThawFrozenCrew");
- Debug.Log("DeepFreezeEvents frozenkerbal =" + FrozenCrew);
- ProtoCrewMember kerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(a => a.name == FrozenCrew);
- if (kerbal != null)
- {
- Vessel vessel = FlightGlobals.Vessels.Find(v => v.id == vesselID);
- if (vessel == null)
- {
- if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
- {
- if (Funding.CanAfford(costToThawKerbal))
- {
- Funding.Instance.AddFunds(-costToThawKerbal, TransactionReasons.Vessels);
- this.Log_Debug("Took funds to thaw kerbal");
- }
- else
- {
- this.Log_Debug("Not enough funds to thaw kerbal");
- ScreenMessages.PostScreenMessage("Insufficient funds to thaw " + kerbal.name + " at this time.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
- return;
- }
- }
- kerbal.type = ProtoCrewMember.KerbalType.Crew;
- kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned;
- this.Log_Debug("Kerbal " + kerbal.name + " " + kerbal.type + " " + kerbal.rosterStatus);
- kerbal.ArchiveFlightLog();
- kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Available;
- this.Log_Debug("Kerbal " + kerbal.name + " " + kerbal.type + " " + kerbal.rosterStatus);
- ScreenMessages.PostScreenMessage(kerbal.name + " was found and thawed out.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
- DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(kerbal.name);
- }
- else
- {
- this.Log_Debug("Cannot thaw, vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName);
- ScreenMessages.PostScreenMessage("Cannot thaw " + kerbal.name + " vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName, 5.0f, ScreenMessageStyle.UPPER_CENTER);
- }
- }
- }
-
- public void KillFrozenCrew(string FrozenCrew)
- {
- Debug.Log("DeepFreezeEvents KillFrozenCrew");
- Debug.Log("DeepFreezeEvents frozenkerbal =" + FrozenCrew);
- DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(FrozenCrew);
- ProtoCrewMember kerbal = HighLogic.CurrentGame.CrewRoster.Unowned.FirstOrDefault(a => a.name == FrozenCrew);
- if (kerbal != null)
- {
- Debug.Log("DeepFreezeEvents" + kerbal.name + " killed");
- kerbal.type = ProtoCrewMember.KerbalType.Crew;
- kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Dead;
- if (HighLogic.CurrentGame.Parameters.Difficulty.MissingCrewsRespawn == true)
- {
- kerbal.StartRespawnPeriod();
- Debug.Log("DeepFreezeEvents" + kerbal.name + " respawn started.");
- }
- }
- else
- Debug.Log("DeepFreezeEvents" + kerbal.name + " couldn't find them to kill them.");
- }
- }
-}
\ No newline at end of file
diff --git a/Source/DeepFreezeGUI.cs b/Source/DeepFreezeGUI.cs
index 0c3d2ce..117ed5a 100644
--- a/Source/DeepFreezeGUI.cs
+++ b/Source/DeepFreezeGUI.cs
@@ -23,16 +23,14 @@
using UnityEngine;
using Random = System.Random;
using KSP.UI.Screens;
+using RSTUtils.Extensions;
namespace DF
{
internal class DeepFreezeGUI : MonoBehaviour, Savable
{
//GUI Properties
- private bool gamePaused;
-
- private IButton button1;
- private ApplicationLauncherButton stockToolbarButton; // Stock Toolbar Button
+ internal AppLauncherToolBar DFMenuAppLToolBar;
private float DFWINDOW_WIDTH = 560;
private float CFWINDOW_WIDTH = 340;
private float KACWINDOW_WIDTH = 485;
@@ -83,7 +81,6 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable
//settings vars for GUI
private bool InputVautoRecover;
-
private bool InputVdebug;
private bool InputVToolTips;
private bool InputVECReqd;
@@ -111,7 +108,6 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable
//Settings vars
private bool ECreqdForFreezer;
-
private bool debugging;
private bool ToolTips;
private bool AutoRecoverFznKerbals;
@@ -130,7 +126,6 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable
//SwitchVessel vars
private bool showUnabletoSwitchVessel;
-
private bool showSwitchVessel;
private bool switchVesselManual;
private string showSwitchVesselStr = string.Empty;
@@ -138,116 +133,23 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable
private double switchVesselManualTimer;
private bool chgECHeatsettings;
private double chgECHeatsettingsTimer;
-
- //GuiVisibility
- private bool _Visible;
-
- public Boolean GuiVisible
- {
- get { return _Visible; }
- set
- {
- _Visible = value; //Set the private variable
- }
- }
-
+
public bool Useapplauncher;
-
- #region AppLauncher
-
- private void OnGUIAppLauncherReady()
- {
- Utilities.Log_Debug("OnGUIAppLauncherReady");
- if (ApplicationLauncher.Ready)
- {
- Utilities.Log_Debug("Adding AppLauncherButton");
- stockToolbarButton = ApplicationLauncher.Instance.AddModApplication(
- onAppLaunchToggle,
- onAppLaunchToggle,
- DummyVoid,
- DummyVoid,
- DummyVoid,
- DummyVoid,
- ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.FLIGHT |
- ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB |
- ApplicationLauncher.AppScenes.TRACKSTATION,
- GameDatabase.Instance.GetTexture("REPOSoftTech/DeepFreeze/Icons/DeepFreezeOff", false));
- }
- }
-
- private void DummyVoid()
- {
- }
-
- private void onAppLaunchToggle()
- {
- GuiVisible = !GuiVisible;
- if (stockToolbarButton != null)
- stockToolbarButton.SetTexture(GameDatabase.Instance.GetTexture(GuiVisible ? "REPOSoftTech/DeepFreeze/Icons/DeepFreezeOn" : "REPOSoftTech/DeepFreeze/Icons/DeepFreezeOff", false));
- }
-
- private void DestroyToolBar()
- {
- if (ToolbarManager.ToolbarAvailable)
- {
- if (button1 != null)
- button1.Destroy();
- }
- }
-
- private void CreateToolBar()
- {
- if (ToolbarManager.ToolbarAvailable)
- {
- button1 = ToolbarManager.Instance.add("DeepFreeze", "button1");
- button1.TexturePath = "REPOSoftTech/DeepFreeze/Icons/DFtoolbar";
- button1.ToolTip = "DeepFreeze";
- button1.Visibility = new GameScenesVisibility(GameScenes.FLIGHT, GameScenes.EDITOR, GameScenes.SPACECENTER, GameScenes.TRACKSTATION);
- button1.OnClick += e => GuiVisible = !GuiVisible;
- }
- }
-
- private void DestroyStockButton()
- {
- GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
- if (stockToolbarButton != null)
- {
- ApplicationLauncher.Instance.RemoveModApplication(stockToolbarButton);
- stockToolbarButton = null;
- }
- }
-
- private void CreateStockButton()
- {
- Utilities.Log_Debug("Adding onGUIAppLauncher callbacks");
- if (ApplicationLauncher.Ready)
- {
- if (stockToolbarButton == null)
- OnGUIAppLauncherReady();
- }
- else
- GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
- }
-
- #endregion AppLauncher
-
+ private double currentTime;
+
internal void OnDestroy()
{
- DestroyToolBar();
- DestroyStockButton();
- if (GuiVisible) GuiVisible = !GuiVisible;
- GameEvents.onGamePause.Remove(GamePaused);
- GameEvents.onGameUnpause.Remove(GameUnPaused);
+ DFMenuAppLToolBar.Destroy();
}
internal void Start()
{
Utilities.Log_Debug("DeepFreezeGUI startup");
- windowID = new Random().Next();
- CFwindowID = windowID + 1;
- KACwindowID = CFwindowID + 1;
- VSwindowID = KACwindowID + 1;
- VSFwindowID = VSFwindowID + 1;
+ windowID = Utilities.getnextrandomInt();
+ CFwindowID = Utilities.getnextrandomInt();
+ KACwindowID = Utilities.getnextrandomInt();
+ VSwindowID = Utilities.getnextrandomInt();
+ VSFwindowID = Utilities.getnextrandomInt();
DFwindowPos = new Rect(40, Screen.height / 2 - 100, DFWINDOW_WIDTH, WINDOW_BASE_HEIGHT);
CFwindowPos = new Rect(450, Screen.height / 2 - 100, CFWINDOW_WIDTH, 250);
@@ -275,41 +177,35 @@ internal void Start()
DFvslRT = Mathf.Round((DFWINDOW_WIDTH - 28f) * .12f);
Utilities.setScaledScreen();
-
- // create toolbar button
-
- if (ToolbarManager.ToolbarAvailable && Useapplauncher == false)
- {
- CreateToolBar();
- }
- else
+
+ DFMenuAppLToolBar = new AppLauncherToolBar("DeepFreeze", "DeepFreeze",
+ "REPOSoftTech/DeepFreeze/Icons/DFtoolbar",
+ ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.FLIGHT |
+ ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB |
+ ApplicationLauncher.AppScenes.TRACKSTATION,
+ GameDatabase.Instance.GetTexture("REPOSoftTech/DeepFreeze/Icons/DeepFreezeOn", false),
+ GameDatabase.Instance.GetTexture("REPOSoftTech/DeepFreeze/Icons/DeepFreezeOff", false),
+ GameScenes.FLIGHT, GameScenes.EDITOR, GameScenes.SPACECENTER, GameScenes.TRACKSTATION);
+
+ //If Settings wants to use ToolBar mod, check it is installed and available. If not set the TST Setting to use Stock.
+ if (!ToolbarManager.ToolbarAvailable && Useapplauncher)
{
- // Set up the stock toolbar
- CreateStockButton();
+ Useapplauncher = true;
}
- GameEvents.onGamePause.Add(GamePaused);
- GameEvents.onGameUnpause.Add(GameUnPaused);
- Utilities.Log_Debug("DeepFreezeGUI END startup");
- }
- private void GamePaused()
- {
- gamePaused = true;
- }
-
- private void GameUnPaused()
- {
- gamePaused = false;
+ DFMenuAppLToolBar.Start(Useapplauncher);
+
+ Utilities.Log_Debug("DeepFreezeGUI END startup");
}
-
+
private void FixedUpdate()
{
if (Time.timeSinceLevelLoad < 2f) return; //Wait 2 seconds on level load before executing
if (chgECHeatsettings)
{
- double time = Planetarium.GetUniversalTime();
- if (time - chgECHeatsettingsTimer > 2)
+ currentTime = Planetarium.GetUniversalTime();
+ if (currentTime - chgECHeatsettingsTimer > 2)
{
chgECHeatsettings = false;
}
@@ -320,22 +216,19 @@ private void FixedUpdate()
private void OnGUI()
{
- if (!GuiVisible) return;
-
if (!Textures.StylesSet)
Textures.SetupStyles();
if (showSwitchVessel)
{
- if (!Utilities.WindowVisibile(DFVSwindowPos))
- Utilities.MakeWindowVisible(DFVSwindowPos);
+
+ DFVSwindowPos.ClampToScreen();
DFVSwindowPos = GUILayout.Window(VSwindowID, DFVSwindowPos, windowVS, "DeepFreeze Vessel Switch", GUILayout.ExpandWidth(false),
GUILayout.ExpandHeight(true), GUILayout.Width(320), GUILayout.MinHeight(100));
}
if (showUnabletoSwitchVessel && !switchVesselManual)
{
- if (!Utilities.WindowVisibile(DFVSFwindowPos))
- Utilities.MakeWindowVisible(DFVSFwindowPos);
+ DFVSFwindowPos.ClampToScreen();
DFVSFwindowPos = GUILayout.Window(VSFwindowID, DFVSFwindowPos, windowVSF, "DeepFreeze Vessel Switch Failed", GUILayout.ExpandWidth(false),
GUILayout.ExpandHeight(true), GUILayout.Width(320), GUILayout.MinHeight(100));
}
@@ -347,15 +240,14 @@ private void OnGUI()
switchVesselManual = false;
}
}
- if (!GuiVisible || gamePaused || FlightDriver.Pause)
+ if (!DFMenuAppLToolBar.GuiVisible || DFMenuAppLToolBar.gamePaused || DFMenuAppLToolBar.hideUI)
{
return;
}
if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT)
{
GUI.skin = HighLogic.Skin;
- if (!Utilities.WindowVisibile(DFwindowPos))
- Utilities.MakeWindowVisible(DFwindowPos);
+ DFwindowPos.ClampInsideScreen();
DFwindowPos = GUILayout.Window(windowID, DFwindowPos, windowDF, "DeepFreeze Kerbals", GUILayout.ExpandWidth(true),
GUILayout.ExpandHeight(true), GUILayout.MinWidth(200), GUILayout.MinHeight(250));
if (showConfigGUI)
@@ -382,15 +274,13 @@ private void OnGUI()
InputStripLightsOn = StripLightsOn;
LoadConfig = false;
}
- if (!Utilities.WindowVisibile(CFwindowPos))
- Utilities.MakeWindowVisible(CFwindowPos);
+ CFwindowPos.ClampInsideScreen();
CFwindowPos = GUILayout.Window(CFwindowID, CFwindowPos, windowCF, "DeepFreeze Settings", GUILayout.ExpandWidth(true),
GUILayout.ExpandHeight(true), GUILayout.MinWidth(400), GUILayout.MinHeight(300));
}
if (showKACGUI)
{
- if (!Utilities.WindowVisibile(DFKACwindowPos))
- Utilities.MakeWindowVisible(DFKACwindowPos);
+ DFKACwindowPos.ClampInsideScreen();
DFKACwindowPos = GUILayout.Window(KACwindowID, DFKACwindowPos, windowKAC, "DeepFreeze Alarms", GUILayout.ExpandWidth(true),
GUILayout.ExpandHeight(true), GUILayout.MinWidth(360), GUILayout.MinHeight(150));
}
@@ -406,7 +296,7 @@ private void windowDF(int id)
Rect closeRect = new Rect(DFwindowPos.width - 21, 4, 16, 16);
if (GUI.Button(closeRect, closeContent, Textures.ClosebtnStyle))
{
- onAppLaunchToggle();
+ DFMenuAppLToolBar.onAppLaunchToggle();
return;
}
@@ -953,30 +843,11 @@ private void windowCF(int id)
GUILayout.BeginHorizontal();
if (GUILayout.Button(new GUIContent("Save & Exit Settings", "Exit this menu and Save Settings"), GUILayout.Width(155f)))
{
+
if (Useapplauncher != InputAppL)
{
- if (InputAppL == true) //Use stock
- {
- Useapplauncher = InputAppL;
- DestroyToolBar();
- CreateStockButton();
- }
- else //Use toolbar
- {
- if (ToolbarManager.ToolbarAvailable) //Is it available?
- {
- Useapplauncher = InputAppL;
- DestroyStockButton();
- CreateToolBar();
- }
- else //Otherwise use stock.
- {
- Useapplauncher = true;
- DestroyToolBar();
- CreateStockButton();
- }
-
- }
+ Useapplauncher = InputAppL;
+ DFMenuAppLToolBar.chgAppIconStockToolBar(Useapplauncher);
}
if (ECreqdForFreezer != InputVECReqd)
diff --git a/Source/DeepFreezeOff.png b/Source/DeepFreezeOff.png
deleted file mode 100644
index 223c150..0000000
Binary files a/Source/DeepFreezeOff.png and /dev/null differ
diff --git a/Source/DeepFreezeOn.png b/Source/DeepFreezeOn.png
deleted file mode 100644
index f54c851..0000000
Binary files a/Source/DeepFreezeOn.png and /dev/null differ
diff --git a/Source/DeepFreezerPart.cs b/Source/DeepFreezerPart.cs
index ff5ebc8..b220610 100644
--- a/Source/DeepFreezerPart.cs
+++ b/Source/DeepFreezerPart.cs
@@ -28,15 +28,6 @@
namespace DF
{
- public enum DoorState
- {
- OPEN,
- CLOSED,
- OPENING,
- CLOSING,
- UNKNOWN
- }
-
public class DeepFreezer : PartModule, IResourceConsumer
{
private float lastUpdate; // time since we last updated the part menu
@@ -186,7 +177,7 @@ public void showMenu()
{
DeepFreezeGUI obj = DeepFreeze.Instance.GetComponent("DeepFreezeGUI") as DeepFreezeGUI;
if (obj != null)
- obj.GuiVisible = !obj.GuiVisible;
+ obj.DFMenuAppLToolBar.GuiVisible = !obj.DFMenuAppLToolBar.GuiVisible;
else
Utilities.Log("DeepFreezer ToggleMenu error");
}
@@ -1466,14 +1457,14 @@ private void ChkOngoingTemp(PartInfo partInfo)
public override void OnLoad(ConfigNode node)
{
- Debug.Log("DeepFreezer onLoad");
+ //Debug.Log("DeepFreezer onLoad");
base.OnLoad(node);
cryopodstateclosed = new bool[FreezerSize];
seatTakenbyFrznKerbal = new bool[FreezerSize];
loadcryopodstatepersistent();
loadexternaldoorstatepersistent();
- Debug.Log("OnLoad: " + node);
- Debug.Log("DeepFreezer end onLoad");
+ //Debug.Log("OnLoad: " + node);
+ //Debug.Log("DeepFreezer end onLoad");
}
public override void OnStart(StartState state)
@@ -1631,12 +1622,12 @@ public override void OnStart(StartState state)
public override void OnSave(ConfigNode node)
{
- Debug.Log("DeepFreezer onSave");
+ //Debug.Log("DeepFreezer onSave");
savecryopodstatepersistent();
saveexternaldoorstatepersistent();
base.OnSave(node);
- Debug.Log("OnSave: " + node);
- Debug.Log("DeepFreezer end onSave");
+ //Debug.Log("OnSave: " + node);
+ //Debug.Log("DeepFreezer end onSave");
}
private void OnDestroy()
@@ -4619,77 +4610,5 @@ public static void FixedBackgroundUpdate(Vessel v, uint partFlightID, Func();
- Utilities.Log_Debug("DFExtDoorMgr OnUpdate Set part " + part.name);
- }
- }
- }
-
- public void ButtonExtDoor(bool state)
- {
- if (Freezer == null)
- {
- Freezer = part.FindModuleImplementing();
- Utilities.Log_Debug("DFExtDoorMgr buttonExtDoorState set part " + part.name);
- }
- if (Freezer == null) return; // If freezer is still null just return
- if (!Freezer.ExternalDoorActive) return; // if freezer doesn't have an external door just return.
-
- if (Freezer._externaldoorstate == DoorState.OPEN)
- {
- //Door is open so we trigger a closedoor.
- Freezer.eventCloseDoors();
- Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired triggerred eventCloseDoors");
- }
- else
- {
- if (Freezer._externaldoorstate == DoorState.CLOSED)
- {
- //Door is closed so we trigger a opendoor.
- Freezer.eventOpenDoors();
- Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired triggerred eventOpenDoors");
- }
- else
- {
- // door already opening or closing...
- Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoor fired but door state is opening, closing or unknown");
- }
- }
- }
-
- public bool ButtonExtDoorState()
- {
- // Utilities.Log_Debug("DFExtDoorMgr ButtonExtDoorState fired");
- if (Freezer == null)
- {
- Freezer = part.FindModuleImplementing();
- Utilities.Log_Debug("DFExtDoorMgr buttonExtDoorState set part " + part.name);
- }
- if (Freezer == null) return false; // if freezer still null return false
- if (!Freezer.ExternalDoorActive) return false; // if freezer doesn't have an external door just return.
- if (Freezer._externaldoorstate == DoorState.CLOSED || Freezer._externaldoorstate == DoorState.CLOSING || Freezer._externaldoorstate == DoorState.UNKNOWN)
- {
- Utilities.Log_Debug("DFExtDoorMgr Door is closed or closing or unknown return state false");
- return false;
- }
- Utilities.Log_Debug("DFExtDoorMgr Door is open or opening return state true");
- return true;
- }
- }
-
- #endregion ExtDoorMgr
+
}
\ No newline at end of file
diff --git a/Source/KACWrapper.cs b/Source/KACWrapper.cs
deleted file mode 100644
index a4cfc3d..0000000
--- a/Source/KACWrapper.cs
+++ /dev/null
@@ -1,651 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Reflection;
-
-// TODO: Change this namespace to something specific to your plugin here.
-//EG:
-// namespace MyPlugin_KACWrapper
-namespace DF
-{
- ///////////////////////////////////////////////////////////////////////////////////////////
- // BELOW HERE SHOULD NOT BE EDITED - this links to the loaded KAC module without requiring a Hard Dependancy
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- ///
- /// The Wrapper class to access KAC from another plugin
- ///
- public class KACWrapper
- {
- protected static System.Type KACType;
- protected static System.Type KACAlarmType;
-
- protected static Object actualKAC = null;
-
- ///
- /// This is the Kerbal Alarm Clock object
- ///
- /// SET AFTER INIT
- ///
- public static KACAPI KAC = null;
-
- ///
- /// Whether we found the KerbalAlarmClock assembly in the loadedassemblies.
- ///
- /// SET AFTER INIT
- ///
- public static Boolean AssemblyExists { get { return (KACType != null); } }
-
- ///
- /// Whether we managed to hook the running Instance from the assembly.
- ///
- /// SET AFTER INIT
- ///
- public static Boolean InstanceExists { get { return (KAC != null); } }
-
- ///
- /// Whether we managed to wrap all the methods/functions from the instance.
- ///
- /// SET AFTER INIT
- ///
- private static Boolean _KACWrapped = false;
-
- ///
- /// Whether the object has been wrapped and the APIReady flag is set in the real KAC
- ///
- public static Boolean APIReady { get { return _KACWrapped && KAC.APIReady && !NeedUpgrade; } }
-
- public static Boolean NeedUpgrade { get; private set; }
-
- ///
- /// This method will set up the KAC object and wrap all the methods/functions
- ///
- /// This option will force the Init function to rebind everything
- ///
- public static Boolean InitKACWrapper()
- {
- //if (!_KACWrapped )
- //{
- //reset the internal objects
- _KACWrapped = false;
- actualKAC = null;
- KAC = null;
- LogFormatted("Attempting to Grab KAC Types...");
-
- //find the base type
- KACType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KerbalAlarmClock");
-
- if (KACType == null)
- {
- return false;
- }
-
- LogFormatted("KAC Version:{0}", KACType.Assembly.GetName().Version.ToString());
- if (KACType.Assembly.GetName().Version.CompareTo(new System.Version(3, 0, 0, 5)) < 0)
- {
- //No TimeEntry or alarmchoice options = need a newer version
- NeedUpgrade = true;
- }
-
- //now the Alarm Type
- KACAlarmType = AssemblyLoader.loadedAssemblies
- .Select(a => a.assembly.GetExportedTypes())
- .SelectMany(t => t)
- .FirstOrDefault(t => t.FullName == "KerbalAlarmClock.KACAlarm");
-
- if (KACAlarmType == null)
- {
- return false;
- }
-
- //now grab the running instance
- LogFormatted("Got Assembly Types, grabbing Instance");
-
- try
- {
- actualKAC = KACType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
- }
- catch (Exception)
- {
- NeedUpgrade = true;
- LogFormatted("No APIInstance found - most likely you have KAC v2 installed");
- //throw;
- }
- if (actualKAC == null)
- {
- LogFormatted("Failed grabbing Instance");
- return false;
- }
-
- //If we get this far we can set up the local object and its methods/functions
- LogFormatted("Got Instance, Creating Wrapper Objects");
- KAC = new KACAPI(actualKAC);
- //}
- _KACWrapped = true;
- return true;
- }
-
- ///
- /// The Type that is an analogue of the real KAC. This lets you access all the API-able properties and Methods of the KAC
- ///
- public class KACAPI
- {
- internal KACAPI(Object KAC)
- {
- //store the actual object
- actualKAC = KAC;
-
- //these sections get and store the reflection info and actual objects where required. Later in the properties we then read the values from the actual objects
- //for events we also add a handler
- LogFormatted("Getting APIReady Object");
- APIReadyField = KACType.GetField("APIReady", BindingFlags.Public | BindingFlags.Static);
- LogFormatted("Success: " + (APIReadyField != null).ToString());
-
- //WORK OUT THE STUFF WE NEED TO HOOK FOR PEOPEL HERE
- LogFormatted("Getting Alarms Object");
- AlarmsField = KACType.GetField("alarms", BindingFlags.Public | BindingFlags.Static);
- actualAlarms = AlarmsField.GetValue(actualKAC);
- LogFormatted("Success: " + (actualAlarms != null).ToString());
-
- //Events
- LogFormatted("Getting Alarm State Change Event");
- onAlarmStateChangedEvent = KACType.GetEvent("onAlarmStateChanged", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (onAlarmStateChangedEvent != null).ToString());
- LogFormatted_DebugOnly("Adding Handler");
- AddHandler(onAlarmStateChangedEvent, actualKAC, AlarmStateChanged);
-
- //Methods
- LogFormatted("Getting Create Method");
- CreateAlarmMethod = KACType.GetMethod("CreateAlarm", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (CreateAlarmMethod != null).ToString());
-
- LogFormatted("Getting Delete Method");
- DeleteAlarmMethod = KACType.GetMethod("DeleteAlarm", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (DeleteAlarmMethod != null).ToString());
-
- LogFormatted("Getting DrawAlarmAction");
- DrawAlarmActionChoiceMethod = KACType.GetMethod("DrawAlarmActionChoiceAPI", BindingFlags.Public | BindingFlags.Instance);
- LogFormatted_DebugOnly("Success: " + (DrawAlarmActionChoiceMethod != null).ToString());
-
- //LogFormatted("Getting DrawTimeEntry");
- //DrawTimeEntryMethod = KACType.GetMethod("DrawTimeEntryAPI", BindingFlags.Public | BindingFlags.Instance);
- //LogFormatted_DebugOnly("Success: " + (DrawTimeEntryMethod != null).ToString());
-
- //Commenting out rubbish lines
- //MethodInfo[] mis = KACType.GetMethods(BindingFlags.Public | BindingFlags.Instance);
- //foreach (MethodInfo mi in mis)
- //{
- // LogFormatted("M:{0}-{1}", mi.Name, mi.DeclaringType);
- //}
- }
-
- private Object actualKAC;
-
- private FieldInfo APIReadyField;
-
- ///
- /// Whether the APIReady flag is set in the real KAC
- ///
- public Boolean APIReady
- {
- get
- {
- if (APIReadyField == null)
- return false;
-
- return (Boolean)APIReadyField.GetValue(null);
- }
- }
-
- #region Alarms
-
- private Object actualAlarms;
- private FieldInfo AlarmsField;
-
- ///
- /// The list of Alarms that are currently active in game
- ///
- internal KACAlarmList Alarms
- {
- get
- {
- return ExtractAlarmList(actualAlarms);
- }
- }
-
- ///
- /// This converts the KACAlarmList actual object to a new List for consumption
- ///
- ///
- ///
- private KACAlarmList ExtractAlarmList(Object actualAlarmList)
- {
- KACAlarmList ListToReturn = new KACAlarmList();
- try
- {
- //iterate each "value" in the dictionary
-
- foreach (var item in (IList)actualAlarmList)
- {
- KACAlarm r1 = new KACAlarm(item);
- ListToReturn.Add(r1);
- }
- }
- catch (Exception)
- {
- //LogFormatted("Arrggg: {0}", ex.Message);
- //throw ex;
- //
- }
- return ListToReturn;
- }
-
- #endregion Alarms
-
- #region Events
-
- ///
- /// Takes an EventInfo and binds a method to the event firing
- ///
- /// EventInfo of the event we want to attach to
- /// actual object the eventinfo is gathered from
- /// Method that we are going to hook to the event
- protected void AddHandler(EventInfo Event, Object KACObject, Action