Compare commits
4 commits
63a8cf7075
...
b287c827d2
Author | SHA1 | Date | |
---|---|---|---|
b287c827d2 | |||
2c2e5ad936 | |||
ef05c075ba | |||
14d75e0e83 |
10 changed files with 143 additions and 114 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -30,7 +30,3 @@
|
||||||
path = third-party/cpr
|
path = third-party/cpr
|
||||||
url = https://github.com/whoshuu/cpr
|
url = https://github.com/whoshuu/cpr
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "json.hpp"]
|
|
||||||
path = third-party/json
|
|
||||||
url = https://github.com/nlohmann/json
|
|
||||||
branch = master
|
|
||||||
|
|
|
@ -92,7 +92,4 @@ set(CPR_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) # For some reason, even when HTTP_ONLY is set to ON, libcurl will try to link to libssh2.
|
set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) # For some reason, even when HTTP_ONLY is set to ON, libcurl will try to link to libssh2.
|
||||||
add_subdirectory(third-party/cpr EXCLUDE_FROM_ALL)
|
add_subdirectory(third-party/cpr EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
|
|
||||||
add_subdirectory(third-party/json)
|
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -192,6 +192,5 @@ target_link_libraries(MassBuilderSaveTool PRIVATE
|
||||||
efsw
|
efsw
|
||||||
zip
|
zip
|
||||||
cpr::cpr
|
cpr::cpr
|
||||||
nlohmann_json::nlohmann_json
|
|
||||||
imm32
|
imm32
|
||||||
wtsapi32)
|
wtsapi32)
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
#include <cpr/cpr.h>
|
#include <cpr/cpr.h>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include <processthreadsapi.h>
|
#include <processthreadsapi.h>
|
||||||
|
@ -64,18 +62,6 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
tweak.enable(""_s, "../../"_s);
|
tweak.enable(""_s, "../../"_s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(SDL_VERSION_ATLEAST(2, 0, 5)) {
|
|
||||||
if(SDL_SetHintWithPriority(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1", SDL_HINT_OVERRIDE) == SDL_TRUE) {
|
|
||||||
Utility::Debug{} << "Clickthrough is available."_s;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Utility::Warning{} << "Clickthrough is not available (hint couldn't be set)."_s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Utility::Warning{} << "Clickthrough is not available (SDL2 is too old)."_s;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL::Renderer::enable(GL::Renderer::Feature::Blending);
|
GL::Renderer::enable(GL::Renderer::Feature::Blending);
|
||||||
GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);
|
GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);
|
||||||
GL::Renderer::disable(GL::Renderer::Feature::FaceCulling);
|
GL::Renderer::disable(GL::Renderer::Feature::FaceCulling);
|
||||||
|
@ -85,7 +71,24 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add,
|
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add,
|
||||||
GL::Renderer::BlendEquation::Add);
|
GL::Renderer::BlendEquation::Add);
|
||||||
|
|
||||||
initialiseGui();
|
Utility::Debug{} << "Renderer initialisation successful.";
|
||||||
|
|
||||||
|
Utility::Debug{} << "===Configuring SDL2===";
|
||||||
|
|
||||||
|
{
|
||||||
|
Utility::Debug d{};
|
||||||
|
d << "Enabling clickthrough...";
|
||||||
|
|
||||||
|
if(SDL_VERSION_ATLEAST(2, 0, 5)) {
|
||||||
|
if(SDL_SetHintWithPriority(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1", SDL_HINT_OVERRIDE) == SDL_TRUE) {
|
||||||
|
d << "success!"_s;
|
||||||
|
} else {
|
||||||
|
d << "error: hint couldn't be set."_s;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
d << "error: SDL2 is too old (version < 2.0.5)."_s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((_initEventId = SDL_RegisterEvents(3)) == UnsignedInt(-1)) {
|
if((_initEventId = SDL_RegisterEvents(3)) == UnsignedInt(-1)) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
||||||
|
@ -97,20 +100,26 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
_updateEventId = _initEventId + 1;
|
_updateEventId = _initEventId + 1;
|
||||||
_fileEventId = _initEventId + 2;
|
_fileEventId = _initEventId + 2;
|
||||||
|
|
||||||
initialiseToolDirectories();
|
if(SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", SDL_GetError(), window());
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!findGameDataDirectory()) {
|
Utility::Debug{} << "SDL2 configuration successful.";
|
||||||
|
|
||||||
|
Utility::Debug{} << "===Initialising the Save Tool===";
|
||||||
|
|
||||||
|
initialiseGui();
|
||||||
|
|
||||||
|
if(!initialiseToolDirectories()) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_configDir = Utility::Path::join(_gameDataDir, "Saved/Config/WindowsNoEditor");
|
if(!findGameDataDirectory()) {
|
||||||
_saveDir = Utility::Path::join(_gameDataDir, "Saved/SaveGames");
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window());
|
||||||
_screenshotsDir = Utility::Path::join(_gameDataDir, "Saved/Screenshots/WindowsNoEditor");
|
|
||||||
|
|
||||||
if(SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
|
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", SDL_GetError(), window());
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -153,6 +162,9 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
|
GL::DebugOutput::setEnabled(GL::DebugOutput::Source::Api, GL::DebugOutput::Type::Other, {131185}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utility::Debug{} << "Initialisation successful.";
|
||||||
|
Utility::Debug{} << "===Running main loop===";
|
||||||
|
|
||||||
if(_skipDisclaimer) {
|
if(_skipDisclaimer) {
|
||||||
_uiState = UiState::Initialising;
|
_uiState = UiState::Initialising;
|
||||||
_initThread = std::thread{[this]{ initialiseManager(); }};
|
_initThread = std::thread{[this]{ initialiseManager(); }};
|
||||||
|
@ -160,8 +172,12 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveTool::~SaveTool() {
|
SaveTool::~SaveTool() {
|
||||||
|
Utility::Debug{} << "===Perfoming cleanup===";
|
||||||
|
|
||||||
SDL_RemoveTimer(_gameCheckTimerId);
|
SDL_RemoveTimer(_gameCheckTimerId);
|
||||||
|
|
||||||
|
Utility::Debug{} << "Saving the configuration...";
|
||||||
|
|
||||||
_conf.setValue("cheat_mode"_s, _cheatMode);
|
_conf.setValue("cheat_mode"_s, _cheatMode);
|
||||||
_conf.setValue("unsafe_mode"_s, _unsafeMode);
|
_conf.setValue("unsafe_mode"_s, _unsafeMode);
|
||||||
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup);
|
||||||
|
@ -180,6 +196,8 @@ SaveTool::~SaveTool() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_conf.save();
|
_conf.save();
|
||||||
|
|
||||||
|
Utility::Debug{} << "Exiting...";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
|
@ -286,6 +304,7 @@ void SaveTool::initEvent(SDL_Event& event) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
break;
|
break;
|
||||||
case ProfileManagerFailure:
|
case ProfileManagerFailure:
|
||||||
|
Utility::Error{} << "Error initialising ProfileManager:" << _profileManager->lastError();
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().data(), window());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().data(), window());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
break;
|
break;
|
||||||
|
@ -310,10 +329,6 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using json = nlohmann::json;
|
|
||||||
|
|
||||||
json response = json::parse(r.text);
|
|
||||||
|
|
||||||
struct Version {
|
struct Version {
|
||||||
explicit Version(Containers::StringView str) {
|
explicit Version(Containers::StringView str) {
|
||||||
std::size_t start_point = 0;
|
std::size_t start_point = 0;
|
||||||
|
@ -327,17 +342,31 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||||
major = std::strtol(components[0].data(), nullptr, 10);
|
major = std::strtol(components[0].data(), nullptr, 10);
|
||||||
minor = std::strtol(components[1].data(), nullptr, 10);
|
minor = std::strtol(components[1].data(), nullptr, 10);
|
||||||
patch = std::strtol(components[2].data(), nullptr, 10);
|
patch = std::strtol(components[2].data(), nullptr, 10);
|
||||||
|
|
||||||
|
fullVersion = major * 10000 + minor * 100 + patch;
|
||||||
|
|
||||||
|
if(str.hasSuffix("-pre")) {
|
||||||
|
prerelease = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Int major;
|
Int fullVersion;
|
||||||
Int minor;
|
Int major = 0;
|
||||||
Int patch;
|
Int minor = 0;
|
||||||
|
Int patch = 0;
|
||||||
|
bool prerelease = false;
|
||||||
|
|
||||||
bool operator==(const Version& other) const {
|
bool operator==(const Version& other) const {
|
||||||
return (major == other.major) && (minor == other.minor) && (patch == other.patch);
|
return fullVersion == other.fullVersion;
|
||||||
}
|
}
|
||||||
bool operator>(const Version& other) const {
|
bool operator>(const Version& other) const {
|
||||||
return ( major * 10000 + minor * 100 + patch) >
|
if((fullVersion > other.fullVersion) ||
|
||||||
(other.major * 10000 + other.minor * 100 + other.patch);
|
(fullVersion == other.fullVersion && prerelease == false && other.prerelease == true))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
operator Containers::String() const {
|
operator Containers::String() const {
|
||||||
return Utility::format("{}.{}.{}", major, minor, patch);
|
return Utility::format("{}.{}.{}", major, minor, patch);
|
||||||
|
@ -346,29 +375,24 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||||
|
|
||||||
static const Version current_ver{SAVETOOL_VERSION};
|
static const Version current_ver{SAVETOOL_VERSION};
|
||||||
|
|
||||||
for(auto& release : response) {
|
Containers::String response = r.text.c_str();
|
||||||
if(release["prerelease"] == true) {
|
auto components = response.split('\n');
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Version latest_ver{release["tag_name"].get<std::string>().c_str()};
|
Version latest_ver{components.front()};
|
||||||
|
|
||||||
if(latest_ver > current_ver || (latest_ver == current_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
|
if(latest_ver > current_ver) {
|
||||||
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information."_s,
|
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information."_s,
|
||||||
std::chrono::milliseconds{5000});
|
std::chrono::milliseconds{5000});
|
||||||
_updateAvailable = true;
|
_updateAvailable = true;
|
||||||
_latestVersion = latest_ver;
|
_latestVersion = latest_ver;
|
||||||
_releaseLink = release["html_url"].get<std::string>().c_str();
|
_releaseLink = Utility::format("https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool/releases/tag/v{}", components.front());
|
||||||
_downloadLink = release["assets"][0]["browser_download_url"].get<std::string>().c_str();
|
_downloadLink = components.back();
|
||||||
}
|
}
|
||||||
else if(latest_ver == current_ver || (current_ver > latest_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
|
else if(latest_ver == current_ver || (current_ver > latest_ver && current_ver.prerelease == true)) {
|
||||||
_queue.addToast(Toast::Type::Success, "The application is already up to date."_s);
|
_queue.addToast(Toast::Type::Success, "The application is already up to date."_s);
|
||||||
}
|
}
|
||||||
else if(current_ver > latest_ver) {
|
else if(current_ver > latest_ver && current_ver.prerelease == false) {
|
||||||
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"_s);
|
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"_s);
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +480,8 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseConfiguration() {
|
void SaveTool::initialiseConfiguration() {
|
||||||
|
Utility::Debug{} << "Reading configuration file...";
|
||||||
|
|
||||||
if(_conf.hasValue("cheat_mode"_s)) {
|
if(_conf.hasValue("cheat_mode"_s)) {
|
||||||
_cheatMode = _conf.value<bool>("cheat_mode"_s);
|
_cheatMode = _conf.value<bool>("cheat_mode"_s);
|
||||||
}
|
}
|
||||||
|
@ -505,6 +531,8 @@ void SaveTool::initialiseConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseGui() {
|
void SaveTool::initialiseGui() {
|
||||||
|
Utility::Debug{} << "Initialising ImGui...";
|
||||||
|
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
@ -564,7 +592,9 @@ void SaveTool::initialiseManager() {
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseToolDirectories() {
|
auto SaveTool::initialiseToolDirectories() -> bool {
|
||||||
|
Utility::Debug{} << "Initialising Save Tool directories...";
|
||||||
|
|
||||||
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
|
_backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups");
|
||||||
_stagingDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "staging");
|
_stagingDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "staging");
|
||||||
//_armouryDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "armoury");
|
//_armouryDir = Utility::Directory::join(Utility::Directory::path(Utility::Directory::executableLocation()), "armoury");
|
||||||
|
@ -573,52 +603,83 @@ void SaveTool::initialiseToolDirectories() {
|
||||||
//_stylesDir = Utility::Directory::join(_armouryDir, "styles");
|
//_stylesDir = Utility::Directory::join(_armouryDir, "styles");
|
||||||
|
|
||||||
if(!Utility::Path::exists(_backupsDir)) {
|
if(!Utility::Path::exists(_backupsDir)) {
|
||||||
Utility::Path::make(_backupsDir);
|
Utility::Debug{} << "Backups directory not found, creating...";
|
||||||
|
if(!Utility::Path::make(_backupsDir)) {
|
||||||
|
Utility::Error{} << (_lastError = "Couldn't create the backups directory.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Path::exists(_stagingDir)) {
|
if(!Utility::Path::exists(_stagingDir)) {
|
||||||
Utility::Path::make(_stagingDir);
|
Utility::Debug{} << "Staging directory not found, creating...";
|
||||||
|
if(!Utility::Path::make(_stagingDir)) {
|
||||||
|
Utility::Error{} << (_lastError = "Couldn't create the backups directory.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(!Utility::Directory::exists(_armouryDir)) {
|
//if(!Utility::Directory::exists(_armouryDir)) {
|
||||||
// Utility::Directory::mkpath(_armouryDir);
|
// Utility::Debug{} << "Armoury directory not found, creating...";
|
||||||
|
// if(!Utility::Path::make(_armouryDir)) {
|
||||||
|
// Utility::Error{} << (_lastError = "Couldn't create the armoury directory.");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//if(!Utility::Directory::exists(_armoursDir)) {
|
//if(!Utility::Directory::exists(_armoursDir)) {
|
||||||
// Utility::Directory::mkpath(_armoursDir);
|
// Utility::Debug{} << "Armours directory not found, creating...";
|
||||||
|
// if(!Utility::Path::make(_armoursDir)) {
|
||||||
|
// Utility::Error{} << (_lastError = "Couldn't create the armours directory.");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//if(!Utility::Directory::exists(_weaponsDir)) {
|
//if(!Utility::Directory::exists(_weaponsDir)) {
|
||||||
// Utility::Directory::mkpath(_weaponsDir);
|
// Utility::Debug{} << "Weapons directory not found, creating...";
|
||||||
|
// if(!Utility::Path::make(_weaponsDir)) {
|
||||||
|
// Utility::Error{} << (_lastError = "Couldn't create the weapons directory.");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//if(!Utility::Directory::exists(_stylesDir)) {
|
//if(!Utility::Directory::exists(_stylesDir)) {
|
||||||
// Utility::Directory::mkpath(_stylesDir);
|
// Utility::Debug{} << "Styles directory not found, creating...";
|
||||||
|
// if(!Utility::Path::make(_stylesDir)) {
|
||||||
|
// Utility::Error{} << (_lastError = "Couldn't create the styles directory.");
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SaveTool::findGameDataDirectory() -> bool {
|
auto SaveTool::findGameDataDirectory() -> bool {
|
||||||
|
Utility::Debug{} << "Searching for the game's save directory...";
|
||||||
|
|
||||||
wchar_t* localappdata_path = nullptr;
|
wchar_t* localappdata_path = nullptr;
|
||||||
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
|
||||||
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
|
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
|
||||||
{
|
{
|
||||||
_lastError = "SHGetKnownFolderPath() failed in SaveTool::findGameDataDirectory()"_s;
|
Utility::Error{} << (_lastError = "SHGetKnownFolderPath() failed in SaveTool::findGameDataDirectory()"_s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gameDataDir = Utility::Path::join(Utility::Path::fromNativeSeparators(Utility::Unicode::narrow(localappdata_path)), "MASS_Builder"_s);
|
_gameDataDir = Utility::Path::join(Utility::Path::fromNativeSeparators(Utility::Unicode::narrow(localappdata_path)), "MASS_Builder"_s);
|
||||||
|
|
||||||
if(!Utility::Path::exists(_gameDataDir)) {
|
if(!Utility::Path::exists(_gameDataDir)) {
|
||||||
_lastError = _gameDataDir + " wasn't found. Make sure to play the game at least once."_s;
|
Utility::Error{} << (_lastError = _gameDataDir + " wasn't found. Make sure to play the game at least once."_s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_configDir = Utility::Path::join(_gameDataDir, "Saved/Config/WindowsNoEditor"_s);
|
||||||
|
_saveDir = Utility::Path::join(_gameDataDir, "Saved/SaveGames"_s);
|
||||||
|
_screenshotsDir = Utility::Path::join(_gameDataDir, "Saved/Screenshots/WindowsNoEditor"_s);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseMassManager() {
|
void SaveTool::initialiseMassManager() {
|
||||||
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
|
_massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir);
|
||||||
initialiseFileWatcher();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseFileWatcher() {
|
void SaveTool::initialiseFileWatcher() {
|
||||||
|
@ -826,12 +887,11 @@ void SaveTool::checkGameState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::checkForUpdates() {
|
void SaveTool::checkForUpdates() {
|
||||||
cpr::Response r = cpr::Get(cpr::Url{"https://williamjcm.ovh/git/api/v1/repos/williamjcm/MassBuilderSaveTool/releases"}, cpr::Timeout{10000});
|
cpr::Response r = cpr::Get(cpr::Url{"https://williamjcm.ovh/mbst/version"}, cpr::Timeout{10000});
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_zero(event);
|
SDL_zero(event);
|
||||||
event.type = _updateEventId;
|
event.type = _updateEventId;
|
||||||
event.user.code = r.status_code;
|
|
||||||
event.user.data1 = new cpr::Response{std::move(r)};
|
event.user.data1 = new cpr::Response{std::move(r)};
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
void initialiseConfiguration();
|
void initialiseConfiguration();
|
||||||
void initialiseGui();
|
void initialiseGui();
|
||||||
void initialiseManager();
|
void initialiseManager();
|
||||||
void initialiseToolDirectories();
|
auto initialiseToolDirectories() -> bool;
|
||||||
auto findGameDataDirectory() -> bool;
|
auto findGameDataDirectory() -> bool;
|
||||||
void initialiseMassManager();
|
void initialiseMassManager();
|
||||||
void initialiseFileWatcher();
|
void initialiseFileWatcher();
|
||||||
|
|
|
@ -88,6 +88,7 @@ void SaveTool::drawProfileManager() {
|
||||||
{
|
{
|
||||||
_currentProfile = _profileManager->getProfile(i);
|
_currentProfile = _profileManager->getProfile(i);
|
||||||
initialiseMassManager();
|
initialiseMassManager();
|
||||||
|
initialiseFileWatcher();
|
||||||
_uiState = UiState::MainManager;
|
_uiState = UiState::MainManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,31 +270,6 @@ void SaveTool::drawAbout() {
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::TreeNodeEx("JSON for Modern C++ (aka json.hpp)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
|
||||||
auto json_website = "https://json.nlohmann.me/";
|
|
||||||
drawAlignedText(ICON_FA_GLOBE " %s", json_website);
|
|
||||||
ImGui::SameLine();
|
|
||||||
if(ImGui::Button("Copy to clipboard")) {
|
|
||||||
ImGui::SetClipboardText(json_website);
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if(ImGui::Button("Open in browser")) {
|
|
||||||
openUri(json_website);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::TextUnformatted("Licence: MIT");
|
|
||||||
|
|
||||||
static auto json_licence = _rs.getRaw("LICENSE.json");
|
|
||||||
if(ImGui::BeginChild("##jsonLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
|
|
||||||
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
|
|
||||||
ImGui::TextUnformatted(json_licence);
|
|
||||||
ImGui::PopFont();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ImGui::TreeNodeEx("Font Awesome", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
if(ImGui::TreeNodeEx("Font Awesome", ImGuiTreeNodeFlags_SpanAvailWidth)) {
|
||||||
ImGui::TextUnformatted("Version used: 5.15.3");
|
ImGui::TextUnformatted("Version used: 5.15.3");
|
||||||
auto fa_website = "https://fontawesome.com/";
|
auto fa_website = "https://fontawesome.com/";
|
||||||
|
|
|
@ -47,7 +47,3 @@ alias=LICENSE.efsw
|
||||||
[file]
|
[file]
|
||||||
filename=../third-party/cpr/LICENSE
|
filename=../third-party/cpr/LICENSE
|
||||||
alias=LICENSE.cpr
|
alias=LICENSE.cpr
|
||||||
|
|
||||||
[file]
|
|
||||||
filename=../third-party/json/LICENSE.MIT
|
|
||||||
alias=LICENSE.json
|
|
||||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -25,7 +25,20 @@
|
||||||
#include <winerror.h>
|
#include <winerror.h>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
void* mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");
|
#ifndef SAVETOOL_DEBUG_BUILD
|
||||||
|
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
|
||||||
|
|
||||||
|
Utility::Debug d{&output};
|
||||||
|
Utility::Warning w{&output};
|
||||||
|
Utility::Error e{&output};
|
||||||
|
#else
|
||||||
|
Utility::Warning w{Utility::Debug::defaultOutput()};
|
||||||
|
Utility::Error e{Utility::Debug::defaultOutput()};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Utility::Debug{} << "===M.A.S.S. Builder Save Tool version " SAVETOOL_VERSION "===";
|
||||||
|
|
||||||
|
auto mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");
|
||||||
|
|
||||||
if(!mutex_handle) {
|
if(!mutex_handle) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
||||||
|
@ -39,14 +52,7 @@ int main(int argc, char** argv) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
Utility::Debug{} << "===Initialising OpenGL renderer===";
|
||||||
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
|
|
||||||
|
|
||||||
Utility::Debug d{&output};
|
|
||||||
Utility::Warning w{&output};
|
|
||||||
Utility::Error e{&output};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SaveTool app({argc, argv});
|
SaveTool app({argc, argv});
|
||||||
Int result = app.exec();
|
Int result = app.exec();
|
||||||
|
|
||||||
|
|
1
third-party/json
vendored
1
third-party/json
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit 626e7d61e44dee32887126c8f437dd077dec09cf
|
|
Loading…
Reference in a new issue