PostProcessing: Use ints-for-bools CPU-side as well

This commit is contained in:
Connor McLaughlin 2020-09-16 11:51:42 +10:00
parent 3bd9f85af8
commit 3096f0953f
3 changed files with 6 additions and 7 deletions

View file

@ -27,14 +27,14 @@ void PostProcessingShaderConfigWidget::createUi()
if (option.type == PostProcessingShader::Option::Type::Bool)
{
QCheckBox* checkbox = new QCheckBox(QString::fromStdString(option.ui_name), this);
checkbox->setChecked(option.value[0].bool_value);
checkbox->setChecked(option.value[0].int_value != 0);
connect(checkbox, &QCheckBox::stateChanged, [this, &option](int state) {
option.value[0].bool_value = (state == Qt::Checked);
option.value[0].int_value = (state == Qt::Checked) ? 1 : 0;
configChanged();
});
connect(this, &PostProcessingShaderConfigWidget::resettingtoDefaults, [&option, checkbox]() {
QSignalBlocker sb(checkbox);
checkbox->setChecked(option.default_value[0].bool_value);
checkbox->setChecked(option.default_value[0].int_value != 0);
option.value = option.default_value;
});
m_layout->addWidget(checkbox, row, 0, 1, 3, Qt::AlignLeft);

View file

@ -166,7 +166,7 @@ std::string PostProcessingShader::GetConfigString() const
switch (option.type)
{
case Option::Type::Bool:
ss << option.value[i].bool_value ? "true" : "false";
ss << (option.value[i].int_value != 0) ? "true" : "false";
break;
case Option::Type::Int:
@ -209,7 +209,7 @@ void PostProcessingShader::SetConfigString(const std::string_view& str)
switch (option->type)
{
case Option::Type::Bool:
option->value[0].bool_value = StringUtil::FromChars<bool>(value).value_or(false);
option->value[0].int_value = StringUtil::FromChars<bool>(value).value_or(false) ? 1 : 0;
break;
case Option::Type::Int:
@ -389,7 +389,7 @@ void PostProcessingShader::LoadOptions()
u32 size = 0;
if (current_option.type == Option::Type::Bool)
(*dst_array)[size++].bool_value = StringUtil::FromChars<bool>(value).value_or(false);
(*dst_array)[size++].int_value = StringUtil::FromChars<bool>(value).value_or(false) ? 1 : 0;
else if (current_option.type == Option::Type::Float)
size = ParseVector<float>(value, dst_array);
else if (current_option.type == Option::Type::Int)

View file

@ -33,7 +33,6 @@ public:
union Value
{
bool bool_value;
s32 int_value;
float float_value;
};