Exemple #1
0
 private void Setup()
 {
     owner                     = (ForestBrushPanel)parent;
     autoLayout                = true;
     autoLayoutDirection       = LayoutDirection.Vertical;
     autoFitChildrenVertically = true;
     autoLayoutPadding         = new RectOffset(0, 0, 10, 0);
     width                     = parent.width;
 }
Exemple #2
0
        public override void Start()
        {
            base.Start();
            owner = (ForestBrushPanel)parent;
            selectBrushDropDown = owner.BrushSelectSection.SelectBrushDropDown;

            Filtering = new Filtering();

            width                     = owner.width;
            autoLayout                = true;
            autoLayoutDirection       = LayoutDirection.Vertical;
            autoFitChildrenVertically = true;
            autoLayoutStart           = LayoutStart.TopLeft;
            autoLayoutPadding         = new RectOffset(0, 0, 0, 10);

            topPanel                             = AddUIComponent <UIPanel>();
            topPanel.height                      = 30f;
            topPanel.zOrder                      = 0;
            topPanel.autoLayout                  = true;
            topPanel.autoLayoutDirection         = LayoutDirection.Horizontal;
            topPanel.autoFitChildrenHorizontally = true;
            topPanel.autoLayoutStart             = LayoutStart.TopLeft;
            topPanel.autoLayoutPadding           = new RectOffset(10, 0, 0, 0);

            centerPanel                           = AddUIComponent <UIPanel>();
            centerPanel.width                     = width;
            centerPanel.zOrder                    = 1;
            centerPanel.autoLayout                = true;
            centerPanel.autoLayoutDirection       = LayoutDirection.Vertical;
            centerPanel.autoFitChildrenVertically = true;
            centerPanel.autoLayoutStart           = LayoutStart.TopLeft;
            centerPanel.autoLayoutPadding         = new RectOffset(10, 0, 0, 0);

            bottomPanel        = AddUIComponent <UIPanel>();
            bottomPanel.height = 30f;
            bottomPanel.width  = 400f;
            bottomPanel.zOrder = 2;

            SetupRenameField();
            SetupButtons();
            SetupListSection();
            SetupSearchFieldSection();

            LoadBrush(UserMod.Settings.SelectedBrush);

            if (!UserMod.Settings.BrushEditOpen)
            {
                owner.BrushSelectSection.UnfocusEditSectionButton();
                Hide();
            }
        }
        public override void Start()
        {
            base.Start();
            owner                       = (ForestBrushPanel)parent;
            height                      = 30f;
            autoLayout                  = true;
            autoLayoutDirection         = LayoutDirection.Horizontal;
            autoFitChildrenHorizontally = true;
            autoLayoutStart             = LayoutStart.TopLeft;
            autoLayoutPadding           = new RectOffset(10, 0, 0, 0);

            SetupDropDown();
            SetupButtons();

            LoadBrush(UserMod.Settings.SelectedBrush);
        }
        private void Setup()
        {
            width                = parent.width;
            height               = 122f;
            autoLayout           = true;
            autoLayoutDirection  = LayoutDirection.Horizontal;
            padding              = new RectOffset(10, 0, 0, 0);
            autoLayoutPadding    = new RectOffset(0, 0, 0, 0);
            isInteractive        = true;
            builtinKeyNavigation = true;
            relativePosition     = new Vector2(410.0f, 0.0f);

            ScrollablePanel                      = AddUIComponent <UIScrollablePanel>();
            ScrollablePanel.zOrder               = 0;
            ScrollablePanel.width                = 366f;
            ScrollablePanel.height               = height;
            ScrollablePanel.autoLayout           = true;
            ScrollablePanel.wrapLayout           = true;
            ScrollablePanel.clipChildren         = true;
            ScrollablePanel.backgroundSprite     = "TextFieldPanel";
            ScrollablePanel.autoLayoutDirection  = LayoutDirection.Horizontal;
            ScrollablePanel.autoLayoutPadding    = new RectOffset(2, 2, 2, 2);
            ScrollablePanel.color                = new Color32(255, 255, 255, 255);
            ScrollablePanel.isInteractive        = true;
            ScrollablePanel.builtinKeyNavigation = true;
            ScrollablePanel.scrollWheelDirection = UIOrientation.Vertical;
            ScrollablePanel.scrollWithArrowKeys  = true;
            Dictionary <string, Texture2D> brushes = ForestBrush.Instance.GetBrushBitmaps();

            foreach (KeyValuePair <string, Texture2D> brush in brushes)
            {
                UIButton button = ScrollablePanel.AddUIComponent <UIButton>();
                button.atlas          = ResourceLoader.Atlas;
                button.normalBgSprite = ResourceLoader.GenericPanel;
                if (UserMod.Settings.SelectedBrush != null &&
                    UserMod.Settings.SelectedBrush.Options != null &&
                    UserMod.Settings.SelectedBrush.Options.BitmapID == brush.Key)
                {
                    button.normalBgSprite = string.Empty;
                }
                button.color        = new Color32(170, 170, 170, 255);
                button.hoveredColor = new Color32(210, 210, 210, 255);
                button.focusedColor = Color.white;
                button.pressedColor = Color.white;
                button.size         = new Vector2(57.0f, 57.0f);
                UITextureSprite sprite = button.AddUIComponent <UITextureSprite>();
                sprite.size             = button.size - new Vector2(4.0f, 4.0f);
                sprite.relativePosition = new Vector2(2.0f, 2.0f);
                sprite.texture          = brush.Value;
                button.objectUserData   = brush.Key;
                button.eventClicked    += Button_eventClicked;
                BrushButtons.Add(brush.Key, button);
            }

            UIScrollbar scrollbar = AddUIComponent <UIScrollbar>();

            scrollbar.zOrder          = 1;
            scrollbar.width           = 13f;
            scrollbar.height          = ScrollablePanel.height;
            scrollbar.orientation     = UIOrientation.Vertical;
            scrollbar.minValue        = 0;
            scrollbar.value           = 0;
            scrollbar.incrementAmount = 61;

            UISlicedSprite tracSprite = scrollbar.AddUIComponent <UISlicedSprite>();

            tracSprite.atlas            = ResourceLoader.Atlas;
            tracSprite.relativePosition = new Vector3(0, 0);
            tracSprite.autoSize         = true;
            tracSprite.size             = tracSprite.parent.size;
            tracSprite.fillDirection    = UIFillDirection.Vertical;
            tracSprite.spriteName       = ResourceLoader.LevelBarBackground;

            scrollbar.trackObject = tracSprite;

            UISlicedSprite thumbSprite = tracSprite.AddUIComponent <UISlicedSprite>();

            thumbSprite.atlas            = ResourceLoader.Atlas;
            thumbSprite.relativePosition = Vector2.zero;
            thumbSprite.fillDirection    = UIFillDirection.Vertical;
            thumbSprite.autoSize         = true;
            thumbSprite.width            = 13f;
            thumbSprite.spriteName       = ResourceLoader.LevelBarForeground;

            scrollbar.thumbObject = thumbSprite;

            ScrollablePanel.verticalScrollbar = scrollbar;

            owner = (ForestBrushPanel)parent;
        }