public override void Execute(UIComponent uiComponent)
        {
            
            if (uiComponent.children.Count > 0)
            {
                int curChildIndex = 0;
                UIComponent curChild = uiComponent.children[curChildIndex];
                while (!curChild.hasFocus && curChildIndex < uiComponent.children.Count - 1)
                {
                    curChildIndex++;
                    curChild = uiComponent.children[curChildIndex];
                }

                if (curChild.hasFocus)
                {
                    movement.Normalize();
                    if (movement.Y > 0)
                    {
                        if (curChildIndex == 0)
                        {
                            curChildIndex = uiComponent.children.Count - 1;
                        }
                        else
                            curChildIndex--;
                    }
                    else if (movement.Y < 0)
                    {
                        if (curChildIndex == uiComponent.children.Count - 1)
                        {
                            curChildIndex = 0;
                        }
                        else
                            curChildIndex++;
                    }
                    uiComponent.children[curChildIndex].giveFocus();
                }
                else
                {
                    uiComponent.children[0].giveFocus();
                }
                
            }
        }
Esempio n. 2
0
 public abstract void Execute(UIComponent uiComponent);
Esempio n. 3
0
 private void mouseMoved(int x, int y)
 {
     Rectangle mouseRect = new Rectangle(x, y, 0, 0);
     if (focusedElement != null && !focusedElement.dimensions.Intersects(mouseRect))
     {
         focusedElement.takeFocus();
         focusedElement = null;
     }
     foreach (UIComponent child in rootGUIElement.children)
     {
         if (child.dimensions.Intersects(mouseRect) && child.canHaveFocus)
         {
             
             child.giveFocus();
             focusedElement = child;
         }
     }
 }
Esempio n. 4
0
        public void enterPauseMenu()
        {
            menuItems.Clear();

            Panel pauseMenu = new Panel(guiTextures["whiteSquare"], Color.Black);
            pauseMenu.dimensions.Width = drawSpace.Width / 4;
            pauseMenu.dimensions.Height = drawSpace.Height / 4;
            pauseMenu.dimensions.X = drawSpace.Width / 2 - pauseMenu.dimensions.Width/2;
            pauseMenu.dimensions.Y = drawSpace.Height / 2 - pauseMenu.dimensions.Height / 2;

            pauseLabel = new Label(spriteFont, "Paused");
            pauseLabel.dimensions.X = drawSpace.Width / 2 - (int)spriteFont.MeasureString("Paused").X /2;
            pauseLabel.dimensions.Y = drawSpace.Height / 2 - (int)spriteFont.MeasureString("Paused").Y / 2 - 60;

            pauseButton = new Button(guiTextures["exitButton"]);
            pauseButton.dimensions.Width = drawSpace.Width / 6;
            pauseButton.dimensions.Height = drawSpace.Height / 8;
            pauseButton.dimensions.X = drawSpace.Width / 2 - pauseButton.dimensions.Width / 2;
            pauseButton.dimensions.Y = drawSpace.Height / 2 - pauseButton.dimensions.Height / 2 + 30;
            pauseButton.onClick = exitClicked;

            pausePanel = pauseMenu;
            menuItems.Add(pauseMenu);
            menuItems.Add(pauseLabel);
            menuItems.Add(pauseButton);
            pauseMenu.children.Add(pauseLabel);
            pauseMenu.children.Add(pauseButton);
            rootGUIElement = pauseMenu;
            menuEnabled = true;
            //EnableMenu(this, EventArgs.Empty);
        }
