Compare commits
2 commits
d0716d6242
...
22c9627b84
Author | SHA1 | Date | |
---|---|---|---|
22c9627b84 | |||
e99ff14749 |
5 changed files with 70 additions and 25 deletions
|
@ -145,6 +145,7 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
SaveTool::~SaveTool() {
|
SaveTool::~SaveTool() {
|
||||||
SDL_RemoveTimer(_gameCheckTimerId);
|
SDL_RemoveTimer(_gameCheckTimerId);
|
||||||
|
|
||||||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||||||
_conf.setValue("unsafe_mode", _unsafeMode);
|
_conf.setValue("unsafe_mode", _unsafeMode);
|
||||||
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||||||
_conf.save();
|
_conf.save();
|
||||||
|
@ -357,6 +358,13 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseConfiguration() {
|
void SaveTool::initialiseConfiguration() {
|
||||||
|
if(_conf.hasValue("cheat_mode")) {
|
||||||
|
_cheatMode = _conf.value<bool>("cheat_mode");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||||||
|
}
|
||||||
|
|
||||||
if(_conf.hasValue("unsafe_mode")) {
|
if(_conf.hasValue("unsafe_mode")) {
|
||||||
_unsafeMode = _conf.value<bool>("unsafe_mode");
|
_unsafeMode = _conf.value<bool>("unsafe_mode");
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,4 +204,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
std::string _latestVersion;
|
std::string _latestVersion;
|
||||||
std::string _releaseLink;
|
std::string _releaseLink;
|
||||||
std::string _downloadLink;
|
std::string _downloadLink;
|
||||||
|
|
||||||
|
bool _cheatMode{false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -231,6 +231,10 @@ void SaveTool::drawGeneralInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!_cheatMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
static Int credits;
|
static Int credits;
|
||||||
|
@ -295,30 +299,32 @@ void SaveTool::drawResearchInventory() {
|
||||||
ImGui::TableSetColumnIndex(1); \
|
ImGui::TableSetColumnIndex(1); \
|
||||||
ImGui::TextDisabled("Unavailable as of M.A.S.S. Builder version " SUPPORTED_GAME_VERSION);
|
ImGui::TextDisabled("Unavailable as of M.A.S.S. Builder version " SUPPORTED_GAME_VERSION);
|
||||||
|
|
||||||
#define matRow(name, var, getter, setter) \
|
#define matRow(name, var, getter, setter) \
|
||||||
ImGui::TableNextRow(); \
|
ImGui::TableNextRow(); \
|
||||||
ImGui::TableSetColumnIndex(0); \
|
ImGui::TableSetColumnIndex(0); \
|
||||||
ImGui::TextUnformatted((name)); \
|
ImGui::TextUnformatted((name)); \
|
||||||
ImGui::TableSetColumnIndex(1); \
|
ImGui::TableSetColumnIndex(1); \
|
||||||
if(_currentProfile->getter() != -1) { \
|
if(_currentProfile->getter() != -1) { \
|
||||||
drawUnsafeText("%i", _currentProfile->getter()); \
|
ImGui::Text("%i", _currentProfile->getter()); \
|
||||||
ImGui::TableSetColumnIndex(2); \
|
if(_cheatMode) { \
|
||||||
ImGui::PushID(#setter); \
|
ImGui::TableSetColumnIndex(2); \
|
||||||
static Int var = _currentProfile->getter(); \
|
ImGui::PushID(#setter); \
|
||||||
if(drawUnsafeWidget([]{ return ImGui::SmallButton(ICON_FA_EDIT); })) { \
|
static Int var = _currentProfile->getter(); \
|
||||||
(var) = _currentProfile->getter(); \
|
if(drawUnsafeWidget([]{ return ImGui::SmallButton(ICON_FA_EDIT); })) { \
|
||||||
ImGui::OpenPopup("int_edit"); \
|
(var) = _currentProfile->getter(); \
|
||||||
} \
|
ImGui::OpenPopup("int_edit"); \
|
||||||
if(drawIntEditPopup(&(var), 9999)) { \
|
} \
|
||||||
if(!_currentProfile->set##setter((var))) { \
|
if(drawIntEditPopup(&(var), 9999)) { \
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", \
|
if(!_currentProfile->set##setter((var))) { \
|
||||||
_currentProfile->lastError().c_str(), window()); \
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", \
|
||||||
} \
|
_currentProfile->lastError().c_str(), window()); \
|
||||||
} \
|
} \
|
||||||
ImGui::PopID(); \
|
} \
|
||||||
} \
|
ImGui::PopID(); \
|
||||||
else { \
|
} \
|
||||||
ImGui::TextDisabled("Not found in the save file"); \
|
} \
|
||||||
|
else { \
|
||||||
|
ImGui::TextDisabled("Not found in the save file"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::BeginTable("##ResearchInventoryTable", 3,
|
if(ImGui::BeginTable("##ResearchInventoryTable", 3,
|
||||||
|
|
|
@ -55,8 +55,15 @@ void SaveTool::drawMainMenu() {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
||||||
|
ImGui::Checkbox("Cheat mode", &_cheatMode);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
|
drawHelpMarker("This gives access to save edition features that can be considered cheats.",
|
||||||
|
Float(windowSize().x()) * 0.4f);
|
||||||
|
|
||||||
ImGui::Checkbox("Unsafe mode", &_unsafeMode);
|
ImGui::Checkbox("Unsafe mode", &_unsafeMode);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
drawHelpMarker("This allows changing the state of save files in the game's save folder even when the game is running.",
|
drawHelpMarker("This allows changing the state of save files in the game's save folder even when the game is running.",
|
||||||
Float(windowSize().x()) * 0.4f);
|
Float(windowSize().x()) * 0.4f);
|
||||||
|
|
||||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -18,7 +18,25 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <errhandlingapi.h>
|
||||||
|
#include <synchapi.h>
|
||||||
|
#include <winerror.h>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
void* mutex_handle = CreateMutexW(nullptr, 0, L"MassBuilderSaveTool");
|
||||||
|
|
||||||
|
if(!mutex_handle) {
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
||||||
|
"There was an error initialising the mutex.",nullptr);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app",
|
||||||
|
"There can be only one running instance of the application.",nullptr);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
#ifndef SAVETOOL_DEBUG_BUILD
|
||||||
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
|
std::ofstream output{"SaveToolLog.txt", std::ios::trunc|std::ios::out};
|
||||||
|
|
||||||
|
@ -28,5 +46,9 @@ int main(int argc, char** argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SaveTool app({argc, argv});
|
SaveTool app({argc, argv});
|
||||||
return app.exec();
|
Int result = app.exec();
|
||||||
|
|
||||||
|
ReleaseMutex(mutex_handle);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue