Skip to content

Commit

Permalink
Merge 2.2.0.0 to master
Browse files Browse the repository at this point in the history
  • Loading branch information
TriggerAu committed Apr 19, 2014
2 parents 270b751 + 09ca0a6 commit 4def0d4
Show file tree
Hide file tree
Showing 15 changed files with 370 additions and 51 deletions.
51 changes: 38 additions & 13 deletions AlternateResourcePanel/ARP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private KSPAlternateResourcePanel()

internal ARPPartList lstPartsLastStageEngines;
internal List<ModuleEngines> lstLastStageEngineModules;
internal List<ModuleEnginesFX> lstLastStageEngineFXModules;

/// <summary>
/// ResourceIDs of ones to show in window
Expand Down Expand Up @@ -307,7 +308,8 @@ void DrawGUI()
ShowAll = false;

//Are we drawing the main window - hovering, or toggled or alarmsenabled and an unackowledged alarm - and theres resources
if ((HoverOn || settings.ToggleOn || (settings.AlarmsEnabled && lstResourcesVessel.UnacknowledgedAlarms())) && (lstResourcesVessel.Count > 0))
//if ((HoverOn || settings.ToggleOn || (settings.AlarmsEnabled && lstResourcesVessel.UnacknowledgedAlarms())) && (lstResourcesVessel.Count > 0))
if ((HoverOn || settings.ToggleOn || (settings.AlarmsEnabled && lstResourcesVessel.UnacknowledgedAlarms())) && (lstResourcesVessel.Count > 0))
{
windowMain.Visible = true;
if (blnResetWindow)
Expand All @@ -332,13 +334,15 @@ void DrawGUI()
internal Boolean IsMouseOver()
{
if ((settings.BlizzyToolbarIsAvailable && settings.UseBlizzyToolbarIfAvailable))
return MouseOverToolbarBtn || (windowMain.Visible && windowMain.WindowRect.Contains(Event.current.mousePosition));
//return MouseOverToolbarBtn || (windowMain.Visible && windowMain.WindowRect.Contains(Event.current.mousePosition));
return (MouseOverToolbarBtn && !settings.DisableHover) ||
(windowMain.Visible && windowMain.WindowRect.Contains(Event.current.mousePosition));

//are we painting?
Boolean blnRet = Event.current.type == EventType.Repaint;

//And the mouse is over the button
blnRet = blnRet && rectButton.Contains(Event.current.mousePosition);
//And the mouse is over the button - if hovering is not disabled
blnRet = blnRet && rectButton.Contains(Event.current.mousePosition) && !settings.DisableHover;

//mouse in main window
blnRet = blnRet || (windowMain.Visible && windowMain.WindowRect.Contains(Event.current.mousePosition));
Expand Down Expand Up @@ -401,7 +405,7 @@ internal override void RepeatingWorker()
}
}

if(DecoupledInLastStage && p.Modules.OfType<ModuleEngines>().Any())
if(DecoupledInLastStage && (p.Modules.OfType<ModuleEngines>().Any() || p.Modules.OfType<ModuleEnginesFX>().Any()))
{
//Add the part to the engines list for the active stage
lstPartsLastStageEngines.Add(p);
Expand Down Expand Up @@ -473,11 +477,16 @@ internal override void RepeatingWorker()
if (lstResourcesVessel[ResourceID].MonitorState == ARPResource.MonitorStateEnum.None)
continue;
}
else if (settings.HideEmptyResources && settings.Resources[ResourceID].HideWhenEmpty && lstResourcesVessel[ResourceID].IsEmpty)
{
else if (settings.HideEmptyResources && settings.Resources[ResourceID].HideWhenEmpty && lstResourcesVessel[ResourceID].IsEmpty) {
//if the alarms not firing and the time has passed then hide it
if (lstResourcesVessel[ResourceID].AlarmState != ARPResource.AlarmStateEnum.Unacknowledged &&
lstResourcesVessel[ResourceID].EmptyAt < DateTime.Now.AddSeconds(-settings.HideAfter))
continue;
}
else if (settings.HideFullResources && settings.Resources[ResourceID].HideWhenFull && lstResourcesVessel[ResourceID].IsFull) {
//if the alarms not firing and the time has passed then hide it
if (lstResourcesVessel[ResourceID].AlarmState!=ARPResource.AlarmStateEnum.Unacknowledged &&
lstResourcesVessel[ResourceID].EmptyAt<DateTime.Now.AddSeconds(-settings.HideAfter))
if (lstResourcesVessel[ResourceID].AlarmState != ARPResource.AlarmStateEnum.Unacknowledged &&
lstResourcesVessel[ResourceID].FullAt < DateTime.Now.AddSeconds(-settings.HideAfter))
continue;
}
}
Expand Down Expand Up @@ -517,6 +526,7 @@ internal override void RepeatingWorker()

