Пример #1
0
        private static void SpawnColorItem(Color color, UiSpacer spacer, out UiColumn colorSquare, out UiTextBlock colorText)
        {
            colorSquare = new UiColumn();
            var colorSquare1 = new UiTexture2D(graphics => Helpers.GetTexture(graphics));

            colorSquare1.SetColor(color);
            colorSquare.AddChild(UiSpacer.GetSpacer(0, 5));
            colorSquare.AddChild(colorSquare1);

            colorText = new UiTextBlock();
            colorText.SetString($"{color.R:X2}{color.G:X2}{color.B:X2}");
        }
Пример #2
0
        private static void SpawnHistoryColorItem(UiWindow window, UiWindow parentwindow, Color color, UiSpacer spacer, Action <Color> setColor,
                                                  Action <UiWindow, UiSpacer, Action <Color> > renew, Action <Color> remove, bool showAddFav, out UiColumn colorSquare, out UiTextBlock colorText, out UiRow buttons)
        {
            SpawnColorItem(color, spacer, out colorSquare, out colorText);

            var buttonSpacer = UiSpacer.GetSpacer(5, 5);

            buttons = new UiRow();

            if (showAddFav)
            {
                var addToFavButton = new UiButton();
                addToFavButton.SetBackground(Constants.Backgrounds.Button);
                var addToFavePic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.addFavorite");
                addToFavButton.AddChild(addToFavePic);
                buttons.AddChild(addToFavButton);
                buttons.AddChild(buttonSpacer);

                addToFavButton.OnClick += () => {
                    _historyColor = color;
                    SpawnAddToFavFromHistoryMenu(parentwindow, spacer, setColor);
                };
            }

            var setButton = new UiButton();

            setButton.SetBackground(Constants.Backgrounds.Button);
            var setPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.set");

            setButton.AddChild(setPic);
            setButton.OnClick += () => {
                setColor(color);
                parentwindow.Dispose();
            };
            buttons.AddChild(setButton);
            buttons.AddChild(buttonSpacer);

            var deleteButton = new UiButton();

            deleteButton.SetBackground(Constants.Backgrounds.Button);
            var deletePic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.delete");

            deleteButton.AddChild(deletePic);
            deleteButton.OnClick += () => {
                remove(color);
                parentwindow.Dispose();
                renew(window, spacer, setColor);
            };
            buttons.AddChild(deleteButton);
        }
