public override void draw(SpriteBatch spriteBatch)
        {
            if (_debouceWaitTime < 10)
            {
                _debouceWaitTime++;
            }
            else
            {
                RegisterMouseEvents();
            }

            Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height, false, true);
            upperRightCloseButton?.draw(spriteBatch);
            DrawHeader(spriteBatch);
            if (!_inputInitiated)
            {
                InitiateInput();
            }
            _resetRecipesCheckbox.Draw(spriteBatch);
            _useExperienceMultiplierCheckbox.Draw(spriteBatch);
            _tierOneCostEditor.Draw(spriteBatch);
            _tierTwoCostEditor.Draw(spriteBatch);
            _pointsPerPrestigeEditor.Draw(spriteBatch);
            _painlessPrestigeModeCheckbox.Draw(spriteBatch);
            _experiencePerPainlessPrestigeEditor.Draw(spriteBatch);
            Mouse.DrawCursor(spriteBatch);
        }
 /// <summary>Draw a checkbox to the screen, including any position updates needed.</summary>
 /// <param name="batch">The sprite batch being drawn.</param>
 /// <param name="font">The font to use for the checkbox label.</param>
 /// <param name="checkbox">The checkbox to draw.</param>
 /// <param name="x">The top-left X position to start drawing from.</param>
 /// <param name="y">The top-left Y position to start drawing from.</param>
 /// <param name="textKey">The translation key for the checkbox label.</param>
 private void DrawAndPositionCheckbox(SpriteBatch batch, Checkbox checkbox, int x, int y, SpriteFont font = null, string textKey = null)
 {
     checkbox.X     = x;
     checkbox.Y     = y;
     checkbox.Width = 24;
     checkbox.Draw(batch);
     if (textKey != null && font != null)
     {
         string label = textKey;
         batch.DrawString(font, label, new Vector2(x + 7 + checkbox.Width, y), checkbox.Value ? Color.Red : Color.Black);
     }
 }
