/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // Show mouse on screen. IsMouseVisible = true; Mouse.WindowHandle = Window.Handle; Manager.Content = Content; // Create menu with items. _mainMenu = CreateMainMenu(); _entityCollection.Add(_mainMenu); }
private Menu CreateOptionsMenu() { var menu = new Menu(); var left = GraphicsDevice.Viewport.Width / 2 - Manager.ButtonTextures[0].Width / 2; var top = Constants.MainMenuTop; var backButton = new Button("Back", left, 400); backButton.OnClick += OnOptionsBackButtonClicked; menu.AddMenuItem(backButton); menu.AddMenuItem(new Slider("Difficulty", left, top, _difficultyValue)); menu.AddMenuItem(new Checkbox("Subtitles", menu.Area.Left + menu.Area.Width - Manager.CheckboxTextures[0].Width, top + 40, _enableSubtitles)); return menu; }
private void OnOptionsMenuButtonClicked(object sender, EventArgs e) { _mainMenu.SlideLeft(-_mainMenu.Area.Width); Thread.Sleep(100); _optionsMenu = CreateOptionsMenu(); _entityCollection.Add(_optionsMenu); }
private Menu CreateMainMenu() { var menu = new Menu(); var left = GraphicsDevice.Viewport.Width/2 - Manager.ButtonTextures[0].Width/2; var top = Constants.MainMenuTop; menu.AddMenuItem(new Button("New Game", left, top)); top += Constants.MenuButtonHeightOffset; var optionsItem = new Button("Options", left, top); optionsItem.OnClick += OnOptionsMenuButtonClicked; menu.AddMenuItem(optionsItem); top += Constants.MenuButtonHeightOffset; menu.AddMenuItem(new Button("Statistics", left, top)); top += Constants.MenuButtonHeightOffset; var exitItem = new Button("Exit", left, top); exitItem.OnClick += OnExitMenuButtonClicked; menu.AddMenuItem(exitItem); return menu; }