Exemplo n.º 1
0
        protected void LoadMenus()
        {
            this.IsMouseVisible = true;
            mainMenuBG          = this.Content.Load <Texture2D>("Other\\menuBG");

            mainMenuContainer  = new UIContainer(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, mainMenuBG);
            pauseMenuContainer = new UIContainer(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, mainMenuBG);

            Texture2D tex_Element                = this.Content.Load <Texture2D>("Menu\\uielement");
            Texture2D tex_Element_Press          = this.Content.Load <Texture2D>("Menu\\uielement_pressed");
            int       texElementMainMenu         = mainMenuContainer.AddTexture(tex_Element);
            int       texElementPauseMenu        = pauseMenuContainer.AddTexture(tex_Element);
            int       texPressedElementMainMenu  = mainMenuContainer.AddTexture(tex_Element_Press);
            int       texPressedElementPauseMenu = pauseMenuContainer.AddTexture(tex_Element_Press);

            Dictionary <UIElementState, int> uielementStateMapMain = new Dictionary <UIElementState, int>();

            uielementStateMapMain.Add(UIElementState.None, texElementMainMenu);
            uielementStateMapMain.Add(UIElementState.Pressed, texPressedElementMainMenu);

            Dictionary <UIElementState, int> uielementStateMapPause = new Dictionary <UIElementState, int>();

            uielementStateMapPause.Add(UIElementState.None, texElementPauseMenu);
            uielementStateMapPause.Add(UIElementState.Pressed, texPressedElementPauseMenu);

            UIElement restartGame = new UIElement("btnRestart", new Rectangle(100, 100, 200, 50), uielementStateMapPause, "Restart");
            UIElement startGame   = new UIElement("btnStart", new Rectangle(100, 100, 200, 50), uielementStateMapMain, "Start!");

            pauseMenuContainer.AddElement(restartGame);
            mainMenuContainer.AddElement(startGame);

            startGame.RaiseUIElementReleasedEvent   += new EventHandler <UIElementReleasedEventArgs>(startGame_RaiseUIElementReleasedEvent);
            restartGame.RaiseUIElementReleasedEvent += new EventHandler <UIElementReleasedEventArgs>(restartGame_RaiseUIElementReleasedEvent);
            font      = this.Content.Load <SpriteFont>("mainFont");
            alertFont = this.Content.Load <SpriteFont>("alertFont");

            mainMenuContainer.Font  = font;
            pauseMenuContainer.Font = font;
        }
Exemplo n.º 2
0
        protected void LoadMenus()
        {
            this.IsMouseVisible = true;
            mainMenuBG = this.Content.Load<Texture2D>("Other\\menuBG");

            mainMenuContainer = new UIContainer(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight,mainMenuBG);
            pauseMenuContainer = new UIContainer(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, mainMenuBG);

            Texture2D tex_Element = this.Content.Load<Texture2D>("Menu\\uielement");
            Texture2D tex_Element_Press = this.Content.Load<Texture2D>("Menu\\uielement_pressed");
            int texElementMainMenu = mainMenuContainer.AddTexture(tex_Element);
            int texElementPauseMenu = pauseMenuContainer.AddTexture(tex_Element);
            int texPressedElementMainMenu = mainMenuContainer.AddTexture(tex_Element_Press);
            int texPressedElementPauseMenu = pauseMenuContainer.AddTexture(tex_Element_Press);

            Dictionary<UIElementState, int> uielementStateMapMain = new Dictionary<UIElementState, int>();
            uielementStateMapMain.Add(UIElementState.None, texElementMainMenu);
            uielementStateMapMain.Add(UIElementState.Pressed, texPressedElementMainMenu);

            Dictionary<UIElementState, int> uielementStateMapPause = new Dictionary<UIElementState, int>();
            uielementStateMapPause.Add(UIElementState.None, texElementPauseMenu);
            uielementStateMapPause.Add(UIElementState.Pressed, texPressedElementPauseMenu);

            UIElement restartGame = new UIElement("btnRestart", new Rectangle(100, 100, 200, 50), uielementStateMapPause, "Restart");
            UIElement startGame = new UIElement("btnStart", new Rectangle(100, 100, 200, 50), uielementStateMapMain, "Start!");

            pauseMenuContainer.AddElement(restartGame);
            mainMenuContainer.AddElement(startGame);

            startGame.RaiseUIElementReleasedEvent += new EventHandler<UIElementReleasedEventArgs>(startGame_RaiseUIElementReleasedEvent);
            restartGame.RaiseUIElementReleasedEvent += new EventHandler<UIElementReleasedEventArgs>(restartGame_RaiseUIElementReleasedEvent);
            font = this.Content.Load<SpriteFont>("mainFont");
            alertFont = this.Content.Load<SpriteFont>("alertFont");

            mainMenuContainer.Font = font;
            pauseMenuContainer.Font = font;
        }