Esempio n. 1
0
        public UiInputWindow(string watermark, string text)
        {
            #region Construct

            SizeToContent         = SizeToContent.WidthAndHeight;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowStyle           = WindowStyle.None;

            UiGrid root = UiGridFactory.Create(1, 2);
            {
                root.ColumnDefinitions[1].Width = GridLength.Auto;

                _textBox = UiWatermarkTextBoxFactory.Create(watermark, text);
                {
                    _textBox.Width  = 320;
                    _textBox.Margin = new Thickness(3);
                    root.AddUiElement(_textBox, 0, 0);
                }

                UiButton button = UiButtonFactory.Create("OK");
                {
                    button.Width  = 70;
                    button.Margin = new Thickness(3);
                    button.Click += OnOkButtonClick;
                    root.AddUiElement(button, 0, 1);
                }
            }
            Content = root;

            #endregion
        }
Esempio n. 2
0
        public MultiplayerScreen() : base()
        {
            background = new UiImage(this, Point.Zero, Point.Zero, "textures/ui/ui_background");
            AddComponent(background);

            serverIP = new UiTextbox(this, Point.Zero, new Point(264, 20), "multiplayer.add.ip");
            serverIP.maxCharacters  = 256;
            serverIP.isLanguageText = true;
            AddComponent(serverIP);

            serverPort = new UiTextbox(this, Point.Zero, new Point(164, 20), "multiplayer.server.port");
            serverPort.maxCharacters  = 5;
            serverPort.isLanguageText = true;
            AddComponent(serverPort);

            cancelBtn = new UiButton(this, "multiplayer.add.cancel", Point.Zero, new Point(164, 20));
            AddComponent(cancelBtn);
            cancelBtn.OnClicked += OnCancelClicked;

            joinBtn = new UiButton(this, "multiplayer.add.join", Point.Zero, new Point(164, 20));
            AddComponent(joinBtn);
            joinBtn.OnClicked += OnJoinClicked;

            serverJoinHeader = new UiLangText(this, Point.Zero, "multiplayer.add.title");
            AddComponent(serverJoinHeader);

            visible = false;
            Reset();
        }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            _button = target as UiButton;
            if (_button == null)
            {
                return;
            }

            serializedObject.Update();


            EditorGUILayout.PropertyField(_debugProperty);


            //button style change

            _bUseTween = EditorGUILayout.Toggle("UseTween", _button.UseTween);
            if (_button.UseTween != _bUseTween)
            {
                _button.SetUseTween(_bUseTween);
                DoDirty();
            }

            _isEnable = EditorGUILayout.Toggle("isEnableButton", _button.isEnable);
            if (_button.isEnable != _isEnable)
            {
                _button.isEnable = _isEnable;
                DoDirty();
            }

            serializedObject.ApplyModifiedProperties();

            base.OnInspectorGUI();
        }
Esempio n. 4
0
    void Start()
    {
        uiText.text = character.ToUpperInvariant();

        UiButton.OnClickAsObservable()
        .Subscribe(_ => DoCharacterQuickJump());
        this.ObserveEveryValueChanged(me => me.character).WhereNotNull()
        .Subscribe(newCharacter => uiText.text = newCharacter.ToUpperInvariant());

        disposables.Add(InputManager.GetInputAction(R.InputActions.ui_submit).PerformedAsObservable()
                        .Where(_ => eventSystem.currentSelectedGameObject == UiButton.gameObject)
                        .Subscribe(_ => DoCharacterQuickJump()));
    }
Esempio n. 5
0
        private void OnButtonPressed(UiButton button)
        {
            switch (button)
            {
            case UiButton.Ability1:
                CGM.Battle.ActivateEffect(0);
                break;

            case UiButton.Ability2:
                CGM.Battle.ActivateEffect(1);
                break;
            }
        }
        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);
        }
        public void OnGameTimeEnds()
        {
            PlayerScoreSystem.SetGlobalPosition(400, 200);
            GridNode.Dispose();

            Texture2D exitButtonTexture = Global.Game.Content.Load <Texture2D>("ok-button");
            UiButton  ExitButton;

            ExitButton = new UiButton();
            ExitButton.SetGlobalPosition(300, 475);
            ExitButton.SetSize(200, 50);
            ExitButton.Name             = "ExitButton";
            ExitButton.OnButtonPressed += () => Global.Game.ChangeScene(new MainMenu());
            ExitButton.SetTexture(exitButtonTexture);
            AddChild(ExitButton);
        }
