Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion TransferWindowPlanner/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal enum DisplaySkin


[Persistent] internal TWP_KACWrapper.KACWrapper.KACAPI.AlarmActionEnum KACAlarmAction = TWP_KACWrapper.KACWrapper.KACAPI.AlarmActionEnum.KillWarp;
[Persistent] internal Double KACMargin = 24;
[Persistent] internal Double AlarmMargin = 24;

[Persistent] internal Boolean ClickThroughProtect_KSC=true;
[Persistent] internal Boolean ClickThroughProtect_Editor=true;
Expand All @@ -72,6 +72,8 @@ internal enum DisplaySkin

[Persistent] internal bool UseStockDateFormatters = true;

[Persistent] internal bool OverrideKAC = false;

//Version Stuff
[Persistent] internal Boolean DailyVersionCheck = true;
internal Boolean VersionAttentionFlag = false;
Expand Down
37 changes: 31 additions & 6 deletions TransferWindowPlanner/TWPWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,18 @@ private void DrawTransferDetails()
}

//Action Buttons
if (KACWrapper.APIReady)
if (KACWrapper.APIReady && !settings.OverrideKAC)
{
if (GUI.Button(new Rect(10, WindowRect.height - 30, 132, 20), new GUIContent(" Add KAC Alarm", Resources.btnKAC)))
{
String tmpID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.TransferModelled,
String.Format("{0} -> {1}", mbTWP.windowMain.TransferSelected.Origin.bodyName, mbTWP.windowMain.TransferSelected.Destination.bodyName),
(mbTWP.windowMain.TransferSelected.DepartureTime - settings.KACMargin * 60 * 60));
(mbTWP.windowMain.TransferSelected.DepartureTime - settings.AlarmMargin * 60 * 60));


KACWrapper.KACAPI.KACAlarm alarmNew = KACWrapper.KAC.Alarms.First(a => a.ID == tmpID);
alarmNew.Notes = mbTWP.windowMain.GenerateTransferDetailsText();
alarmNew.AlarmMargin = settings.KACMargin * 60 * 60;
alarmNew.AlarmMargin = settings.AlarmMargin * 60 * 60;
alarmNew.AlarmAction = settings.KACAlarmAction;
alarmNew.XferOriginBodyName = mbTWP.windowMain.TransferSelected.Origin.bodyName;
alarmNew.XferTargetBodyName = mbTWP.windowMain.TransferSelected.Destination.bodyName;
Expand All @@ -471,13 +471,38 @@ private void DrawTransferDetails()
}
else
{
if (GUI.Button(new Rect(10, WindowRect.height - 30, 250, 20), new GUIContent(" Copy Transfer Details", Resources.btnCopy)))
if (GUI.Button(new Rect(10, WindowRect.height - 30, 132, 20), new GUIContent(" Add ACA Alarm", Resources.btnKAC)))
{
AlarmTypeRaw raw = new AlarmTypeRaw();

raw.title = String.Format("<color=yellow>{0}</color>@{2:0} -> <color=yellow>{1}</color>@{3:0}",
mbTWP.windowMain.TransferSelected.Origin.bodyName,
mbTWP.windowMain.TransferSelected.Destination.bodyName,
TransferSpecs.InitialOrbitAltitude / 1000,
TransferSpecs.FinalOrbitAltitude / 1000);

raw.ut = mbTWP.windowMain.TransferSelected.DepartureTime - settings.AlarmMargin * 60 * 60;
raw.description = $"Alarm Margin: {settings.AlarmMargin} hours<br>";
raw.description += mbTWP.windowMain.GenerateTransferDetailsText().Replace("\n", "<br>");
// alarmNew.AlarmMargin = settings.KACMargin * 60 * 60;
raw.actions.warp = AlarmActions.WarpEnum.KillWarp;

//raw.sourceBody = mbTWP.windowMain.TransferSelected.Origin.bodyName;
//raw.destBody = mbTWP.windowMain.TransferSelected.Destination.bodyName;

if (raw.CanSetAlarm(KSP.UI.AlarmUIDisplayMode.Add))
{
AlarmClockScenario.AddAlarm(raw);
}
}


if (GUI.Button(new Rect(132 + 15, WindowRect.height - 30, 120, 20), new GUIContent(" Copy Details", Resources.btnCopy)))
{
CopyAllDetailsToClipboard();
}
}



GUILayout.EndVertical();

GUILayout.BeginVertical();
Expand Down
42 changes: 29 additions & 13 deletions TransferWindowPlanner/TWPWindowSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,33 @@ private void DrawWindow_General()

private void DrawWindow_Alarm()
{
GUILayout.Label("Kerbal Alarm Clock Options", Styles.styleTextHeading);
GUILayout.BeginVertical(Styles.styleSettingsArea);

GUILayout.Space(10);

GUILayout.BeginHorizontal();
GUILayout.Label("Margin", Styles.styleText, GUILayout.Width(85));
if (DrawTextBox(ref settings.AlarmMargin))
settings.Save();
GUILayout.Label("(hours)", Styles.styleTextYellow, GUILayout.Width(50));
GUILayout.EndHorizontal();

GUILayout.Space(10);
GUILayout.Label("Alarm Clock App (ACA)", Styles.styleTextHeading);

if (!TWP_KACWrapper.KACWrapper.AssemblyExists || !TWP_KACWrapper.KACWrapper.InstanceExists)
{
GUILayout.Label("Stock Alarm Clock App is used.", Styles.styleTextCenterGreen);
}
else
{
if (DrawToggle(ref settings.OverrideKAC, "use Stock ACA instead of KAC", Styles.styleToggle))
{
settings.Save();
}
}
GUILayout.Space(10);
GUILayout.Label("Kerbal Alarm Clock (KAC)", Styles.styleTextHeading);

if (!TWP_KACWrapper.KACWrapper.AssemblyExists)
{
Expand All @@ -273,28 +299,18 @@ private void DrawWindow_Alarm()
GUILayout.Label("You can access these in scenes where KAC is visible", Styles.styleTextGreen);
GUILayout.Space(10);
GUILayout.Label("Go on... Move along... Nothing to see...", Styles.styleTextGreen);

}
else
{
//Alarm Area
GUILayout.BeginVertical(Styles.styleSettingsArea);
//if (KACWrapper.KAC.DrawAlarmActionChoice(ref KACAlarmAction, "On Alarm:", 108, 61))
if (KACWrapper.KAC.DrawAlarmActionChoice(ref settings.KACAlarmAction, "Action:", 90 , 38))
{
settings.Save();
}

GUILayout.BeginHorizontal();
GUILayout.Label("Margin", Styles.styleText,GUILayout.Width(85));
if (DrawTextBox(ref settings.KACMargin))
settings.Save();
GUILayout.Label("(hours)", Styles.styleTextYellow, GUILayout.Width(50));

GUILayout.EndHorizontal();

GUILayout.EndVertical();
}

GUILayout.EndVertical();
}

private void DrawWindow_Calendar()
Expand Down