Ejemplo n.º 1
0
        public void OnMenuItemClick(object sender, EventArgs e)
        {
            ButtonMenu btn = (ButtonMenu)sender;

            btn.Selected = true;

            if (lastSelectedButton != null)
            {
                lastSelectedButton.Selected = false;
            }

            lastSelectedButton = btn;

            int index = 0;

            for (var i = 0; i < MenuViewModel.MenuItems.Count; i++)
            {
                if (MenuViewModel.MenuItems[i].page_title == btn.MenuItem.page_title)
                {
                    index = i;
                }
            }

            MenuClickEvent.Notify(btn.MenuItem.menu_title, btn.MenuItem.url, index);
        }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            backButton.Update(gameTime);
            LeftButton.Update(gameTime);
            RightButton.Update(gameTime);
            StartButton.Update(gameTime);

            KeyboardState ks = Keyboard.GetState();

            Keys[] pressedKeys = ks.GetPressedKeys();
            if (pressedKeys.Length > 0)
            {
                if (clickedKey == LeftButton)
                {
                    Main.moveLeft   = pressedKeys[0];
                    LeftButton.Text = Main.moveLeft.ToString();
                }
                else if (clickedKey == RightButton)
                {
                    Main.moveRight   = pressedKeys[0];
                    RightButton.Text = Main.moveRight.ToString();
                }
                else if (clickedKey == StartButton)
                {
                    Main.startBall   = pressedKeys[0];
                    StartButton.Text = Main.startBall.ToString();
                }
                assigning = false;
            }
            if (!assigning)
            {
                clickedKey = null;
            }
        }
Ejemplo n.º 3
0
 public MenuPrincipal()
 {
     this.Height             = 400;
     buttonImportarDados     = new ButtonMenu("Importar Dados", this.Width - 15, 0, 0, new System.EventHandler(this.ImportarDados));
     buttonAdicionarFilme    = new ButtonMenu("Adicionar Filme", this.Width - 15, 0, 30, new System.EventHandler(this.AdicionarFilme));
     buttonListarFilmes      = new ButtonMenu("Listar Filmes", this.Width - 15, 0, 60, new System.EventHandler(this.ListarFilmes));
     buttonConsultarFilme    = new ButtonMenu("Consultar Filme", this.Width - 15, 0, 90, new System.EventHandler(this.ConsultarFilme));
     buttonAdicionarCliente  = new ButtonMenu("Adicionar Cliente", this.Width - 15, 0, 150, new System.EventHandler(this.AdicionarCliente));
     buttonListarClientes    = new ButtonMenu("Listar Clientes", this.Width - 15, 0, 180, new System.EventHandler(this.ListarClientes));
     buttonConsultarClientes = new ButtonMenu("Consultar Clientes", this.Width - 15, 0, 210, new System.EventHandler(this.ConsultarClientes));
     buttonCriarLocacao      = new ButtonMenu("Realizar Locação", this.Width - 15, 0, 270, new System.EventHandler(this.CriarLocacao));
     buttonListarLocacoes    = new ButtonMenu("Listar Todas as Locações", this.Width - 15, 0, 300, new System.EventHandler(this.ListarLocacoes));
     buttonConsultarLocacao  = new ButtonMenu("Consultar uma Locação", this.Width - 15, 0, 330, new System.EventHandler(this.ConsultarLocacao));
     //Corrigidos
     this.Controls.Add(buttonImportarDados);
     this.Controls.Add(buttonAdicionarFilme);
     this.Controls.Add(buttonListarFilmes);
     this.Controls.Add(buttonListarClientes);
     this.Controls.Add(buttonAdicionarCliente);
     this.Controls.Add(buttonListarLocacoes);
     this.Controls.Add(buttonCriarLocacao);
     //Falta corrigir
     this.Controls.Add(buttonConsultarFilme);
     this.Controls.Add(buttonConsultarClientes);
     this.Controls.Add(buttonConsultarLocacao);
 }
Ejemplo n.º 4
0
        public OptionsState(Main game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            buttonTexture = content.Load <Texture2D>("Controls/button_0");
            buttonFont    = content.Load <SpriteFont>("MenuFont");

            backButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(30, 600),
                Text     = "Back",
            };
            backButton.Click += BackButton_Click;

            LeftButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 18, 200),
                Text     = Main.moveLeft.ToString(),
            };
            LeftButton.Click += LeftButton_Click;

            RightButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 18, 300),
                Text     = Main.moveRight.ToString(),
            };
            RightButton.Click += RightButton_Click;

            StartButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 18, 400),
                Text     = Main.startBall.ToString(),
            };
            StartButton.Click += StartButton_Click;
        }
