SaveTool: move some stuff into its own function.

This commit is contained in:
Guillaume Jacquemin 2022-03-06 09:12:40 +01:00
parent 8791eb32ac
commit db3eba5b59
2 changed files with 39 additions and 34 deletions

View file

@ -96,36 +96,7 @@ SaveTool::SaveTool(const Arguments& arguments):
_updateEventId = _initEventId + 1; _updateEventId = _initEventId + 1;
_backupsDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups"); initialiseToolDirectories();
_stagingDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "staging");
_armouryDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "armoury");
_armoursDir = Utility::Directory::join(_armouryDir, "armours");
_weaponsDir = Utility::Directory::join(_armouryDir, "weapons");
_stylesDir = Utility::Directory::join(_armouryDir, "styles");
if(!Utility::Directory::exists(_backupsDir)) {
Utility::Directory::mkpath(_backupsDir);
}
if(!Utility::Directory::exists(_stagingDir)) {
Utility::Directory::mkpath(_stagingDir);
}
if(!Utility::Directory::exists(_armouryDir)) {
Utility::Directory::mkpath(_armouryDir);
}
if(!Utility::Directory::exists(_armoursDir)) {
Utility::Directory::mkpath(_armoursDir);
}
if(!Utility::Directory::exists(_weaponsDir)) {
Utility::Directory::mkpath(_weaponsDir);
}
if(!Utility::Directory::exists(_stylesDir)) {
Utility::Directory::mkpath(_stylesDir);
}
if(!findGameDataDirectory()) { if(!findGameDataDirectory()) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window());
@ -563,6 +534,39 @@ void SaveTool::initialiseManager() {
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
void SaveTool::initialiseToolDirectories() {
_backupsDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "backups");
_stagingDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "staging");
//_armouryDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "armoury");
//_armoursDir = Utility::Directory::join(_armouryDir, "armours");
//_weaponsDir = Utility::Directory::join(_armouryDir, "weapons");
//_stylesDir = Utility::Directory::join(_armouryDir, "styles");
if(!Utility::Directory::exists(_backupsDir)) {
Utility::Directory::mkpath(_backupsDir);
}
if(!Utility::Directory::exists(_stagingDir)) {
Utility::Directory::mkpath(_stagingDir);
}
//if(!Utility::Directory::exists(_armouryDir)) {
// Utility::Directory::mkpath(_armouryDir);
//}
//if(!Utility::Directory::exists(_armoursDir)) {
// Utility::Directory::mkpath(_armoursDir);
//}
//if(!Utility::Directory::exists(_weaponsDir)) {
// Utility::Directory::mkpath(_weaponsDir);
//}
//if(!Utility::Directory::exists(_stylesDir)) {
// Utility::Directory::mkpath(_stylesDir);
//}
}
auto SaveTool::findGameDataDirectory() -> bool { auto SaveTool::findGameDataDirectory() -> bool {
wchar_t* localappdata_path = nullptr; wchar_t* localappdata_path = nullptr;
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree}; Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};

View file

@ -87,6 +87,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void initialiseConfiguration(); void initialiseConfiguration();
void initialiseGui(); void initialiseGui();
void initialiseManager(); void initialiseManager();
void initialiseToolDirectories();
auto findGameDataDirectory() -> bool; auto findGameDataDirectory() -> bool;
void initialiseMassManager(); void initialiseMassManager();
void initialiseFileWatcher(); void initialiseFileWatcher();
@ -226,10 +227,10 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
Containers::String _backupsDir; Containers::String _backupsDir;
Containers::String _stagingDir; Containers::String _stagingDir;
Containers::String _armouryDir; //Containers::String _armouryDir;
Containers::String _armoursDir; //Containers::String _armoursDir;
Containers::String _weaponsDir; //Containers::String _weaponsDir;
Containers::String _stylesDir; //Containers::String _stylesDir;
enum class GameState : UnsignedByte { enum class GameState : UnsignedByte {
Unknown, NotRunning, Running Unknown, NotRunning, Running