Exemple #1
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button("\nRestore factory default settings\n"))
            {
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_global.cfg").Delete();
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
                core.ReloadAllComputerModules();
            }

            if (GuiUtils.skin == null || GuiUtils.skin.name != "KSP window 2")
            {
                GUILayout.Label("Current skin: MechJeb 2");
                if (GUILayout.Button("Use MechJeb 1 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
                    useOldSkin = true;
                }
            }
            else
            {
                GUILayout.Label("Current skin: MechJeb 1");
                if (GUILayout.Button("Use MechJeb 2 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
                    useOldSkin = false;
                }
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Exemple #2
0
        public override void OnLoad(ConfigNode local, ConfigNode type, ConfigNode global)
        {
            base.OnLoad(local, type, global);

            if (useOldSkin)
            {
                GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
            }
        }
Exemple #3
0
        private void OnGUI()
        {
            if (!showGui || this != vessel.GetMasterMechJeb() || (!FlightGlobals.ready && HighLogic.LoadedSceneIsFlight) || !ready)
            {
                return;
            }

            Profiler.BeginSample("MechJebCore.OnGUI");

            if (HighLogic.LoadedSceneIsEditor || (FlightGlobals.ready && (vessel == FlightGlobals.ActiveVessel) && (part.State != PartStates.DEAD)))
            {
                Matrix4x4 previousGuiMatrix = GUI.matrix;
                GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(GuiUtils.scale, GuiUtils.scale, 1));

                GuiUtils.ComboBox.DrawGUI();

                GuiUtils.LoadSkin((GuiUtils.SkinType)settings.skinId);

                GUI.skin = GuiUtils.skin;

                foreach (DisplayModule module in GetComputerModules <DisplayModule>())
                {
                    Profiler.BeginSample(module.profilerName);
                    try
                    {
                        if (module.enabled)
                        {
                            module.DrawGUI(HighLogic.LoadedSceneIsEditor);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in DrawGUI: " + e);
                    }
                    Profiler.EndSample();
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    PreventEditorClickthrough();
                }
                if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneHasPlanetarium)
                {
                    PreventInFlightClickthrough();
                }
                GUI.matrix = previousGuiMatrix;

                for (int i = 0; i < postDrawQueue.Count; i++)
                {
                    postDrawQueue[i]();
                }
            }
            Profiler.EndSample();
        }
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button("\nRestore factory default settings\n"))
            {
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_global.cfg").Delete();
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
                core.ReloadAllComputerModules();
            }

            GUILayout.Label("Current skin: " + (GuiUtils.SkinType)skinId);
            if (GuiUtils.skin == null || skinId != 1)
            {
                if (GUILayout.Button("Use MechJeb 1 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
                    skinId = 1;
                }
            }
            if (GuiUtils.skin == null || skinId != 0)
            {
                if (GUILayout.Button("Use MechJeb 2 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
                    skinId = 0;
                }
            }
            if (GuiUtils.skin == null || skinId != 2)
            {
                if (GUILayout.Button("Use MJ2 Compact GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Compact);
                    skinId = 2;
                }
            }

            MechJebModuleCustomWindowEditor ed = core.GetComputerModule <MechJebModuleCustomWindowEditor>();

            ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();

            if (ToolbarManager.ToolbarAvailable)
            {
                ed.registry.Find(i => i.id == "Toggle:Menu.hideButton").DrawItem();
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Exemple #5
0
        private void OnGUI()
        {
            if (!showGui || this != vessel.GetMasterMechJeb())
            {
                return;
            }

            if (HighLogic.LoadedSceneIsEditor || (FlightGlobals.ready && (vessel == FlightGlobals.ActiveVessel) && (part.State != PartStates.DEAD)))
            {
                Matrix4x4 previousGuiMatrix = GUI.matrix;
                GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(GuiUtils.scale, GuiUtils.scale, 1));

                GuiUtils.ComboBox.DrawGUI();

                GuiUtils.LoadSkin((GuiUtils.SkinType)GetComputerModule <MechJebModuleSettings>().skinId);

                GuiUtils.CheckSkin();

                GUI.skin = GuiUtils.skin;

                foreach (DisplayModule module in GetComputerModules <DisplayModule>())
                {
                    try
                    {
                        if (module.enabled)
                        {
                            module.DrawGUI(HighLogic.LoadedSceneIsEditor);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in DrawGUI: " + e);
                    }
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    PreventEditorClickthrough();
                }
                if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneHasPlanetarium)
                {
                    PreventInFlightClickthrough();
                }
                GUI.matrix = previousGuiMatrix;
            }
        }
Exemple #6
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button("\nRestore factory default settings\n"))
            {
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_global.cfg").Delete();
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
                core.ReloadAllComputerModules();
            }

            GUILayout.Label("Current skin: " + (GuiUtils.SkinType)skinId);
            if (GuiUtils.skin == null || skinId != 1)
            {
                if (GUILayout.Button("Use MechJeb 1 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
                    skinId = 1;
                }
            }
            if (GuiUtils.skin == null || skinId != 0)
            {
                if (GUILayout.Button("Use MechJeb 2 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
                    skinId = 0;
                }
            }
            if (GuiUtils.skin == null || skinId != 2)
            {
                if (GUILayout.Button("Use MJ2 Compact GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Compact);
                    skinId = 2;
                }
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Exemple #7
0
        private void OnGUI()
        {
            if (!showGui)
            {
                return;
            }

            GuiUtils.LoadSkin((GuiUtils.SkinType)GetComputerModule <MechJebModuleSettings>().skinId);

            GuiUtils.CheckSkin();

            GUI.skin = GuiUtils.skin;

            if (this == vessel.GetMasterMechJeb() &&
                ((HighLogic.LoadedSceneIsEditor) || ((FlightGlobals.ready) && (vessel == FlightGlobals.ActiveVessel) && (part.State != PartStates.DEAD))))
            {
                foreach (DisplayModule module in GetComputerModules <DisplayModule>())
                {
                    try
                    {
                        if (module.enabled)
                        {
                            module.DrawGUI(HighLogic.LoadedSceneIsEditor);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("MechJeb module " + module.GetType().Name + " threw an exception in DrawGUI: " + e);
                    }
                }

                if (HighLogic.LoadedSceneIsEditor)
                {
                    PreventEditorClickthrough();
                }
            }
        }
Exemple #8
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button1")))//"\nRestore factory default settings\n"
            {
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_global.cfg").Delete();
                if (vessel != null && vessel.vesselName != null)
                {
                    KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
                }
                core.ReloadAllComputerModules();
                GuiUtils.SetGUIScale(1);
            }

            GUILayout.Label(Localizer.Format("#MechJeb_Settings_label1", (GuiUtils.SkinType)skinId));//"Current skin: <<1>>"
            if (GuiUtils.skin == null || skinId != 1)
            {
                if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button2")))//"Use MechJeb 1 GUI skin"
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
                    skinId = 1;
                }
            }
            if (GuiUtils.skin == null || skinId != 0)
            {
                if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button3")))//"Use MechJeb 2 GUI skin"
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
                    skinId = 0;
                }
            }
            if (GuiUtils.skin == null || skinId != 2)
            {
                if (GUILayout.Button(Localizer.Format("#MechJeb_Settings_button4")))//"Use MJ2 Compact GUI skin"
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Compact);
                    skinId = 2;
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#MechJeb_Settings_label2"), GUILayout.ExpandWidth(true));//"UI Scale:"
            UIScale.text = GUILayout.TextField(UIScale.text, GUILayout.Width(60));
            GUILayout.EndHorizontal();

            GuiUtils.SetGUIScale(UIScale.val);

            dontUseDropDownMenu          = GUILayout.Toggle(dontUseDropDownMenu, Localizer.Format("#MechJeb_Settings_checkbox1"));//"Replace drop down menu with arrow selector"
            GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu;

            MechJebModuleCustomWindowEditor ed = core.GetComputerModule <MechJebModuleCustomWindowEditor>();

            ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();

            ed.registry.Find(i => i.id == "Toggle:Settings.useTitlebarDragging").DrawItem();

            ed.registry.Find(i => i.id == "Toggle:Menu.useAppLauncher").DrawItem();
            if (ToolbarManager.ToolbarAvailable || core.GetComputerModule <MechJebModuleMenu>().useAppLauncher)
            {
                ed.registry.Find(i => i.id == "Toggle:Menu.hideButton").DrawItem();
            }

            ed.registry.Find(i => i.id == "General:Menu.MenuPosition").DrawItem();

            ed.registry.Find(i => i.id == "Toggle:Settings.rssMode").DrawItem();

            core.warp.activateSASOnWarp = GUILayout.Toggle(core.warp.activateSASOnWarp, Localizer.Format("#MechJeb_Settings_checkbox2"));//"Activate SAS on Warp"

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Exemple #9
0
 void OnGUI()
 {
     GuiUtils.LoadSkin();
     GameObject.Destroy(gameObject);
 }
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button("\nRestore factory default settings\n"))
            {
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_global.cfg").Delete();
                KSP.IO.FileInfo.CreateForType <MechJebCore>("mechjeb_settings_type_" + vessel.vesselName + ".cfg").Delete();
                core.ReloadAllComputerModules();
                GuiUtils.SetGUIScale(1);
            }

            GUILayout.Label("Current skin: " + (GuiUtils.SkinType)skinId);
            if (GuiUtils.skin == null || skinId != 1)
            {
                if (GUILayout.Button("Use MechJeb 1 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.MechJeb1);
                    skinId = 1;
                }
            }
            if (GuiUtils.skin == null || skinId != 0)
            {
                if (GUILayout.Button("Use MechJeb 2 GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Default);
                    skinId = 0;
                }
            }
            if (GuiUtils.skin == null || skinId != 2)
            {
                if (GUILayout.Button("Use MJ2 Compact GUI skin"))
                {
                    GuiUtils.LoadSkin(GuiUtils.SkinType.Compact);
                    skinId = 2;
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("UI Scale:", GUILayout.ExpandWidth(true));
            UIScale.text = GUILayout.TextField(UIScale.text, GUILayout.Width(60));
            GUILayout.EndHorizontal();

            GuiUtils.SetGUIScale(UIScale.val);

            dontUseDropDownMenu          = GUILayout.Toggle(dontUseDropDownMenu, "Replace drop down menu with arrow selector");
            GuiUtils.dontUseDropDownMenu = dontUseDropDownMenu;

            MechJebModuleCustomWindowEditor ed = core.GetComputerModule <MechJebModuleCustomWindowEditor>();

            ed.registry.Find(i => i.id == "Toggle:Settings.hideBrakeOnEject").DrawItem();

            ed.registry.Find(i => i.id == "Toggle:Settings.useTitlebarDragging").DrawItem();

            ed.registry.Find(i => i.id == "Toggle:Menu.useAppLauncher").DrawItem();
            if (ToolbarManager.ToolbarAvailable || core.GetComputerModule <MechJebModuleMenu>().useAppLauncher)
            {
                ed.registry.Find(i => i.id == "Toggle:Menu.hideButton").DrawItem();
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }