internal override void Awake() { LogFormatted("Awakening the TransferWindowPlanner (TWP)"); LogFormatted("Loading Settings"); settings = new Settings("settings.cfg"); if (!settings.Load()) { LogFormatted("Settings Load Failed"); } InitWindows(); if (settings.SelectedCalendar == CalendarTypeEnum.Earth) { KSPDateStructure.SetEarthCalendar(settings.EarthEpoch); windowSettings.ddlSettingsCalendar.SelectedIndex = (Int32)settings.SelectedCalendar; } //plug us in to the draw queue and start the worker //Rem out for unity5 //RenderingManager.AddToPostDrawQueue(1, DrawGUI); //Get whether the toolbar is there settings.BlizzyToolbarIsAvailable = ToolbarManager.ToolbarAvailable; //setup the Toolbar button if necessary if (settings.ButtonStyleToDisplay == Settings.ButtonStyleEnum.Toolbar) { btnToolbar = InitToolbarButton(); } //Hook the App Launcher GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady); GameEvents.onGUIApplicationLauncherDestroyed.Add(DestroyAppLauncherButton); GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequestedForAppLauncher); // Need this one to handle the hideUI cancelling via pause menu GameEvents.onGameUnpause.Add(OnUnpause); //Hook the Angle renderers if (lstScenesForAngles.Contains(HighLogic.LoadedScene)) { PhaseAngle = MapView.MapCamera.gameObject.AddComponent <AngleRenderPhase>(); EjectAngle = MapView.MapCamera.gameObject.AddComponent <AngleRenderEject>(); } //do the daily version check if required if (settings.DailyVersionCheck) { settings.VersionCheck(false); } }
void ddlSettingsCalendar_OnSelectionChanged(KerbalAlarmClock.DropDownList sender, int OldIndex, int NewIndex) { settings.SelectedCalendar = (CalendarTypeEnum)NewIndex; settings.Save(); switch (settings.SelectedCalendar) { case CalendarTypeEnum.KSPStock: KSPDateStructure.SetKSPStockCalendar(); break; case CalendarTypeEnum.Earth: KSPDateStructure.SetEarthCalendar(settings.EarthEpoch); break; case CalendarTypeEnum.Custom: KSPDateStructure.SetCustomCalendar(); break; default: KSPDateStructure.SetKSPStockCalendar(); break; } }
public void TestFormats() { KSPDateTime dt = new KSPDateTime(1, 100); KSPDateStructure.Months = new List <KSPMonth>(); Assert.AreEqual("100/00/0001", dt.ToString("dd/MM/yyyy")); Assert.AreEqual("Year 1, Day 100 - 0h, 0m", dt.ToString()); KSPDateStructure.SetEarthCalendar(); Assert.AreEqual("25/01/1951", dt.ToString("dd/MM/yyyy")); dt = new KSPDateTime(1951, 100); Assert.AreEqual("10/04/1951", dt.ToString("dd/MM/yyyy")); Assert.AreEqual("Hello there 1951", String.Format("Hello there {0:yyyy}", dt)); }
public void TestEarthDateTime() { KSPDateStructure.SetEarthCalendar(); Double DateUT = 301.123; KSPDateTime dt = new KSPDateTime(DateUT); //Console.Write(dt.Day); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(123, dt.Millisecond); Assert.AreEqual(0, dt.Hour); Assert.AreEqual(1, dt.DayOfYear); Assert.AreEqual(1951, dt.Year); dt = dt.AddMilliSeconds(456); Assert.AreEqual(5, dt.Minute); Assert.AreEqual(1, dt.Second); Assert.AreEqual(579, dt.Millisecond); //dt.Second = 68; //Assert.AreEqual(6, dt.Minute); //Assert.AreEqual(8, dt.Second); //Assert.AreEqual(456, dt.Millisecond); //dt.Year = 1969; //Assert.AreEqual(1969, dt.Year, "Hello"); //dt.DayOfYear = 50; //Assert.AreEqual(50, dt.DayOfYear); //KSPDateTimeStructure.SetCalendarTypeEarth(1951,1,1); //dt = new KSPDateTime(1951, 50, 10, 20, 30); //Assert.AreEqual(2, dt.Month); //Assert.AreEqual(19, dt.Day); }
private void WindowLayout_SettingsCalendar() { //Update Check Area GUILayout.Label("General Settings", KACResources.styleAddSectionHeading); GUILayout.BeginVertical(KACResources.styleAddFieldAreas); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(60)); GUILayout.Space(2); //to even up the text GUILayout.Label("Calendar:", KACResources.styleAddHeading); GUILayout.EndVertical(); GUILayout.BeginVertical(); ddlSettingsCalendar.DrawButton(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (DrawToggle(ref settings.ShowCalendarToggle, "Show Calendar Toggle in Main Window", KACResources.styleCheckbox)) { settings.Save(); } GUILayout.EndVertical(); if (settings.SelectedCalendar == CalendarTypeEnum.Earth) { GUILayout.Label("Earth Settings", KACResources.styleAddSectionHeading); GUILayout.BeginVertical(KACResources.styleAddFieldAreas); GUILayout.BeginHorizontal(); GUILayout.Label("Earth Epoch:"); String strYear, strMonth, strDay; strYear = KSPDateStructure.CustomEpochEarth.Year.ToString(); strMonth = KSPDateStructure.CustomEpochEarth.Month.ToString(); strDay = KSPDateStructure.CustomEpochEarth.Day.ToString(); if (DrawYearMonthDay(ref strYear, ref strMonth, ref strDay)) { try { KSPDateStructure.SetEarthCalendar(strYear.ToInt32(), strMonth.ToInt32(), strDay.ToInt32()); settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("yyyy-MM-dd"); settings.Save(); } catch (Exception) { LogFormatted("Unable to set the Epoch date using the values provided-{0}-{1}-{2}", strYear, strMonth, strDay); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset Earth Epoch")) { KSPDateStructure.SetEarthCalendar(); settings.EarthEpoch = KSPDateStructure.CustomEpochEarth.ToString("1951-01-01"); settings.Save(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } //if RSS not installed and RSS chosen... ///section for custom stuff }
internal override void DrawWindow(int id) { //Calendar toggle if (settings.ShowCalendarToggle) { if (GUI.Button(new Rect(WindowRect.width - 122, 2, 30, 20), new GUIContent(Resources.btnCalendar, "Toggle Calendar"), "ButtonSettings")) { if (settings.SelectedCalendar == CalendarTypeEnum.Earth) { settings.SelectedCalendar = CalendarTypeEnum.KSPStock; KSPDateStructure.SetKSPStockCalendar(); } else { settings.SelectedCalendar = CalendarTypeEnum.Earth; KSPDateStructure.SetEarthCalendar(settings.EarthEpoch); } settings.Save(); } } //Settings toggle GUIContent contSettings = new GUIContent(Resources.GetSettingsButtonIcon(TransferWindowPlanner.settings.VersionAttentionFlag), "Settings..."); if (TransferWindowPlanner.settings.VersionAvailable) { contSettings.tooltip = "Updated Version Available - Settings..."; } mbTWP.windowSettings.Visible = GUI.Toggle(new Rect(WindowRect.width - 92, 2, 30, 20), mbTWP.windowSettings.Visible, contSettings, "ButtonSettings"); //Set a default for the MinMax button GUIContent contMaxMin = new GUIContent(Resources.btnChevronUp, "Minimize"); if (ShowMinimized) { contMaxMin.image = Resources.btnChevronDown; contMaxMin.tooltip = "Expand"; } if (GUI.Button(new Rect(WindowRect.width - 62, 2, 30, 20), contMaxMin, "ButtonSettings")) { ShowMinimized = !ShowMinimized; //if its changed then affect the window size if (ShowMinimized) { WindowRect.x = WindowRect.x + WindowRect.width - 320; WindowRect.width = 350; WindowRect.height = 0; } else { WindowRect.x = WindowRect.x + 320 - 750; WindowRect.width = 750; WindowRect.height = 400; } } //Close button if (GUI.Button(new Rect(WindowRect.width - 32, 2, 30, 20), "X", "ButtonSettings")) { //Visible = false; if (TransferWindowPlanner.settings.ButtonStyleToDisplay == Settings.ButtonStyleEnum.Launcher) { mbTWP.btnAppLauncher.SetFalse(); } else { Visible = false; } } //Set the settings window pos if (mbTWP.windowSettings.Visible) { mbTWP.windowSettings.WindowRect.y = WindowRect.y; if (ShowMinimized) { mbTWP.windowSettings.WindowRect.x = WindowRect.x + WindowRect.width; } else { mbTWP.windowSettings.WindowRect.x = WindowRect.x + WindowRect.width - mbTWP.windowSettings.WindowRect.width; } } mbTWP.windowSettingsBlockout.Visible = mbTWP.windowSettingsBlockoutExtra.Visible = mbTWP.windowSettings.Visible && !ShowMinimized; //Now draw the window if (ShowMinimized) { if (!Done) { GUILayout.Label("No Selected Transfer to be able to display info", Styles.styleTextInstruction); GUILayout.Space(10); GUILayout.Label("Go back to restored mode and plot a transfer first", Styles.styleTextInstruction); //GUILayout.Label("You need to have run a plot and selected a transfer to get this"); } else { DrawTransferDetailsMinimal(); } } else { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(300)); DrawTransferEntry(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(10)); GUILayout.Box(Resources.texSeparatorV, Styles.styleSeparatorV, GUILayout.Height(335)); GUILayout.EndVertical(); GUILayout.BeginVertical(); DrawTransferPlot(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (DepartureSelected >= 0 && TransferSelected != null) { DrawTransferDetails(); } } //close the settings window if we click elsewhere if (!ShowMinimized && Event.current.type == EventType.mouseDown) { if (!mbTWP.windowSettings.WindowRect.Contains(Event.current.mousePosition)) { mbTWP.windowSettings.Visible = false; } } }