Esempio n. 8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            SpriteFont font = Content.Load <SpriteFont>("file");

            UiProgressBar progressbar = new UiProgressBar(this, new Vector2(0, 200), 51, font);
            UiTextbox     textbox     = new UiTextbox(this, new Vector2(0, -100), font);
            UiRadio       radio       = new UiRadio(this, new Vector2(0, -200), "hejsan", font);
            UiCheckBox    box         = new UiCheckBox(this, new Vector2(0, 0), "textbox visible", font);

            UiButton btn = new UiButton(this, new Vector2(0, 100), "Hej", font,
                                        delegate(object sender, EventArgs args)
            {
                progressbar.Procent += (MoveUp ? 2 : -3);

                switch (progressbar.Procent)
                {
                case 100:
                    MoveUp = false;
                    break;

                case 0:
                    MoveUp = true;
                    break;
                }
                if (box.IsChecked)
                {
                    textbox.IsVisible = false;
                }
                else
                {
                    textbox.IsVisible = true;
                }
            });

            Menu1 = new Menu();
            Menu1.Add(btn);
            Menu1.Add(textbox);
            Menu1.Add(radio);
            Menu1.Add(box);
            Menu1.Add(progressbar);
        }
Esempio n. 9
0
        public override void OnInspectorGUI()
        {
            UiButton button = target as UiButton;

            button.IsEnabled = EditorGUILayout.Toggle(new GUIContent("Enabled", "Is button interactable"), button.IsEnabled);

            button._transitionType = (UiButton.TransitionType)EditorGUILayout.EnumPopup("Transition Type", button._transitionType);

            switch (button._transitionType)
            {
            case UiButton.TransitionType.None:
                break;

            case UiButton.TransitionType.ObjectsSwap:
                button._objectNormal   = (GameObject)EditorGUILayout.ObjectField("    Normal", button._objectNormal, typeof(GameObject), allowSceneObjects: true);
                button._objectHover    = (GameObject)EditorGUILayout.ObjectField("    Hover", button._objectHover, typeof(GameObject), allowSceneObjects: true);
                button._objectPressed  = (GameObject)EditorGUILayout.ObjectField("    Pressed", button._objectPressed, typeof(GameObject), allowSceneObjects: true);
                button._objectDisabled = (GameObject)EditorGUILayout.ObjectField("    Disabled", button._objectDisabled, typeof(GameObject), allowSceneObjects: true);

                button._transitionTime = EditorGUILayout.FloatField(new GUIContent("    Transition Time", ""), button._transitionTime);

                break;
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_captions"), new GUIContent("Captions [?]", "Array of text fields that can be changed dynamically"), includeChildren: true);

            button._interactionDelay = EditorGUILayout.FloatField(new GUIContent("Interaction Delay [?]", "Time in seconds to prevent undesirable interactions repeat like double click"), button._interactionDelay);

            InternalLayout.ButtonSignals
            (
                "Signals on click",
                "Select signals to dispatch on button click",
                button._signalsClick,
                (string[] result) =>
            {
                button._signalsClick = result;
                Repaint();
            }
            );

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 10
0
        void GuiSignal(GameObject child)
        {
            // If a map piece is selected from the GUI, move to place that piece
            PieceButton pieceButton = child.GetComponent <PieceButton>();

            if (pieceButton != null)
            {
                ui.commandPanel.Hide();
                ui.infoPanel.Hide();
                game.ChangeState(new PlacingPiece(pieceButton.piece));
            }

            // If a unit control is clicked from the GUI, move to move that unit
            UiButton button = child.GetComponent <UiButton>();

            if ((button != null) && (button == ui.cellInfoPanel.moveButton))
            {
                game.ChangeState(new UnitMovement(ui.cellInfoPanel.selectedUnit));
            }
        }
Esempio n. 11
0
        public PauseScreen()
        {
            //Darken overlay
            darken          = new UiImage(this, 0, 0, int.MaxValue, int.MaxValue, new Color(0, 0, 0, 123));
            darken.location = Point.Zero;
            AddComponent(darken);

            PausedText = new UiLangText(this, 0, 0, "pause.title", Color.White);
            AddComponent(PausedText);

            Resume = new UiButton(this, "pause.resume", new Point(0, 0), new Point(164, 20));
            AddComponent(Resume);
            Resume.OnClicked += OnResumeClick;

            Options = new UiButton(this, "pause.options", new Point(0, 0), new Point(164, 20));
            AddComponent(Options);
            Options.OnClicked += OnOptionsClick;

            MainMenu = new UiButton(this, "pause.mainmenu", new Point(0, 0), new Point(164, 20));
            AddComponent(MainMenu);
            MainMenu.OnClicked += OnMainMenuClick;
        }
Esempio n. 12
0
        public MainMenu()
            : base("MainMenu")
        {
            UiButton BeginGameButton;
            UiButton ExitButton;


            BeginGameButton = new UiButton();
            BeginGameButton.SetPosition(300, 400);
            BeginGameButton.SetSize(200, 50);
            BeginGameButton.Name             = "BeginGameButton";
            BeginGameButton.OnButtonPressed += () => Global.Game.ChangeScene(new GameplayScene());
            AddChild(BeginGameButton);



            ExitButton = new UiButton();
            ExitButton.SetPosition(300, 475);
            ExitButton.SetSize(200, 50);
            ExitButton.Name             = "ExitButton";
            ExitButton.OnButtonPressed += () => Global.Game.Exit();
            AddChild(ExitButton);
        }
Esempio n. 13
0
    void Button_OnUp(UiButton button, PointerEventData data)
    {
        GuiButtonTypeTEMP key = GuiButtonTypeTEMP.None;

        if (button == upButton)
        {
            key = GuiButtonTypeTEMP.Up;
        }
        else if (button == downButton)
        {
            key = (GuiButtonTypeTEMP.Down);
        }
        else if (button == leftButton)
        {
            key = (GuiButtonTypeTEMP.Left);
        }
        else if (button == rightButton)
        {
            key = (GuiButtonTypeTEMP.Right);
        }
        else if (button == resetButton)
        {
            key = (GuiButtonTypeTEMP.Reset);
        }
        else if (button == disconnectButton)
        {
            key = (GuiButtonTypeTEMP.Disconnect);
        }

        if (key != GuiButtonTypeTEMP.None)
        {
            isPressed.Remove(key);
            isPressed.Add(key, false);
        }

        OnUp?.Invoke(key);
    }
Esempio n. 14
0
    void DoTeleport(object sender, DestinationMarkerEventArgs e)
    {
        //if (ValidLocation (e.target, e.destinationPosition) && e.enableTeleport)
        //return;

        Tower tower = e.target.gameObject.GetComponent <Tower> ();

        if (tower != null)
        {
            Vector3 newPos = tower.transform.position;
            newPos.y += DEFAULT_Y;
            transform.localPosition = newPos;
            Events.OnTeleport(tower);
            return;
        }

        UiButton uiButton = e.target.gameObject.GetComponent <UiButton> ();

        if (uiButton != null)
        {
            uiButton.Clicked();
            return;
        }
    }
        private static UiElement SpawnFolderItem(UiWindow window, UiWindow parent, UiSpacer spacer, Action <Color> setColor, string folder, Func <string, bool> onClick, Action <UiWindow, UiSpacer, Action <Color> > renew)
        {
            var itemRow = new UiRow();

            var itemButton = new UiButton();

            itemRow.AddChild(itemButton);
            var itemText = new UiTextBlock();

            itemText.SetString(folder);
            itemButton.AddChild(itemText);
            itemRow.AddChild(spacer);
            itemButton.OnClick += () => {
                if (onClick(folder))
                {
                    parent.Dispose();
                }
            };

            var deleteButton = new UiButton();

            itemRow.AddChild(deleteButton);
            var deleteIcon = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.delete.text");

            deleteButton.AddChild(deleteIcon);
            deleteButton.OnClick += () => {
                var confirmWindow = new UiWindow();
                confirmWindow.Container.SetBackground(Constants.Backgrounds.Dark);
                parent.AddChildWindow(confirmWindow);

                var confirmTitle = new UiTextBlock();
                confirmWindow.AddChild(confirmTitle);
                confirmTitle.SetFont(Constants.Fonts.MyFirstCrush36);
                confirmTitle.SetColor(Color.Orange);
                confirmTitle.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteTitle"), folder));
                confirmWindow.AddChild(spacer);

                var confirmMessage = new UiTextBlock();
                confirmWindow.AddChild(confirmMessage);
                confirmMessage.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteMessage"), folder));
                confirmWindow.AddChild(spacer);

                var buttonRow = new UiRow();
                confirmWindow.AddChild(buttonRow);

                var confirmButton = new UiButton();
                buttonRow.AddChild(confirmButton);
                var confirmButtonText = new UiTextBlock();
                confirmButton.AddChild(confirmButtonText);
                confirmButtonText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.delete"));
                buttonRow.AddChild(spacer);
                confirmButton.OnClick += () => {
                    if (_favDir.FileExists(folder))
                    {
                        _favDir.DeleteFile(folder);
                    }
                    parent.Dispose();
                    renew(window, spacer, setColor);
                };

                confirmWindow.OnClose += () => {
                    parent.ListenForEscape(true);
                    parent.Show();
                    parent.StartUpdateCalls();
                };

                var cancelButton = new UiButton();
                buttonRow.AddChild(cancelButton);
                var cancelText = new UiTextBlock();
                cancelButton.AddChild(cancelText);
                cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel"));

                cancelButton.OnClick += () => { confirmWindow.Dispose(); };

                parent.Hide();
                parent.ListenForEscape(false);
                parent.StopUpdateCalls();
                confirmWindow.Show();
            };

            return(itemRow);
        }
Esempio n. 16
0
 public void buttonSingleInit(UiButton Button, int buttonNumber, int tabPage)
 {
     Button.TextBoxLocation = new Vector2(buttonDrawPos.X, buttonDrawPos.Y + (buttonNumber * (buttonSize.Y + 10)));
     Button.SetStringPos();
     tabs.Add(Button, tabPage);
     Button.TextBoxRectangleSet();
 
 }
        private static void SpawnFavoriteFolderMenuContent(UiWindow window, UiWindow favFolderMenuWindow, UiSpacer spacer,
                                                           Action <Color> setColor)
        {
            var scrollable = new UiScrollableContainer();

            scrollable.SetDimensions(400, 500);
            var favFolderMenuTitle = new UiTextBlock();

            favFolderMenuTitle.SetFont(Constants.Fonts.MyFirstCrush36);
            favFolderMenuTitle.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.favorites"));
            favFolderMenuTitle.SetColor(Color.Orange);
            favFolderMenuWindow.AddChild(favFolderMenuTitle);
            favFolderMenuWindow.AddChild(spacer);
            favFolderMenuWindow.AddChild(scrollable);

            var newFolderButton = new UiButton();
            var newFolderText   = new UiTextBlock();

            newFolderText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"));
            newFolderButton.OnClick += () => {
                favFolderMenuWindow.Dispose();
                SpawnInputTextWindow(window, spacer, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.name") + ":", ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"), value => {
                    if (_favDir.Files
                        .Any(x => x.ToLower() == value.ToLower()))
                    {
                        return(false);
                    }

                    using (var stream = _favDir
                                        .ObtainFileStream(value, FileMode.Create, FileAccess.ReadWrite)) {
                        stream.Seek(0L, SeekOrigin.Begin);
                    }

                    return(true);
                }, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists"), ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists.message"), () => {
                    SpawnFavoriteFolderMenu(window, spacer, setColor);
                });
            };
            newFolderButton.AddChild(newFolderText);
            scrollable.AddChild(newFolderButton);
            scrollable.AddChild(spacer);

            var files = _favDir.Files;

            if (files.Any())
            {
                foreach (var file in files)
                {
                    scrollable.AddChild(SpawnFolderItem(window, favFolderMenuWindow, spacer, setColor, file,
                                                        (folder) => {
                        SpawnFolderColorWindow(favFolderMenuWindow, spacer, setColor, folder);
                        return(false);
                    }, SpawnFavoriteFolderMenu));
                    scrollable.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);

            favFolderMenuWindow.AddChild(closeButton);

            closeButton.OnClick += favFolderMenuWindow.Dispose;
        }
        private static void SpawnAddToFavFromHistoryMenuContent(UiWindow window, UiWindow favFolderMenuWindow, UiSpacer spacer,
                                                                Action <Color> setColor)
        {
            var scrollable = new UiScrollableContainer();

            scrollable.SetDimensions(400, 500);
            var favFolderMenuTitle = new UiTextBlock();

            favFolderMenuTitle.SetFont(Constants.Fonts.MyFirstCrush36);
            favFolderMenuTitle.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.favorites"));
            favFolderMenuTitle.SetColor(Color.Orange);
            favFolderMenuWindow.AddChild(favFolderMenuTitle);
            favFolderMenuWindow.AddChild(spacer);
            favFolderMenuWindow.AddChild(scrollable);

            var newFolderButton = new UiButton();
            var newFolderText   = new UiTextBlock();

            newFolderText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"));
            newFolderButton.OnClick += () => {
                favFolderMenuWindow.StopUpdateCalls();
                favFolderMenuWindow.Dispose();
                SpawnInputTextWindow(window, spacer, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.name") + ":", ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"), value => {
                    if (_favDir.Files.Any(x => x.ToLower() == value.ToLower()))
                    {
                        return(false);
                    }

                    using (var stream = _favDir
                                        .ObtainFileStream(value, FileMode.Create, FileAccess.ReadWrite)) {
                        stream.Seek(0L, SeekOrigin.Begin);
                    }

                    return(true);
                }, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists"), ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists.message"), () => {
                    SpawnAddToFavFromHistoryMenu(window, spacer, setColor);
                });
            };
            newFolderButton.AddChild(newFolderText);
            scrollable.AddChild(newFolderButton);
            scrollable.AddChild(spacer);

            var files = _favDir.Files;

            if (files.Any())
            {
                foreach (var file in files)
                {
                    scrollable.AddChild(SpawnFolderItem(window, favFolderMenuWindow, spacer, setColor, file,
                                                        (folder) => {
                        var values = new List <string>();
                        if (_favDir.FileExists(folder))
                        {
                            values.AddRange(
                                File.ReadAllLines(
                                    Path.Combine(_favDir.GetPath(Path.DirectorySeparatorChar), folder)));
                        }

                        if (!values.Contains($"{_historyColor.R:X2}{_historyColor.G:X2}{_historyColor.B:X2}"))
                        {
                            values.Add($"{_historyColor.R:X2}{_historyColor.G:X2}{_historyColor.B:X2}");
                        }

                        File.WriteAllLines(Path.Combine(_favDir.GetPath(Path.DirectorySeparatorChar), folder), values);
                        return(true);
                    }, SpawnAddToFavFromHistoryMenu));
                    scrollable.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);

            scrollable.AddChild(closeButton);

            closeButton.OnClick += () => {
                favFolderMenuWindow.Dispose();
                window.ListenForEscape(true);
                window.Show();
                window.StartUpdateCalls();
            };
        }
        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;
        }
        public ColorPickerWindow(Color?_default = null)
        {
            if (_default != null)
            {
                _color = _default.Value;
            }

            _current = new UiWindow();

            _current.ListenForEscape(true);

            _current.Container.SetBackground(Constants.Backgrounds.Dark);

            var picker = new UiColorPicker();

            var currentColor  = new UiTexture2D(context => Helpers.GetTexture(context));
            var hoverColor    = new UiTexture2D(context => Helpers.GetTexture(context));
            var selectedColor = new UiTexture2D(context => Helpers.GetTexture(context));

            selectedColor.SetColor(_color);
            currentColor.SetColor(_color);

            var row = new UiRow();

            row.AddChild(picker);

            var column = new UiColumn();

            var spacer = new UiSpacer();

            spacer.SetHeight(20);
            spacer.SetWidth(20);

            row.AddChild(spacer);

            var mouseText = new UiTextBlock();

            mouseText.SetColor(Color.White);
            mouseText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.mouse"));
            column.AddChild(mouseText);
            column.AddChild(hoverColor);
            column.AddChild(spacer);

            var selectedText = new UiTextBlock();

            selectedText.SetColor(Color.White);
            selectedText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.selected"));
            column.AddChild(selectedText);
            column.AddChild(selectedColor);
            column.AddChild(spacer);

            var currentText = new UiTextBlock();

            currentText.SetColor(Color.White);
            currentText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.current"));
            column.AddChild(currentText);
            column.AddChild(currentColor);

            row.AddChild(column);

            _current.AddChild(row);

            _current.AddChild(spacer);

            var colorRow = new UiRow();

            UiTextInput colorHex = null;

            var colorR = new UiNumberInput();

            colorR.SetItteration(1.0f);
            colorR.SetMin(0);
            colorR.SetMax(255);
            colorR.SetValue(_color.R);
            colorR.SetBackgroundColors(Color.Red, Color.Pink);

            colorR.OnChange += value => {
                if (byte.TryParse(value.ToString(), out var val))
                {
                    _color.R = val;
                    colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}");
                    selectedColor.SetColor(_color);
                }
            };
            var colorG = new UiNumberInput();

            colorG.SetItteration(1.0f);
            colorG.SetMin(0);
            colorG.SetMax(255);
            colorG.SetValue(_color.G);
            colorG.SetBackgroundColors(Color.Green, Color.LimeGreen);

            colorG.OnChange += value => {
                if (byte.TryParse(value.ToString(), out var val))
                {
                    _color.G = val;
                    colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}");
                    selectedColor.SetColor(_color);
                }
            };

            var colorB = new UiNumberInput();

            colorB.SetItteration(1.0f);
            colorB.SetMin(0);
            colorB.SetMax(255);
            colorB.SetValue(_color.B);
            colorB.SetBackgroundColors(Color.Blue, Color.LightBlue);
            colorB.SetTextColors(Color.White, Color.Black);

            colorB.OnChange += value => {
                if (byte.TryParse(value.ToString(), out var val))
                {
                    _color.B = val;
                    colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}");
                    selectedColor.SetColor(_color);
                }
            };

            var colorHexRow = new UiRow();

            var hex = new UiTextBlock();

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

            colorHex = new UiTextInput();
            colorHex.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}");
            colorHex.SetBackgroundColor(new Color(237, 207, 154));
            colorHex.SetTextColor(Color.Black);
            colorHex.SetActiveTextColor(Color.Black);
            colorHex.SetBackground(Constants.Backgrounds.TextInput);
            colorHex.SetLimit(6);
            colorHex.InputCheck += key => {
                switch (key.ToString().ToUpper())
                {
                default:
                    return(false);

                case "A":
                case "B":
                case "C":
                case "D":
                case "E":
                case "F":
                case "0":
                case "1":
                case "2":
                case "3":
                case "4":
                case "5":
                case "6":
                case "7":
                case "8":
                case "9":
                    return(true);
                }
            };

            colorHex.OnChange += text => {
                if (text.IsNullOrEmpty())
                {
                    _color = Color.Black;
                }
                else
                {
                    _color = ColorMath.ParseString(text);
                }
                selectedColor.SetColor(_color);
                colorR.ForceSetValue(_color.R);
                colorG.ForceSetValue(_color.G);
                colorB.ForceSetValue(_color.B);
            };

            picker.ColorClick += color => {
                selectedColor.SetColor(color);
                _color = color;
                colorR.ForceSetValue(_color.R);
                colorG.ForceSetValue(_color.G);
                colorB.ForceSetValue(_color.B);
                colorHex.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}");
            };

            colorRow.AddChild(colorR);
            colorRow.AddChild(spacer);
            colorRow.AddChild(colorG);
            colorRow.AddChild(spacer);
            colorRow.AddChild(colorB);

            _current.AddChild(colorRow);
            _current.AddChild(spacer);
            colorHexRow.AddChild(hex);
            colorHexRow.AddChild(colorHex);
            _current.AddChild(colorHexRow);

            _current.AddChild(spacer);

            var confirmButton = new UiButton();

            confirmButton.SetBackground(Constants.Backgrounds.Button);

            var confirmText = new UiTextBlock();

            confirmText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.setColor"));

            confirmButton.AddChild(confirmText);

            confirmButton.OnClick += () => {
                OnColorSet?.Invoke(_color);

                if (_colorHistory.Contains(_color))
                {
                    _colorHistory.Remove(_color);
                }

                _colorHistory.Add(_color);

                _current.Dispose();
            };

            var cancelButton = new UiButton();

            cancelButton.SetBackground(Constants.Backgrounds.Button);

            var cancelText = new UiTextBlock();

            cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel"));

            cancelButton.AddChild(cancelText);

            cancelButton.OnClick += () => {
                _current.Dispose();
            };

            var buttonRow = new UiRow();

            buttonRow.AddChild(confirmButton);
            buttonRow.AddChild(spacer);
            buttonRow.AddChild(cancelButton);
            buttonRow.AddChild(spacer);

            var favButton = new UiButton();

            favButton.SetBackground(Constants.Backgrounds.Button);
            var favPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.favorites");

            favButton.AddChild(favPic);
            buttonRow.AddChild(favButton);
            buttonRow.AddChild(spacer);

            favButton.OnClick += () => {
                SpawnFavoriteFolderMenu(_current, spacer, color => {
                    colorHex.ForceSetValue($"{color.R:X2}{color.G:X2}{color.B:X2}", true);
                });
            };

            var historyButton = new UiButton();

            historyButton.SetBackground(Constants.Backgrounds.Button);
            var historyPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.history");

            historyButton.AddChild(historyPic);
            buttonRow.AddChild(historyButton);

            historyButton.OnClick += () => {
                SpawnHistoryWindow(_current, spacer, color => {
                    colorHex.ForceSetValue($"{color.R:X2}{color.G:X2}{color.B:X2}", true);
                });
            };

            _current.AddChild(buttonRow);

            picker.ColorHover += color => { hoverColor.SetColor(color); };

            _current.OnClose += () => {
                OnClose?.Invoke();
            };
        }
