コード例 #1
0
ファイル: ScreenManager.cs プロジェクト: zakvdm/Frenetic
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Game game, ContentManager contentManager, MenuInputState menuInputState)
            : base(game)
        {
            content = contentManager;
            _menuInputState = menuInputState;

            graphicsDeviceService = (IGraphicsDeviceService)game.Services.GetService(
                                                        typeof(IGraphicsDeviceService));

            if (graphicsDeviceService == null)
                throw new InvalidOperationException("No graphics device service.");
        }
コード例 #2
0
ファイル: GameplayScreen.cs プロジェクト: zakvdm/Frenetic
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(MenuInputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (!IsExiting)
            {
                if (input.PauseGame)
                {
                    // If they pressed pause, bring up the pause menu screen.
                    const string message = "Exit the game?";
                    MessageBoxScreen messageBox = _screenFactory.MakeMessageBoxScreen(message);
                    //messageBox.Accepted += (sender, e) => base.ExitScreen();
                    messageBox.Accepted += ExitScreen;
                }
            }
            base.HandleInput(input);
        }
コード例 #3
0
ファイル: MessageBoxScreen.cs プロジェクト: zakvdm/Frenetic
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(MenuInputState input)
        {
            if (input.MenuSelect && (!pauseMenu ||
                (input.CurrentGamePadState.Buttons.A == ButtonState.Pressed)))
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, EventArgs.Empty);

                ExitScreen();
            }
            else if (input.MenuCancel || (input.MenuSelect && pauseMenu &&
                (input.CurrentGamePadState.Buttons.A == ButtonState.Released)))
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, EventArgs.Empty);

                ExitScreen();
            }
        }
コード例 #4
0
ファイル: GameScreen.cs プロジェクト: zakvdm/Frenetic
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(MenuInputState input) { }
コード例 #5
0
 public void SetUp()
 {
     stubKeyboard = MockRepository.GenerateStub<IKeyboard>();
     menuInputState = new MenuInputState(stubKeyboard);
 }