mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Merge branch 'settings_reload' into 'master'
Support reload for settings values See merge request OpenMW/openmw!3543
This commit is contained in:
commit
8a8d77a444
@ -145,6 +145,8 @@ namespace Settings
|
||||
|
||||
void Manager::clear()
|
||||
{
|
||||
sInitialized.clear();
|
||||
StaticValues::clear();
|
||||
mDefaultSettings.clear();
|
||||
mUserSettings.clear();
|
||||
mChangedSettings.clear();
|
||||
|
@ -4,24 +4,29 @@
|
||||
|
||||
namespace Settings
|
||||
{
|
||||
Index* StaticValues::sIndex = nullptr;
|
||||
Values* StaticValues::sValues = nullptr;
|
||||
std::unique_ptr<Index> StaticValues::sIndex;
|
||||
std::unique_ptr<Values> StaticValues::sDefaultValues;
|
||||
std::unique_ptr<Values> StaticValues::sValues;
|
||||
|
||||
void StaticValues::initDefaults()
|
||||
{
|
||||
if (sValues != nullptr)
|
||||
throw std::logic_error("Default settings already initialized");
|
||||
static Index index;
|
||||
static Values values(index);
|
||||
sIndex = &index;
|
||||
sValues = &values;
|
||||
if (sDefaultValues != nullptr)
|
||||
throw std::logic_error("Default settings are already initialized");
|
||||
sIndex = std::make_unique<Index>();
|
||||
sDefaultValues = std::make_unique<Values>(*sIndex);
|
||||
}
|
||||
|
||||
void StaticValues::init()
|
||||
{
|
||||
if (sValues == nullptr)
|
||||
if (sDefaultValues == nullptr)
|
||||
throw std::logic_error("Default settings are not initialized");
|
||||
static Values values(std::move(*sValues));
|
||||
sValues = &values;
|
||||
sValues = std::make_unique<Values>(std::move(*sDefaultValues));
|
||||
}
|
||||
|
||||
void StaticValues::clear()
|
||||
{
|
||||
sValues = nullptr;
|
||||
sDefaultValues = nullptr;
|
||||
sIndex = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "settingvalue.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace Settings
|
||||
@ -71,9 +72,12 @@ namespace Settings
|
||||
|
||||
static void init();
|
||||
|
||||
static void clear();
|
||||
|
||||
private:
|
||||
static Index* sIndex;
|
||||
static Values* sValues;
|
||||
static std::unique_ptr<Index> sIndex;
|
||||
static std::unique_ptr<Values> sDefaultValues;
|
||||
static std::unique_ptr<Values> sValues;
|
||||
|
||||
friend Values& values();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user