Merge branch 'master' of https://github.com/dolphin-emu/dolphin into dolphin-emu-maste2r

This commit is contained in:
Nayla Hanegan 2024-12-24 20:47:03 -05:00
commit 75a9451d0b
218 changed files with 53095 additions and 44354 deletions

View file

@ -21,6 +21,7 @@
#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h"
@ -36,7 +37,7 @@ AchievementSettingsWidget::AchievementSettingsWidget(QWidget* parent) : QWidget(
// If hardcore is enabled when the emulator starts, make sure it turns off what it needs to
if (Config::Get(Config::RA_HARDCORE_ENABLED))
ToggleHardcore();
UpdateHardcoreMode();
}
void AchievementSettingsWidget::UpdateData(int login_failed_code)
@ -258,11 +259,7 @@ void AchievementSettingsWidget::ToggleRAIntegration()
instance.Init();
else
instance.Shutdown();
if (Config::Get(Config::RA_HARDCORE_ENABLED))
{
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
emit Settings::Instance().HardcoreStateChanged();
}
UpdateHardcoreMode();
}
void AchievementSettingsWidget::Login()
@ -276,24 +273,31 @@ void AchievementSettingsWidget::Login()
void AchievementSettingsWidget::Logout()
{
AchievementManager::GetInstance().Logout();
SaveSettings();
auto confirm = ModalMessageBox::question(
this, tr("Confirm Logout"), tr("Are you sure you want to log out of RetroAchievements?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal);
if (confirm == QMessageBox::Yes)
{
AchievementManager::GetInstance().Logout();
SaveSettings();
}
}
void AchievementSettingsWidget::ToggleHardcore()
{
SaveSettings();
AchievementManager::GetInstance().SetHardcoreMode();
if (Config::Get(Config::RA_HARDCORE_ENABLED))
{
if (Config::Get(Config::MAIN_EMULATION_SPEED) < 1.0f)
Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED, 1.0f);
Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, false);
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, false);
Settings::Instance().SetDebugModeEnabled(false);
auto confirm = ModalMessageBox::question(
this, tr("Confirm Hardcore Off"), tr("Are you sure you want to turn hardcore mode off?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton, Qt::ApplicationModal);
if (confirm != QMessageBox::Yes)
{
SignalBlocking(m_common_hardcore_enabled_input)->setChecked(true);
return;
}
}
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
emit Settings::Instance().HardcoreStateChanged();
SaveSettings();
UpdateHardcoreMode();
}
void AchievementSettingsWidget::ToggleUnofficial()
@ -323,4 +327,14 @@ void AchievementSettingsWidget::ToggleProgress()
SaveSettings();
}
void AchievementSettingsWidget::UpdateHardcoreMode()
{
if (Config::Get(Config::RA_HARDCORE_ENABLED))
{
Settings::Instance().SetDebugModeEnabled(false);
}
emit Settings::Instance().EmulationStateChanged(Core::GetState(Core::System::GetInstance()));
emit Settings::Instance().HardcoreStateChanged();
}
#endif // USE_RETRO_ACHIEVEMENTS

View file

@ -39,6 +39,8 @@ private:
void ToggleDiscordPresence();
void ToggleProgress();
void UpdateHardcoreMode();
QGroupBox* m_common_box;
QVBoxLayout* m_common_layout;
ToolTipCheckBox* m_common_integration_enabled_input;

View file

@ -52,6 +52,7 @@ add_executable(dolphin-mpn
Config/ConfigControls/ConfigBool.h
Config/ConfigControls/ConfigChoice.cpp
Config/ConfigControls/ConfigChoice.h
Config/ConfigControls/ConfigControl.h
Config/ConfigControls/ConfigInteger.cpp
Config/ConfigControls/ConfigInteger.h
Config/ConfigControls/ConfigRadio.cpp
@ -318,6 +319,8 @@ add_executable(dolphin-mpn
QtUtils/ParallelProgressDialog.h
QtUtils/PartiallyClosableTabWidget.cpp
QtUtils/PartiallyClosableTabWidget.h
QtUtils/QtUtils.cpp
QtUtils/QtUtils.h
QtUtils/SetWindowDecorations.cpp
QtUtils/SetWindowDecorations.h
QtUtils/SignalBlocking.h

View file

@ -115,7 +115,7 @@ void ARCodeWidget::OnItemChanged(QListWidgetItem* item)
m_ar_codes[m_code_list->row(item)].enabled = (item->checkState() == Qt::Checked);
if (!m_restart_required)
ActionReplay::ApplyCodes(m_ar_codes);
ActionReplay::ApplyCodes(m_ar_codes, m_game_id);
UpdateList();
SaveCodes();
@ -140,20 +140,14 @@ void ARCodeWidget::SortAlphabetically()
void ARCodeWidget::SortEnabledCodesFirst()
{
std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) {
return a.enabled && a.enabled != b.enabled;
});
std::ranges::stable_partition(m_ar_codes, std::identity{}, &ActionReplay::ARCode::enabled);
UpdateList();
SaveCodes();
}
void ARCodeWidget::SortDisabledCodesFirst()
{
std::stable_sort(m_ar_codes.begin(), m_ar_codes.end(), [](const auto& a, const auto& b) {
return !a.enabled && a.enabled != b.enabled;
});
std::ranges::stable_partition(m_ar_codes, std::logical_not{}, &ActionReplay::ARCode::enabled);
UpdateList();
SaveCodes();
}

View file

@ -3,31 +3,28 @@
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include <QEvent>
#include <QFont>
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigBool::ConfigBool(const QString& label, const Config::Info<bool>& setting, bool reverse)
: ToolTipCheckBox(label), m_setting(setting), m_reverse(reverse)
: ConfigBool(label, setting, nullptr, reverse)
{
}
ConfigBool::ConfigBool(const QString& label, const Config::Info<bool>& setting,
Config::Layer* layer, bool reverse)
: ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_reverse(reverse)
{
setChecked(ReadValue(setting) ^ reverse);
connect(this, &QCheckBox::toggled, this, &ConfigBool::Update);
setChecked(Config::Get(m_setting) ^ reverse);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
setChecked(Config::Get(m_setting) ^ m_reverse);
});
}
void ConfigBool::Update()
{
Config::SetBaseOrCurrent(m_setting, static_cast<bool>(isChecked() ^ m_reverse));
const bool value = static_cast<bool>(isChecked() ^ m_reverse);
SaveValue(m_setting, value);
}
void ConfigBool::OnConfigChanged()
{
setChecked(ReadValue(m_setting) ^ m_reverse);
}

View file

@ -3,23 +3,25 @@
#pragma once
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
namespace Config
{
template <typename T>
class Info;
}
#include "Common/Config/ConfigInfo.h"
class ConfigBool : public ToolTipCheckBox
class ConfigBool final : public ConfigControl<ToolTipCheckBox>
{
Q_OBJECT
public:
ConfigBool(const QString& label, const Config::Info<bool>& setting, bool reverse = false);
ConfigBool(const QString& label, const Config::Info<bool>& setting, Config::Layer* layer,
bool reverse = false);
protected:
void OnConfigChanged() override;
private:
void Update();
const Config::Info<bool>& m_setting;
const Config::Info<bool> m_setting;
bool m_reverse;
};

View file

@ -5,85 +5,168 @@
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigChoice::ConfigChoice(const QStringList& options, const Config::Info<int>& setting)
: m_setting(setting)
ConfigChoice::ConfigChoice(const QStringList& options, const Config::Info<int>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
{
addItems(options);
setCurrentIndex(ReadValue(setting));
connect(this, &QComboBox::currentIndexChanged, this, &ConfigChoice::Update);
setCurrentIndex(Config::Get(m_setting));
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
setCurrentIndex(Config::Get(m_setting));
});
}
void ConfigChoice::Update(int choice)
{
Config::SetBaseOrCurrent(m_setting, choice);
SaveValue(m_setting, choice);
}
void ConfigChoice::OnConfigChanged()
{
setCurrentIndex(ReadValue(m_setting));
}
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
const Config::Info<std::string>& setting)
: m_setting(setting), m_text_is_data(true)
const Config::Info<std::string>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(true)
{
for (const auto& op : options)
addItem(QString::fromStdString(op));
Connect();
Load();
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
}
ConfigStringChoice::ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
const Config::Info<std::string>& setting)
: m_setting(setting), m_text_is_data(false)
const Config::Info<std::string>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting), m_text_is_data(false)
{
for (const auto& [option_text, option_data] : options)
addItem(option_text, option_data);
Connect();
Load();
}
void ConfigStringChoice::Connect()
{
const auto on_config_changed = [this]() {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
Load();
};
connect(&Settings::Instance(), &Settings::ConfigChanged, this, on_config_changed);
connect(this, &QComboBox::currentIndexChanged, this, &ConfigStringChoice::Update);
Load();
}
void ConfigStringChoice::Update(int index)
{
if (m_text_is_data)
{
Config::SetBaseOrCurrent(m_setting, itemText(index).toStdString());
}
SaveValue(m_setting, itemText(index).toStdString());
else
{
Config::SetBaseOrCurrent(m_setting, itemData(index).toString().toStdString());
}
SaveValue(m_setting, itemData(index).toString().toStdString());
}
void ConfigStringChoice::Load()
{
const QString setting_value = QString::fromStdString(Config::Get(m_setting));
const QString setting_value = QString::fromStdString(ReadValue(m_setting));
const int index = m_text_is_data ? findText(setting_value) : findData(setting_value);
// This can be called publicly.
const QSignalBlocker block(this);
setCurrentIndex(index);
}
void ConfigStringChoice::OnConfigChanged()
{
Load();
}
ConfigComplexChoice::ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
Config::Layer* layer)
: m_setting1(setting1), m_setting2(setting2), m_layer(layer)
{
connect(&Settings::Instance(), &Settings::ConfigChanged, this, &ConfigComplexChoice::Refresh);
connect(this, &QComboBox::currentIndexChanged, this, &ConfigComplexChoice::SaveValue);
}
void ConfigComplexChoice::Refresh()
{
auto& location = GetLocation();
QFont bf = font();
if (m_layer != nullptr)
{
bf.setBold(m_layer->Exists(location.first) || m_layer->Exists(location.second));
}
else
{
bf.setBold(Config::GetActiveLayerForConfig(location.first) != Config::LayerType::Base ||
Config::GetActiveLayerForConfig(location.second) != Config::LayerType::Base);
}
setFont(bf);
UpdateComboIndex();
}
void ConfigComplexChoice::Add(const QString& name, const OptionVariant option1,
const OptionVariant option2)
{
const QSignalBlocker blocker(this);
addItem(name);
m_options.push_back(std::make_pair(option1, option2));
}
void ConfigComplexChoice::Reset()
{
clear();
m_options.clear();
}
void ConfigComplexChoice::SaveValue(int choice)
{
auto Set = [this, choice](auto& setting, auto& value) {
if (m_layer != nullptr)
{
m_layer->Set(setting.GetLocation(), value);
Config::OnConfigChanged();
return;
}
Config::SetBaseOrCurrent(setting, value);
};
std::visit(Set, m_setting1, m_options[choice].first);
std::visit(Set, m_setting2, m_options[choice].second);
}
void ConfigComplexChoice::UpdateComboIndex()
{
auto Get = [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 it = std::find(m_options.begin(), m_options.end(), values);
int index = static_cast<int>(std::distance(m_options.begin(), it));
const QSignalBlocker blocker(this);
setCurrentIndex(index);
}
const std::pair<Config::Location, Config::Location> ConfigComplexChoice::GetLocation() const
{
auto visit = [](auto& v) { return v.GetLocation(); };
return {std::visit(visit, m_setting1), std::visit(visit, m_setting2)};
}
void ConfigComplexChoice::mousePressEvent(QMouseEvent* event)
{
if (event->button() == Qt::RightButton && m_layer != nullptr)
{
auto& location = GetLocation();
m_layer->DeleteKey(location.first);
m_layer->DeleteKey(location.second);
Config::OnConfigChanged();
}
else
{
QComboBox::mousePressEvent(event);
}
};

View file

@ -7,15 +7,20 @@
#include <utility>
#include <vector>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
#include "Common/Config/Config.h"
#include "Common/Config/ConfigInfo.h"
class ConfigChoice : public ToolTipComboBox
class ConfigChoice final : public ConfigControl<ToolTipComboBox>
{
Q_OBJECT
public:
ConfigChoice(const QStringList& options, const Config::Info<int>& setting);
ConfigChoice(const QStringList& options, const Config::Info<int>& setting,
Config::Layer* layer = nullptr);
protected:
void OnConfigChanged() override;
private:
void Update(int choice);
@ -23,20 +28,49 @@ private:
Config::Info<int> m_setting;
};
class ConfigStringChoice : public ToolTipComboBox
class ConfigStringChoice final : public ConfigControl<ToolTipComboBox>
{
Q_OBJECT
public:
ConfigStringChoice(const std::vector<std::string>& options,
const Config::Info<std::string>& setting);
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
ConfigStringChoice(const std::vector<std::pair<QString, QString>>& options,
const Config::Info<std::string>& setting);
private:
void Connect();
void Update(int index);
const Config::Info<std::string>& setting, Config::Layer* layer = nullptr);
void Load();
Config::Info<std::string> m_setting;
protected:
void OnConfigChanged() override;
private:
void Update(int index);
const Config::Info<std::string> m_setting;
bool m_text_is_data = false;
};
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>;
public:
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
Config::Layer* layer = nullptr);
void Add(const QString& name, const OptionVariant option1, const OptionVariant option2);
void Refresh();
void Reset();
const std::pair<Config::Location, Config::Location> GetLocation() const;
private:
void SaveValue(int choice);
void UpdateComboIndex();
void mousePressEvent(QMouseEvent* event) override;
Config::Layer* m_layer;
const InfoVariant m_setting1;
const InfoVariant m_setting2;
std::vector<std::pair<OptionVariant, OptionVariant>> m_options;
};

View file

@ -0,0 +1,105 @@
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QFont>
#include <QMouseEvent>
#include <QSignalBlocker>
#include "Common/Config/Enums.h"
#include "Common/Config/Layer.h"
#include "DolphinQt/Settings.h"
namespace Config
{
template <typename T>
class Info;
struct Location;
} // namespace Config
template <class Derived>
class ConfigControl : public Derived
{
public:
ConfigControl(const Config::Location& location, Config::Layer* layer)
: m_location(location), m_layer(layer)
{
ConnectConfig();
}
ConfigControl(const QString& label, const Config::Location& location, Config::Layer* layer)
: Derived(label), m_location(location), m_layer(layer)
{
ConnectConfig();
}
ConfigControl(const Qt::Orientation& orient, const Config::Location& location,
Config::Layer* layer)
: Derived(orient), m_location(location), m_layer(layer)
{
ConnectConfig();
}
const Config::Location GetLocation() const { return m_location; }
protected:
void ConnectConfig()
{
Derived::connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = Derived::font();
bf.setBold(IsConfigLocal());
Derived::setFont(bf);
const QSignalBlocker blocker(this);
OnConfigChanged();
});
}
template <typename T>
void SaveValue(const Config::Info<T>& setting, const T& value)
{
if (m_layer != nullptr)
{
m_layer->Set(m_location, value);
Config::OnConfigChanged();
return;
}
Config::SetBaseOrCurrent(setting, value);
}
template <typename T>
const T ReadValue(const Config::Info<T>& setting) const
{
if (m_layer != nullptr)
return m_layer->Get(setting);
return Config::Get(setting);
}
virtual void OnConfigChanged(){};
private:
bool IsConfigLocal() const
{
if (m_layer != nullptr)
return m_layer->Exists(m_location);
else
return Config::GetActiveLayerForConfig(m_location) != Config::LayerType::Base;
}
void mousePressEvent(QMouseEvent* event) override
{
if (m_layer != nullptr && event->button() == Qt::RightButton)
{
m_layer->DeleteKey(m_location);
Config::OnConfigChanged();
}
else
{
Derived::mousePressEvent(event);
}
}
const Config::Location m_location;
Config::Layer* m_layer;
};

View file

@ -3,20 +3,16 @@
#include "DolphinQt/Config/ConfigControls/ConfigFloatSlider.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigFloatSlider::ConfigFloatSlider(float minimum, float maximum,
const Config::Info<float>& setting, float step)
: ToolTipSlider(Qt::Horizontal), m_minimum(minimum), m_step(step), m_setting(setting)
const Config::Info<float>& setting, float step,
Config::Layer* layer)
: ConfigControl(Qt::Horizontal, setting.GetLocation(), layer), m_minimum(minimum), m_step(step),
m_setting(setting)
{
const float range = maximum - minimum;
const int steps = std::round(range / step);
const int interval = std::round(range / steps);
const int current_value = std::round((Config::Get(m_setting) - minimum) / step);
const int current_value = std::round((ReadValue(setting) - minimum) / step);
setMinimum(0);
setMaximum(steps);
@ -24,25 +20,21 @@ ConfigFloatSlider::ConfigFloatSlider(float minimum, float maximum,
setValue(current_value);
connect(this, &ConfigFloatSlider::valueChanged, this, &ConfigFloatSlider::Update);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
const int value = std::round((Config::Get(m_setting) - m_minimum) / m_step);
setValue(value);
});
}
void ConfigFloatSlider::Update(int value)
{
const float current_value = (m_step * value) + m_minimum;
Config::SetBaseOrCurrent(m_setting, current_value);
SaveValue(m_setting, current_value);
}
float ConfigFloatSlider::GetValue() const
{
return (m_step * value()) + m_minimum;
}
void ConfigFloatSlider::OnConfigChanged()
{
setValue(std::round((ReadValue(m_setting) - m_minimum) / m_step));
}

View file

@ -3,28 +3,29 @@
#pragma once
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"
namespace Config
{
template <typename T>
class Info;
}
#include "Common/Config/ConfigInfo.h"
// Automatically converts an int slider into a float one.
// Do not read the int values or ranges directly from it.
class ConfigFloatSlider : public ToolTipSlider
class ConfigFloatSlider final : public ConfigControl<ToolTipSlider>
{
Q_OBJECT
public:
ConfigFloatSlider(float minimum, float maximum, const Config::Info<float>& setting, float step);
ConfigFloatSlider(float minimum, float maximum, const Config::Info<float>& setting, float step,
Config::Layer* layer = nullptr);
void Update(int value);
// Returns the adjusted float value
float GetValue() const;
protected:
void OnConfigChanged() override;
private:
float m_minimum;
float m_step;
const Config::Info<float>& m_setting;
const Config::Info<float> m_setting;
};

View file

@ -3,33 +3,39 @@
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, int step)
: ToolTipSpinBox(), m_setting(setting)
: ConfigInteger(minimum, maximum, setting, nullptr, step)
{
}
ConfigInteger::ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting,
Config::Layer* layer, int step)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
{
setMinimum(minimum);
setMaximum(maximum);
setSingleStep(step);
setValue(Config::Get(setting));
setValue(ReadValue(setting));
connect(this, &ConfigInteger::valueChanged, this, &ConfigInteger::Update);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
setValue(Config::Get(m_setting));
});
}
void ConfigInteger::Update(int value)
{
Config::SetBaseOrCurrent(m_setting, value);
SaveValue(m_setting, value);
}
void ConfigInteger::OnConfigChanged()
{
setValue(ReadValue(m_setting));
}
ConfigIntegerLabel::ConfigIntegerLabel(const QString& text, ConfigInteger* widget)
: QLabel(text), m_widget(QPointer<ConfigInteger>(widget))
{
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this]() {
// Label shares font changes with ConfigInteger to mark game ini settings.
if (m_widget)
setFont(m_widget->font());
});
}

View file

@ -3,21 +3,38 @@
#pragma once
#include <QLabel>
#include <QPointer>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h"
namespace Config
{
template <typename T>
class Info;
}
#include "Common/Config/ConfigInfo.h"
class ConfigInteger : public ToolTipSpinBox
class ConfigInteger final : public ConfigControl<ToolTipSpinBox>
{
Q_OBJECT
public:
ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, int step = 1);
ConfigInteger(int minimum, int maximum, const Config::Info<int>& setting, Config::Layer* layer,
int step = 1);
void Update(int value);
protected:
void OnConfigChanged() override;
private:
const Config::Info<int>& m_setting;
const Config::Info<int> m_setting;
};
class ConfigIntegerLabel final : public QLabel
{
Q_OBJECT
public:
ConfigIntegerLabel(const QString& text, ConfigInteger* widget);
private:
QPointer<ConfigInteger> m_widget;
};

