예제 #1
0
 public UIElementReleasedEventArgs(UIElement element, string cmd)
 {
     _element = element;
     _command = cmd;
 }
예제 #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;
        }
예제 #3
0
 public void AddElement(UIElement element)
 {
     _elementMap.Add(element.Name, element);
 }