mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
DolphinQt: Allow ConfigComplexChoice to handle DefaultState values.
This commit is contained in:
@ -131,17 +131,28 @@ void ConfigComplexChoice::SaveValue(int choice)
|
|||||||
|
|
||||||
void ConfigComplexChoice::UpdateComboIndex()
|
void ConfigComplexChoice::UpdateComboIndex()
|
||||||
{
|
{
|
||||||
auto Get = [this](auto& setting) {
|
auto get_layer_value = [this](auto& setting) {
|
||||||
if (m_layer != nullptr)
|
if (m_layer != nullptr)
|
||||||
return static_cast<OptionVariant>(m_layer->Get(setting));
|
return static_cast<OptionVariant>(m_layer->Get(setting));
|
||||||
|
|
||||||
return static_cast<OptionVariant>(Config::Get(setting));
|
return static_cast<OptionVariant>(Config::Get(setting));
|
||||||
};
|
};
|
||||||
|
|
||||||
std::pair<OptionVariant, OptionVariant> values =
|
auto get_default_value = [](auto& setting) { return OptionVariant(setting.GetDefaultValue()); };
|
||||||
std::make_pair(std::visit(Get, m_setting1), std::visit(Get, m_setting2));
|
|
||||||
|
|
||||||
auto it = std::find(m_options.begin(), m_options.end(), values);
|
auto is_current_value = [&](const InfoVariant& info, const OptionVariant& option) {
|
||||||
|
return std::visit(get_layer_value, info) ==
|
||||||
|
(std::holds_alternative<Config::DefaultState>(option) ?
|
||||||
|
std::visit(get_default_value, info) :
|
||||||
|
option);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto is_correct_option = [&](const std::pair<OptionVariant, OptionVariant>& option) {
|
||||||
|
return is_current_value(m_setting1, option.first) &&
|
||||||
|
is_current_value(m_setting2, option.second);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto it = std::find_if(m_options.begin(), m_options.end(), is_correct_option);
|
||||||
int index = static_cast<int>(std::distance(m_options.begin(), it));
|
int index = static_cast<int>(std::distance(m_options.begin(), it));
|
||||||
|
|
||||||
// Will crash if not blocked
|
// Will crash if not blocked
|
||||||
|
@ -53,7 +53,7 @@ class ConfigComplexChoice final : public ToolTipComboBox
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
using InfoVariant = std::variant<Config::Info<u32>, Config::Info<int>, Config::Info<bool>>;
|
using InfoVariant = std::variant<Config::Info<u32>, Config::Info<int>, Config::Info<bool>>;
|
||||||
using OptionVariant = std::variant<u32, int, bool>;
|
using OptionVariant = std::variant<Config::DefaultState, u32, int, bool>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
|
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
|
||||||
|
Reference in New Issue
Block a user