View file

@ -3,33 +3,21 @@
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value)
: ToolTipRadioButton(label), m_setting(setting), m_value(value)
ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
Config::Layer* layer)
: ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_value(value)
{
setChecked(Config::Get(m_setting) == m_value);
setChecked(ReadValue(setting) == value);
connect(this, &QRadioButton::toggled, this, &ConfigRadioInt::Update);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
setChecked(Config::Get(m_setting) == m_value);
});
}
void ConfigRadioInt::Update()
{
if (isChecked())
{
Config::SetBaseOrCurrent(m_setting, m_value);
SaveValue(m_setting, m_value);
emit OnSelected(m_value);
}
else
@ -37,3 +25,8 @@ void ConfigRadioInt::Update()
emit OnDeselected(m_value);
}
}
void ConfigRadioInt::OnConfigChanged()
{
setChecked(ReadValue(m_setting) == m_value);
}

View file

@ -3,15 +3,17 @@
#pragma once
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h"
#include "Common/Config/Config.h"
#include "Common/Config/ConfigInfo.h"
class ConfigRadioInt : public ToolTipRadioButton
class ConfigRadioInt final : public ConfigControl<ToolTipRadioButton>
{
Q_OBJECT
public:
ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value);
ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
Config::Layer* layer = nullptr);
signals:
// Since selecting a new radio button deselects the old one, ::toggled will generate two signals.
@ -19,9 +21,12 @@ signals:
void OnSelected(int new_value);
void OnDeselected(int old_value);
protected:
void OnConfigChanged() override;
private:
void Update();
Config::Info<int> m_setting;
const Config::Info<int> m_setting;
int m_value;
};

View file

@ -1,36 +1,45 @@
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QFont>
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
ConfigSlider::ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick)
: ToolTipSlider(Qt::Horizontal), m_setting(setting)
: ConfigSlider(minimum, maximum, setting, nullptr, tick)
{
}
ConfigSlider::ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting,
Config::Layer* layer, int tick)
: ConfigControl(Qt::Horizontal, setting.GetLocation(), layer), m_setting(setting)
{
setMinimum(minimum);
setMaximum(maximum);
setTickInterval(tick);
setValue(Config::Get(setting));
setValue(ReadValue(setting));
connect(this, &ConfigSlider::valueChanged, this, &ConfigSlider::Update);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
const QSignalBlocker blocker(this);
setValue(Config::Get(m_setting));
});
}
void ConfigSlider::Update(int value)
{
Config::SetBaseOrCurrent(m_setting, value);
SaveValue(m_setting, value);
}
void ConfigSlider::OnConfigChanged()
{
setValue(ReadValue(m_setting));
}
ConfigSliderLabel::ConfigSliderLabel(const QString& text, ConfigSlider* slider)
: QLabel(text), m_slider(QPointer<ConfigSlider>(slider))
{
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this]() {
// Label shares font changes with slider to mark game ini settings.
if (m_slider)
setFont(m_slider->font());
});
}

View file

@ -3,21 +3,38 @@
#pragma once
#include <QLabel>
#include <QPointer>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"
namespace Config
{
template <typename T>
class Info;
}
#include "Common/Config/ConfigInfo.h"
class ConfigSlider : public ToolTipSlider
class ConfigSlider final : public ConfigControl<ToolTipSlider>
{
Q_OBJECT
public:
ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick = 0);
ConfigSlider(int minimum, int maximum, const Config::Info<int>& setting, Config::Layer* layer,
int tick = 0);
void Update(int value);
protected:
void OnConfigChanged() override;
private:
const Config::Info<int>& m_setting;
const Config::Info<int> m_setting;
};
class ConfigSliderLabel final : public QLabel
{
Q_OBJECT
public:
ConfigSliderLabel(const QString& text, ConfigSlider* slider);
private:
QPointer<ConfigSlider> m_slider;
};

View file

@ -3,37 +3,39 @@
#include "DolphinQt/Config/GameConfigWidget.h"
#include <QCheckBox>
#include <QComboBox>
#include <QFont>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <QTabWidget>
#include <QTimer>
#include <QToolTip>
#include <QVBoxLayout>
#include "Common/CommonPaths.h"
#include "Common/Config/Config.h"
#include "Common/Config/Layer.h"
#include "Common/FileUtil.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigManager.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include "DolphinQt/Config/GameConfigEdit.h"
#include "DolphinQt/Config/Graphics/AdvancedWidget.h"
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
#include "DolphinQt/Config/Graphics/GeneralWidget.h"
#include "DolphinQt/Config/Graphics/HacksWidget.h"
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
#include "UICommon/GameFile.h"
constexpr int DETERMINISM_NOT_SET_INDEX = 0;
constexpr int DETERMINISM_AUTO_INDEX = 1;
constexpr int DETERMINISM_NONE_INDEX = 2;
constexpr int DETERMINISM_FAKE_COMPLETION_INDEX = 3;
constexpr const char* DETERMINISM_NOT_SET_STRING = "";
constexpr const char* DETERMINISM_AUTO_STRING = "auto";
constexpr const char* DETERMINISM_NONE_STRING = "none";
constexpr const char* DETERMINISM_FAKE_COMPLETION_STRING = "fake-completion";
static void PopulateTab(QTabWidget* tab, const std::string& path, std::string& game_id,
u16 revision, bool read_only)
{
@ -55,46 +57,62 @@ GameConfigWidget::GameConfigWidget(const UICommon::GameFile& game) : m_game(game
m_gameini_local_path =
QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini");
m_layer = std::make_unique<Config::Layer>(
ConfigLoaders::GenerateLocalGameConfigLoader(m_game_id, m_game.GetRevision()));
m_global_layer = std::make_unique<Config::Layer>(
ConfigLoaders::GenerateGlobalGameConfigLoader(m_game_id, m_game.GetRevision()));
CreateWidgets();
LoadSettings();
ConnectWidgets();
connect(&Settings::Instance(), &Settings::ConfigChanged, this, &GameConfigWidget::LoadSettings);
PopulateTab(m_default_tab, File::GetSysDirectory() + GAMESETTINGS_DIR DIR_SEP, m_game_id,
m_game.GetRevision(), true);
PopulateTab(m_local_tab, File::GetUserPath(D_GAMESETTINGS_IDX), m_game_id, m_game.GetRevision(),
false);
// Always give the user the opportunity to create a new INI
if (m_local_tab->count() == 0)
bool game_id_tab = false;
for (int i = 0; i < m_local_tab->count(); i++)
{
if (m_local_tab->tabText(i).toStdString() == m_game_id + ".ini")
game_id_tab = true;
}
if (game_id_tab == false)
{
// Create new local game ini tab if none exists.
auto* edit = new GameConfigEdit(
nullptr, QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"),
false);
m_local_tab->addTab(edit, QString::fromStdString(m_game_id + ".ini"));
}
// Fails to change font if it's directly called at this time. Is there a better workaround?
QTimer::singleShot(100, this, [this]() {
SetItalics();
Config::OnConfigChanged();
});
}
void GameConfigWidget::CreateWidgets()
{
// General
m_refresh_config = new QPushButton(tr("Refresh"));
Config::Layer* layer = m_layer.get();
// Core
auto* core_box = new QGroupBox(tr("Core"));
auto* core_layout = new QGridLayout;
core_box->setLayout(core_layout);
m_enable_dual_core = new QCheckBox(tr("Enable Dual Core"));
m_enable_mmu = new QCheckBox(tr("Enable MMU"));
m_enable_fprf = new QCheckBox(tr("Enable FPRF"));
m_sync_gpu = new QCheckBox(tr("Synchronize GPU thread"));
m_emulate_disc_speed = new QCheckBox(tr("Emulate Disc Speed"));
m_use_dsp_hle = new QCheckBox(tr("DSP HLE (fast)"));
m_manual_texture_sampling = new QCheckBox(tr("Manual Texture Sampling"));
m_deterministic_dual_core = new QComboBox;
m_enable_dual_core = new ConfigBool(tr("Enable Dual Core"), Config::MAIN_CPU_THREAD, layer);
m_enable_mmu = new ConfigBool(tr("Enable MMU"), Config::MAIN_MMU, layer);
m_enable_fprf = new ConfigBool(tr("Enable FPRF"), Config::MAIN_FPRF, layer);
m_sync_gpu = new ConfigBool(tr("Synchronize GPU thread"), Config::MAIN_SYNC_GPU, layer);
m_emulate_disc_speed =
new ConfigBool(tr("Emulate Disc Speed"), Config::MAIN_FAST_DISC_SPEED, layer, true);
m_use_dsp_hle = new ConfigBool(tr("DSP HLE (fast)"), Config::MAIN_DSP_HLE, layer);
for (const auto& item : {tr("Not Set"), tr("auto"), tr("none"), tr("fake-completion")})
m_deterministic_dual_core->addItem(item);
const std::vector<std::string> choice{tr("auto").toStdString(), tr("none").toStdString(),
tr("fake-completion").toStdString()};
m_deterministic_dual_core =
new ConfigStringChoice(choice, Config::MAIN_GPU_DETERMINISM_MODE, layer);
m_enable_mmu->setToolTip(tr(
"Enables the Memory Management Unit, needed for some games. (ON = Compatible, OFF = Fast)"));
@ -114,24 +132,18 @@ void GameConfigWidget::CreateWidgets()
core_layout->addWidget(m_sync_gpu, 3, 0);
core_layout->addWidget(m_emulate_disc_speed, 4, 0);
core_layout->addWidget(m_use_dsp_hle, 5, 0);
core_layout->addWidget(m_manual_texture_sampling, 6, 0);
core_layout->addWidget(new QLabel(tr("Deterministic dual core:")), 7, 0);
core_layout->addWidget(m_deterministic_dual_core, 7, 1);
core_layout->addWidget(new QLabel(tr("Deterministic dual core:")), 6, 0);
core_layout->addWidget(m_deterministic_dual_core, 6, 1);
// Stereoscopy
auto* stereoscopy_box = new QGroupBox(tr("Stereoscopy"));
auto* stereoscopy_layout = new QGridLayout;
stereoscopy_box->setLayout(stereoscopy_layout);
m_depth_slider = new QSlider(Qt::Horizontal);
m_depth_slider->setMinimum(100);
m_depth_slider->setMaximum(200);
m_convergence_spin = new QSpinBox;
m_convergence_spin->setMinimum(0);
m_convergence_spin->setMaximum(INT32_MAX);
m_use_monoscopic_shadows = new QCheckBox(tr("Monoscopic Shadows"));
m_depth_slider = new ConfigSlider(100, 200, Config::GFX_STEREO_DEPTH_PERCENTAGE, layer);
m_convergence_spin = new ConfigInteger(0, INT32_MAX, Config::GFX_STEREO_CONVERGENCE, layer);
m_use_monoscopic_shadows =
new ConfigBool(tr("Monoscopic Shadows"), Config::GFX_STEREO_EFB_MONO_DEPTH, layer);
m_depth_slider->setToolTip(
tr("This value is multiplied with the depth set in the graphics configuration."));
@ -140,37 +152,23 @@ void GameConfigWidget::CreateWidgets()
m_use_monoscopic_shadows->setToolTip(
tr("Use a single depth buffer for both eyes. Needed for a few games."));
stereoscopy_layout->addWidget(new QLabel(tr("Depth Percentage:")), 0, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Depth Percentage:"), m_depth_slider), 0,
0);
stereoscopy_layout->addWidget(m_depth_slider, 0, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Convergence:")), 1, 0);
stereoscopy_layout->addWidget(new ConfigIntegerLabel(tr("Convergence:"), m_convergence_spin), 1,
0);
stereoscopy_layout->addWidget(m_convergence_spin, 1, 1);
stereoscopy_layout->addWidget(m_use_monoscopic_shadows, 2, 0);
auto* settings_box = new QGroupBox(tr("Game-Specific Settings"));
auto* settings_layout = new QVBoxLayout;
settings_box->setLayout(settings_layout);
settings_layout->addWidget(
new QLabel(tr("These settings override core Dolphin settings.\nUndetermined means the game "
"uses Dolphin's setting.")));
settings_layout->addWidget(core_box);
settings_layout->addWidget(stereoscopy_box);
auto* general_layout = new QGridLayout;
general_layout->addWidget(settings_box, 0, 0, 1, -1);
general_layout->addWidget(m_refresh_config, 1, 0, 1, -1);
for (QCheckBox* item :
{m_enable_dual_core, m_enable_mmu, m_enable_fprf, m_sync_gpu, m_emulate_disc_speed,
m_use_dsp_hle, m_manual_texture_sampling, m_use_monoscopic_shadows})
item->setTristate(true);
auto* general_layout = new QVBoxLayout;
general_layout->addWidget(core_box);
general_layout->addWidget(stereoscopy_box);
general_layout->addStretch();
auto* general_widget = new QWidget;
general_widget->setLayout(general_layout);
// Advanced
// Editor tab
auto* advanced_layout = new QVBoxLayout;
auto* default_group = new QGroupBox(tr("Default Config (Read Only)"));
@ -196,207 +194,186 @@ void GameConfigWidget::CreateWidgets()
auto* layout = new QVBoxLayout;
auto* tab_widget = new QTabWidget;
tab_widget->addTab(general_widget, tr("General"));
tab_widget->addTab(advanced_widget, tr("Editor"));
// GFX settings tabs. Placed in a QWidget for consistent margins.
auto* gfx_tab_holder = new QWidget;
auto* gfx_layout = new QVBoxLayout;
gfx_tab_holder->setLayout(gfx_layout);
tab_widget->addTab(gfx_tab_holder, tr("Graphics"));
auto* gfx_tabs = new QTabWidget;
gfx_tabs->addTab(GetWrappedWidget(new GeneralWidget(this, m_layer.get()), this, 125, 100),
tr("General"));
gfx_tabs->addTab(GetWrappedWidget(new EnhancementsWidget(this, m_layer.get()), this, 125, 100),
tr("Enhancements"));
gfx_tabs->addTab(GetWrappedWidget(new HacksWidget(this, m_layer.get()), this, 125, 100),
tr("Hacks"));
gfx_tabs->addTab(GetWrappedWidget(new AdvancedWidget(this, m_layer.get()), this, 125, 100),
tr("Advanced"));
const int editor_index = tab_widget->addTab(advanced_widget, tr("Editor"));
gfx_layout->addWidget(gfx_tabs);
connect(tab_widget, &QTabWidget::currentChanged, this, [this, editor_index](int index) {
// Update the ini editor after editing other tabs.
if (index == editor_index)
{
// Layer only auto-saves when it is destroyed.
m_layer->Save();
// There can be multiple ini loaded for a game, only replace the one related to the game
// ini being edited.
for (int i = 0; i < m_local_tab->count(); i++)
{
if (m_local_tab->tabText(i).toStdString() == m_game_id + ".ini")
{
m_local_tab->removeTab(i);
auto* edit = new GameConfigEdit(
nullptr,
QString::fromStdString(File::GetUserPath(D_GAMESETTINGS_IDX) + m_game_id + ".ini"),
false);
m_local_tab->insertTab(i, edit, QString::fromStdString(m_game_id + ".ini"));
break;
}
}
}
// Update other tabs after using ini editor.
if (m_prev_tab_index == editor_index)
{
// Load won't clear deleted keys, so everything is wiped before loading.
m_layer->DeleteAllKeys();
m_layer->Load();
Config::OnConfigChanged();
}
m_prev_tab_index = index;
});
const QString help_msg = tr(
"Italics mark default game settings, bold marks user settings.\nRight-click to remove user "
"settings.\nGraphics tabs don't display the value of a default game setting.\nAnti-Aliasing "
"settings are disabled when the global graphics backend doesn't "
"match the game setting.");
auto help_icon = style()->standardIcon(QStyle::SP_MessageBoxQuestion);
auto* help_label = new QLabel(tr("These settings override core Dolphin settings."));
help_label->setToolTip(help_msg);
auto help_label_icon = new QLabel();
help_label_icon->setPixmap(help_icon.pixmap(12, 12));
help_label_icon->setToolTip(help_msg);
auto* help_layout = new QHBoxLayout();
help_layout->addWidget(help_label);
help_layout->addWidget(help_label_icon);
help_layout->addStretch();
layout->addLayout(help_layout);
layout->addWidget(tab_widget);
setLayout(layout);
}
void GameConfigWidget::ConnectWidgets()
GameConfigWidget::~GameConfigWidget()
{
// Buttons
connect(m_refresh_config, &QPushButton::clicked, this, &GameConfigWidget::LoadSettings);
// Destructor saves the layer to file.
m_layer.reset();
for (QCheckBox* box :
{m_enable_dual_core, m_enable_mmu, m_enable_fprf, m_sync_gpu, m_emulate_disc_speed,
m_use_dsp_hle, m_manual_texture_sampling, m_use_monoscopic_shadows})
connect(box, &QCheckBox::stateChanged, this, &GameConfigWidget::SaveSettings);
connect(m_deterministic_dual_core, &QComboBox::currentIndexChanged, this,
&GameConfigWidget::SaveSettings);
connect(m_depth_slider, &QSlider::valueChanged, this, &GameConfigWidget::SaveSettings);
connect(m_convergence_spin, &QSpinBox::valueChanged, this, &GameConfigWidget::SaveSettings);
}
void GameConfigWidget::LoadCheckBox(QCheckBox* checkbox, const std::string& section,
const std::string& key, bool reverse)
{
bool checked;
if (m_gameini_local.GetOrCreateSection(section)->Get(key, &checked))
return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked);
if (m_gameini_default.GetOrCreateSection(section)->Get(key, &checked))
return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked);
checkbox->setCheckState(Qt::PartiallyChecked);
}
void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& section,
const std::string& key, bool reverse)
{
// Delete any existing entries from the local gameini if checkbox is undetermined.
// Otherwise, write the current value to the local gameini if the value differs from the default
// gameini values.
// Delete any existing entry from the local gameini if the value does not differ from the default
// gameini value.
if (checkbox->checkState() == Qt::PartiallyChecked)
// If a game is running and the game properties window is closed, update local game layer with
// any new changes. Not sure if doing it more frequently is safe.
auto local_layer = Config::GetLayer(Config::LayerType::LocalGame);
if (local_layer && SConfig::GetInstance().GetGameID() == m_game_id)
{
m_gameini_local.DeleteKey(section, key);
return;
local_layer->DeleteAllKeys();
local_layer->Load();
Config::OnConfigChanged();
}
bool checked = (checkbox->checkState() == Qt::Checked) ^ reverse;
if (m_gameini_default.Exists(section, key))
{
bool default_value;
m_gameini_default.GetOrCreateSection(section)->Get(key, &default_value);
if (default_value != checked)
m_gameini_local.GetOrCreateSection(section)->Set(key, checked);
else
m_gameini_local.DeleteKey(section, key);
return;
}
m_gameini_local.GetOrCreateSection(section)->Set(key, checked);
// Delete empty configs
if (File::GetSize(m_gameini_local_path.toStdString()) == 0)
File::Delete(m_gameini_local_path.toStdString());
}
void GameConfigWidget::LoadSettings()
{
// Reload config
m_gameini_local = SConfig::LoadLocalGameIni(m_game_id, m_game.GetRevision());
m_gameini_default = SConfig::LoadDefaultGameIni(m_game_id, m_game.GetRevision());
// Load globals
auto update_bool = [this](auto config, bool reverse = false) {
const Config::Location& setting = config->GetLocation();
// Load game-specific settings
// Don't overwrite local with global
if (m_layer->Exists(setting) || !m_global_layer->Exists(setting))
return;
// Core
LoadCheckBox(m_enable_dual_core, "Core", "CPUThread");
LoadCheckBox(m_enable_mmu, "Core", "MMU");
LoadCheckBox(m_enable_fprf, "Core", "FPRF");
LoadCheckBox(m_sync_gpu, "Core", "SyncGPU");
LoadCheckBox(m_emulate_disc_speed, "Core", "FastDiscSpeed", true);
LoadCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
LoadCheckBox(m_manual_texture_sampling, "Video_Hacks", "FastTextureSampling", true);
std::optional<bool> value = m_global_layer->Get<bool>(config->GetLocation());
std::string determinism_mode;
if (value.has_value())
{
const QSignalBlocker blocker(config);
config->setChecked(value.value() ^ reverse);
}
};
int determinism_index = DETERMINISM_NOT_SET_INDEX;
auto update_int = [this](auto config) {
const Config::Location& setting = config->GetLocation();
m_gameini_default.GetIfExists("Core", "GPUDeterminismMode", &determinism_mode);
m_gameini_local.GetIfExists("Core", "GPUDeterminismMode", &determinism_mode);
if (m_layer->Exists(setting) || !m_global_layer->Exists(setting))
return;
if (determinism_mode == DETERMINISM_AUTO_STRING)
std::optional<int> value = m_global_layer->Get<int>(setting);
if (value.has_value())
{
const QSignalBlocker blocker(config);
config->setValue(value.value());
}
};
for (ConfigBool* config : {m_enable_dual_core, m_enable_mmu, m_enable_fprf, m_sync_gpu,
m_use_dsp_hle, m_use_monoscopic_shadows})
{
determinism_index = DETERMINISM_AUTO_INDEX;
}
else if (determinism_mode == DETERMINISM_NONE_STRING)
{
determinism_index = DETERMINISM_NONE_INDEX;
}
else if (determinism_mode == DETERMINISM_FAKE_COMPLETION_STRING)
{
determinism_index = DETERMINISM_FAKE_COMPLETION_INDEX;
update_bool(config);
}
m_deterministic_dual_core->setCurrentIndex(determinism_index);
update_bool(m_emulate_disc_speed, true);
// Stereoscopy
int depth_percentage = 100;
m_gameini_default.GetIfExists("Video_Stereoscopy", "StereoDepthPercentage", &depth_percentage);
m_gameini_local.GetIfExists("Video_Stereoscopy", "StereoDepthPercentage", &depth_percentage);
m_depth_slider->setValue(depth_percentage);
int convergence = 0;
m_gameini_default.GetIfExists("Video_Stereoscopy", "StereoConvergence", &convergence);
m_gameini_local.GetIfExists("Video_Stereoscopy", "StereoConvergence", &convergence);
m_convergence_spin->setValue(convergence);
LoadCheckBox(m_use_monoscopic_shadows, "Video_Stereoscopy", "StereoEFBMonoDepth");
update_int(m_depth_slider);
update_int(m_convergence_spin);
}
void GameConfigWidget::SaveSettings()
void GameConfigWidget::SetItalics()
{
// Core
SaveCheckBox(m_enable_dual_core, "Core", "CPUThread");
SaveCheckBox(m_enable_mmu, "Core", "MMU");
SaveCheckBox(m_enable_fprf, "Core", "FPRF");
SaveCheckBox(m_sync_gpu, "Core", "SyncGPU");
SaveCheckBox(m_emulate_disc_speed, "Core", "FastDiscSpeed", true);
SaveCheckBox(m_use_dsp_hle, "Core", "DSPHLE");
SaveCheckBox(m_manual_texture_sampling, "Video_Hacks", "FastTextureSampling", true);
// Mark system game settings with italics. Called once because it should never change.
auto italics = [this](auto config) {
if (!m_global_layer->Exists(config->GetLocation()))
return;
int determinism_num = m_deterministic_dual_core->currentIndex();
QFont ifont = config->font();
ifont.setItalic(true);
config->setFont(ifont);
};
std::string determinism_mode = DETERMINISM_NOT_SET_STRING;
for (auto* config : findChildren<ConfigBool*>())
italics(config);
for (auto* config : findChildren<ConfigSlider*>())
italics(config);
for (auto* config : findChildren<ConfigInteger*>())
italics(config);
for (auto* config : findChildren<ConfigRadioInt*>())
italics(config);
for (auto* config : findChildren<ConfigChoice*>())
italics(config);
for (auto* config : findChildren<ConfigStringChoice*>())
italics(config);
switch (determinism_num)
for (auto* config : findChildren<ConfigComplexChoice*>())
{
case DETERMINISM_AUTO_INDEX:
determinism_mode = DETERMINISM_AUTO_STRING;
break;
case DETERMINISM_NONE_INDEX:
determinism_mode = DETERMINISM_NONE_STRING;
break;
case DETERMINISM_FAKE_COMPLETION_INDEX:
determinism_mode = DETERMINISM_FAKE_COMPLETION_STRING;
break;
}
if (determinism_mode != DETERMINISM_NOT_SET_STRING)
{
std::string default_mode = DETERMINISM_NOT_SET_STRING;
if (!(m_gameini_default.GetIfExists("Core", "GPUDeterminismMode", &default_mode) &&
default_mode == determinism_mode))
std::pair<Config::Location, Config::Location> location = config->GetLocation();
if (m_global_layer->Exists(location.first) || m_global_layer->Exists(location.second))
{
m_gameini_local.GetOrCreateSection("Core")->Set("GPUDeterminismMode", determinism_mode);
QFont ifont = config->font();
ifont.setItalic(true);
config->setFont(ifont);
}
}
else
{
m_gameini_local.DeleteKey("Core", "GPUDeterminismMode");
}
// Stereoscopy
int depth_percentage = m_depth_slider->value();
if (depth_percentage != 100)
{
int default_value = 0;
if (!(m_gameini_default.GetIfExists("Video_Stereoscopy", "StereoDepthPercentage",
&default_value) &&
default_value == depth_percentage))
{
m_gameini_local.GetOrCreateSection("Video_Stereoscopy")
->Set("StereoDepthPercentage", depth_percentage);
}
}
int convergence = m_convergence_spin->value();
if (convergence != 0)
{
int default_value = 0;
if (!(m_gameini_default.GetIfExists("Video_Stereoscopy", "StereoConvergence", &default_value) &&
default_value == convergence))
{
m_gameini_local.GetOrCreateSection("Video_Stereoscopy")
->Set("StereoConvergence", convergence);
}
}
SaveCheckBox(m_use_monoscopic_shadows, "Video_Stereoscopy", "StereoEFBMonoDepth");
bool success = m_gameini_local.Save(m_gameini_local_path.toStdString());
// If the resulting file is empty, delete it. Kind of a hack, but meh.
if (success && File::GetSize(m_gameini_local_path.toStdString()) == 0)
File::Delete(m_gameini_local_path.toStdString());
}