Ejemplo n.º 5
0
 private void StartButton_Click(object sender, EventArgs e)
 {
     //Keybindings beállítása elindításhoz
     //Mainben kell létrehozni
     clickedKey       = StartButton;
     assigning        = true;
     StartButton.Text = "Press a key";
 }
Ejemplo n.º 6
0
        public Task VisitButtonMenu(ButtonMenu buttonDialog)
        {
            log.Debug($"{buttonDialog.Caption}, cols:{buttonDialog.ColumnsCount}");
            log.Debug("========================");
            buttonDialog.Buttons.ForEach(async b => await VisitButton(b));

            return(Task.CompletedTask);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Меню кнопок
        /// </summary>
        /// <param name="ChatId"></param>
        public string MyMenu()
        {
            ButtonMenu btn = new ButtonMenu(CreateMenu());
            //необходимо сериализовать класс в JSON
            string replyMarkup = JsonConvert.SerializeObject(btn);

            return(replyMarkup);
        }
Ejemplo n.º 8
0
 private void RightButton_Click(object sender, EventArgs e)
 {
     //Keybindings beállítása jobbra
     //Mainben kell létrehozni
     clickedKey       = RightButton;
     assigning        = true;
     RightButton.Text = "Press a key";
 }
Ejemplo n.º 9
0
 public static void Prefix(ButtonMenu __instance, int a)
 {
     if (MenuRegistry.Singleton.GetEntry(a) is CraftMenuInfo craftMenu)
     {
         __instance.button       = (Material)Resources.Load("mat/craftButtonInactive" + craftMenu.ID);
         __instance.buttonSelect = (Material)Resources.Load("mat/craftButtonInactive" + craftMenu.ID);
         __instance.GetComponent <Renderer>().material = __instance.button;
     }
 }
Ejemplo n.º 10
0
 private void CreateButton()
 {
     for (int i = 0; i < MainMenu.ItemsMenu.Count; i++)
     {
         ButtonMenu.Add(new Button());
         DefinitionButton(i);
         panel.Controls.Add(ButtonMenu[i]);
         ButtonMenu[i].MouseClick += OnMouseClickButton;
     }
 }
Ejemplo n.º 11
0
        public MenuState(Main game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            buttonTexture = _content.Load <Texture2D>("Controls/button_0");
            buttonFont    = _content.Load <SpriteFont>("MenuFont");

            newGameButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 118, (Main.Graphics.PreferredBackBufferHeight / 2) - 120),
                Text     = "New Game",
            };

            newGameButton.Click += newGameButton_Click;

            selectLevelGameButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 118, (Main.Graphics.PreferredBackBufferHeight / 2) - 60),
                Text     = "Select Level",
            };

            selectLevelGameButton.Click += selectLevelGameButton_Click;

            descriptionGameButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 118, Main.Graphics.PreferredBackBufferHeight / 2),
                Text     = "Description",
            };

            descriptionGameButton.Click += DescriptionGameButton_Click;

            optionsGameButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 118, (Main.Graphics.PreferredBackBufferHeight / 2) + 60),
                Text     = "Options",
            };

            optionsGameButton.Click += OptionsGameButton_Click;

            quitGameButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2((Main.Graphics.PreferredBackBufferWidth / 2) - 118, (Main.Graphics.PreferredBackBufferHeight / 2) + 120),
                Text     = "Quit Game",
            };

            quitGameButton.Click += quitGameButton_Click;

            _components = new List <Component>()
            {
                newGameButton,
                selectLevelGameButton,
                quitGameButton,
                descriptionGameButton,
                optionsGameButton,
            };
        }
Ejemplo n.º 12
0
        private void addStartButton()
        {
            Texture2D buttonImage = Content.Load <Texture2D>("GUI/start_button");

            buttonMenu = new ButtonMenu(lhg, lhg.NormalFont, buttonImage, 5, this);

            string[] items = { "Start" };

            buttonMenu.SetMenuItems(items);
            buttonMenu.Position      = new Vector2(700, 500);
            buttonMenu.SelectedIndex = 0;
        }
Ejemplo n.º 13
0
 public async Task VisitButtonMenu(ButtonMenu buttonDialog)
 {
     await SendDialog(buttonDialog.Caption,
                      new ReplyKeyboardMarkup(
                          buttonDialog.Buttons
                          .ByIndex()
                          .GroupBy(i => i / buttonDialog.ColumnsCount)
                          .Select(gi => gi.Select(i => buttonDialog.Buttons[i]).Select(button =>
                                                                                       new KeyboardButton(button.Go)).ToArray())
                          .ToArray(),
                          true
                          ));
 }
