public IMenu AddTextBox(string label, Action <string, IMenuTextBox> onChange, out IMenuTextBox control, string startingText = "", bool multiLine = false)
        {
            var item = new MenuTextBox(label, startingText, multiLine);

            item.OnChange = (v) => onChange((string)v, item);
            _items.Add(item);
            control = item;
            return(this);
        }
        public static void Init()
        {
            screenWidth  = ScreenManager.screenWidth;
            screenHeight = ScreenManager.screenHeight;

            RightBorderLine            = new Rectangle();
            RightBorderLine.BorderType = Shapes.BORDER_TYPE.Single;
            RightBorderLine.Create(
                new Point(ScreenManager.screenWidth - 30 - 2, ScreenManager.MapWidowHeight + ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2)),
                new Size(32, ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2)),
                BorderColor, ConsoleColor.Black);

            BorderLine            = new Rectangle();
            BorderLine.BorderType = Shapes.BORDER_TYPE.Single;
            BorderLine.Create(
                new Point(0, ScreenManager.MapWidowHeight + ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2)),
                new Size(ScreenManager.MapWindowsWidth + (ScreenManager.DefaultBorder * 2) - 32,
                         ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2)),
                BorderColor, ConsoleColor.Black);

            //Top Title
            InstrutionLabel = new TextBox();
            InstrutionLabel.Create(new Point(2, ScreenManager.screenHeight - 3),
                                   new Size(ScreenManager.screenWidth - 32 - 4 - 1, 1), ConsoleColor.White, ConsoleColor.Black);
            //InstrutionLabel.alighnment = TextBox.ALIGN_ENUM.Centre_Justify;
            InstrutionLabel.textItem = InstrutionLabelStrVal;

            /* Text Box for the Options Menu */
            menutxtBox = new MenuTextBox();
            menutxtBox.Create(
                new Point(ScreenManager.screenWidth - 30, ScreenManager.MapWidowHeight + ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2) + 1),
                new Size(29, 9),
                ConsoleColor.White, ConsoleColor.Black);
            menutxtBox.lineItem = menuOptions;

            messagebox = new MultiLineTextBox();
            messagebox.Create(
                new Point(2, ScreenManager.MapWidowHeight + ScreenManager.HUDHeight + (ScreenManager.DefaultBorder * 2) + 1),
                new Size(ScreenManager.screenWidth - 32 - 4 - 1, 9),
                ConsoleColor.White, ConsoleColor.Black);
            messagebox.textItem = "1234567890123456789012345678901234567890123456789012345678901234567890ABCDEFGHIJKLMNOP";
        }
