Compare commits
1 commit
9349b840a4
...
b569e27d6d
Author | SHA1 | Date | |
---|---|---|---|
b569e27d6d |
8 changed files with 55 additions and 39 deletions
|
@ -24,11 +24,11 @@
|
|||
|
||||
static const std::string empty_string = "";
|
||||
|
||||
MassManager::MassManager(const std::string& save_path, const std::string& steam_id, bool demo, const std::string& staging_dir):
|
||||
MassManager::MassManager(const std::string& save_path, const std::string& steam_id, bool demo):
|
||||
_saveDirectory{save_path},
|
||||
_steamId{steam_id},
|
||||
_demo{demo},
|
||||
_stagingAreaDirectory{staging_dir}
|
||||
_stagingAreaDirectory{Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "staging")}
|
||||
{
|
||||
Containers::arrayReserve(_hangars, 32);
|
||||
|
||||
|
@ -45,6 +45,14 @@ MassManager::MassManager(const std::string& save_path, const std::string& steam_
|
|||
refreshStagedMasses();
|
||||
}
|
||||
|
||||
auto MassManager::saveDirectory() -> std::string const& {
|
||||
return _saveDirectory;
|
||||
}
|
||||
|
||||
auto MassManager::stagingAreaDirectory() -> std::string const& {
|
||||
return _stagingAreaDirectory;
|
||||
}
|
||||
|
||||
auto MassManager::lastError() -> std::string const& {
|
||||
return _lastError;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ using namespace Corrade;
|
|||
|
||||
class MassManager {
|
||||
public:
|
||||
MassManager(const std::string& save_path, const std::string& steam_id, bool demo, const std::string& staging_dir);
|
||||
MassManager(const std::string& save_path, const std::string& steam_id, bool demo);
|
||||
|
||||
auto saveDirectory() -> std::string const&;
|
||||
auto stagingAreaDirectory() -> std::string const&;
|
||||
|
||||
auto lastError() -> std::string const&;
|
||||
|
||||
|
@ -47,15 +50,15 @@ class MassManager {
|
|||
auto deleteStagedMass(const std::string& filename) -> bool;
|
||||
|
||||
private:
|
||||
const std::string& _saveDirectory;
|
||||
const std::string& _steamId;
|
||||
std::string _saveDirectory;
|
||||
std::string _steamId;
|
||||
bool _demo;
|
||||
|
||||
std::string _lastError;
|
||||
|
||||
Containers::Array<Mass> _hangars;
|
||||
|
||||
const std::string& _stagingAreaDirectory;
|
||||
const std::string _stagingAreaDirectory;
|
||||
|
||||
std::map<std::string, std::string> _stagedMasses;
|
||||
};
|
||||
|
|
|
@ -33,10 +33,20 @@
|
|||
|
||||
using namespace Corrade;
|
||||
|
||||
ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
|
||||
_saveDirectory{save_dir},
|
||||
_backupsDirectory{backup_dir}
|
||||
ProfileManager::ProfileManager(const std::string& base_path):
|
||||
_backupsDirectory{Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups")}
|
||||
{
|
||||
_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();
|
||||
}
|
||||
|
||||
|
@ -48,6 +58,14 @@ auto ProfileManager::lastError() -> std::string const& {
|
|||
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& {
|
||||
return _profiles;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,14 @@ struct Backup {
|
|||
|
||||
class ProfileManager {
|
||||
public:
|
||||
explicit ProfileManager(const std::string& save_dir, const std::string& backup_dir);
|
||||
ProfileManager(const std::string& base_path);
|
||||
|
||||
auto ready() const -> bool;
|
||||
auto lastError() -> std::string const&;
|
||||
|
||||
auto saveDirectory() -> std::string const&;
|
||||
auto backupsDirectory() -> std::string const&;
|
||||
|
||||
auto profiles() -> std::vector<Profile> const&;
|
||||
auto refreshProfiles() -> bool;
|
||||
|
||||
|
@ -58,10 +61,10 @@ class ProfileManager {
|
|||
|
||||
private:
|
||||
bool _ready = false;
|
||||
std::string _lastError;
|
||||
std::string _lastError = "";
|
||||
|
||||
const std::string& _saveDirectory;
|
||||
const std::string& _backupsDirectory;
|
||||
std::string _saveDirectory;
|
||||
const std::string _backupsDirectory;
|
||||
|
||||
std::vector<Profile> _profiles;
|
||||
std::vector<Backup> _backups;
|
||||
|
|
|
@ -87,17 +87,6 @@ SaveTool::SaveTool(const Arguments& arguments):
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
_backupsDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups");
|
||||
_stagingDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "staging");
|
||||
|
||||
if(!Utility::Directory::exists(_backupsDir)) {
|
||||
Utility::Directory::mkpath(_backupsDir);
|
||||
}
|
||||
|
||||
if(!Utility::Directory::exists(_stagingDir)) {
|
||||
Utility::Directory::mkpath(_stagingDir);
|
||||
}
|
||||
|
||||
if(!findGameDataDirectory()) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.c_str(), window());
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -318,7 +307,7 @@ void SaveTool::initialiseManager() {
|
|||
SDL_zero(event);
|
||||
event.type = _initEventId;
|
||||
|
||||
_profileManager.emplace(_saveDir, _backupsDir);
|
||||
_profileManager.emplace(_gameDataDir);
|
||||
if(!_profileManager->ready()) {
|
||||
event.user.code = ProfileManagerFailure;
|
||||
SDL_PushEvent(&event);
|
||||
|
@ -351,18 +340,17 @@ auto SaveTool::findGameDataDirectory() -> bool {
|
|||
void SaveTool::initialiseMassManager() {
|
||||
_currentProfile->refreshValues();
|
||||
|
||||
_massManager.emplace(_saveDir,
|
||||
_massManager.emplace(_profileManager->saveDirectory(),
|
||||
_currentProfile->steamId(),
|
||||
_currentProfile->type() == ProfileType::Demo,
|
||||
_stagingDir);
|
||||
_currentProfile->type() == ProfileType::Demo);
|
||||
|
||||
initialiseFileWatcher();
|
||||
}
|
||||
|
||||
void SaveTool::initialiseFileWatcher() {
|
||||
_fileWatcher.emplace();
|
||||
_watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false);
|
||||
_watchIDs[StagingDir] = _fileWatcher->addWatch(_stagingDir, this, false);
|
||||
_watchIDs[SaveDir] = _fileWatcher->addWatch(_profileManager->saveDirectory(), this, false);
|
||||
_watchIDs[StagingDir] = _fileWatcher->addWatch(_massManager->stagingAreaDirectory(), this, false);
|
||||
_fileWatcher->watch();
|
||||
}
|
||||
|
||||
|
|
|
@ -170,9 +170,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
std::string _saveDir;
|
||||
std::string _screenshotsDir;
|
||||
|
||||
std::string _backupsDir;
|
||||
std::string _stagingDir;
|
||||
|
||||
enum class GameState : UnsignedByte {
|
||||
Unknown, NotRunning, Running
|
||||
} _gameState{GameState::Unknown};
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include <Corrade/Containers/Reference.h>
|
||||
#include <Corrade/Utility/Directory.h>
|
||||
#include <Corrade/Utility/FormatStl.h>
|
||||
#include <Corrade/Utility/String.h>
|
||||
|
||||
|
@ -652,7 +651,7 @@ void SaveTool::drawMassManager() {
|
|||
ImGui::TextUnformatted("Staging area");
|
||||
ImGui::SameLine();
|
||||
if(ImGui::SmallButton(ICON_FA_FOLDER_OPEN " Open staging folder")) {
|
||||
openUri(Utility::Directory::toNativeSeparators(_stagingDir));
|
||||
openUri(_massManager->stagingAreaDirectory());
|
||||
}
|
||||
|
||||
for(const auto& pair : _massManager->stagedMasses()) {
|
||||
|
|
|
@ -41,12 +41,12 @@ void SaveTool::drawMainMenu() {
|
|||
}
|
||||
|
||||
if(ImGui::BeginMenu(ICON_FA_FOLDER_OPEN " Open manager directory")) {
|
||||
if(ImGui::MenuItem(ICON_FA_FILE_ARCHIVE " Profile backups", nullptr, false, _profileManager != nullptr)) {
|
||||
openUri(Utility::Directory::toNativeSeparators(_backupsDir));
|
||||
if(ImGui::MenuItem(ICON_FA_EXCHANGE_ALT " Staging area", nullptr, false, _massManager != nullptr)) {
|
||||
openUri(Utility::Directory::toNativeSeparators(_massManager->stagingAreaDirectory()));
|
||||
}
|
||||
|
||||
if(ImGui::MenuItem(ICON_FA_EXCHANGE_ALT " Staging area", nullptr, false, _massManager != nullptr)) {
|
||||
openUri(Utility::Directory::toNativeSeparators(_stagingDir));
|
||||
if(ImGui::MenuItem(ICON_FA_FILE_ARCHIVE " Profile backups", nullptr, false, _profileManager != nullptr)) {
|
||||
openUri(Utility::Directory::toNativeSeparators(_profileManager->backupsDirectory()));
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
|
|
Loading…
Reference in a new issue