summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/configuration/config.cpp3
-rw-r--r--src/yuzu/configuration/configure_dialog.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.cpp30
-rw-r--r--src/yuzu/configuration/configure_general.h7
-rw-r--r--src/yuzu/configuration/configure_general.ui41
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.cpp19
-rw-r--r--src/yuzu/configuration/configure_input_player_widget.h2
-rw-r--r--src/yuzu/configuration/configure_per_game.cpp14
-rw-r--r--src/yuzu/configuration/configure_per_game.h4
-rw-r--r--src/yuzu/debugger/controller.cpp6
-rw-r--r--src/yuzu/game_list.cpp56
-rw-r--r--src/yuzu/game_list.h3
-rw-r--r--src/yuzu/game_list_worker.cpp12
-rw-r--r--src/yuzu/main.cpp67
-rw-r--r--src/yuzu/main.h5
-rw-r--r--src/yuzu/uisettings.h1
16 files changed, 206 insertions, 66 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index eb58bfa5b..e9d4bef60 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -255,7 +255,8 @@ void Config::Initialize(const std::string& config_name) {
Reload();
break;
case ConfigType::PerGameConfig:
- qt_config_loc = FS::PathToUTF8String(fs_config_loc / "custom" / config_file);
+ qt_config_loc =
+ FS::PathToUTF8String(fs_config_loc / "custom" / FS::ToU8String(config_file));
void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat);
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp
index 6028135c5..371bc01b1 100644
--- a/src/yuzu/configuration/configure_dialog.cpp
+++ b/src/yuzu/configuration/configure_dialog.cpp
@@ -27,6 +27,8 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
ui->inputTab->Initialize(input_subsystem);
+ ui->generalTab->SetResetCallback([&] { this->close(); });
+
SetConfiguration();
PopulateSelectionList();
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 55a6a37bd..38edb4d8d 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -2,11 +2,15 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <functional>
+#include <utility>
#include <QCheckBox>
+#include <QMessageBox>
#include <QSpinBox>
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_general.h"
+#include "yuzu/configuration/config.h"
#include "yuzu/configuration/configuration_shared.h"
#include "yuzu/configuration/configure_general.h"
#include "yuzu/uisettings.h"
@@ -23,6 +27,9 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
connect(ui->toggle_frame_limit, &QCheckBox::clicked, ui->frame_limit,
[this]() { ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); });
}
+
+ connect(ui->button_reset_defaults, &QPushButton::clicked, this,
+ &ConfigureGeneral::ResetDefaults);
}
ConfigureGeneral::~ConfigureGeneral() = default;
@@ -41,6 +48,8 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit.GetValue());
ui->frame_limit->setValue(Settings::values.frame_limit.GetValue());
+ ui->button_reset_defaults->setEnabled(runtime_lock);
+
if (Settings::IsConfiguringGlobal()) {
ui->frame_limit->setEnabled(Settings::values.use_frame_limit.GetValue());
} else {
@@ -49,6 +58,25 @@ void ConfigureGeneral::SetConfiguration() {
}
}
+// Called to set the callback when resetting settings to defaults
+void ConfigureGeneral::SetResetCallback(std::function<void()> callback) {
+ reset_callback = std::move(callback);
+}
+
+void ConfigureGeneral::ResetDefaults() {
+ QMessageBox::StandardButton answer = QMessageBox::question(
+ this, tr("yuzu"),
+ tr("This reset all settings and remove all per-game configurations. This will not delete "
+ "game directories, profiles, or input profiles. Proceed?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ if (answer == QMessageBox::No) {
+ return;
+ }
+ UISettings::values.reset_to_defaults = true;
+ UISettings::values.is_game_list_reload_pending.exchange(true);
+ reset_callback();
+}
+
void ConfigureGeneral::ApplyConfiguration() {
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, ui->use_multi_core,
use_multi_core);
@@ -105,6 +133,8 @@ void ConfigureGeneral::SetupPerGameUI() {
ui->toggle_background_pause->setVisible(false);
ui->toggle_hide_mouse->setVisible(false);
+ ui->button_reset_defaults->setVisible(false);
+
ConfigurationShared::SetColoredTristate(ui->toggle_frame_limit,
Settings::values.use_frame_limit, use_frame_limit);
ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core,
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h
index 323ffbd8f..a0fd52492 100644
--- a/src/yuzu/configuration/configure_general.h
+++ b/src/yuzu/configuration/configure_general.h
@@ -4,9 +4,12 @@
#pragma once
+#include <functional>
#include <memory>
#include <QWidget>
+class ConfigureDialog;
+
namespace ConfigurationShared {
enum class CheckState;
}
@@ -24,6 +27,8 @@ public:
explicit ConfigureGeneral(QWidget* parent = nullptr);
~ConfigureGeneral() override;
+ void SetResetCallback(std::function<void()> callback);
+ void ResetDefaults();
void ApplyConfiguration();
private:
@@ -34,6 +39,8 @@ private:
void SetupPerGameUI();
+ std::function<void()> reset_callback;
+
std::unique_ptr<Ui::ConfigureGeneral> ui;
ConfigurationShared::CheckState use_frame_limit;
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index 2711116a2..bc7041090 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>300</width>
+ <width>329</width>
<height>407</height>
</rect>
</property>
@@ -104,6 +104,45 @@
</property>
</spacer>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="layout_reset">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
+ <number>5</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="button_reset_defaults">
+ <property name="text">
+ <string>Reset All Settings</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer_reset">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
</layout>
</item>
</layout>
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp
index 61ba91cef..f50cda2f3 100644
--- a/src/yuzu/configuration/configure_input_player_widget.cpp
+++ b/src/yuzu/configuration/configure_input_player_widget.cpp
@@ -85,6 +85,8 @@ void PlayerControlPreview::SetConnectedStatus(bool checked) {
led_color[1] = led_pattern.position2 ? colors.led_on : colors.led_off;
led_color[2] = led_pattern.position3 ? colors.led_on : colors.led_off;
led_color[3] = led_pattern.position4 ? colors.led_on : colors.led_off;
+ is_enabled = checked;
+ ResetInputs();
}
void PlayerControlPreview::SetControllerType(const Settings::ControllerType type) {
@@ -108,6 +110,7 @@ void PlayerControlPreview::EndMapping() {
analog_mapping_index = Settings::NativeAnalog::NumAnalogs;
mapping_active = false;
blink_counter = 0;
+ ResetInputs();
}
void PlayerControlPreview::UpdateColors() {
@@ -156,7 +159,23 @@ void PlayerControlPreview::UpdateColors() {
// colors.right = QColor(Settings::values.players.GetValue()[player_index].body_color_right);
}
+void PlayerControlPreview::ResetInputs() {
+ for (std::size_t index = 0; index < button_values.size(); ++index) {
+ button_values[index] = false;
+ }
+
+ for (std::size_t index = 0; index < axis_values.size(); ++index) {
+ axis_values[index].properties = {0, 1, 0};
+ axis_values[index].value = {0, 0};
+ axis_values[index].raw_value = {0, 0};
+ }
+ update();
+}
+
void PlayerControlPreview::UpdateInput() {
+ if (!is_enabled && !mapping_active) {
+ return;
+ }
bool input_changed = false;
const auto& button_state = buttons;
for (std::size_t index = 0; index < button_values.size(); ++index) {
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h
index 51bb84eb6..5fc16d8af 100644
--- a/src/yuzu/configuration/configure_input_player_widget.h
+++ b/src/yuzu/configuration/configure_input_player_widget.h
@@ -100,6 +100,7 @@ private:
static LedPattern GetColorPattern(std::size_t index, bool player_on);
void UpdateColors();
+ void ResetInputs();
// Draw controller functions
void DrawHandheldController(QPainter& p, QPointF center);
@@ -176,6 +177,7 @@ private:
using StickArray =
std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>;
+ bool is_enabled{};
bool mapping_active{};
int blink_counter{};
QColor button_color{};
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp
index d89f1ad4b..a1d434aca 100644
--- a/src/yuzu/configuration/configure_per_game.cpp
+++ b/src/yuzu/configuration/configure_per_game.cpp
@@ -3,9 +3,13 @@
// Refer to the license.txt file included.
#include <algorithm>
+#include <filesystem>
#include <memory>
+#include <string>
#include <utility>
+#include <fmt/format.h>
+
#include <QAbstractButton>
#include <QCheckBox>
#include <QDialogButtonBox>
@@ -17,6 +21,8 @@
#include <QTimer>
#include <QTreeView>
+#include "common/fs/fs_util.h"
+#include "common/fs/path_util.h"
#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
@@ -29,10 +35,12 @@
#include "yuzu/uisettings.h"
#include "yuzu/util/util.h"
-ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
+ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id, const std::string& file_name)
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
- game_config = std::make_unique<Config>(fmt::format("{:016X}", title_id),
- Config::ConfigType::PerGameConfig);
+ const auto file_path = std::filesystem::path(Common::FS::ToU8String(file_name));
+ const auto config_file_name = title_id == 0 ? Common::FS::PathToUTF8String(file_path.filename())
+ : fmt::format("{:016X}", title_id);
+ game_config = std::make_unique<Config>(config_file_name, Config::ConfigType::PerGameConfig);
Settings::SetConfiguringGlobal(false);
diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h
index f6e6ab7c4..a2d0211a3 100644
--- a/src/yuzu/configuration/configure_per_game.h
+++ b/src/yuzu/configuration/configure_per_game.h
@@ -5,6 +5,7 @@
#pragma once
#include <memory>
+#include <string>
#include <vector>
#include <QDialog>
@@ -27,7 +28,8 @@ class ConfigurePerGame : public QDialog {
Q_OBJECT
public:
- explicit ConfigurePerGame(QWidget* parent, u64 title_id);
+ // Cannot use std::filesystem::path due to https://bugreports.qt.io/browse/QTBUG-73263
+ explicit ConfigurePerGame(QWidget* parent, u64 title_id, const std::string& file_name);
~ConfigurePerGame() override;
/// Save all button configurations to settings file
diff --git a/src/yuzu/debugger/controller.cpp b/src/yuzu/debugger/controller.cpp
index d85408ac6..c1fc69578 100644
--- a/src/yuzu/debugger/controller.cpp
+++ b/src/yuzu/debugger/controller.cpp
@@ -28,6 +28,7 @@ ControllerDialog::ControllerDialog(QWidget* parent) : QWidget(parent, Qt::Dialog
// Configure focus so that widget is focusable and the dialog automatically forwards focus to
// it.
setFocusProxy(widget);
+ widget->SetConnectedStatus(false);
widget->setFocusPolicy(Qt::StrongFocus);
widget->setFocus();
}
@@ -36,9 +37,8 @@ void ControllerDialog::refreshConfiguration() {
const auto& players = Settings::values.players.GetValue();
constexpr std::size_t player = 0;
widget->SetPlayerInputRaw(player, players[player].buttons, players[player].analogs);
- widget->SetConnectedStatus(players[player].connected);
widget->SetControllerType(players[player].controller_type);
- widget->repaint();
+ widget->SetConnectedStatus(players[player].connected);
}
QAction* ControllerDialog::toggleViewAction() {
@@ -56,6 +56,7 @@ void ControllerDialog::showEvent(QShowEvent* ev) {
if (toggle_view_action) {
toggle_view_action->setChecked(isVisible());
}
+ refreshConfiguration();
QWidget::showEvent(ev);
}
@@ -63,5 +64,6 @@ void ControllerDialog::hideEvent(QHideEvent* ev) {
if (toggle_view_action) {
toggle_view_action->setChecked(isVisible());
}
+ widget->SetConnectedStatus(false);
QWidget::hideEvent(ev);
}
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 63cf82f7d..9308cfef8 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -91,9 +91,8 @@ QString GameListSearchField::filterText() const {
QString GameList::GetLastFilterResultItem() const {
QString file_path;
- const int folder_count = item_model->rowCount();
- for (int i = 0; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
const QStandardItem* folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -184,7 +183,6 @@ void GameList::OnItemExpanded(const QModelIndex& item) {
// Event in order to filter the gamelist after editing the searchfield
void GameList::OnTextChanged(const QString& new_text) {
- const int folder_count = tree_view->model()->rowCount();
QString edit_filter_text = new_text.toLower();
QStandardItem* folder;
int children_total = 0;
@@ -194,7 +192,7 @@ void GameList::OnTextChanged(const QString& new_text) {
if (edit_filter_text.isEmpty()) {
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(),
UISettings::values.favorited_ids.size() == 0);
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -207,7 +205,7 @@ void GameList::OnTextChanged(const QString& new_text) {
} else {
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true);
int result_count = 0;
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -328,18 +326,14 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide
tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
- item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1);
+ item_model->insertColumns(0, COLUMN_COUNT);
item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
- if (UISettings::values.show_add_ons) {
- item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
- item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
- } else {
- item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
- }
+ item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
+ tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons);
+ item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
+ item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
item_model->setSortRole(GameListItemPath::SortRole);
connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons);
@@ -466,9 +460,8 @@ void GameList::DonePopulating(const QStringList& watch_list) {
QCoreApplication::processEvents();
}
tree_view->setEnabled(true);
- const int folder_count = tree_view->model()->rowCount();
int children_total = 0;
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
children_total += item_model->item(i, 0)->rowCount();
}
search_field->setFilterResult(children_total, children_total);
@@ -561,11 +554,11 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
connect(remove_dlc, &QAction::triggered, [this, program_id]() {
emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::AddOnContent);
});
- connect(remove_shader_cache, &QAction::triggered, [this, program_id]() {
- emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache);
+ connect(remove_shader_cache, &QAction::triggered, [this, program_id, path]() {
+ emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache, path);
});
- connect(remove_custom_config, &QAction::triggered, [this, program_id]() {
- emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration);
+ connect(remove_custom_config, &QAction::triggered, [this, program_id, path]() {
+ emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration, path);
});
connect(dump_romfs, &QAction::triggered,
[this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
@@ -649,9 +642,9 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) {
}
void GameList::AddFavoritesPopup(QMenu& context_menu) {
- QAction* clear_all = context_menu.addAction(tr("Clear"));
+ QAction* clear = context_menu.addAction(tr("Clear"));
- connect(clear_all, &QAction::triggered, [this] {
+ connect(clear, &QAction::triggered, [this] {
for (const auto id : UISettings::values.favorited_ids) {
RemoveFavorite(id);
}
@@ -708,22 +701,7 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
tree_view->setEnabled(false);
// Update the columns in case UISettings has changed
- item_model->removeColumns(0, item_model->columnCount());
- item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1);
- item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
- item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
-
- if (UISettings::values.show_add_ons) {
- item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
- item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
- } else {
- item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
- item_model->removeColumns(COLUMN_COUNT - 1, 1);
- }
-
- LoadInterfaceLayout();
+ tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons);
// Delete any rows that might already exist if we're repopulating
item_model->removeRows(0, item_model->rowCount());
@@ -800,7 +778,7 @@ void GameList::AddFavorite(u64 program_id) {
if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() ==
program_id) {
QList<QStandardItem*> list;
- for (int k = 0; k < item_model->columnCount(); k++) {
+ for (int k = 0; k < COLUMN_COUNT; k++) {
list.append(folder->child(j, k)->clone());
}
list[0]->setData(folder->child(j)->data(GameListItem::SortRole),
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 9c0a1a482..ab6866735 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -88,7 +88,8 @@ signals:
const std::string& game_path);
void OpenTransferableShaderCacheRequested(u64 program_id);
void RemoveInstalledEntryRequested(u64 program_id, InstalledEntryType type);
- void RemoveFileRequested(u64 program_id, GameListRemoveTarget target);
+ void RemoveFileRequested(u64 program_id, GameListRemoveTarget target,
+ const std::string& game_path);
void DumpRomFSRequested(u64 program_id, const std::string& game_path);
void CopyTIDRequested(u64 program_id);
void NavigateToGamedbEntryRequested(u64 program_id,
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index 485045334..33cc90d5a 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -215,13 +215,11 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
new GameListItemSize(Common::FS::GetSize(path)),
};
- if (UISettings::values.show_add_ons) {
- const auto patch_versions = GetGameListCachedObject(
- fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] {
- return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable());
- });
- list.insert(2, new GameListItem(patch_versions));
- }
+ const auto patch_versions = GetGameListCachedObject(
+ fmt::format("{:016X}", patch.GetTitleID()), "pv.txt", [&patch, &loader] {
+ return FormatPatchNameVersions(patch, loader, loader.IsRomFSUpdatable());
+ });
+ list.insert(2, new GameListItem(patch_versions));
return list;
}
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 0f0e228b0..e683fb920 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1334,7 +1334,11 @@ void GMainWindow::BootGame(const QString& filename, std::size_t program_index) {
if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) {
// Load per game settings
- Config per_game_config(fmt::format("{:016X}", title_id), Config::ConfigType::PerGameConfig);
+ const auto file_path = std::filesystem::path{filename.toStdU16String()};
+ const auto config_file_name = title_id == 0
+ ? Common::FS::PathToUTF8String(file_path.filename())
+ : fmt::format("{:016X}", title_id);
+ Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig);
}
ConfigureVibration::SetAllVibrationDevices();
@@ -1795,7 +1799,8 @@ void GMainWindow::RemoveAddOnContent(u64 program_id, const QString& entry_type)
tr("Successfully removed %1 installed DLC.").arg(count));
}
-void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) {
+void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target,
+ const std::string& game_path) {
const QString question = [this, target] {
switch (target) {
case GameListRemoveTarget::ShaderCache:
@@ -1817,7 +1822,7 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
RemoveTransferableShaderCache(program_id);
break;
case GameListRemoveTarget::CustomConfiguration:
- RemoveCustomConfiguration(program_id);
+ RemoveCustomConfiguration(program_id, game_path);
break;
}
}
@@ -1842,9 +1847,13 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id) {
}
}
-void GMainWindow::RemoveCustomConfiguration(u64 program_id) {
- const auto custom_config_file_path = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) /
- "custom" / fmt::format("{:016X}.ini", program_id);
+void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& game_path) {
+ const auto file_path = std::filesystem::path(Common::FS::ToU8String(game_path));
+ const auto config_file_name =
+ program_id == 0 ? Common::FS::PathToUTF8String(file_path.filename()).append(".ini")
+ : fmt::format("{:016X}.ini", program_id);
+ const auto custom_config_file_path =
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom" / config_file_name;
if (!Common::FS::Exists(custom_config_file_path)) {
QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
@@ -2587,13 +2596,53 @@ void GMainWindow::OnConfigure() {
&GMainWindow::OnLanguageChanged);
const auto result = configure_dialog.exec();
- if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
+ if (result != QDialog::Accepted && !UISettings::values.configuration_applied &&
+ !UISettings::values.reset_to_defaults) {
+ // Runs if the user hit Cancel or closed the window, and did not ever press the Apply button
+ // or `Reset to Defaults` button
return;
} else if (result == QDialog::Accepted) {
+ // Only apply new changes if user hit Okay
+ // This is here to avoid applying changes if the user hit Apply, made some changes, then hit
+ // Cancel
configure_dialog.ApplyConfiguration();
- controller_dialog->refreshConfiguration();
+ } else if (UISettings::values.reset_to_defaults) {
+ LOG_INFO(Frontend, "Resetting all settings to defaults");
+ if (!Common::FS::RemoveFile(config->GetConfigFilePath())) {
+ LOG_WARNING(Frontend, "Failed to remove configuration file");
+ }
+ if (!Common::FS::RemoveDirContentsRecursively(
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "custom")) {
+ LOG_WARNING(Frontend, "Failed to remove custom configuration files");
+ }
+ if (!Common::FS::RemoveDirRecursively(
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) {
+ LOG_WARNING(Frontend, "Failed to remove game metadata cache files");
+ }
+
+ // Explicitly save the game directories, since reinitializing config does not explicitly do
+ // so.
+ QVector<UISettings::GameDir> old_game_dirs = std::move(UISettings::values.game_dirs);
+ QVector<u64> old_favorited_ids = std::move(UISettings::values.favorited_ids);
+
+ Settings::values.disabled_addons.clear();
+
+ config = std::make_unique<Config>();
+ UISettings::values.reset_to_defaults = false;
+
+ UISettings::values.game_dirs = std::move(old_game_dirs);
+ UISettings::values.favorited_ids = std::move(old_favorited_ids);
+
+ InitializeRecentFileMenuActions();
+
+ SetDefaultUIGeometry();
+ RestoreUIState();
+
+ ShowTelemetryCallout();
}
+ controller_dialog->refreshConfiguration();
InitializeHotkeys();
+
if (UISettings::values.theme != old_theme) {
UpdateUITheme();
}
@@ -2635,7 +2684,7 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
const auto v_file = Core::GetGameFileFromPath(vfs, file_name);
const auto& system = Core::System::GetInstance();
- ConfigurePerGame dialog(this, title_id);
+ ConfigurePerGame dialog(this, title_id, file_name);
dialog.LoadFromFile(v_file);
const auto result = dialog.exec();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index b3a5033ce..490b6889f 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -236,7 +236,8 @@ private slots:
const std::string& game_path);
void OnTransferableShaderCacheOpenFile(u64 program_id);
void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type);
- void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target);
+ void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target,
+ const std::string& game_path);
void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
void OnGameListCopyTID(u64 program_id);
void OnGameListNavigateToGamedbEntry(u64 program_id,
@@ -275,7 +276,7 @@ private:
void RemoveUpdateContent(u64 program_id, const QString& entry_type);
void RemoveAddOnContent(u64 program_id, const QString& entry_type);
void RemoveTransferableShaderCache(u64 program_id);
- void RemoveCustomConfiguration(u64 program_id);
+ void RemoveCustomConfiguration(u64 program_id, const std::string& game_path);
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
InstallResult InstallNSPXCI(const QString& filename);
InstallResult InstallNCA(const QString& filename);
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index 49122ec32..cdcb83f9f 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -97,6 +97,7 @@ struct Values {
bool cache_game_list;
bool configuration_applied;
+ bool reset_to_defaults;
};
extern Values values;