Esempio n. 3
0
        protected override void LoadContent()
        {
            GameDatas.GameFocus = true;
            IsMouseVisible      = true;

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _gameStates = new Stack <GameState>();

            //////////////////////////////////////////////////////////

            GameDatas.Theme = new Theme("PinkTheme", 10, 40, 17, 3, 28, 33, 5, 50, 48);

            GameDatas.Theme.Load(Content);

            //////////////////////////////////////////////////////////

            _graphics.PreferredBackBufferWidth  = GameDatas.Theme.GridTexture.Width * 2 + 50;
            _graphics.PreferredBackBufferHeight = GameDatas.Theme.GridTexture.Height +
                                                  GameDatas.Theme.LogoTexture.Height + 50;
            _graphics.ApplyChanges();

            GameDatas.WindowWidth  = Window.ClientBounds.Width;
            GameDatas.WindowHeight = Window.ClientBounds.Height;

            //////////////////////////////////////////////////////////

            var logo           = new MenuPassive(GameDatas.Theme.LogoTexture);
            var comeBackButton = new MenuButton("Come Back :D");

            // CREATION MENU CREATE GAME

            var createNameTextBox = new MenuTextBox("What's your name?");
            var submitCreateGame  = new MenuButton("Go !")
            {
                Click = CreateGame
            };

            var createGameMenuItems = new List <MenuItem> {
                logo, createNameTextBox, submitCreateGame, comeBackButton
            };
            var createGameMenuState = new MenuState(createGameMenuItems, true);

            createGameMenuState.SetPositions();
            submitCreateGame.subMenu = createGameMenuState;

            // CREATION MENU JOIN GAME

            var joinNameTextBox = new MenuTextBox("What's your name?");
            var serverIpTextBox = new MenuTextBox("IP Server :D");
            var submitJoinGame  = new MenuButton("Go !");

            var joinGameMenuItems = new List <MenuItem> {
                logo, joinNameTextBox, serverIpTextBox, submitJoinGame, comeBackButton
            };
            var joinGameMenuState = new MenuState(joinGameMenuItems, true);

            joinGameMenuState.SetPositions();
            submitJoinGame.subMenu = joinGameMenuState;
            submitJoinGame.Click   = JoinGame;
            comeBackButton.Click   = _comeBack;

            // CREATION MENU ACCUEIL

            var createGameButton = new MenuButton("Create a Game");
            var joinGameButton   = new MenuButton("Join a Game");

            createGameButton.subMenu = createGameMenuState;
            createGameButton.Click   = _launchMenu;
            joinGameButton.subMenu   = joinGameMenuState;
            joinGameButton.Click     = _launchMenu;

            var homeMenuItems = new List <MenuItem> {
                logo, createGameButton, joinGameButton
            };
            var homeMenuState = new MenuState(homeMenuItems, true);

            homeMenuState.SetPositions();

            // FIN CREATION MENUS

            _gameStates.Push(homeMenuState);
            _gameStates.Peek().Initialize();
            _gameStates.Peek().LoadContent(Content);
        }
