2013-11-16 10:31:46 +01:00
|
|
|
#ifndef GAME_MWSTATE_STATEMANAGER_H
|
|
|
|
#define GAME_MWSTATE_STATEMANAGER_H
|
|
|
|
|
2023-04-17 21:12:05 +02:00
|
|
|
#include <filesystem>
|
2014-06-02 20:24:35 +02:00
|
|
|
#include <list>
|
2013-11-24 15:19:56 +01:00
|
|
|
#include <string>
|
2013-11-21 11:10:18 +01:00
|
|
|
|
2013-11-19 15:38:26 +01:00
|
|
|
namespace MWState
|
|
|
|
{
|
|
|
|
struct Slot;
|
|
|
|
class Character;
|
|
|
|
}
|
|
|
|
|
2013-11-16 10:31:46 +01:00
|
|
|
namespace MWBase
|
|
|
|
{
|
|
|
|
/// \brief Interface for game state manager (implemented in MWState)
|
|
|
|
class StateManager
|
|
|
|
{
|
2013-11-18 15:15:47 +01:00
|
|
|
public:
|
|
|
|
enum State
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-11-18 15:15:47 +01:00
|
|
|
State_NoGame,
|
|
|
|
State_Ended,
|
|
|
|
State_Running
|
2022-09-22 21:26:05 +03:00
|
|
|
};
|
2013-11-18 15:15:47 +01:00
|
|
|
|
|
|
|
typedef std::list<MWState::Character>::const_iterator CharacterIterator;
|
|
|
|
|
2014-06-02 20:24:35 +02:00
|
|
|
private:
|
|
|
|
StateManager(const StateManager&);
|
|
|
|
///< not implemented
|
2013-11-21 11:10:18 +01:00
|
|
|
|
2013-11-16 10:31:46 +01:00
|
|
|
StateManager& operator=(const StateManager&);
|
|
|
|
///< not implemented
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
public:
|
2013-11-16 10:31:46 +01:00
|
|
|
StateManager() {}
|
|
|
|
|
|
|
|
virtual ~StateManager() {}
|
|
|
|
|
2013-11-16 11:07:23 +01:00
|
|
|
virtual void requestQuit() = 0;
|
2013-11-16 10:31:46 +01:00
|
|
|
|
|
|
|
virtual bool hasQuitRequest() const = 0;
|
|
|
|
|
|
|
|
virtual void askLoadRecent() = 0;
|
2013-11-16 11:07:23 +01:00
|
|
|
|
|
|
|
virtual State getState() const = 0;
|
|
|
|
|
|
|
|
virtual void newGame(bool bypass = false) = 0;
|
|
|
|
///< Start a new game.
|
2022-09-22 21:26:05 +03:00
|
|
|
///
|
2013-11-16 11:07:23 +01:00
|
|
|
/// \param bypass Skip new game mechanics.
|
2013-11-16 12:22:28 +01:00
|
|
|
|
2013-12-19 22:08:34 +02:00
|
|
|
virtual void resumeGame() = 0;
|
|
|
|
|
2013-11-18 15:15:47 +01:00
|
|
|
virtual void deleteGame(const MWState::Character* character, const MWState::Slot* slot) = 0;
|
2013-11-16 12:22:28 +01:00
|
|
|
|
2023-07-23 14:40:46 -04:00
|
|
|
virtual void saveGame(std::string_view description, const MWState::Slot* slot = nullptr) = 0;
|
2013-11-16 12:22:28 +01:00
|
|
|
///< 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 15:38:08 +01:00
|
|
|
|
2018-07-26 19:54:08 +03: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 03:03:56 +01: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 19:54:08 +03:00
|
|
|
|
2014-04-28 20:57:45 +02: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 11:39:47 +04: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 15:38:26 +01:00
|
|
|
|
2022-06-19 13:28:33 +02:00
|
|
|
/// Simple loader, loads the last saved file
|
2014-04-24 03:14:47 -04:00
|
|
|
/** Used for quickload **/
|
2022-06-19 13:28:33 +02:00
|
|
|
virtual void quickLoad() = 0;
|
2015-01-07 03:03:56 +01:00
|
|
|
|
2022-06-19 13:28:33 +02:00
|
|
|
virtual MWState::Character* getCurrentCharacter() = 0;
|
2015-01-07 03:03:56 +01:00
|
|
|
///< @note May return null.
|
2013-11-21 12:24:24 +01:00
|
|
|
|
2014-04-24 03:06:36 -04:00
|
|
|
virtual CharacterIterator characterBegin() = 0;
|
|
|
|
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned
|
|
|
|
/// iterator.
|
|
|
|
|
2013-11-21 11:10:18 +01:00
|
|
|
virtual CharacterIterator characterEnd() = 0;
|
2013-11-16 10:31:46 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|