#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GAME_STATES_EXTENSIBLEGAMESTATEMANAGER_H #define NUCLEX_GAME_STATES_EXTENSIBLEGAMESTATEMANAGER_H #include "Nuclex/Game/Config.h" #include "Nuclex/Game/States/GameStateManager.h" #include namespace Nuclex { namespace Game { namespace States { // ------------------------------------------------------------------------------------------- // class GameState; // forward declaration so we don't need the header // ------------------------------------------------------------------------------------------- // /// Game state manager with a configurable event chain to its states class ExtensibleGameStateManager : GameStateManager { /// /// Destroys the game state manager, leaving and dropping any active game state /// public: virtual ~ExtensibleGameStateManager() {} /// Returns the currently active game state /// The lastmost game state on the stack public: virtual std::shared_ptr Peek() const = 0; /// Appends a new game state to the stack /// Game state that will be pushed onto the stack /// Whether the state completely obscures the state below it public: virtual void Push( const std::shared_ptr &state, Modality::Enum modality = Modality::Exclusive ) = 0; /// Removes the lastmost game state from the stack /// The state that has been removed from the stack public: virtual std::shared_ptr Pop() = 0; /// Replaces the lastmost game state on the stack /// State the lastmost state on the stack will be replaced with /// Whether the state completely obscures the state below it /// The previously lastmost state on the stack that was replaced /// /// This method is mostly just syntactic sugar for a call to Pop() followed by Push(), /// except that it will also work if the game state stack is currently empty, in which /// case it will equal the Push() method and return an empty smart pointer. /// public: virtual std::shared_ptr Switch( const std::shared_ptr &state, Modality::Enum modality = Modality::Exclusive ) { std::shared_ptr currentState = Peek(); if(currentState) { Pop(); } Push(state, modality); return currentState; } }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Game::States #endif // NUCLEX_GAME_STATES_EXTENSIBLEGAMESTATEMANAGER_H