2013-11-16 09:31:46 +00:00
|
|
|
#ifndef GAME_MWSTATE_STATEMANAGER_H
|
|
|
|
#define GAME_MWSTATE_STATEMANAGER_H
|
|
|
|
|
2023-04-17 19:12:05 +00:00
|
|
|
#include <filesystem>
|
2014-06-02 18:24:35 +00:00
|
|
|
#include <list>
|
2013-11-24 14:19:56 +00:00
|
|
|
#include <string>
|
2013-11-21 10:10:18 +00:00
|
|
|
|
2013-11-19 14:38:26 +00:00
|
|
|
namespace MWState
|
|
|
|
{
|
|
|
|
struct Slot;
|
|
|
|
class Character;
|
|
|
|
}
|
|
|
|
|
2013-11-16 09:31:46 +00:00
|
|
|
namespace MWBase
|
|
|
|
{
|
|
|
|
/// \brief Interface for game state manager (implemented in MWState)
|
|
|
|
class StateManager
|
|
|
|
{
|
2013-11-18 14:15:47 +00:00
|
|
|
public:
|
|
|
|
enum State
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2013-11-18 14:15:47 +00:00
|
|
|
State_NoGame,
|
|
|
|
State_Ended,
|
|
|
|
State_Running
|
2022-09-22 18:26:05 +00:00
|
|
|
};
|
2013-11-18 14:15:47 +00:00
|
|
|
|
|
|
|
typedef std::list<MWState::Character>::const_iterator CharacterIterator;
|
|
|
|
|
2014-06-02 18:24:35 +00:00
|
|
|
private:
|
|
|
|
StateManager(const StateManager&);
|
|
|
|
///< not implemented
|
2013-11-21 10:10:18 +00:00
|
|
|
|
2013-11-16 09:31:46 +00:00
|
|
|
StateManager& operator=(const StateManager&);
|
|
|
|
///< not implemented
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2013-11-16 09:31:46 +00:00
|
|
|
StateManager() {}
|
|
|
|
|
|
|
|
virtual ~StateManager() {}
|
|
|
|
|
2013-11-16 10:07:23 +00:00
|
|
|
virtual void requestQuit() = 0;
|
2013-11-16 09:31:46 +00:00
|
|
|
|
|
|
|
virtual bool hasQuitRequest() const = 0;
|
|
|
|
|
|
|
|
virtual void askLoadRecent() = 0;
|
2013-11-16 10:07:23 +00:00
|
|
|
|
|
|
|
virtual State getState() const = 0;
|
|
|
|
|
|
|
|
virtual void newGame(bool bypass = false) = 0;
|
|
|
|
///< Start a new game.
|
2022-09-22 18:26:05 +00:00
|
|
|
///
|
2013-11-16 10:07:23 +00:00
|
|
|
/// \param bypass Skip new game mechanics.
|
2013-11-16 11:22:28 +00:00
|
|
|
|
2013-12-19 20:08:34 +00:00
|
|
|
virtual void resumeGame() = 0;
|
|
|
|
|
2013-11-18 14:15:47 +00:00
|
|
|
virtual void deleteGame(const MWState::Character* character, const MWState::Slot* slot) = 0;
|
2013-11-16 11:22:28 +00:00
|
|
|
|
|
|
|
virtual void saveGame(const std::string& description, const MWState::Slot* slot = nullptr) = 0;
|
|
|
|
///< Write a saved game to \a slot or create a new slot if \a slot == 0.
|
|
|
|
///
|
|
|
|
/// \note Slot must belong to the current character.
|
2013-11-18 14:38:08 +00:00
|
|
|
|
2018-07-26 16:54:08 +00:00
|
|
|
virtual void loadGame(const std::filesystem::path& filepath) = 0;
|
|
|
|
///< Load a saved game directly from the given file path. This will search the CharacterManager
|
2015-01-07 02:03:56 +00:00
|
|
|
/// for a Character containing this save file, and set this Character current if one was found.
|
|
|
|
/// Otherwise, a new Character will be created.
|
2018-07-26 16:54:08 +00:00
|
|
|
|
2014-04-28 18:57:45 +00:00
|
|
|
virtual void loadGame(const MWState::Character* character, const std::filesystem::path& filepath) = 0;
|
|
|
|
///< Load a saved game file belonging to the given character.
|
|
|
|
|
2020-11-13 07:39:47 +00:00
|
|
|
/// Simple saver, writes over the file if already existing
|
|
|
|
/** Used for quick save and autosave **/
|
|
|
|
virtual void quickSave(std::string = "Quicksave") = 0;
|
2013-11-19 14:38:26 +00:00
|
|
|
|
2022-06-19 11:28:33 +00:00
|
|
|
/// Simple loader, loads the last saved file
|
2014-04-24 07:14:47 +00:00
|
|
|
/** Used for quickload **/
|
2022-06-19 11:28:33 +00:00
|
|
|
virtual void quickLoad() = 0;
|
2015-01-07 02:03:56 +00:00
|
|
|
|
2022-06-19 11:28:33 +00:00
|
|
|
virtual MWState::Character* getCurrentCharacter() = 0;
|
2015-01-07 02:03:56 +00:00
|
|
|
///< @note May return null.
|
2013-11-21 11:24:24 +00:00
|
|
|
|
2014-04-24 07:06:36 +00:00
|
|
|
virtual CharacterIterator characterBegin() = 0;
|
|
|
|
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned
|
|
|
|
/// iterator.
|
|
|
|
|
2013-11-21 10:10:18 +00:00
|
|
|
virtual CharacterIterator characterEnd() = 0;
|
2013-11-16 09:31:46 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|