//now do the autostaging stuff
lstLastStageEngineModules = lstPartsLastStageEngines.SelectMany(x => x.Modules.OfType<ModuleEngines>()).ToList();
lstLastStageEngineFXModules = lstPartsLastStageEngines.SelectMany(x => x.Modules.OfType<ModuleEnginesFX>()).ToList();
AutoStagingMaxStage = Mathf.Min(AutoStagingMaxStage, Staging.StageCount - 1);
AutoStagingTerminateAt = Mathf.Min(AutoStagingTerminateAt, AutoStagingMaxStage);
AutoStagingStatusColor = Color.white;
Expand All @@ -529,7 +539,7 @@ internal override void RepeatingWorker()
AutoStagingStatusColor = Color.white;
AutoStagingStatus = "Armed... waiting for stage";
//when to set it to running
if (lstLastStageEngineModules.Any(x => x.staged))
if (lstLastStageEngineModules.Any(x => x.staged) || lstLastStageEngineFXModules.Any(x => x.staged))
AutoStagingRunning = true;
}
else if (Staging.CurrentStage > AutoStagingTerminateAt)
Expand All @@ -539,7 +549,7 @@ internal override void RepeatingWorker()
AutoStagingStatus = "Running";

//are all the engines that are active flamed out in the last stage
if (AutoStagingTriggeredAt == 0 && (lstLastStageEngineModules.Where(x=>x.staged).All(x => x.getFlameoutState)))
if (AutoStagingTriggeredAt == 0 && (lstLastStageEngineModules.Where(x => x.staged).All(x => x.getFlameoutState)) && (lstLastStageEngineFXModules.Where(x => x.staged).All(x => x.getFlameoutState)))
{
AutoStagingTriggeredAt = Planetarium.GetUniversalTime();
}
Expand Down Expand Up @@ -865,11 +875,26 @@ public void Start()
{
first = false;
HighLogic.SaveFolder = "default";
var game = GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false);
Game game = GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false);

if (game != null && game.flightState != null && game.compatible)
{
FlightDriver.StartAndFocusVessel(game, 0);
Int32 FirstVessel;
Boolean blnFoundVessel=false;
for (FirstVessel = 0; FirstVessel < game.flightState.protoVessels.Count; FirstVessel++)
{
if (game.flightState.protoVessels[FirstVessel].vesselType != VesselType.SpaceObject &&
game.flightState.protoVessels[FirstVessel].vesselType != VesselType.Unknown)
{
blnFoundVessel = true;
break;
}
}
if (!blnFoundVessel)
FirstVessel = 0;
FlightDriver.StartAndFocusVessel(game, FirstVessel);
}

//CheatOptions.InfiniteFuel = true;
}
}
Expand Down
24 changes: 20 additions & 4 deletions AlternateResourcePanel/ARPWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ internal override void DrawWindow(Int32 id)
////STAGING STUFF
if (settings.StagingEnabled)
{
////Keyboard Stage Lock
//GUIContent contLock = new GUIContent(Resources.btnUnlock, "Keyboard Staging Unlocked\r\nClick to toggle");
//if (FlightInputHandler.fetch.stageLock)
// contLock = new GUIContent(Resources.btnLock, "Keyboard Staging Locked\r\nClick to toggle");
//if (GUILayout.Button(contLock, Styles.styleAlarmButton))
// FlightInputHandler.fetch.stageLock = !FlightInputHandler.fetch.stageLock;

if (!settings.AutoStagingEnabled)
{
//GUILayout.Label("Stage:", Styles.styleStageTextHead, GUILayout.Width(50));
Expand All @@ -175,7 +182,8 @@ internal override void DrawWindow(Int32 id)
if (GUILayout.Button("Activate Stage", "ButtonGeneral", GUILayout.Width(100)))
Staging.ActivateNextStage();
}
GUILayout.Space(48 + IconAlarmOffset);
//GUILayout.Space(48 + IconAlarmOffset);
GUILayout.Space(21 + IconAlarmOffset);
}
else
{
Expand Down Expand Up @@ -205,15 +213,23 @@ internal override void DrawWindow(Int32 id)

GUIStyle StatusStyle = new GUIStyle(SkinsLibrary.CurrentSkin.label) ;
StatusStyle.normal.textColor = mbARP.AutoStagingStatusColor;
GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(147+IconAlarmOffset));
//GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(147 + IconAlarmOffset));
GUILayout.Label(mbARP.AutoStagingStatus, StatusStyle, GUILayout.Width(120 + IconAlarmOffset));
}
}
else
{
GUILayout.Space(234 + IconAlarmOffset);
//GUILayout.Space(234 + IconAlarmOffset);
GUILayout.Space(207 + IconAlarmOffset);
}