Esempio n. 21
0
        public InfoScreen(GraphicsDevice graphicsDevice)
        {
            tabs = new UiTabs(graphicsDevice, Art.DebugFont, 8, new Vector2(200, 200), new string[8] { "", "", "", "", "", "", "", "" }, Art.tabTestTexture, Art.ButtonEffectTexture, new Vector2(100, 50));
            backButton = new UiButton(Art.UiFont, new Vector2(20, 800), new Vector2(100, 50 ), Art.TextBoxBackGround, Art.ButtonEffectTexture, "backButton", true);

            backButton.SetButtonState = UiButton.UiButtonStates.Button_Up;

            tabs.tabList[0].tabButton.TextBoxTexture = Art.ChurchilPort;
            tabs.tabList[1].tabButton.TextBoxTexture = Art.StalinPort;
            tabs.tabList[2].tabButton.TextBoxTexture = Art.FrenchiePort;
            tabs.tabList[3].tabButton.TextBoxTexture = Art.HitlerPort;
            tabs.tabList[4].tabButton.TextBoxTexture = Art.MussoPort;
            tabs.tabList[5].tabButton.TextBoxTexture = Art.HiroHitoPort;
            tabs.tabList[6].tabButton.TextBoxTexture = Art.AlliesPort;
            tabs.tabList[7].tabButton.TextBoxTexture = Art.AxisPort;

            backButton.StringText = "Back";
            backButton.StringOffset = new Vector2(10);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Churchill, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[0], 0);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Stalin, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[1], 1);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, CharlesDeGaulle, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[2], 2);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Hitler, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[3], 3);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Mussolini, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[4], 4);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, HiroHito, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[5], 5);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Allies, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[6], 6);

            InfoBoxes.Add(new UiTextBox(Art.InfoFont, Axis, new Vector2(200, 255), Color.White, Art.TextBoxBackGround, false));
            tabs.Add(InfoBoxes[7], 7);

            
            foreach (UiTextBox box in InfoBoxes)
            {
                box.TextBoxSize = new Vector2(900, 500);
                box.StringOffset = new Vector2(20, 10);
                box.LineWrapper();
            }

        }
 private void ButtonPressed(UiButton button, int dispenseIndex = -1)
 {
     SendMessage(new UiButtonPressedMessage(button, dispenseIndex));
 }
            public readonly int DispenseIndex; //Index of dispense button / reagent being pressed. Only used when a dispense button is pressed.

            public UiButtonPressedMessage(UiButton button, int dispenseIndex)
            {
                Button        = button;
                DispenseIndex = dispenseIndex;
            }
 private void ButtonPressed(UiButton button)
 {
     SendMessage(new UiButtonPressedMessage(button));
 }