Ejemplo n.º 14
0
        public DescriptionState(Main game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            buttonTexture = content.Load <Texture2D>("Controls/button_0");
            buttonFont    = content.Load <SpriteFont>("MenuFont");

            backButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(30, 600),
                Text     = "Back",
            };

            backButton.Click += BackButton_Click;
        }
Ejemplo n.º 15
0
        public CreditScreen(Game game)
            : base(game)
        {
            LoadContent();
            Components.Add(new BackgroundComponent(game, background, true));
            string[] items = { "RETURN TO MENU" };

            buttonMenu = new ButtonMenu(game, spriteFont, buttonImage);
            buttonMenu.SetMenuItems(items);
            Components.Add(buttonMenu);

            position = new Vector2(0, 0);
        }
Ejemplo n.º 16
0
    float size;//перевод в число времени

    void Start()
    {
        ButtonMenu buttonMenu = GetComponent <ButtonMenu>();

        ShowTime.text          = "Time - " + Exit.stringMinutes + ":" + Exit.stringSecond.Remove(4);
        LoadLevel.accountOrder = 4;

        if (float.Parse(Exit.stringMinutes) > 0)
        {
            size = float.Parse(Exit.stringMinutes) * 60 + float.Parse(Exit.stringSecond);
        }
        else
        {
            size = float.Parse(Exit.stringSecond);
        }
    }
Ejemplo n.º 17
0
        public void loadActionMenu()
        {
            Texture2D actionButton = lhg.Content.Load <Texture2D>("GUI/blackbutton");

            actionMenu = new ButtonMenu(lhg, this.lhg.SmallFont, actionButton, 0, this);
            string[] items = { "Attack",
                               "Move",
                               "Defend",
                               "Use",
                               "Inventory",
                               "End Turn" };
            actionMenu.SetMenuItems(items);
            actionMenu.HiliteColor  = Color.Red;
            actionMenu.NormalColor  = Color.White;
            this.actionMenu.Visible = false;
        }
Ejemplo n.º 18
0
        public QuitGameScreen(Game game)
            : base(game)
        {
            LoadContent();

            Components.Add(new BackgroundComponent(game, image, false));

            imagePosition   = new Vector2();
            imagePosition.X = (game.Window.ClientBounds.Width - image.Width) / 2;
            imagePosition.Y = (game.Window.ClientBounds.Height - image.Height) / 2;

            string[] items = { "YES", "NO" };
            menu = new ButtonMenu(game, spriteFont, buttonImage);
            menu.SetMenuItems(items);
            Components.Add(menu);
        }
Ejemplo n.º 19
0
        public ClassPopUpScreen(Game game)
            : base(game)
        {
            LoadContent();

            Components.Add(new BackgroundComponent(game, image, false));

            imagePosition   = new Vector2();
            imagePosition.X = (game.Window.ClientBounds.Width - image.Width) / 2;
            imagePosition.Y = (game.Window.ClientBounds.Height - image.Height) / 2;

            string[] items = Enum.GetNames(typeof(CharClass));

            menu = new ButtonMenu(game, spriteFont, buttonImage);
            menu.SetMenuItems(items);
            Components.Add(menu);
        }
Ejemplo n.º 20
0
    public void OnClickButtonMenu(ButtonMenu bm)
    {
        switch (bm)
        {
        case ButtonMenu.Start:
            DoTweenControllerScript.main.SetAlphaShadow(() => { LoadNext(UIBoder, UINextGameStart); });
            break;

        case ButtonMenu.Music:
            print(bm);
            break;

        case ButtonMenu.Rank:
            print(bm);
            break;

        case ButtonMenu.Facebook:
            print(bm);
            break;

        case ButtonMenu.Twitter:
            print(bm);
            break;

        case ButtonMenu.Share:
            print(bm);
            break;

        case ButtonMenu.Like:
            print(bm);
            break;

        case ButtonMenu.MemoryTest:
            DoTweenControllerScript.main.SetAlphaShadow(() => { LoadNext(UINextGameStart, UITutorial); });
            break;
        }
    }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes all Lists, thus creating all the text for the help screens
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            //fontSize
            fontScale = 0.24f;

            helpTitle = new List<string>();
            helpText = new List<List<string>>();
            helpTextLocation = new List<List<Vector2>>();
            helpTextColor = new List<List<Color>>();

            //Strings
            List<string> tempText;
            List<Vector2> tempLocation;
            List<Color> tempColor;

            //create the text, text location, and text color for each help section
            #region General Help

            tempText = new List<string>();
            tempLocation = new List<Vector2>();
            tempColor = new List<Color>();

            helpTitle.Add("Help: General");

            tempText.Add("All sections of this game share the same controls. They are as follows: "); //0
            tempText.Add("Select button or menu option:"); //1
            tempText.Add("     Keyboad and Mouse: "); //2
            tempText.Add("Left Mouse Button, Space, or Enter"); //3
            tempText.Add("     Gamepad: "); //4
            tempText.Add("A or Start"); //5
            tempText.Add("Navigate buttons or menu options:"); //6
            tempText.Add("     Keyboad and Mouse: "); //7
            tempText.Add("Arrow Keys or Mouse"); //8
            tempText.Add("     Gamepad: "); //9
            tempText.Add("Left Thumbstick or D-Pad"); //10
            tempText.Add("Exit Section:"); //11
            tempText.Add("     Keyboad and Mouse: "); //12
            tempText.Add("Esc or Q"); //13
            tempText.Add("     Gamepad: "); //14
            tempText.Add("B or Back"); //15

            helpText.Add(tempText);

            tempLocation.Add(new Vector2(75, 150)); //0
            tempLocation.Add(new Vector2(75, tempLocation[0].Y + font.MeasureString(tempText[0]).Y * fontScale)); //1
            tempLocation.Add(new Vector2(75, tempLocation[1].Y + font.MeasureString(tempText[1]).Y * fontScale)); //2
            tempLocation.Add(new Vector2(tempLocation[2].X + font.MeasureString(tempText[2]).X * fontScale, tempLocation[2].Y)); //3
            tempLocation.Add(new Vector2(75, tempLocation[3].Y + font.MeasureString(tempText[3]).Y * fontScale)); //4
            tempLocation.Add(new Vector2(tempLocation[4].X + font.MeasureString(tempText[4]).X * fontScale, tempLocation[4].Y)); //5
            tempLocation.Add(new Vector2(75, tempLocation[5].Y + font.MeasureString(tempText[5]).Y * fontScale)); //6
            tempLocation.Add(new Vector2(75, tempLocation[6].Y + font.MeasureString(tempText[6]).Y * fontScale)); //7
            tempLocation.Add(new Vector2(tempLocation[7].X + font.MeasureString(tempText[7]).X * fontScale, tempLocation[7].Y)); //8
            tempLocation.Add(new Vector2(75, tempLocation[8].Y + font.MeasureString(tempText[8]).Y * fontScale)); //9
            tempLocation.Add(new Vector2(tempLocation[9].X + font.MeasureString(tempText[9]).X * fontScale, tempLocation[9].Y)); //10
            tempLocation.Add(new Vector2(75, tempLocation[10].Y + font.MeasureString(tempText[10]).Y * fontScale)); //11
            tempLocation.Add(new Vector2(75, tempLocation[11].Y + font.MeasureString(tempText[11]).Y * fontScale)); //12
            tempLocation.Add(new Vector2(tempLocation[12].X + font.MeasureString(tempText[12]).X * fontScale, tempLocation[12].Y)); //13
            tempLocation.Add(new Vector2(75, tempLocation[13].Y + font.MeasureString(tempText[13]).Y * fontScale)); //14
            tempLocation.Add(new Vector2(tempLocation[14].X + font.MeasureString(tempText[14]).X * fontScale, tempLocation[14].Y)); //15

            helpTextLocation.Add(tempLocation);

            tempColor.Add(Color.Honeydew); //0
            tempColor.Add(Color.LightGoldenrodYellow); //1
            tempColor.Add(Color.PeachPuff); //2
            tempColor.Add(Color.Salmon); //3
            tempColor.Add(Color.PeachPuff); //4
            tempColor.Add(Color.Salmon); //5
            tempColor.Add(Color.LightGoldenrodYellow); //6
            tempColor.Add(Color.PeachPuff); //7
            tempColor.Add(Color.Salmon); //8
            tempColor.Add(Color.PeachPuff); //9
            tempColor.Add(Color.Salmon);//10
            tempColor.Add(Color.LightGoldenrodYellow); //11
            tempColor.Add(Color.PeachPuff); //12
            tempColor.Add(Color.Salmon); //13
            tempColor.Add(Color.PeachPuff); //14
            tempColor.Add(Color.Salmon); //15

            helpTextColor.Add(tempColor);

            #endregion

            #region Practice Help

            tempText = new List<string>();
            tempLocation = new List<Vector2>();
            tempColor = new List<Color>();

            helpTitle.Add("Help: Practice");

            tempText.Add("The practice session provides an interactive times table which can help teach\n" + //0
                          "multiplication.");
            tempText.Add("Highlighting one of the multiplication problems will display a number of objects\n" + //1
                          "equal to the answer.");
            tempText.Add("Clicking on a problem will show the answer inside the selected button and display\n" + //2
                          "the full equation in the bottom right");

            helpText.Add(tempText);

            tempLocation.Add(new Vector2(75, 150)); //0
            tempLocation.Add(new Vector2(75, tempLocation[0].Y + font.MeasureString(tempText[0]).Y * fontScale)); //1
            tempLocation.Add(new Vector2(75, tempLocation[1].Y + font.MeasureString(tempText[1]).Y * fontScale)); //2

            helpTextLocation.Add(tempLocation);

            tempColor.Add(Color.LightGoldenrodYellow); // 0
            tempColor.Add(Color.Honeydew); //1
            tempColor.Add(Color.Honeydew); //2

            helpTextColor.Add(tempColor);

            #endregion

            #region Test Help

            tempText = new List<string>();
            tempLocation = new List<Vector2>();
            tempColor = new List<Color>();

            helpTitle.Add("Help: Test");

            tempText.Add("The test section allows you to test your multiplication skills through a quiz.\n"); //0
            tempText.Add("A multiplication problem will be presented and you are asked to answer it. You"); //1
            tempText.Add("may use the the supplied input buttons, or the ");//2
            tempText.Add("0 - 9"); //3
            tempText.Add(" keys on your keyboard."); //4

            helpText.Add(tempText);

            tempLocation.Add(new Vector2(75, 150)); //0
            tempLocation.Add(new Vector2(75, tempLocation[0].Y + font.MeasureString(tempText[0]).Y * fontScale)); //1
            tempLocation.Add(new Vector2(75, tempLocation[1].Y + font.MeasureString(tempText[1]).Y * fontScale)); //2
            tempLocation.Add(new Vector2(tempLocation[2].X + font.MeasureString(tempText[2]).X * fontScale, tempLocation[2].Y)); //3
            tempLocation.Add(new Vector2(tempLocation[3].X + font.MeasureString(tempText[3]).X * fontScale, tempLocation[3].Y)); //4

            helpTextLocation.Add(tempLocation);

            tempColor.Add(Color.LightGoldenrodYellow); //0
            tempColor.Add(Color.Honeydew); //1
            tempColor.Add(Color.Honeydew); //2
            tempColor.Add(Color.Salmon); //3
            tempColor.Add(Color.Honeydew); //4

            helpTextColor.Add(tempColor);

            #endregion

            //title Elements
            titleScale = 0.74f;
            titlePosition = new Vector2(Graphics.PreferredBackBufferWidth / 2, 100);
            titleOrigin = (font.MeasureString(helpTitle[(int)current])) / 2;

            //Help Screen Navigation Buttons
            ButtonMenu button;
            arrows = new List<ButtonMenu>();
            button = new ButtonMenu(new Vector2(0,0),
                "",
                0,
                font
                );
            button.fontSize = 0.2f;
            button.TextColor = Color.Aquamarine;
            arrows.Add(button);
            button = new ButtonMenu(new Vector2(0,0),
                helpTitle[(int)current+1],
                1,
                font
                );
            button.fontSize = 0.2f;
            button.TextColor = Color.Aquamarine;
            arrows.Add(button);
            arrows[1].Location = new Vector2(Graphics.PreferredBackBufferWidth - (font.MeasureString(helpTitle[(int)current + 1]).X * 0.2f) / 2 - 75,
                                  Graphics.PreferredBackBufferHeight - (font.MeasureString(helpTitle[(int)current + 1]).Y * 0.2f) / 3 - 75);
            arrows[1].NormalText = helpTitle[(int)current + 1];
        }
Ejemplo n.º 22
0
        public SelectLevelState(Main game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            buttonTexture = content.Load <Texture2D>("Controls/button_0");
            buttonFont    = content.Load <SpriteFont>("MenuFont");



            Level1Button = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(100, 250),
                Text     = "Level 1",
            };
            Level1Button.Click += Level1Button_Click;

            Level2Button = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(400, 250),
                Text     = "Level 2",
            };
            Level2Button.Click += Level2Button_Click;

            Level3Button = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(700, 250),
                Text     = "Level 3",
            };
            Level3Button.Click += Level3Button_Click;

            Level4Button = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(100, 500),
                Text     = "Level 4",
            };
            Level4Button.Click += Level4Button_Click;

            Level5Button = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(400, 500),

                Text = "Level 5",
            };
            Level5Button.Click += Level5Button_Click;
            Level6Button        = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(700, 500),
                Text     = "Level 6",
            };
            Level6Button.Click += Level6Button_Click;



            backButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(30, 600),
                Text     = "Back",
            };

            backButton.Click += BackButton_Click;

            RandomLevelButton = new ButtonMenu(buttonTexture, buttonFont)
            {
                Position = new Vector2(1000, 600),
                Text     = "Random",
            };
            RandomLevelButton.Click += RandomLevel_Click;
        }
