Skip to content

Commit

Permalink
Updates to support new GUI. Removed lots of debug spam
Browse files Browse the repository at this point in the history
  • Loading branch information
jwvanderbeck committed Jan 8, 2015
1 parent a087b99 commit 6590b80
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions TestFlightCore/TestFlightCore/TestFlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal struct PartStatus
internal int flightTime;
internal double flightData;
internal double reliability;
internal double momentaryReliability;
internal ITestFlightCore flightCore;
internal ITestFlightFailure activeFailure;
internal bool highlightPart;
Expand Down Expand Up @@ -244,6 +245,19 @@ public override void OnAwake()
settings.minTimeBetweenFailurePoll = 60;
settings.processAllVessels = false;
settings.masterStatusUpdateFrequency = 10;
settings.displaySettingsWindow = true;

settings.showFailedPartsOnlyInMSD = false;
settings.showFlightDataInMSD = true;
settings.showMomentaryReliabilityInMSD = false;
settings.showRestingReliabilityInMSD = true;
settings.showStatusTextInMSD = true;
settings.shortenPartNameInMSD = false;
settings.settingsPage = 0;
settings.mainWindowLocked = true;
settings.mainWindowPosition = new Rect(0, 0, 0, 0);
settings.currentMSDSize = 1;

settings.Save();
}
settings.Load();
Expand Down Expand Up @@ -297,7 +311,6 @@ public void VerifyMasterStatus()
List<Guid> vesselsToDelete = new List<Guid>();
foreach(var entry in masterStatus)
{
Debug.Log("TestFlightManagerScenario: Checking if vessel(" + entry.Key + ") in Master Status is still valid");
Vessel vessel = FlightGlobals.Vessels.Find(v => v.id == entry.Key);
if (vessel == null)
{
Expand All @@ -313,7 +326,8 @@ public void VerifyMasterStatus()
}
}
}
Debug.Log("TestFlightManagerScenario: Removing " + vesselsToDelete.Count() + " vessels from Master Status");
if (vesselsToDelete.Count > 0)
Debug.Log("TestFlightManagerScenario: Removing " + vesselsToDelete.Count() + " vessels from Master Status");
foreach (Guid id in vesselsToDelete)
{
masterStatus.Remove(id);
Expand All @@ -324,18 +338,17 @@ public void VerifyMasterStatus()
{
partsToDelete.Clear();
Vessel vessel = FlightGlobals.Vessels.Find(v => v.id == entry.Key);
Debug.Log("TestFlightManagerScenario: Scanning parts on vessel" + vessel.GetName() + " for master status update");
foreach (PartStatus partStatus in masterStatus[entry.Key].allPartsStatus)
{
Debug.Log("TestFlightManagerScenario: Looking to see if part with flightID " + partStatus.partID + " still exists");
Part part = vessel.Parts.Find(p => p.flightID == partStatus.partID);
if (part == null)
{
Debug.Log("TestFlightManagerScenario: Could not find part. Marking it for deletion.");
Debug.Log("TestFlightManagerScenario: Could not find part. " + partStatus.partName + "(" + partStatus.partID + ") Marking it for deletion.");
partsToDelete.Add(partStatus);
}
}
Debug.Log("TestFlightManagerScenario: Deleting " + partsToDelete.Count() + " parts from vessel " + vessel.GetName());
if (partsToDelete.Count > 0)
Debug.Log("TestFlightManagerScenario: Deleting " + partsToDelete.Count() + " parts from vessel " + vessel.GetName());
foreach (PartStatus oldPartStatus in partsToDelete)
{
masterStatus[entry.Key].allPartsStatus.Remove(oldPartStatus);
Expand Down Expand Up @@ -413,7 +426,6 @@ public TestFlightData DoDataUpdate(ITestFlightCore core, Part part)

public void DoFailureUpdate(ITestFlightCore core, double launchTime)
{
Debug.Log("TestFlightManagerScenario: Doing Failure Update");
core.DoFailureCheck(launchTime, settings.globalReliabilityModifier);
}

Expand Down Expand Up @@ -535,16 +547,13 @@ public void Update()

public override void OnLoad(ConfigNode node)
{
Debug.Log("TestFlightManagerScenario: OnLoad()");
Debug.Log(node);
if (node.HasNode("FLIGHTDATA_PART"))
{
if (partsFlightData == null)
partsFlightData = new List<PartFlightData>();

foreach (ConfigNode partNode in node.GetNodes("FLIGHTDATA_PART"))
{
Debug.Log("TestFlightManagerScenario: Loading Flight Data");
PartFlightData partData = new PartFlightData();
partData.Load(partNode);
partsFlightData.Add(partData);
Expand All @@ -556,10 +565,8 @@ public override void OnLoad(ConfigNode node)

public override void OnSave(ConfigNode node)
{
Debug.Log("TestFlightManagerScenario: OnSave()");
if (HighLogic.LoadedSceneIsFlight)
{
Debug.Log("TestFlightManagerScenario: Saving in FLIGHT scene");
foreach (PartFlightData partData in partsFlightData)
{
ConfigNode partNode = node.AddNode("FLIGHTDATA_PART");
Expand All @@ -568,15 +575,12 @@ public override void OnSave(ConfigNode node)
}
else
{
Debug.Log("TestFlightManagerScenario: Saving in NON-FLIGHT scene");
foreach (PartFlightData partData in partsFlightData)
{
ConfigNode partNode = node.AddNode("FLIGHTDATA_PART");
partData.Save(partNode);
}
}
Debug.Log(node);
Debug.Log("TestFlight: Scenario Saved");
}

}
Expand Down

0 comments on commit 6590b80

Please sign in to comment.