Ejemplo n.º 1
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.º 2
0
        /// <summary>
        /// Triggered when the Mod Options button is clicked.
        /// </summary>
        public void ShowDialog()
        {
            string title;

            if (string.IsNullOrEmpty(displayInfo.Title))
            {
                title = PLibStrings.BUTTON_OPTIONS;
            }
            else
            {
                title = string.Format(PLibStrings.DIALOG_TITLE, OptionsEntry.LookInStrings(
                                          displayInfo.Title));
            }
            // 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              = title, Size = SETTINGS_DIALOG_SIZE, SortKey = 150.0f,
                DialogBackColor    = PUITuning.Colors.OptionsBackground,
                DialogClosed       = OnOptionsSelected, MaxSize = SETTINGS_DIALOG_MAX_SIZE,
                RoundToNearestEven = true
            }.AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK, PLibStrings.TOOLTIP_OK,
                        PUITuning.Colors.ButtonPinkStyle).AddButton(PDialog.DIALOG_KEY_CLOSE,
                                                                    STRINGS.UI.CONFIRMDIALOG.CANCEL, PLibStrings.TOOLTIP_CANCEL,
                                                                    PUITuning.Colors.ButtonBlueStyle);

            options = POptions.ReadSettings(POptions.GetConfigFilePath(optionsType),
                                            optionsType);
            if (options == null)
            {
                options = CreateOptions(optionsType);
            }
            AddModInfoScreen(pDialog);
            FillModOptions(pDialog);
            // Manually build the dialog so the options can be updated after realization
            var obj = pDialog.Build();

            UpdateOptions();
            dialog = obj.GetComponent <KScreen>();
            dialog.Activate();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Triggered when the Mod Options button is clicked.
 /// </summary>
 public void OnModOptions(GameObject _)
 {
     if (path != null)
     {
         string title = handler.GetTitle(OptionsEntry.LookInStrings(infoAttr?.Title));
         if (string.IsNullOrEmpty(title))
         {
             title = PUIStrings.BUTTON_OPTIONS;
         }
         // 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              = title, Size = SETTINGS_DIALOG_SIZE, SortKey = 150.0f,
             DialogBackColor    = PUITuning.Colors.OptionsBackground,
             DialogClosed       = OnOptionsSelected, MaxSize = SETTINGS_DIALOG_MAX_SIZE,
             RoundToNearestEven = true
         }.AddButton("ok", STRINGS.UI.CONFIRMDIALOG.OK, PUIStrings.TOOLTIP_OK,
                     PUITuning.Colors.ButtonPinkStyle).AddButton(PDialog.DIALOG_KEY_CLOSE,
                                                                 STRINGS.UI.CONFIRMDIALOG.CANCEL, PUIStrings.TOOLTIP_CANCEL,
                                                                 PUITuning.Colors.ButtonBlueStyle);
         options = POptions.ReadSettings(path, optionsType);
         if (options == null)
         {
             CreateOptions();
         }
         if (infoAttr != null)
         {
             AddModInfoScreen(pDialog);
         }
         FillModOptions(pDialog);
         // Manually build the dialog so the options can be updated after realization
         var obj = pDialog.Build();
         UpdateOptions();
         dialog = obj.GetComponent <KScreen>();
         dialog.Activate();
     }
 }
Ejemplo n.º 4
0
		internal RuntimeOptionsHandler(string path, string title) {
			ConfigPath = path;
			this.title = string.IsNullOrEmpty(title) ? null : OptionsEntry.LookInStrings(title);
		}