Ejemplo n.º 1
0
 public static void loadMenu(Menu menu)
 {
     if(CurrentMenu !=null)
         CurrentMenu.Active = false;
     CurrentMenu = menu;
     CurrentMenu.Active = true;
 }
Ejemplo n.º 2
0
 public MenuTest()
 {
     parent = new Menu("p");
     child0 = new Menu("c0", parent);
     child1 = new Menu("c1", parent);
     child0_0 = new Menu("c0_0", child0);
     child1_0 = new Menu("c1_0", child1);
     child1_1 = new Menu("c1_1", child1);
     child1_2 = new Menu("c1_2", child1);
 }
Ejemplo n.º 3
0
        public Button(string textureId, Vector2 position, Vector2 size, IParent parent)
            : base(parent: parent, textureId: textureId, position: position, size: size, collidable: false)
        {
            _onClickListeners = new List<FunctionCall>();
            _onClickListenersString = new List<Tuple<FunctionCallString, string>>();
            Color = Color.White;

            if (parent is Menu)
                parentMenu = (Menu)parent;
            else
                parentMenu = null;

            InputManager.AddMouseMoveCallback(MouseOver, parentMenu, parent is Menu);
            InputManager.AddMouseCallback(InputManager.MouseButtons.LeftButton, OnClick, InputManager.InputState.OnInputDown, parentMenu, parent is Menu);
        }
Ejemplo n.º 4
0
        private void createMenus()
        {
            TextureManager.LoadTexture("bgMainMenu");
            TextureManager.LoadTexture("bgSelectLevel");
            TextureManager.LoadTexture("bgControls");
            TextureManager.LoadTexture("bgMainMenuText");
            TextureManager.LoadTexture("bgSelectLevelText");
            TextureManager.LoadTexture("bgControlsText");

            //Main menu creation
            Menu.MainMenu = new Menu("mainmenu");
            Menu.MainMenu.Background = new Sprite(Menu.MainMenu, "bgMainMenu");
            Menu.MainMenu.Text = new Sprite(Menu.MainMenu, "bgMainMenuText");

            Button startButton = new Button("button", "Start Game", Color.Cyan, new Vector2(200, 300), new Vector2(230, 40), Menu.MainMenu);
            Button levelSelectButton = new Button("button", "Select Level", Color.Lime, new Vector2(200, 360), new Vector2(230, 40), Menu.MainMenu);
            Button controlsButton = new Button("button", "Controls", Color.Orange, new Vector2(200, 420), new Vector2(230, 40), Menu.MainMenu);
            Button exitButton = new Button("button", "Quit", Color.Red, new Vector2(200, 480), new Vector2(230, 40), Menu.MainMenu);

            Menu.MainMenu.MenuElements.Add(startButton);
            Menu.MainMenu.MenuElements.Add(levelSelectButton);
            Menu.MainMenu.MenuElements.Add(controlsButton);
            Menu.MainMenu.MenuElements.Add(exitButton);

            //Levelselect menu creation
            Menu levelSelect = new Menu("mainSelectLevel", Menu.MainMenu);
            levelSelect.Background = new Sprite(levelSelect, "bgSelectLevel");
            levelSelect.Text = new Sprite(Menu.MainMenu, "bgSelectLevelText");
            Button levelSelectBack = new Button("button", "Back", Color.Lime, new Vector2(200, 100), new Vector2(230, 40), levelSelect);
            levelSelect.MenuElements.Add(levelSelectBack);

            //Controls menu
            Menu controlsMenu = new Menu("mainControls", Menu.MainMenu);
            controlsMenu.Background = new Sprite(controlsMenu, "bgControls");
            controlsMenu.Text = new Sprite(controlsMenu, "bgControlsText");
            Button controlsBack = new Button("button", "Back", Color.Orange, new Vector2(200, 100), new Vector2(230, 40), controlsMenu);
            controlsMenu.MenuElements.Add(controlsBack);

            string[] filePaths = System.IO.Directory.GetFiles("../../../../levels/", "*.xml");
            string tmpFilename;
            Vector2 buttonPos = new Vector2(-50, 300);
            foreach (string fn in filePaths) {
                if (buttonPos.X >= 750) {
                    buttonPos.X = 200;
                    buttonPos.Y += 80;
                } else {
                    buttonPos.X += 250;
                }
                tmpFilename = System.IO.Path.GetFileNameWithoutExtension(fn);

                levelList.Add(tmpFilename);
                Button loadLevelButton = new Button("button", tmpFilename, Color.Red, buttonPos, new Vector2(230, 40), levelSelect);
                loadLevelButton.AddOnClickListener(LoadLevel, tmpFilename);
                levelSelect.MenuElements.Add(loadLevelButton);
            }

            _pauseMenu = new PauseMenu(this);

            //Main menu button functions
            if (levelList.Count > 0) {
                startButton.AddOnClickListener(LoadLevel, levelList[0]);
            }
            levelSelectButton.AddOnClickListener(Menu.MainMenu.goToChildMenu, levelSelect.Id);
            controlsButton.AddOnClickListener(Menu.MainMenu.goToChildMenu, controlsMenu.Id);
            exitButton.AddOnClickListener(Exit);

            //back to main menu buttons
            levelSelectBack.AddOnClickListener(levelSelect.goToParentMenu);
            controlsBack.AddOnClickListener(CheckPauseBackButton);

            Menu.loadMenu(Menu.MainMenu);

            InputManager.AddKeyboardCallback(Keys.Escape, Exit, InputManager.InputState.OnInputDown, Menu.MainMenu, true);
            InputManager.AddKeyboardCallback(Keys.Escape, levelSelect.goToParentMenu, InputManager.InputState.OnInputDown, levelSelect, true);
            InputManager.AddKeyboardCallback(Keys.Escape, controlsMenu.goToParentMenu, InputManager.InputState.OnInputDown, controlsMenu, true);

            _pauseMenu.Initialize();
            levelSelect.Initialize();
            controlsMenu.Initialize();
            Menu.MainMenu.Initialize();
        }
