mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-10 21:11:11 -04:00
Order characters by last save
This commit is contained in:
parent
4520eb077d
commit
d756b02d68
@ -18,14 +18,25 @@ bool MWState::operator<(const Slot& left, const Slot& right)
|
|||||||
return left.mTimeStamp < right.mTimeStamp;
|
return left.mTimeStamp < right.mTimeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MWState::getFirstGameFile(const std::vector<std::string>& contentFiles)
|
bool MWState::operator<(const Character& left, const Character& right)
|
||||||
|
{
|
||||||
|
if (left.mSlots.empty() && right.mSlots.empty())
|
||||||
|
return left.mPath < right.mPath;
|
||||||
|
else if (left.mSlots.empty())
|
||||||
|
return false;
|
||||||
|
else if (right.mSlots.empty())
|
||||||
|
return true;
|
||||||
|
return right.mSlots.back() < left.mSlots.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view MWState::getFirstGameFile(const std::vector<std::string>& contentFiles)
|
||||||
{
|
{
|
||||||
for (const std::string& c : contentFiles)
|
for (const std::string& c : contentFiles)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEndsWith(c, ".esm") || Misc::StringUtils::ciEndsWith(c, ".omwgame"))
|
if (Misc::StringUtils::ciEndsWith(c, ".esm") || Misc::StringUtils::ciEndsWith(c, ".omwgame"))
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
return "";
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWState::Character::addSlot(const std::filesystem::path& path, const std::string& game)
|
void MWState::Character::addSlot(const std::filesystem::path& path, const std::string& game)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define GAME_STATE_CHARACTER_H
|
#define GAME_STATE_CHARACTER_H
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#include <components/esm3/savedgame.hpp>
|
#include <components/esm3/savedgame.hpp>
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace MWState
|
|||||||
|
|
||||||
bool operator<(const Slot& left, const Slot& right);
|
bool operator<(const Slot& left, const Slot& right);
|
||||||
|
|
||||||
std::string getFirstGameFile(const std::vector<std::string>& contentFiles);
|
std::string_view getFirstGameFile(const std::vector<std::string>& contentFiles);
|
||||||
|
|
||||||
class Character
|
class Character
|
||||||
{
|
{
|
||||||
@ -63,6 +64,8 @@ namespace MWState
|
|||||||
///< Return signature information for this character.
|
///< Return signature information for this character.
|
||||||
///
|
///
|
||||||
/// \attention This function must not be called if there are no slots.
|
/// \attention This function must not be called if there are no slots.
|
||||||
|
|
||||||
|
friend bool operator<(const Character& left, const Character& right);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,8 @@ MWState::CharacterManager::CharacterManager(std::filesystem::path saves, const s
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (std::filesystem::directory_iterator iter(mPath); iter != std::filesystem::directory_iterator(); ++iter)
|
for (const std::filesystem::path& characterDir : std::filesystem::directory_iterator(mPath))
|
||||||
{
|
{
|
||||||
std::filesystem::path characterDir = *iter;
|
|
||||||
|
|
||||||
if (std::filesystem::is_directory(characterDir))
|
if (std::filesystem::is_directory(characterDir))
|
||||||
{
|
{
|
||||||
Character character(characterDir, mGame);
|
Character character(characterDir, mGame);
|
||||||
@ -30,6 +28,7 @@ MWState::CharacterManager::CharacterManager(std::filesystem::path saves, const s
|
|||||||
mCharacters.push_back(character);
|
mCharacters.push_back(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mCharacters.sort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user