Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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
            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
            OnGUIAppLauncherReady();
            //GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequestedForAppLauncher);

            //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);
        }
        private void DrawWindow_About()
        {
            //Update Check Area
            GUILayout.Label("Version Check", Styles.styleTextHeading);

            GUILayout.BeginVertical(Styles.styleSettingsArea);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Space(3);
            if (DrawToggle(ref settings.DailyVersionCheck, "Check Version Daily", Styles.styleToggle))
            {
                settings.Save();
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Check Version Now"))
            {
                settings.VersionCheck(mbTWP, true);
                //Hide the flag as we already have the window open;
                settings.VersionAttentionFlag = false;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.Width(200));
            GUILayout.Space(4);
            GUILayout.Label("Last Check Attempt:");
            GUILayout.Label("Current Version:");
            GUILayout.Label("Last Version from Web:");
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label(settings.VersionCheckDate_AttemptString, Styles.styleTextGreen);
            GUILayout.Label(settings.Version, Styles.styleTextGreen);

            if (settings.VersionCheckRunning)
            {
                Int32 intDots = Convert.ToInt32(Math.Truncate(DateTime.Now.Millisecond / 250d)) + 1;
                GUILayout.Label(String.Format("{0} Checking", new String('.', intDots)), Styles.styleTextYellowBold);
            }
            else
            {
                if (settings.VersionAvailable)
                {
                    GUILayout.Label(String.Format("{0} @ {1}", settings.VersionWeb, settings.VersionCheckDate_SuccessString), Styles.styleTextYellowBold);
                }
                else
                {
                    GUILayout.Label(String.Format("{0} @ {1}", settings.VersionWeb, settings.VersionCheckDate_SuccessString), Styles.styleTextGreen);
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (settings.VersionAvailable)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(80);
                if (GUILayout.Button("Updated Version Available - Click Here", Styles.styleTextYellowBold))
                {
                    Application.OpenURL("https://github.com/TriggerAu/TransferWindowPlanner/releases");
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();


            //About Area
            GUILayout.BeginVertical(Styles.styleSettingsArea);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            //GUILayout.Label("Written by:", Styles.styleStageTextHead);
            GUILayout.Label("Documentation and Links:", Styles.styleTextHeading);
            GUILayout.Label("GitHub Page:", Styles.styleTextHeading);
            GUILayout.Label("Forum Page:", Styles.styleTextHeading);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            //GUILayout.Label("Trigger Au",KACResources.styleContent);
            if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
            {
                Application.OpenURL("http://triggerau.github.io/TransferWindowPlanner/");
            }
            if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
            {
                Application.OpenURL("http://github.com/TriggerAu/TransferWindowPlanner/");
            }
            if (GUILayout.Button("Click Here", Styles.styleTextCenterGreen))
            {
                Application.OpenURL("http://forum.kerbalspaceprogram.com/threads/93115-Transfer-Window-Planner");
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }