SaveTool: add configuration system.
This commit is contained in:
parent
83002868d9
commit
445d7323b3
4 changed files with 49 additions and 26 deletions
|
@ -131,10 +131,16 @@ SaveTool::SaveTool(const Arguments& arguments):
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialiseConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveTool::~SaveTool() {
|
SaveTool::~SaveTool() {
|
||||||
SDL_RemoveTimer(_gameCheckTimerId);
|
SDL_RemoveTimer(_gameCheckTimerId);
|
||||||
|
|
||||||
|
_conf.setValue("unsafe_mode", _unsafeMode);
|
||||||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||||||
|
_conf.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
||||||
|
@ -283,6 +289,24 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveTool::initialiseConfiguration() {
|
||||||
|
if(_conf.hasValue("unsafe_mode")) {
|
||||||
|
_unsafeMode = _conf.value<bool>("unsafe_mode");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("unsafe_mode", _unsafeMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_conf.hasValue("startup_update_check")) {
|
||||||
|
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||||||
|
}
|
||||||
|
|
||||||
|
_conf.save();
|
||||||
|
}
|
||||||
|
|
||||||
void SaveTool::initialiseGui() {
|
void SaveTool::initialiseGui() {
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <Corrade/Containers/Pointer.h>
|
#include <Corrade/Containers/Pointer.h>
|
||||||
|
#include <Corrade/Utility/Configuration.h>
|
||||||
#include <Corrade/Utility/Resource.h>
|
#include <Corrade/Utility/Resource.h>
|
||||||
|
|
||||||
#include <Magnum/Platform/Sdl2Application.h>
|
#include <Magnum/Platform/Sdl2Application.h>
|
||||||
|
@ -73,6 +74,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
void updateCheckEvent(SDL_Event& event);
|
void updateCheckEvent(SDL_Event& event);
|
||||||
|
|
||||||
// Initialisation methods
|
// Initialisation methods
|
||||||
|
void initialiseConfiguration();
|
||||||
void initialiseGui();
|
void initialiseGui();
|
||||||
void initialiseManager();
|
void initialiseManager();
|
||||||
auto findGameDataDirectory() -> bool;
|
auto findGameDataDirectory() -> bool;
|
||||||
|
@ -139,6 +141,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
|
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
|
|
||||||
|
Utility::Configuration _conf{"MassBuilderSaveTool.ini"};
|
||||||
Utility::Resource _rs{"assets"};
|
Utility::Resource _rs{"assets"};
|
||||||
|
|
||||||
// GUI-related members
|
// GUI-related members
|
||||||
|
@ -191,5 +194,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
};
|
};
|
||||||
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
Containers::StaticArray<2, efsw::WatchID> _watchIDs;
|
||||||
|
|
||||||
|
bool _checkUpdatesOnStartup{true};
|
||||||
bool _unsafeMode{false};
|
bool _unsafeMode{false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,30 +42,16 @@ void SaveTool::drawManager() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::BeginTable("##TopRow", 2)) {
|
ImGui::AlignTextToFramePadding();
|
||||||
ImGui::TableSetupColumn("##ProfileInfo", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::Text("Current profile: %s (%s)",
|
||||||
ImGui::TableSetupColumn("##Unsafe", ImGuiTableColumnFlags_WidthFixed);
|
_currentProfile->companyName().c_str(),
|
||||||
|
_currentProfile->type() == ProfileType::Demo ? "demo" : "full game");
|
||||||
ImGui::TableNextRow();
|
ImGui::SameLine();
|
||||||
ImGui::TableSetColumnIndex(0);
|
if(ImGui::Button("Close")) {
|
||||||
ImGui::AlignTextToFramePadding();
|
_currentProfile = nullptr;
|
||||||
ImGui::Text("Current profile: %s (%s)",
|
_massManager.reset();
|
||||||
_currentProfile->companyName().c_str(),
|
_fileWatcher.reset();
|
||||||
_currentProfile->type() == ProfileType::Demo ? "demo" : "full game");
|
_uiState = UiState::ProfileManager;
|
||||||
ImGui::SameLine();
|
|
||||||
if(ImGui::Button("Close")) {
|
|
||||||
_currentProfile = nullptr;
|
|
||||||
_massManager.reset();
|
|
||||||
_fileWatcher.reset();
|
|
||||||
_uiState = UiState::ProfileManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::TableSetColumnIndex(1);
|
|
||||||
ImGui::Checkbox("Unsafe mode", &_unsafeMode);
|
|
||||||
drawTooltip("Enabling this allows interactions deemed to be unsafe to do while the game is running.",
|
|
||||||
Float(windowSize().x()) * 0.35f);
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImGui::BeginChild("##ProfileInfo",
|
if(ImGui::BeginChild("##ProfileInfo",
|
||||||
|
|
|
@ -54,8 +54,17 @@ void SaveTool::drawMainMenu() {
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if(ImGui::MenuItem(ICON_FA_SYNC_ALT " Check for updates", nullptr, false, false)) {
|
if(ImGui::BeginMenu(ICON_FA_COG " Settings")) {
|
||||||
// TODO: implement
|
ImGui::Checkbox("Unsafe mode", &_unsafeMode);
|
||||||
|
ImGui::SameLine();
|
||||||
|
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);
|
||||||
|
|
||||||
|
ImGui::Checkbox("Check for updates on startup", &_checkUpdatesOnStartup);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Button(ICON_FA_SYNC_ALT " Check now");
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
Loading…
Reference in a new issue