1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-12 00:40:23 +00:00
OpenMW/apps/openmw/mwstate/character.hpp

70 lines
1.9 KiB
C++
Raw Normal View History

#ifndef GAME_STATE_CHARACTER_H
#define GAME_STATE_CHARACTER_H
#include <filesystem>
#include <components/esm3/savedgame.hpp>
namespace MWState
{
struct Slot
{
std::filesystem::path mPath;
ESM::SavedGame mProfile;
std::filesystem::file_time_type mTimeStamp;
};
2022-09-22 21:26:05 +03:00
bool operator<(const Slot& left, const Slot& right);
std::string getFirstGameFile(const std::vector<std::string>& contentFiles);
class Character
{
2022-09-22 21:26:05 +03:00
public:
typedef std::vector<Slot>::const_reverse_iterator SlotIterator;
2022-09-22 21:26:05 +03:00
private:
std::filesystem::path mPath;
std::vector<Slot> mSlots;
2022-09-22 21:26:05 +03:00
void addSlot(const std::filesystem::path& path, const std::string& game);
2022-09-22 21:26:05 +03:00
void addSlot(const ESM::SavedGame& profile);
2022-09-22 21:26:05 +03:00
public:
2024-01-30 09:45:57 +04:00
Character(const std::filesystem::path& saves, const std::string& game);
2022-09-22 21:26:05 +03:00
void cleanup();
///< Delete the directory we used, if it is empty
2022-09-22 21:26:05 +03:00
const Slot* createSlot(const ESM::SavedGame& profile);
///< Create new slot.
///
/// \attention The ownership of the slot is not transferred.
2022-09-22 21:26:05 +03:00
/// \note Slot must belong to this character.
///
/// \attention The \a slot pointer will be invalidated by this call.
void deleteSlot(const Slot* slot);
2022-09-22 21:26:05 +03:00
const Slot* updateSlot(const Slot* slot, const ESM::SavedGame& profile);
/// \note Slot must belong to this character.
///
/// \attention The \a slot pointer will be invalidated by this call.
2022-09-22 21:26:05 +03:00
SlotIterator begin() const;
///< Any call to createSlot and updateSlot can invalidate the returned iterator.
2022-09-22 21:26:05 +03:00
SlotIterator end() const;
2013-11-21 11:18:56 +01:00
2022-09-22 21:26:05 +03:00
const std::filesystem::path& getPath() const;
2022-09-22 21:26:05 +03:00
const ESM::SavedGame& getSignature() const;
///< Return signature information for this character.
///
/// \attention This function must not be called if there are no slots.
};
}
#endif