View file

@ -7,19 +7,21 @@
#include <QString>
#include <QWidget>
#include "Common/IniFile.h"
namespace UICommon
{
class GameFile;
}
class QCheckBox;
class QComboBox;
namespace Config
{
class Layer;
} // namespace Config
class ConfigBool;
class ConfigInteger;
class ConfigSlider;
class ConfigStringChoice;
class QPushButton;
class QSlider;
class QSpinBox;
class QTabWidget;
class GameConfigWidget : public QWidget
@ -27,45 +29,33 @@ class GameConfigWidget : public QWidget
Q_OBJECT
public:
explicit GameConfigWidget(const UICommon::GameFile& game);
~GameConfigWidget();
private:
void CreateWidgets();
void ConnectWidgets();
void LoadSettings();
void SaveSettings();
void SetItalics();
void SaveCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key,
bool reverse = false);
void LoadCheckBox(QCheckBox* checkbox, const std::string& section, const std::string& key,
bool reverse = false);
QString m_gameini_sys_path;
QString m_gameini_local_path;
QTabWidget* m_default_tab;
QTabWidget* m_local_tab;
QCheckBox* m_enable_dual_core;
QCheckBox* m_enable_mmu;
QCheckBox* m_enable_fprf;
QCheckBox* m_sync_gpu;
QCheckBox* m_emulate_disc_speed;
QCheckBox* m_use_dsp_hle;
QCheckBox* m_use_monoscopic_shadows;
QCheckBox* m_manual_texture_sampling;
ConfigBool* m_enable_dual_core;
ConfigBool* m_enable_mmu;
ConfigBool* m_enable_fprf;
ConfigBool* m_sync_gpu;
ConfigBool* m_emulate_disc_speed;
ConfigBool* m_use_dsp_hle;
ConfigBool* m_use_monoscopic_shadows;
QPushButton* m_refresh_config;
QComboBox* m_deterministic_dual_core;
QSlider* m_depth_slider;
QSpinBox* m_convergence_spin;
ConfigStringChoice* m_deterministic_dual_core;
ConfigSlider* m_depth_slider;
ConfigInteger* m_convergence_spin;
const UICommon::GameFile& m_game;
std::string m_game_id;
Common::IniFile m_gameini_local;
Common::IniFile m_gameini_default;
std::unique_ptr<Config::Layer> m_layer;
std::unique_ptr<Config::Layer> m_global_layer;
int m_prev_tab_index = 0;
};

View file

@ -206,7 +206,7 @@ void GeckoCodeWidget::OnItemChanged(QListWidgetItem* item)
m_gecko_codes[index].enabled = (item->checkState() == Qt::Checked);
if (!m_restart_required)
Gecko::SetActiveCodes(m_gecko_codes);
Gecko::SetActiveCodes(m_gecko_codes, m_game_id);
SaveCodes();
}
@ -318,20 +318,14 @@ void GeckoCodeWidget::SortAlphabetically()
void GeckoCodeWidget::SortEnabledCodesFirst()
{
std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) {
return a.enabled && a.enabled != b.enabled;
});
std::ranges::stable_partition(m_gecko_codes, std::identity{}, &Gecko::GeckoCode::enabled);
UpdateList();
SaveCodes();
}
void GeckoCodeWidget::SortDisabledCodesFirst()
{
std::stable_sort(m_gecko_codes.begin(), m_gecko_codes.end(), [](const auto& a, const auto& b) {
return !a.enabled && a.enabled != b.enabled;
});
std::ranges::stable_partition(m_gecko_codes, std::logical_not{}, &Gecko::GeckoCode::enabled);
UpdateList();
SaveCodes();
}

View file

@ -3,11 +3,9 @@
#include "DolphinQt/Config/Graphics/AdvancedWidget.h"
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QSpinBox>
#include <QVBoxLayout>
#include "Core/Config/GraphicsSettings.h"
@ -19,6 +17,7 @@
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
#include "DolphinQt/Config/GameConfigWidget.h"
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
@ -29,7 +28,6 @@
AdvancedWidget::AdvancedWidget(GraphicsWindow* parent)
{
CreateWidgets();
LoadSettings();
ConnectWidgets();
AddDescriptions();
@ -37,17 +35,30 @@ AdvancedWidget::AdvancedWidget(GraphicsWindow* parent)
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
OnEmulationStateChanged(state != Core::State::Uninitialized);
});
connect(m_manual_texture_sampling, &QCheckBox::toggled, [this, parent] {
SaveSettings();
emit parent->UseFastTextureSamplingChanged();
});
connect(m_manual_texture_sampling, &QCheckBox::toggled,
[this, parent] { emit parent->UseFastTextureSamplingChanged(); });
OnBackendChanged();
OnEmulationStateChanged(!Core::IsUninitialized(Core::System::GetInstance()));
}
AdvancedWidget::AdvancedWidget(GameConfigWidget* parent, Config::Layer* layer) : m_game_layer(layer)
{
CreateWidgets();
ConnectWidgets();
AddDescriptions();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
OnEmulationStateChanged(state != Core::State::Uninitialized);
});
OnEmulationStateChanged(Core::GetState(Core::System::GetInstance()) !=
Core::State::Uninitialized);
}
void AdvancedWidget::CreateWidgets()
{
const bool local_edit = m_game_layer != nullptr;
auto* main_layout = new QVBoxLayout;
// Performance
@ -55,17 +66,19 @@ void AdvancedWidget::CreateWidgets()
auto* performance_layout = new QGridLayout();
performance_box->setLayout(performance_layout);
m_show_fps = new ConfigBool(tr("Show FPS"), Config::GFX_SHOW_FPS);
m_show_ftimes = new ConfigBool(tr("Show Frame Times"), Config::GFX_SHOW_FTIMES);
m_show_vps = new ConfigBool(tr("Show VPS"), Config::GFX_SHOW_VPS);
m_show_vtimes = new ConfigBool(tr("Show VBlank Times"), Config::GFX_SHOW_VTIMES);
m_show_graphs = new ConfigBool(tr("Show Performance Graphs"), Config::GFX_SHOW_GRAPHS);
m_show_speed = new ConfigBool(tr("Show % Speed"), Config::GFX_SHOW_SPEED);
m_show_speed_colors = new ConfigBool(tr("Show Speed Colors"), Config::GFX_SHOW_SPEED_COLORS);
m_perf_samp_window = new ConfigInteger(0, 10000, Config::GFX_PERF_SAMP_WINDOW, 100);
m_show_fps = new ConfigBool(tr("Show FPS"), Config::GFX_SHOW_FPS, m_game_layer);
m_show_ftimes = new ConfigBool(tr("Show Frame Times"), Config::GFX_SHOW_FTIMES, m_game_layer);
m_show_vps = new ConfigBool(tr("Show VPS"), Config::GFX_SHOW_VPS, m_game_layer);
m_show_vtimes = new ConfigBool(tr("Show VBlank Times"), Config::GFX_SHOW_VTIMES, m_game_layer);
m_show_graphs =
new ConfigBool(tr("Show Performance Graphs"), Config::GFX_SHOW_GRAPHS, m_game_layer);
m_show_speed = new ConfigBool(tr("Show % Speed"), Config::GFX_SHOW_SPEED, m_game_layer);
m_show_speed_colors =
new ConfigBool(tr("Show Speed Colors"), Config::GFX_SHOW_SPEED_COLORS, m_game_layer);
m_perf_samp_window = new ConfigInteger(0, 10000, Config::GFX_PERF_SAMP_WINDOW, m_game_layer, 100);
m_perf_samp_window->SetTitle(tr("Performance Sample Window (ms)"));
m_log_render_time =
new ConfigBool(tr("Log Render Time to File"), Config::GFX_LOG_RENDER_TIME_TO_FILE);
m_log_render_time = new ConfigBool(tr("Log Render Time to File"),
Config::GFX_LOG_RENDER_TIME_TO_FILE, m_game_layer);
performance_layout->addWidget(m_show_fps, 0, 0);
performance_layout->addWidget(m_show_ftimes, 0, 1);
@ -83,14 +96,16 @@ void AdvancedWidget::CreateWidgets()
auto* debugging_layout = new QGridLayout();
debugging_box->setLayout(debugging_layout);
m_enable_wireframe = new ConfigBool(tr("Enable Wireframe"), Config::GFX_ENABLE_WIREFRAME);
m_show_statistics = new ConfigBool(tr("Show Statistics"), Config::GFX_OVERLAY_STATS);
m_show_proj_statistics =
new ConfigBool(tr("Show Projection Statistics"), Config::GFX_OVERLAY_PROJ_STATS);
m_enable_wireframe =
new ConfigBool(tr("Enable Wireframe"), Config::GFX_ENABLE_WIREFRAME, m_game_layer);
m_show_statistics =
new ConfigBool(tr("Show Statistics"), Config::GFX_OVERLAY_STATS, m_game_layer);
m_show_proj_statistics = new ConfigBool(tr("Show Projection Statistics"),
Config::GFX_OVERLAY_PROJ_STATS, m_game_layer);
m_enable_format_overlay =
new ConfigBool(tr("Texture Format Overlay"), Config::GFX_TEXFMT_OVERLAY_ENABLE);
m_enable_api_validation =
new ConfigBool(tr("Enable API Validation Layers"), Config::GFX_ENABLE_VALIDATION_LAYER);
new ConfigBool(tr("Texture Format Overlay"), Config::GFX_TEXFMT_OVERLAY_ENABLE, m_game_layer);
m_enable_api_validation = new ConfigBool(tr("Enable API Validation Layers"),
Config::GFX_ENABLE_VALIDATION_LAYER, m_game_layer);
debugging_layout->addWidget(m_enable_wireframe, 0, 0);
debugging_layout->addWidget(m_show_statistics, 0, 1);
@ -103,14 +118,25 @@ void AdvancedWidget::CreateWidgets()
auto* utility_layout = new QGridLayout();
utility_box->setLayout(utility_layout);
m_load_custom_textures = new ConfigBool(tr("Load Custom Textures"), Config::GFX_HIRES_TEXTURES);
m_prefetch_custom_textures =
new ConfigBool(tr("Prefetch Custom Textures"), Config::GFX_CACHE_HIRES_TEXTURES);
m_load_custom_textures =
new ConfigBool(tr("Load Custom Textures"), Config::GFX_HIRES_TEXTURES, m_game_layer);
m_prefetch_custom_textures = new ConfigBool(tr("Prefetch Custom Textures"),
Config::GFX_CACHE_HIRES_TEXTURES, m_game_layer);
m_prefetch_custom_textures->setEnabled(m_load_custom_textures->isChecked());
m_dump_efb_target = new ConfigBool(tr("Dump EFB Target"), Config::GFX_DUMP_EFB_TARGET);
m_dump_xfb_target = new ConfigBool(tr("Dump XFB Target"), Config::GFX_DUMP_XFB_TARGET);
m_disable_vram_copies =
new ConfigBool(tr("Disable EFB VRAM Copies"), Config::GFX_HACK_DISABLE_COPY_TO_VRAM);
m_enable_graphics_mods = new ToolTipCheckBox(tr("Enable Graphics Mods"));
if (local_edit)
{
// It's hazardous to accidentally set these in a game ini.
m_dump_efb_target->setEnabled(false);
m_dump_xfb_target->setEnabled(false);
}
m_disable_vram_copies = new ConfigBool(tr("Disable EFB VRAM Copies"),
Config::GFX_HACK_DISABLE_COPY_TO_VRAM, m_game_layer);
m_enable_graphics_mods =
new ConfigBool(tr("Enable Graphics Mods"), Config::GFX_MODS_ENABLE, m_game_layer);
utility_layout->addWidget(m_load_custom_textures, 0, 0);
utility_layout->addWidget(m_prefetch_custom_textures, 0, 1);
@ -128,6 +154,16 @@ void AdvancedWidget::CreateWidgets()
m_dump_textures = new ConfigBool(tr("Enable"), Config::GFX_DUMP_TEXTURES);
m_dump_base_textures = new ConfigBool(tr("Dump Base Textures"), Config::GFX_DUMP_BASE_TEXTURES);
m_dump_mip_textures = new ConfigBool(tr("Dump Mip Maps"), Config::GFX_DUMP_MIP_TEXTURES);
m_dump_mip_textures->setEnabled(m_dump_textures->isChecked());
m_dump_base_textures->setEnabled(m_dump_textures->isChecked());
if (local_edit)
{
// It's hazardous to accidentally set dumping in a game ini.
m_dump_textures->setEnabled(false);
m_dump_base_textures->setEnabled(false);
m_dump_mip_textures->setEnabled(false);
}
texture_dump_layout->addWidget(m_dump_textures, 0, 0);
@ -142,18 +178,22 @@ void AdvancedWidget::CreateWidgets()
m_frame_dumps_resolution_type =
new ConfigChoice({tr("Window Resolution"), tr("Aspect Ratio Corrected Internal Resolution"),
tr("Raw Internal Resolution")},
Config::GFX_FRAME_DUMPS_RESOLUTION_TYPE);
m_dump_use_ffv1 = new ConfigBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1);
m_dump_bitrate = new ConfigInteger(0, 1000000, Config::GFX_BITRATE_KBPS, 1000);
m_png_compression_level = new ConfigInteger(0, 9, Config::GFX_PNG_COMPRESSION_LEVEL);
Config::GFX_FRAME_DUMPS_RESOLUTION_TYPE, m_game_layer);
m_png_compression_level =
new ConfigInteger(0, 9, Config::GFX_PNG_COMPRESSION_LEVEL, m_game_layer);
dump_layout->addWidget(new QLabel(tr("Resolution Type:")), 0, 0);
dump_layout->addWidget(m_frame_dumps_resolution_type, 0, 1);
#if defined(HAVE_FFMPEG)
m_dump_use_ffv1 =
new ConfigBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1, m_game_layer);
m_dump_bitrate = new ConfigInteger(0, 1000000, Config::GFX_BITRATE_KBPS, m_game_layer, 1000);
m_dump_bitrate->setEnabled(!m_dump_use_ffv1->isChecked());
dump_layout->addWidget(m_dump_use_ffv1, 1, 0);
dump_layout->addWidget(new QLabel(tr("Bitrate (kbps):")), 2, 0);
dump_layout->addWidget(m_dump_bitrate, 2, 1);
#endif
dump_layout->addWidget(new QLabel(tr("PNG Compression Level:")), 3, 0);
m_png_compression_level->SetTitle(tr("PNG Compression Level"));
dump_layout->addWidget(m_png_compression_level, 3, 1);
@ -163,14 +203,16 @@ void AdvancedWidget::CreateWidgets()
auto* misc_layout = new QGridLayout();
misc_box->setLayout(misc_layout);
m_enable_cropping = new ConfigBool(tr("Crop"), Config::GFX_CROP);
m_enable_prog_scan = new ToolTipCheckBox(tr("Enable Progressive Scan"));
m_backend_multithreading =
new ConfigBool(tr("Backend Multithreading"), Config::GFX_BACKEND_MULTITHREADING);
m_enable_cropping = new ConfigBool(tr("Crop"), Config::GFX_CROP, m_game_layer);
m_enable_prog_scan =
new ConfigBool(tr("Enable Progressive Scan"), Config::SYSCONF_PROGRESSIVE_SCAN, m_game_layer);
m_backend_multithreading = new ConfigBool(tr("Backend Multithreading"),
Config::GFX_BACKEND_MULTITHREADING, m_game_layer);
m_prefer_vs_for_point_line_expansion = new ConfigBool(
// i18n: VS is short for vertex shaders.
tr("Prefer VS for Point/Line Expansion"), Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION);
m_cpu_cull = new ConfigBool(tr("Cull Vertices on the CPU"), Config::GFX_CPU_CULL);
tr("Prefer VS for Point/Line Expansion"), Config::GFX_PREFER_VS_FOR_LINE_POINT_EXPANSION,
m_game_layer);
m_cpu_cull = new ConfigBool(tr("Cull Vertices on the CPU"), Config::GFX_CPU_CULL, m_game_layer);
misc_layout->addWidget(m_enable_cropping, 0, 0);
misc_layout->addWidget(m_enable_prog_scan, 0, 1);
@ -179,7 +221,7 @@ void AdvancedWidget::CreateWidgets()
misc_layout->addWidget(m_cpu_cull, 2, 0);
#ifdef _WIN32
m_borderless_fullscreen =
new ConfigBool(tr("Borderless Fullscreen"), Config::GFX_BORDERLESS_FULLSCREEN);
new ConfigBool(tr("Borderless Fullscreen"), Config::GFX_BORDERLESS_FULLSCREEN, m_game_layer);
misc_layout->addWidget(m_borderless_fullscreen, 2, 1);
#endif
@ -189,10 +231,10 @@ void AdvancedWidget::CreateWidgets()
auto* experimental_layout = new QGridLayout();
experimental_box->setLayout(experimental_layout);
m_defer_efb_access_invalidation =
new ConfigBool(tr("Defer EFB Cache Invalidation"), Config::GFX_HACK_EFB_DEFER_INVALIDATION);
m_manual_texture_sampling =
new ConfigBool(tr("Manual Texture Sampling"), Config::GFX_HACK_FAST_TEXTURE_SAMPLING, true);
m_defer_efb_access_invalidation = new ConfigBool(
tr("Defer EFB Cache Invalidation"), Config::GFX_HACK_EFB_DEFER_INVALIDATION, m_game_layer);
m_manual_texture_sampling = new ConfigBool(
tr("Manual Texture Sampling"), Config::GFX_HACK_FAST_TEXTURE_SAMPLING, m_game_layer, true);
experimental_layout->addWidget(m_defer_efb_access_invalidation, 0, 0);
experimental_layout->addWidget(m_manual_texture_sampling, 0, 1);
@ -211,34 +253,19 @@ void AdvancedWidget::CreateWidgets()
void AdvancedWidget::ConnectWidgets()
{
connect(m_load_custom_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_dump_use_ffv1, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_enable_prog_scan, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_dump_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
connect(m_enable_graphics_mods, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings);
}
connect(m_load_custom_textures, &QCheckBox::toggled, this,
[this](bool checked) { m_prefetch_custom_textures->setEnabled(checked); });
connect(m_dump_textures, &QCheckBox::toggled, this, [this](bool checked) {
m_dump_mip_textures->setEnabled(checked);
m_dump_base_textures->setEnabled(checked);
});
connect(m_enable_graphics_mods, &QCheckBox::toggled, this,
[this](bool checked) { emit Settings::Instance().EnableGfxModsChanged(checked); });
void AdvancedWidget::LoadSettings()
{
m_prefetch_custom_textures->setEnabled(Config::Get(Config::GFX_HIRES_TEXTURES));
m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1));
m_enable_prog_scan->setChecked(Config::Get(Config::SYSCONF_PROGRESSIVE_SCAN));
m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES));
m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES));
SignalBlocking(m_enable_graphics_mods)->setChecked(Settings::Instance().GetGraphicModsEnabled());
}
void AdvancedWidget::SaveSettings()
{
m_prefetch_custom_textures->setEnabled(Config::Get(Config::GFX_HIRES_TEXTURES));
m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1));
Config::SetBase(Config::SYSCONF_PROGRESSIVE_SCAN, m_enable_prog_scan->isChecked());
m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES));
m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES));
Settings::Instance().SetGraphicModsEnabled(m_enable_graphics_mods->isChecked());
#if defined(HAVE_FFMPEG)
connect(m_dump_use_ffv1, &QCheckBox::toggled, this,
[this](bool checked) { m_dump_bitrate->setEnabled(!checked); });
#endif
}
void AdvancedWidget::OnBackendChanged()

