Example #1
0
        internal void CreateDialog()
        {
            var dialog = new PDialog("ModifyItem")
            {
                Title        = string.Format(UI.MODIFYDIALOG.TITLE, mod.label.title.ToUpper()),
                DialogClosed = OnDialogClosed, SortKey = 200.0f, Parent = parent
            }.AddButton("ok", UI.MODIFYDIALOG.OK, null, PUITuning.Colors.ButtonPinkStyle).
            AddButton("close", UI.MODIFYDIALOG.CANCEL, null, PUITuning.Colors.
                      ButtonBlueStyle);
            var body = new PGridPanel("ModifyBody")
            {
                Margin = new RectOffset(10, 10, 10, 10)
            }.AddColumn(new GridColumnSpec()).AddColumn(new GridColumnSpec(0.0f, 1.0f));

            body.AddRow(UI.MODIFYDIALOG.CAPTION, new PTextField("Title")
            {
                Text = editor.Title, MaxLength = 127, MinWidth = 512, BackColor =
                    PUITuning.Colors.DialogDarkBackground, TextStyle = PUITuning.Fonts.
                                                                       TextLightStyle, TextAlignment = TMPro.TextAlignmentOptions.Left
            }.AddOnRealize((obj) => titleField = obj));
            body.AddRow(UI.MODIFYDIALOG.DESC, new PTextArea("Description")
            {
                LineCount = 8, Text = editor.Description, MaxLength = 7999,
                MinWidth  = 512, BackColor = PUITuning.Colors.DialogDarkBackground,
                TextStyle = PUITuning.Fonts.TextLightStyle
            }.AddOnRealize((obj) => descriptionField = obj));
            body.AddRow(UI.MODIFYDIALOG.IMAGE_PATH, CheckGroup(new PCheckBox("UpdateImage")
            {
                CheckSize = new Vector2(16.0f, 16.0f), OnChecked = ToggleCheckbox, BackColor =
                    PUITuning.Colors.DialogDarkBackground, CheckColor = PUITuning.Colors.
                                                                        ComponentDarkStyle
            }.AddOnRealize((obj) => doUpdateImg = obj), new PTextField("PreviewPath")
            {
                Text = editor.PreviewPath, MaxLength = 512, MinWidth = 512, BackColor =
                    PUITuning.Colors.DialogDarkBackground, TextStyle = PUITuning.Fonts.
                                                                       TextLightStyle, TextAlignment = TMPro.TextAlignmentOptions.Left
            }.AddOnRealize((obj) => imagePathField = obj)));
            body.AddRow(UI.MODIFYDIALOG.DATA_PATH, CheckGroup(new PCheckBox("UpdateData")
            {
                CheckSize = new Vector2(16.0f, 16.0f), OnChecked = ToggleCheckbox, BackColor =
                    PUITuning.Colors.DialogDarkBackground, CheckColor = PUITuning.Colors.
                                                                        ComponentDarkStyle
            }.AddOnRealize((obj) => doUpdateData = obj), new PTextField("DataPath")
            {
                Text = editor.DataPath, MaxLength = 512, MinWidth = 512, BackColor =
                    PUITuning.Colors.DialogDarkBackground, TextStyle = PUITuning.Fonts.
                                                                       TextLightStyle, TextAlignment = TMPro.TextAlignmentOptions.Left
            }.AddOnRealize((obj) => dataPathField = obj)));
            body.AddRow(UI.MODIFYDIALOG.PATCHNOTES, new PTextField("PatchNotes")
            {
                Text      = editor.PatchInfo, MaxLength = 512, MinWidth = 512,
                BackColor = PUITuning.Colors.DialogDarkBackground, TextStyle = PUITuning.Fonts.
                                                                               TextLightStyle, TextAlignment = TMPro.TextAlignmentOptions.Left
            }.AddOnRealize((obj) => patchNotesField = obj));
            dialog.Body.AddChild(body);
            dialog.Show();
        }
