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>(); }
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>(); }
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); }