View file

@ -8,22 +8,22 @@
class ConfigBool;
class ConfigChoice;
class ConfigInteger;
class GameConfigWidget;
class GraphicsWindow;
class QCheckBox;
class QComboBox;
class QSpinBox;
class ToolTipCheckBox;
namespace Config
{
class Layer;
} // namespace Config
class AdvancedWidget final : public QWidget
{
Q_OBJECT
public:
explicit AdvancedWidget(GraphicsWindow* parent);
AdvancedWidget(GameConfigWidget* parent, Config::Layer* layer);
private:
void LoadSettings();
void SaveSettings();
void CreateWidgets();
void ConnectWidgets();
void AddDescriptions();
@ -52,7 +52,7 @@ private:
ConfigBool* m_dump_xfb_target;
ConfigBool* m_disable_vram_copies;
ConfigBool* m_load_custom_textures;
ToolTipCheckBox* m_enable_graphics_mods;
ConfigBool* m_enable_graphics_mods;
// Texture dumping
ConfigBool* m_dump_textures;
@ -67,7 +67,7 @@ private:
// Misc
ConfigBool* m_enable_cropping;
ToolTipCheckBox* m_enable_prog_scan;
ConfigBool* m_enable_prog_scan;
ConfigBool* m_backend_multithreading;
ConfigBool* m_prefer_vs_for_point_line_expansion;
ConfigBool* m_cpu_cull;
@ -76,4 +76,6 @@ private:
// Experimental
ConfigBool* m_defer_efb_access_invalidation;
ConfigBool* m_manual_texture_sampling;
Config::Layer* m_game_layer = nullptr;
};

View file

