Example #1
0
            internal TypeSelectCategory(TypeSelectControl parent, Tag categoryTag,
                                        string overrideName = null)
            {
                Control     = parent ?? throw new ArgumentNullException("parent");
                CategoryTag = categoryTag;
                string title = string.IsNullOrEmpty(overrideName) ? CategoryTag.ProperName() :
                               overrideName;
                var selectBox = new PCheckBox("SelectCategory")
                {
                    Text      = title, DynamicSize = true, OnChecked = OnCheck,
                    CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED,
                    TextStyle = PUITuning.Fonts.TextDarkStyle
                };

                selectBox.OnRealize += (obj) => { CheckBox = obj; };
                Header = new PPanel("TypeSelectCategory")
                {
                    Direction = PanelDirection.Horizontal, Alignment = TextAnchor.MiddleLeft,
                    Spacing   = 5
                }.AddChild(new PToggle("ShowHide")
                {
                    OnStateChanged = OnToggle, Size = new Vector2(ROW_SIZE.x * 0.5f,
                                                                  ROW_SIZE.y * 0.5f), Color = PUITuning.Colors.ComponentLightStyle
                }).AddChild(selectBox).Build();
                children = new SortedList <Tag, TypeSelectElement>(16, TagAlphabetComparer.
                                                                   INSTANCE);
                ChildPanel = new PPanel("Children")
                {
                    Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft,
                    Spacing   = ROW_SPACING, Margin = new RectOffset(INDENT, 0, 0, 0)
                }.Build();
                ChildPanel.transform.localScale = Vector3.zero;
            }
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
        // штуки для создания сидескреенов
        // чекбокс и слидер с обвязкой и подгрузкой строк, добавляемые на панельку
        // установка и считывание значений реализованы через акции-каллбаки
        public static PPanel AddCheckBox(this PPanel parent, string prefix, string name, Action <bool> onChecked, out Action <bool> setChecked, out Action <bool> setActive)
        {
            prefix = (prefix + name).ToUpperInvariant();
            GameObject cb_go = null;
            var        cb    = new PCheckBox(name)
            {
                CheckColor    = PUITuning.Colors.ComponentLightStyle,
                CheckSize     = new Vector2(26f, 26f),
                Text          = Strings.Get(prefix + ".NAME"),
                TextAlignment = TextAnchor.MiddleLeft,
                TextStyle     = PUITuning.Fonts.TextDarkStyle,
                ToolTip       = Strings.Get(prefix + ".TOOLTIP"),
                OnChecked     = (go, state) =>
                {
                    // переворачиваем предыдующее значение
                    bool @checked = state == PCheckBox.STATE_UNCHECKED;
                    PCheckBox.SetCheckState(go, @checked ? PCheckBox.STATE_CHECKED : PCheckBox.STATE_UNCHECKED);
                    onChecked?.Invoke(@checked);
                    // внесапно, численное значение состояния чекбокса совпало с индексом таблицы звуков
                    KFMOD.PlayUISound(WidgetSoundPlayer.getSoundPath(ToggleSoundPlayer.default_values[state]));
                },
            }.AddOnRealize(realized => cb_go = realized);

            setChecked = @checked =>
            {
                if (cb_go != null)
                {
                    PCheckBox.SetCheckState(cb_go, @checked ? PCheckBox.STATE_CHECKED : PCheckBox.STATE_UNCHECKED);
                }
            };
            setActive = on => cb_go?.SetActive(on);
            return(parent.AddChild(cb));
        }
Example #4
0
        public TypeSelectControl(bool disableIcons = false)
        {
            DisableIcons = disableIcons;
            // Select/deselect all types
            var allCheckBox = new PCheckBox("SelectAll")
            {
                Text      = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON,
                CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED,
                OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle
            };

            allCheckBox.OnRealize += (obj) => { allItems = obj; };
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING
            };

            cp.OnRealize += (obj) => { childPanel = obj; };
            RootPanel     = new PPanel("Border")
            {
                // 1px dark border for contrast
                Margin    = new RectOffset(1, 1, 1, 1), Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.MiddleCenter, Spacing = 1
            }.AddChild(new PLabel("Title")
            {
                // Title bar
                TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings.
                                                                DIALOG_TITLE, FlexSize = new Vector2(1.0f, 0.0f), DynamicSize = true,
                Margin = new RectOffset(1, 1, 1, 1)
            }.SetKleiPinkColor()).AddChild(new PPanel("TypeSelectControl")
            {
                // White background for scroll bar
                Direction = PanelDirection.Vertical, Margin = OUTER_MARGIN,
                Alignment = TextAnchor.MiddleCenter, Spacing = 0,
                BackColor = PUITuning.Colors.BackgroundLight, FlexSize = Vector2.one
            }.AddChild(new PScrollPane("Scroll")
            {
                // Scroll to select elements
                Child = new PPanel("SelectType")
                {
                    Direction = PanelDirection.Vertical, Margin = ELEMENT_MARGIN,
                    FlexSize  = new Vector2(1.0f, 0.0f), Alignment = TextAnchor.UpperLeft
                }.AddChild(allCheckBox).AddChild(cp), ScrollHorizontal = false,
                ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f,
                FlexSize       = Vector2.one, BackColor = PUITuning.Colors.BackgroundLight,
            })).SetKleiBlueColor().BuildWithFixedSize(PANEL_SIZE);
            // Cache the vertical scroll bar
            var vst = RootPanel.transform.Find("TypeSelectControl/Scroll/Viewport/SelectType");

#pragma warning disable IDE0031 // Use null propagation
            vScroll = (vst == null) ? null : vst.gameObject;
#pragma warning restore IDE0031 // Use null propagation
            children = new SortedList <Tag, TypeSelectCategory>(16, TagAlphabetComparer.
                                                                INSTANCE);
            position = Vector3.zero;
            Screen   = RootPanel.AddComponent <TypeSelectScreen>();
        }
Example #5
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);
            }
        }
