Ejemplo n.º 1
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
            });
        }
Ejemplo n.º 2
0
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            if (getTitle != null)
            {
                Title = getTitle.Invoke();
            }
            else
            {
                // Only displayed in error cases, should not be localized
                Title = "<No Title>";
            }
            var label = new PLabel("Label")
            {
                Text = LookInStrings(Title), TextStyle = PUITuning.Fonts.TextLightStyle
            };

            label.OnRealize += OnRealizeLabel;
            parent.AddChild(label, new GridComponentSpec(row, 0)
            {
                Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
            });
            parent.AddChild(this, new GridComponentSpec(row, 1)
            {
                Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
            });
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 public override void CreateUIEntry(PGridPanel parent, ref int row)
 {
     parent.AddChild(new PLabel(Field)
     {
         Text      = LookInStrings(Title), ToolTip = LookInStrings(ToolTip),
         TextStyle = WRAP_TEXT_STYLE
     }, new GridComponentSpec(row, 0)
     {
         Margin = CONTROL_MARGIN, Alignment = TextAnchor.MiddleCenter, ColumnSpan = 2
     });
 }
Ejemplo n.º 5
0
 public override void CreateUIEntry(PGridPanel parent, ref int row)
 {
     parent.AddChild(new PButton(Field)
     {
         Text    = LookInStrings(Title), ToolTip = LookInStrings(Tooltip),
         OnClick = OnButtonClicked
     }.SetKleiPinkStyle(), new GridComponentSpec(row, 0)
     {
         Margin = CONTROL_MARGIN, Alignment = TextAnchor.MiddleCenter, ColumnSpan = 2
     });
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the line item entry for this options entry.
 /// </summary>
 /// <param name="parent">The location to add this entry.</param>
 /// <param name="row">The layout row index to use.</param>
 internal void CreateUIEntry(PGridPanel parent, int row)
 {
     parent.AddChild(new PLabel("Label")
     {
         Text      = LookInStrings(Title), ToolTip = LookInStrings(ToolTip),
         TextStyle = PUITuning.Fonts.TextLightStyle
     }, new GridComponentSpec(row, 0)
     {
         Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
     });
     parent.AddChild(GetUIComponent(), new GridComponentSpec(row, 1)
     {
         Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
     });
 }
Ejemplo n.º 7
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
            });
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a default UI entry. This entry will have the title and tool tip in the
 /// first column, and the provided UI component in the second column. Only one row is
 /// added by this method.
 /// </summary>
 /// <param name="entry">The options entry to be presented.</param>
 /// <param name="parent">The parent where the components will be added.</param>
 /// <param name="row">The row index where the components will be added.</param>
 /// <param name="presenter">The presenter that can display this option's value.</param>
 public static void CreateDefaultUIEntry(IOptionsEntry entry, PGridPanel parent,
                                         int row, IUIComponent presenter)
 {
     parent.AddChild(new PLabel("Label")
     {
         Text      = LookInStrings(entry.Title), ToolTip = LookInStrings(entry.Tooltip),
         TextStyle = PUITuning.Fonts.TextLightStyle
     }, new GridComponentSpec(row, 0)
     {
         Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
     });
     parent.AddChild(presenter, new GridComponentSpec(row, 1)
     {
         Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
     });
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds a category header to the dialog.
 /// </summary>
 /// <param name="container">The parent of the header.</param>
 /// <param name="category">The header title.</param>
 /// <param name="contents">The panel containing the options in this category.</param>
 private void AddCategoryHeader(PGridPanel container, string category,
                                PGridPanel contents)
 {
     contents.AddColumn(new GridColumnSpec(flex: 1.0f)).AddColumn(new GridColumnSpec());
     if (!string.IsNullOrEmpty(category))
     {
         bool state   = !(infoAttr?.ForceCollapseCategories ?? false);
         var  handler = new CategoryExpandHandler(state);
         container.AddColumn(new GridColumnSpec()).AddColumn(new GridColumnSpec(
                                                                 flex: 1.0f)).AddRow(new GridRowSpec()).AddRow(new GridRowSpec(flex: 1.0f));
         // Toggle is upper left, header is upper right
         var header = new PLabel("CategoryHeader")
         {
             Text = OptionsEntry.LookInStrings(category), TextStyle =
                 CATEGORY_TITLE_STYLE, TextAlignment = TextAnchor.LowerCenter
         };
         var toggle = new PToggle("CategoryToggle")
         {
             Color          = PUITuning.Colors.ComponentDarkStyle, InitialState = state,
             ToolTip        = PUIStrings.TOOLTIP_TOGGLE, Size = TOGGLE_SIZE,
             OnStateChanged = handler.OnExpandContract
         };
         header.OnRealize += handler.OnRealizeHeader;
         toggle.OnRealize += handler.OnRealizeToggle;
         container.AddChild(header, new GridComponentSpec(0, 1)
         {
             Margin = new RectOffset(OUTER_MARGIN, OUTER_MARGIN, 0, 0)
         }).AddChild(toggle, new GridComponentSpec(0, 0));
         if (contents != null)
         {
             contents.OnRealize += handler.OnRealizePanel;
         }
         container.AddChild(contents, new GridComponentSpec(1, 0)
         {
             ColumnSpan = 2
         });
     }
     else
     {
         // Default of unconstrained fills the whole panel
         container.AddColumn(new GridColumnSpec(flex: 1.0f)).AddRow(new GridRowSpec(
                                                                        flex: 1.0f)).AddChild(contents, new GridComponentSpec(0, 0));
     }
 }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
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
                });
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds the line item entry for this options entry.
 /// </summary>
 /// <param name="parent">The location to add this entry.</param>
 /// <param name="row">The layout row index to use. If updated, the row index will
 /// continue to count up from the new value.</param>
 public virtual void CreateUIEntry(PGridPanel parent, ref int row)
 {
     CreateDefaultUIEntry(this, parent, row, this);
 }