@ -11,6 +11,8 @@
#include <QPushButton>
#include <QVBoxLayout>
#include "Common/CommonTypes.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/ConfigManager.h"
@ -18,6 +20,7 @@
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include "DolphinQt/Config/GameConfigWidget.h"
#include "DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.h"
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
#include "DolphinQt/Config/Graphics/PostProcessingConfigWindow.h"
@ -31,31 +34,43 @@
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
EnhancementsWidget::EnhancementsWidget(GraphicsWindow* parent) : m_block_save(false)
EnhancementsWidget::EnhancementsWidget(GraphicsWindow* parent)
{
CreateWidgets();
LoadSettings();
LoadPPShaders();
ConnectWidgets();
AddDescriptions();
connect(parent, &GraphicsWindow::BackendChanged,
[this](const QString& backend) { LoadSettings(); });
connect(parent, &GraphicsWindow::UseFastTextureSamplingChanged, this,
&EnhancementsWidget::LoadSettings);
connect(parent, &GraphicsWindow::UseGPUTextureDecodingChanged, this,
&EnhancementsWidget::LoadSettings);
// BackendChanged is called by parent on window creation.
connect(parent, &GraphicsWindow::BackendChanged, this, &EnhancementsWidget::OnBackendChanged);
connect(parent, &GraphicsWindow::UseFastTextureSamplingChanged, this, [this]() {
m_texture_filtering_combo->setEnabled(ReadSetting(Config::GFX_HACK_FAST_TEXTURE_SAMPLING));
});
connect(parent, &GraphicsWindow::UseGPUTextureDecodingChanged, this, [this]() {
m_arbitrary_mipmap_detection->setEnabled(!ReadSetting(Config::GFX_ENABLE_GPU_TEXTURE_DECODING));
});
}
constexpr int TEXTURE_FILTERING_DEFAULT = 0;
constexpr int TEXTURE_FILTERING_ANISO_2X = 1;
constexpr int TEXTURE_FILTERING_ANISO_4X = 2;
constexpr int TEXTURE_FILTERING_ANISO_8X = 3;
constexpr int TEXTURE_FILTERING_ANISO_16X = 4;
constexpr int TEXTURE_FILTERING_FORCE_NEAREST = 5;
constexpr int TEXTURE_FILTERING_FORCE_LINEAR = 6;
constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X = 7;
constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X = 8;
constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X = 9;
constexpr int TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X = 10;
EnhancementsWidget::EnhancementsWidget(GameConfigWidget* parent, Config::Layer* layer)
: m_game_layer(layer)
{
CreateWidgets();
LoadPPShaders();
ConnectWidgets();
AddDescriptions();
connect(&Settings::Instance(), &Settings::ConfigChanged, this,
&EnhancementsWidget::OnConfigChanged);
}
constexpr int ANISO_DEFAULT = 0;
constexpr int ANISO_2X = 1;
constexpr int ANISO_4X = 2;
constexpr int ANISO_8X = 3;
constexpr int ANISO_16X = 4;
constexpr int FILTERING_DEFAULT = 0;
constexpr int FILTERING_NEAREST = 1;
constexpr int FILTERING_LINEAR = 2;
void EnhancementsWidget::CreateWidgets()
{
@ -83,7 +98,7 @@ void EnhancementsWidget::CreateWidgets()
// If the current scale is greater than the max scale in the ini, add sufficient options so that
// when the settings are saved we don't lose the user-modified value from the ini.
const int max_efb_scale =
std::max(Config::Get(Config::GFX_EFB_SCALE), Config::Get(Config::GFX_MAX_EFB_SCALE));
std::max(ReadSetting(Config::GFX_EFB_SCALE), ReadSetting(Config::GFX_MAX_EFB_SCALE));
for (int scale = static_cast<int>(resolution_options.size()); scale <= max_efb_scale; scale++)
{
const QString scale_text = QString::number(scale);
@ -104,61 +119,60 @@ void EnhancementsWidget::CreateWidgets()
}
}
m_ir_combo = new ConfigChoice(resolution_options, Config::GFX_EFB_SCALE);
m_ir_combo = new ConfigChoice(resolution_options, Config::GFX_EFB_SCALE, m_game_layer);
m_ir_combo->setMaxVisibleItems(visible_resolution_option_count);
m_aa_combo = new ToolTipComboBox();
m_aa_combo = new ConfigComplexChoice(Config::GFX_MSAA, Config::GFX_SSAA, m_game_layer);
m_aa_combo->Add(tr("None"), (u32)1, false);
m_texture_filtering_combo = new ToolTipComboBox();
m_texture_filtering_combo->addItem(tr("Default"), TEXTURE_FILTERING_DEFAULT);
m_texture_filtering_combo->addItem(tr("2x Anisotropic"), TEXTURE_FILTERING_ANISO_2X);
m_texture_filtering_combo->addItem(tr("4x Anisotropic"), TEXTURE_FILTERING_ANISO_4X);
m_texture_filtering_combo->addItem(tr("8x Anisotropic"), TEXTURE_FILTERING_ANISO_8X);
m_texture_filtering_combo->addItem(tr("16x Anisotropic"), TEXTURE_FILTERING_ANISO_16X);
m_texture_filtering_combo->addItem(tr("Force Nearest"), TEXTURE_FILTERING_FORCE_NEAREST);
m_texture_filtering_combo->addItem(tr("Force Linear"), TEXTURE_FILTERING_FORCE_LINEAR);
m_texture_filtering_combo->addItem(tr("Force Linear and 2x Anisotropic"),
TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X);
m_texture_filtering_combo->addItem(tr("Force Linear and 4x Anisotropic"),
TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X);
m_texture_filtering_combo->addItem(tr("Force Linear and 8x Anisotropic"),
TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X);
m_texture_filtering_combo->addItem(tr("Force Linear and 16x Anisotropic"),
TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X);
m_texture_filtering_combo =
new ConfigComplexChoice(Config::GFX_ENHANCE_MAX_ANISOTROPY,
Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING, m_game_layer);
m_output_resampling_combo = new ToolTipComboBox();
m_output_resampling_combo->addItem(tr("Default"),
static_cast<int>(OutputResamplingMode::Default));
m_output_resampling_combo->addItem(tr("Bilinear"),
static_cast<int>(OutputResamplingMode::Bilinear));
m_output_resampling_combo->addItem(tr("Bicubic: B-Spline"),
static_cast<int>(OutputResamplingMode::BSpline));
m_output_resampling_combo->addItem(tr("Bicubic: Mitchell-Netravali"),
static_cast<int>(OutputResamplingMode::MitchellNetravali));
m_output_resampling_combo->addItem(tr("Bicubic: Catmull-Rom"),
static_cast<int>(OutputResamplingMode::CatmullRom));
m_output_resampling_combo->addItem(tr("Sharp Bilinear"),
static_cast<int>(OutputResamplingMode::SharpBilinear));
m_output_resampling_combo->addItem(tr("Area Sampling"),
static_cast<int>(OutputResamplingMode::AreaSampling));
m_texture_filtering_combo->Add(tr("Default"), ANISO_DEFAULT, FILTERING_DEFAULT);
m_texture_filtering_combo->Add(tr("2x Anisotropic"), ANISO_2X, FILTERING_DEFAULT);
m_texture_filtering_combo->Add(tr("4x Anisotropic"), ANISO_4X, FILTERING_DEFAULT);
m_texture_filtering_combo->Add(tr("8x Anisotropic"), ANISO_8X, FILTERING_DEFAULT);
m_texture_filtering_combo->Add(tr("16x Anisotropic"), ANISO_16X, FILTERING_DEFAULT);
m_texture_filtering_combo->Add(tr("Force Nearest"), ANISO_DEFAULT, FILTERING_NEAREST);
m_texture_filtering_combo->Add(tr("Force Linear"), ANISO_DEFAULT, FILTERING_LINEAR);
m_texture_filtering_combo->Add(tr("Force Linear and 2x Anisotropic"), ANISO_2X, FILTERING_LINEAR);
m_texture_filtering_combo->Add(tr("Force Linear and 4x Anisotropic"), ANISO_4X, FILTERING_LINEAR);
m_texture_filtering_combo->Add(tr("Force Linear and 8x Anisotropic"), ANISO_8X, FILTERING_LINEAR);
m_texture_filtering_combo->Add(tr("Force Linear and 16x Anisotropic"), ANISO_16X,
FILTERING_LINEAR);
m_texture_filtering_combo->Refresh();
m_texture_filtering_combo->setEnabled(ReadSetting(Config::GFX_HACK_FAST_TEXTURE_SAMPLING));
m_output_resampling_combo = new ConfigChoice(
{tr("Default"), tr("Bilinear"), tr("Bicubic: B-Spline"), tr("Bicubic: Mitchell-Netravali"),
tr("Bicubic: Catmull-Rom"), tr("Sharp Bilinear"), tr("Area Sampling")},
Config::GFX_ENHANCE_OUTPUT_RESAMPLING, m_game_layer);
m_configure_color_correction = new ToolTipPushButton(tr("Configure"));
m_pp_effect = new ToolTipComboBox();
m_pp_effect = new ConfigStringChoice(VideoCommon::PostProcessing::GetShaderList(),
Config::GFX_ENHANCE_POST_SHADER, m_game_layer);
m_configure_pp_effect = new NonDefaultQPushButton(tr("Configure"));
m_scaled_efb_copy = new ConfigBool(tr("Scaled EFB Copy"), Config::GFX_HACK_COPY_EFB_SCALED);
m_per_pixel_lighting =
new ConfigBool(tr("Per-Pixel Lighting"), Config::GFX_ENABLE_PIXEL_LIGHTING);
m_configure_pp_effect->setDisabled(true);
m_widescreen_hack = new ConfigBool(tr("Widescreen Hack"), Config::GFX_WIDESCREEN_HACK);
m_disable_fog = new ConfigBool(tr("Disable Fog"), Config::GFX_DISABLE_FOG);
m_scaled_efb_copy =
new ConfigBool(tr("Scaled EFB Copy"), Config::GFX_HACK_COPY_EFB_SCALED, m_game_layer);
m_per_pixel_lighting =
new ConfigBool(tr("Per-Pixel Lighting"), Config::GFX_ENABLE_PIXEL_LIGHTING, m_game_layer);
m_widescreen_hack =
new ConfigBool(tr("Widescreen Hack"), Config::GFX_WIDESCREEN_HACK, m_game_layer);
m_disable_fog = new ConfigBool(tr("Disable Fog"), Config::GFX_DISABLE_FOG, m_game_layer);
m_force_24bit_color =
new ConfigBool(tr("Force 24-Bit Color"), Config::GFX_ENHANCE_FORCE_TRUE_COLOR);
m_disable_copy_filter =
new ConfigBool(tr("Disable Copy Filter"), Config::GFX_ENHANCE_DISABLE_COPY_FILTER);
m_arbitrary_mipmap_detection = new ConfigBool(tr("Arbitrary Mipmap Detection"),
Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION);
m_hdr = new ConfigBool(tr("HDR Post-Processing"), Config::GFX_ENHANCE_HDR_OUTPUT);
new ConfigBool(tr("Force 24-Bit Color"), Config::GFX_ENHANCE_FORCE_TRUE_COLOR, m_game_layer);
m_disable_copy_filter = new ConfigBool(tr("Disable Copy Filter"),
Config::GFX_ENHANCE_DISABLE_COPY_FILTER, m_game_layer);
m_arbitrary_mipmap_detection =
new ConfigBool(tr("Arbitrary Mipmap Detection"),
Config::GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION, m_game_layer);
m_arbitrary_mipmap_detection->setEnabled(!ReadSetting(Config::GFX_ENABLE_GPU_TEXTURE_DECODING));
m_hdr = new ConfigBool(tr("HDR Post-Processing"), Config::GFX_ENHANCE_HDR_OUTPUT, m_game_layer);
int row = 0;
enhancements_layout->addWidget(new QLabel(tr("Internal Resolution:")), row, 0);
@ -209,26 +223,27 @@ void EnhancementsWidget::CreateWidgets()
m_3d_mode = new ConfigChoice({tr("Off"), tr("Side-by-Side"), tr("Top-and-Bottom"), tr("Anaglyph"),
tr("HDMI 3D"), tr("Passive")},
Config::GFX_STEREO_MODE);
m_3d_depth = new ConfigSlider(0, Config::GFX_STEREO_DEPTH_MAXIMUM, Config::GFX_STEREO_DEPTH);
Config::GFX_STEREO_MODE, m_game_layer);
m_3d_depth =
new ConfigSlider(0, Config::GFX_STEREO_DEPTH_MAXIMUM, Config::GFX_STEREO_DEPTH, m_game_layer);
m_3d_convergence = new ConfigSlider(0, Config::GFX_STEREO_CONVERGENCE_MAXIMUM,
Config::GFX_STEREO_CONVERGENCE, 100);
Config::GFX_STEREO_CONVERGENCE, m_game_layer, 100);
m_3d_swap_eyes = new ConfigBool(tr("Swap Eyes"), Config::GFX_STEREO_SWAP_EYES);
m_3d_swap_eyes = new ConfigBool(tr("Swap Eyes"), Config::GFX_STEREO_SWAP_EYES, m_game_layer);
m_3d_per_eye_resolution =
new ConfigBool(tr("Use Full Resolution Per Eye"), Config::GFX_STEREO_PER_EYE_RESOLUTION_FULL);
m_3d_per_eye_resolution = new ConfigBool(
tr("Use Full Resolution Per Eye"), Config::GFX_STEREO_PER_EYE_RESOLUTION_FULL, m_game_layer);
stereoscopy_layout->addWidget(new QLabel(tr("Stereoscopic 3D Mode:")), 0, 0);
stereoscopy_layout->addWidget(m_3d_mode, 0, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Depth:")), 1, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Depth:"), m_3d_depth), 1, 0);
stereoscopy_layout->addWidget(m_3d_depth, 1, 1);
stereoscopy_layout->addWidget(new QLabel(tr("Convergence:")), 2, 0);
stereoscopy_layout->addWidget(new ConfigSliderLabel(tr("Convergence:"), m_3d_convergence), 2, 0);
stereoscopy_layout->addWidget(m_3d_convergence, 2, 1);
stereoscopy_layout->addWidget(m_3d_swap_eyes, 3, 0);
stereoscopy_layout->addWidget(m_3d_per_eye_resolution, 4, 0);
auto current_stereo_mode = Config::Get(Config::GFX_STEREO_MODE);
auto current_stereo_mode = ReadSetting(Config::GFX_STEREO_MODE);
if (current_stereo_mode != StereoMode::SBS && current_stereo_mode != StereoMode::TAB)
m_3d_per_eye_resolution->hide();
@ -241,58 +256,53 @@ void EnhancementsWidget::CreateWidgets()
void EnhancementsWidget::ConnectWidgets()
{
connect(m_aa_combo, &QComboBox::currentIndexChanged, [this](int) { SaveSettings(); });
connect(m_texture_filtering_combo, &QComboBox::currentIndexChanged,
[this](int) { SaveSettings(); });
connect(m_output_resampling_combo, &QComboBox::currentIndexChanged,
[this](int) { SaveSettings(); });
connect(m_pp_effect, &QComboBox::currentIndexChanged, [this](int) { SaveSettings(); });
connect(m_3d_mode, &QComboBox::currentIndexChanged, [this] {
m_block_save = true;
m_configure_color_correction->setEnabled(g_Config.backend_info.bSupportsPostProcessing);
auto current_stereo_mode = Config::Get(Config::GFX_STEREO_MODE);
LoadPPShaders(current_stereo_mode);
auto current_stereo_mode = ReadSetting(Config::GFX_STEREO_MODE);
LoadPPShaders();
if (current_stereo_mode == StereoMode::SBS || current_stereo_mode == StereoMode::TAB)
m_3d_per_eye_resolution->show();
else
m_3d_per_eye_resolution->hide();
m_block_save = false;
SaveSettings();
});
connect(m_pp_effect, &QComboBox::currentIndexChanged, this, &EnhancementsWidget::ShaderChanged);
connect(m_configure_color_correction, &QPushButton::clicked, this,
&EnhancementsWidget::ConfigureColorCorrection);
connect(m_configure_pp_effect, &QPushButton::clicked, this,
&EnhancementsWidget::ConfigurePostProcessingShader);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
const QSignalBlocker blocker(this);
m_block_save = true;
LoadPPShaders(Config::Get(Config::GFX_STEREO_MODE));
m_block_save = false;
});
}
void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode)
template <typename T>
T EnhancementsWidget::ReadSetting(const Config::Info<T>& setting) const
{
std::vector<std::string> shaders = VideoCommon::PostProcessing::GetShaderList();
if (stereo_mode == StereoMode::Anaglyph)
{
shaders = VideoCommon::PostProcessing::GetAnaglyphShaderList();
}
else if (stereo_mode == StereoMode::Passive)
{
shaders = VideoCommon::PostProcessing::GetPassiveShaderList();
}
if (m_game_layer != nullptr)
return m_game_layer->Get(setting);
else
return Config::Get(setting);
}
void EnhancementsWidget::LoadPPShaders()
{
auto stereo_mode = ReadSetting(Config::GFX_STEREO_MODE);
const QSignalBlocker blocker(m_pp_effect);
m_pp_effect->clear();
// Get shader list
std::vector<std::string> shaders = VideoCommon::PostProcessing::GetShaderList();
if (stereo_mode == StereoMode::Anaglyph)
shaders = VideoCommon::PostProcessing::GetAnaglyphShaderList();
else if (stereo_mode == StereoMode::Passive)
shaders = VideoCommon::PostProcessing::GetPassiveShaderList();
// Populate widget
if (stereo_mode != StereoMode::Anaglyph && stereo_mode != StereoMode::Passive)
m_pp_effect->addItem(tr("(off)"));
auto selected_shader = Config::Get(Config::GFX_ENHANCE_POST_SHADER);
auto selected_shader = ReadSetting(Config::GFX_ENHANCE_POST_SHADER);
bool found = false;
@ -306,6 +316,7 @@ void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode)
}
}
// Force a shader for StereoModes that require it.
if (!found)
{
if (stereo_mode == StereoMode::Anaglyph)
@ -321,103 +332,20 @@ void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode)
else
m_pp_effect->setCurrentIndex(0);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, selected_shader);
// Save forced shader, but avoid forcing an option into a game ini layer.
if (m_game_layer == nullptr && ReadSetting(Config::GFX_ENHANCE_POST_SHADER) != selected_shader)
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, selected_shader);
}
const bool supports_postprocessing = g_Config.backend_info.bSupportsPostProcessing;
m_pp_effect->setEnabled(supports_postprocessing);
m_pp_effect->setToolTip(supports_postprocessing ?
QString{} :
tr("%1 doesn't support this feature.")
.arg(tr(g_video_backend->GetDisplayName().c_str())));
VideoCommon::PostProcessingConfiguration pp_shader;
if (selected_shader != "" && supports_postprocessing)
{
pp_shader.LoadShader(selected_shader);
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}
else
{
m_configure_pp_effect->setEnabled(false);
}
m_pp_effect->Load();
ShaderChanged();
}
void EnhancementsWidget::LoadSettings()
void EnhancementsWidget::OnBackendChanged()
{
m_block_save = true;
m_texture_filtering_combo->setEnabled(Config::Get(Config::GFX_HACK_FAST_TEXTURE_SAMPLING));
m_arbitrary_mipmap_detection->setEnabled(!Config::Get(Config::GFX_ENABLE_GPU_TEXTURE_DECODING));
// Anti-Aliasing
const u32 aa_selection = Config::Get(Config::GFX_MSAA);
const bool ssaa = Config::Get(Config::GFX_SSAA);
const int aniso = Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY);
const TextureFilteringMode tex_filter_mode =
Config::Get(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING);
m_aa_combo->clear();
for (const u32 aa_mode : g_Config.backend_info.AAModes)
{
if (aa_mode == 1)
m_aa_combo->addItem(tr("None"), 1);
else
m_aa_combo->addItem(tr("%1x MSAA").arg(aa_mode), static_cast<int>(aa_mode));
if (aa_mode == aa_selection && !ssaa)
m_aa_combo->setCurrentIndex(m_aa_combo->count() - 1);
}
if (g_Config.backend_info.bSupportsSSAA)
{
for (const u32 aa_mode : g_Config.backend_info.AAModes)
{
if (aa_mode != 1) // don't show "None" twice
{
// Mark SSAA using negative values in the variant
m_aa_combo->addItem(tr("%1x SSAA").arg(aa_mode), -static_cast<int>(aa_mode));
if (aa_mode == aa_selection && ssaa)
m_aa_combo->setCurrentIndex(m_aa_combo->count() - 1);
}
}
}
m_aa_combo->setEnabled(m_aa_combo->count() > 1);
switch (tex_filter_mode)
{
case TextureFilteringMode::Default:
if (aniso >= 0 && aniso <= 4)
m_texture_filtering_combo->setCurrentIndex(aniso);
else
m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_DEFAULT);
break;
case TextureFilteringMode::Nearest:
m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_NEAREST);
break;
case TextureFilteringMode::Linear:
if (aniso >= 0 && aniso <= 4)
m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_LINEAR + aniso);
else
m_texture_filtering_combo->setCurrentIndex(TEXTURE_FILTERING_FORCE_LINEAR);
break;
}
// Resampling
const OutputResamplingMode output_resampling_mode =
Config::Get(Config::GFX_ENHANCE_OUTPUT_RESAMPLING);
m_output_resampling_combo->setCurrentIndex(
m_output_resampling_combo->findData(static_cast<int>(output_resampling_mode)));
m_output_resampling_combo->setEnabled(g_Config.backend_info.bSupportsPostProcessing);
// Color Correction
m_configure_color_correction->setEnabled(g_Config.backend_info.bSupportsPostProcessing);
// Post Processing Shader
LoadPPShaders(Config::Get(Config::GFX_STEREO_MODE));
m_hdr->setEnabled(g_Config.backend_info.bSupportsHDROutput);
// Stereoscopy
const bool supports_stereoscopy = g_Config.backend_info.bSupportsGeometryShaders;
@ -426,105 +354,98 @@ void EnhancementsWidget::LoadSettings()
m_3d_depth->setEnabled(supports_stereoscopy);
m_3d_swap_eyes->setEnabled(supports_stereoscopy);
m_hdr->setEnabled(g_Config.backend_info.bSupportsHDROutput);
m_block_save = false;
}
void EnhancementsWidget::SaveSettings()
{
if (m_block_save)
return;
const u32 aa_value = static_cast<u32>(std::abs(m_aa_combo->currentData().toInt()));
const bool is_ssaa = m_aa_combo->currentData().toInt() < 0;
Config::SetBaseOrCurrent(Config::GFX_MSAA, aa_value);
Config::SetBaseOrCurrent(Config::GFX_SSAA, is_ssaa);
const int texture_filtering_selection = m_texture_filtering_combo->currentData().toInt();
switch (texture_filtering_selection)
// PostProcessing
const bool supports_postprocessing = g_Config.backend_info.bSupportsPostProcessing;
if (!supports_postprocessing)
{
case TEXTURE_FILTERING_DEFAULT:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Default);
break;
case TEXTURE_FILTERING_ANISO_2X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 1);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Default);
break;
case TEXTURE_FILTERING_ANISO_4X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 2);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Default);
break;
case TEXTURE_FILTERING_ANISO_8X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 3);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Default);
break;
case TEXTURE_FILTERING_ANISO_16X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 4);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Default);
break;
case TEXTURE_FILTERING_FORCE_NEAREST:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Nearest);
break;
case TEXTURE_FILTERING_FORCE_LINEAR:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 0);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Linear);
break;
case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_2X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 1);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Linear);
break;
case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_4X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 2);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Linear);
break;
case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_8X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 3);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Linear);
break;
case TEXTURE_FILTERING_FORCE_LINEAR_ANISO_16X:
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_MAX_ANISOTROPY, 4);
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_FORCE_TEXTURE_FILTERING,
TextureFilteringMode::Linear);
break;
m_configure_pp_effect->setEnabled(false);
m_pp_effect->setEnabled(false);
m_pp_effect->setToolTip(
tr("%1 doesn't support this feature.").arg(tr(g_video_backend->GetDisplayName().c_str())));
}
else if (!m_pp_effect->isEnabled() && supports_postprocessing)
{
m_configure_pp_effect->setEnabled(true);
m_pp_effect->setEnabled(true);
m_pp_effect->setToolTip(QString{});
LoadPPShaders();
}
const int output_resampling_selection = m_output_resampling_combo->currentData().toInt();
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_OUTPUT_RESAMPLING,
static_cast<OutputResamplingMode>(output_resampling_selection));
UpdateAAOptions();
}
const bool anaglyph = g_Config.stereo_mode == StereoMode::Anaglyph;
const bool passive = g_Config.stereo_mode == StereoMode::Passive;
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER,
(!anaglyph && !passive && m_pp_effect->currentIndex() == 0) ?
"" :
m_pp_effect->currentText().toStdString());
void EnhancementsWidget::ShaderChanged()
{
auto shader = ReadSetting(Config::GFX_ENHANCE_POST_SHADER);
VideoCommon::PostProcessingConfiguration pp_shader;
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) != "")
if (shader == "(off)" || shader == "")
{
pp_shader.LoadShader(Config::Get(Config::GFX_ENHANCE_POST_SHADER));
shader = "";
// Setting a shader to null in a game ini could be confusing, as it won't be bolded. Remove it
// instead.
if (m_game_layer != nullptr)
m_game_layer->DeleteKey(Config::GFX_ENHANCE_POST_SHADER.GetLocation());
else
Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, shader);
}
if (shader != "" && m_pp_effect->isEnabled())
{
VideoCommon::PostProcessingConfiguration pp_shader;
pp_shader.LoadShader(shader);
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}
else
{
m_configure_pp_effect->setEnabled(false);
}
}
LoadSettings();
void EnhancementsWidget::OnConfigChanged()
{
// Only used for the GameConfigWidget. Bypasses graphics window signals and backend info due to it
// being global.
m_texture_filtering_combo->setEnabled(ReadSetting(Config::GFX_HACK_FAST_TEXTURE_SAMPLING));
m_arbitrary_mipmap_detection->setEnabled(!ReadSetting(Config::GFX_ENABLE_GPU_TEXTURE_DECODING));
UpdateAAOptions();
// Needs to update after deleting a key for 3d settings.
LoadPPShaders();
}
void EnhancementsWidget::UpdateAAOptions()
{
const QSignalBlocker blocker_aa(m_aa_combo);
m_aa_combo->Reset();
m_aa_combo->Add(tr("None"), (u32)1, false);
std::vector<u32> aa_modes = g_Config.backend_info.AAModes;
for (const u32 aa_mode : aa_modes)
{
if (aa_mode > 1)
m_aa_combo->Add(tr("%1x MSAA").arg(aa_mode), aa_mode, false);
}
if (g_Config.backend_info.bSupportsSSAA)
{
for (const u32 aa_mode : aa_modes)
{
if (aa_mode > 1)
m_aa_combo->Add(tr("%1x SSAA").arg(aa_mode), aa_mode, true);
}
}
m_aa_combo->Refresh();
// Backend info can't be populated in the local game settings window. Only enable local game AA
// edits when the backend info is correct - global and local have the same backend.
const bool good_info =
m_game_layer == nullptr || !m_game_layer->Exists(Config::MAIN_GFX_BACKEND.GetLocation()) ||
Config::Get(Config::MAIN_GFX_BACKEND) == m_game_layer->Get(Config::MAIN_GFX_BACKEND);
m_aa_combo->setEnabled(m_aa_combo->count() > 1 && good_info);
}
void EnhancementsWidget::AddDescriptions()
@ -713,7 +634,7 @@ void EnhancementsWidget::ConfigureColorCorrection()
void EnhancementsWidget::ConfigurePostProcessingShader()
{
const std::string shader = Config::Get(Config::GFX_ENHANCE_POST_SHADER);
const std::string shader = ReadSetting(Config::GFX_ENHANCE_POST_SHADER);
PostProcessingConfigWindow dialog(this, shader);
SetQWidgetWindowDecorations(&dialog);
dialog.exec();

View file

@ -9,39 +9,52 @@
class ConfigBool;
class ConfigChoice;
class ConfigComplexChoice;
class ConfigStringChoice;
class ConfigSlider;
class GameConfigWidget;
class GraphicsWindow;
class QCheckBox;
class QComboBox;
class QPushButton;
class QSlider;
class ToolTipComboBox;
class ToolTipPushButton;
enum class StereoMode : int;
namespace Config
{
template <typename T>
class Info;
class Layer;
} // namespace Config
class EnhancementsWidget final : public QWidget
{
Q_OBJECT
public:
explicit EnhancementsWidget(GraphicsWindow* parent);
EnhancementsWidget(GameConfigWidget* parent, Config::Layer* layer);
private:
void LoadSettings();
void SaveSettings();
template <typename T>
T ReadSetting(const Config::Info<T>& setting) const;
void CreateWidgets();
void ConnectWidgets();
void AddDescriptions();
void OnBackendChanged();
void UpdateAAOptions();
void LoadPPShaders();
void ShaderChanged();
void OnConfigChanged();
void ConfigureColorCorrection();
void ConfigurePostProcessingShader();
void LoadPPShaders(StereoMode stereo_mode);
// Enhancements
ConfigChoice* m_ir_combo;
ToolTipComboBox* m_aa_combo;
ToolTipComboBox* m_texture_filtering_combo;
ToolTipComboBox* m_output_resampling_combo;
ToolTipComboBox* m_pp_effect;
ConfigComplexChoice* m_aa_combo;
ConfigComplexChoice* m_texture_filtering_combo;
ConfigChoice* m_output_resampling_combo;
ConfigStringChoice* m_pp_effect;
ToolTipPushButton* m_configure_color_correction;
QPushButton* m_configure_pp_effect;
ConfigBool* m_scaled_efb_copy;
@ -60,6 +73,5 @@ private:
ConfigBool* m_3d_swap_eyes;
ConfigBool* m_3d_per_eye_resolution;
int m_msaa_modes;
bool m_block_save;
Config::Layer* m_game_layer = nullptr;
};

View file

@ -23,6 +23,7 @@
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
#include "DolphinQt/Config/GameConfigWidget.h"
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
@ -38,7 +39,6 @@ GeneralWidget::GeneralWidget(GraphicsWindow* parent)
LoadSettings();
ConnectWidgets();
AddDescriptions();
emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
connect(parent, &GraphicsWindow::BackendChanged, this, &GeneralWidget::OnBackendChanged);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
@ -47,6 +47,14 @@ GeneralWidget::GeneralWidget(GraphicsWindow* parent)
OnEmulationStateChanged(!Core::IsUninitialized(Core::System::GetInstance()));
}
GeneralWidget::GeneralWidget(GameConfigWidget* parent, Config::Layer* layer) : m_game_layer(layer)
{
CreateWidgets();
LoadSettings();
ConnectWidgets();
AddDescriptions();
}
void GeneralWidget::CreateWidgets()
{
auto* main_layout = new QVBoxLayout;
@ -55,33 +63,36 @@ void GeneralWidget::CreateWidgets()
auto* m_video_box = new QGroupBox(tr("Basic"));
m_video_layout = new QGridLayout();
m_backend_combo = new ToolTipComboBox();
std::vector<std::pair<QString, QString>> options;
for (auto& backend : VideoBackendBase::GetAvailableBackends())
{
options.push_back(std::make_pair(tr(backend->GetDisplayName().c_str()),
QString::fromStdString(backend->GetName())));
}
m_backend_combo = new ConfigStringChoice(options, Config::MAIN_GFX_BACKEND, m_game_layer);
m_previous_backend = m_backend_combo->currentIndex();
m_aspect_combo = new ConfigChoice({tr("Auto"), tr("Force 16:9"), tr("Force 4:3"),
tr("Stretch to Window"), tr("Custom"), tr("Custom (Stretch)")},
Config::GFX_ASPECT_RATIO);
Config::GFX_ASPECT_RATIO, m_game_layer);
m_custom_aspect_label = new QLabel(tr("Custom Aspect Ratio:"));
m_custom_aspect_label->setHidden(true);
constexpr int MAX_CUSTOM_ASPECT_RATIO_RESOLUTION = 10000;
m_custom_aspect_width = new ConfigInteger(1, MAX_CUSTOM_ASPECT_RATIO_RESOLUTION,
Config::GFX_CUSTOM_ASPECT_RATIO_WIDTH);
Config::GFX_CUSTOM_ASPECT_RATIO_WIDTH, m_game_layer);
m_custom_aspect_width->setEnabled(false);
m_custom_aspect_width->setHidden(true);
m_custom_aspect_height = new ConfigInteger(1, MAX_CUSTOM_ASPECT_RATIO_RESOLUTION,
Config::GFX_CUSTOM_ASPECT_RATIO_HEIGHT);
Config::GFX_CUSTOM_ASPECT_RATIO_HEIGHT, m_game_layer);
m_custom_aspect_height->setEnabled(false);
m_custom_aspect_height->setHidden(true);
m_adapter_combo = new ToolTipComboBox;
m_enable_vsync = new ConfigBool(tr("V-Sync"), Config::GFX_VSYNC);
m_enable_fullscreen = new ConfigBool(tr("Start in Fullscreen"), Config::MAIN_FULLSCREEN);
m_enable_vsync = new ConfigBool(tr("V-Sync"), Config::GFX_VSYNC, m_game_layer);
m_enable_fullscreen =
new ConfigBool(tr("Start in Fullscreen"), Config::MAIN_FULLSCREEN, m_game_layer);
m_video_box->setLayout(m_video_layout);
for (auto& backend : VideoBackendBase::GetAvailableBackends())
{
m_backend_combo->addItem(tr(backend->GetDisplayName().c_str()),
QVariant(QString::fromStdString(backend->GetName())));
}
m_video_layout->addWidget(new QLabel(tr("Backend:")), 0, 0);
m_video_layout->addWidget(m_backend_combo, 0, 1, 1, -1);
@ -102,12 +113,15 @@ void GeneralWidget::CreateWidgets()
auto* m_options_box = new QGroupBox(tr("Other"));
auto* m_options_layout = new QGridLayout();
m_show_ping = new ConfigBool(tr("Show NetPlay Ping"), Config::GFX_SHOW_NETPLAY_PING);
m_show_turn_count = new ConfigBool(tr("Show MP Turn"), Config::GFX_SHOW_MP_TURN);
m_autoadjust_window_size =
new ConfigBool(tr("Auto-Adjust Window Size"), Config::MAIN_RENDER_WINDOW_AUTOSIZE);
m_show_messages = new ConfigBool(tr("Show NetPlay Messages"), Config::GFX_SHOW_NETPLAY_MESSAGES);
m_render_main_window = new ConfigBool(tr("Render to Main Window"), Config::MAIN_RENDER_TO_MAIN);
m_show_ping =
new ConfigBool(tr("Show NetPlay Ping"), Config::GFX_SHOW_NETPLAY_PING, m_game_layer);
m_autoadjust_window_size = new ConfigBool(tr("Auto-Adjust Window Size"),
Config::MAIN_RENDER_WINDOW_AUTOSIZE, m_game_layer);
m_show_turn_count = new ConfigBool(tr("Show MP Turn"), Config::GFX_SHOW_MP_TURN. m_game_layer);
m_show_messages =
new ConfigBool(tr("Show NetPlay Messages"), Config::GFX_SHOW_NETPLAY_MESSAGES, m_game_layer);
m_render_main_window =
new ConfigBool(tr("Render to Main Window"), Config::MAIN_RENDER_TO_MAIN, m_game_layer);
m_options_box->setLayout(m_options_layout);
@ -130,13 +144,13 @@ void GeneralWidget::CreateWidgets()
}};
for (size_t i = 0; i < modes.size(); i++)
{
m_shader_compilation_mode[i] =
new ConfigRadioInt(tr(modes[i]), Config::GFX_SHADER_COMPILATION_MODE, static_cast<int>(i));
m_shader_compilation_mode[i] = new ConfigRadioInt(
tr(modes[i]), Config::GFX_SHADER_COMPILATION_MODE, static_cast<int>(i), m_game_layer);
shader_compilation_layout->addWidget(m_shader_compilation_mode[i], static_cast<int>(i / 2),
static_cast<int>(i % 2));
}
m_wait_for_shaders = new ConfigBool(tr("Compile Shaders Before Starting"),
Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING);
Config::GFX_WAIT_FOR_SHADERS_BEFORE_STARTING, m_game_layer);
shader_compilation_layout->addWidget(m_wait_for_shaders);
shader_compilation_box->setLayout(shader_compilation_layout);
@ -151,7 +165,7 @@ void GeneralWidget::CreateWidgets()
void GeneralWidget::ConnectWidgets()
{
// Video Backend
connect(m_backend_combo, &QComboBox::currentIndexChanged, this, &GeneralWidget::SaveSettings);
connect(m_backend_combo, &QComboBox::currentIndexChanged, this, &GeneralWidget::BackendWarning);
connect(m_adapter_combo, &QComboBox::currentIndexChanged, this, [&](int index) {
g_Config.iAdapter = index;
Config::SetBaseOrCurrent(Config::GFX_ADAPTER, index);
@ -170,10 +184,6 @@ void GeneralWidget::ConnectWidgets()
void GeneralWidget::LoadSettings()
{
// Video Backend
m_backend_combo->setCurrentIndex(m_backend_combo->findData(
QVariant(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)))));
const bool is_custom_aspect_ratio =
(Config::Get(Config::GFX_ASPECT_RATIO) == AspectMode::Custom) ||
(Config::Get(Config::GFX_ASPECT_RATIO) == AspectMode::CustomStretch);
@ -184,13 +194,8 @@ void GeneralWidget::LoadSettings()
m_custom_aspect_height->setHidden(!is_custom_aspect_ratio);
}
void GeneralWidget::SaveSettings()
void GeneralWidget::BackendWarning()
{
// Video Backend
const auto current_backend = m_backend_combo->currentData().toString().toStdString();
if (Config::Get(Config::MAIN_GFX_BACKEND) == current_backend)
return;
if (Config::GetActiveLayerForConfig(Config::MAIN_GFX_BACKEND) == Config::LayerType::Base)
{
auto warningMessage = VideoBackendBase::GetAvailableBackends()[m_backend_combo->currentIndex()]
@ -207,15 +212,14 @@ void GeneralWidget::SaveSettings()
SetQWidgetWindowDecorations(&confirm_sw);
if (confirm_sw.exec() != QMessageBox::Yes)
{
m_backend_combo->setCurrentIndex(m_backend_combo->findData(
QVariant(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)))));
m_backend_combo->setCurrentIndex(m_previous_backend);
return;
}
}
}
Config::SetBaseOrCurrent(Config::MAIN_GFX_BACKEND, current_backend);
emit BackendChanged(QString::fromStdString(current_backend));
m_previous_backend = m_backend_combo->currentIndex();
emit BackendChanged(m_backend_combo->currentData().toString());
}
void GeneralWidget::OnEmulationStateChanged(bool running)
@ -229,7 +233,10 @@ void GeneralWidget::OnEmulationStateChanged(bool running)
std::string current_backend = m_backend_combo->currentData().toString().toStdString();
if (Config::Get(Config::MAIN_GFX_BACKEND) != current_backend)
{
m_backend_combo->Load();
emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
}
}
void GeneralWidget::AddDescriptions()
@ -241,7 +248,7 @@ void GeneralWidget::AddDescriptions()
"recommended. Different games and different GPUs will behave differently on each "
"backend, so for the best emulation experience it is recommended to try each and "
"select the backend that is least problematic.<br><br><dolphin_emphasis>If unsure, "
"select OpenGL.</dolphin_emphasis>");
"select %1.</dolphin_emphasis>");
static const char TR_FULLSCREEN_DESCRIPTION[] =
QT_TR_NOOP("Uses the entire screen for rendering.<br><br>If disabled, a "
"render window will be created instead.<br><br><dolphin_emphasis>If "
@ -313,7 +320,9 @@ void GeneralWidget::AddDescriptions()
"unsure, leave this unchecked.</dolphin_emphasis>");
m_backend_combo->SetTitle(tr("Backend"));
m_backend_combo->SetDescription(tr(TR_BACKEND_DESCRIPTION));
m_backend_combo->SetDescription(
tr(TR_BACKEND_DESCRIPTION)
.arg(QString::fromStdString(VideoBackendBase::GetDefaultBackendDisplayName())));
m_adapter_combo->SetTitle(tr("Adapter"));
@ -348,8 +357,6 @@ void GeneralWidget::AddDescriptions()
void GeneralWidget::OnBackendChanged(const QString& backend_name)
{
m_backend_combo->setCurrentIndex(m_backend_combo->findData(QVariant(backend_name)));
const QSignalBlocker blocker(m_adapter_combo);
m_adapter_combo->clear();

View file

@ -11,6 +11,8 @@ class ConfigBool;
class ConfigChoice;
class ConfigInteger;
class ConfigRadioInt;
class ConfigStringChoice;
class GameConfigWidget;
class GraphicsWindow;
class QCheckBox;
class QComboBox;
@ -19,17 +21,24 @@ class QRadioButton;
class QGridLayout;
class ToolTipComboBox;
namespace Config
{
class Layer;
} // namespace Config
class GeneralWidget final : public QWidget
{
Q_OBJECT
public:
explicit GeneralWidget(GraphicsWindow* parent);
GeneralWidget(GameConfigWidget* parent, Config::Layer* layer);
signals:
void BackendChanged(const QString& backend);
private:
void LoadSettings();
void SaveSettings();
void BackendWarning();
void CreateWidgets();
void ConnectWidgets();
@ -40,7 +49,7 @@ private:
// Video
QGridLayout* m_video_layout;
ToolTipComboBox* m_backend_combo;
ConfigStringChoice* m_backend_combo;
ToolTipComboBox* m_adapter_combo;
ConfigChoice* m_aspect_combo;
QLabel* m_custom_aspect_label;
@ -57,4 +66,6 @@ private:
ConfigBool* m_render_main_window;
std::array<ConfigRadioInt*, 4> m_shader_compilation_mode{};
ConfigBool* m_wait_for_shaders;
int m_previous_backend = 0;
Config::Layer* m_game_layer = nullptr;
};

View file

@ -15,6 +15,7 @@
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include "DolphinQt/Config/GameConfigWidget.h"
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"
#include "DolphinQt/Settings.h"
@ -37,6 +38,14 @@ HacksWidget::HacksWidget(GraphicsWindow* parent)
});
}
HacksWidget::HacksWidget(GameConfigWidget* parent, Config::Layer* layer) : m_game_layer(layer)
{
CreateWidgets();
LoadSettings();
ConnectWidgets();
AddDescriptions();
}
void HacksWidget::CreateWidgets()
{
auto* main_layout = new QVBoxLayout;
@ -45,14 +54,14 @@ void HacksWidget::CreateWidgets()
auto* efb_box = new QGroupBox(tr("Embedded Frame Buffer (EFB)"));
auto* efb_layout = new QGridLayout();
efb_box->setLayout(efb_layout);
m_skip_efb_cpu =
new ConfigBool(tr("Skip EFB Access from CPU"), Config::GFX_HACK_EFB_ACCESS_ENABLE, true);
m_ignore_format_changes = new ConfigBool(tr("Ignore Format Changes"),
Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, true);
m_store_efb_copies =
new ConfigBool(tr("Store EFB Copies to Texture Only"), Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
m_defer_efb_copies =
new ConfigBool(tr("Defer EFB Copies to RAM"), Config::GFX_HACK_DEFER_EFB_COPIES);
m_skip_efb_cpu = new ConfigBool(tr("Skip EFB Access from CPU"),
Config::GFX_HACK_EFB_ACCESS_ENABLE, m_game_layer, true);
m_ignore_format_changes = new ConfigBool(
tr("Ignore Format Changes"), Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, m_game_layer, true);
m_store_efb_copies = new ConfigBool(tr("Store EFB Copies to Texture Only"),
Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, m_game_layer);
m_defer_efb_copies = new ConfigBool(tr("Defer EFB Copies to RAM"),
Config::GFX_HACK_DEFER_EFB_COPIES, m_game_layer);
efb_layout->addWidget(m_skip_efb_cpu, 0, 0);
efb_layout->addWidget(m_ignore_format_changes, 0, 1);
@ -69,8 +78,8 @@ void HacksWidget::CreateWidgets()
m_accuracy->setMaximum(2);
m_accuracy->setPageStep(1);
m_accuracy->setTickPosition(QSlider::TicksBelow);
m_gpu_texture_decoding =
new ConfigBool(tr("GPU Texture Decoding"), Config::GFX_ENABLE_GPU_TEXTURE_DECODING);
m_gpu_texture_decoding = new ConfigBool(tr("GPU Texture Decoding"),
Config::GFX_ENABLE_GPU_TEXTURE_DECODING, m_game_layer);
auto* safe_label = new QLabel(tr("Safe"));
safe_label->setAlignment(Qt::AlignRight);
@ -88,11 +97,12 @@ void HacksWidget::CreateWidgets()
auto* xfb_layout = new QVBoxLayout();
xfb_box->setLayout(xfb_layout);
m_store_xfb_copies =
new ConfigBool(tr("Store XFB Copies to Texture Only"), Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM);
m_immediate_xfb = new ConfigBool(tr("Immediately Present XFB"), Config::GFX_HACK_IMMEDIATE_XFB);
m_skip_duplicate_xfbs =
new ConfigBool(tr("Skip Presenting Duplicate Frames"), Config::GFX_HACK_SKIP_DUPLICATE_XFBS);
m_store_xfb_copies = new ConfigBool(tr("Store XFB Copies to Texture Only"),
Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM, m_game_layer);
m_immediate_xfb =
new ConfigBool(tr("Immediately Present XFB"), Config::GFX_HACK_IMMEDIATE_XFB, m_game_layer);
m_skip_duplicate_xfbs = new ConfigBool(tr("Skip Presenting Duplicate Frames"),
Config::GFX_HACK_SKIP_DUPLICATE_XFBS, m_game_layer);
xfb_layout->addWidget(m_store_xfb_copies);
xfb_layout->addWidget(m_immediate_xfb);
@ -104,13 +114,14 @@ void HacksWidget::CreateWidgets()
other_box->setLayout(other_layout);
m_fast_depth_calculation =
new ConfigBool(tr("Fast Depth Calculation"), Config::GFX_FAST_DEPTH_CALC);
new ConfigBool(tr("Fast Depth Calculation"), Config::GFX_FAST_DEPTH_CALC, m_game_layer);
m_disable_bounding_box =
new ConfigBool(tr("Disable Bounding Box"), Config::GFX_HACK_BBOX_ENABLE, true);
m_vertex_rounding = new ConfigBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUNDING);
m_save_texture_cache_state =
new ConfigBool(tr("Save Texture Cache to State"), Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE);
m_vi_skip = new ConfigBool(tr("VBI Skip"), Config::GFX_HACK_VI_SKIP);
new ConfigBool(tr("Disable Bounding Box"), Config::GFX_HACK_BBOX_ENABLE, m_game_layer, true);
m_vertex_rounding =
new ConfigBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUNDING, m_game_layer);
m_save_texture_cache_state = new ConfigBool(
tr("Save Texture Cache to State"), Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE, m_game_layer);
m_vi_skip = new ConfigBool(tr("VBI Skip"), Config::GFX_HACK_VI_SKIP, m_game_layer);
other_layout->addWidget(m_fast_depth_calculation, 0, 0);
other_layout->addWidget(m_disable_bounding_box, 0, 1);
@ -223,7 +234,7 @@ void HacksWidget::AddDescriptions()
"Ignores any requests from the CPU to read from or write to the EFB. "
"<br><br>Improves performance in some games, but will disable all EFB-based "
"graphical effects or gameplay-related features.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>");
"leave this checked.</dolphin_emphasis>");
static const char TR_IGNORE_FORMAT_CHANGE_DESCRIPTION[] = QT_TR_NOOP(
"Ignores any changes to the EFB format.<br><br>Improves performance in many games "
"without "

View file

@ -6,15 +6,22 @@
#include <QWidget>
class ConfigBool;
class GameConfigWidget;
class GraphicsWindow;
class QLabel;
class ToolTipSlider;
namespace Config
{
class Layer;
} // namespace Config
class HacksWidget final : public QWidget
{
Q_OBJECT
public:
explicit HacksWidget(GraphicsWindow* parent);
HacksWidget(GameConfigWidget* parent, Config::Layer* layer);
private:
void LoadSettings();
@ -45,6 +52,8 @@ private:
ConfigBool* m_vi_skip;
ConfigBool* m_save_texture_cache_state;
Config::Layer* m_game_layer = nullptr;
void CreateWidgets();
void ConnectWidgets();
void AddDescriptions();

View file

@ -35,7 +35,7 @@ void HardcoreWarningWidget::CreateWidgets()
auto* icon = new QLabel;
icon->setPixmap(warning_icon);
m_text = new QLabel(tr("This feature is disabled in hardcore mode."));
m_text = new QLabel(tr("Only approved codes will be applied in hardcore mode."));
m_settings_button = new QPushButton(tr("Achievement Settings"));
auto* layout = new QHBoxLayout;

View file

@ -5,7 +5,6 @@
#include <array>
#include <cmath>
#include <numeric>
#include <fmt/format.h>
@ -19,12 +18,10 @@
#include "Core/HW/WiimoteEmu/Camera.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/Cursor.h"
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerInterface/CoreDevice.h"
#include "DolphinQt/Config/Mapping/MappingWidget.h"
@ -289,7 +286,14 @@ void GenerateFibonacciSphere(int point_count, F&& callback)
void MappingIndicator::paintEvent(QPaintEvent*)
{
constexpr float max_elapsed_seconds = 0.1f;
const auto now = Clock::now();
const float elapsed_seconds = std::chrono::duration_cast<DT_s>(now - m_last_update).count();
m_last_update = now;
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
Update(std::min(elapsed_seconds, max_elapsed_seconds));
Draw();
}
@ -321,7 +325,7 @@ void SquareIndicator::TransformPainter(QPainter& p)
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
p.translate(width() / 2, height() / 2);
p.translate(width() / 2.0, height() / 2.0);
const auto scale = GetContentsScale();
p.scale(scale, scale);
}
@ -413,10 +417,13 @@ void AnalogStickIndicator::Draw()
(adj_coord.x || adj_coord.y) ? std::make_optional(adj_coord) : std::nullopt);
}
void TiltIndicator::Update(float elapsed_seconds)
{
WiimoteEmu::EmulateTilt(&m_motion_state, &m_group, elapsed_seconds);
}
void TiltIndicator::Draw()
{
WiimoteEmu::EmulateTilt(&m_motion_state, &m_group, 1.f / INDICATOR_UPDATE_FREQ);
auto adj_coord = Common::DVec2{-m_motion_state.angle.y, m_motion_state.angle.x} / MathUtil::PI;
// Angle values after dividing by pi.
@ -564,28 +571,54 @@ void SwingIndicator::DrawUnderGate(QPainter& p)
}
}
void SwingIndicator::Update(float elapsed_seconds)
{
WiimoteEmu::EmulateSwing(&m_motion_state, &m_swing_group, elapsed_seconds);
}
void SwingIndicator::Draw()
{
auto& force = m_swing_group;
WiimoteEmu::EmulateSwing(&m_motion_state, &force, 1.f / INDICATOR_UPDATE_FREQ);
DrawReshapableInput(force, SWING_GATE_COLOR,
DrawReshapableInput(m_swing_group, SWING_GATE_COLOR,
Common::DVec2{-m_motion_state.position.x, m_motion_state.position.z});
}
void ShakeMappingIndicator::Update(float elapsed_seconds)
{
WiimoteEmu::EmulateShake(&m_motion_state, &m_shake_group, elapsed_seconds);
for (auto& sample : m_position_samples)
sample.age += elapsed_seconds;
m_position_samples.erase(
std::ranges::find_if(m_position_samples,
[](const ShakeSample& sample) { return sample.age > 1.f; }),
m_position_samples.end());
constexpr float MAX_DISTANCE = 0.5f;
m_position_samples.push_front(ShakeSample{m_motion_state.position / MAX_DISTANCE});
const bool any_non_zero_samples =
std::any_of(m_position_samples.begin(), m_position_samples.end(),
[](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
// Only start moving the line if there's non-zero data.
if (m_grid_line_position || any_non_zero_samples)
{
m_grid_line_position += elapsed_seconds;
if (m_grid_line_position > 1.f)
{
if (any_non_zero_samples)
m_grid_line_position = std::fmod(m_grid_line_position, 1.f);
else
m_grid_line_position = 0;
}
}
}
void ShakeMappingIndicator::Draw()
{
constexpr std::size_t HISTORY_COUNT = INDICATOR_UPDATE_FREQ;
WiimoteEmu::EmulateShake(&m_motion_state, &m_shake_group, 1.f / INDICATOR_UPDATE_FREQ);
constexpr float MAX_DISTANCE = 0.5f;
m_position_samples.push_front(m_motion_state.position / MAX_DISTANCE);
// This also holds the current state so +1.
if (m_position_samples.size() > HISTORY_COUNT + 1)
m_position_samples.pop_back();
QPainter p(this);
DrawBoundingBox(p);
TransformPainter(p);
@ -610,15 +643,7 @@ void ShakeMappingIndicator::Draw()
p.drawPoint(QPointF{-0.5 + c * 0.5, raw_coord.data[c]});
}
// Grid line.
if (m_grid_line_position ||
std::any_of(m_position_samples.begin(), m_position_samples.end(),
[](const Common::Vec3& v) { return v.LengthSquared() != 0.0; }))
{
// Only start moving the line if there's non-zero data.
m_grid_line_position = (m_grid_line_position + 1) % HISTORY_COUNT;
}
const double grid_line_x = 1.0 - m_grid_line_position * 2.0 / HISTORY_COUNT;
const double grid_line_x = 1.0 - m_grid_line_position * 2.0;
p.setPen(QPen(GetRawInputColor(), 0));
p.drawLine(QPointF{grid_line_x, -1.0}, QPointF{grid_line_x, 1.0});
@ -629,12 +654,8 @@ void ShakeMappingIndicator::Draw()
{
QPolygonF polyline;
int i = 0;
for (auto& sample : m_position_samples)
{
polyline.append(QPointF{1.0 - i * 2.0 / HISTORY_COUNT, sample.data[c]});
++i;
}
polyline.append(QPointF{1.0 - sample.age * 2.0, sample.state.data[c]});
p.setPen(QPen(component_colors[c], 0));
p.drawPolyline(polyline);
@ -692,7 +713,7 @@ void AccelerometerMappingIndicator::Draw()
p.setBrush(Qt::NoBrush);
p.resetTransform();
p.translate(width() / 2, height() / 2);
p.translate(width() / 2.0, height() / 2.0);
// Red dot upright target.
p.setPen(GetAdjustedInputColor());
@ -717,6 +738,28 @@ void AccelerometerMappingIndicator::Draw()
fmt::format("{:.2f} g", state.Length() / WiimoteEmu::GRAVITY_ACCELERATION)));
}
void GyroMappingIndicator::Update(float elapsed_seconds)
{
const auto gyro_state = m_gyro_group.GetState();
const auto angular_velocity = gyro_state.value_or(Common::Vec3{});
m_state *= WiimoteEmu::GetRotationFromGyroscope(angular_velocity * Common::Vec3(-1, +1, -1) *
elapsed_seconds);
m_state = m_state.Normalized();
// Reset orientation when stable for a bit:
constexpr float STABLE_RESET_SECONDS = 1.f;
// Consider device stable when data (with deadzone applied) is zero.
const bool is_stable = !angular_velocity.LengthSquared();
if (!is_stable)
m_stable_time = 0;
else if (m_stable_time < STABLE_RESET_SECONDS)
m_stable_time += elapsed_seconds;
if (m_stable_time >= STABLE_RESET_SECONDS)
m_state = Common::Quaternion::Identity();
}
void GyroMappingIndicator::Draw()
{
const auto gyro_state = m_gyro_group.GetState();
@ -725,23 +768,9 @@ void GyroMappingIndicator::Draw()
const auto jitter = raw_gyro_state - m_previous_velocity;
m_previous_velocity = raw_gyro_state;
m_state *= WiimoteEmu::GetRotationFromGyroscope(angular_velocity * Common::Vec3(-1, +1, -1) /
INDICATOR_UPDATE_FREQ);
m_state = m_state.Normalized();
// Reset orientation when stable for a bit:
constexpr u32 STABLE_RESET_STEPS = INDICATOR_UPDATE_FREQ;
// Consider device stable when data (with deadzone applied) is zero.
const bool is_stable = !angular_velocity.LengthSquared();
if (!is_stable)
m_stable_steps = 0;
else if (m_stable_steps != STABLE_RESET_STEPS)
++m_stable_steps;
if (STABLE_RESET_STEPS == m_stable_steps)
m_state = Common::Quaternion::Identity();
// Use an empty rotation matrix if gyroscope data is not present.
const auto rotation =
(gyro_state.has_value() ? Common::Matrix33::FromQuaternion(m_state) : Common::Matrix33{});
@ -814,7 +843,7 @@ void GyroMappingIndicator::Draw()
p.setBrush(Qt::NoBrush);
p.resetTransform();
p.translate(width() / 2, height() / 2);
p.translate(width() / 2.0, height() / 2.0);
// Red dot upright target.
p.setPen(GetAdjustedInputColor());

View file

@ -45,9 +45,12 @@ public:
protected:
virtual void Draw() {}
virtual void Update(float elapsed_seconds) {}
private:
void paintEvent(QPaintEvent*) override;
Clock::time_point m_last_update = Clock::now();
};
class SquareIndicator : public MappingIndicator
@ -98,6 +101,7 @@ public:
private:
void Draw() override;
void Update(float elapsed_seconds) override;
ControllerEmu::Tilt& m_group;
WiimoteEmu::MotionState m_motion_state{};
@ -132,6 +136,7 @@ public:
private:
void Draw() override;
void Update(float elapsed_seconds) override;
void DrawUnderGate(QPainter& p) override;
@ -146,11 +151,19 @@ public:
private:
void Draw() override;
void Update(float elapsed_seconds) override;
ControllerEmu::Shake& m_shake_group;
WiimoteEmu::MotionState m_motion_state{};
std::deque<ControllerEmu::Shake::StateData> m_position_samples;
int m_grid_line_position = 0;
struct ShakeSample
{
ControllerEmu::Shake::StateData state;
float age = 0.f;
};
std::deque<ShakeSample> m_position_samples;
float m_grid_line_position = 0;
};
class AccelerometerMappingIndicator : public SquareIndicator
@ -174,11 +187,12 @@ public:
private:
void Draw() override;
void Update(float elapsed_seconds) override;
ControllerEmu::IMUGyroscope& m_gyro_group;
Common::Quaternion m_state = Common::Quaternion::Identity();
Common::Vec3 m_previous_velocity = {};
u32 m_stable_steps = 0;
float m_stable_time = 0;
};
class IRPassthroughMappingIndicator : public SquareIndicator

View file

@ -228,6 +228,8 @@ void MappingWidget::AddSettingWidgets(QFormLayout* layout, ControllerEmu::Contro
const auto hbox = new QHBoxLayout;
hbox->addWidget(setting_widget);
setting_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
hbox->addWidget(CreateSettingAdvancedMappingButton(*setting));
layout->addRow(tr(setting->GetUIName()), hbox);

View file

@ -27,8 +27,6 @@ class NumericSettingBase;
enum class SettingVisibility;
} // namespace ControllerEmu
constexpr int INDICATOR_UPDATE_FREQ = 30;
class MappingWidget : public QWidget
{
Q_OBJECT

View file

@ -10,12 +10,12 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QPushButton>
#include <QScreen>
#include <QTabWidget>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
#include "Core/Core.h"
#include "Core/HotkeyManager.h"
#include "Common/CommonPaths.h"
@ -73,12 +73,15 @@ MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num)
SetMappingType(type);
const auto timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [this] {
connect(timer, &QTimer::timeout, this, [this, timer] {
const double refresh_rate = screen()->refreshRate();
timer->setInterval(1000 / refresh_rate);
const auto lock = GetController()->GetStateLock();
emit Update();
});
timer->start(1000 / INDICATOR_UPDATE_FREQ);
timer->start(100);
const auto lock = GetController()->GetStateLock();
emit ConfigChanged();

View file

@ -379,6 +379,12 @@ void CodeWidget::UpdateSymbols()
{
QString name = QString::fromStdString(symbol.second.name);
// If the symbol has an object name, add it to the entry name.
if (!symbol.second.object_name.empty())
{
name += QString::fromStdString(fmt::format(" ({})", symbol.second.object_name));
}
auto* item = new QListWidgetItem(name);
if (name == selection)
item->setSelected(true);
@ -408,8 +414,17 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
if (call_symbol)
{
const QString name =
QString::fromStdString(fmt::format("> {} ({:08x})", call_symbol->name, addr));
QString name;
if (!call_symbol->object_name.empty())
{
name = QString::fromStdString(
fmt::format("< {} ({}, {:08x})", call_symbol->name, call_symbol->object_name, addr));
}
else
{
name = QString::fromStdString(fmt::format("< {} ({:08x})", call_symbol->name, addr));
}
if (!name.contains(filter, Qt::CaseInsensitive))
continue;
@ -433,8 +448,17 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
if (caller_symbol)
{
const QString name =
QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
QString name;
if (!caller_symbol->object_name.empty())
{
name = QString::fromStdString(fmt::format("< {} ({}, {:08x})", caller_symbol->name,
caller_symbol->object_name, addr));
}
else
{
name = QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
}
if (!name.contains(filter, Qt::CaseInsensitive))
continue;

View file

@ -313,7 +313,7 @@ void JITWidget::SaveQSettings() const
void JITWidget::ConnectSlots()
{
auto* const host = Host::GetInstance();
connect(host, &Host::JitCacheCleared, this, &JITWidget::OnJitCacheCleared);
connect(host, &Host::JitCacheInvalidation, this, &JITWidget::OnJitCacheInvalidation);
connect(host, &Host::UpdateDisasmDialog, this, &JITWidget::OnUpdateDisasmDialog);
connect(host, &Host::PPCSymbolsChanged, this, &JITWidget::OnPPCSymbolsUpdated);
connect(host, &Host::PPCBreakpointsChanged, this, &JITWidget::OnPPCBreakpointsChanged);
@ -326,7 +326,7 @@ void JITWidget::ConnectSlots()
void JITWidget::DisconnectSlots()
{
auto* const host = Host::GetInstance();
disconnect(host, &Host::JitCacheCleared, this, &JITWidget::OnJitCacheCleared);
disconnect(host, &Host::JitCacheInvalidation, this, &JITWidget::OnJitCacheInvalidation);
disconnect(host, &Host::UpdateDisasmDialog, this, &JITWidget::OnUpdateDisasmDialog);
disconnect(host, &Host::PPCSymbolsChanged, this, &JITWidget::OnPPCSymbolsUpdated);
disconnect(host, &Host::PPCBreakpointsChanged, this, &JITWidget::OnPPCBreakpointsChanged);
@ -340,7 +340,7 @@ void JITWidget::Show()
{
ConnectSlots();
// Handle every slot that may have missed a signal while this widget was hidden.
// OnJitCacheCleared() can be skipped.
// OnJitCacheInvalidation() can be skipped.
// OnUpdateDisasmDialog() can be skipped.
// OnPPCSymbolsUpdated() can be skipped.
// OnPPCBreakpointsChanged() can be skipped.
@ -446,7 +446,7 @@ void JITWidget::OnStatusBarPressed()
ShowFreeMemoryStatus();
}
void JITWidget::OnJitCacheCleared()
void JITWidget::OnJitCacheInvalidation()
{
if (Core::GetState(m_system) != Core::State::Paused)
return;

View file

@ -102,7 +102,7 @@ private:
void OnStatusBarPressed();
// Conditionally connected slots (external signals)
void OnJitCacheCleared();
void OnJitCacheInvalidation();
void OnUpdateDisasmDialog();
void OnPPCSymbolsUpdated();
void OnPPCBreakpointsChanged();

View file

@ -112,7 +112,7 @@ void JitBlockTableModel::UpdateSymbols()
void JitBlockTableModel::ConnectSlots()
{
auto* const host = Host::GetInstance();
connect(host, &Host::JitCacheCleared, this, &JitBlockTableModel::OnJitCacheCleared);
connect(host, &Host::JitCacheInvalidation, this, &JitBlockTableModel::OnJitCacheInvalidation);
connect(host, &Host::JitProfileDataWiped, this, &JitBlockTableModel::OnJitProfileDataWiped);
connect(host, &Host::UpdateDisasmDialog, this, &JitBlockTableModel::OnUpdateDisasmDialog);
connect(host, &Host::PPCSymbolsChanged, this, &JitBlockTableModel::OnPPCSymbolsUpdated);
@ -125,7 +125,7 @@ void JitBlockTableModel::ConnectSlots()
void JitBlockTableModel::DisconnectSlots()
{
auto* const host = Host::GetInstance();
disconnect(host, &Host::JitCacheCleared, this, &JitBlockTableModel::OnJitCacheCleared);
disconnect(host, &Host::JitCacheInvalidation, this, &JitBlockTableModel::OnJitCacheInvalidation);
disconnect(host, &Host::JitProfileDataWiped, this, &JitBlockTableModel::OnJitProfileDataWiped);
disconnect(host, &Host::UpdateDisasmDialog, this, &JitBlockTableModel::OnUpdateDisasmDialog);
disconnect(host, &Host::PPCSymbolsChanged, this, &JitBlockTableModel::OnPPCSymbolsUpdated);
@ -169,7 +169,7 @@ void JitBlockTableModel::OnFilterSymbolTextChanged(const QString& string)
m_filtering_by_symbols = !string.isEmpty();
}
void JitBlockTableModel::OnJitCacheCleared()
void JitBlockTableModel::OnJitCacheInvalidation()
{
Update(Core::GetState(m_system));
}
@ -187,7 +187,9 @@ void JitBlockTableModel::OnUpdateDisasmDialog()
void JitBlockTableModel::OnPPCSymbolsUpdated()
{
UpdateSymbols();
// Previously, this was only a call to `UpdateSymbols`, but HLE patch engine code can
// invalidate JIT blocks when specific symbols are loaded. What can be done about it?
Update(Core::GetState(m_system));
}
void JitBlockTableModel::OnPPCBreakpointsChanged()

View file

@ -106,7 +106,7 @@ private:
void Hide();
// Conditionally connected slots (external signals)
void OnJitCacheCleared();
void OnJitCacheInvalidation();
void OnJitProfileDataWiped();
void OnUpdateDisasmDialog();
void OnPPCSymbolsUpdated();

View file

@ -205,6 +205,7 @@
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
<ClCompile Include="QtUtils\NonDefaultQPushButton.cpp" />
<ClCompile Include="QtUtils\PartiallyClosableTabWidget.cpp" />
<ClCompile Include="QtUtils\QtUtils.cpp" />
<ClCompile Include="QtUtils\SetWindowDecorations.cpp" />
<ClCompile Include="QtUtils\UTF8CodePointCountValidator.cpp" />
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
@ -248,6 +249,7 @@
-->
<ItemGroup>
<ClInclude Include="Config\CheatCodeEditor.h" />
<ClInclude Include="Config\ConfigControls\ConfigControl.h" />
<ClInclude Include="Config\GameConfigEdit.h" />
<ClInclude Include="Config\Mapping\MappingCommon.h" />
<ClInclude Include="Config\Mapping\MappingIndicator.h" />
@ -412,6 +414,7 @@
<ClInclude Include="QtUtils\FromStdString.h" />
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
<ClInclude Include="QtUtils\QtUtils.h" />
<ClInclude Include="QtUtils\SetWindowDecorations.h" />
<QtMoc Include="QtUtils\UTF8CodePointCountValidator.h" />
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />

View file

@ -546,13 +546,13 @@ void GameList::OpenProperties()
return;
PropertiesDialog* properties = new PropertiesDialog(this, *game);
// Since the properties dialog locks the game file, it's important to free it as soon as it's
// closed so that the file can be moved or deleted.
properties->setAttribute(Qt::WA_DeleteOnClose, true);
connect(properties, &PropertiesDialog::OpenGeneralSettings, this, &GameList::OpenGeneralSettings);
connect(properties, &PropertiesDialog::OpenGraphicsSettings, this,
&GameList::OpenGraphicsSettings);
connect(properties, &PropertiesDialog::finished, this,
[properties]() { properties->deleteLater(); });
#ifdef USE_RETRO_ACHIEVEMENTS
connect(properties, &PropertiesDialog::OpenAchievementSettings, this,
&GameList::OpenAchievementSettings);

View file

@ -256,9 +256,9 @@ void Host_UpdateDisasmDialog()
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->UpdateDisasmDialog(); });
}
void Host_JitCacheCleared()
void Host_JitCacheInvalidation()
{
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->JitCacheCleared(); });
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->JitCacheInvalidation(); });
}
void Host_JitProfileDataWiped()
@ -271,6 +271,12 @@ void Host_PPCSymbolsChanged()
QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->PPCSymbolsChanged(); });
}
void Host_PPCBreakpointsChanged()
{
QueueOnObject(QApplication::instance(),
[] { emit Host::GetInstance()->PPCBreakpointsChanged(); });
}
// We ignore these, and their purpose should be questioned individually.
// In particular, RequestRenderWindowSize, RequestFullscreen, and
// UpdateMainFrame should almost certainly be removed.