Example #6
0
        public TypeSelectControl(bool disableIcons = false)
        {
            DisableIcons = disableIcons;
            // Select/deselect all types
            var allCheckBox = new PCheckBox("SelectAll")
            {
                Text      = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON,
                CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED,
                OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle
            };

            allCheckBox.OnRealize += (obj) => { allItems = obj; };
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING, Margin = ELEMENT_MARGIN, FlexSize = Vector2.right,
            };

            cp.AddChild(allCheckBox);
            cp.OnRealize += (obj) => { childPanel = obj; };
            // Scroll to select elements
            var sp = new PScrollPane("Scroll")
            {
                Child = cp, ScrollHorizontal = false, ScrollVertical = true,
                AlwaysShowVertical = true, TrackSize = 8.0f, FlexSize = Vector2.one
            };
            // Title bar
            var title = new PLabel("Title")
            {
                TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings.
                                                                DIALOG_TITLE, FlexSize = Vector2.right, Margin = TITLE_MARGIN
            }.SetKleiPinkColor();

            // Bottom border on the title for contrast
            title.OnRealize += (obj) => {
                var img = obj.AddOrGet <Image>();
                img.sprite = PUITuning.Images.BoxBorder;
                img.type   = Image.Type.Sliced;
            };
            // 1px black border on the rest of the dialog for contrast
            var panel = new PRelativePanel("Border")
            {
                BackImage   = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced,
                DynamicSize = false, BackColor = PUITuning.Colors.BackgroundLight
            }.AddChild(sp).AddChild(title);

            RootPanel = panel.SetMargin(sp, OUTER_MARGIN).
                        SetLeftEdge(title, fraction: 0.0f).SetRightEdge(title, fraction: 1.0f).
                        SetLeftEdge(sp, fraction: 0.0f).SetRightEdge(sp, fraction: 1.0f).
                        SetTopEdge(title, fraction: 1.0f).SetBottomEdge(sp, fraction: 0.0f).
                        SetTopEdge(sp, below: title).Build();
            RootPanel.SetMinUISize(PANEL_SIZE);
            children = new SortedList <Tag, TypeSelectCategory>(16, TagAlphabetComparer.
                                                                INSTANCE);
            Screen = RootPanel.AddComponent <TypeSelectScreen>();
        }
Example #7
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            // One long linear row
            var panel = new PPanel("MoreModActions")
            {
                BackColor = PUITuning.Colors.DialogDarkBackground, Spacing = 6,
                BackImage = PUITuning.Images.BoxBorder, ImageMode = Image.Type.Sliced,
                Direction = PanelDirection.Horizontal, Margin = new RectOffset(6, 6, 6, 6)
            }.AddChild(MakeButton("MoveToFirst", UI.TOOLTIPS.DNI_TOP,
                                  SpriteRegistry.GetTopIcon(), OnMoveFirst, (obj) =>
                                  buttonFirst = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveUpTen", UI.TOOLTIPS.DNI_UP,
                                 Assets.GetSprite("icon_priority_up_2"), OnMoveUp, (obj) =>
                                 buttonUp = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveDownTen", UI.TOOLTIPS.DNI_DOWN,
                                 Assets.GetSprite("icon_priority_down_2"), OnMoveDown, (obj) =>
                                 buttonDown = obj.GetComponent <KButton>()))
            .AddChild(MakeButton("MoveToLast", UI.TOOLTIPS.DNI_BOTTOM,
                                 SpriteRegistry.GetBottomIcon(), OnMoveLast, (obj) =>
                                 buttonLast = obj.GetComponent <KButton>()))
            .AddChild(new PButton("ManageMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_SUBSCRIPTION, DynamicSize = false,
                OnClick = OnManage, ToolTip = "Manage Mod", Margin = DebugUtils.BUTTON_MARGIN
            }.SetKleiBlueStyle().AddOnRealize((obj) => buttonManage = obj))
            .AddChild(new PButton("UnsubMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_UNSUB, DynamicSize = false,
                OnClick = OnUnsub, ToolTip = UI.TOOLTIPS.DNI_UNSUB, Margin = DebugUtils.
                                                                             BUTTON_MARGIN
            }.SetKleiBlueStyle().AddOnRealize((obj) => buttonUnsub = obj.
                                                                     GetComponent <KButton>()));

#if DEBUG
            panel.AddChild(new PButton("ModifyMod")
            {
                Text    = UI.MODSSCREEN.BUTTON_MODIFY, DynamicSize = false,
                OnClick = OnModify, ToolTip = UI.TOOLTIPS.DNI_MODIFY, Margin = DebugUtils.
                                                                               BUTTON_MARGIN
            }.SetKleiPinkStyle().AddOnRealize((obj) => buttonModify = obj.
                                                                      GetComponent <KButton>()));
#endif
            var actionsObj = panel.AddTo(gameObject);
#if DEBUG
            PButton.SetButtonEnabled(buttonModify.gameObject, false);
#endif
            actionsObj.SetActive(false);
            // Blacklist from auto layout
            actionsObj.AddOrGet <LayoutElement>().ignoreLayout = true;
            PUIElements.SetAnchors(actionsObj, PUIAnchoring.End, PUIAnchoring.Center);
            unsubCaller = new CallResult <RemoteStorageUnsubscribePublishedFileResult_t>(
                OnUnsubComplete);
            actionsScreen = actionsObj.AddComponent <ModActionsScreen>();
            callingButton = null;
        }
Example #8
0
        public TestControl(bool disableIcons = false)
        {
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING
            };

            cp.AddChild(new PTextField()
            {
                FlexSize = Vector2.one,
            });
            cp.AddChild(new PTextField()
            {
            });
            cp.AddChild(new PTextField()
            {
            });
            cp.AddChild(new PTextField()
            {
            });
            cp.AddChild(new PTextField()
            {
            });
            cp.OnRealize += (obj) => { childPanel = obj; };
            RootPanel     = new PPanel("GridFilterableSideScreen")
            {
                // White background for scroll bar
                Direction = PanelDirection.Vertical,
                Margin    = OUTER_MARGIN,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 0,
                BackColor = PUITuning.Colors.BackgroundLight,
                FlexSize  = Vector2.one
            }.AddChild(new PScrollPane("Scroll")
            {
                // Scroll to select elements
                Child = new PPanel("SelectType")
                {
                    Direction = PanelDirection.Vertical,
                    Margin    = ELEMENT_MARGIN,
                    FlexSize  = new Vector2(1.0f, 0.0f),
                    Alignment = TextAnchor.UpperLeft
                }.AddChild(cp),
                ScrollHorizontal   = false,
                ScrollVertical     = true,
                AlwaysShowVertical = true,
                TrackSize          = 8.0f,
                FlexSize           = Vector2.one,
                BackColor          = PUITuning.Colors.BackgroundLight,
            }).SetKleiBlueColor().Build();
        }