// ShowAll Button
if (GUILayout.Button(new GUIContent(Resources.btnViewTimes, "Toggle Time Remaining"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
{
settings.ShowTimeRem = !settings.ShowTimeRem;
}

//Settings ShowAll Button
// ShowAll Button
if (GUILayout.Button(new GUIContent(Resources.btnViewAll, "Toggle Hidden Resources"), SkinsLibrary.CurrentSkin.button.PaddingChange(1), GUILayout.Width(23)))
{
KSPAlternateResourcePanel.ShowAll = !KSPAlternateResourcePanel.ShowAll;
Expand Down
48 changes: 40 additions & 8 deletions AlternateResourcePanel/ARPWindowDebug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ internal class ARPWindowDebug: MonoBehaviourWindowPlus
public Int32 intTest3=0;
public Int32 intTest4 = 0;
public Int32 intTest5 = 200;

//Boolean Clicked = false;
internal override void DrawWindow(int id)
{
//GUILayout.Label(Drawing.RectTest.ToString());
Expand Down Expand Up @@ -75,10 +77,39 @@ internal override void DrawWindow(int id)
GUILayout.Label(String.Format("Draw Settings Duration: {0:0.00}ms", mbARP.windowSettings.DrawWindowInternalDuration.TotalMilliseconds));
GUILayout.Label(String.Format("Draw Main Duration: {0:0.00}ms", mbARP.windowMain.DrawWindowInternalDuration.TotalMilliseconds));

foreach (ModuleEngines item in mbARP.lstLastStageEngineModules)
{
GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}-{5}", item.getFlameoutState, item.getIgnitionState, item.EngineIgnited, item.isOperational, item.staged, item.status));
}
//GUILayout.Label(InputLockManager.IsLocked(ControlTypes.STAGING).ToString());
//foreach (KeyValuePair<string,ulong> item in InputLockManager.lockStack)
//{
// GUILayout.Label(String.Format("{0},{1}", item.Key.ToString(), item.Value.ToString()));
//}
//if (GUILayout.Button("Lock"))
//{
// if (InputLockManager.IsLocked(ControlTypes.STAGING))
// if (InputLockManager.lockStack.ContainsKey("manualStageLock"))
// InputLockManager.RemoveControlLock("manualStageLock");
// else
// InputLockManager.SetControlLock(ControlTypes.STAGING, "manualStageLock");
//}

//foreach (ModuleEngines item in mbARP.lstLastStageEngineModules)
//{
// GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}-{5}", item.getFlameoutState, item.getIgnitionState, item.EngineIgnited, item.isOperational, item.staged, item.status));
//}

//foreach (Part p in FlightGlobals.ActiveVessel.Parts)
//{
// foreach (PartModule item in p.Modules)
// {
// GUILayout.Label(String.Format("{0}", item.ClassName));

// if (item.ClassName=="ModuleEnginesFX")
// {
// ModuleEnginesFX a = (ModuleEnginesFX)item;
// GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}-{5}", a.getFlameoutState, a.getIgnitionState, a.EngineIgnited, a.isOperational, a.staged, a.status));
// }
// }
//}


//GUILayout.Label(KSPAlternateResourcePanel.HoverOn.ToString());
//GUILayout.Label(KSPAlternateResourcePanel.ShowAll.ToString());
Expand Down Expand Up @@ -152,12 +183,13 @@ internal override void DrawWindow(int id)

//GUILayout.Label(mbARP.MouseOverToolbarBtn.ToString());

//foreach (ARPResource r in mbARP.lstResourcesVessel.Values)
//{
// //GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}", r.ResourceDef.name, r.AmountFormatted, r.MaxAmountFormatted, r.RateFormatted, r.AmountLastFormatted)); //, r.RateFormatted2, r.RateSamples.Count));
foreach (ARPResource r in mbARP.lstResourcesVessel.Values)
{
GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", r.ResourceDef.name, r.AmountFormatted, r.MaxAmountFormatted, r.RateFormatted, r.IsEmpty, r.EmptyAt.ToString("HH:mm:ss"), r.IsFull, r.FullAt.ToString("HH:mm:ss"))); //, r.RateFormatted2, r.RateSamples.Count));

// //GUILayout.Label(String.Format("{0}-{1}-{2}-{3:0}-{4}-{5}", r.ResourceDef.name, r.AmountFormatted, r.MaxAmountFormatted, r.Amount / r.MaxAmount * 100, KSPAlternateResourcePanel.settings.Resources[r.ResourceDef.id].MonitorWarningLevel, r.MonitorWarning)); //, r.RateFormatted2, r.RateSamples.Count));
// GUILayout.Label(String.Format("{0}-{1}-{2}-{3}-{4}", r.ResourceDef.name, r.MonitorWarning,r.MonitorAlert,r.MonitorWorstHealth,r.AlarmAcknowledged)); //, r.RateFormatted2, r.RateSamples.Count));
//}
}

//foreach (Int32 item in mbARP.lstResourcesToDisplay)
//{
Expand Down
4 changes: 4 additions & 0 deletions AlternateResourcePanel/ARPWindowResourceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ internal override void DrawWindow(int id)
GUILayout.Label("Empty Behaviour:", temp, GUILayout.Width(120));
DrawToggle(ref settings.Resources[item.id].HideWhenEmpty, "Hide When Empty", Styles.styleToggle);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Full Behaviour:", temp, GUILayout.Width(120));
DrawToggle(ref settings.Resources[item.id].HideWhenFull, "Hide When Full", Styles.styleToggle);
GUILayout.EndHorizontal();
GUILayout.Space(3);
GUILayout.EndVertical();
}
Expand Down
Loading

0 comments on commit 4def0d4

Please sign in to comment.