View file

@ -40,7 +40,7 @@ signals:
void RequestStop();
void RequestRenderSize(int w, int h);
void UpdateDisasmDialog();
void JitCacheCleared();
void JitCacheInvalidation();
void JitProfileDataWiped();
void PPCSymbolsChanged();
void PPCBreakpointsChanged();

View file

@ -257,7 +257,8 @@ int main(int argc, char* argv[])
Settings::Instance().InitDefaultPalette();
Settings::Instance().ApplyStyle();
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
MainWindow win{Core::System::GetInstance(), std::move(boot),
static_cast<const char*>(options.get("movie"))};

View file

@ -219,9 +219,9 @@ static std::vector<std::string> StringListToStdVector(QStringList list)
return result;
}
MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
MainWindow::MainWindow(Core::System& system, std::unique_ptr<BootParameters> boot_parameters,
const std::string& movie_path)
: QMainWindow(nullptr)
: QMainWindow(nullptr), m_system(system)
{
setWindowTitle(QString::fromStdString(Common::GetScmRevStr()));
setWindowIcon(Resources::GetAppIcon());
@ -275,6 +275,8 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
#ifdef USE_RETRO_ACHIEVEMENTS
AchievementManager::GetInstance().Init();
if (AchievementManager::GetInstance().IsHardcoreModeActive())
Settings::Instance().SetDebugModeEnabled(false);
#endif // USE_RETRO_ACHIEVEMENTS
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
@ -292,7 +294,7 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
if (!movie_path.empty())
{
std::optional<std::string> savestate_path;
if (Core::System::GetInstance().GetMovie().PlayInput(movie_path, &savestate_path))
if (m_system.GetMovie().PlayInput(movie_path, &savestate_path))
{
m_pending_boot->boot_session_data.SetSavestateData(std::move(savestate_path),
DeleteSavestateAfterBoot::No);
@ -465,17 +467,17 @@ void MainWindow::CreateComponents()
m_wii_tas_input_windows[i] = new WiiTASInputWindow(nullptr, i);
}
m_jit_widget = new JITWidget(Core::System::GetInstance(), this);
m_jit_widget = new JITWidget(m_system, this);
m_log_widget = new LogWidget(this);
m_log_config_widget = new LogConfigWidget(this);
m_memory_widget = new MemoryWidget(Core::System::GetInstance(), this);
m_memory_widget = new MemoryWidget(m_system, this);
m_network_widget = new NetworkWidget(this);
m_register_widget = new RegisterWidget(this);
m_thread_widget = new ThreadWidget(this);
m_watch_widget = new WatchWidget(this);
m_breakpoint_widget = new BreakpointWidget(this);
m_code_widget = new CodeWidget(this);
m_cheats_manager = new CheatsManager(Core::System::GetInstance(), this);
m_cheats_manager = new CheatsManager(m_system, this);
m_assembler_widget = new AssemblerWidget(this);
const auto request_watch = [this](QString name, u32 addr) {
@ -512,7 +514,7 @@ void MainWindow::CreateComponents()
connect(m_memory_widget, &MemoryWidget::RequestWatch, request_watch);
connect(m_breakpoint_widget, &BreakpointWidget::ShowCode, [this](u32 address) {
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
});
connect(m_breakpoint_widget, &BreakpointWidget::ShowMemory, m_memory_widget,
@ -651,7 +653,7 @@ void MainWindow::ConnectHotkeys()
connect(m_hotkey_scheduler, &HotkeyScheduler::ConnectWiiRemote, this,
&MainWindow::OnConnectWiiRemote);
connect(m_hotkey_scheduler, &HotkeyScheduler::ToggleReadOnlyMode, [this] {
auto& movie = Core::System::GetInstance().GetMovie();
auto& movie = m_system.GetMovie();
bool read_only = !movie.IsReadOnly();
movie.SetReadOnly(read_only);
emit ReadOnlyModeChanged(read_only);
@ -808,14 +810,12 @@ void MainWindow::ChangeDisc()
if (paths.empty())
return;
auto& system = Core::System::GetInstance();
system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{system}, paths);
m_system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{m_system}, paths);
}
void MainWindow::EjectDisc()
{
auto& system = Core::System::GetInstance();
system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{system}, DVD::EjectCause::User);
m_system.GetDVDInterface().EjectDisc(Core::CPUThreadGuard{m_system}, DVD::EjectCause::User);
}
void MainWindow::OpenUserFolder()
@ -840,9 +840,9 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
// Otherwise, play the default game.
// Otherwise, play the last played game, if there is one.
// Otherwise, prompt for a new game.
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
{
Core::SetState(Core::System::GetInstance(), Core::State::Running);
Core::SetState(m_system, Core::State::Running);
}
else
{
@ -870,12 +870,12 @@ void MainWindow::Play(const std::optional<std::string>& savestate_path)
void MainWindow::Pause()
{
Core::SetState(Core::System::GetInstance(), Core::State::Paused);
Core::SetState(m_system, Core::State::Paused);
}
void MainWindow::TogglePause()
{
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
if (Core::GetState(m_system) == Core::State::Paused)
{
Play();
}
@ -918,7 +918,7 @@ void MainWindow::OnStopComplete()
bool MainWindow::RequestStop()
{
if (Core::IsUninitialized(Core::System::GetInstance()))
if (Core::IsUninitialized(m_system))
{
Core::QueueHostJob([this](Core::System&) { OnStopComplete(); }, true);
return true;
@ -944,13 +944,13 @@ bool MainWindow::RequestStop()
Common::ScopeGuard confirm_lock([this] { m_stop_confirm_showing = false; });
const Core::State state = Core::GetState(Core::System::GetInstance());
const Core::State state = Core::GetState(m_system);
// Only pause the game, if NetPlay is not running
bool pause = !Settings::Instance().GetNetPlayClient();
if (pause)
Core::SetState(Core::System::GetInstance(), Core::State::Paused);
Core::SetState(m_system, Core::State::Paused);
if (rendered_widget_was_active)
{
@ -980,7 +980,7 @@ bool MainWindow::RequestStop()
m_render_widget->SetWaitingForMessageBox(false);
if (pause)
Core::SetState(Core::System::GetInstance(), state);
Core::SetState(m_system, state);
return false;
}
@ -1001,8 +1001,8 @@ bool MainWindow::RequestStop()
// Unpause because gracefully shutting down needs the game to actually request a shutdown.
// TODO: Do not unpause in debug mode to allow debugging until the complete shutdown.
if (Core::GetState(Core::System::GetInstance()) == Core::State::Paused)
Core::SetState(Core::System::GetInstance(), Core::State::Running);
if (Core::GetState(m_system) == Core::State::Paused)
Core::SetState(m_system, Core::State::Running);
// Tell NetPlay about the power event
if (NetPlay::IsNetPlayRunning())
@ -1125,13 +1125,12 @@ bool MainWindow::RequestStopNetplay()
void MainWindow::ForceStop()
{
Core::Stop(Core::System::GetInstance());
Core::Stop(m_system);
}
void MainWindow::Reset()
{
auto& system = Core::System::GetInstance();
auto& movie = system.GetMovie();
auto& movie = m_system.GetMovie();
if (movie.IsRecordingInput())
movie.SetReset(true);
system.GetProcessorInterface().ResetButton_Tap_FromUser();
@ -1139,7 +1138,7 @@ void MainWindow::Reset()
void MainWindow::FrameAdvance()
{
Core::DoFrameStep(Core::System::GetInstance());
Core::DoFrameStep(m_system);
}
void MainWindow::FullScreen()
@ -1230,7 +1229,7 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
}
// If we're running, only start a new game once we've stopped the last.
if (!Core::IsUninitialized(Core::System::GetInstance()))
if (!Core::IsUninitialized(m_system))
{
if (!RequestStop())
return;
@ -1244,7 +1243,7 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
ShowRenderWidget();
// Boot up, show an error if it fails to load the game.
if (!BootManager::BootCore(Core::System::GetInstance(), std::move(parameters),
if (!BootManager::BootCore(m_system, std::move(parameters),
::GetWindowSystemInfo(m_render_widget->windowHandle())))
{
ModalMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
@ -1483,8 +1482,7 @@ void MainWindow::ShowFIFOPlayer()
{
if (!m_fifo_window)
{
m_fifo_window = new FIFOPlayerWindow(Core::System::GetInstance().GetFifoPlayer(),
Core::System::GetInstance().GetFifoRecorder());
m_fifo_window = new FIFOPlayerWindow(m_system.GetFifoPlayer(), m_system.GetFifoRecorder());
connect(m_fifo_window, &FIFOPlayerWindow::LoadFIFORequested, this,
[this](const QString& path) { StartGame(path, ScanForSecondDisc::No); });
}
@ -1530,7 +1528,7 @@ void MainWindow::StateLoad()
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::LoadAs(Core::System::GetInstance(), path.toStdString());
State::LoadAs(m_system, path.toStdString());
}
void MainWindow::StateSave()
@ -1542,47 +1540,47 @@ void MainWindow::StateSave()
this, tr("Select a File"), dialog_path, tr("All Save States (*.sav *.s##);; All Files (*)"));
Config::SetBase(Config::MAIN_CURRENT_STATE_PATH, QFileInfo(path).dir().path().toStdString());
if (!path.isEmpty())
State::SaveAs(Core::System::GetInstance(), path.toStdString());
State::SaveAs(m_system, path.toStdString());
}
void MainWindow::StateLoadSlot()
{
State::Load(Core::System::GetInstance(), m_state_slot);
State::Load(m_system, m_state_slot);
}
void MainWindow::StateSaveSlot()
{
State::Save(Core::System::GetInstance(), m_state_slot);
State::Save(m_system, m_state_slot);
}
void MainWindow::StateLoadSlotAt(int slot)
{
State::Load(Core::System::GetInstance(), slot);
State::Load(m_system, slot);
}
void MainWindow::StateLoadLastSavedAt(int slot)
{
State::LoadLastSaved(Core::System::GetInstance(), slot);
State::LoadLastSaved(m_system, slot);
}
void MainWindow::StateSaveSlotAt(int slot)
{
State::Save(Core::System::GetInstance(), slot);
State::Save(m_system, slot);
}
void MainWindow::StateLoadUndo()
{
State::UndoLoadState(Core::System::GetInstance());
State::UndoLoadState(m_system);
}
void MainWindow::StateSaveUndo()
{
State::UndoSaveState(Core::System::GetInstance());
State::UndoSaveState(m_system);
}
void MainWindow::StateSaveOldest()
{
State::SaveFirstSaved(Core::System::GetInstance());
State::SaveFirstSaved(m_system);
}
void MainWindow::SetStateSlot(int slot)
@ -1655,7 +1653,7 @@ void MainWindow::NetPlayInit()
bool MainWindow::NetPlayJoin()
{
if (!Core::IsUninitialized(Core::System::GetInstance()))
if (!Core::IsUninitialized(m_system))
{
ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!"));
@ -1722,7 +1720,7 @@ bool MainWindow::NetPlayJoin()
bool MainWindow::NetPlayHost(const UICommon::GameFile& game)
{
if (!Core::IsUninitialized(Core::System::GetInstance()))
if (!Core::IsUninitialized(m_system))
{
ModalMessageBox::critical(nullptr, tr("Error"),
tr("Can't start a NetPlay Session while a game is still running!"));
@ -1784,7 +1782,7 @@ void MainWindow::NetPlayQuit()
void MainWindow::UpdateScreenSaverInhibition()
{
const bool inhibit = Config::Get(Config::MAIN_DISABLE_SCREENSAVER) &&
(Core::GetState(Core::System::GetInstance()) == Core::State::Running);
(Core::GetState(m_system) == Core::State::Running);
if (inhibit == m_is_screensaver_inhibited)
return;
@ -1945,7 +1943,7 @@ void MainWindow::OnPlayRecording()
if (dtm_file.isEmpty())
return;
auto& movie = Core::System::GetInstance().GetMovie();
auto& movie = m_system.GetMovie();
if (!movie.IsReadOnly())
{
// let's make the read-only flag consistent at the start of a movie.
@ -1964,10 +1962,9 @@ void MainWindow::OnPlayRecording()
void MainWindow::OnStartRecording()
{
auto& system = Core::System::GetInstance();
auto& movie = system.GetMovie();
if (Core::GetState(system) == Core::State::Starting ||
Core::GetState(system) == Core::State::Stopping || movie.IsRecordingInput() ||
auto& movie = m_system.GetMovie();
if (Core::GetState(m_system) == Core::State::Starting ||
Core::GetState(m_system) == Core::State::Stopping || movie.IsRecordingInput() ||
movie.IsPlayingInput())
{
return;
@ -1999,14 +1996,14 @@ void MainWindow::OnStartRecording()
{
emit RecordingStatusChanged(true);
if (Core::IsUninitialized(system))
if (Core::IsUninitialized(m_system))
Play();
}
}
void MainWindow::OnStopRecording()
{
auto& movie = Core::System::GetInstance().GetMovie();
auto& movie = m_system.GetMovie();
if (movie.IsRecordingInput())
OnExportRecording();
if (movie.IsMovieActive())
@ -2016,13 +2013,12 @@ void MainWindow::OnStopRecording()
void MainWindow::OnExportRecording()
{
auto& system = Core::System::GetInstance();
const Core::CPUThreadGuard guard(system);
const Core::CPUThreadGuard guard(m_system);
QString dtm_file = DolphinFileDialog::getSaveFileName(
this, tr("Save Recording File As"), QString(), tr("Dolphin TAS Movies (*.dtm)"));
if (!dtm_file.isEmpty())
system.GetMovie().SaveRecording(dtm_file.toStdString());
m_system.GetMovie().SaveRecording(dtm_file.toStdString());
}
void MainWindow::OnActivateChat()
@ -2060,11 +2056,10 @@ void MainWindow::ShowTASInput()
}
}
auto& system = Core::System::GetInstance();
for (int i = 0; i < num_wii_controllers; i++)
{
if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated &&
(!Core::IsRunning(system) || system.IsWii()))
(!Core::IsRunning(m_system) || m_system.IsWii()))
{
SetQWidgetWindowDecorations(m_wii_tas_input_windows[i]);
m_wii_tas_input_windows[i]->show();
@ -2076,7 +2071,7 @@ void MainWindow::ShowTASInput()
void MainWindow::OnConnectWiiRemote(int id)
{
const Core::CPUThreadGuard guard(Core::System::GetInstance());
const Core::CPUThreadGuard guard(m_system);
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
{
const auto wm = bt->AccessWiimoteByIndex(id);

View file

@ -55,6 +55,11 @@ class WatchWidget;
class WiiTASInputWindow;
struct WindowSystemInfo;
namespace Core
{
class System;
}
namespace DiscIO
{
enum class Region;
@ -75,7 +80,7 @@ class MainWindow final : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(std::unique_ptr<BootParameters> boot_parameters,
explicit MainWindow(Core::System& system, std::unique_ptr<BootParameters> boot_parameters,
const std::string& movie_path);
~MainWindow();
@ -216,6 +221,8 @@ private:
QSize sizeHint() const override;
void ShowGeckoCodes();
Core::System& m_system;
#ifdef HAVE_XRANDR
std::unique_ptr<X11Utils::XRRConfiguration> m_xrr_config;
#endif

View file

@ -0,0 +1,22 @@
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/QtUtils/QtUtils.h"
#include <QDateTimeEdit>
namespace QtUtils
{
void ShowFourDigitYear(QDateTimeEdit* widget)
{
if (!widget->displayFormat().contains(QStringLiteral("yyyy")))
{
// Always show the full year, no matter what the locale specifies. Otherwise, two-digit years
// will always be interpreted as in the 21st century.
widget->setDisplayFormat(
widget->displayFormat().replace(QStringLiteral("yy"), QStringLiteral("yyyy")));
}
}
} // namespace QtUtils

View file

@ -0,0 +1,13 @@
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
class QDateTimeEdit;
namespace QtUtils
{
void ShowFourDigitYear(QDateTimeEdit* widget);
}

View file

@ -310,11 +310,9 @@ void Settings::RemovePath(const QString& qpath)
std::string path = qpath.toStdString();
std::vector<std::string> paths = Config::GetIsoPaths();
auto new_end = std::remove(paths.begin(), paths.end(), path);
if (new_end == paths.end())
if (std::erase(paths, path) == 0)
return;
paths.erase(new_end, paths.end());
Config::SetIsoPaths(paths);
emit PathRemoved(qpath);
}

View file

@ -24,6 +24,7 @@
#include "Core/System.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h"
@ -168,13 +169,7 @@ void AdvancedPane::CreateLayout()
m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace(
QStringLiteral("mm"), QStringLiteral("mm:ss")));
if (!m_custom_rtc_datetime->displayFormat().contains(QStringLiteral("yyyy")))
{
// Always show the full year, no matter what the locale specifies. Otherwise, two-digit years
// will always be interpreted as in the 21st century.
m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace(
QStringLiteral("yy"), QStringLiteral("yyyy")));
}
QtUtils::ShowFourDigitYear(m_custom_rtc_datetime);
m_custom_rtc_datetime->setDateTimeRange(QDateTime({2000, 1, 1}, {0, 0, 0}, Qt::UTC),
QDateTime({2099, 12, 31}, {23, 59, 59}, Qt::UTC));
m_custom_rtc_datetime->setTimeSpec(Qt::UTC);

View file

@ -163,7 +163,7 @@ void AudioPane::CreateWidgets()
auto* misc_layout = new QGridLayout;
misc_box->setLayout(misc_layout);
m_speed_up_mute_enable = new QCheckBox(tr("Mute When Disabling Speed Limit."));
m_speed_up_mute_enable = new QCheckBox(tr("Mute When Disabling Speed Limit"));
m_speed_up_mute_enable->setToolTip(
tr("Mutes the audio when overriding the emulation speed limit (default hotkey: Tab)."));

View file

@ -17,6 +17,7 @@
#include "Core/IOS/USB/Emulated/Skylanders/Skylander.h"
#include "Core/System.h"
#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
SkylanderModifyDialog::SkylanderModifyDialog(QWidget* parent, u8 slot)
@ -168,8 +169,9 @@ void SkylanderModifyDialog::PopulateSkylanderOptions(QVBoxLayout* layout)
edit_nick->setValidator(
new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^\\p{L}{0,15}$")), this));
edit_playtime->setValidator(new QIntValidator(0, INT_MAX, this));
edit_last_reset->setDisplayFormat(QStringLiteral("dd/MM/yyyy hh:mm"));
edit_last_placed->setDisplayFormat(QStringLiteral("dd/MM/yyyy hh:mm"));
QtUtils::ShowFourDigitYear(edit_last_reset);
QtUtils::ShowFourDigitYear(edit_last_placed);
edit_toy_code->setToolTip(tr("The toy code for this figure. Only available for real figures."));
edit_money->setToolTip(tr("The amount of money this Skylander has. Between 0 and 65000"));

View file

@ -25,14 +25,14 @@ IRWidget::IRWidget(QWidget* parent) : QWidget(parent)
void IRWidget::SetX(u16 x)
{
m_x = std::min(ir_max_x, x);
m_x = std::min(IR_MAX_X, x);
update();
}
void IRWidget::SetY(u16 y)
{
m_y = std::min(ir_max_y, y);
m_y = std::min(IR_MAX_Y, y);
update();
}
@ -54,8 +54,8 @@ void IRWidget::paintEvent(QPaintEvent* event)
painter.drawLine(PADDING + w / 2, PADDING, PADDING + w / 2, PADDING + h);
// convert from value space to widget space
u16 x = PADDING + ((m_x * w) / ir_max_x);
u16 y = PADDING + (h - (m_y * h) / ir_max_y);
u16 x = PADDING + ((m_x * w) / IR_MAX_X);
u16 y = PADDING + (h - (m_y * h) / IR_MAX_Y);
painter.drawLine(PADDING + w / 2, PADDING + h / 2, x, y);
@ -84,17 +84,17 @@ void IRWidget::handleMouseEvent(QMouseEvent* event)
if (event->button() == Qt::RightButton)
{
m_x = std::round(ir_max_x / 2.);
m_y = std::round(ir_max_y / 2.);
m_x = std::round(IR_MAX_X / 2.);
m_y = std::round(IR_MAX_Y / 2.);
}
else
{
// convert from widget space to value space
int new_x = (event->pos().x() * ir_max_x) / width();
int new_y = ir_max_y - (event->pos().y() * ir_max_y) / height();
int new_x = (event->pos().x() * IR_MAX_X) / width();
int new_y = IR_MAX_Y - (event->pos().y() * IR_MAX_Y) / height();
m_x = std::max(0, std::min(static_cast<int>(ir_max_x), new_x));
m_y = std::max(0, std::min(static_cast<int>(ir_max_y), new_y));
m_x = std::max(0, std::min(static_cast<int>(IR_MAX_X), new_x));
m_y = std::max(0, std::min(static_cast<int>(IR_MAX_Y), new_y));
}
bool changed = false;

View file

@ -13,6 +13,11 @@ class IRWidget : public QWidget
public:
explicit IRWidget(QWidget* parent);
static constexpr u16 IR_MIN_X = 0;
static constexpr u16 IR_MIN_Y = 0;
static constexpr u16 IR_MAX_X = 1023;
static constexpr u16 IR_MAX_Y = 767;
signals:
void ChangedX(u16 x);
void ChangedY(u16 y);
@ -32,9 +37,3 @@ private:
u16 m_y = 0;
bool m_ignore_movement = false;
};
// Should be part of class but fails to compile on mac os
static const u16 ir_min_x = 0;
static const u16 ir_min_y = 0;
static const u16 ir_max_x = 1023;
static const u16 ir_max_y = 767;

View file

@ -51,20 +51,20 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
const int ir_x_center = static_cast<int>(std::round(ir_max_x / 2.));
const int ir_y_center = static_cast<int>(std::round(ir_max_y / 2.));
const int ir_x_center = static_cast<int>(std::round(IRWidget::IR_MAX_X / 2.));
const int ir_y_center = static_cast<int>(std::round(IRWidget::IR_MAX_Y / 2.));
auto* x_layout = new QHBoxLayout;
m_ir_x_value = CreateSliderValuePair(
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::X_INPUT_OVERRIDE,
&m_wiimote_overrider, x_layout, ir_x_center, ir_x_center, ir_min_x, ir_max_x,
ir_x_shortcut_key_sequence, Qt::Horizontal, m_ir_box);
&m_wiimote_overrider, x_layout, ir_x_center, ir_x_center, IRWidget::IR_MIN_X,
IRWidget::IR_MAX_X, ir_x_shortcut_key_sequence, Qt::Horizontal, m_ir_box);
auto* y_layout = new QVBoxLayout;
m_ir_y_value = CreateSliderValuePair(
WiimoteEmu::Wiimote::IR_GROUP, ControllerEmu::ReshapableInput::Y_INPUT_OVERRIDE,
&m_wiimote_overrider, y_layout, ir_y_center, ir_y_center, ir_min_y, ir_max_y,
ir_y_shortcut_key_sequence, Qt::Vertical, m_ir_box);
&m_wiimote_overrider, y_layout, ir_y_center, ir_y_center, IRWidget::IR_MIN_Y,
IRWidget::IR_MAX_Y, ir_y_shortcut_key_sequence, Qt::Vertical, m_ir_box);
m_ir_y_value->setMaximumWidth(60);
auto* visual = new IRWidget(this);
@ -76,7 +76,7 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue);
connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue);
auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y);
auto* visual_ar = new AspectRatioWidget(visual, IRWidget::IR_MAX_X, IRWidget::IR_MAX_Y);
auto* visual_layout = new QHBoxLayout;
visual_layout->addWidget(visual_ar);