Exemple #3
0
        static void Main(string[] args)
        {
            RenderWindow window = new RenderWindow(new VideoMode(1280, 720), "Checkbox", Styles.Titlebar | Styles.Close);

            window.SetFramerateLimit(60);
            window.SetVerticalSyncEnabled(true);
            window.Closed += (_, __) => window.Close();

            Checkbox checkbox = new Checkbox(window, new Vector2f(150, 150));

            checkbox.Width          = 310;
            checkbox.Height         = 310;
            checkbox.CrossThickness = 20f;

            Button button = new Button(window, checkbox.Position + new Vector2f(checkbox.Width + 5, 0), new Vector2f(100, 100));

            button.ButtonPressed += () =>
            {
                button.CenterColor = new Color((byte)new Random().Next(255), (byte)new Random().Next(255),
                                               (byte)new Random().Next(255));
            };
            button.CenterColor = Color.Blue;

            Button button2 = new Button(window, button.Position + new Vector2f(0, button.Height + 5), button.Size);

            button2.CenterColor = Color.Green;

            Button button3 = new Button(window, button2.Position + new Vector2f(0, button2.Height + 5), button2.Size);


            TextInput textInput = new TextInput(window, button.Position + new Vector2f(button.Width + 5, 0), 500, 100, new Font("Arial.ttf"));

            Slider slider = new Slider(window, textInput.Position + new Vector2f(0, textInput.Height + 5), 500, 100, 0, 100);

            Dropdown dropdown = new Dropdown(window, checkbox.Position + new Vector2f(0, checkbox.Height + 5), new Font("Arial.ttf"), 59,
                                             "Lorem Ipsum",
                                             "Lorem Larum",
                                             "Lorem Lurum",
                                             "Lorem Durum"
                                             );

            TextBox textBox = new TextBox(window, slider.Position + new Vector2f(0, slider.Height + 5), textInput.Width, textInput.Height, new Font("Arial.ttf"), (uint)Math.Round(textInput.Height * 0.75));

            textBox.Output("DURUM");
            textBox.TextColor = Color.Black;

            Graphic graphic = new Graphic(window, "background.png", textBox.Position + new Vector2f(0, textBox.Height + 5), new Vector2f(0, 0), new Vector2f(textBox.Width, textBox.Height));

            button2.ButtonPressed += () =>
            {
                graphic.StartFlashing((long)(1 + 10 * slider.Value));
            };

            button3.ButtonPressed += () =>
            {
                graphic.StopFlashing();
            };

            RadioButton radioButton = new RadioButton(window, textInput.Position + new Vector2f(textInput.Width + 25, 0), 50, new Vector2f(0, 157), 3);

            while (window.IsOpen)
            {
                window.DispatchEvents();

                window.Clear();

                checkbox.Draw();
                button.Draw();
                textInput.Draw();
                slider.Draw();
                textInput.SetText(slider.Value.ToString());
                dropdown.Draw();
                textBox.Draw();
                graphic.Draw();
                button2.Draw();
                button3.Draw();
                radioButton.Draw();

                window.Display();
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            RenderWindow Window = new RenderWindow(new VideoMode(1024, 768), "Graphic test", Styles.Titlebar | Styles.Close);

            Window.Closed += OnClose;
            SfmlUI.Graphic background = new SfmlUI.Graphic(Window, "background.png", new Vector2f(20, 20));
            SfmlUI.Graphic element    = new SfmlUI.Graphic(Window, "background.png", new Vector2f(820, 100), new Vector2f(100, 100), new Vector2f(100, 100));
            element.StartFlashing(300);
            SfmlUI.Graphic scaledElement = new SfmlUI.Graphic(Window, "background.png", new Vector2f(870, 250), new Vector2f(100, 200), new Vector2f(100, 100), 2f);
            scaledElement.Origin.Horizontal.Center();
            SfmlUI.Graphic element2 = new SfmlUI.Graphic(Window, "background.png", new Vector2f(870, 600), new Vector2f(500, 100), new Vector2f(100, 100));
            element2.Origin.Horizontal.Center();
            element2.Origin.Vertical.Center();
            element2.Fade(0.7f);
            SfmlUI.Graphic element3 = new SfmlUI.Graphic(Window, "background.png", new Vector2f(400, 600), new Vector2f(100, 200), new Vector2f(100, 100));
            element3.Color(255, 0, 0);
            SfmlUI.Graphic element4 = new SfmlUI.Graphic(Window, "background.png", new Vector2f(570, 600), new Vector2f(100, 200), new Vector2f(100, 100));
            element4.Rotate(45f);

            Window.KeyReleased += OnKeyReleased;

            Checkbox checkbox = new Checkbox(Window, new Vector2f(770, 470));

            checkbox.Width           = 50;
            checkbox.Height          = 50;
            checkbox.CrossThickness  = 5f;
            checkbox.CrossColor      = Color.Green;
            checkbox.FillColor       = Color.Black;
            checkbox.BorderEnabled   = true;
            checkbox.BorderColor     = Color.White;
            checkbox.BorderThickness = 5;
            checkbox.IsChecked       = true;

            var radioButton  = new RadioButton(Window, new Vector2f(950, 500), 14, new Vector2f(0, 40), 5, 3);
            var radioButton2 = new RadioButton(Window, new Vector2f(720, 550), 14, new Vector2f(0, 40), 5);

            Dropdown dropdown = new Dropdown(Window, new Vector2f(50, 550), new Font("ArialNova.ttf"), 30,
                                             "No Blink",
                                             "Fast",
                                             "Medium",
                                             "Slow"
                                             );
            Dropdown dropdown2 = new Dropdown(Window, new Vector2f(250, 550), new Font("ArialNova.ttf"), 30,
                                              "Red",
                                              "Green",
                                              "Blue",
                                              "Yellow",
                                              "Purple",
                                              "Cyan"
                                              );

            Window.MouseButtonReleased += OnMouseButtonReleased;

            int _lastRadio  = -2;
            int _lastRadio2 = -2;

            while (Window.IsOpen)
            {
                Window.DispatchEvents();

                Window.Clear();
                background.Draw();
                element.Draw();
                scaledElement.Draw();
                scaledElement.IsVisible = checkbox.IsChecked;
                checkbox.Draw();

                radioButton.Draw();
                if (radioButton._selected != _lastRadio)
                {
                    _lastRadio = radioButton._selected;
                    switch (_lastRadio)
                    {
                    case 0:
                        element2.StopFlashing();
                        break;

                    case 1:
                        element2.StartFlashing(1000);
                        break;

                    case 2:
                        element2.StartFlashing(600);
                        break;

                    case 3:
                        element2.StartFlashing(300);
                        break;

                    case 4:
                        element2.StartFlashing(100);
                        break;
                    }
                }
                radioButton2.Draw();
                if (radioButton2._selected != _lastRadio2)
                {
                    _lastRadio2 = radioButton2._selected;
                    switch (_lastRadio2)
                    {
                    case 0:
                        element4.Rotate(0);
                        break;

                    case 1:
                        element4.Rotate(45);
                        break;

                    case 2:
                        element4.Rotate(90);
                        break;

                    case 3:
                        element4.Rotation(30);
                        break;

                    case 4:
                        element4.Rotation(360);
                        break;
                    }
                }

                element2.Draw();
                element3.Draw();
                element4.Draw();
                dropdown.Draw();
                dropdown2.Draw();

                Window.Display();
            }

            void OnMouseButtonReleased(object sender, MouseButtonEventArgs e)
            {
                if (dropdown.ChosenItem == "No Blink")
                {
                    background.StopFlashing();
                }
                if (dropdown.ChosenItem == "Fast")
                {
                    background.StartFlashing(100);
                }
                if (dropdown.ChosenItem == "Medium")
                {
                    background.StartFlashing(300);
                }
                if (dropdown.ChosenItem == "Slow")
                {
                    background.StartFlashing(600);
                }
                if (dropdown2.ChosenItem == "Red")
                {
                    element3.Color(255, 0, 0);
                }
                if (dropdown2.ChosenItem == "Green")
                {
                    element3.Color(0, 255, 0);
                }
                if (dropdown2.ChosenItem == "Blue")
                {
                    element3.Color(0, 0, 255);
                }
                if (dropdown2.ChosenItem == "Yellow")
                {
                    element3.Color(255, 255, 0);
                }
                if (dropdown2.ChosenItem == "Purple")
                {
                    element3.Color(255, 0, 255);
                }
                if (dropdown2.ChosenItem == "Cyan")
                {
                    element3.Color(0, 255, 255);
                }
            }

            void OnKeyReleased(object sender, KeyEventArgs e)
            {
                if (e.Code == Keyboard.Key.H)
                {
                    Console.WriteLine("element Height: " + element.Height);
                }
                if (e.Code == Keyboard.Key.W)
                {
                    Console.WriteLine("scaledElement Width: " + scaledElement.Width);
                }
                if (e.Code == Keyboard.Key.B)
                {
                    element.StartFlashing(300);
                    Console.WriteLine("element Blikning");
                }
                if (e.Code == Keyboard.Key.F)
                {
                    element.StartFlashing(100);
                    Console.WriteLine("element Blikning fast");
                }
                if (e.Code == Keyboard.Key.S)
                {
                    element.StartFlashing(600);
                    Console.WriteLine("element Blining slowly");
                }
                if (e.Code == Keyboard.Key.N)
                {
                    element.StopFlashing();
                    Console.WriteLine("element Not Blinking");
                }
                if (e.Code == Keyboard.Key.I)
                {
                    background.IsVisible = false;
                    Console.WriteLine("background Invisible");
                }
                if (e.Code == Keyboard.Key.V)
                {
                    background.IsVisible = true;
                    Console.WriteLine("background Visible");
                }
                if (e.Code == Keyboard.Key.Escape)
                {
                    Window.Close();
                }
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            RenderWindow   Window     = new RenderWindow(VideoMode.DesktopMode, "Dropdown Sandbox", Styles.Titlebar | Styles.Close);
            RectangleShape Background = new RectangleShape(new Vector2f(Window.Size.X, Window.Size.Y));

            Background.Position  = new Vector2f(0, 0);
            Background.FillColor = new Color(122, 122, 122, 255);
            Window.Closed       += OnClose;

            // dropdown 1
            Dropdown dropdown = new Dropdown(Window, new Vector2f(200, 150), new Font("ArialNova.ttf"), 30,
                                             "Lorem Ipsum",
                                             "Electric boogaloo",
                                             "James",
                                             "Brown fox",
                                             "Doc",
                                             "Docile",
                                             "Pizza",
                                             "Hut Hut",
                                             "Last item"
                                             );

            dropdown.OutlineColor     = Color.Cyan;
            dropdown.OutlineThickness = 50;
            dropdown.TextColor        = Color.Blue;
            dropdown.HighlightColor   = Color.Cyan;
            dropdown.BackgroundColor  = Color.Yellow;
            dropdown.FontSize         = 200;

            // Button
            Button button = new Button(Window, new Vector2f(200, 200), new Vector2f(100, 20));

            button.CenterColor    = Color.Black;
            button.OuterColor     = Color.Red;
            button.ButtonPressed += buttonPress;

            void buttonPress()
            {
                dropdown.AddItem("last time i was here i was just a kid");
            }

            // Checkbox
            Checkbox checkbox = new Checkbox(Window, new Vector2f(1000, 500));

            checkbox.FillColor  = Color.Yellow;
            checkbox.CrossColor = Color.Magenta;

            // RadioButton
            RadioButton radiobutton = new RadioButton(Window, new Vector2f(500, 700), 10f, new Vector2f(0, 50f), 3);

            // Slider
            Slider slider = new Slider(Window, new Vector2f(1080, 500), 200f, 50f, 0f, 100f);

            // Text input
            TextInput textinput = new TextInput(Window, new Vector2f(900, 80), 900f, 50f, new Font("ArialNova.ttf"));


            while (Window.IsOpen)
            {
                Window.DispatchEvents();

                Window.Clear();
                Window.Draw(Background);

                dropdown.Draw();
                button.Draw();
                checkbox.Draw();
                radiobutton.Draw();
                slider.Draw();
                textinput.Draw();

                Window.Display();
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            _window = new RenderWindow(new VideoMode(1000, 1000), "RadioButton");

            //RadioButton(RenderWindow = _window, startingPosition, globalRadius, lineSpacing, radioAmount)
            RadioButton radioButton = new RadioButton(_window, new Vector2f(100, 100), 30, new Vector2f(0, 100), 5);

            //TextBox(_window, position, ?, font, fontSize
            TextBox text1 = new TextBox(_window, new Vector2f(190, 115), 200f, 200f, new Font("Arial.ttf"), 30);

            text1.BackgroundColor = new Color(0, 0, 0, 0);
            text1.OutlineColor    = new Color(0, 0, 160);
            text1.TextColor       = Color.White;
            text1.Output("Radio button 1");

            TextBox text2 = new TextBox(_window, new Vector2f(190, 215), 200f, 200f, new Font("Arial.ttf"), 30);

            text2.BackgroundColor = new Color(0, 0, 0, 0);
            text2.OutlineColor    = new Color(0, 0, 160);
            text2.TextColor       = Color.White;
            text2.Output("Radio button 2");

            TextBox text3 = new TextBox(_window, new Vector2f(190, 315), 200f, 200f, new Font("Arial.ttf"), 30);

            text3.BackgroundColor = new Color(0, 0, 0, 0);
            text3.OutlineColor    = new Color(0, 0, 160);
            text3.TextColor       = Color.White;
            text3.Output("Radio button 3");

            TextBox text4 = new TextBox(_window, new Vector2f(190, 415), 200f, 200f, new Font("Arial.ttf"), 30);

            text4.BackgroundColor = new Color(0, 0, 0, 0);
            text4.OutlineColor    = new Color(0, 0, 160);
            text4.TextColor       = Color.White;
            text4.Output("Radio button 4");

            TextBox text5 = new TextBox(_window, new Vector2f(190, 515), 200f, 200f, new Font("Arial.ttf"), 30);

            text5.BackgroundColor = new Color(0, 0, 0, 0);
            text5.OutlineColor    = new Color(0, 0, 160);
            text5.TextColor       = Color.White;
            text5.Output("Radio button 5");

            TextBox text6 = new TextBox(_window, new Vector2f(100, 615), 200f, 200f, new Font("Arial.ttf"), 30);

            text6.BackgroundColor = new Color(0, 0, 0, 0);
            text6.OutlineColor    = new Color(0, 0, 160);
            text6.TextColor       = Color.White;

            //Slider(_window, position, length, height, min-value, max-value)
            Slider slider = new Slider(_window, new Vector2f(500, 100), 400f, 50f, 0f, 100f);

            TextBox text7 = new TextBox(_window, new Vector2f(600, 50), 200f, 200f, new Font("Arial.ttf"), 30);

            text7.BackgroundColor = new Color(0, 0, 0, 0);
            text7.OutlineColor    = new Color(0, 0, 160);
            text7.TextColor       = Color.White;

            //Button(_window, position, size)
            Button button = new Button(_window, new Vector2f(500, 200), new Vector2f(200, 200));

            button.Shape = Button.Shapes.Elipse;

            button.ButtonPressed  += buttonPressed;
            button.ButtonReleased += buttonReleased;

            Text8 = new TextBox(_window, new Vector2f(730, 275), 200f, 200f, new Font("Arial.ttf"), 30);
            Text8.BackgroundColor = new Color(0, 0, 0, 0);
            Text8.OutlineColor    = new Color(0, 0, 160);
            Text8.TextColor       = Color.White;
            Text8.Output("Not pressed");

            //Checkbox(_window, position)
            Checkbox checkbox = new Checkbox(_window, new Vector2f(500, 450));

            checkbox.Width          = 50;
            checkbox.Height         = 50;
            checkbox.CrossThickness = 5f;
            checkbox.FillColor      = new Color(255, 255, 255);
            checkbox.CrossColor     = new Color(100, 100, 100);

            TextBox text9 = new TextBox(_window, new Vector2f(575, 455), 200f, 200f, new Font("Arial.ttf"), 30);

            text9.BackgroundColor = new Color(0, 0, 0, 0);
            text9.OutlineColor    = new Color(0, 0, 160);
            text9.TextColor       = Color.White;

            //Dropdown(_window, position, font, fontSize)
            Dropdown dropdown = new Dropdown(_window, new Vector2f(100, 700), new Font("Arial.ttf"), 30,
                                             "Lorem Ipsum",
                                             "Electric boogaloo",
                                             "James",
                                             "Brown fox",
                                             "Doc",
                                             "Docile",
                                             "Pizza"
                                             );

            dropdown.OutlineColor     = new Color(100, 100, 100);
            dropdown.OutlineThickness = 50;
            dropdown.TextColor        = new Color(255, 255, 255);
            dropdown.HighlightColor   = new Color(255, 0, 0);;
            dropdown.BackgroundColor  = new Color(100, 100, 100);

            TextBox text10 = new TextBox(_window, new Vector2f(100, 775), 200f, 200f, new Font("Arial.ttf"), 30);

            text10.BackgroundColor = new Color(0, 0, 0, 0);
            text10.OutlineColor    = new Color(0, 0, 160);
            text10.TextColor       = Color.White;

            //TextInput(_window, position, width, height, font)
            TextInput textInput = new TextInput(_window, new Vector2f(500, 550), 400f, 50f, new Font("Arial.ttf"));

            textInput.OutlineColor = new Color(100, 100, 100);
            textInput.TextColor    = new Color(0, 0, 0);

            TextBox text11 = new TextBox(_window, new Vector2f(500, 625), 200f, 200f, new Font("Arial.ttf"), 30);

            text11.BackgroundColor = new Color(0, 0, 0, 0);
            text11.OutlineColor    = new Color(0, 0, 160);
            text11.TextColor       = Color.White;

            //Graphic(_window, "name.filetype", position)
            Graphic graphic = new Graphic(_window, "image.jpg", new Vector2f(500, 700));

            _window.Closed += WindowClosed;

            _window.SetFramerateLimit(60);
            _window.SetVerticalSyncEnabled(true);

            while (_window.IsOpen)
            {
                _window.DispatchEvents();
                _window.Clear();

                radioButton.Draw();
                text1.Draw();
                text2.Draw();
                text3.Draw();
                text4.Draw();
                text5.Draw();
                if (radioButton._selected == -1)
                {
                    text6.Output("Selected button: none");
                }
                else
                {
                    text6.Output("Selected button: " + (radioButton._selected + 1));
                }
                text6.Draw();

                slider.Draw();
                text7.Output(slider.Value.ToString());
                text7.Draw();

                button.Draw();
                Text8.Draw();

                checkbox.Draw();
                if (checkbox.IsChecked == true)
                {
                    text9.Output("Checked");
                }
                else
                {
                    text9.Output("Unchecked");
                }
                text9.Draw();

                text10.Output("Selected: " + dropdown.ChosenItem);
                text10.Draw();
                dropdown.Draw();

                textInput.Draw();
                text11.Output("Input: " + textInput.Text);
                text11.Draw();

                graphic.Draw();

                _window.Display();
            }
        }
 public override void Draw(SpriteBatch spritebatch)
 {
     a.Draw(spritebatch);
     spritebatch.DrawString(font, "a.ticked: " + a.ticked.ToString(), new Vector2(180, 170), Color.White);
     base.Draw(spritebatch);
 }