Пример #3
0
        private static void SpawnColorWindowContent(UiWindow window, UiWindow historyWindow, UiSpacer spacer,
                                                    Action <Color> setColor, Action <UiWindow, UiSpacer, Action <Color> > renew, Action <Color> remove, List <Color> colors, string title, string noColorText, bool showAddToFav = false)
        {
            var historyTitle = new UiTextBlock();

            historyTitle.SetString(title);
            historyTitle.SetColor(Color.Orange);
            historyTitle.SetFont(Constants.Fonts.MyFirstCrush36);
            historyWindow.AddChild(historyTitle);
            historyWindow.AddChild(spacer);

            if (!colors.Any())
            {
                var historyText = new UiTextBlock();
                historyText.SetString(noColorText);
                historyWindow.AddChild(historyText);
            }
            else
            {
                var column1        = new UiRow();
                var column1Squares = new UiColumn();
                var column1Text    = new UiColumn();
                var column1Buttons = new UiColumn();
                column1.AddChild(column1Squares);
                column1.AddChild(UiSpacer.GetSpacer());
                column1.AddChild(column1Text);
                column1.AddChild(UiSpacer.GetSpacer());
                column1.AddChild(column1Buttons);

                var column2        = new UiRow();
                var column2Squares = new UiColumn();
                var column2Text    = new UiColumn();
                var column2Buttons = new UiColumn();
                column2.AddChild(column2Squares);
                column2.AddChild(UiSpacer.GetSpacer());
                column2.AddChild(column2Text);
                column2.AddChild(UiSpacer.GetSpacer());
                column2.AddChild(column2Buttons);

                var column = 1;
                var count  = 0;
                foreach (var color in colors)
                {
                    SpawnHistoryColorItem(window, historyWindow, color, spacer, setColor, renew, remove, showAddToFav, out var colorSquare, out var colorText, out var buttons);
                    if (count >= 2)
                    {
                        if (column == 1)
                        {
                            column1Squares.AddChild(UiSpacer.GetSpacer(0, 20));
                            column1Text.AddChild(UiSpacer.GetSpacer(0, 12));
                            column1Buttons.AddChild(UiSpacer.GetSpacer(0, 15));
                        }
                        else
                        {
                            column2Squares.AddChild(UiSpacer.GetSpacer(0, 20));
                            column2Text.AddChild(UiSpacer.GetSpacer(0, 12));
                            column2Buttons.AddChild(UiSpacer.GetSpacer(0, 15));
                        }
                    }

                    if (column == 1)
                    {
                        column1Squares.AddChild(colorSquare);
                        column1Text.AddChild(colorText);
                        column1Buttons.AddChild(buttons);
                        column = 2;
                    }
                    else
                    {
                        column2Squares.AddChild(colorSquare);
                        column2Text.AddChild(colorText);
                        column2Buttons.AddChild(buttons);
                        column = 1;
                    }

                    count++;
                }
                var columnRow = new UiRow();
                columnRow.AddChild(column1);
                if (colors.Count >= 2)
                {
                    columnRow.AddChild(UiSpacer.GetSpacer(10, 0));
                    columnRow.AddChild(column2);
                }

                var scrollable = new UiScrollableContainer();
                scrollable.AddChild(columnRow);
                scrollable.SetDimensions(600, 400);
                historyWindow.AddChild(scrollable);
            }

            historyWindow.AddChild(spacer);

            var closeButton = new UiButton();

            closeButton.SetBackground(Constants.Backgrounds.Button);

            var closeText = new UiTextBlock();

            closeText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.close"));

            closeButton.AddChild(closeText);

            historyWindow.AddChild(closeButton);

            closeButton.OnClick += historyWindow.Dispose;
        }
Пример #4
0
        public UiNumberInput()
        {
            _textInput = new UiTextInput();
            _textInput.SetBackground(Constants.Backgrounds.TextInput);
            _textInput.SetTextColor(Color.Black);
            _textInput.SetActiveTextColor(Color.Black);
            _textInput.InputCheck += ch => {
                switch (ch)
                {
                default:
                    return(false);

                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                case '.':
                    return(true);
                }
            };
            _textInput.OnChange += text => {
                if (float.TryParse(text, out var value))
                {
                    SetValue(value, true);
                }
            };
            _displayRow = new UiRow();

            var downButton = new UiButton();

            downButton.SetBackground(Constants.Backgrounds.Button);
            downButton.OnHold += () => {
                SetValue(_value - _itterations, true);
            };
            downButton.SetTextColor(Color.Black);
            downButton.SetActiveTextColor(Color.Black);
            var downText = new UiTextBlock();

            downText.SetString("-");
            downButton.AddChild(downText);

            var spacer = UiSpacer.GetSpacer(5, 5);

            _displayRow.AddChild(downButton);
            _displayRow.AddChild(spacer);

            base.AddChild(_displayRow);
            var upButton = new UiButton();

            upButton.SetBackground(Constants.Backgrounds.Button);
            upButton.OnHold += () => {
                SetValue(_value + _itterations, true);
            };

            var inputColumn = new UiColumn();

            inputColumn.AddChild(spacer);
            inputColumn.AddChild(_textInput);
            inputColumn.AddChild(spacer);

            _displayRow.AddChild(inputColumn);
            _displayRow.AddChild(spacer);
            _displayRow.AddChild(upButton);
            upButton.SetTextColor(Color.Black);
            upButton.SetActiveTextColor(Color.Black);
            var upText = new UiTextBlock();

            upText.SetString("+");
            upButton.AddChild(upText);

            SetSize(60, 30);
        }