This commit is contained in:
OpenSauce 2025-12-12 15:18:59 +01:00 committed by GitHub
commit 698b479a0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 45 additions and 110 deletions

View File

@ -20,7 +20,8 @@ class SliderSetting(
val units: String,
val key: String? = null,
val defaultValue: Float? = null,
override var isEnabled: Boolean = true
override var isEnabled: Boolean = true,
val showSlider: Boolean = true
) : SettingsItem(setting, titleId, descriptionId) {
override val type = TYPE_SLIDER
val selectedFloat: Float

View File

@ -15,6 +15,7 @@ import android.text.InputType
import android.text.TextWatcher
import android.text.format.DateFormat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
@ -315,7 +316,6 @@ class SettingsAdapter(
clickedPosition = position
sliderProgress = (item.selectedFloat * 100f).roundToInt() / 100f
val inflater = LayoutInflater.from(context)
val sliderBinding = DialogSliderBinding.inflate(inflater)
textInputLayout = sliderBinding.textInput
@ -335,6 +335,11 @@ class SettingsAdapter(
valueFrom = item.min.toFloat()
valueTo = item.max.toFloat()
value = sliderProgress
if (!item.showSlider) {
isEnabled = false
visibility = View.GONE
}
textSliderValue?.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
var textValue = s.toString().toFloatOrNull();

View File

@ -230,10 +230,11 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
R.string.frame_limit_slider,
R.string.frame_limit_slider_description,
1,
200,
9999,
"%",
IntSetting.FRAME_LIMIT.key,
IntSetting.FRAME_LIMIT.defaultValue.toFloat()
IntSetting.FRAME_LIMIT.defaultValue.toFloat(),
showSlider = false
)
)
add(
@ -241,11 +242,12 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
IntSetting.TURBO_LIMIT,
R.string.turbo_limit,
R.string.turbo_limit_description,
100,
400,
1,
9999,
"%",
IntSetting.TURBO_LIMIT.key,
IntSetting.TURBO_LIMIT.defaultValue.toFloat()
IntSetting.TURBO_LIMIT.defaultValue.toFloat(),
showSlider = false
)
)
add(

View File

@ -28,16 +28,9 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
: QWidget(parent), ui(std::make_unique<Ui::ConfigureGeneral>()) {
ui->setupUi(this);
connect(ui->turbo_limit, &QSlider::valueChanged, this, [&](double value) {
Settings::values.turbo_limit.SetValue(SliderToSettings(value));
ui->turbo_limit_display_label->setText(
QStringLiteral("%1%").arg(Settings::values.turbo_limit.GetValue()));
});
// Set a minimum width for the label to prevent the slider from changing size.
// This scales across DPIs, and is acceptable for uncapitalized strings.
const auto width = static_cast<int>(tr("unthrottled").size() * 6);
ui->emulation_speed_display_label->setMinimumWidth(width);
ui->emulation_speed_combo->setVisible(!Settings::IsConfiguringGlobal());
ui->screenshot_combo->setVisible(!Settings::IsConfiguringGlobal());
#ifndef __unix__
@ -53,17 +46,6 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
connect(ui->button_reset_defaults, &QPushButton::clicked, this,
&ConfigureGeneral::ResetDefaults);
connect(ui->frame_limit, &QSlider::valueChanged, this, [&](int value) {
if (value == ui->frame_limit->maximum()) {
ui->emulation_speed_display_label->setText(tr("unthrottled"));
} else {
ui->emulation_speed_display_label->setText(
QStringLiteral("%1%")
.arg(SliderToSettings(value))
.rightJustified(tr("unthrottled").size()));
}
});
connect(ui->change_screenshot_dir, &QToolButton::clicked, this, [this] {
ui->change_screenshot_dir->setEnabled(false);
const QString dir_path = QFileDialog::getExistingDirectory(
@ -80,9 +62,7 @@ ConfigureGeneral::~ConfigureGeneral() = default;
void ConfigureGeneral::SetConfiguration() {
if (Settings::IsConfiguringGlobal()) {
ui->turbo_limit->setValue(SettingsToSlider(Settings::values.turbo_limit.GetValue()));
ui->turbo_limit_display_label->setText(
QStringLiteral("%1%").arg(Settings::values.turbo_limit.GetValue()));
ui->turbo_limit->setValue(Settings::values.turbo_limit.GetValue());
ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue());
ui->toggle_background_pause->setChecked(
@ -97,19 +77,7 @@ void ConfigureGeneral::SetConfiguration() {
#endif
}
if (Settings::values.frame_limit.GetValue() == 0) {
ui->frame_limit->setValue(ui->frame_limit->maximum());
} else {
ui->frame_limit->setValue(SettingsToSlider(Settings::values.frame_limit.GetValue()));
}
if (ui->frame_limit->value() == ui->frame_limit->maximum()) {
ui->emulation_speed_display_label->setText(tr("unthrottled"));
} else {
ui->emulation_speed_display_label->setText(
QStringLiteral("%1%")
.arg(SliderToSettings(ui->frame_limit->value()))
.rightJustified(tr("unthrottled").size()));
}
ui->frame_limit->setValue(Settings::values.frame_limit.GetValue());
if (!Settings::IsConfiguringGlobal()) {
if (Settings::values.frame_limit.UsingGlobal()) {
@ -163,11 +131,9 @@ void ConfigureGeneral::ResetDefaults() {
}
void ConfigureGeneral::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(
&Settings::values.frame_limit, ui->emulation_speed_combo, [this](s32) {
const bool is_maximum = ui->frame_limit->value() == ui->frame_limit->maximum();
return is_maximum ? 0 : SliderToSettings(ui->frame_limit->value());
});
ConfigurationShared::ApplyPerGameSetting(&Settings::values.frame_limit,
ui->emulation_speed_combo,
[this](s32) { return ui->frame_limit->value(); });
ConfigurationShared::ApplyPerGameSetting(
&UISettings::values.screenshot_path, ui->screenshot_combo,
@ -182,6 +148,7 @@ void ConfigureGeneral::ApplyConfiguration() {
#ifdef __unix__
Settings::values.enable_gamemode = ui->toggle_gamemode->isChecked();
#endif
Settings::values.turbo_limit = ui->turbo_limit->value();
}
}

View File

@ -105,44 +105,32 @@
<item>
<widget class="QLabel" name="label_emulation_speed">
<property name="text">
<string>Emulation Speed</string>
<string>Emulation Speed:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="frame_limit">
<property name="minimum">
<number>0</number>
</property>
<widget class="QSpinBox" name="frame_limit">
<property name="maximum">
<number>199</number>
<number>9999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="pageStep">
<number>15</number>
</property>
<property name="value">
<number>19</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
<property name="suffix">
<string>%</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="emulation_speed_display_label">
<property name="text">
<string/>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
@ -170,56 +158,28 @@
</widget>
</item>
<item>
<widget class="QSlider" name="turbo_limit">
<property name="minimum">
<number>0</number>
</property>
<widget class="QSpinBox" name="turbo_limit">
<property name="maximum">
<number>198</number>
<number>9999</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="pageStep">
<number>15</number>
</property>
<property name="value">
<number>19</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
<property name="suffix">
<string>%</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>32</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="turbo_limit_display_label">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -287,7 +247,7 @@
</layout>
</widget>
</item>
<item alignment="Qt::AlignRight">
<item alignment="Qt::AlignmentFlag::AlignRight">
<widget class="QPushButton" name="button_reset_defaults">
<property name="text">
<string>Reset All Settings</string>
@ -297,7 +257,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

View File

@ -509,8 +509,8 @@ struct Values {
SwitchableSetting<bool> use_vsync{true, "use_vsync"};
Setting<bool> use_shader_jit{true, "use_shader_jit"};
SwitchableSetting<u32, true> resolution_factor{1, 0, 10, "resolution_factor"};
SwitchableSetting<double, true> frame_limit{100, 0, 1000, "frame_limit"};
SwitchableSetting<double, true> turbo_limit{200, 0, 1000, "turbo_limit"};
SwitchableSetting<double, true> frame_limit{100, 1, 9999, "frame_limit"};
SwitchableSetting<double, true> turbo_limit{200, 1, 9999, "turbo_limit"};
SwitchableSetting<TextureFilter> texture_filter{TextureFilter::NoFilter, "texture_filter"};
SwitchableSetting<TextureSampling> texture_sampling{TextureSampling::GameControlled,
"texture_sampling"};