Exemple #1
0
    private void SignButton(ButtonBoardCell button)
    {
        button.SetIcon(SignIcon);
        button.SetColor(StyleManager.Text);

        button.OnClick += () =>
        {
            ButtonToggleActive(button);
        };

        button.OnActiveChanged += (active) =>
        {
            if (OnSignButtonChange != null)
            {
                OnSignButtonChange(active);
            }

            if (!active)
            {
                return;
            }
            SignBoard signBoard = InitChildSignBoard();
            signBoard.OnInputChanged = OnSignInputChanged;
            signBoard.OnValidate     = OnSignInputValidate;

            if (OnSignDefault != null)
            {
                signBoard.SetSign(OnSignDefault());
            }
        };
    }
Exemple #2
0
    public void InitButtons()
    {
        int count = CountOfButtons != null?CountOfButtons() : 0;

        btns = new ButtonBoardCell[count];

        float width = UIConstants.ElementBottonWidth;

        // float height = UIConstants.ElementBottonHeight;

        for (int i = 0; i < count; i++)
        {
            GameObject buttonObject = GameObject.Instantiate(ButtonPrefab.gameObject);
            buttonObject.transform.SetParent(btnWrap.transform, false);
            ButtonBoardCell button = buttonObject.GetComponent <ButtonBoardCell>();
            button.Init();

            float posX = UIConstants.ElementBottonWidth * i;
            button.SetPosXAndWidth(posX, width);
            // rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, posX, width);
            // // rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, height);

            ButtonAtIndex(button, i);

            btns[i] = button;
        }

        buttonsWidth            = UIConstants.ElementBottonWidth * count;
        rectTransform.sizeDelta = new Vector2(buttonsWidth, UIConstants.ElementBottonHeight);
    }
Exemple #3
0
    private void CoordinateButton(ButtonBoardCell button)
    {
        button.SetIcon(CoordinateIcon);
        button.SetColor(StyleManager.Text);

        button.OnClick += () =>
        {
            if (OnElementClickCoordinate != null)
            {
                OnElementClickCoordinate();
            }
        };
    }
Exemple #4
0
    private void ButtonAtStyleBoard(ButtonBoardCell rootButton, ButtonBoardCell button, int buttonIndex)
    {
        button.SetIcon(StyleOfIndex(buttonIndex).Icon);
        button.SetColor(ColorOfIndex(0));

        button.OnClick += () =>
        {
            rootButton.SetIcon(StyleOfIndex(buttonIndex).Icon);

            if (OnElementClickStyle != null)
            {
                OnElementClickStyle(element, buttonIndex);
            }
        };
    }
Exemple #5
0
    private void ButtonAtColorBoard(ButtonBoardCell rootButton, ButtonBoardCell button, int buttonIndex)
    {
        button.SetIcon(null);
        Color color = ColorOfIndex(buttonIndex);

        button.SetColor(color);

        button.OnClick += () =>
        {
            rootButton.SetColor(color);

            if (OnElementClickColor != null)
            {
                OnElementClickColor(element, buttonIndex);
            }
        };
    }
Exemple #6
0
    private void DisplayButton(ButtonBoardCell button)
    {
        bool visible = OnElementVisible();

        button.SetIcon(visible ? ShowIcon : HideIcon);
        button.SetColor(StyleManager.Text);

        button.OnClick += () =>
        {
            if (OnElementClickDisplay != null)
            {
                OnElementClickDisplay(!visible);
            }

            visible = OnElementVisible();
            button.SetIcon(visible ? ShowIcon : HideIcon);
        };
    }
Exemple #7
0
    private void ButtonToggleActive(ButtonBoardCell button)
    {
        bool isActive = button.IsActive();

        if (activeRootButton)
        {
            activeRootButton.SetActive(false);
        }
        if (childBoard)
        {
            Destroy(childBoard);
        }
        activeRootButton = null;

        if (!isActive)
        {
            button.SetActive(true);
            activeRootButton = button;
        }
    }
Exemple #8
0
    private void StyleButton(ButtonBoardCell button)
    {
        button.SetIcon(StyleOfIndex(element.style).Icon);
        button.SetColor(ColorOfIndex(0));

        button.OnClick += () =>
        {
            ButtonToggleActive(button);
        };

        button.OnActiveChanged += (active) =>
        {
            if (!active)
            {
                return;
            }
            ButtonBoard styleBoard = InitChildButtonBoard();
            styleBoard.CountOfButtons = () => ElementStyle(element).Count;
            styleBoard.ButtonAtIndex  = (childButton, index) => ButtonAtStyleBoard(button, childButton, index);
            styleBoard.InitButtons();
        };
    }
Exemple #9
0
    private void ColorButton(ButtonBoardCell button)
    {
        button.SetIcon(null);
        button.SetColor(ColorOfIndex(element.color));

        button.OnClick += () =>
        {
            ButtonToggleActive(button);
        };

        button.OnActiveChanged += (active) =>
        {
            if (!active)
            {
                return;
            }
            ButtonBoard colorBoard = InitChildButtonBoard();
            colorBoard.CountOfButtons = () => StyleManager.Themes.Length + 1;
            colorBoard.ButtonAtIndex  = (childButton, index) => ButtonAtColorBoard(button, childButton, index);
            colorBoard.InitButtons();
        };
    }