MainMenuScreen.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // MainMenuScreen.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. using GameStateManagement;
  14. using Microsoft.Xna.Framework;
  15. using Microsoft.Xna.Framework.Graphics;
  16. #endregion
  17. namespace Blackjack
  18. {
  19. class MainMenuScreen : MenuScreen
  20. {
  21. public static string Theme = "Red";
  22. #region Initializations
  23. /// <summary>
  24. /// Initializes a new instance of the screen.
  25. /// </summary>
  26. public MainMenuScreen()
  27. : base("")
  28. {
  29. }
  30. #endregion
  31. public override void LoadContent()
  32. {
  33. // Create our menu entries.
  34. MenuEntry startGameMenuEntry = new MenuEntry("Play");
  35. MenuEntry themeGameMenuEntry = new MenuEntry("Theme");
  36. MenuEntry exitMenuEntry = new MenuEntry("Exit");
  37. // Hook up menu event handlers.
  38. startGameMenuEntry.Selected += StartGameMenuEntrySelected;
  39. themeGameMenuEntry.Selected += ThemeGameMenuEntrySelected;
  40. exitMenuEntry.Selected += OnCancel;
  41. // Add entries to the menu.
  42. MenuEntries.Add(startGameMenuEntry);
  43. MenuEntries.Add(themeGameMenuEntry);
  44. MenuEntries.Add(exitMenuEntry);
  45. base.LoadContent();
  46. }
  47. #region Update
  48. /// <summary>
  49. /// Respond to "Play" Item Selection
  50. /// </summary>
  51. /// <param name="sender"></param>
  52. /// <param name="e"></param>
  53. void StartGameMenuEntrySelected(object sender, EventArgs e)
  54. {
  55. foreach (GameScreen screen in ScreenManager.GetScreens())
  56. screen.ExitScreen();
  57. ScreenManager.AddScreen(new GameplayScreen(Theme), null);
  58. }
  59. /// <summary>
  60. /// Respond to "Theme" Item Selection
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. void ThemeGameMenuEntrySelected(object sender, EventArgs e)
  65. {
  66. ScreenManager.AddScreen(new OptionsMenu(), null);
  67. }
  68. /// <summary>
  69. /// Respond to "Exit" Item Selection
  70. /// </summary>
  71. /// <param name="playerIndex"></param>
  72. protected override void OnCancel(PlayerIndex playerIndex)
  73. {
  74. ScreenManager.Game.Exit();
  75. }
  76. #endregion
  77. }
  78. }