Ejemplo n.º 5
0
 public Menu(string id, Menu parent)
 {
     Parent = parent;
     initialize(id);
 }
Ejemplo n.º 6
0
 public static void AddGamePadCallback(PlayerIndex gamePad, Buttons button, FunctionCall function, InputState inputState, Menu inMenu = null, bool important = false)
 {
     _callbackList.Add(
         new GamePadInputData(
             playerIndex: gamePad,
             inputValue: (int)button,
             modifier: -1,
             function: function,
             inputState: inputState,
             inMenu: inMenu,
             important: important
             )
         );
 }
Ejemplo n.º 7
0
 public void ExitMenu()
 {
     CurrentMenu.Active = false;
     CurrentMenu = null;
 }
Ejemplo n.º 8
0
 public GamePadInputData(PlayerIndex playerIndex, int inputValue, int modifier, FunctionCall function, InputState inputState, Menu inMenu, bool important)
     : base(inputValue, modifier, function, inputState, InputType.GamePad, inMenu, important)
 {
     PlayerIndex = playerIndex;
 }
Ejemplo n.º 9
0
 public InputData(int inputValue, int modifier, FunctionCall function, InputState inputState, InputType inputType, Menu inMenu, bool important)
 {
     this.Function = function;
     this.InputState = inputState;
     this.InputValue = inputValue;
     this.InputType = inputType;
     this.Enabled = true;
     this.InMenu = inMenu;
     this.Important = important;
     this.Modifier = modifier;
 }
Ejemplo n.º 10
0
 public static void RemoveMouseCallback(MouseButtons mousebutton, InputState inputState, Menu inMenu = null, bool important = false)
 {
     RemoveCallback(
         inputValue: (int)mousebutton,
         modifier: -1,
         inputState: inputState,
         inputType: InputType.Mouse,
         inMenu: inMenu,
         important: important
     );
 }
Ejemplo n.º 11
0
 private static void RemoveCallback(int inputValue, int modifier, InputState inputState, InputType inputType, Menu inMenu, bool important)
 {
     for (int i = _callbackList.Count - 1; i >= 0; i--) {
         if (
             _callbackList[i].InputValue == inputValue &&
             _callbackList[i].InputState == inputState &&
             _callbackList[i].InputType == inputType &&
             _callbackList[i].InMenu == inMenu &&
             _callbackList[i].Important == important &&
             _callbackList[i].Modifier == modifier
          ) {
             _callbackList.RemoveAt(i);
             return;
         }
     }
 }
Ejemplo n.º 12
0
 public static void RemoveKeyboardCallback(Keys key, Keys modifier, InputState inputState, Menu inMenu = null, bool important = false)
 {
     RemoveCallback(
         inputValue: (int)key,
         modifier: (int)modifier,
         inputState: inputState,
         inputType: InputType.Keyboard,
         inMenu: inMenu,
         important: important
     );
 }
Ejemplo n.º 13
0
 public static void RemoveGamePadCallback(PlayerIndex playerIndex, Buttons key, InputState inputState, Menu inMenu = null, bool important = false)
 {
 }
Ejemplo n.º 14
0
 public static void AddMouseMoveCallback(FunctionCall function, Menu inMenu = null, bool important = false)
 {
     _callbackList.Add(
         new InputData(
             inputValue: 0,
             modifier: -1,
             function: function,
             inputState: 0,
             inputType: InputType.MouseMove,
             inMenu: inMenu,
             important: important
         )
     );
 }
Ejemplo n.º 15
0
 public static void AddMouseCallback(MouseButtons Mousebutton, Keys modifier, FunctionCall function, InputState inputState, Menu inMenu = null, bool important = false)
 {
     _callbackList.Add(
         new InputData(
             inputValue: (int)Mousebutton,
             modifier: (int)modifier,
             function: function,
             inputState: inputState,
             inputType: InputType.Mouse,
             inMenu: inMenu,
             important: important
         )
     );
 }
Ejemplo n.º 16
0
 public static void AddKeyboardCallback(Keys key, FunctionCall function, InputState inputState, Menu inMenu = null, bool important = false)
 {
     _callbackList.Add(new InputData((int)key, -1, function, inputState, InputType.Keyboard, inMenu, important));
 }