Пример #1
0
        private void DrawIPAddrField(ConfigKey key)
        {
            bool clicked = GUILayout.Button(key.Value.ToString(), panelSkin.button);

            if (clicked)
            {
                // Make a new picker if it's closed, or close it if it's already open.
                if (ipAddrPicker == null)
                {
                    ipAddrPicker = this.gameObject.AddComponent <ListPickerDialog>();
                    kOS.Screen.ListPickerDialog.ChangeAction onChange = delegate(String s)
                    {
                        bool ok = TelnetMainServer.Instance.SetBindAddrFromString(s);
                        if (ok)
                        {
                            key.Value = s;
                        }
                        return(ok);
                    };

                    kOS.Screen.ListPickerDialog.CloseAction onClose = delegate() { ipAddrPicker = null; };

                    ipAddrPicker.Summon(windowRect.x, windowRect.y + windowRect.height, 300,
                                        "Telnet address (restart telnet to take effect)\n", null,
                                        "current: " + key.Value.ToString(), TelnetMainServer.GetAllAddresses(), onChange, onClose
                                        );
                }
                else
                {
                    ipAddrPicker.Close();
                    ipAddrPicker = null;
                }
            }
        }
Пример #2
0
        public void GoAway()
        {
            if (isOpen)
            {
                Close();
            }
            clickedOn = false;

            try
            {
                if (launcherButton != null && ApplicationLauncher.Instance != null)
                {
                    ApplicationLauncher launcher = ApplicationLauncher.Instance;

                    launcher.DisableMutuallyExclusive(launcherButton);
                    launcher.RemoveOnRepositionCallback(CallbackOnShow);
                    launcher.RemoveOnHideCallback(CallbackOnHide);
                    launcher.RemoveOnShowCallback(CallbackOnShow);
                    launcher.RemoveModApplication(launcherButton);
                    launcherButton = null;
                }
            }
            catch (Exception e)
            {
                SafeHouse.Logger.SuperVerbose("[kOSToolBarWindow] Failed unregistering AppLauncher handlers," + e.Message);
            }

            // force close the font picker window if it was still open:
            if (fontPicker != null)
            {
                fontPicker.Close();
                Destroy(fontPicker);
                fontPicker = null;
            }
        }
Пример #3
0
        public void Awake()
        {
            // TODO - remove commented-out line below after varifying KSP 1.1 works without it:
            // GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequestedForAppLauncher);

            GameEvents.onGUIApplicationLauncherReady.Add(AddButton);
            GameEvents.onGUIApplicationLauncherUnreadifying.Add(RemoveButton);
            GameEvents.onHideUI.Add(OnHideUI);
            GameEvents.onShowUI.Add(OnShowUI);
            GameEvents.onGameStateSave.Add(OnGameStateSave);
            GameObject.DontDestroyOnLoad(this);

            fontPicker = null;
        }
Пример #4
0
        private void DrawFontField(ConfigKey key)
        {
            bool clicked = GUILayout.Button(key.Value.ToString(), panelSkin.button);

            if (clicked)
            {
                // Make a new picker if it's closed, or close it if it's already open.
                if (fontPicker == null)
                {
                    fontPicker = this.gameObject.AddComponent <ListPickerDialog>();
                    kOS.Screen.ListPickerDialog.ChangeAction onChange = delegate(String s)
                    {
                        // If the font is monospaced, we'll accept it, else we'll deny the attempt
                        // and not commit the change to the config fields:
                        bool ok = AssetManager.Instance.GetSystemFontByNameAndSize(s, 13, true) != null;
                        if (ok)
                        {
                            key.Value = s;
                        }
                        return(ok);
                    };

                    kOS.Screen.ListPickerDialog.CloseAction onClose = delegate() { fontPicker = null; };

                    fontPicker.Summon(windowRect.x, windowRect.y + windowRect.height, 300,
                                      key.Name, "(Only fonts detected as monospaced are shown.)",
                                      key.Value.ToString(), AssetManager.Instance.GetSystemFontNames(), onChange, onClose
                                      );
                }
                else
                {
                    fontPicker.Close();
                    Destroy(fontPicker);
                    fontPicker = null;
                }
            }
        }