Beispiel #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).
         AddButton(PDialog.DIALOG_KEY_CLOSE, STRINGS.UI.CONFIRMDIALOG.CANCEL,
                   POptions.TOOLTIP_CANCEL);
         // For each option, add its UI component to panel
         pDialog.Body.Spacing   = 3;
         pDialog.Body.BackColor = PUITuning.Colors.DialogDarkBackground;
         foreach (var entry in optionEntries)
         {
             pDialog.Body.AddChild(entry.GetUIEntry());
         }
         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();
     }
 }
Beispiel #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
            });
        }
Beispiel #3
0
        public static void ExitDialog(string message)
        {
            Game.Instance.gameObject.SetActive(false);

            var dialog = new PDialog("Forced Exit")
            {
                Title           = "Forced Exit",
                DialogBackColor = PUITuning.Colors.DialogDarkBackground,
                DialogClosed    = (option) => OnConfirm(),
                Size            = new Vector2(320.0f, 200.0f),
                MaxSize         = new Vector2(800.0f, 600.0f),
                SortKey         = 150.0f,
            }.AddButton(PDialog.DIALOG_KEY_CLOSE, STRINGS.UI.CONFIRMDIALOG.OK, null, PUITuning.Colors.ButtonPinkStyle);

            dialog.Body.Margin = new RectOffset(20, 20, 20, 20);
            dialog.Body.AddChild(new PLabel("ExitReason")
            {
                Text      = message,
                TextStyle = PUITuning.Fonts.UILightStyle,
                Margin    = new RectOffset(0, 0, 0, 20)
            });
            dialog.Body.AddChild(new PLabel("ExitReason2")
            {
                Text      = "The game is now going to quit. Your game has been saved.",
                TextStyle = PUITuning.Fonts.UILightStyle
            });
            dialog.Show();
        }
Beispiel #4
0
        /// <summary>
        /// Fills in the mod info screen, assuming that infoAttr is non-null.
        /// </summary>
        /// <param name="dialog">The dialog to populate.</param>
        private void AddModInfoScreen(PDialog dialog)
        {
            string image = displayInfo.Image;
            var    body  = dialog.Body;

            // Try to load the mod image sprite if possible
            if (modImage == null && !string.IsNullOrEmpty(image))
            {
                string rootDir = PUtil.GetModPath(optionsType.Assembly);
                modImage = PUIUtils.LoadSpriteFile(rootDir == null ? image : Path.Combine(
                                                       rootDir, image));
            }
            var websiteButton = new PButton("ModSite")
            {
                Text    = PLibStrings.MOD_HOMEPAGE, ToolTip = PLibStrings.TOOLTIP_HOMEPAGE,
                OnClick = VisitModHomepage, Margin = PDialog.BUTTON_MARGIN
            }.SetKleiBlueStyle();
            var versionLabel = new PLabel("ModVersion")
            {
                Text      = displayInfo.Version, ToolTip = PLibStrings.TOOLTIP_VERSION,
                TextStyle = PUITuning.Fonts.UILightStyle, Margin = new RectOffset(0, 0,
                                                                                  OUTER_MARGIN, 0)
            };
            // Find mod URL
            string modURL = displayInfo.URL;

            if (modImage != null)
            {
                // 2 rows and 1 column
                if (optionCategories.Count > 0)
                {
                    body.Direction = PanelDirection.Horizontal;
                }
                var infoPanel = new PPanel("ModInfo")
                {
                    FlexSize  = Vector2.up, Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter
                }.AddChild(new PLabel("ModImage")
                {
                    SpriteSize = MOD_IMAGE_SIZE, TextAlignment = TextAnchor.UpperLeft,
                    Margin     = new RectOffset(0, OUTER_MARGIN, 0, OUTER_MARGIN),
                    Sprite     = modImage
                });
                if (!string.IsNullOrEmpty(modURL))
                {
                    infoPanel.AddChild(websiteButton);
                }
                body.AddChild(infoPanel.AddChild(versionLabel));
            }
            else
            {
                if (!string.IsNullOrEmpty(modURL))
                {
                    body.AddChild(websiteButton);
                }
                body.AddChild(versionLabel);
            }
        }
Beispiel #5
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();
        }
Beispiel #6
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();
     }
 }
Beispiel #7
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();
        }
Beispiel #8
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();
     }
 }
Beispiel #9
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();
        }
Beispiel #10
0
        public static bool Prefix(GeneShuffler __instance, Worker worker)
        {
            var parent = GameScreenManager.Instance.ssOverlayCanvas.gameObject;
            var dialog = new PDialog("ModifyItem")
            {
                Title        = "",
                DialogClosed = OnDialogClosed,
                SortKey      = 200.0f
            }.AddButton("ok", "OK", null, PUITuning.Colors.ButtonPinkStyle).
            AddButton("close", "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 = obj0));
            //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();


            return(true);
        }