mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
GameSettings: Add runahead as per-game setting
This commit is contained in:
parent
16a32bf696
commit
a5dfc68ac9
|
@ -268,6 +268,12 @@ void GamePropertiesDialog::populateGameSettings()
|
|||
m_trait_checkboxes[i]->setChecked(gs.HasTrait(static_cast<GameSettings::Trait>(i)));
|
||||
}
|
||||
|
||||
if (gs.runahead_frames.has_value())
|
||||
{
|
||||
QSignalBlocker sb(m_ui.userRunaheadFrames);
|
||||
m_ui.userRunaheadFrames->setCurrentIndex(static_cast<int>(gs.runahead_frames.value()));
|
||||
}
|
||||
|
||||
if (gs.cpu_overclock_numerator.has_value() || gs.cpu_overclock_denominator.has_value())
|
||||
{
|
||||
const u32 numerator = gs.cpu_overclock_numerator.value_or(1);
|
||||
|
@ -491,6 +497,14 @@ void GamePropertiesDialog::connectUi()
|
|||
m_ui.exportCompatibilityInfo->setVisible(show_buttons);
|
||||
});
|
||||
|
||||
connect(m_ui.userRunaheadFrames, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if (index <= 0)
|
||||
m_game_settings.runahead_frames.reset();
|
||||
else
|
||||
m_game_settings.runahead_frames = static_cast<u32>(index - 1);
|
||||
saveGameSettings();
|
||||
});
|
||||
|
||||
connectBooleanUserSetting(m_ui.userEnableCPUClockSpeedControl, &m_game_settings.cpu_overclock_enable);
|
||||
connect(m_ui.userEnableCPUClockSpeedControl, &QCheckBox::stateChanged, this,
|
||||
&GamePropertiesDialog::updateCPUClockSpeedLabel);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>750</width>
|
||||
<height>567</height>
|
||||
<width>793</width>
|
||||
<height>619</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -436,7 +436,7 @@
|
|||
<property name="title">
|
||||
<string>Other Settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_7">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
|
@ -503,6 +503,77 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="text">
|
||||
<string>Runahead Frames:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="userRunaheadFrames">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>(unchanged)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1 Frame</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>10 Frames</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -119,7 +119,7 @@ private:
|
|||
enum : u32
|
||||
{
|
||||
GAME_LIST_CACHE_SIGNATURE = 0x45434C47,
|
||||
GAME_LIST_CACHE_VERSION = 21
|
||||
GAME_LIST_CACHE_VERSION = 22
|
||||
};
|
||||
|
||||
using DatabaseMap = std::unordered_map<std::string, GameListDatabaseEntry>;
|
||||
|
|
|
@ -105,7 +105,8 @@ bool Entry::LoadFromStream(ByteStream* stream)
|
|||
constexpr u32 num_bytes = (static_cast<u32>(Trait::Count) + 7) / 8;
|
||||
std::array<u8, num_bytes> bits;
|
||||
|
||||
if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &cpu_overclock_numerator) ||
|
||||
if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &runahead_frames) ||
|
||||
!ReadOptionalFromStream(stream, &cpu_overclock_numerator) ||
|
||||
!ReadOptionalFromStream(stream, &cpu_overclock_denominator) ||
|
||||
!ReadOptionalFromStream(stream, &cpu_overclock_enable) || !ReadOptionalFromStream(stream, &cdrom_read_speedup) ||
|
||||
!ReadOptionalFromStream(stream, &display_active_start_offset) ||
|
||||
|
@ -156,7 +157,8 @@ bool Entry::SaveToStream(ByteStream* stream) const
|
|||
bits[i / 8] |= (1u << (i % 8));
|
||||
}
|
||||
|
||||
return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, cpu_overclock_numerator) &&
|
||||
return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, runahead_frames) &&
|
||||
WriteOptionalToStream(stream, cpu_overclock_numerator) &&
|
||||
WriteOptionalToStream(stream, cpu_overclock_denominator) &&
|
||||
WriteOptionalToStream(stream, cpu_overclock_enable) && WriteOptionalToStream(stream, cdrom_read_speedup) &&
|
||||
WriteOptionalToStream(stream, display_active_start_offset) &&
|
||||
|
@ -189,7 +191,11 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
|
|||
entry->AddTrait(static_cast<Trait>(trait));
|
||||
}
|
||||
|
||||
const char* cvalue = ini.GetValue(section, "CPUOverclockNumerator", nullptr);
|
||||
const char* cvalue = ini.GetValue(section, "RunaheadFrameCount", nullptr);
|
||||
if (cvalue)
|
||||
entry->runahead_frames = StringUtil::FromChars<u32>(cvalue);
|
||||
|
||||
cvalue = ini.GetValue(section, "CPUOverclockNumerator", nullptr);
|
||||
if (cvalue)
|
||||
entry->cpu_overclock_numerator = StringUtil::FromChars<u32>(cvalue);
|
||||
cvalue = ini.GetValue(section, "CPUOverclockDenominator", nullptr);
|
||||
|
@ -316,6 +322,9 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
|
|||
ini.SetBoolValue(section, s_trait_names[trait].first, true);
|
||||
}
|
||||
|
||||
if (entry.runahead_frames.has_value())
|
||||
ini.SetLongValue(section, "RunaheadFrameCount", static_cast<long>(entry.runahead_frames.value()));
|
||||
|
||||
if (entry.cpu_overclock_numerator.has_value())
|
||||
ini.SetLongValue(section, "CPUOverclockNumerator", static_cast<long>(entry.cpu_overclock_numerator.value()));
|
||||
if (entry.cpu_overclock_denominator.has_value())
|
||||
|
@ -409,7 +418,14 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
|
|||
|
||||
static std::optional<std::string> GetEntryValueForKey(const Entry& entry, const std::string_view& key)
|
||||
{
|
||||
if (key == "CPUOverclock")
|
||||
if (key == "RunaheadFrameCount")
|
||||
{
|
||||
if (!entry.runahead_frames.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
return std::to_string(entry.runahead_frames.value());
|
||||
}
|
||||
else if (key == "CPUOverclock")
|
||||
{
|
||||
if (!entry.cpu_overclock_enable.has_value())
|
||||
return std::nullopt;
|
||||
|
@ -592,7 +608,14 @@ static std::optional<std::string> GetEntryValueForKey(const Entry& entry, const
|
|||
|
||||
static void SetEntryValueForKey(Entry& entry, const std::string_view& key, const std::optional<std::string>& value)
|
||||
{
|
||||
if (key == "CPUOverclock")
|
||||
if (key == "RunaheadFrameCount")
|
||||
{
|
||||
if (!value.has_value())
|
||||
entry.runahead_frames.reset();
|
||||
else
|
||||
entry.runahead_frames = StringUtil::FromChars<u32>(value.value());
|
||||
}
|
||||
else if (key == "CPUOverclock")
|
||||
{
|
||||
if (!value.has_value())
|
||||
{
|
||||
|
@ -897,6 +920,8 @@ void Entry::ApplySettings(bool display_osd_messages) const
|
|||
{
|
||||
constexpr float osd_duration = 10.0f;
|
||||
|
||||
if (runahead_frames.has_value())
|
||||
g_settings.runahead_frames = runahead_frames.value();
|
||||
if (cpu_overclock_numerator.has_value())
|
||||
g_settings.cpu_overclock_numerator = cpu_overclock_numerator.value();
|
||||
if (cpu_overclock_denominator.has_value())
|
||||
|
|
|
@ -50,6 +50,7 @@ struct Entry
|
|||
std::optional<float> gpu_pgxp_depth_threshold;
|
||||
|
||||
// user settings
|
||||
std::optional<u32> runahead_frames;
|
||||
std::optional<u32> cpu_overclock_numerator;
|
||||
std::optional<u32> cpu_overclock_denominator;
|
||||
std::optional<bool> cpu_overclock_enable;
|
||||
|
|
Loading…
Reference in a new issue