Example #2
0
        /// <summary>
        /// Fills in the actual mod option fields.
        /// </summary>
        /// <param name="dialog">The dialog to populate.</param>
        private void FillModOptions(PDialog dialog)
        {
            var body   = dialog.Body;
            var margin = new RectOffset(CATEGORY_MARGIN, CATEGORY_MARGIN, CATEGORY_MARGIN,
                                        CATEGORY_MARGIN);

            // For each option, add its UI component to panel
            body.Margin = new RectOffset();
            var scrollBody = new PPanel("ScrollContent")
            {
                Spacing = OUTER_MARGIN, Direction = PanelDirection.Vertical, Alignment =
                    TextAnchor.UpperCenter, FlexSize = Vector2.right
            };
            var allOptions = (options == null) ? optionCategories : OptionsEntry.
                             AddCustomOptions(options, optionCategories);

            // Display all categories
            foreach (var catEntries in allOptions)
            {
                string category = catEntries.Key;
                if (catEntries.Value.Count > 0)
                {
                    string name = string.IsNullOrEmpty(category) ? "Default" : category;
                    int    i    = 0;
                    // Not optimal for layout performance, but the panel is needed to have a
                    // different background color for each category "box"
                    var container = new PGridPanel("Category_" + name)
                    {
                        Margin   = margin, BackColor = PUITuning.Colors.DialogDarkBackground,
                        FlexSize = Vector2.right
                    };
                    // Needs to be a separate panel so that it can be collapsed
                    var contents = new PGridPanel("Entries")
                    {
                        FlexSize = Vector2.right
                    };
                    AddCategoryHeader(container, catEntries.Key, contents);
                    foreach (var entry in catEntries.Value)
                    {
                        contents.AddRow(new GridRowSpec());
                        entry.CreateUIEntry(contents, ref i);
                        i++;
                    }
                    scrollBody.AddChild(container);
                }
            }
            // Manual config button
            scrollBody.AddChild(new PButton("ManualConfig")
            {
                Text    = PUIStrings.BUTTON_MANUAL, ToolTip = PUIStrings.TOOLTIP_MANUAL,
                OnClick = OnManualConfig, TextAlignment = TextAnchor.MiddleCenter, Margin =
                    PDialog.BUTTON_MARGIN
            }.SetKleiBlueStyle());
            body.AddChild(new PScrollPane()
            {
                ScrollHorizontal     = false, ScrollVertical = allOptions.Count > 0,
                Child                = scrollBody, FlexSize = Vector2.right, TrackSize = 8,
                AlwaysShowHorizontal = false, AlwaysShowVertical = false
            });
        }
Example #3
0
        internal static void AddRow(this PGridPanel panel, string rowTitle, IUIComponent text)
        {
            int row = panel.Rows;

            panel.AddRow(new GridRowSpec()).AddChild(new PLabel()
            {
                Text = rowTitle, Margin = ROW_MARGIN
            }, new GridComponentSpec(row, 0)
            {
                Alignment = TextAnchor.MiddleRight, Margin = new RectOffset(0, 5, 0, 0)
            }).AddChild(text, new GridComponentSpec(row, 1)
            {
                Alignment = TextAnchor.UpperLeft, Margin = ROW_MARGIN
            });
        }
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            int  i     = row;
            bool first = true;

            parent.AddOnRealize(WhenRealized);
            // Render each sub-entry - order is always Add Spec, Create Entry, Increment Row
            foreach (var pair in subOptions)
            {
                if (!first)
                {
                    i++;
                    parent.AddRow(new GridRowSpec());
                }
                pair.Value.CreateUIEntry(parent, ref i);
                first = false;
            }
            row = i;
        }
Example #5
0
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            double minLimit, maxLimit;

            base.CreateUIEntry(parent, ref row);
            if (limits != null && (minLimit = limits.Minimum) > float.MinValue && (maxLimit =
                                                                                       limits.Maximum) < float.MaxValue && maxLimit > minLimit)
            {
                // NaN will be false on either comparison
                var slider = GetSlider();
                // Min and max labels
                var minLabel = new PLabel("MinValue")
                {
                    TextStyle = PUITuning.Fonts.TextLightStyle, Text = minLimit.
                                                                       ToString("G4"), TextAlignment = TextAnchor.MiddleRight
                };
                var maxLabel = new PLabel("MaxValue")
                {
                    TextStyle = PUITuning.Fonts.TextLightStyle, Text = maxLimit.
                                                                       ToString("G4"), TextAlignment = TextAnchor.MiddleLeft
                };
                // Lay out left to right
                var panel = new PRelativePanel("Slider Grid")
                {
                    FlexSize = Vector2.right, DynamicSize = false
                }.AddChild(slider).AddChild(minLabel).AddChild(maxLabel).AnchorYAxis(slider).
                AnchorYAxis(minLabel, 0.5f).AnchorYAxis(maxLabel, 0.5f).SetLeftEdge(
                    minLabel, fraction: 0.0f).SetRightEdge(maxLabel, fraction: 1.0f).
                SetLeftEdge(slider, toRight: minLabel).SetRightEdge(slider, toLeft:
                                                                    maxLabel).SetMargin(slider, SLIDER_MARGIN);
                slider.OnRealize += OnRealizeSlider;
                // Add another row for the slider
                parent.AddRow(new GridRowSpec());
                parent.AddChild(panel, new GridComponentSpec(++row, 0)
                {
                    ColumnSpan = 2, Margin = ENTRY_MARGIN
                });
            }
        }