mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-21 23:58:51 -05:00
Config versioning to fix the Fullscreen Shortcut debacle (#2966)
* WIP adding new config version. * Implements a ConfigVersionUpdater * Updates to account for new LUS-side changes. * Change `ConfigVersionUpdater` to store `toVersion` * fix typo
This commit is contained in:
parent
eba0b4c146
commit
430d5cddf2
@ -131,6 +131,13 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
set_source_files_properties(soh/OTRGlobals.cpp PROPERTIES COMPILE_FLAGS "/utf-8")
|
||||
endif()
|
||||
|
||||
# soh/config {{{
|
||||
file(GLOB_RECURSE soh__config RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"soh/config/*.h"
|
||||
"soh/config/*.cpp"
|
||||
)
|
||||
# }}}
|
||||
|
||||
# soh/enhancements {{{
|
||||
file(GLOB_RECURSE soh__Enhancements RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"soh/Enhancements/*.c"
|
||||
@ -246,6 +253,7 @@ set(ALL_FILES
|
||||
${Header_Files}
|
||||
${Header_Files__include}
|
||||
${soh__}
|
||||
${soh__config}
|
||||
${soh__Enhancements}
|
||||
${soh__Extractor}
|
||||
${soh__Resource}
|
||||
|
@ -110,6 +110,8 @@ CrowdControl* CrowdControl::Instance;
|
||||
#include "soh/resource/importer/TextFactory.h"
|
||||
#include "soh/resource/importer/BackgroundFactory.h"
|
||||
|
||||
#include "soh/config/ConfigUpdaters.h"
|
||||
|
||||
OTRGlobals* OTRGlobals::Instance;
|
||||
SaveManager* SaveManager::Instance;
|
||||
CustomMessageManager* CustomMessageManager::Instance;
|
||||
@ -789,6 +791,10 @@ extern "C" void InitOTR() {
|
||||
CrowdControl::Instance->Disable();
|
||||
}
|
||||
#endif
|
||||
|
||||
std::shared_ptr<LUS::Config> conf = OTRGlobals::Instance->context->GetConfig();
|
||||
conf->RegisterConfigVersionUpdater(std::make_shared<LUS::ConfigVersion1Updater>());
|
||||
conf->RunVersionUpdates();
|
||||
}
|
||||
|
||||
extern "C" void SaveManager_ThreadPoolWait() {
|
||||
|
53
soh/soh/config/ConfigUpdaters.cpp
Normal file
53
soh/soh/config/ConfigUpdaters.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "ConfigUpdaters.h"
|
||||
|
||||
namespace LUS {
|
||||
ConfigVersion1Updater::ConfigVersion1Updater() : ConfigVersionUpdater(1) {}
|
||||
|
||||
void ConfigVersion1Updater::Update(Config* conf) {
|
||||
if (conf->GetInt("Window.Width", 640) == 640) {
|
||||
conf->Erase("Window.Width");
|
||||
}
|
||||
if (conf->GetInt("Window.Height", 480) == 480) {
|
||||
conf->Erase("Window.Height");
|
||||
}
|
||||
if (conf->GetInt("Window.PositionX", 100) == 100) {
|
||||
conf->Erase("Window.PositionX");
|
||||
}
|
||||
if (conf->GetInt("Window.PositionY", 100) == 100) {
|
||||
conf->Erase("Window.PositionY");
|
||||
}
|
||||
if (conf->GetString("Window.GfxBackend", "") == "") {
|
||||
conf->Erase("Window.GfxBackend");
|
||||
}
|
||||
if (conf->GetString("Window.GfxApi", "") == "") {
|
||||
conf->Erase("Window.GfxApi");
|
||||
}
|
||||
if (conf->GetString("Window.AudioBackend", "") == "") {
|
||||
conf->Erase("Window.AudioBackend");
|
||||
}
|
||||
if (conf->GetBool("Window.Fullscreen.Enabled", false) == false) {
|
||||
conf->Erase("Window.Fullscreen.Enabled");
|
||||
}
|
||||
if (conf->GetInt("Window.Fullscreen.Width", 1920) == 1920) {
|
||||
conf->Erase("Window.Fullscreen.Width");
|
||||
}
|
||||
if (conf->GetInt("Window.Fullscreen.Height", 1080) == 1080) {
|
||||
conf->Erase("Window.Fullscreen.Height");
|
||||
}
|
||||
if (conf->GetInt("Shortcuts.Fullscreen", KbScancode::LUS_KB_F11) == KbScancode::LUS_KB_F10) {
|
||||
conf->Erase("Shortcuts.Fullscreen");
|
||||
}
|
||||
if (conf->GetInt("Shortcuts.Console", KbScancode::LUS_KB_OEM_3) == KbScancode::LUS_KB_OEM_3) {
|
||||
conf->Erase("Shortcuts.Console");
|
||||
}
|
||||
if (conf->GetString("Game.SaveName", "") == "") {
|
||||
conf->Erase("Game.SaveName");
|
||||
}
|
||||
if (conf->GetString("Game.Main Archive", "") == "") {
|
||||
conf->Erase("Game.Main Archive");
|
||||
}
|
||||
if (conf->GetString("Game.Patches Archive", "") == "") {
|
||||
conf->Erase("Game.Patches Archive");
|
||||
}
|
||||
}
|
||||
}
|
9
soh/soh/config/ConfigUpdaters.h
Normal file
9
soh/soh/config/ConfigUpdaters.h
Normal file
@ -0,0 +1,9 @@
|
||||
#include "libultraship/libultraship.h"
|
||||
|
||||
namespace LUS {
|
||||
class ConfigVersion1Updater : public ConfigVersionUpdater {
|
||||
public:
|
||||
ConfigVersion1Updater();
|
||||
void Update(Config* conf);
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user