public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard) { if (!updateReady) { updateReady = true; } if (!dummy.Move && !cleanUp) { dummy.Move = true; } headLine.Update(time, null, mouseState); dummy.Update(time, null, mouseState); foreach (GUI_Element e in elements) { e.Update(time, null, mouseState); } if ((returnButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) || keyboard.IsKeyDown(Keys.Back) || (keyboard.IsKeyDown(Keys.Escape))) { dummy.Move = false; cleanUp = true; returnButton.SpriteColor = Color.Gray; } if (cleanUp && book.CurrentRectangle.Y <= -500 && pressedButton == null) { pressedButton = returnButton; } }
private void UpdatePosition(GUI_Element c) { if (topPole != null) { float tempWidth = MathHelper.Lerp(0, topPole.Rectangle.Width, positionLerpCounter); topPole.CurrentRectangle = new Rectangle(topPole.Rectangle.X, topPole.Rectangle.Y, (int)tempWidth, topPole.Rectangle.Height); } if (bottomPole != null) { float tempWidth = MathHelper.Lerp(0, bottomPole.Rectangle.Width, positionLerpCounter); bottomPole.CurrentRectangle = new Rectangle(bottomPole.Rectangle.X, bottomPole.Rectangle.Y, (int)tempWidth, bottomPole.Rectangle.Height); } c.CurrentRectangle = this.getNewRectangel(c); if (c.Frame != null) { float tempFrameX = MathHelper.Lerp(rectangle.X, c.Frame.Rectangle.X, positionLerpCounter); c.Frame.CurrentRectangle = new Rectangle((int)tempFrameX, c.Frame.Rectangle.Y, c.Frame.Rectangle.Width, c.Frame.Rectangle.Height); } if (c.LeftChain != null) { c.LeftChain.CurrentRectangle = this.getNewRectangel(c.LeftChain); } if (c.RightChain != null) { c.RightChain.CurrentRectangle = this.getNewRectangel(c.RightChain); } }
public static void createGUI() { background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BlackBackgoundHUD); background.SpriteColor = new Color(0.7f, 0.7f, 0.7f, 0.2f); all.Add(background); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 450 - 128 - 10, 512, 128), " Game Over", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 8; all.Add(headLine); underLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 450 - 128 - 10 + 70, 512, 128), " Your Headquarter got destroied!", Vars_Func.GUI_ElementTyp.Dummy); headLine.YBonus = 0; all.Add(headLine); GUI_Element yesButton = new GUI_Element(new Rectangle(1366 / 2 - 256, 450, 128, 64), " Restart", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.NewGameButton); yesButton.Highlightable = true; yesButton.YBonus = 12; buttons.Add(yesButton); all.Add(yesButton); GUI_Element noButton = new GUI_Element(new Rectangle(1366 / 2 + 256 - 128, 450, 128, 64), " Quit", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.QuitButton); noButton.Highlightable = true; noButton.YBonus = 12; buttons.Add(noButton); all.Add(noButton); }
public static void restGUI() { pressedButton = null; cleanUp = false; dontDraw = false; updateReady = false; }
public static void restGUI() { currentSelectedButton = null; pressedButton = null; buttonCounter = 0; visibleLerpCounter = 1; cleanUp = false; dontDraw = false; updateReady = false; }
public static void createGUI() { background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BlackBackgoundHUD); background.SpriteColor = new Color(0.7f, 0.7f, 0.7f, 0.2f); elements.Add(background); all.Add(background); GUI_Element newGameButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 180, 384, 96), " Continue", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.NewGameButton); newGameButton.Highlightable = true; newGameButton.YBonus = 10; buttons.Add(newGameButton); all.Add(newGameButton); GUI_Element settingsFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); frames.Add(settingsFrame); all.Add(settingsFrame); GUI_Element settingsButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296, 384, 96), " Settings", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.SettingsButton); settingsButton.Highlightable = true; settingsButton.YBonus = 10; buttons.Add(settingsButton); all.Add(settingsButton); GUI_Element highscoreFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 412 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); frames.Add(highscoreFrame); all.Add(highscoreFrame); GUI_Element highscoreButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 412, 384, 96), " Highscore", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.HighScoreButton); highscoreButton.Highlightable = true; highscoreButton.YBonus = 10; buttons.Add(highscoreButton); all.Add(highscoreButton); GUI_Element quitFrame = new GUI_Element(new Rectangle(1366 / 2 - (288 / 2), 528 - 32, 288, 64), "", Vars_Func.GUI_ElementTyp.ChainSmall); frames.Add(quitFrame); all.Add(quitFrame); GUI_Element quitButton = new GUI_Element(new Rectangle(1366 / 2 - (288 / 2), 528, 288, 72), " Exit", Vars_Func.GUI_ElementTyp.TextFieldSmall, Vars_Func.GUI_Typ.StartButton); quitButton.Highlightable = true; quitButton.YBonus = 10; buttons.Add(quitButton); all.Add(quitButton); }
private Rectangle getNewRectangel(GUI_Element c) { float tempX = rectangle.X; if (moveAlongX) { tempX = MathHelper.Lerp(rectangle.X, c.Rectangle.X, positionLerpCounter); } float tempY = c.Rectangle.Y; if (moveAlongY) { tempX = c.Rectangle.X; tempY = MathHelper.Lerp(rectangle.Y, c.Rectangle.Y, positionLerpCounter); } return(new Rectangle((int)tempX, (int)tempY, c.Rectangle.Width, c.Rectangle.Height)); }
public static void createGUI() { background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BlackBackgoundHUD); background.SpriteColor = new Color(0.7f, 0.7f, 0.7f, 0.2f); all.Add(background); underLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 450 - 96 - 10, 512, 96), " Please insert you name:", Vars_Func.GUI_ElementTyp.TextFieldBig); underLine.YBonus = 10; all.Add(underLine); GUI_Element quitButton = new GUI_Element(new Rectangle(1366 / 2 - 128 + 32, 450, 256 - 64, 64), " Confirm", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.QuitButton); quitButton.Highlightable = true; quitButton.YBonus = 12; buttons.Add(quitButton); all.Add(quitButton); }
public static void createGUI() { visibleLerpCounter = 0; fireLerpCounter = 0; burnedLerpCounter = 0; visible = false; dummy = new GUI_Element(new Rectangle(0, -600, 1366, 768), "", Vars_Func.GUI_ElementTyp.Dummy, 1f); dummy.MoveAlongX = false; dummy.MoveAlongY = true; dummy.Selectable = false; GUI_Element background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.StartBackgroundHUD); elements.Add(background); all.Add(background); textFrame = new GUI_Element(new Rectangle(1366 / 2 - 144, 513, 293, 72), "", Vars_Func.GUI_ElementTyp.TextFrame); elements.Add(textFrame); dummy.Children.Add(textFrame); all.Add(textFrame); startButton = new GUI_Element(new Rectangle(1366 / 2 - 144, 574, 293, 96), "\n Press Enter To Start", Vars_Func.GUI_ElementTyp.TextBlance, Vars_Func.GUI_Typ.StartButton); startButton.Highlightable = true; dummy.Children.Add(startButton); all.Add(startButton); GUI_Element backgroundFrame = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BackgroundHUD); elements.Add(backgroundFrame); all.Add(backgroundFrame); burnedLogo = new GUI_Element(new Rectangle(1366 / 2 - 400, 0, 800, 525), "", Vars_Func.GUI_ElementTyp.UnderlordBurnedLogo); burnedLogo.SpriteColor = new Color(1, 1, 1, 1); dummy.Children.Add(burnedLogo); all.Add(burnedLogo); fireLogo = new GUI_Element(new Rectangle(1366 / 2 - 400, 0, 800, 525), "", Vars_Func.GUI_ElementTyp.UnderlordFireLogo); fireLogo.SpriteColor = new Color(1, 1, 1, 0); dummy.Children.Add(fireLogo); }
public static void createGUI() { background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BlackBackgoundHUD); background.SpriteColor = new Color(0.7f, 0.7f, 0.7f, 0.2f); all.Add(background); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 450 - 74 - 10, 512, 74), " Are you sure you want to quit?", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 20; all.Add(headLine); GUI_Element yesButton = new GUI_Element(new Rectangle(1366 / 2 - 256, 450, 96, 64), " No", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.NewGameButton); yesButton.Highlightable = true; yesButton.YBonus = 12; buttons.Add(yesButton); all.Add(yesButton); GUI_Element noButton = new GUI_Element(new Rectangle(1366 / 2 + 256 - 96, 450, 96, 64), " Yes", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.QuitButton); noButton.Highlightable = true; noButton.YBonus = 12; buttons.Add(noButton); all.Add(noButton); }
private static void UpdateBook() { dummy.Children.Remove(book); all.Remove(book); string spaceSmall = " ", spaceBig = " "; book = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), 180, 911, 512 + 48), "\n" + spaceBig + "Fullscreen: Brightness: " + brightness + "\n\n\n" + spaceBig + "Show Help: \n\n" + spaceBig + "Menu:" + spaceSmall + " Tab\n" + spaceBig + "Confirm:" + spaceSmall + " Enter/LMT\n" + spaceBig + "Refuse:" + spaceSmall + " Esc/RMT\n" + spaceBig + "Close Help: Esc\n" + spaceBig + "Mine:" + spaceSmall + " M \n" + spaceBig + "Room:" + spaceSmall + " R\n" + spaceBig + "Merge:" + spaceSmall + " T\n" + spaceBig + "Delete:" + spaceSmall + " D\n" + spaceBig + "Upgrade:" + spaceSmall + "U\n" + spaceBig + "Build:" + spaceSmall + " N\n" , Vars_Func.GUI_ElementTyp.BookField); book.YBonus = 10; dummy.Children.Add(book); all.Add(book); }
public static void createGUI() { dummy = new GUI_Element(new Rectangle(0, -600, 1366, 768), "", Vars_Func.GUI_ElementTyp.Dummy, 1f); dummy.MoveAlongX = false; dummy.MoveAlongY = true; dummy.Selectable = false; GUI_Element background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.StartBackgroundHUD); elements.Add(background); all.Add(background); GUI_Element headLineFrame = new GUI_Element(new Rectangle(1366 / 2 - 256, 0 - 50, 512, 100), "", Vars_Func.GUI_ElementTyp.ChainBig); dummy.Children.Add(headLineFrame); frames.Add(headLineFrame); all.Add(headLineFrame); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 32, 512, 128), " Main Menu", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 20; dummy.Children.Add(headLine); all.Add(headLine); aca = new GUI_Element(new Rectangle(1090, 13, 260, 265), "", Vars_Func.GUI_ElementTyp.Aca); dummy.Children.Add(aca); all.Add(aca); GUI_Element newGameFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 180 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(newGameFrame); frames.Add(newGameFrame); all.Add(newGameFrame); GUI_Element newGameButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 180, 384, 96), " New Game", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.NewGameButton); newGameButton.Highlightable = true; newGameButton.YBonus = 10; dummy.Children.Add(newGameButton); buttons.Add(newGameButton); all.Add(newGameButton); //GUI_Element howToFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); //dummy.Children.Add(howToFrame); //frames.Add(howToFrame); //GUI_Element howToButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296, 384, 96), " How To Play", Vars_Func.GUI_ElementTyp.TextFieldMiddle); //howToButton.Highlightable = true; //dummy.Children.Add(howToButton); //buttons.Add(howToButton); GUI_Element settingsFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(settingsFrame); frames.Add(settingsFrame); all.Add(settingsFrame); GUI_Element settingsButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 296, 384, 96), " Settings", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.SettingsButton); settingsButton.Highlightable = true; settingsButton.YBonus = 10; dummy.Children.Add(settingsButton); buttons.Add(settingsButton); all.Add(settingsButton); GUI_Element highscoreFrame = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 412 - 32, 384, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(highscoreFrame); frames.Add(highscoreFrame); all.Add(highscoreFrame); GUI_Element highscoreButton = new GUI_Element(new Rectangle(1366 / 2 - (384 / 2), 412, 384, 96), " Highscore", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.HighScoreButton); highscoreButton.Highlightable = true; highscoreButton.YBonus = 10; dummy.Children.Add(highscoreButton); buttons.Add(highscoreButton); all.Add(highscoreButton); GUI_Element quitFrame = new GUI_Element(new Rectangle(1366 / 2 - (288 / 2), 528 - 32, 288, 64), "", Vars_Func.GUI_ElementTyp.ChainSmall); dummy.Children.Add(quitFrame); frames.Add(quitFrame); all.Add(quitFrame); GUI_Element quitButton = new GUI_Element(new Rectangle(1366 / 2 - (288 / 2), 528, 288, 72), " Quit", Vars_Func.GUI_ElementTyp.TextFieldSmall, Vars_Func.GUI_Typ.QuitButton); quitButton.Highlightable = true; quitButton.YBonus = 10; dummy.Children.Add(quitButton); buttons.Add(quitButton); all.Add(quitButton); backgroundFrame = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BackgroundHUD); all.Add(backgroundFrame); }
public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard) { if (!updateReady) { updateReady = true; } foreach (GUI_Element b in buttons) { b.Update(time, null, mouseState); } if (cleanUp) { if (pressedButton == null) { pressedButton = currentSelectedButton; } } else { bool mouseMoving = false; if ((oldMouseState.X != mouseState.X) || (oldMouseState.Y != mouseState.Y)) { mouseMoving = true; oldMouseState = mouseState; } if (currentSelectedButton == null) { if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown) { currentSelectedButton = buttons[0]; buttonCounter = 0; keyIsDown = true; } if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown) { currentSelectedButton = buttons[buttons.Count - 1]; buttonCounter = buttons.Count - 1; keyIsDown = true; } } else { if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown) { buttonCounter++; buttonCounter %= (buttons.Count); currentSelectedButton = buttons[buttonCounter]; keyIsDown = true; } if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown) { buttonCounter--; if (buttonCounter < 0) { buttonCounter = buttons.Count - 1; } buttonCounter %= (buttons.Count); currentSelectedButton = buttons[buttonCounter]; keyIsDown = true; } } GUI_Element mouseSelection = null; int buttonNumer = 0, mouseNumer = 0; foreach (GUI_Element b in buttons) { if (b.SpriteColor == Color.Gray) { mouseSelection = b; mouseNumer = buttonNumer; } buttonNumer++; } if (mouseSelection != null && mouseSelection != currentSelectedButton && mouseMoving) { buttonCounter = mouseNumer; currentSelectedButton = mouseSelection; } if (mouseSelection != null && mouseSelection != currentSelectedButton && !mouseMoving) { mouseSelection.SpriteColor = Color.White; } if (mouseSelection == null && mouseSelection != currentSelectedButton && mouseMoving) { currentSelectedButton.SpriteColor = Color.White; currentSelectedButton = null; } if (currentSelectedButton != null && currentSelectedButton.SpriteColor != Color.Gray) { currentSelectedButton.SpriteColor = Color.Gray; } if (!keyboard.IsKeyDown(Keys.Up) && !keyboard.IsKeyDown(Keys.W) && !keyboard.IsKeyDown(Keys.Down) && !keyboard.IsKeyDown(Keys.S)) { keyIsDown = false; } if (currentSelectedButton != null && (mouseState.LeftButton == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Enter))) { cleanUp = true; } } }
public static void createGUI() { dummy = new GUI_Element(new Rectangle(0, -600, 1366, 768), "", Vars_Func.GUI_ElementTyp.Dummy, 1f); dummy.MoveAlongX = false; dummy.MoveAlongY = true; dummy.Selectable = false; GUI_Element background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.StartBackgroundHUD); elements.Add(background); all.Add(background); GUI_Element headLineFrame = new GUI_Element(new Rectangle(1366 / 2 - 256, 0 - 50, 512, 100), "", Vars_Func.GUI_ElementTyp.ChainBig); dummy.Children.Add(headLineFrame); frames.Add(headLineFrame); all.Add(headLineFrame); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 32, 512, 128), " Welcome new Lord...", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 45; dummy.Children.Add(headLine); all.Add(headLine); GUI_Element withFrame = new GUI_Element(new Rectangle(1366 / 2 - 911 / 2, 180 + 384 - 20, 256, 64), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(withFrame); frames.Add(withFrame); all.Add(withFrame); GUI_Element withButton = new GUI_Element(new Rectangle(1366 / 2 - 911 / 2, 180 + 384 + 10, 256, 76), " With Help", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.NewGameButton); withButton.Highlightable = true; withButton.YBonus = 15; dummy.Children.Add(withButton); buttons.Add(withButton); all.Add(withButton); GUI_Element bookFrame = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), -(237 / 2) + 100, 911, 237), "", Vars_Func.GUI_ElementTyp.ChainLarge); dummy.Children.Add(bookFrame); frames.Add(bookFrame); all.Add(bookFrame); GUI_Element withOutFrame = new GUI_Element(new Rectangle(1366 / 2 + 911 / 2 - 256, 180 + 384 - 20, 256, 64), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(withOutFrame); frames.Add(withOutFrame); all.Add(withOutFrame); GUI_Element withOutButton = new GUI_Element(new Rectangle(1366 / 2 + 911 / 2 - 256, 180 + 384 + 10, 256, 76), " Without Help", Vars_Func.GUI_ElementTyp.TextFieldMiddle, Vars_Func.GUI_Typ.QuitButton); withOutButton.Highlightable = true; withOutButton.YBonus = 15; dummy.Children.Add(withOutButton); buttons.Add(withOutButton); all.Add(withOutButton); book = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), 180, 911, 384), Player.loadString("Content/Tutorials/MainTutorial.txt"), Vars_Func.GUI_ElementTyp.BookField); book.YBonus = 10; dummy.Children.Add(book); all.Add(book); backgroundFrame = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BackgroundHUD); all.Add(backgroundFrame); }
public static void update(GameTime time, MouseState mouseState, MouseState lastMouseState, KeyboardState keyboard) { if (!updateReady) { updateReady = true; } if (!dummy.Move && !cleanUp) { dummy.Move = true; } headLine.Update(time, null, mouseState); dummy.Update(time, null, mouseState); foreach (GUI_Element e in elements) { e.Update(time, null, mouseState); } if (fullscreenButton.Rectangle.Contains(mouseState.X, mouseState.Y) && lastMouseState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed) { fullscreen = !fullscreen; //buttonPressed = true; } if (tutorialButton.Rectangle.Contains(mouseState.X, mouseState.Y) && lastMouseState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed) { help = !help; //buttonPressed = true; } if (brightnessUp.Rectangle.Contains(mouseState.X, mouseState.Y) && lastMouseState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed) { if (brightness < 10) { brightness++; UpdateBook(); } } if (brightnessDown.Rectangle.Contains(mouseState.X, mouseState.Y) && lastMouseState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed) { if (brightness > 1) { brightness--; UpdateBook(); } } //if (!(fullscreenButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) && // !keyboard.IsKeyDown(Keys.Enter) && buttonPressed) //{ // buttonPressed = false; //} //if (!(tutorialButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) && // !keyboard.IsKeyDown(Keys.Enter) && buttonPressed) //{ // buttonPressed = false; //} if (fullscreen) { fullscreenButton.Text = " On"; } else { fullscreenButton.Text = " Off"; } if (help) { tutorialButton.Text = " On"; } else { tutorialButton.Text = " Off"; } if ((returnButton.Rectangle.Contains(mouseState.X, mouseState.Y) && mouseState.LeftButton == ButtonState.Pressed) || keyboard.IsKeyDown(Keys.Back) || (keyboard.IsKeyDown(Keys.Escape))) { dummy.Move = false; cleanUp = true; returnButton.SpriteColor = Color.Gray; } if (cleanUp && book.CurrentRectangle.Y <= -500 && pressedButton == null) { pressedButton = returnButton; } }
public static void createGUI() { brightness = 5; dummy = new GUI_Element(new Rectangle(0, -600, 1366, 768), "", Vars_Func.GUI_ElementTyp.Dummy, 1f); dummy.MoveAlongX = false; dummy.MoveAlongY = true; dummy.Selectable = false; GUI_Element background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.StartBackgroundHUD); elements.Add(background); all.Add(background); GUI_Element headLineFrame = new GUI_Element(new Rectangle(1366 / 2 - 256, 0 - 50, 512, 100), "", Vars_Func.GUI_ElementTyp.ChainBig); dummy.Children.Add(headLineFrame); frames.Add(headLineFrame); all.Add(headLineFrame); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 32, 512, 128), " Settings", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 20; dummy.Children.Add(headLine); all.Add(headLine); GUI_Element returnFrame = new GUI_Element(new Rectangle(128 - (128 / 2), 0, 256, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(returnFrame); frames.Add(returnFrame); all.Add(returnFrame); returnButton = new GUI_Element(new Rectangle(128 - (128 / 2), 42, 256, 64), " Back", Vars_Func.GUI_ElementTyp.TextArrow, Vars_Func.GUI_Typ.StartButton); returnButton.Highlightable = true; returnButton.YBonus = 15; dummy.Children.Add(returnButton); all.Add(returnButton); GUI_Element bookFrame = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), -(237 / 2) + 100, 911, 237), "", Vars_Func.GUI_ElementTyp.ChainLarge); dummy.Children.Add(bookFrame); frames.Add(bookFrame); all.Add(bookFrame); string spaceSmall = " ", spaceBig = " "; book = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), 180, 911, 512 + 48), "\n" + spaceBig + "Fullscreen: Brightness: " + brightness + "\n\n\n" + spaceBig + "Show Help: \n\n" + spaceBig + "Menu:" + spaceSmall + " Tab\n" + spaceBig + "Confirm:" + spaceSmall + " Enter/LMT\n" + spaceBig + "Refuse:" + spaceSmall + " Esc/RMT\n" + spaceBig + "Close Help: Esc\n" + spaceBig + "Mine:" + spaceSmall + " M \n" + spaceBig + "Room:" + spaceSmall + " R\n" + spaceBig + "Merge:" + spaceSmall + " T\n" + spaceBig + "Delete:" + spaceSmall + " D\n" + spaceBig + "Upgrade:" + spaceSmall + "U\n" + spaceBig + "Build:" + spaceSmall + " N\n" , Vars_Func.GUI_ElementTyp.BookField); book.YBonus = 10; dummy.Children.Add(book); all.Add(book); brightnessUp = new GUI_Element(new Rectangle(1366 / 2 + 215, 180 + 15 + 16, 32, 32), "", Vars_Func.GUI_ElementTyp.BrightnessUp); brightnessUp.Highlightable = true; brightnessUp.YBonus = 20; dummy.Children.Add(brightnessUp); all.Add(brightnessUp); brightnessDown = new GUI_Element(new Rectangle(1366 / 2 + 215, 180 + 15 + 16 + 32, 32, 32), "", Vars_Func.GUI_ElementTyp.BrightnessDown); brightnessDown.Highlightable = true; brightnessDown.YBonus = 20; dummy.Children.Add(brightnessDown); all.Add(brightnessDown); fullscreenButton = new GUI_Element(new Rectangle(1366 / 2 - 200, 180 + 20, 76, 76), " Off", Vars_Func.GUI_ElementTyp.FullScreenButton); fullscreenButton.Highlightable = true; fullscreenButton.YBonus = 20; dummy.Children.Add(fullscreenButton); all.Add(fullscreenButton); tutorialButton = new GUI_Element(new Rectangle(1366 / 2 - 200, 230 + 60, 76, 76), " Off", Vars_Func.GUI_ElementTyp.FullScreenButton); tutorialButton.Highlightable = true; tutorialButton.YBonus = 20; dummy.Children.Add(tutorialButton); all.Add(tutorialButton); backgroundFrame = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BackgroundHUD); all.Add(backgroundFrame); }
public static void createGUI() { dummy = new GUI_Element(new Rectangle(0, -600, 1366, 768), "", Vars_Func.GUI_ElementTyp.Dummy, 1f); dummy.MoveAlongX = false; dummy.MoveAlongY = true; dummy.Selectable = false; GUI_Element background = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.StartBackgroundHUD); elements.Add(background); all.Add(background); GUI_Element headLineFrame = new GUI_Element(new Rectangle(1366 / 2 - 256, 0 - 50, 512, 100), "", Vars_Func.GUI_ElementTyp.ChainBig); dummy.Children.Add(headLineFrame); frames.Add(headLineFrame); all.Add(headLineFrame); headLine = new GUI_Element(new Rectangle(1366 / 2 - 256, 32, 512, 128), " Highscore", Vars_Func.GUI_ElementTyp.TextFieldBig); headLine.YBonus = 20; dummy.Children.Add(headLine); all.Add(headLine); GUI_Element returnFrame = new GUI_Element(new Rectangle(128 - (128 / 2), 0, 256, 84), "", Vars_Func.GUI_ElementTyp.ChainMiddle); dummy.Children.Add(returnFrame); frames.Add(returnFrame); all.Add(returnFrame); returnButton = new GUI_Element(new Rectangle(128 - (128 / 2), 42, 256, 64), " Back", Vars_Func.GUI_ElementTyp.TextArrow, Vars_Func.GUI_Typ.StartButton); returnButton.Highlightable = true; returnButton.YBonus = 15; dummy.Children.Add(returnButton); all.Add(returnButton); GUI_Element bookFrame = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), -(237 / 2) + 100, 911, 237), "", Vars_Func.GUI_ElementTyp.ChainLarge); dummy.Children.Add(bookFrame); frames.Add(bookFrame); all.Add(bookFrame); string startSpace = " "; string text = "\n" + startSpace; String[] highscore = Player.loadScore(); for (int i = 0; i < 10; i++) { int number = i + 1; text += number.ToString() + ". " + highscore[i]; text += "\n"; text += startSpace; } book = new GUI_Element(new Rectangle(1366 / 2 - (911 / 2), 180, 911, 512), text, Vars_Func.GUI_ElementTyp.BookField); book.YBonus = 10; dummy.Children.Add(book); all.Add(book); backgroundFrame = new GUI_Element(new Rectangle(0, 0, 1366, 768), "", Vars_Func.GUI_ElementTyp.BackgroundHUD); all.Add(backgroundFrame); }
public static void update(GameTime time, MouseState mouseState, KeyboardState keyboard) { if (!updateReady) { updateReady = true; } if (!dummy.Move && !cleanUp) { dummy.Move = true; } headLine.Update(time, null, mouseState); dummy.Update(time, null, mouseState); foreach (GUI_Element e in elements) { e.Update(time, null, mouseState); } if (cleanUp) { //if (currentSelectedButton.Typ == Vars_Func.GUI_Typ.NewGameButton) //{ // FadeOut(time); //} //else //{ if (dummy.Children.Last().CurrentRectangle.Y <= -500 && pressedButton == null) { pressedButton = currentSelectedButton; } //} } else { bool mouseMoving = false; if ((oldMouseState.X != mouseState.X) || (oldMouseState.Y != mouseState.Y)) { mouseMoving = true; oldMouseState = mouseState; } if (currentSelectedButton == null) { if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown) { currentSelectedButton = buttons[0]; buttonCounter = 0; keyIsDown = true; } if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown) { currentSelectedButton = buttons[buttons.Count - 1]; buttonCounter = buttons.Count - 1; keyIsDown = true; } } else { if ((keyboard.IsKeyDown(Keys.Down) || keyboard.IsKeyDown(Keys.S)) && !keyIsDown) { buttonCounter++; buttonCounter %= (buttons.Count); currentSelectedButton = buttons[buttonCounter]; keyIsDown = true; } if ((keyboard.IsKeyDown(Keys.Up) || keyboard.IsKeyDown(Keys.W)) && !keyIsDown) { buttonCounter--; if (buttonCounter < 0) { buttonCounter = buttons.Count - 1; } buttonCounter %= (buttons.Count); currentSelectedButton = buttons[buttonCounter]; keyIsDown = true; } } GUI_Element mouseSelection = null; int buttonNumer = 0, mouseNumer = 0; foreach (GUI_Element b in buttons) { if (b.SpriteColor == Color.Gray) { mouseSelection = b; mouseNumer = buttonNumer; } buttonNumer++; } if (mouseSelection != null && mouseSelection != currentSelectedButton && mouseMoving) { buttonCounter = mouseNumer; currentSelectedButton = mouseSelection; } if (mouseSelection != null && mouseSelection != currentSelectedButton && !mouseMoving) { mouseSelection.SpriteColor = Color.White; } if (mouseSelection == null && mouseSelection != currentSelectedButton && mouseMoving) { currentSelectedButton.SpriteColor = Color.White; currentSelectedButton = null; } if (currentSelectedButton != null && currentSelectedButton.SpriteColor != Color.Gray) { currentSelectedButton.SpriteColor = Color.Gray; } if (!keyboard.IsKeyDown(Keys.Up) && !keyboard.IsKeyDown(Keys.W) && !keyboard.IsKeyDown(Keys.Down) && !keyboard.IsKeyDown(Keys.S)) { keyIsDown = false; } if (currentSelectedButton != null && (mouseState.LeftButton == ButtonState.Pressed || keyboard.IsKeyDown(Keys.Enter))) { dummy.Move = false; cleanUp = true; } } }