Example #9
0
 /// <summary>
 /// Adds a category header to the dialog.
 /// </summary>
 /// <param name="body">The parent of the header.</param>
 /// <param name="category">The header title.</param>
 private void AddCategoryHeader(PPanel body, string category)
 {
     if (!string.IsNullOrEmpty(category))
     {
         body.AddChild(new PLabel("CategoryHeader_" + category)
         {
             Text          = category, TextStyle = POptions.TITLE_STYLE,
             TextAlignment = TextAnchor.LowerCenter, DynamicSize = true,
             Margin        = new RectOffset(0, 0, 0, 2), FlexSize = new Vector2(1.0f, 0.0f),
         });
     }
 }
Example #10
0
 public UncategorizedFilterableRow(UncategorizedFilterableControl control)
 {
     Parent     = control ?? throw new ArgumentNullException("parent");
     entities   = new List <UncategorizedFilterableEntity>(16);
     ChildPanel = new PPanel("Children")
     {
         Direction = PanelDirection.Horizontal,
         Alignment = TextAnchor.MiddleLeft,
         Spacing   = CARD_SPACING,
         Margin    = new RectOffset(0, 0, 0, 0)
     }.Build();
     //ChildPanel.transform.localScale = Vector3.zero;
 }
Example #11
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();
     }
 }
Example #12
0
        public TypeSelectControl()
        {
            var allCheckBox = new PCheckBox("SelectAll")
            {
                Text      = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON,
                CheckSize = ROW_SIZE, InitialState = PCheckBox.STATE_CHECKED,
                OnChecked = OnCheck, TextStyle = PUITuning.Fonts.TextDarkStyle
            };

            allCheckBox.OnRealize += (obj) => { allItems = obj; };
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING
            };

            cp.OnRealize += (obj) => { childPanel = obj; };
            RootPanel     = new PPanel("Border")
            {
                // 1px dark border for contrast
                Margin    = new RectOffset(1, 1, 1, 1), Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.MiddleCenter, Spacing = 1
            }.AddChild(new PLabel("Title")
            {
                // Title bar
                TextAlignment = TextAnchor.MiddleCenter, Text = SweepByTypeStrings.
                                                                DIALOG_TITLE, FlexSize = new Vector2(1.0f, 0.0f), DynamicSize = true,
                Margin = new RectOffset(1, 1, 1, 1)
            }.SetKleiPinkColor()).AddChild(new PPanel("TypeSelectControl")
            {
                // White background for scroll bar
                Direction = PanelDirection.Vertical, Margin = OUTER_MARGIN,
                Alignment = TextAnchor.MiddleCenter, Spacing = 0,
                BackColor = PUITuning.Colors.BackgroundLight, FlexSize = Vector2.one
            }.AddChild(new PScrollPane("Scroll")
            {
                // Scroll to select elements
                Child = new PPanel("SelectType")
                {
                    Direction = PanelDirection.Vertical, Margin = ELEMENT_MARGIN,
                    FlexSize  = new Vector2(1.0f, 0.0f), Alignment = TextAnchor.UpperLeft
                }.AddChild(allCheckBox).AddChild(cp), ScrollHorizontal = false,
                ScrollVertical = true, AlwaysShowVertical = true, TrackSize = 8.0f,
                FlexSize       = Vector2.one, BackColor = PUITuning.Colors.BackgroundLight
            })).SetKleiBlueColor().BuildWithFixedSize(PANEL_SIZE);
            children = new SortedList <Tag, TypeSelectCategory>(16, this);
            Screen   = RootPanel.AddComponent <TypeSelectScreen>();
        }
Example #13
0
        public GridFilterableControl()
        {
            // Select/deselect all types
            var allCheckBox = new PCheckBox("SelectAll")
            {
                Text         = STRINGS.UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON,
                CheckSize    = ROW_SIZE,
                InitialState = PCheckBox.STATE_CHECKED,
                OnChecked    = OnCheck,
                TextStyle    = PUITuning.Fonts.TextDarkStyle
            };

            allCheckBox.OnRealize += (obj) => { allItems = obj; };
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING
            };

            cp.OnRealize += (obj) => { childPanel = obj; };
            RootPanel     = new PPanel("GridFilterableSideScreen")
            {
                // White background for scroll bar
                Direction = PanelDirection.Vertical,
                Margin    = OUTER_MARGIN,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 0,
                BackColor = PUITuning.Colors.BackgroundLight,
                FlexSize  = Vector2.one,
            }.AddChild(new PPanel("SelectType")
            {
                Direction = PanelDirection.Vertical,
                Margin    = ELEMENT_MARGIN,
                FlexSize  = new Vector2(1.0f, 0.0f),
                Alignment = TextAnchor.UpperLeft
            }.AddChild(allCheckBox).AddChild(cp)).SetKleiBlueColor().BuildWithFixedSize(PANEL_SIZE);
            children = new List <GridFilterableRow>(16);
            if (Instance != null)
            {
                Debug.LogError("ISSUE! created grid filterable control more than once");
            }
            Instance = this;
        }
Example #14
0
        public NotepadControl()
        {
            descriptionField = DescriptionArea();

            // this button does nothing but it enable to deselect the textarea and to valide the input without closing the sidescreen
            PButton validationButton = new PButton("button")
            {
                Sprite     = PUITuning.Images.Checked,
                SpriteSize = new Vector2(25, 30),
            };

            PLabel descriptionLabel = new PLabel("description label")
            {
                Text          = "Description",
                TextAlignment = TextAnchor.MiddleCenter,
            };


            PPanel panel = new PPanel("Text panel")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = ROW_SPACING,
                FlexSize  = Vector2.one,
            };

            panel.AddChild(descriptionLabel);
            panel.AddChild(descriptionField);
            panel.AddChild(validationButton);


            PPanel root = new PPanel("NotepadSideScreen")
            {
                Direction = PanelDirection.Vertical,
                Margin    = OUTER_MARGIN,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 0,
                BackColor = PUITuning.Colors.BackgroundLight,
                FlexSize  = Vector2.one,
            };

            root.AddChild(panel);
            RootPanel = root.SetKleiBlueColor().Build();
        }
Example #15
0
        public static PPanel AddSliderBox(this PPanel parent, string prefix, string name, float min, float max, Action <float> onValueUpdate, out Action <float> setValue, Func <float, string> customTooltip = null)
        {
            float      value     = 0;
            GameObject text_go   = null;
            GameObject slider_go = null;

            setValue = newValue =>
            {
                value = newValue;
                Update();
            };
            if (!(min > float.NegativeInfinity && max < float.PositiveInfinity && min < max))
            {
                PUtil.LogError("Invalid min max parameters");
                return(parent);
            }
            prefix = (prefix + name).ToUpperInvariant();

            void Update()
            {
                var field = text_go?.GetComponentInChildren <TMP_InputField>();

                if (field != null)
                {
                    field.text = value.ToString("F0");
                }
                if (slider_go != null)
                {
                    PSliderSingle.SetCurrentValue(slider_go, value);
                }
                onValueUpdate?.Invoke(value);
            }

            void OnTextChanged(GameObject _, string text)
            {
                if (float.TryParse(text, out float newValue))
                {
                    value = Mathf.Clamp(newValue, min, max);
                }
                Update();
            }

            void OnSliderChanged(GameObject _, float newValue)
            {
                value = Mathf.Clamp(Mathf.Round(newValue), min, max);
                Update();
            }

            var small    = PUITuning.Fonts.TextDarkStyle.DeriveStyle(size: 12);
            var minLabel = new PLabel("min_" + name)
            {
                TextStyle = small,
                Text      = string.Format(Strings.Get(prefix + ".MIN_MAX"), min),
            };
            var maxLabel = new PLabel("max_" + name)
            {
                TextStyle = small,
                Text      = string.Format(Strings.Get(prefix + ".MIN_MAX"), max),
            };
            var preLabel = new PLabel("pre_" + name)
            {
                TextStyle = PUITuning.Fonts.TextDarkStyle,
                Text      = Strings.Get(prefix + ".PRE"),
            };
            var pstLabel = new PLabel("pst_" + name)
            {
                TextStyle = PUITuning.Fonts.TextDarkStyle,
                Text      = Strings.Get(prefix + ".PST"),
            };

            var textField = new PTextField("text_" + name)
            {
                MinWidth      = 40,
                Type          = PTextField.FieldType.Integer,
                OnTextChanged = OnTextChanged,
            }.AddOnRealize(realized => text_go = realized);

            var margin    = new RectOffset(12, 12, 0, 0);
            var panel_top = new PPanel("slider_top_" + name)
            {
                Alignment = TextAnchor.MiddleCenter,
                Direction = PanelDirection.Horizontal,
                FlexSize  = Vector2.right,
                Margin    = margin,
                Spacing   = 4,
            };

            panel_top.AddChild(minLabel).AddChild(new PSpacer()).AddChild(preLabel)
            .AddChild(textField).AddChild(pstLabel).AddChild(new PSpacer()).AddChild(maxLabel);

            var slider = new PSliderSingle("slider_" + name)
            {
                MinValue       = min,
                MaxValue       = max,
                IntegersOnly   = true,
                Direction      = UnityEngine.UI.Slider.Direction.LeftToRight,
                FlexSize       = Vector2.right,
                HandleSize     = 24,
                TrackSize      = 16,
                ToolTip        = Strings.Get(prefix + ".TOOLTIP"),
                OnDrag         = OnSliderChanged,
                OnValueChanged = OnSliderChanged,
            }.AddOnRealize(realized =>
            {
                slider_go = realized;
                if (customTooltip != null)
                {
                    var ks      = slider_go.GetComponent <KSlider>();
                    var toolTip = slider_go.GetComponent <ToolTip>();
                    if (ks != null && toolTip != null)
                    {
                        toolTip.OnToolTip            = () => customTooltip(ks.value);
                        toolTip.refreshWhileHovering = true;
                    }
                }
            });

            var panel_bottom = new PPanel("slider_bottom_" + name)
            {
                Alignment = TextAnchor.MiddleCenter,
                Direction = PanelDirection.Horizontal,
                FlexSize  = Vector2.right,
                Margin    = margin,
                Spacing   = 4,
            };

            panel_bottom.AddChild(slider);
            return(parent.AddChild(panel_top).AddChild(panel_bottom));
        }
