コード例 #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
        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;
                }
            }
        }