1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

[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.
This commit is contained in:
David Cernat 2019-08-28 06:37:33 +03:00
parent 9b1fbcc6f9
commit 6dccdfe0c1
3 changed files with 12 additions and 38 deletions

View file

@ -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); assert(mChat == nullptr);
float chatDelay = mgr.getFloat("delay", "Chat"); float chatDelay = Settings::Manager::getFloat("delay", "Chat");
int chatY = mgr.getInt("y", "Chat"); int chatY = Settings::Manager::getInt("y", "Chat");
int chatX = mgr.getInt("x", "Chat"); int chatX = Settings::Manager::getInt("x", "Chat");
int chatW = mgr.getInt("w", "Chat"); int chatW = Settings::Manager::getInt("w", "Chat");
int chatH = mgr.getInt("h", "Chat"); int chatH = Settings::Manager::getInt("h", "Chat");
keySay = SDL_GetScancodeFromName(mgr.getString("keySay", "Chat").c_str()); keySay = SDL_GetScancodeFromName(Settings::Manager::getString("keySay", "Chat").c_str());
keyChatMode = SDL_GetScancodeFromName(mgr.getString("keyChatMode", "Chat").c_str()); keyChatMode = SDL_GetScancodeFromName(Settings::Manager::getString("keyChatMode", "Chat").c_str());
mChat = new GUIChat(chatX, chatY, chatW, chatH); mChat = new GUIChat(chatX, chatY, chatW, chatH);
mChat->setDelay(chatDelay); mChat->setDelay(chatDelay);

View file

@ -34,7 +34,7 @@ namespace mwmp
void refreshGuiMode(MWGui::GuiMode guiMode); void refreshGuiMode(MWGui::GuiMode guiMode);
void setupChat(const Settings::Manager &manager); void setupChat();
void printChatMessage(std::string &msg); void printChatMessage(std::string &msg);
void setChatVisible(bool chatVisible); void setChatVisible(bool chatVisible);

View file

@ -118,35 +118,13 @@ void Main::configure(const boost::program_options::variables_map &variables)
resourceDir = variables["resources"].as<Files::EscapeHashString>().toStdString(); resourceDir = variables["resources"].as<Files::EscapeHashString>().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<std::string> &content, Files::Collections &collections) bool Main::init(std::vector<std::string> &content, Files::Collections &collections)
{ {
assert(!pMain); assert(!pMain);
pMain = new Main(); pMain = new Main();
Settings::Manager manager; Settings::Manager manager;
initializeManager(manager); loadSettings(manager);
int logLevel = manager.getInt("logLevel", "General"); int logLevel = manager.getInt("logLevel", "General");
TimedLog::SetLevel(logLevel); TimedLog::SetLevel(logLevel);
@ -168,17 +146,13 @@ bool Main::init(std::vector<std::string> &content, Files::Collections &collectio
get().mLocalPlayer->serverPassword = serverPassword; get().mLocalPlayer->serverPassword = serverPassword;
pMain->mNetworking->connect(pMain->server, pMain->port, content, collections); pMain->mNetworking->connect(pMain->server, pMain->port, content, collections);
restoreManager(manager);
return pMain->mNetworking->isConnected(); return pMain->mNetworking->isConnected();
} }
void Main::postInit() void Main::postInit()
{ {
Settings::Manager manager; pMain->mGUIController->setupChat();
initializeManager(manager);
pMain->mGUIController->setupChat(manager);
restoreManager(manager);
const MWBase::Environment &environment = MWBase::Environment::get(); const MWBase::Environment &environment = MWBase::Environment::get();
environment.getStateManager()->newGame(true); environment.getStateManager()->newGame(true);