Example #16
0
        private void RebuildPanel()
        {
            // Update schedule data

            int selectedSchedule = (sensor != null) ? sensor.scheduleIndex : 0;
            int selectedGroup    = (sensor != null) ? sensor.blockTypeIndex : 0;

            schedules = new List <StringListOption>();
            var slist = ScheduleManager.Instance.GetSchedules();

            foreach (Schedule s in slist)
            {
                schedules.Add(new StringListOption(s.name));
            }

            if (selectedSchedule < 0 || selectedSchedule >= schedules.Count)
            {
                selectedSchedule = 0;
                if (sensor != null)
                {
                    sensor.scheduleIndex = selectedSchedule;
                }
            }

            groups = new List <StringListOption>();
            var glist = Db.Get().ScheduleGroups.allGroups;

            foreach (ScheduleGroup g in glist)
            {
                groups.Add(new StringListOption(g.Name));
            }

            if (selectedGroup < 0 || selectedGroup >= groups.Count)
            {
                selectedGroup = 0;
                if (sensor != null)
                {
                    sensor.blockTypeIndex = selectedGroup;
                }
            }

            // Rebuild UI

            if (ContentContainer != null)
            {
                Destroy(ContentContainer);
                ContentContainer = null;
            }

            var margin     = new RectOffset(8, 8, 8, 8);
            var baseLayout = gameObject.GetComponent <BoxLayoutGroup>();

            if (baseLayout != null)
            {
                baseLayout.Params = new BoxLayoutParams()
                {
                    Margin    = margin,
                    Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter,
                    Spacing   = 8
                };
            }

            var mainPanel = new PPanel();

            var scheduleRow = new PPanel("Schedule Select")
            {
                FlexSize  = Vector2.right,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 10,
                Direction = PanelDirection.Horizontal,
                Margin    = margin
            };

            scheduleRow.AddChild(new PLabel("Schedule")
            {
                TextAlignment = TextAnchor.MiddleRight,
                ToolTip       = "TODO: Schedule Label Tooltip",
                Text          = "Schedule",
                TextStyle     = PUITuning.Fonts.TextDarkStyle
            });

            var scb = new PeterHan.PLib.UI.PComboBox <StringListOption>("Schedule Select")
            {
                Content          = schedules,
                MinWidth         = 100,
                InitialItem      = schedules[selectedSchedule],
                ToolTip          = "TODO: Schedule Select Tooltip",
                TextStyle        = PUITuning.Fonts.TextLightStyle,
                TextAlignment    = TextAnchor.MiddleLeft,
                OnOptionSelected = SetSchedule
            };

            scb.OnRealize += (obj) =>
            {
                scheduleCombo = obj;
            };
            scheduleRow.AddChild(scb);
            mainPanel.AddChild(scheduleRow);

            var groupRow = new PPanel("Group Select")
            {
                FlexSize  = Vector2.right,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 10,
                Direction = PanelDirection.Horizontal,
                Margin    = margin
            };

            groupRow.AddChild(new PLabel("Group")
            {
                TextAlignment = TextAnchor.MiddleRight,
                ToolTip       = "TODO: Group Label Tooltip",
                Text          = "Group",
                TextStyle     = PUITuning.Fonts.TextDarkStyle
            });

            var bcb = new PComboBox <StringListOption>("Group Select")
            {
                Content          = groups,
                MinWidth         = 100,
                InitialItem      = groups[selectedGroup],
                ToolTip          = "TODO: Group Select Tooltip",
                TextStyle        = PUITuning.Fonts.TextLightStyle,
                TextAlignment    = TextAnchor.MiddleLeft,
                OnOptionSelected = SetGroup
            };

            bcb.OnRealize += (obj) =>
            {
                groupCombo = obj;
            };
            groupRow.AddChild(bcb);
            mainPanel.AddChild(groupRow);

            ContentContainer = mainPanel.Build();
            ContentContainer.SetParent(gameObject);

            if (scheduleCombo != null)
            {
                PComboBox <StringListOption> .SetSelectedItem(scheduleCombo, schedules[selectedSchedule]);
            }

            if (groupCombo != null)
            {
                PComboBox <StringListOption> .SetSelectedItem(groupCombo, groups[selectedGroup]);
            }
        }
        protected override void OnPrefabInit()
        {
            Color      backColour = new Color(0.998f, 0.998f, 0.998f);
            RectOffset rectOffset = new RectOffset(8, 8, 8, 8);

            PPanel moveTitle_panel = new PPanel("MovespeedTitleRow");

            moveTitle_panel.BackColor = backColour;
            moveTitle_panel.Alignment = TextAnchor.MiddleCenter;
            moveTitle_panel.Direction = PanelDirection.Horizontal;
            moveTitle_panel.Spacing   = 10;
            moveTitle_panel.Margin    = rectOffset;
            moveTitle_panel.FlexSize  = Vector2.right;
            PLabel moveTitle_label = new PLabel("MovespeedTitleLabel");

            moveTitle_label.TextAlignment = TextAnchor.MiddleRight;
            moveTitle_label.Text          = SweepyStrings.MoveSpeedTitleName;
            moveTitle_label.ToolTip       = SweepyStrings.MoveSpeedTitleTooltip;
            moveTitle_label.TextStyle     = PUITuning.Fonts.TextDarkStyle;
            PTextField moveTitle_textField = new PTextField("MovespeedSliderTextField")
            {
                Text      = SweepyConfigChecker.BaseMovementSpeed.ToString("0.00"),
                MaxLength = 10,
            };

            moveTitle_textField.OnTextChanged = this.ChangeTextFieldMovespeed;
            moveTitle_textField.OnRealize    += (PUIDelegates.OnRealize)(obj => this.MoveSpeedText = obj);

            PPanel moveTitle_components = moveTitle_panel.AddChild((IUIComponent)moveTitle_label);

            moveTitle_components = moveTitle_panel.AddChild((IUIComponent)moveTitle_textField);
            moveTitle_components.AddTo(this.gameObject, -2);

            PPanel moveSlider_panel = new PPanel("MovespeedSliderRow");

            moveSlider_panel.BackColor = backColour;
            moveSlider_panel.ImageMode = Image.Type.Sliced;
            moveSlider_panel.Alignment = TextAnchor.MiddleCenter;
            moveSlider_panel.Direction = PanelDirection.Horizontal;
            moveSlider_panel.Spacing   = 10;
            moveSlider_panel.Margin    = new RectOffset(8, 8, 6, 32);
            moveSlider_panel.FlexSize  = Vector2.right;

            PLabel moveSliderMin_label = new PLabel("MovespeedSliderMinLabel");

            moveSliderMin_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MinSpeedSliderValue).ToString();
            moveSliderMin_label.TextStyle = PUITuning.Fonts.TextDarkStyle;

            PPanel moveSlider_components = moveSlider_panel.AddChild((IUIComponent)moveSliderMin_label);

            PSliderSingle moveSpeedSlider = new PSliderSingle("Movespeed")
            {
                Direction       = Slider.Direction.LeftToRight,
                HandleColor     = PUITuning.Colors.ButtonPinkStyle,
                HandleSize      = 16.0f,
                InitialValue    = SweepyConfigChecker.BaseMovementSpeed,
                IntegersOnly    = false,
                MaxValue        = SweepyConfigChecker.MaxSpeedSliderValue,
                MinValue        = SweepyConfigChecker.MinSpeedSliderValue,
                PreferredLength = 140.0f,
                TrackSize       = 16.0f,
            };

            moveSpeedSlider.OnRealize     += (PUIDelegates.OnRealize)(obj => this.MoveSpeedSlider = obj);
            moveSpeedSlider.OnValueChanged = ChangeMovespeed;
            moveSlider_components.AddChild(moveSpeedSlider);

            PLabel moveSliderMax_label = new PLabel("MovespeedSliderMaxLabel");

            moveSliderMax_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MaxSpeedSliderValue).ToString();
            moveSliderMax_label.TextStyle = PUITuning.Fonts.TextDarkStyle;
            moveSlider_components.AddChild(moveSliderMax_label);

            moveSlider_components.AddTo(this.gameObject, -2);



            PPanel probingTitle_panel = new PPanel("ProbingRadiusTitleRow");

            probingTitle_panel.BackColor = backColour;
            probingTitle_panel.Alignment = TextAnchor.MiddleCenter;
            probingTitle_panel.Direction = PanelDirection.Horizontal;
            probingTitle_panel.Spacing   = 10;
            probingTitle_panel.Margin    = rectOffset;
            probingTitle_panel.FlexSize  = Vector2.right;
            PLabel probingTitle_label = new PLabel("ProbingRadiusTitleLabel");

            probingTitle_label.TextAlignment = TextAnchor.MiddleRight;
            probingTitle_label.Text          = SweepyStrings.ProbingRadiusTitleName;
            probingTitle_label.ToolTip       = SweepyStrings.ProbingRadiusTitleTooltip;
            probingTitle_label.TextStyle     = PUITuning.Fonts.TextDarkStyle;
            PTextField probingTitle_TextField = new PTextField("ProbingSliderTextField")
            {
                Text      = SweepyConfigChecker.BaseProbingRadius.ToString("0"),
                MaxLength = 8,
            };

            probingTitle_TextField.OnTextChanged = this.ChangeTextFieldProbingRadius;
            probingTitle_TextField.OnRealize    += (PUIDelegates.OnRealize)(obj => this.ProbingRadiusText = obj);

            PPanel probingTitle_components = probingTitle_panel.AddChild((IUIComponent)probingTitle_label);

            probingTitle_components = probingTitle_panel.AddChild((IUIComponent)probingTitle_TextField);
            probingTitle_components.AddTo(this.gameObject, -2);

            PPanel probingSlider_panel = new PPanel("ProbingRadiusSliderRow");

            probingSlider_panel.BackColor = backColour;
            probingSlider_panel.ImageMode = Image.Type.Sliced;
            probingSlider_panel.Alignment = TextAnchor.MiddleCenter;
            probingSlider_panel.Direction = PanelDirection.Horizontal;
            probingSlider_panel.Spacing   = 10;
            probingSlider_panel.Margin    = new RectOffset(8, 8, 6, 32);
            probingSlider_panel.FlexSize  = Vector2.right;

            PLabel probingSliderMin_label = new PLabel("ProbingSliderMinLabel");

            probingSliderMin_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MinProbingSliderValue).ToString();
            probingSliderMin_label.TextStyle = PUITuning.Fonts.TextDarkStyle;

            PPanel probingSlider_components = probingSlider_panel.AddChild((IUIComponent)probingSliderMin_label);

            PSliderSingle probingSpeedSlider = new PSliderSingle("Probing Radius")
            {
                Direction       = Slider.Direction.LeftToRight,
                HandleColor     = PUITuning.Colors.ButtonPinkStyle,
                HandleSize      = 16.0f,
                InitialValue    = SweepyConfigChecker.BaseProbingRadius,
                IntegersOnly    = true,
                MaxValue        = SweepyConfigChecker.MaxProbingSliderValue,
                MinValue        = SweepyConfigChecker.MinProbingSliderValue,
                PreferredLength = 140.0f,
                TrackSize       = 16.0f,
            };

            probingSpeedSlider.OnRealize     += (PUIDelegates.OnRealize)(obj => this.ProbingRadiusSlider = obj);
            probingSpeedSlider.OnValueChanged = ChangeProbingRadius;
            probingSlider_components.AddChild(probingSpeedSlider);

            PLabel probingSliderMax_label = new PLabel("ProbingSliderMaxLabel");

            probingSliderMax_label.Text      = Mathf.RoundToInt(SweepyConfigChecker.MaxProbingSliderValue).ToString();
            probingSliderMax_label.TextStyle = PUITuning.Fonts.TextDarkStyle;
            probingSlider_components.AddChild(probingSliderMax_label);

            probingSlider_components.AddTo(this.gameObject, -2);



            PPanel bottomRow_panel = new PPanel("BottomRow");

            bottomRow_panel.BackColor = backColour;
            bottomRow_panel.Alignment = TextAnchor.MiddleCenter;
            bottomRow_panel.Direction = PanelDirection.Horizontal;
            bottomRow_panel.Margin    = rectOffset;
            bottomRow_panel.Spacing   = 10;

            PButton findButton = new PButton();

            findButton.Color      = PUITuning.Colors.ButtonBlueStyle;
            findButton.Margin     = new RectOffset(16, 16, 8, 8);
            findButton.TextStyle  = PUITuning.Fonts.TextLightStyle;
            findButton.OnClick    = new PUIDelegates.OnButtonPressed(this.FindSweepyBot);
            findButton.Text       = SweepyStrings.FindSweepyButtonText;
            findButton.ToolTip    = SweepyStrings.FindSweepyButtonTooltip;
            findButton.OnRealize += (PUIDelegates.OnRealize)(obj => this.FindSweepyButton = obj);

            PButton resetButton = new PButton();

            resetButton.Color      = PUITuning.Colors.ButtonBlueStyle;
            resetButton.Margin     = new RectOffset(16, 16, 8, 8);
            resetButton.TextStyle  = PUITuning.Fonts.TextLightStyle;
            resetButton.OnClick    = new PUIDelegates.OnButtonPressed(this.ResetSweepyBot);
            resetButton.Text       = SweepyStrings.ResetSweepyButtonText;
            resetButton.ToolTip    = SweepyStrings.ResetSweepyButtonTooltip;
            resetButton.OnRealize += (PUIDelegates.OnRealize)(obj => this.ResetSweepyButton = obj);

            bottomRow_panel.AddChild(findButton);
            bottomRow_panel.AddChild(resetButton);
            bottomRow_panel.AddTo(this.gameObject, -2);


            this.ContentContainer = this.gameObject;
            base.OnPrefabInit();
            this.SetTarget(this.target.gameObject);
        }
