mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Merge pull request #5418 from MerryMage/config-again-and-again
VideoConfig: Port to layered configuration system
This commit is contained in:
@ -91,6 +91,9 @@ void Save()
|
||||
|
||||
void Init()
|
||||
{
|
||||
// These layers contain temporary values
|
||||
s_layers[LayerType::CommandLine] = std::make_unique<Layer>(LayerType::CommandLine);
|
||||
ClearCurrentRunLayer();
|
||||
// This layer always has to exist
|
||||
s_layers[LayerType::Meta] = std::make_unique<RecursiveLayer>();
|
||||
}
|
||||
@ -101,6 +104,11 @@ void Shutdown()
|
||||
s_callbacks.clear();
|
||||
}
|
||||
|
||||
void ClearCurrentRunLayer()
|
||||
{
|
||||
s_layers[LayerType::CurrentRun] = std::make_unique<Layer>(LayerType::CurrentRun);
|
||||
}
|
||||
|
||||
static const std::map<System, std::string> system_to_name = {
|
||||
{System::Main, "Dolphin"}, {System::GCPad, "GCPad"}, {System::WiiPad, "Wiimote"},
|
||||
{System::GCKeyboard, "GCKeyboard"}, {System::GFX, "Graphics"}, {System::Logger, "Logger"},
|
||||
|
@ -38,24 +38,9 @@ void InvokeConfigChangedCallbacks();
|
||||
void Load();
|
||||
void Save();
|
||||
|
||||
// Often used functions for getting or setting configuration on the base layer for the main system
|
||||
template <typename T>
|
||||
T Get(const std::string& section_name, const std::string& key, const T& default_value)
|
||||
{
|
||||
auto base_layer = GetLayer(Config::LayerType::Base);
|
||||
return base_layer->GetOrCreateSection(Config::System::Main, section_name)
|
||||
->Get(key, default_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Set(const std::string& section_name, const std::string& key, const T& value)
|
||||
{
|
||||
auto base_layer = GetLayer(Config::LayerType::Base);
|
||||
base_layer->GetOrCreateSection(Config::System::Main, section_name)->Set(key, value);
|
||||
}
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
void ClearCurrentRunLayer();
|
||||
|
||||
const std::string& GetSystemName(System system);
|
||||
System GetSystemFromName(const std::string& system);
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
enum class LayerType
|
||||
@ -29,4 +31,10 @@ enum class System
|
||||
Debugger,
|
||||
UI,
|
||||
};
|
||||
|
||||
constexpr std::array<LayerType, 7> SEARCH_ORDER{{
|
||||
// Skip the meta layer
|
||||
LayerType::CurrentRun, LayerType::CommandLine, LayerType::Movie, LayerType::Netplay,
|
||||
LayerType::LocalGame, LayerType::GlobalGame, LayerType::Base,
|
||||
}};
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -254,13 +253,7 @@ bool RecursiveSection::Exists(const std::string& key) const
|
||||
bool RecursiveSection::Get(const std::string& key, std::string* value,
|
||||
const std::string& default_value) const
|
||||
{
|
||||
static constexpr std::array<LayerType, 7> search_order = {{
|
||||
// Skip the meta layer
|
||||
LayerType::CurrentRun, LayerType::CommandLine, LayerType::Movie, LayerType::Netplay,
|
||||
LayerType::LocalGame, LayerType::GlobalGame, LayerType::Base,
|
||||
}};
|
||||
|
||||
for (auto layer_id : search_order)
|
||||
for (auto layer_id : SEARCH_ORDER)
|
||||
{
|
||||
auto layers_it = Config::GetLayers()->find(layer_id);
|
||||
if (layers_it == Config::GetLayers()->end())
|
||||
|
Reference in New Issue
Block a user