public MainMenuItems() : base(Horizontal.Center, Vertical.Top) { this.newGameButton = new TextButton( "#mainmenu_newgame#", DataIdentifier.defaultFontLarge, Horizontal.Center, Vertical.Top); this.optionsButton = new TextButton( "#mainmenu_options#", DataIdentifier.defaultFontLarge, Horizontal.Center, Vertical.Top); this.exitButton = new TextButton( "#mainmenu_exit#", DataIdentifier.defaultFontLarge, Horizontal.Center, Vertical.Top); this.newGameButton.onClick += new EventHandler(HandleNewGameMenuClick); this.optionsButton.onClick += new EventHandler(HandleOptionMenuClick); this.exitButton.onClick += new EventHandler(HandleExitMenuClick); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 0), this.newGameButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 60), this.optionsButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 120), this.exitButton); this.ResetPosition(new Microsoft.Xna.Framework.Vector2(0, 430)); }
/// <summary> /// Create a toolbar /// </summary> public ToolBar() : base(Horizontal.Left, Vertical.Bottom) { this.menuButton = new Helper.UI.TextButton( "#hud_menu#", DataIdentifier.defaultFont, Horizontal.Left, Vertical.Bottom); this.buildButton = new Helper.UI.ImageButton( DataIdentifier.textureIconTunnel, DataIdentifier.textureIconTunnelHover, Horizontal.Left, Vertical.Bottom, true); this.buildCaveSmallButton = new Helper.UI.ImageButton( DataIdentifier.textureIconSmallCave, DataIdentifier.textureIconSmallCaveHover, Horizontal.Left, Vertical.Bottom, true); this.buildCaveMediumButton = new Helper.UI.ImageButton( DataIdentifier.textureIconMediumCave, DataIdentifier.textureIconMediumCaveHover, Horizontal.Left, Vertical.Bottom, true); this.buildCaveLargeButton = new Helper.UI.ImageButton( DataIdentifier.textureIconLargeCave, DataIdentifier.textureIconLargeCaveHover, Horizontal.Left, Vertical.Bottom, true); this.clearButton = new Helper.UI.TextButton( "#hud_clear_tunnel#", DataIdentifier.defaultFont, Horizontal.Left, Vertical.Bottom, true); this.buildButton.onClick += new EventHandler(this.handleBuildTunnelClick); this.buildCaveSmallButton.onClick += new EventHandler(this.handleBuildCaveSmallClick); this.buildCaveMediumButton.onClick += new EventHandler(this.handleBuildCaveMediumClick); this.buildCaveLargeButton.onClick += new EventHandler(this.handleBuildCaveLargeClick); this.clearButton.onClick += new EventHandler(this.handleClearTunnelClick); this.menuButton.onClick += new EventHandler(this.handleMenuClick); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(50, -40), this.buildButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(140, -40), this.buildCaveSmallButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(210, -40), this.buildCaveMediumButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(280, -40), this.buildCaveLargeButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(360, -40), this.clearButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(460, -40), this.menuButton); this.ResetPosition(new Microsoft.Xna.Framework.Vector2(0, 0)); }
public OptionMenuItems() : base(Horizontal.Center, Vertical.Top) { // language int defaultLanguage = FenrirGame.Instance.Properties.ContentManager.Languages.IndexOf(FenrirGame.Instance.Config.Language); this.languageList = new SelectionList( DataIdentifier.labelOptionMenuLanguage, DataIdentifier.defaultFont, FenrirGame.Instance.Properties.ContentManager.Languages, defaultLanguage, Horizontal.Center, Vertical.Top ); this.languageList.onSelected += new EventHandler<ItemSelectedEventArgs>(HandelLanguageChange); // resolution List<String> resolutions = new List<String>(); resolutions.Add("1024 x 768"); resolutions.Add("1280 x 720"); resolutions.Add("1920 x 1080"); resolutions.Add("2560 x 1440"); String defaultResolutionString = FenrirGame.Instance.Config.ResolutionX + " x " + FenrirGame.Instance.Config.ResolutionY; if (!resolutions.Contains(defaultResolutionString)) resolutions.Add(defaultResolutionString); int defaultResolution = resolutions.IndexOf(defaultResolutionString); this.resolutionList = new SelectionList( DataIdentifier.labelOptionMenuResolution, DataIdentifier.defaultFont, resolutions, defaultResolution, Horizontal.Center, Vertical.Top ); // fullscree List<String> windowModes = new List<String>(); windowModes.Add(DataIdentifier.labelOptionMenuWindowModeFullscreen); windowModes.Add(DataIdentifier.labelOptionMenuWindowModeBorderless); windowModes.Add(DataIdentifier.labelOptionMenuWindowModeWindowed); int defaultWindowmode = FenrirGame.Instance.Properties.IsFullscreen ? 0 : 1; this.windowModeList = new SelectionList( DataIdentifier.labelOptionMenuWindowMode, DataIdentifier.defaultFont, windowModes, defaultWindowmode, Horizontal.Center, Vertical.Top ); this.applyButton = new TextButton( DataIdentifier.labelApply, DataIdentifier.defaultFont, Horizontal.Center, Vertical.Top); this.backButton = new TextButton( DataIdentifier.labelBack, DataIdentifier.defaultFont, Horizontal.Center, Vertical.Top); this.applyButton.onClick += new EventHandler(HandleOptionMenuApplyClick); this.backButton.onClick += new EventHandler(HandleOptionMenuBackClick); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 0), this.languageList); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 60), this.resolutionList); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(0, 120), this.windowModeList); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(-100, 180), this.applyButton); this.AddUiElement(new Microsoft.Xna.Framework.Vector2(100, 180), this.backButton); this.ResetPosition(new Microsoft.Xna.Framework.Vector2(0, 430)); }
/// <summary> /// Sets a new index /// </summary> /// <param name="newIndex"></param> private void resetIndex(int newIndex) { if (this.index < 0) this.index = 0; if (this.index >= this.entries.Count) this.index = this.entries.Count - 1; else this.index = newIndex; this.currentSelection = this.entries[this.index].Copy(); this.currentSelection.Position = new Vector2(this.position.X + 50, this.Position.Y); this.currentSelection.onClick += ToggleMenu; }
/// <summary> /// build all entries in this selection /// </summary> private void buildList() { this.entries.Clear(); for (int i = 0; i < this.data.Count; i++) { TextButton entry = new TextButton(data[i], this.font, Horizontal.Left, Vertical.Top); entry.onClick += HandleSelection; entry.onClick += ToggleMenu; this.entries.Add(entry); } this.resetIndex(this.index); }