Example #18
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();
        }
Example #19
0
        private void RebuildPanel()
        {
            // Rebuild UI

            if (ContentContainer != null)
            {
                Destroy(ContentContainer);
                ContentContainer = null;
            }

            var margin     = new RectOffset(8, 8, 8, 8);
            var baseLayout = gameObject.GetComponent <BoxLayoutGroup>();

            if (baseLayout != null)
            {
                baseLayout.Params = new BoxLayoutParams()
                {
                    Margin    = margin,
                    Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter,
                    Spacing   = 8
                };
            }

            var mainPanel = new PPanel();

            if (engine != null)
            {
                var efficiencyRow = new PPanel("EfficiencyRow")
                {
                    FlexSize  = Vector2.right,
                    Alignment = TextAnchor.MiddleCenter,
                    Spacing   = 10,
                    Direction = PanelDirection.Horizontal,
                    Margin    = margin
                };

                efficiencyRow.AddChild(new PLabel("Efficiency")
                {
                    TextAlignment = TextAnchor.MiddleRight,
                    ToolTip       = "Indicates the percentage of input heat that is currently being converted to power.",
                    Text          = $"Current Efficiency: {(engine.currentEfficiency * 100f):F0} %",
                    TextStyle     = PUITuning.Fonts.TextDarkStyle
                });

                mainPanel.AddChild(efficiencyRow);

                var powerRow = new PPanel("PowerRow")
                {
                    FlexSize  = Vector2.right,
                    Alignment = TextAnchor.MiddleCenter,
                    Spacing   = 10,
                    Direction = PanelDirection.Horizontal,
                    Margin    = margin
                };

                powerRow.AddChild(new PLabel("Power")
                {
                    TextAlignment = TextAnchor.MiddleRight,
                    ToolTip       = "Indicates the amount of power currently being output into the circuit.",
                    Text          = $"Estimated Power Output: {engine.currentGeneratedPower:F0} W",
                    TextStyle     = PUITuning.Fonts.TextDarkStyle
                });

                mainPanel.AddChild(powerRow);

                var heatRow = new PPanel("HeatRow")
                {
                    FlexSize  = Vector2.right,
                    Alignment = TextAnchor.MiddleCenter,
                    Spacing   = 10,
                    Direction = PanelDirection.Horizontal,
                    Margin    = margin
                };

                heatRow.AddChild(new PLabel("Heat")
                {
                    TextAlignment = TextAnchor.MiddleRight,
                    ToolTip       = "Indicates the amount of heat currently being added to the building temperature.",
                    Text          = $"Estimated Heat Output: {engine.currentGeneratedHeat:F0} DTU/s",
                    TextStyle     = PUITuning.Fonts.TextDarkStyle
                });

                mainPanel.AddChild(heatRow);

                ContentContainer = mainPanel.Build();
                ContentContainer.SetParent(gameObject);
            }
        }
        public UncategorizedFilterableControl()
        {
            // Select/deselect all types
            var allCheckBox = new PCheckBox("SelectAll")
            {
                Text         = UI.UISIDESCREENS.TREEFILTERABLESIDESCREEN.ALLBUTTON,
                CheckSize    = ALL_CHECK_SIZE,
                InitialState = PCheckBox.STATE_CHECKED,
                OnChecked    = OnCheck,
                TextStyle    = PUITuning.Fonts.TextDarkStyle,
                Margin       = ELEMENT_MARGIN
            };

            allCheckBox.OnRealize += (obj) =>
            {
                allItems = obj;
                allItems.AddComponent <ToolTip>().SetSimpleTooltip("Allow storage of all resource choices in this container");
            };
            var cp = new PPanel("Categories")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = UncategorizedFilterableRow.CARD_SPACING,
                Margin    = CARD_MARGIN
            };

            cp.OnRealize += (obj) => { childPanel = obj; };
            RootPanel     = new PPanel("UncategorizedFilterableSideScreen")
            {
                Direction = PanelDirection.Vertical,
                Margin    = BORDER_MARGIN,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = 0,
                BackColor = new Color(0, 0, 0, 255)
            }.AddChild(new PPanel("Content")
            {
                // White background for scroll bar
                Direction = PanelDirection.Vertical,
                Margin    = OUTER_MARGIN,
                Alignment = TextAnchor.UpperLeft,
                Spacing   = 0,
                BackColor = PUITuning.Colors.BackgroundLight,
                FlexSize  = Vector2.one,
            }.AddChild(new PScrollPane("Scroll")
            {
                // Scroll to select elements
                Child = new PPanel("SelectType")
                {
                    Direction = PanelDirection.Vertical,
                    Margin    = ELEMENT_MARGIN,
                    FlexSize  = new Vector2(1.0f, 0.0f),
                    Alignment = TextAnchor.UpperLeft
                }.AddChild(allCheckBox).AddChild(cp),
                ScrollHorizontal   = false,
                ScrollVertical     = true,
                AlwaysShowVertical = true,
                TrackSize          = 8.0f,
                FlexSize           = Vector2.one,
                BackColor          = PUITuning.Colors.BackgroundLight,
            }));
            rows     = new List <UncategorizedFilterableRow>(4);
            entities = new Dictionary <Tag, UncategorizedFilterableEntity>(16);
        }
