public Button(Texture2D tex):base() { dimensions = new Rectangle(0, 0, 0, 0); basePanel = new Panel(tex, Color.Gray); originalPanelColor = new Color(basePanel.color, 255); basePanel.dimensions = dimensions; children = new List<UIComponent>(); canHaveFocus = true; }
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); }
private void Actor_Death(object sender, EventArgs e) { Actor deadActor = (Actor)sender; healthBars.Remove(deadActor); actors.Remove(deadActor); if (deadActor.className == "player") { Panel panel = new Panel(guiTextures["whiteSquare"], new Color(Color.TransparentBlack, .5f)); panel.dimensions.Width = (int)( drawSpace.Width * 2.5 / 10); panel.dimensions.Height = drawSpace.Width * 1 / 10; panel.dimensions.X = drawSpace.Width / 2 - panel.dimensions.Width/2; panel.dimensions.Y = drawSpace.Height / 2 - panel.dimensions.Height / 2; tutorialGui.Add(panel); Label deadLabel = new Label(spriteFont, "YOU ARE DEAD"); deadLabel.color = Color.Red; deadLabel.dimensions.X = drawSpace.Width / 2 - (int)spriteFont.MeasureString(deadLabel.contents).X / 2; deadLabel.dimensions.Y = drawSpace.Height / 2 - (int)spriteFont.MeasureString(deadLabel.contents).Y / 2 - 25; tutorialGui.Add(deadLabel); Label helpLabel = new Label(spriteFont, "Press e to restart."); helpLabel.dimensions.X = drawSpace.Width / 2 - (int)spriteFont.MeasureString(helpLabel.contents).X / 2; helpLabel.dimensions.Y = drawSpace.Height / 2 - (int)spriteFont.MeasureString(helpLabel.contents).Y / 2 + 25; tutorialGui.Add(helpLabel); } }
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); }
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); }