Ejemplo n.º 23
0
        private void CreateMenuItems()
        {
            var bg = Util.NewColorsItem("Background", $"Modifies the ~b~{nameof(RAGENativeUI.Elements.InstructionalButtons)}.{nameof(RAGENativeUI.Elements.InstructionalButtons.BackgroundColor)}~s~ property.");

            bg.SelectedItem = HudColor.PanelLight;
            InstructionalButtons.BackgroundColor = HudColor.PanelLight.GetColor();
            bg.IndexChanged += (s, o, n) =>
            {
                Color c = bg.SelectedItem.GetColor();
                InstructionalButtons.BackgroundColor = c;
                InstructionalButtons.Update();
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.BackgroundColor = c;
                    child.InstructionalButtons.Update();
                }
            };

            var maxWidth = new UIMenuNumericScrollerItem <float>("Max Width", $"Modifies the ~b~{nameof(RAGENativeUI.Elements.InstructionalButtons)}.{nameof(RAGENativeUI.Elements.InstructionalButtons.MaxWidth)}~s~ property.",
                                                                 0.0f, 1.0f, 0.01f)
            {
                Formatter = v => v.ToString("0.00"),
            }.WithTextEditing();

            maxWidth.Value         = InstructionalButtons.MaxWidth;
            maxWidth.IndexChanged += (s, o, n) =>
            {
                float v = maxWidth.Value;
                InstructionalButtons.MaxWidth = v;
                InstructionalButtons.Update();
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.MaxWidth = v;
                    child.InstructionalButtons.Update();
                }
            };

            var addButton = new UIMenuItem("Add Button");

            addButton.Activated += (m, s) =>
            {
                var button     = new InstructionalButton("A", "Slot #" + slotId++);
                var buttonMenu = new ButtonMenu(button);
                buttonMenu.InstructionalButtons.BackgroundColor = bg.SelectedItem.GetColor();
                buttonMenu.InstructionalButtons.MaxWidth        = maxWidth.Value;
                buttonMenu.InstructionalButtons.Buttons.Clear();
                buttonMenu.InstructionalButtons.Buttons.AddRange(InstructionalButtons.Buttons);

                var bindItem = new UIMenuItem(button.Text);
                AddItem(bindItem);
                BindMenuToItem(buttonMenu, bindItem);

                InstructionalButtons.Buttons.Add(button);
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.Buttons.Add(button);
                }
            };

            AddItems(bg, maxWidth, addButton);
            this.WithFastScrollingOn(maxWidth);
        }
