//------------------------------------------------------------------------------ // Function: OptionsMenu // Author: nholmes // Summary: constructor - creates the menu and adds all of the menu items //------------------------------------------------------------------------------ public OptionsMenu(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment title = "Options"; alignment = Alignment.centre; // set this menu to the required size SetCentered(320, 210); // create our menu items screenModeItem = new ItemSelector(this, game, screenModeList, 0, 20, 200, Alignment.centre, textFont, Color.White, textYOffset); musicVolumeItem = new ItemSlider(this, game, 0, 100, 75, 55, 200, Alignment.centre, textFont, Color.White, textYOffset); sfxVolumeItem = new ItemSlider(this, game, 0, 100, 75, 90, 200, Alignment.centre, textFont, Color.White, textYOffset); backMenuItem = new ItemButton(this, game, "Back", 125, 200, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu event handlers backMenuItem.Selected += OnCancel; screenModeItem.NextOptionWanted += IncreaseScreenMode; screenModeItem.PreviousOptionWanted += DecreaseScreenMode; musicVolumeItem.ValueIncreased += IncreaseMusicVolume; musicVolumeItem.ValueDecreased += DecreaseMusicVolume; sfxVolumeItem.ValueIncreased += IncreaseSfxVolume; sfxVolumeItem.ValueDecreased += DecreaseSfxVolume; // add items to the menu menuItems.Add(screenModeItem); menuItems.Add(musicVolumeItem); menuItems.Add(sfxVolumeItem); menuItems.Add(backMenuItem); }
//------------------------------------------------------------------------------ // Function: PauseMenu // Author: nholmes // Summary: constructor - creates the menu and adds all the menu items //------------------------------------------------------------------------------ public PauseMenu(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment title = "Pause"; alignment = Alignment.centre; // set this menu to occupy the full screen SetCentered(250,180); // create our menu items ItemButton resumeMenuItem = new ItemButton(this, game, "Resume", 20, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton optionsMenuItem = new ItemButton(this, game, "Options", 55, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton quitMenuItem = new ItemButton(this, game, "Quit", 90, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu event handlers resumeMenuItem.Selected += OnCancel; optionsMenuItem.Selected += OptionsMenuItemSelected; quitMenuItem.Selected += QuitMenuItemSelected; // add our items to the menu menuItems.Add(resumeMenuItem); menuItems.Add(optionsMenuItem); menuItems.Add(quitMenuItem); }
//------------------------------------------------------------------------------ // Function: MainMenu // Author: nholmes // Summary: constructor - creates the menu and all of the items it contains //------------------------------------------------------------------------------ public MainMenu(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment title = "Main Menu"; alignment = Alignment.centre; // set this menu to be a fixed size in the middle of the screen SetArbitary((int)(displayManager.GameResolutionX * 0.5f) - 125, 360, 250, 250); // create our menu items ItemButton playGameMenuItem = new ItemButton(this, game, "Play Game", 20, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton achievementsMenuItem = new ItemButton(this, game, "Achievements", 55, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton leaderboardsMenuItem = new ItemButton(this, game, "Leaderboards", 90, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton optionsMenuItem = new ItemButton(this, game, "Options", 125, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); ItemButton exitMenuItem = new ItemButton(this, game, "Exit", 160, 170, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu item event handlers playGameMenuItem.Selected += PlayGameMenuItemSelected; achievementsMenuItem.Selected += AchievementsMenuItemSelected; leaderboardsMenuItem.Selected += LeaderboardsMenuItemSelected; optionsMenuItem.Selected += OptionsMenuItemSelected; exitMenuItem.Selected += OnCancel; // add the items to the menu menuItems.Add(playGameMenuItem); menuItems.Add(achievementsMenuItem); menuItems.Add(leaderboardsMenuItem); menuItems.Add(optionsMenuItem); menuItems.Add(exitMenuItem); }
//------------------------------------------------------------------------------ // Class: QuestionBox // Author: nholmes // Summary: constructor - creates the menu as a pop-up and adds all the items //------------------------------------------------------------------------------ public QuestionBox(Game game, PlayerIndex? controllingPlayer, string title, string question, string optionA, string optionB) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment this.title = title; alignment = Alignment.centre; // figure out the width of the menu int width = (int)textFont.MeasureString(question).X + 80; // check if the width is below the minimum allowed and set it to the minimum if it is if (width < 300) { width = 300; } // set this menu to be centered at a fixed size SetCentered(width, 180); // create our menu items ItemText questionTextItem = new ItemText(this, game, question, 20, Alignment.centre, textFont, Color.White, textYOffset, false); ItemButton continueMenuItem = new ItemButton(this, game, optionA, 55, 170, Alignment.centre, textFont, Color.Black, Alignment.centre, textYOffset); ItemButton exitMenuItem = new ItemButton(this, game, optionB, 90, 170, Alignment.centre, textFont, Color.Black, Alignment.centre, textYOffset); // hook up the menu item event handlers continueMenuItem.Selected += OptionASelected; exitMenuItem.Selected += OptionBSelected; // add the items to the menu menuItems.Add(questionTextItem); menuItems.Add(continueMenuItem); menuItems.Add(exitMenuItem); }
//------------------------------------------------------------------------------ // Function: TitleScreen // Author: nholmes // Summary: constructor, creates the title screen and adds the press start button //------------------------------------------------------------------------------ public TitleScreen(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.Black) { // tell the menu that we dont want to display anything other than items backgroundVisible = false; // set the menu size and position SetArbitary((displayManager.GameResolutionX / 2) - 120, displayManager.GameResolutionY - 200, 200, 100); // create the press start menu item ItemButton pressStartMenuItem = new ItemButton(this, game, "Press Start", 0, 250, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu item event handler pressStartMenuItem.Selected += PressStartMenuItemSelected; // add the item to the menu menuItems.Add(pressStartMenuItem); }
//------------------------------------------------------------------------------ // Function: AchievementsMenu // Author: nholmes // Summary: constructor - creates the menu and adds all of the menu items //------------------------------------------------------------------------------ public AchievementsMenu(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment title = "Achievements"; alignment = Alignment.centre; // set this menu to the required size SetCentered(640, 600); // create our menu items backMenuItem = new ItemButton(this, game, "Back", 500, 200, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu event handlers backMenuItem.Selected += OnCancel; // add items to the menu menuItems.Add(backMenuItem); // get the achievment list display service achievementList = (ICAchievementList)game.Services.GetService(typeof(ICAchievementList)); }
//------------------------------------------------------------------------------ // Function: LeaderboardsMenu // Author: nholmes // Summary: constructor - creates the menu and adds all of the menu items //------------------------------------------------------------------------------ public LeaderboardsMenu(Game game, PlayerIndex? controllingPlayer) : base(game, controllingPlayer, Color.White) { // set the title and it's alignment - no title on leaderboard menu as we expect the name of the leaderboard to be displayed title = ""; alignment = Alignment.centre; // set this menu to the required size SetCentered(640, 600); // create our menu items backMenuItem = new ItemButton(this, game, "Back", 500, 200, Alignment.centre, textFont, Color.White, Alignment.centre, textYOffset); // hook up the menu event handlers backMenuItem.Selected += OnCancel; // add items to the menu menuItems.Add(backMenuItem); // get the leaderboard browserservice leaderboardsBrowser = (ICLeaderboardsBrowser)game.Services.GetService(typeof(ICLeaderboardsBrowser)); }