Build viewer/editor #13
4 changed files with 31 additions and 14 deletions
|
@ -36,7 +36,6 @@ using namespace Corrade;
|
||||||
Profile::Profile(const std::string& path):
|
Profile::Profile(const std::string& path):
|
||||||
_profile(path)
|
_profile(path)
|
||||||
{
|
{
|
||||||
_profileDirectory = Utility::Directory::path(path);
|
|
||||||
_filename = Utility::Directory::filename(path);
|
_filename = Utility::Directory::filename(path);
|
||||||
|
|
||||||
if(Utility::String::beginsWith(_filename, "Demo")) {
|
if(Utility::String::beginsWith(_filename, "Demo")) {
|
||||||
|
@ -46,7 +45,14 @@ Profile::Profile(const std::string& path):
|
||||||
_type = ProfileType::FullGame;
|
_type = ProfileType::FullGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steamId = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"});
|
_account = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"});
|
||||||
|
|
||||||
|
if(Utility::String::beginsWith(_account, "PMCSlot")) {
|
||||||
|
_version = ProfileVersion::Normal;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_version = ProfileVersion::Legacy;
|
||||||
|
}
|
||||||
|
|
||||||
refreshValues();
|
refreshValues();
|
||||||
|
|
||||||
|
@ -69,8 +75,12 @@ auto Profile::type() const -> ProfileType {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Profile::steamId() const -> std::string const& {
|
auto Profile::version() const -> ProfileVersion {
|
||||||
return _steamId;
|
return _version;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Profile::account() const -> std::string const& {
|
||||||
|
return _account;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::refreshValues() {
|
void Profile::refreshValues() {
|
||||||
|
|
|
@ -29,6 +29,11 @@ enum class ProfileType : UnsignedByte {
|
||||||
FullGame
|
FullGame
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ProfileVersion : UnsignedByte {
|
||||||
|
Legacy, // pre-0.8
|
||||||
|
Normal // 0.8 and later
|
||||||
|
};
|
||||||
|
|
||||||
class Profile {
|
class Profile {
|
||||||
public:
|
public:
|
||||||
explicit Profile(const std::string& path);
|
explicit Profile(const std::string& path);
|
||||||
|
@ -41,7 +46,9 @@ class Profile {
|
||||||
|
|
||||||
auto type() const -> ProfileType;
|
auto type() const -> ProfileType;
|
||||||
|
|
||||||
auto steamId() const -> std::string const&;
|
auto version() const -> ProfileVersion;
|
||||||
|
|
||||||
|
auto account() const -> std::string const&;
|
||||||
|
|
||||||
void refreshValues();
|
void refreshValues();
|
||||||
|
|
||||||
|
@ -122,10 +129,10 @@ class Profile {
|
||||||
auto getResource(const char* container, Int id) -> Int;
|
auto getResource(const char* container, Int id) -> Int;
|
||||||
auto setResource(const char* container, Int id, Int amount) -> bool;
|
auto setResource(const char* container, Int id, Int amount) -> bool;
|
||||||
|
|
||||||
std::string _profileDirectory;
|
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
|
|
||||||
ProfileType _type;
|
ProfileType _type;
|
||||||
|
ProfileVersion _version;
|
||||||
|
|
||||||
UESaveFile _profile;
|
UESaveFile _profile;
|
||||||
|
|
||||||
|
@ -159,7 +166,7 @@ class Profile {
|
||||||
Int _mineralExoskeletology = 0;
|
Int _mineralExoskeletology = 0;
|
||||||
Int _carbonisedSkin = 0;
|
Int _carbonisedSkin = 0;
|
||||||
|
|
||||||
std::string _steamId;
|
std::string _account;
|
||||||
|
|
||||||
bool _valid = false;
|
bool _valid = false;
|
||||||
std::string _lastError;
|
std::string _lastError;
|
||||||
|
|
|
@ -100,7 +100,7 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
|
||||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||||
std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||||
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||||
i, _profiles[index].steamId());
|
i, _profiles[index].account());
|
||||||
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
|
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
||||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||||
std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||||
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||||
i, _profiles[index].steamId());
|
i, _profiles[index].account());
|
||||||
|
|
||||||
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
|
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -227,7 +227,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case efsw::Actions::Add:
|
case efsw::Actions::Add:
|
||||||
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) {
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
@ -241,7 +241,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case efsw::Actions::Delete:
|
case efsw::Actions::Delete:
|
||||||
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) {
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
@ -255,7 +255,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
if(filename == _currentProfile->filename()) {
|
if(filename == _currentProfile->filename()) {
|
||||||
_currentProfile->refreshValues();
|
_currentProfile->refreshValues();
|
||||||
}
|
}
|
||||||
else if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
else if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) {
|
||||||
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) {
|
||||||
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) +
|
||||||
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
(filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30);
|
||||||
|
@ -273,7 +273,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case efsw::Actions::Moved:
|
case efsw::Actions::Moved:
|
||||||
if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) {
|
if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) {
|
||||||
if(Utility::String::endsWith(old_filename, ".tmp")) {
|
if(Utility::String::endsWith(old_filename, ".tmp")) {
|
||||||
is_moved_after_save = true;
|
is_moved_after_save = true;
|
||||||
return;
|
return;
|
||||||
|
@ -582,7 +582,7 @@ auto SaveTool::findGameDataDirectory() -> bool {
|
||||||
|
|
||||||
void SaveTool::initialiseMassManager() {
|
void SaveTool::initialiseMassManager() {
|
||||||
_massManager.emplace(_saveDir,
|
_massManager.emplace(_saveDir,
|
||||||
_currentProfile->steamId(),
|
_currentProfile->account(),
|
||||||
_currentProfile->type() == ProfileType::Demo,
|
_currentProfile->type() == ProfileType::Demo,
|
||||||
_stagingDir);
|
_stagingDir);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue