Пример #1
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>();
        }
Пример #2
0
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            double minLimit, maxLimit;

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

            GameObject baseContent         = ToolMenu.Instance.toolParameterMenu.content;
            GameObject baseWidgetContainer = ToolMenu.Instance.toolParameterMenu.widgetContainer;

            content = Util.KInstantiateUI(baseContent, baseContent.transform.parent.gameObject);
            content.transform.GetChild(1).gameObject.SetActive(false);

            var buttonsPanel = new PRelativePanel {
                BackColor = PUITuning.Colors.ButtonPinkStyle.inactiveColor
            };

            var allButton = new PButton
            {
                Text    = "All",
                OnClick = (_) => SetAll(ToolParameterMenu.ToggleState.On)
            }.SetKleiPinkStyle();

            var noneButton = new PButton {
                Text = "None"
            };

            noneButton.OnClick += source => {
                Instance.SetAll(ToolParameterMenu.ToggleState.Off);
            };

            PCheckBox syncCheckBox = new PCheckBox {
                Text = "Auto. Sync"
            };

            syncCheckBox.SetKleiPinkStyle();
            syncCheckBox.OnRealize += realized => {
                syncMultiToggle = realized.GetComponent <MultiToggle>();
            };
            syncCheckBox.OnChecked += (source, state) => {
                if (state == PCheckBox.STATE_UNCHECKED)
                {
                    syncMultiToggle.ChangeState(PCheckBox.STATE_CHECKED);
                }

                else if (state == PCheckBox.STATE_CHECKED)
                {
                    syncMultiToggle.ChangeState(PCheckBox.STATE_UNCHECKED);
                }

                OnSyncChanged?.Invoke(syncMultiToggle.CurrentState == PCheckBox.STATE_CHECKED);
            };

            buttonsPanel.AddChild(allButton);
            buttonsPanel.SetLeftEdge(allButton, 0)
            .SetRightEdge(allButton, 0.25F);

            buttonsPanel.AddChild(noneButton);
            buttonsPanel.SetLeftEdge(noneButton, 0.25F)
            .SetRightEdge(noneButton, 0.5F);

            buttonsPanel.AddChild(syncCheckBox);
            buttonsPanel.SetLeftEdge(syncCheckBox, 0.5F)
            .SetRightEdge(syncCheckBox, 1F);

            widgetContainer = Util.KInstantiateUI(baseWidgetContainer, content, true);
            buttonsPanel.AddTo(content, 3);

            content.SetActive(false);
        }