Example #21
0
        public UncategorizedFilterableEntity(UncategorizedFilterableRow parent, Tag elementTag, string name)
        {
            Parent     = parent;
            ElementTag = elementTag;
            Name       = name;

            var tint   = Color.white;
            var sprite = GetStorageObjectSprite(elementTag, out tint);

            var background = new PPanel("Background")
            {
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.MiddleCenter
            }.AddChild(new PEntityToggle("Select")
            {
                OnChecked     = OnCheck,
                InitialState  = PCheckBox.STATE_CHECKED,
                Sprite        = sprite,
                SpriteTint    = tint,
                Margin        = ELEMENT_MARGIN,
                TextAlignment = TextAnchor.UpperCenter,
                CheckSize     = CHECK_SIZE,
                SpriteSize    = ICON_SIZE,
            });

            // Background
            background.OnRealize += (obj) =>
            {
                var kImage          = obj.AddComponent <KImage>();
                var ButtonBlueStyle = ScriptableObject.CreateInstance <ColorStyleSetting>();
                ButtonBlueStyle.activeColor         = new Color(0.5033521f, 0.5444419f, 0.6985294f);
                ButtonBlueStyle.inactiveColor       = new Color(0.2431373f, 0.2627451f, 0.3411765f);
                ButtonBlueStyle.disabledColor       = new Color(0.4156863f, 0.4117647f, 0.4f);
                ButtonBlueStyle.disabledActiveColor = new Color(0.625f, 0.6158088f, 0.5882353f);
                ButtonBlueStyle.hoverColor          = new Color(0.3461289f, 0.3739619f, 0.4852941f);
                ButtonBlueStyle.disabledhoverColor  = new Color(0.5f, 0.4898898f, 0.4595588f);
                kImage.colorStyleSetting            = ButtonBlueStyle;
                kImage.color = ButtonBlueStyle.inactiveColor;

                var kButton = obj.AddComponent <KButton>();
                kButton.additionalKImages = new KImage[0];
                kButton.soundPlayer       = ButtonSounds;
                kButton.bgImage           = kImage;
                kButton.colorStyleSetting = ButtonBlueStyle;
            };
            CheckBox = new PPanel("Border")
            {
                Margin    = BORDER_MARGIN,
                Direction = PanelDirection.Vertical,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 1,
                BackColor = new Color(0, 0, 0, 255)
            }.AddChild(background).Build();

            var tooltip = CheckBox.AddComponent <ToolTip>();

            tooltip.SetSimpleTooltip(name);
            tooltip.tooltipPivot          = new Vector2(0.5f, 1f);
            tooltip.tooltipPositionOffset = new Vector2(0.0f, -60f);
            tooltip.parentPositionAnchor  = new Vector2(0.5f, 0.5f);
        }
