mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-14 15:51:29 +02:00
DolphinQt: Allow ConfigComplexChoice to handle DefaultState values.
This commit is contained in:
parent
ba1bf6959e
commit
4b711e1e0a
@ -131,17 +131,28 @@ void ConfigComplexChoice::SaveValue(int choice)
|
||||
|
||||
void ConfigComplexChoice::UpdateComboIndex()
|
||||
{
|
||||
auto Get = [this](auto& setting) {
|
||||
auto get_layer_value = [this](auto& setting) {
|
||||
if (m_layer != nullptr)
|
||||
return static_cast<OptionVariant>(m_layer->Get(setting));
|
||||
|
||||
return static_cast<OptionVariant>(Config::Get(setting));
|
||||
};
|
||||
|
||||
std::pair<OptionVariant, OptionVariant> values =
|
||||
std::make_pair(std::visit(Get, m_setting1), std::visit(Get, m_setting2));
|
||||
auto get_default_value = [](auto& setting) { return OptionVariant(setting.GetDefaultValue()); };
|
||||
|
||||
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));
|
||||
|
||||
// Will crash if not blocked
|
||||
|
@ -53,7 +53,7 @@ class ConfigComplexChoice final : public ToolTipComboBox
|
||||
Q_OBJECT
|
||||
|
||||
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:
|
||||
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
|
||||
|
Loading…
x
Reference in New Issue
Block a user