1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwstate/statemanagerimp.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3.3 KiB
C++
Raw Normal View History

2013-11-16 10:31:46 +01:00
#ifndef GAME_STATE_STATEMANAGER_H
#define GAME_STATE_STATEMANAGER_H
#include <filesystem>
#include <map>
2013-11-16 10:31:46 +01:00
#include "../mwbase/statemanager.hpp"
#include "charactermanager.hpp"
2013-11-16 10:31:46 +01:00
namespace MWState
{
class StateManager : public MWBase::StateManager
{
bool mQuitRequest;
2013-12-19 22:08:34 +02:00
bool mAskLoadRecent;
bool mNewGameRequest = false;
std::optional<std::filesystem::path> mLoadRequest;
State mState;
CharacterManager mCharacterManager;
double mTimePlayed;
std::filesystem::path mLastSavegame;
2013-11-28 11:22:34 +01:00
private:
void cleanup(bool force = false);
void printSavegameFormatError(const std::string& exceptionText, const std::string& messageBoxText);
bool confirmLoading(const std::vector<std::string_view>& missingFiles) const;
2015-06-03 16:40:16 +02:00
void writeScreenshot(std::vector<char>& imageData) const;
std::map<int, int> buildContentFileIndexMap(const ESM::ESMReader& reader) const;
2013-11-16 10:31:46 +01:00
2022-09-22 21:26:05 +03:00
public:
StateManager(const std::filesystem::path& saves, const std::vector<std::string>& contentFiles);
2013-11-16 10:31:46 +01:00
void requestQuit() override;
bool hasQuitRequest() const override;
void askLoadRecent() override;
2013-12-19 22:08:34 +02:00
void requestNewGame() override { mNewGameRequest = true; }
void requestLoad(const std::filesystem::path& filepath) override { mLoadRequest = filepath; }
State getState() const override;
void newGame(bool bypass = false) override;
///< Start a new game.
///
/// \param bypass Skip new game mechanics.
2013-11-18 15:38:08 +01:00
2022-05-06 19:56:10 +02:00
void endGame();
void resumeGame() override;
2018-07-26 19:54:08 +03:00
void deleteGame(const MWState::Character* character, const MWState::Slot* slot) override;
///< Delete a saved game slot from this character. If all save slots are deleted, the character will be deleted
///< too.
void saveGame(std::string_view description, const Slot* slot = nullptr) override;
///< Write a saved game to \a slot or create a new slot if \a slot == 0.
///
/// \note Slot must belong to the current character.
/// Saves a file, using supplied filename, overwritting if needed
/** This is mostly used for quicksaving and autosaving, for they use the same name over and over again
\param name Name of save, defaults to "Quicksave"**/
void quickSave(std::string name = "Quicksave") override;
/// Loads the last saved file
/** Used for quickload **/
void quickLoad() override;
void loadGame(const std::filesystem::path& filepath) override;
///< Load a saved game directly from the given file path. This will search the CharacterManager
/// for a Character containing this save file, and set this Character current if one was found.
/// Otherwise, a new Character will be created.
void loadGame(const Character* character, const std::filesystem::path& filepath) override;
///< Load a saved game file belonging to the given character.
2013-11-21 12:24:24 +01:00
Character* getCurrentCharacter() override;
///< @note May return null.
CharacterIterator characterBegin() override;
2013-11-21 12:29:24 +01:00
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned
/// iterator.
CharacterIterator characterEnd() override;
void update(float duration);
2013-11-16 10:31:46 +01:00
};
}
#endif