Example #22
0
        protected override void OnPrefabInit()
        {
            var margin     = new RectOffset(6, 6, 6, 6);
            var baseLayout = gameObject.GetComponent <BoxLayoutGroup>();

            if (baseLayout != null)
            {
                baseLayout.Params = new BoxLayoutParams()
                {
                    Alignment = TextAnchor.MiddleLeft,
                    Margin    = margin,
                }
            }
            ;
            var panel = new PPanel("MainPanel")
            {
                Alignment = TextAnchor.MiddleLeft,
                Direction = PanelDirection.Vertical,
                Margin    = margin,
                Spacing   = 8,
                FlexSize  = Vector2.right,
            }
            // ловить лишних не выбранных в фильтре
            .AddCheckBox(prefix, nameof(wrangle_unselected),
                         b => { if (target != null)
                                {
                                    target.wrangleUnSelected = b;
                                }
                         }, out wrangle_unselected, out _)
            // ловить старых
            .AddCheckBox(prefix, nameof(wrangle_old_aged),
                         b => { if (target != null)
                                {
                                    target.wrangleOldAged = b;
                                }
                         }, out wrangle_old_aged, out _)
            // ползун возраста
            .AddSliderBox(prefix, nameof(age_threshold), 0f, 100f,
                          f => { if (target != null)
                                 {
                                     target.ageButchThresold = f / 100f;
                                 }
                          }, out age_threshold, GetAgeTooltip)
            // ловить лишних избыточных
            .AddCheckBox(prefix, nameof(wrangle_surplus),
                         b => { if (target != null)
                                {
                                    target.wrangleSurplus = b;
                                }
                         }, out wrangle_surplus, out _)
            // ползун количества
            .AddSliderBox(prefix, nameof(creature_limit), 0f, ButcherStationOptions.Instance.max_creature_limit,
                          f => { if (target != null)
                                 {
                                     target.creatureLimit = Mathf.RoundToInt(f);
                                 }
                          }, out creature_limit)
            // оставить живым
            .AddCheckBox(prefix, nameof(leave_alive),
                         b => { if (target != null)
                                {
                                    target.leaveAlive = b;
                                }
                         }, out leave_alive, out enable_leave_alive)
            .AddChild(new PLabel("Bottom")
            {
                Text      = Strings.Get(prefix + "FILTER_LABEL"),
                TextStyle = PUITuning.Fonts.TextDarkStyle
            })
            .AddTo(gameObject);

            ContentContainer = gameObject;
            titleKey         = "STRINGS.UI.UISIDESCREENS.CAPTURE_POINT_SIDE_SCREEN.TITLE";
            base.OnPrefabInit();
            UpdateScreen();
        }
Example #23
0
        private void BuildPanel()
        {
            if (ContentContainer != null)
            {
                Destroy(ContentContainer);
                ContentContainer = null;
            }

            var margin     = new RectOffset(8, 8, 8, 8);
            var baseLayout = gameObject.GetComponent <BoxLayoutGroup>();

            if (baseLayout != null)
            {
                baseLayout.Params = new BoxLayoutParams()
                {
                    Margin    = margin,
                    Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter,
                    Spacing   = 8
                };
            }

            var mainPanel = new PPanel();

            var mainRow = new PPanel("Toggle Lock")
            {
                FlexSize  = Vector2.right,
                Alignment = TextAnchor.MiddleCenter,
                Spacing   = 10,
                Direction = PanelDirection.Horizontal,
                Margin    = margin
            };

            var lockBtn = new PButton("LockButton")
            {
                Text = "Lock"
            };

            lockBtn.SetKleiBlueStyle();
            lockBtn.OnClick = (obj) =>
            {
                if (curtain == null)
                {
                    return;
                }
                curtain.QueueStateChange(Curtain.ControlState.Locked);
            };

            var unlockBtn = new PButton("UnlockButton")
            {
                Text = "Auto"
            };

            unlockBtn.SetKleiBlueStyle();
            unlockBtn.OnClick = (obj) =>
            {
                if (curtain == null)
                {
                    return;
                }
                curtain.QueueStateChange(Curtain.ControlState.Auto);
            };

            var openBtn = new PButton("OpenButton")
            {
                Text = "Open"
            };

            openBtn.SetKleiBlueStyle();
            openBtn.OnClick = (obj) =>
            {
                if (curtain == null)
                {
                    return;
                }
                curtain.QueueStateChange(Curtain.ControlState.Open);
            };

            mainRow.AddChild(lockBtn);
            mainRow.AddChild(unlockBtn);
            mainRow.AddChild(openBtn);
            mainPanel.AddChild(mainRow);
            ContentContainer = mainPanel.Build();
            ContentContainer.SetParent(gameObject);
        }