From 6dccdfe0c1c39d30eafece244fbb023f9d4b636c Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 28 Aug 2019 06:37:33 +0300 Subject: [PATCH] [Client] Load up TES3MP's settings in the same map as OpenMW's settings This allows the "font size" property to be read when the chat window is created. --- apps/openmw/mwmp/GUIController.cpp | 16 +++++++-------- apps/openmw/mwmp/GUIController.hpp | 2 +- apps/openmw/mwmp/Main.cpp | 32 +++--------------------------- 3 files changed, 12 insertions(+), 38 deletions(-) diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index 574303b06..5eb51961e 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -64,18 +64,18 @@ void mwmp::GUIController::refreshGuiMode(MWGui::GuiMode guiMode) } } -void mwmp::GUIController::setupChat(const Settings::Manager &mgr) +void mwmp::GUIController::setupChat() { assert(mChat == nullptr); - float chatDelay = mgr.getFloat("delay", "Chat"); - int chatY = mgr.getInt("y", "Chat"); - int chatX = mgr.getInt("x", "Chat"); - int chatW = mgr.getInt("w", "Chat"); - int chatH = mgr.getInt("h", "Chat"); + float chatDelay = Settings::Manager::getFloat("delay", "Chat"); + int chatY = Settings::Manager::getInt("y", "Chat"); + int chatX = Settings::Manager::getInt("x", "Chat"); + int chatW = Settings::Manager::getInt("w", "Chat"); + int chatH = Settings::Manager::getInt("h", "Chat"); - keySay = SDL_GetScancodeFromName(mgr.getString("keySay", "Chat").c_str()); - keyChatMode = SDL_GetScancodeFromName(mgr.getString("keyChatMode", "Chat").c_str()); + keySay = SDL_GetScancodeFromName(Settings::Manager::getString("keySay", "Chat").c_str()); + keyChatMode = SDL_GetScancodeFromName(Settings::Manager::getString("keyChatMode", "Chat").c_str()); mChat = new GUIChat(chatX, chatY, chatW, chatH); mChat->setDelay(chatDelay); diff --git a/apps/openmw/mwmp/GUIController.hpp b/apps/openmw/mwmp/GUIController.hpp index f55e017f3..9b1412b88 100644 --- a/apps/openmw/mwmp/GUIController.hpp +++ b/apps/openmw/mwmp/GUIController.hpp @@ -34,7 +34,7 @@ namespace mwmp void refreshGuiMode(MWGui::GuiMode guiMode); - void setupChat(const Settings::Manager &manager); + void setupChat(); void printChatMessage(std::string &msg); void setChatVisible(bool chatVisible); diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index 90b9e0685..b5d8aab5e 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -118,35 +118,13 @@ void Main::configure(const boost::program_options::variables_map &variables) resourceDir = variables["resources"].as().toStdString(); } -static Settings::CategorySettingValueMap saveUserSettings; -static Settings::CategorySettingValueMap saveDefaultSettings; -static Settings::CategorySettingVector saveChangedSettings; - -void initializeManager(Settings::Manager &manager) -{ - saveUserSettings = manager.mUserSettings; - saveDefaultSettings = manager.mDefaultSettings; - saveChangedSettings = manager.mChangedSettings; - manager.mUserSettings.clear(); - manager.mDefaultSettings.clear(); - manager.mChangedSettings.clear(); - loadSettings(manager); -} - -void restoreManager(Settings::Manager &manager) -{ - manager.mUserSettings = saveUserSettings; - manager.mDefaultSettings = saveDefaultSettings; - manager.mChangedSettings = saveChangedSettings; -} - bool Main::init(std::vector &content, Files::Collections &collections) { assert(!pMain); pMain = new Main(); Settings::Manager manager; - initializeManager(manager); + loadSettings(manager); int logLevel = manager.getInt("logLevel", "General"); TimedLog::SetLevel(logLevel); @@ -168,17 +146,13 @@ bool Main::init(std::vector &content, Files::Collections &collectio get().mLocalPlayer->serverPassword = serverPassword; pMain->mNetworking->connect(pMain->server, pMain->port, content, collections); - restoreManager(manager); + return pMain->mNetworking->isConnected(); } void Main::postInit() { - Settings::Manager manager; - initializeManager(manager); - - pMain->mGUIController->setupChat(manager); - restoreManager(manager); + pMain->mGUIController->setupChat(); const MWBase::Environment &environment = MWBase::Environment::get(); environment.getStateManager()->newGame(true);