ProfileManager: move some fields to SaveTool.
This commit is contained in:
parent
2a617b3359
commit
241f5b754d
5 changed files with 19 additions and 32 deletions
|
@ -33,20 +33,10 @@
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
|
|
||||||
ProfileManager::ProfileManager(const std::string& base_path):
|
ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
|
||||||
_backupsDirectory{Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups")}
|
_saveDirectory{save_dir},
|
||||||
|
_backupsDirectory{backup_dir}
|
||||||
{
|
{
|
||||||
_saveDirectory = Utility::Directory::join(base_path, "Saved/SaveGames");
|
|
||||||
|
|
||||||
if(!Utility::Directory::exists(_backupsDirectory)) {
|
|
||||||
Utility::Directory::mkpath(_backupsDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Utility::Directory::exists(_saveDirectory)) {
|
|
||||||
_lastError = "Couldn't find the profile directory. Make sure you played enough of the game.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_ready = refreshProfiles();
|
_ready = refreshProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,14 +48,6 @@ auto ProfileManager::lastError() -> std::string const& {
|
||||||
return _lastError;
|
return _lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProfileManager::saveDirectory() -> std::string const& {
|
|
||||||
return _saveDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ProfileManager::backupsDirectory() -> std::string const& {
|
|
||||||
return _backupsDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ProfileManager::profiles() -> std::vector<Profile> const& {
|
auto ProfileManager::profiles() -> std::vector<Profile> const& {
|
||||||
return _profiles;
|
return _profiles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,11 @@ struct Backup {
|
||||||
|
|
||||||
class ProfileManager {
|
class ProfileManager {
|
||||||
public:
|
public:
|
||||||
ProfileManager(const std::string& base_path);
|
explicit ProfileManager(const std::string& save_dir, const std::string& backup_dir);
|
||||||
|
|
||||||
auto ready() const -> bool;
|
auto ready() const -> bool;
|
||||||
auto lastError() -> std::string const&;
|
auto lastError() -> std::string const&;
|
||||||
|
|
||||||
auto saveDirectory() -> std::string const&;
|
|
||||||
auto backupsDirectory() -> std::string const&;
|
|
||||||
|
|
||||||
auto profiles() -> std::vector<Profile> const&;
|
auto profiles() -> std::vector<Profile> const&;
|
||||||
auto refreshProfiles() -> bool;
|
auto refreshProfiles() -> bool;
|
||||||
|
|
||||||
|
@ -61,10 +58,10 @@ class ProfileManager {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _ready = false;
|
bool _ready = false;
|
||||||
std::string _lastError = "";
|
std::string _lastError;
|
||||||
|
|
||||||
std::string _saveDirectory;
|
const std::string& _saveDirectory;
|
||||||
const std::string _backupsDirectory;
|
const std::string& _backupsDirectory;
|
||||||
|
|
||||||
std::vector<Profile> _profiles;
|
std::vector<Profile> _profiles;
|
||||||
std::vector<Backup> _backups;
|
std::vector<Backup> _backups;
|
||||||
|
|
|
@ -87,6 +87,12 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_backupsDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups");
|
||||||
|
|
||||||
|
if(!Utility::Directory::exists(_backupsDir)) {
|
||||||
|
Utility::Directory::mkpath(_backupsDir);
|
||||||
|
}
|
||||||
|
|
||||||
if(!findGameDataDirectory()) {
|
if(!findGameDataDirectory()) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.c_str(), window());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.c_str(), window());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -304,7 +310,7 @@ void SaveTool::initialiseManager() {
|
||||||
SDL_zero(event);
|
SDL_zero(event);
|
||||||
event.type = _initEventId;
|
event.type = _initEventId;
|
||||||
|
|
||||||
_profileManager.emplace(_gameDataDir);
|
_profileManager.emplace(_saveDir, _backupsDir);
|
||||||
if(!_profileManager->ready()) {
|
if(!_profileManager->ready()) {
|
||||||
event.user.code = ProfileManagerFailure;
|
event.user.code = ProfileManagerFailure;
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
|
@ -337,7 +343,7 @@ auto SaveTool::findGameDataDirectory() -> bool {
|
||||||
void SaveTool::initialiseMassManager() {
|
void SaveTool::initialiseMassManager() {
|
||||||
_currentProfile->refreshValues();
|
_currentProfile->refreshValues();
|
||||||
|
|
||||||
_massManager.emplace(_profileManager->saveDirectory(),
|
_massManager.emplace(_saveDir,
|
||||||
_currentProfile->steamId(),
|
_currentProfile->steamId(),
|
||||||
_currentProfile->type() == ProfileType::Demo);
|
_currentProfile->type() == ProfileType::Demo);
|
||||||
|
|
||||||
|
@ -346,7 +352,7 @@ void SaveTool::initialiseMassManager() {
|
||||||
|
|
||||||
void SaveTool::initialiseFileWatcher() {
|
void SaveTool::initialiseFileWatcher() {
|
||||||
_fileWatcher.emplace();
|
_fileWatcher.emplace();
|
||||||
_watchIDs[SaveDir] = _fileWatcher->addWatch(_profileManager->saveDirectory(), this, false);
|
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);
|
||||||
_watchIDs[StagingDir] = _fileWatcher->addWatch(_massManager->stagingAreaDirectory(), this, false);
|
_watchIDs[StagingDir] = _fileWatcher->addWatch(_massManager->stagingAreaDirectory(), this, false);
|
||||||
_fileWatcher->watch();
|
_fileWatcher->watch();
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
std::string _saveDir;
|
std::string _saveDir;
|
||||||
std::string _screenshotsDir;
|
std::string _screenshotsDir;
|
||||||
|
|
||||||
|
std::string _backupsDir;
|
||||||
|
|
||||||
enum class GameState : UnsignedByte {
|
enum class GameState : UnsignedByte {
|
||||||
Unknown, NotRunning, Running
|
Unknown, NotRunning, Running
|
||||||
} _gameState{GameState::Unknown};
|
} _gameState{GameState::Unknown};
|
||||||
|
|
|
@ -46,7 +46,7 @@ void SaveTool::drawMainMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::MenuItem(ICON_FA_FILE_ARCHIVE " Profile backups", nullptr, false, _profileManager != nullptr)) {
|
if(ImGui::MenuItem(ICON_FA_FILE_ARCHIVE " Profile backups", nullptr, false, _profileManager != nullptr)) {
|
||||||
openUri(Utility::Directory::toNativeSeparators(_profileManager->backupsDirectory()));
|
openUri(Utility::Directory::toNativeSeparators(_backupsDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
|
Loading…
Reference in a new issue