示例#1
0
 /// <summary>
 /// Triggered when the Mod Options button is clicked.
 /// </summary>
 public void OnModOptions(GameObject _)
 {
     if (path != null)
     {
         // Close current dialog if open
         CloseDialog();
         // Ensure that it is on top of other screens (which may be +100 modal)
         var pDialog = new PDialog("ModOptions")
         {
             Title = POptions.DIALOG_TITLE.text.F(modSpec.title), Size = POptions.
                                                                         SETTINGS_DIALOG_SIZE, SortKey = 150.0f, DialogBackColor = PUITuning.Colors.
                                                                                                                                   OptionsBackground, DialogClosed = OnOptionsSelected
         }.AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK, POptions.TOOLTIP_OK);
         pDialog.AddButton("manual", POptions.BUTTON_MANUAL, POptions.TOOLTIP_MANUAL).
         AddButton(PDialog.DIALOG_KEY_CLOSE, STRINGS.UI.CONFIRMDIALOG.CANCEL,
                   POptions.TOOLTIP_CANCEL);
         PPanel body = pDialog.Body, current;
         var    margin = body.Margin;
         // For each option, add its UI component to panel
         body.Spacing = 10;
         body.Margin  = new RectOffset(0, 0, 0, 0);
         // Display all categories
         foreach (var catEntries in optionCategories)
         {
             string category = catEntries.Key;
             current = new PPanel("Entries_" + category)
             {
                 Alignment = TextAnchor.UpperCenter, Spacing = 5,
                 BackColor = PUITuning.Colors.DialogDarkBackground,
                 FlexSize  = new Vector2(1.0f, 0.0f), Margin = margin
             };
             AddCategoryHeader(current, catEntries.Key);
             foreach (var entry in catEntries.Value)
             {
                 current.AddChild(entry.GetUIEntry());
             }
             body.AddChild(current);
         }
         options = POptions.ReadSettings(path, optionsType);
         if (options == null)
         {
             CreateOptions();
         }
         // Manually build the dialog so the options can be updated after realization
         var obj = pDialog.Build();
         UpdateOptions();
         dialog = obj.GetComponent <KScreen>();
         dialog.Activate();
     }
 }
示例#2
0
        private void PressItBaby()
        {
            address       = Z.address;
            port          = Z.port;
            ping_interval = Z.ping_interval;

            var dialog = new PDialog("ZTransportOptions")
            {
                Title           = "ZTransport Options",
                Size            = new Vector2(320f, 200f),
                DialogBackColor = PUITuning.Colors.OptionsBackground,
                DialogClosed    = OnDialogClosed,
                MaxSize         = new Vector2(320f, 400f),
            };

            dialog
            .AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK,
                       STRINGS.ZTRANSPORT.UI.OK_TOOLTIP,
                       PUITuning.Colors.ButtonPinkStyle)
            .AddButton(PDialog.DIALOG_KEY_CLOSE,
                       STRINGS.UI.CONFIRMDIALOG.CANCEL,
                       PUIStrings.TOOLTIP_CANCEL,
                       PUITuning.Colors.ButtonBlueStyle);
            var body  = dialog.Body;
            var panel = new PPanel("ConnectionSettings")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.UpperLeft,
                FlexSize  = Vector2.right,
            };

            panel.AddChild(new PLabel("ServerAddressLabel")
            {
                TextAlignment = TextAnchor.UpperLeft,
                Text          = STRINGS.ZTRANSPORT.UI.SERVER_ADDRESS,
                FlexSize      = Vector2.right,
                Margin        = new RectOffset(0, 10, 0, 10),
            });
            panel.AddChild(new PTextField("ServerAddressField")
            {
                Text          = Z.address,
                TextStyle     = PUITuning.Fonts.TextDarkStyle,
                FlexSize      = Vector2.right,
                ToolTip       = STRINGS.ZTRANSPORT.UI.ADDRESS_TOOLTIP,
                OnTextChanged = ServerAddressChanged,
            });
            panel.AddChild(new PLabel("ServerPortLabel")
            {
                TextAlignment = TextAnchor.UpperLeft,
                Text          = STRINGS.ZTRANSPORT.UI.SERVER_PORT,
                FlexSize      = Vector2.right,
                Margin        = new RectOffset(0, 10, 0, 10),
            });
            panel.AddChild(new PTextField("ServerPortField")
            {
                Text          = Z.port.ToString(),
                TextStyle     = PUITuning.Fonts.TextDarkStyle,
                FlexSize      = Vector2.right,
                ToolTip       = STRINGS.ZTRANSPORT.UI.PORT_TOOLTIP,
                OnTextChanged = ServerPortChanged,
                OnValidate    = ServerPortValidate,
            });
            panel.AddChild(new PLabel("PingIntervalLabel")
            {
                TextAlignment = TextAnchor.UpperLeft,
                Text          = STRINGS.ZTRANSPORT.UI.PING_INTERVAL,
                FlexSize      = Vector2.right,
                Margin        = new RectOffset(0, 10, 0, 10),
            });
            panel.AddChild(new PTextField("PingIntervalField")
            {
                Text          = Z.ping_interval.ToString(),
                TextStyle     = PUITuning.Fonts.TextDarkStyle,
                FlexSize      = Vector2.right,
                ToolTip       = STRINGS.ZTRANSPORT.UI.PING_TOOLTIP,
                OnTextChanged = PingIntervalChanged,
                OnValidate    = PingIntervalValidate,
            });
            body.AddChild(panel);
            var built  = dialog.Build();
            var screen = built.GetComponent <KScreen>();

            screen.Activate();
        }