Esempio n. 4
0
        /*
         * public static void UpdateArmourLevel(int level)
         * {
         *  ArmourBar.Percent = level;
         *  ArmourBar.draw();
         * }
         */

        public static void Init()
        {
            PanelWidth  = (ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1;
            PanelHeight = ScreenManager.MapWidowHeight;

            BorderLine            = new Rectangle();
            BorderLine.BorderType = Shapes.BORDER_TYPE.Single;
            BorderLine.Create(
                new Point(
                    ((ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2) + ScreenManager.RoomMapWindowsWidth + 1,
                    ScreenManager.HUDHeight + 2),
                new Size(
                    (ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1,
                    ScreenManager.MapWidowHeight),
                BorderColor, ConsoleColor.Black);

            UIPosCol = ((ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2) + ScreenManager.RoomMapWindowsWidth + 1;
            UIPosRow = ScreenManager.HUDHeight + 2;

            //Top Title
            TitleLabel = new TextBox();
            TitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 1),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            TitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            TitleLabel.textItem   = "Legend";

            //HealthLevelTitleLabel
            HealthLevelTitleLabel = new TextBox();
            HealthLevelTitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 15),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            HealthLevelTitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            HealthLevelTitleLabel.textItem   = "Health Level";

            //HealthBar

            HealthBar = new PercentageBar();
            HealthBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 17),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            HealthBar.BarWidth = 20;
            HealthBar.Percent  = 100;


            //EnemyTitleLabel

            EnemyTitleLabel = new TextBox();
            EnemyTitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 19),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            EnemyTitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            EnemyTitleLabel.textItem   = "";


            //EnemyHealthBar

            EnemyHealthBar = new PercentageBarEx1();
            EnemyHealthBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 21),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            EnemyHealthBar.BarWidth = 20;
            EnemyHealthBar.Percent  = 0;


            /* Text Box for the Options Menu */
            menutxtBox = new MenuTextBox();
            menutxtBox.Create(
                new Point(UIPosCol + 2, UIPosRow + 3),
                new Size(PanelWidth - 4, 11),
                ConsoleColor.White, ConsoleColor.Black);
            menutxtBox.lineItem = menuOptions;
        }
        public Menu()
        {
            MenuBackground = new MenuBackground();

            ScoreBox        = new MenuTextBox(new Vector2f(0, 350), new Vector2f(1000, 40), "ffff", 20);
            PlayerNameInput = new TextInput(new Vector2f(300, 410), new Vector2f(400, 80), "Enter your name", 20);

            QuitButton       = new ActionTextButton(new Vector2f(0, 510), new Vector2f(1000, 80), "Quit", 30, OnQuitClicked);
            QuitNoSaveButton = new ActionTextButton(new Vector2f(0, 610), new Vector2f(1000, 80), "Surrender", 30, OnQuitNoSaveButton);

            BackButton = new ActionTextButton(new Vector2f(0, 910), new Vector2f(1000, 80), "Back", 30, OnBackClicked);

            ScoresText = new MenuTextBox(new Vector2f(0, 110), new Vector2f(1000, 40), "Top Scores", 30);
            ScoresPrev = new ActionTextButton(new Vector2f(100, 810), new Vector2f(300, 80), "Prev", 30, OnPrevClicked);
            ScoresNext = new ActionTextButton(new Vector2f(600, 810), new Vector2f(300, 80), "Next", 30, OnNextClicked);

            ScoreActors = new List <Actor> {
                BackButton, ScoresText, ScoresNext, ScoresPrev
            };

            Layers = new Dictionary <MenuLayer, List <Actor> >
            {
                {
                    MenuLayer.Main,
                    new List <Actor>
                    {
                        new ActionTextButton(new Vector2f(0, 110), new Vector2f(1000, 80), "New Game", 30, OnStartGameClicked),
                        new ActionTextButton(new Vector2f(0, 210), new Vector2f(1000, 80), "Continue", 30, OnContinueGameClicked),
                        new ActionTextButton(new Vector2f(0, 310), new Vector2f(1000, 80), "Keyboard Settings", 30, OnKeysClicked),
                        new ActionTextButton(new Vector2f(0, 410), new Vector2f(1000, 80), "Top Scores", 30, OnScoresClicked),
                        QuitButton,
                        QuitNoSaveButton
                    }
                },
                {
                    MenuLayer.Keys,
                    new List <Actor>
                    {
                        new MenuTextBox(new Vector2f(100, 110), new Vector2f(300, 80), KeyActionType.MoveUp.Item2, 20, null, TextPosition.Start),
                        new MenuTextBox(new Vector2f(100, 210), new Vector2f(300, 80), KeyActionType.MoveDown.Item2, 20, null, TextPosition.Start),
                        new MenuTextBox(new Vector2f(100, 310), new Vector2f(300, 80), KeyActionType.MoveLeft.Item2, 20, null, TextPosition.Start),
                        new MenuTextBox(new Vector2f(100, 410), new Vector2f(300, 80), KeyActionType.MoveRight.Item2, 20, null, TextPosition.Start),
                        new MenuTextBox(new Vector2f(100, 510), new Vector2f(300, 80), KeyActionType.Shoot.Item2, 20, null, TextPosition.Start),
                        new MenuTextBox(new Vector2f(100, 610), new Vector2f(300, 80), KeyActionType.Pause.Item2, 20, null, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 110), new Vector2f(300, 80), KeyActionType.MoveUp, 20, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 210), new Vector2f(300, 80), KeyActionType.MoveDown, 20, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 310), new Vector2f(300, 80), KeyActionType.MoveLeft, 20, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 410), new Vector2f(300, 80), KeyActionType.MoveRight, 20, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 510), new Vector2f(300, 80), KeyActionType.Shoot, 20, TextPosition.Start),
                        new ChangeKeyButton(new Vector2f(600, 610), new Vector2f(300, 80), KeyActionType.Pause, 20, TextPosition.Start),
                        BackButton
                    }
                },
                {
                    MenuLayer.EndScreen,
                    new List <Actor>
                    {
                        new MenuTextBox(new Vector2f(0, 110), new Vector2f(1000, 80), "GAME OVER", 40),
                        new MenuTextBox(new Vector2f(0, 310), new Vector2f(1000, 40), "Your Score:", 20),
                        ScoreBox,
                        PlayerNameInput,
                        new ActionTextButton(new Vector2f(0, 710), new Vector2f(1000, 80), "Return to menu", 30, OnBackToMenuClicked)
                    }
                },
                {
                    MenuLayer.Scores,
                    new List <Actor> (ScoreActors)
                }
            };

            ShowMenu();
        }