Esempio n. 25
0
 public void OpenLink(UiButton sender)
 {
     Platform.OpenWebsite(sender.Text.StringValue);
 }
        private static void SpawnInputTextWindow(UiWindow window, UiSpacer spacer,
                                                 string labelText, string titleText, Func <string, bool> validationAndSuccess, string errorTitle, string errorMessage, Action onClose)
        {
            var textInputWindow = new UiWindow();

            textInputWindow.Container.SetBackground(Constants.Backgrounds.Dark);
            textInputWindow.ListenForEscape(true);

            textInputWindow.OnClose += () => {
                onClose();
            };

            var title = new UiTextBlock();

            title.SetColor(Color.Orange);
            title.SetFont(Constants.Fonts.MyFirstCrush36);
            title.SetString(titleText);
            textInputWindow.AddChild(title);
            textInputWindow.AddChild(spacer);

            var inputRow = new UiRow();

            textInputWindow.AddChild(inputRow);
            textInputWindow.AddChild(spacer);

            var label = new UiTextBlock();

            label.SetString(labelText);
            inputRow.AddChild(label);
            inputRow.AddChild(spacer);

            var input = new UiTextInput();

            input.SetBackgroundColor(new Color(237, 207, 154));
            input.SetTextColor(Color.Black);
            input.SetActiveTextColor(Color.Black);
            input.SetBackground(Constants.Backgrounds.TextInput);
            inputRow.AddChild(input);
            input.SetSize(300);
            input.SetLimit(25);

            var buttonRow = new UiRow();

            textInputWindow.AddChild(buttonRow);

            var createButton = new UiButton();

            buttonRow.AddChild(createButton);
            buttonRow.AddChild(spacer);
            var createText = new UiTextBlock();

            createText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.create"));
            createButton.AddChild(createText);

            createButton.OnClick += () => {
                if (validationAndSuccess(input.GetValue()))
                {
                    textInputWindow.Dispose();
                }
                else
                {
                    var errorWindow = new UiWindow();
                    errorWindow.Container.SetBackground(Constants.Backgrounds.Dark);

                    var errorTitleText = new UiTextBlock();
                    errorTitleText.SetColor(Color.Orange);
                    errorTitleText.SetFont(Constants.Fonts.MyFirstCrush36);
                    errorTitleText.SetString(errorTitle);
                    errorWindow.AddChild(errorTitleText);
                    errorWindow.AddChild(spacer);

                    var message = new UiTextBlock();
                    message.SetString(errorMessage);
                    message.SetColor(Color.Red);
                    errorWindow.AddChild(message);
                    errorWindow.AddChild(spacer);

                    var okButton = new UiButton();
                    var okText   = new UiTextBlock();
                    okText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.ok"));
                    okButton.AddChild(okText);
                    okButton.OnClick += () => {
                        textInputWindow.StartUpdateCalls();
                        errorWindow.Dispose();
                    };
                    errorWindow.AddChild(okButton);

                    textInputWindow.AddChildWindow(errorWindow);
                    textInputWindow.ListenForEscape(false);
                    textInputWindow.StopUpdateCalls();
                    errorWindow.ListenForEscape(true);

                    errorWindow.OnClose += () => {
                        textInputWindow.ListenForEscape(true);
                        textInputWindow.StartUpdateCalls();
                    };

                    errorWindow.Show();
                }
            };

            var cancelButton = new UiButton();

            buttonRow.AddChild(cancelButton);
            var cancelText = new UiTextBlock();

            cancelButton.AddChild(cancelText);
            cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel"));

            cancelButton.OnClick += () => {
                textInputWindow.Dispose();
            };

            window.Hide();
            window.ListenForEscape(false);
            window.AddChildWindow(textInputWindow);
            window.StopUpdateCalls();
            textInputWindow.Show();
        }
Esempio n. 27
0
 public CloningPodUiButtonPressedMessage(UiButton button, int?scanId)
 {
     Button = button;
     ScanId = scanId;
 }
Esempio n. 28
0
 public void ButtonPressed(UiButton button)
 {
     SendMessage(new IdButtonPressedMessage(button));
 }
 public UiButtonPressedMessage(UiButton button)
 {
     Button = button;
 }
Esempio n. 30
0
 public void OpenLink(UiButton button)
 {
     Platform.OpenWebsite(button.Text.StringValue);
 }
 public void ButtonPressed(UiButton button, int dispenseIndex = -1)
 {
     SendMessage(new UiButtonPressedMessage(button));
 }
Esempio n. 32
0
 private void ButtonPressed(UiButton button)
 {
     SendMessage(new UiButtonPressedMessage(button));
     // If we get client-side power stuff then we can predict the button presses but for now we won't as it stuffs
     // the pressure lerp up.
 }