mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
Qt: Add UI elements for overclocking in game properties
This commit is contained in:
parent
9a23c5547a
commit
345a38ef03
|
@ -2,6 +2,7 @@
|
||||||
#include "common/cd_image.h"
|
#include "common/cd_image.h"
|
||||||
#include "common/cd_image_hasher.h"
|
#include "common/cd_image_hasher.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
#include "core/system.h"
|
||||||
#include "frontend-common/game_list.h"
|
#include "frontend-common/game_list.h"
|
||||||
#include "qthostinterface.h"
|
#include "qthostinterface.h"
|
||||||
#include "qtprogresscallback.h"
|
#include "qtprogresscallback.h"
|
||||||
|
@ -254,6 +255,18 @@ void GamePropertiesDialog::populateGameSettings()
|
||||||
m_trait_checkboxes[i]->setChecked(gs.HasTrait(static_cast<GameSettings::Trait>(i)));
|
m_trait_checkboxes[i]->setChecked(gs.HasTrait(static_cast<GameSettings::Trait>(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gs.cpu_overclock_numerator.has_value() || gs.cpu_overclock_denominator.has_value())
|
||||||
|
{
|
||||||
|
const u32 numerator = gs.cpu_overclock_numerator.value_or(1);
|
||||||
|
const u32 denominator = gs.cpu_overclock_denominator.value_or(1);
|
||||||
|
const u32 percent = Settings::CPUOverclockFractionToPercent(numerator, denominator);
|
||||||
|
QSignalBlocker sb(m_ui.userCPUClockSpeed);
|
||||||
|
m_ui.userCPUClockSpeed->setValue(static_cast<int>(percent));
|
||||||
|
}
|
||||||
|
|
||||||
|
populateBooleanUserSetting(m_ui.userEnableCPUClockSpeedControl, gs.cpu_overclock_enable);
|
||||||
|
updateCPUClockSpeedLabel();
|
||||||
|
|
||||||
if (gs.display_active_start_offset.has_value())
|
if (gs.display_active_start_offset.has_value())
|
||||||
{
|
{
|
||||||
QSignalBlocker sb(m_ui.displayActiveStartOffset);
|
QSignalBlocker sb(m_ui.displayActiveStartOffset);
|
||||||
|
@ -385,6 +398,28 @@ void GamePropertiesDialog::connectUi()
|
||||||
m_ui.exportCompatibilityInfo->setVisible(show_buttons);
|
m_ui.exportCompatibilityInfo->setVisible(show_buttons);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connectBooleanUserSetting(m_ui.userEnableCPUClockSpeedControl, &m_game_settings.cpu_overclock_enable);
|
||||||
|
connect(m_ui.userEnableCPUClockSpeedControl, &QCheckBox::stateChanged, this,
|
||||||
|
&GamePropertiesDialog::updateCPUClockSpeedLabel);
|
||||||
|
|
||||||
|
connect(m_ui.userCPUClockSpeed, &QSlider::valueChanged, [this](int value) {
|
||||||
|
if (value == 100)
|
||||||
|
{
|
||||||
|
m_game_settings.cpu_overclock_numerator.reset();
|
||||||
|
m_game_settings.cpu_overclock_denominator.reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
u32 numerator, denominator;
|
||||||
|
Settings::CPUOverclockPercentToFraction(static_cast<u32>(value), &numerator, &denominator);
|
||||||
|
m_game_settings.cpu_overclock_numerator = numerator;
|
||||||
|
m_game_settings.cpu_overclock_denominator = denominator;
|
||||||
|
}
|
||||||
|
|
||||||
|
saveGameSettings();
|
||||||
|
updateCPUClockSpeedLabel();
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui.userAspectRatio, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
connect(m_ui.userAspectRatio, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||||
if (index <= 0)
|
if (index <= 0)
|
||||||
m_game_settings.display_aspect_ratio.reset();
|
m_game_settings.display_aspect_ratio.reset();
|
||||||
|
@ -514,6 +549,13 @@ void GamePropertiesDialog::connectUi()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GamePropertiesDialog::updateCPUClockSpeedLabel()
|
||||||
|
{
|
||||||
|
const int percent = m_ui.userCPUClockSpeed->value();
|
||||||
|
const double frequency = (static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0;
|
||||||
|
m_ui.userCPUClockSpeedLabel->setText(tr("%1% (%2MHz)").arg(percent).arg(frequency / 1000000.0, 0, 'f', 2));
|
||||||
|
}
|
||||||
|
|
||||||
void GamePropertiesDialog::fillEntryFromUi(GameListCompatibilityEntry* entry)
|
void GamePropertiesDialog::fillEntryFromUi(GameListCompatibilityEntry* entry)
|
||||||
{
|
{
|
||||||
entry->code = m_ui.gameCode->text().toStdString();
|
entry->code = m_ui.gameCode->text().toStdString();
|
||||||
|
|
|
@ -36,6 +36,7 @@ private Q_SLOTS:
|
||||||
void onComputeHashClicked();
|
void onComputeHashClicked();
|
||||||
void onVerifyDumpClicked();
|
void onVerifyDumpClicked();
|
||||||
void onExportCompatibilityInfoClicked();
|
void onExportCompatibilityInfoClicked();
|
||||||
|
void updateCPUClockSpeedLabel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupAdditionalUi();
|
void setupAdditionalUi();
|
||||||
|
|
|
@ -187,6 +187,74 @@
|
||||||
<string>User Settings (Console)</string>
|
<string>User Settings (Console)</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_7">
|
||||||
|
<property name="title">
|
||||||
|
<string>CPU Clock Speed Control</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="userEnableCPUClockSpeedControl">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable Clock Speed Control (Overclocking/Underclocking)</string>
|
||||||
|
</property>
|
||||||
|
<property name="tristate">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="userCPUClockSpeedLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>100% (effective 33.3mhz)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QSlider" name="userCPUClockSpeed">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickPosition">
|
||||||
|
<enum>QSlider::TicksBothSides</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tickInterval">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
Loading…
Reference in a new issue