Ejemplo n.º 24
0
 private void OnEnable()
 {
     _menu = (ButtonMenu)target;
 }
        void ReleaseDesignerOutlets()
        {
            if (Browser != null)
            {
                Browser.Dispose();
                Browser = null;
            }

            if (ButtonAddURL != null)
            {
                ButtonAddURL.Dispose();
                ButtonAddURL = null;
            }

            if (ButtonClose != null)
            {
                ButtonClose.Dispose();
                ButtonClose = null;
            }

            if (ButtonCreateFolder != null)
            {
                ButtonCreateFolder.Dispose();
                ButtonCreateFolder = null;
            }

            if (ButtonInsets != null)
            {
                ButtonInsets.Dispose();
                ButtonInsets = null;
            }

            if (ButtonLoad != null)
            {
                ButtonLoad.Dispose();
                ButtonLoad = null;
            }

            if (ButtonMenu != null)
            {
                ButtonMenu.Dispose();
                ButtonMenu = null;
            }

            if (ButtonReturnOnStart != null)
            {
                ButtonReturnOnStart.Dispose();
                ButtonReturnOnStart = null;
            }

            if (TableView != null)
            {
                TableView.Dispose();
                TableView = null;
            }

            if (TableViewPages != null)
            {
                TableViewPages.Dispose();
                TableViewPages = null;
            }

            if (TextBoxURL != null)
            {
                TextBoxURL.Dispose();
                TextBoxURL = null;
            }

            if (ViewForList != null)
            {
                ViewForList.Dispose();
                ViewForList = null;
            }

            if (ViewForOpenPages != null)
            {
                ViewForOpenPages.Dispose();
                ViewForOpenPages = null;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Initialization of menu interface
        /// </summary>
        public void InitializeMenu()
        {
            //Buttons of race
            buttonRaces = new List<ButtonMenu<Race>>();
            for (int i = 0; i < 7; ++i)
            {
                buttonRaces.Add(new ButtonMenu<Race>(new Rectangle(5 + 79 * i, 25, 75, 30),
                    localization.Get("RACE_" + (i + 1)), (Race)i));
            }

            //current race
            if (map.hero == null)
            {
                //start heroes race
                buttonRaces[(int)Race.Human].Selected = true;
                HeroesRace = Race.Human;
            }
            else
            {
                foreach (ButtonMenu<Race> button in buttonRaces)
                {
                    if (button.Parameter == map.hero.RaceHero)
                        button.Selected = true;
                }
                HeroesRace = map.hero.RaceHero;
            }

            //marked button
            foreach (ButtonMenu<Race> button in buttonRaces)
            {
                if (map.saveData._ListWinRace.Any(p => p == button.Parameter))
                    button.MarkedIsWin = true;
            }
            if (map.saveData._ListWinRace.Count < 1)
                buttonRaces[4].Invisible = true;
            if (map.saveData._ListWinRace.Count < 2)
                buttonRaces[5].Invisible = true;
            if (map.saveData._ListWinRace.Count < 3)
                buttonRaces[6].Invisible = true;

            //button of class
            buttonClass = new List<ButtonMenu<Class>>();
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 3; ++x)
                {
                    buttonClass.Add(new ButtonMenu<Class>(new Rectangle(30 + 90 * y, 100 + 35 * x, 85, 30),
                        localization.Get("CLASS_" + (y * 3 + x + 1)), (Class)(y * 3 + x)));
                }
            }

            // 3 if with Tinker
            int countBonusClasses = 3;
            --countBonusClasses;

            //Bonus classes
            for (int i = 0; i < countBonusClasses; ++i)
            {
                buttonClass.Add(new ButtonMenu<Class>(new Rectangle(430, 100 + 35 * i, 85, 30),
                    localization.Get("CLASS_" + (i + 13)), (Class)(12 + i)));
            }

            //current class
            if (map.hero == null)
            {
                //start heroes class
                buttonClass[(int)Class.Fighter].Selected = true;
                HeroesClass = Class.Fighter;
            }
            else
            {
                foreach (ButtonMenu<Class> button in buttonClass)
                {
                    if (button.Parameter == map.hero.ClassHero)
                        button.Selected = true;
                }
                HeroesClass = map.hero.ClassHero;
            }

            //marked class buttons
            foreach (ButtonMenu<Class> button in buttonClass)
            {
                if (map.saveData._ListWinClass.Any(p => p == button.Parameter))
                    button.MarkedIsWin = true;
            }

            //dependes of classes
            DependOnClass(Class.Berserker, Class.Fighter);
            DependOnClass(Class.Rogue, Class.Thief);
            DependOnClass(Class.Monk, Class.Priest);
            DependOnClass(Class.Sorcerer, Class.Wizard);

            DependOnClass(Class.Warlord, Class.Berserker);
            DependOnClass(Class.Assassin, Class.Rogue);
            DependOnClass(Class.Paladin, Class.Monk);
            DependOnClass(Class.Bloodmage, Class.Sorcerer);

            DependOnClass(Class.Transmuter, Class.Bloodmage);
            DependOnClass(Class.Crusader, Class.Warlord);
            //DependOnClass(Class.Tinker, Class.Assassin);

            //Other buttons
            buttonStart = new ButtonMenu<GameState>(new Rectangle(350, 250, 150, 60),
                localization.Get("BUTTON_START"), GameState.Menu);
            buttonStart.Selected = true;
            buttonExit = new ButtonMenu<GameState>(new Rectangle(450, 383, 80, 15),
                localization.Get("BUTTON_EXIT"), GameState.Menu);
            buttonAbout = new ButtonMenu<GameState>(new Rectangle(20, 383, 100, 15),
                 localization.Get("BUTTON_ABOUT"), GameState.About);
        }
Ejemplo n.º 27
0
        public override void ViewDidLoad()
        {
            //base.ViewDidLoad();

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                BackgroundColor  = Style.Menu.BackgroundColor
            };

            int     top = 120, left = 30;
            UIImage divider = UIImage.FromBundle("divider");

            MenuViewModel.MenuItems.Add(new MenuItem()
            {
                menu_title = Translator.GetText("gallery"),
                page_title = Translator.GetText("gallery"),
                url        = string.Empty
            });

            for (var i = 0; i < MenuViewModel.MenuItems.Count; i++)
            {
                MenuItem item = MenuViewModel.MenuItems[i];

                if (MvxEnumerableExtensions.ElementAt(menuIds, i) != null)
                {
                    var img       = UIImage.FromBundle(menuIds[i])?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                    var btnHeight = img?.Size.Height + 10 ?? 20;

                    var btn = new ButtonMenu(new CGRect(0, top, scrollView.Frame.Width, btnHeight), item, img)
                    {
                        ContentEdgeInsets = new UIEdgeInsets(0, left, 0, 0),
                        ContentMode       = UIViewContentMode.ScaleAspectFit
                    };

                    btn.TouchUpInside += OnMenuItemClick;

                    if (i == 0)
                    {
                        btn.Selected       = true;
                        lastSelectedButton = btn;
                    }

                    scrollView.Add(btn);

                    top += (int)btn.Frame.Height;

                    var leftSeparator = left + btn.TitleEdgeInsets.Left;
                    leftSeparator += btn.CurrentImage?.Size.Width ?? 0;

                    var separator = new UIImageView(new CGRect(leftSeparator, top, scrollView.Frame.Width - 160, 5))
                    {
                        Image = divider
                    };

                    scrollView.Add(separator);

                    top += (int)separator.Frame.Height + 10;
                }
            }

            Add(scrollView);


            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View));

            //scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            // var constraints = scrollView.VerticalStackPanelConstraints(new Margins(20, 120, 0, 10, 5, 5), scrollView.Subviews);
            //
            // scrollView.AddConstraints(constraints);
        }
