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