Esempio n. 5
0
        public void enterStartMenu()
        {
            menuItems.Clear();
            actors.Clear();
            props.Clear();
            credits.Clear();
            drawSpace.X = 0;
            drawSpace.Y = 0;

            Panel bg = new Panel(guiTextures["menuPanel"], Color.White);
            bg.dimensions.X = drawSpace.X;
            bg.dimensions.Y = drawSpace.Y;
            bg.dimensions.Width = drawSpace.Width;
            bg.dimensions.Height = drawSpace.Height;

            Panel logo = new Panel(guiTextures["logo"], new Color(255, 255, 255));
            logo.dimensions.Width = drawSpace.Width * 4 / 5;
            logo.dimensions.Height = drawSpace.Height * 2 / 10;
            logo.dimensions.X = drawSpace.Width / 2 - logo.dimensions.Width / 2;
            logo.dimensions.Y = 50;
            
            bg.addChild(logo);

            Button newGameButton = new Button(guiTextures["newGameButton"]);
            newGameButton.dimensions.Width = drawSpace.Width * 2 / 5;
            newGameButton.dimensions.Height = drawSpace.Height / 6;
            newGameButton.dimensions.X = drawSpace.Width / 2 - newGameButton.dimensions.Width / 2;
            newGameButton.dimensions.Y = drawSpace.Height * 3 / 10;
            newGameButton.onClick = newGameClicked;
            bg.addChild(newGameButton);

            Button tutorialButton = new Button(guiTextures["tutorialButton"]);
            tutorialButton.dimensions.Width = drawSpace.Width * 2 / 5;
            tutorialButton.dimensions.Height = drawSpace.Height / 6;
            tutorialButton.dimensions.X = drawSpace.Width / 2 - tutorialButton.dimensions.Width / 2;
            tutorialButton.dimensions.Y = drawSpace.Height * 5 / 10;
            tutorialButton.onClick = tutorialClicked;
            bg.addChild(tutorialButton);

            Button creditsButton = new Button(guiTextures["creditsButton"]);
            creditsButton.dimensions.Width = drawSpace.Width * 2 / 5;
            creditsButton.dimensions.Height = drawSpace.Height / 6;
            creditsButton.dimensions.X = drawSpace.Width / 2 - creditsButton.dimensions.Width / 2;
            creditsButton.dimensions.Y = drawSpace.Height * 7 / 10;
            creditsButton.onClick = creditsClicked;
            bg.addChild(creditsButton);


            menuItems.Add(bg);
            rootGUIElement = bg;
            menuEnabled = true;
            //EnableMenu(this, EventArgs.Empty);
        }
Esempio n. 6
0
 public void enterStartMenu()
 {
     menuItems.Clear();
     drawSpace.X = 0;
     drawSpace.Y = 0;
     Panel bg = new Panel(guiTextures["menuPanel"], new Color(255, 255, 255));
     bg.dimensions.X = drawSpace.X;
     bg.dimensions.Y = drawSpace.Y;
     bg.dimensions.Width = drawSpace.Width;
     bg.dimensions.Height = drawSpace.Height;
     Panel logo = new Panel(guiTextures["logo"], new Color(255, 255, 255));
     logo.dimensions.X = drawSpace.Width / 2 - guiTextures["logo"].Width /2;
     logo.dimensions.Y = 50;
     logo.dimensions.Width = guiTextures["logo"].Width;
     logo.dimensions.Height = guiTextures["logo"].Height * 4 / 5;
     Button newGameButton = new Button(guiTextures["newGameButton"]);
     newGameButton.dimensions.X = drawSpace.Width / 2 - guiTextures["newGameButton"].Width / 2;
     newGameButton.dimensions.Y = 400;
     newGameButton.dimensions.Width = guiTextures["newGameButton"].Width;
     newGameButton.dimensions.Height = guiTextures["newGameButton"].Height * 4 / 5;
     newGameButton.onClick = newGameClicked;
     bg.addChild(newGameButton);
     bg.addChild(logo);
     menuItems.Add(bg);
     rootGUIElement = bg;
     menuEnabled = true;
     //EnableMenu(this, EventArgs.Empty);
 }
Esempio n. 7
0
 public void addChild(UIComponent child){
     child.dimensions.X += dimensions.X;
     child.dimensions.Y += dimensions.Y;
     child.parent = this;
     children.Add(child);
 }