Ejemplo n.º 28
0
        public override void LoadContent()
        {
            //create backdrop
            UIFactory.createFrame(null, new Point(0, 0), s_Container.GraphicsDevice.Viewport.Height, s_Container.GraphicsDevice.Viewport.Width, "Title");


            //create menu
            Entity e = ecs_instance.create();

            int   border   = 10;
            int   spacing  = 5;
            int   height   = 38;
            int   width    = 100;
            Point screen   = new Point(s_Container.GraphicsDevice.Viewport.Width, s_Container.GraphicsDevice.Viewport.Height);
            Point location = new Point(screen.X / 2 - (width + 2 * border) / 2, screen.Y / 2);

            s_ButtonMenu = new ButtonMenu(e, null, ecs_instance, 3, location, height, width, border, spacing);


            s_ButtonMenu.init();

            s_ButtonMenu.Frame.background_name  = "frame";
            s_ButtonMenu.Frame.background_color = Color.Black;
            s_ButtonMenu.Frame.transparency     = 0.75f;

            s_ButtonMenu.Buttons[0].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[0].background_color = Color.Gray;
            s_ButtonMenu.Buttons[0].transparency     = 1f; //0.75f;
            s_ButtonMenu.Buttons[0].border           = 10;
            s_ButtonMenu.Buttons[0].font_name        = "General";
            s_ButtonMenu.Buttons[0].autosize         = false;
            s_ButtonMenu.Buttons[0].center_text      = true;
            s_ButtonMenu.Buttons[0].text             = "New Game";
            s_ButtonMenu.Buttons[0].text_color       = Color.White;
            s_ButtonMenu.Buttons[0].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[0].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[0].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[0].mouse_click     += OnMouseClickNewGame;

            s_ButtonMenu.Buttons[1].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[1].background_color = Color.Gray;
            s_ButtonMenu.Buttons[1].transparency     = 1f;
            s_ButtonMenu.Buttons[1].border           = 10;
            s_ButtonMenu.Buttons[1].font_name        = "General";
            s_ButtonMenu.Buttons[1].autosize         = false;
            s_ButtonMenu.Buttons[1].center_text      = true;
            s_ButtonMenu.Buttons[1].text             = "World Gen";
            s_ButtonMenu.Buttons[1].text_color       = Color.White;
            s_ButtonMenu.Buttons[1].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[1].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[1].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[1].mouse_click     += OnMouseClickWorldGen;

            s_ButtonMenu.Buttons[2].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[2].background_color = Color.Gray;
            s_ButtonMenu.Buttons[2].transparency     = 1f;
            s_ButtonMenu.Buttons[2].border           = 10;
            s_ButtonMenu.Buttons[2].font_name        = "General";
            s_ButtonMenu.Buttons[2].autosize         = false;
            s_ButtonMenu.Buttons[2].center_text      = true;
            s_ButtonMenu.Buttons[2].text             = "Exit Game";
            s_ButtonMenu.Buttons[2].text_color       = Color.White;
            s_ButtonMenu.Buttons[2].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[2].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[2].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[2].mouse_click     += OnMouseClickExit;


            s_ButtonMenu.assemble();

            UserInterface ui = new UserInterface(s_ButtonMenu.Form);

            ecs_instance.add_component(e, ui);

            ecs_instance.resolve(e);

            //load the json start screen file
            s_json = s_JsonManager.loadJSON(GameConfig.root_dir + "/Content/json/start_screen.v");

            //create mouse pointer
            s_Frame = UIFactory.createMousePointer(InputManager.getMousePosition(), 10, 10, "pointer", OnMousePointerUpdate);

            //early entity reslove
            ecs_instance.resolve_entities();

            //load system content
            ecs_instance.system_manager.systems_load_content();

            base.LoadContent();
        }