mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 10:43:33 +00:00
Merge pull request 'feat: New Autoloader & Rebrand Current to "Update Manager"' (#66) from feat/autoloader-update-manager into main
Reviewed-on: https://git.citron-emu.org/Citron/Emulator/pulls/66
This commit is contained in:
@@ -44,7 +44,9 @@
|
|||||||
#include "citron/configuration/configure_ui.h"
|
#include "citron/configuration/configure_ui.h"
|
||||||
#include "citron/configuration/configure_web.h"
|
#include "citron/configuration/configure_web.h"
|
||||||
#include "citron/configuration/style_animation_event_filter.h"
|
#include "citron/configuration/style_animation_event_filter.h"
|
||||||
|
#include "citron/game_list.h"
|
||||||
#include "citron/hotkeys.h"
|
#include "citron/hotkeys.h"
|
||||||
|
#include "citron/main.h"
|
||||||
#include "citron/theme.h"
|
#include "citron/theme.h"
|
||||||
#include "citron/uisettings.h"
|
#include "citron/uisettings.h"
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
|||||||
InputCommon::InputSubsystem* input_subsystem,
|
InputCommon::InputSubsystem* input_subsystem,
|
||||||
std::vector<VkDeviceInfo::Record>& vk_device_records,
|
std::vector<VkDeviceInfo::Record>& vk_device_records,
|
||||||
Core::System& system_, bool enable_web_config)
|
Core::System& system_, bool enable_web_config)
|
||||||
|
|
||||||
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, registry(registry_),
|
: QDialog(parent), ui{std::make_unique<Ui::ConfigureDialog>()}, registry(registry_),
|
||||||
system{system_},
|
system{system_},
|
||||||
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
|
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
|
||||||
@@ -98,6 +101,11 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_,
|
|||||||
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)},
|
system_tab{std::make_unique<ConfigureSystem>(system_, nullptr, *builder, this)},
|
||||||
web_tab{std::make_unique<ConfigureWeb>(this)}, rainbow_timer{new QTimer(this)} {
|
web_tab{std::make_unique<ConfigureWeb>(this)}, rainbow_timer{new QTimer(this)} {
|
||||||
|
|
||||||
|
if (auto* main_window = qobject_cast<GMainWindow*>(parent)) {
|
||||||
|
connect(filesystem_tab.get(), &ConfigureFilesystem::RequestGameListRefresh,
|
||||||
|
main_window, &GMainWindow::RefreshGameList);
|
||||||
|
}
|
||||||
|
|
||||||
Settings::SetConfiguringGlobal(true);
|
Settings::SetConfiguringGlobal(true);
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint |
|
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowSystemMenuHint |
|
||||||
Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
||||||
@@ -267,7 +275,6 @@ void ConfigureDialog::SetUIPositioning(const QString& positioning) {
|
|||||||
for (QPushButton* button : tab_buttons) {
|
for (QPushButton* button : tab_buttons) {
|
||||||
h_layout->removeWidget(button);
|
h_layout->removeWidget(button);
|
||||||
v_layout->addWidget(button);
|
v_layout->addWidget(button);
|
||||||
// Reset the inline stylesheet so it uses the main template's style.
|
|
||||||
button->setStyleSheet(QStringLiteral(""));
|
button->setStyleSheet(QStringLiteral(""));
|
||||||
}
|
}
|
||||||
v_layout->addStretch(1);
|
v_layout->addStretch(1);
|
||||||
@@ -344,13 +351,11 @@ void ConfigureDialog::AnimateTabSwitch(int id) {
|
|||||||
|
|
||||||
const int duration = 400;
|
const int duration = 400;
|
||||||
|
|
||||||
// Prepare Widgets for Live Animation
|
|
||||||
next_widget->setGeometry(0, 0, ui->stackedWidget->width(), ui->stackedWidget->height());
|
next_widget->setGeometry(0, 0, ui->stackedWidget->width(), ui->stackedWidget->height());
|
||||||
next_widget->move(0, 0);
|
next_widget->move(0, 0);
|
||||||
next_widget->show();
|
next_widget->show();
|
||||||
next_widget->raise();
|
next_widget->raise();
|
||||||
|
|
||||||
// Animation Logic
|
|
||||||
auto anim_old_pos = new QPropertyAnimation(current_widget, "pos");
|
auto anim_old_pos = new QPropertyAnimation(current_widget, "pos");
|
||||||
anim_old_pos->setEndValue(QPoint(-ui->stackedWidget->width(), 0));
|
anim_old_pos->setEndValue(QPoint(-ui->stackedWidget->width(), 0));
|
||||||
anim_old_pos->setDuration(duration);
|
anim_old_pos->setDuration(duration);
|
||||||
@@ -401,9 +406,7 @@ void ConfigureDialog::AnimateTabSwitch(int id) {
|
|||||||
connect(animation_group, &QAbstractAnimation::finished, this, [this, current_widget, next_widget, id]() {
|
connect(animation_group, &QAbstractAnimation::finished, this, [this, current_widget, next_widget, id]() {
|
||||||
ui->stackedWidget->setCurrentIndex(id);
|
ui->stackedWidget->setCurrentIndex(id);
|
||||||
|
|
||||||
// Clean up graphics effects to return control to the stylesheet
|
|
||||||
next_widget->setGraphicsEffect(nullptr);
|
next_widget->setGraphicsEffect(nullptr);
|
||||||
// Ensure the old widget is hidden and reset for next time
|
|
||||||
current_widget->hide();
|
current_widget->hide();
|
||||||
current_widget->move(0, 0);
|
current_widget->move(0, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class ConfigureProfileManager;
|
|||||||
class ConfigureSystem;
|
class ConfigureSystem;
|
||||||
class ConfigureUi;
|
class ConfigureUi;
|
||||||
class ConfigureWeb;
|
class ConfigureWeb;
|
||||||
|
class GameList;
|
||||||
|
|
||||||
class ConfigureDialog final : public QDialog {
|
class ConfigureDialog final : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -49,6 +50,8 @@ public:
|
|||||||
|
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
|
|
||||||
|
ConfigureFilesystem* GetFilesystemTab() const { return filesystem_tab.get(); }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void UpdateTheme();
|
void UpdateTheme();
|
||||||
|
|
||||||
|
|||||||
@@ -2,155 +2,183 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "citron/configuration/configure_filesystem.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
#include <thread>
|
||||||
|
#include "citron/main.h"
|
||||||
|
#include "citron/uisettings.h"
|
||||||
#include "common/fs/fs.h"
|
#include "common/fs/fs.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
|
#include "common/literals.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
#include "frontend_common/content_manager.h"
|
||||||
#include "ui_configure_filesystem.h"
|
#include "ui_configure_filesystem.h"
|
||||||
#include "citron/configuration/configure_filesystem.h"
|
|
||||||
#include "citron/uisettings.h"
|
static constexpr size_t CopyBufferSize = 0x400000;
|
||||||
|
|
||||||
ConfigureFilesystem::ConfigureFilesystem(QWidget* parent)
|
ConfigureFilesystem::ConfigureFilesystem(QWidget* parent)
|
||||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureFilesystem>()) {
|
: QWidget(parent), ui(std::make_unique<Ui::ConfigureFilesystem>()) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
|
|
||||||
connect(ui->nand_directory_button, &QToolButton::pressed, this,
|
connect(ui->run_autoloader_button, &QPushButton::clicked, this, &ConfigureFilesystem::OnRunAutoloader);
|
||||||
[this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); });
|
connect(ui->nand_directory_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::NAND, ui->nand_directory_edit); });
|
||||||
connect(ui->sdmc_directory_button, &QToolButton::pressed, this,
|
connect(ui->sdmc_directory_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::SD, ui->sdmc_directory_edit); });
|
||||||
[this] { SetDirectory(DirectoryTarget::SD, ui->sdmc_directory_edit); });
|
connect(ui->gamecard_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Gamecard, ui->gamecard_path_edit); });
|
||||||
connect(ui->gamecard_path_button, &QToolButton::pressed, this,
|
connect(ui->dump_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Dump, ui->dump_path_edit); });
|
||||||
[this] { SetDirectory(DirectoryTarget::Gamecard, ui->gamecard_path_edit); });
|
connect(ui->load_path_button, &QToolButton::pressed, this, [this] { SetDirectory(DirectoryTarget::Load, ui->load_path_edit); });
|
||||||
connect(ui->dump_path_button, &QToolButton::pressed, this,
|
connect(ui->reset_game_list_cache, &QPushButton::pressed, this, &ConfigureFilesystem::ResetMetadata);
|
||||||
[this] { SetDirectory(DirectoryTarget::Dump, ui->dump_path_edit); });
|
connect(ui->gamecard_inserted, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls);
|
||||||
connect(ui->load_path_button, &QToolButton::pressed, this,
|
connect(ui->gamecard_current_game, &QCheckBox::checkStateChanged, this, &ConfigureFilesystem::UpdateEnabledControls);
|
||||||
[this] { SetDirectory(DirectoryTarget::Load, ui->load_path_edit); });
|
|
||||||
|
|
||||||
connect(ui->reset_game_list_cache, &QPushButton::pressed, this,
|
connect(this, &ConfigureFilesystem::UpdateInstallProgress, this, &ConfigureFilesystem::OnUpdateInstallProgress);
|
||||||
&ConfigureFilesystem::ResetMetadata);
|
|
||||||
|
|
||||||
connect(ui->gamecard_inserted, &QCheckBox::checkStateChanged, this,
|
|
||||||
&ConfigureFilesystem::UpdateEnabledControls);
|
|
||||||
connect(ui->gamecard_current_game, &QCheckBox::checkStateChanged, this,
|
|
||||||
&ConfigureFilesystem::UpdateEnabledControls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureFilesystem::~ConfigureFilesystem() = default;
|
ConfigureFilesystem::~ConfigureFilesystem() = default;
|
||||||
|
|
||||||
void ConfigureFilesystem::changeEvent(QEvent* event) {
|
void ConfigureFilesystem::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) { RetranslateUI(); } QWidget::changeEvent(event); }
|
||||||
if (event->type() == QEvent::LanguageChange) {
|
void ConfigureFilesystem::SetConfiguration() { ui->nand_directory_edit->setText(QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::NANDDir))); ui->sdmc_directory_edit->setText(QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir))); ui->gamecard_path_edit->setText(QString::fromStdString(Settings::values.gamecard_path.GetValue())); ui->dump_path_edit->setText(QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::DumpDir))); ui->load_path_edit->setText(QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::LoadDir))); ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted.GetValue()); ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game.GetValue()); ui->dump_exefs->setChecked(Settings::values.dump_exefs.GetValue()); ui->dump_nso->setChecked(Settings::values.dump_nso.GetValue()); ui->cache_game_list->setChecked(UISettings::values.cache_game_list.GetValue()); ui->prompt_for_autoloader->setChecked(UISettings::values.prompt_for_autoloader.GetValue()); UpdateEnabledControls(); }
|
||||||
RetranslateUI();
|
void ConfigureFilesystem::ApplyConfiguration() { Common::FS::SetCitronPath(Common::FS::CitronPath::NANDDir, ui->nand_directory_edit->text().toStdString()); Common::FS::SetCitronPath(Common::FS::CitronPath::SDMCDir, ui->sdmc_directory_edit->text().toStdString()); Common::FS::SetCitronPath(Common::FS::CitronPath::DumpDir, ui->dump_path_edit->text().toStdString()); Common::FS::SetCitronPath(Common::FS::CitronPath::LoadDir, ui->load_path_edit->text().toStdString()); Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked(); Settings::values.gamecard_current_game = ui->gamecard_current_game->isChecked(); Settings::values.dump_exefs = ui->dump_exefs->isChecked(); Settings::values.dump_nso = ui->dump_nso->isChecked(); UISettings::values.cache_game_list = ui->cache_game_list->isChecked(); UISettings::values.prompt_for_autoloader = ui->prompt_for_autoloader->isChecked(); }
|
||||||
}
|
void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) { QString caption; switch (target) { case DirectoryTarget::NAND: caption = tr("Select Emulated NAND Directory..."); break; case DirectoryTarget::SD: caption = tr("Select Emulated SD Directory..."); break; case DirectoryTarget::Gamecard: caption = tr("Select Gamecard Path..."); break; case DirectoryTarget::Dump: caption = tr("Select Dump Directory..."); break; case DirectoryTarget::Load: caption = tr("Select Mod Load Directory..."); break; } QString str; if (target == DirectoryTarget::Gamecard) { str = QFileDialog::getOpenFileName(this, caption, QFileInfo(edit->text()).dir().path(), QStringLiteral("NX Gamecard;*.xci")); } else { str = QFileDialog::getExistingDirectory(this, caption, edit->text()); } if (str.isNull() || str.isEmpty()) { return; } if (str.back() != QChar::fromLatin1('/')) { str.append(QChar::fromLatin1('/')); } edit->setText(str); }
|
||||||
|
void ConfigureFilesystem::ResetMetadata() { if (!Common::FS::Exists(Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list/")) { QMessageBox::information(this, tr("Reset Metadata Cache"), tr("The metadata cache is already empty.")); } else if (Common::FS::RemoveDirRecursively(Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list")) { QMessageBox::information(this, tr("Reset Metadata Cache"), tr("The operation completed successfully.")); UISettings::values.is_game_list_reload_pending.exchange(true); } else { QMessageBox::warning(this, tr("Reset Metadata Cache"), tr("The metadata cache couldn't be deleted. It might be in use or non-existent.")); } }
|
||||||
|
void ConfigureFilesystem::UpdateEnabledControls() { ui->gamecard_current_game->setEnabled(ui->gamecard_inserted->isChecked()); ui->gamecard_path_edit->setEnabled(ui->gamecard_inserted->isChecked() && !ui->gamecard_current_game->isChecked()); ui->gamecard_path_button->setEnabled(ui->gamecard_inserted->isChecked() && !ui->gamecard_current_game->isChecked()); }
|
||||||
|
void ConfigureFilesystem::RetranslateUI() { ui->retranslateUi(this); }
|
||||||
|
|
||||||
QWidget::changeEvent(event);
|
void ConfigureFilesystem::OnUpdateInstallProgress() {
|
||||||
|
if (install_progress) {
|
||||||
|
install_progress->setValue(install_progress->value() + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureFilesystem::SetConfiguration() {
|
void ConfigureFilesystem::OnRunAutoloader(bool skip_confirmation) {
|
||||||
ui->nand_directory_edit->setText(
|
if (!skip_confirmation) {
|
||||||
QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::NANDDir)));
|
QMessageBox msgBox;
|
||||||
ui->sdmc_directory_edit->setText(
|
msgBox.setWindowTitle(tr("Begin Autoloader?"));
|
||||||
QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir)));
|
msgBox.setText(tr("The Autoloader will scan your Game Directories for all .nsp files "
|
||||||
ui->gamecard_path_edit->setText(
|
"and attempt to install any found updates or DLC. This may take a while."));
|
||||||
QString::fromStdString(Settings::values.gamecard_path.GetValue()));
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
ui->dump_path_edit->setText(
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::DumpDir)));
|
if (msgBox.exec() != QMessageBox::Ok) {
|
||||||
ui->load_path_edit->setText(
|
return;
|
||||||
QString::fromStdString(Common::FS::GetCitronPathString(Common::FS::CitronPath::LoadDir)));
|
}
|
||||||
|
|
||||||
ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted.GetValue());
|
|
||||||
ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game.GetValue());
|
|
||||||
ui->dump_exefs->setChecked(Settings::values.dump_exefs.GetValue());
|
|
||||||
ui->dump_nso->setChecked(Settings::values.dump_nso.GetValue());
|
|
||||||
|
|
||||||
ui->cache_game_list->setChecked(UISettings::values.cache_game_list.GetValue());
|
|
||||||
|
|
||||||
UpdateEnabledControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureFilesystem::ApplyConfiguration() {
|
|
||||||
Common::FS::SetCitronPath(Common::FS::CitronPath::NANDDir,
|
|
||||||
ui->nand_directory_edit->text().toStdString());
|
|
||||||
Common::FS::SetCitronPath(Common::FS::CitronPath::SDMCDir,
|
|
||||||
ui->sdmc_directory_edit->text().toStdString());
|
|
||||||
Common::FS::SetCitronPath(Common::FS::CitronPath::DumpDir,
|
|
||||||
ui->dump_path_edit->text().toStdString());
|
|
||||||
Common::FS::SetCitronPath(Common::FS::CitronPath::LoadDir,
|
|
||||||
ui->load_path_edit->text().toStdString());
|
|
||||||
|
|
||||||
Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked();
|
|
||||||
Settings::values.gamecard_current_game = ui->gamecard_current_game->isChecked();
|
|
||||||
Settings::values.dump_exefs = ui->dump_exefs->isChecked();
|
|
||||||
Settings::values.dump_nso = ui->dump_nso->isChecked();
|
|
||||||
|
|
||||||
UISettings::values.cache_game_list = ui->cache_game_list->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit) {
|
|
||||||
QString caption;
|
|
||||||
|
|
||||||
switch (target) {
|
|
||||||
case DirectoryTarget::NAND:
|
|
||||||
caption = tr("Select Emulated NAND Directory...");
|
|
||||||
break;
|
|
||||||
case DirectoryTarget::SD:
|
|
||||||
caption = tr("Select Emulated SD Directory...");
|
|
||||||
break;
|
|
||||||
case DirectoryTarget::Gamecard:
|
|
||||||
caption = tr("Select Gamecard Path...");
|
|
||||||
break;
|
|
||||||
case DirectoryTarget::Dump:
|
|
||||||
caption = tr("Select Dump Directory...");
|
|
||||||
break;
|
|
||||||
case DirectoryTarget::Load:
|
|
||||||
caption = tr("Select Mod Load Directory...");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString str;
|
GMainWindow* main_window = qobject_cast<GMainWindow*>(this->parent()); // Try direct parent first
|
||||||
if (target == DirectoryTarget::Gamecard) {
|
if (!main_window) {
|
||||||
str = QFileDialog::getOpenFileName(this, caption, QFileInfo(edit->text()).dir().path(),
|
// Fallback for when it's nested in the config dialog
|
||||||
QStringLiteral("NX Gamecard;*.xci"));
|
main_window = qobject_cast<GMainWindow*>(this->window()->parent());
|
||||||
} else {
|
|
||||||
str = QFileDialog::getExistingDirectory(this, caption, edit->text());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str.isNull() || str.isEmpty()) {
|
if (!main_window) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("Could not find the main window."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Core::System* system = main_window->GetSystem();
|
||||||
|
const auto& vfs = main_window->GetVFS();
|
||||||
|
if (!system) {
|
||||||
|
QMessageBox::critical(this, tr("Error"), tr("System is not initialized."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str.back() != QChar::fromLatin1('/')) {
|
QStringList files_to_install;
|
||||||
str.append(QChar::fromLatin1('/'));
|
for (const auto& game_dir : UISettings::values.game_dirs) {
|
||||||
|
Common::FS::IterateDirEntriesRecursively(game_dir.path, [&](const auto& entry) {
|
||||||
|
if (!entry.is_directory() && entry.path().extension() == ".nsp") {
|
||||||
|
files_to_install.append(QString::fromStdString(entry.path().string()));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
edit->setText(str);
|
if (files_to_install.isEmpty()) {
|
||||||
}
|
QMessageBox::information(this, tr("Autoloader"), tr("No .nsp files found to install."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigureFilesystem::ResetMetadata() {
|
qint64 total_chunks = 0;
|
||||||
if (!Common::FS::Exists(Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) /
|
for (const QString& file : files_to_install) {
|
||||||
"game_list/")) {
|
total_chunks += (QFileInfo(file).size() + CopyBufferSize - 1) / CopyBufferSize;
|
||||||
QMessageBox::information(this, tr("Reset Metadata Cache"),
|
}
|
||||||
tr("The metadata cache is already empty."));
|
if (total_chunks == 0) {
|
||||||
} else if (Common::FS::RemoveDirRecursively(
|
QMessageBox::information(this, tr("Autoloader"), tr("Selected files are empty."));
|
||||||
Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list")) {
|
return;
|
||||||
QMessageBox::information(this, tr("Reset Metadata Cache"),
|
}
|
||||||
tr("The operation completed successfully."));
|
|
||||||
UISettings::values.is_game_list_reload_pending.exchange(true);
|
QStringList new_files{}, overwritten_files{}, failed_files{};
|
||||||
|
bool detected_base_install{};
|
||||||
|
bool was_cancelled = false;
|
||||||
|
|
||||||
|
install_progress = new QProgressDialog(QString{}, tr("Cancel"), 0, static_cast<int>(total_chunks), this);
|
||||||
|
install_progress->setWindowFlags(install_progress->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
install_progress->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
install_progress->setFixedWidth(400);
|
||||||
|
// When the dialog is destroyed (e.g., user clicks X), set the pointer to nullptr
|
||||||
|
connect(install_progress, &QObject::destroyed, this, [this]() { install_progress = nullptr; });
|
||||||
|
install_progress->show();
|
||||||
|
|
||||||
|
int remaining = files_to_install.size();
|
||||||
|
for (const QString& file : files_to_install) {
|
||||||
|
if (!install_progress || install_progress->wasCanceled()) {
|
||||||
|
was_cancelled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
install_progress->setWindowTitle(tr("Autoloader - %n file(s) remaining", "", remaining));
|
||||||
|
install_progress->setLabelText(tr("Installing: %1").arg(QFileInfo(file).fileName()));
|
||||||
|
|
||||||
|
auto progress_callback = [this](size_t, size_t) {
|
||||||
|
emit UpdateInstallProgress();
|
||||||
|
if (!install_progress) return true;
|
||||||
|
return install_progress->wasCanceled();
|
||||||
|
};
|
||||||
|
|
||||||
|
QFuture<ContentManager::InstallResult> future =
|
||||||
|
QtConcurrent::run([&] { return ContentManager::InstallNSP(*system, *vfs, file.toStdString(), progress_callback); });
|
||||||
|
|
||||||
|
while (!future.isFinished()) {
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentManager::InstallResult result = future.result();
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case ContentManager::InstallResult::Success: new_files.append(QFileInfo(file).fileName()); break;
|
||||||
|
case ContentManager::InstallResult::Overwrite: overwritten_files.append(QFileInfo(file).fileName()); break;
|
||||||
|
case ContentManager::InstallResult::Failure: failed_files.append(QFileInfo(file).fileName()); break;
|
||||||
|
case ContentManager::InstallResult::BaseInstallAttempted:
|
||||||
|
failed_files.append(QFileInfo(file).fileName());
|
||||||
|
detected_base_install = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
--remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (install_progress) {
|
||||||
|
install_progress->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detected_base_install) {
|
||||||
|
QMessageBox::warning(this, tr("Install Results"), tr("Warning: Base games were detected and skipped. The autoloader is intended for updates and DLC."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_files.isEmpty() && overwritten_files.isEmpty() && failed_files.isEmpty()) {
|
||||||
|
if (!was_cancelled) {
|
||||||
|
QMessageBox::information(this, tr("Autoloader"), tr("No new files were installed."));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(
|
QString install_results = tr("Installation Complete!");
|
||||||
this, tr("Reset Metadata Cache"),
|
install_results.append(QLatin1String("\n\n"));
|
||||||
tr("The metadata cache couldn't be deleted. It might be in use or non-existent."));
|
if (!new_files.isEmpty()) install_results.append(tr("%n file(s) were newly installed.", nullptr, new_files.size()));
|
||||||
|
if (!overwritten_files.isEmpty()) install_results.append(tr("\n%n file(s) were overwritten.", nullptr, overwritten_files.size()));
|
||||||
|
if (!failed_files.isEmpty()) install_results.append(tr("\n%n file(s) failed to install.", nullptr, failed_files.size()));
|
||||||
|
QMessageBox::information(this, tr("Install Results"), install_results);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureFilesystem::UpdateEnabledControls() {
|
Common::FS::RemoveDirRecursively(Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list");
|
||||||
ui->gamecard_current_game->setEnabled(ui->gamecard_inserted->isChecked());
|
emit RequestGameListRefresh();
|
||||||
ui->gamecard_path_edit->setEnabled(ui->gamecard_inserted->isChecked() &&
|
|
||||||
!ui->gamecard_current_game->isChecked());
|
|
||||||
ui->gamecard_path_button->setEnabled(ui->gamecard_inserted->isChecked() &&
|
|
||||||
!ui->gamecard_current_game->isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureFilesystem::RetranslateUI() {
|
|
||||||
ui->retranslateUi(this);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -7,9 +8,10 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
class QProgressDialog;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureFilesystem;
|
class ConfigureFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigureFilesystem : public QWidget {
|
class ConfigureFilesystem : public QWidget {
|
||||||
@@ -20,24 +22,24 @@ public:
|
|||||||
~ConfigureFilesystem() override;
|
~ConfigureFilesystem() override;
|
||||||
|
|
||||||
void ApplyConfiguration();
|
void ApplyConfiguration();
|
||||||
|
void OnRunAutoloader(bool skip_confirmation = false);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void UpdateInstallProgress();
|
||||||
|
void RequestGameListRefresh();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void OnUpdateInstallProgress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
void RetranslateUI();
|
void RetranslateUI();
|
||||||
void SetConfiguration();
|
void SetConfiguration();
|
||||||
|
enum class DirectoryTarget { NAND, SD, Gamecard, Dump, Load };
|
||||||
enum class DirectoryTarget {
|
|
||||||
NAND,
|
|
||||||
SD,
|
|
||||||
Gamecard,
|
|
||||||
Dump,
|
|
||||||
Load,
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetDirectory(DirectoryTarget target, QLineEdit* edit);
|
void SetDirectory(DirectoryTarget target, QLineEdit* edit);
|
||||||
void ResetMetadata();
|
void ResetMetadata();
|
||||||
void UpdateEnabledControls();
|
void UpdateEnabledControls();
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureFilesystem> ui;
|
std::unique_ptr<Ui::ConfigureFilesystem> ui;
|
||||||
|
QProgressDialog* install_progress = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,29 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="autoloader_group">
|
||||||
|
<property name="title">
|
||||||
|
<string>Autoloader</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_Autoloader">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="prompt_for_autoloader">
|
||||||
|
<property name="text">
|
||||||
|
<string>Prompt to run Autoloader when a new game directory is added</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="run_autoloader_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Run Autoloader Now</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_5">
|
<widget class="QGroupBox" name="groupBox_5">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
@@ -818,6 +819,27 @@ void GameList::ValidateEntry(const QModelIndex& item) {
|
|||||||
}
|
}
|
||||||
case GameListItemType::AddDir:
|
case GameListItemType::AddDir:
|
||||||
emit AddDirectory();
|
emit AddDirectory();
|
||||||
|
|
||||||
|
if (UISettings::values.prompt_for_autoloader) {
|
||||||
|
QMessageBox msg_box(this);
|
||||||
|
msg_box.setWindowTitle(tr("Autoloader"));
|
||||||
|
msg_box.setText(
|
||||||
|
tr("Would you like to use the Autoloader to install all Updates/DLC within your game directories?\n\n"
|
||||||
|
"If not now, you can always go to Emulation -> Configure -> Filesystem in order to use this feature. Also, if you have multiple update files for a single game, you can use the Update Manager "
|
||||||
|
"in File -> Install Updates with Update Manager."));
|
||||||
|
msg_box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
|
QCheckBox* check_box = new QCheckBox(tr("Do not ask me again"));
|
||||||
|
msg_box.setCheckBox(check_box);
|
||||||
|
|
||||||
|
if (msg_box.exec() == QMessageBox::Yes) {
|
||||||
|
emit RunAutoloaderRequested();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check_box->isChecked()) {
|
||||||
|
UISettings::values.prompt_for_autoloader = false;
|
||||||
|
emit SaveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ signals:
|
|||||||
void ShowList(bool show);
|
void ShowList(bool show);
|
||||||
void PopulatingCompleted();
|
void PopulatingCompleted();
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
void RunAutoloaderRequested();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnConfigurationChanged();
|
void OnConfigurationChanged();
|
||||||
@@ -204,7 +205,7 @@ private:
|
|||||||
ControllerNavigation* controller_navigation = nullptr;
|
ControllerNavigation* controller_navigation = nullptr;
|
||||||
CompatibilityList compatibility_list;
|
CompatibilityList compatibility_list;
|
||||||
QTimer* online_status_timer;
|
QTimer* online_status_timer;
|
||||||
QTimer config_update_timer; // NEW: Timer for debouncing config changes
|
QTimer config_update_timer;
|
||||||
|
|
||||||
friend class GameListSearchField;
|
friend class GameListSearchField;
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
|||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "citron/compatibility_list.h"
|
#include "citron/compatibility_list.h"
|
||||||
#include "citron/configuration/configure_dialog.h"
|
#include "citron/configuration/configure_dialog.h"
|
||||||
|
#include "citron/configuration/configure_filesystem.h"
|
||||||
#include "citron/configuration/configure_input_per_game.h"
|
#include "citron/configuration/configure_input_per_game.h"
|
||||||
#include "citron/configuration/qt_config.h"
|
#include "citron/configuration/qt_config.h"
|
||||||
#include "citron/debugger/console.h"
|
#include "citron/debugger/console.h"
|
||||||
@@ -213,7 +214,6 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr int default_mouse_hide_timeout = 2500;
|
|
||||||
constexpr int default_input_update_timeout = 1;
|
constexpr int default_input_update_timeout = 1;
|
||||||
|
|
||||||
constexpr size_t CopyBufferSize = 1_MiB;
|
constexpr size_t CopyBufferSize = 1_MiB;
|
||||||
@@ -1618,6 +1618,7 @@ void GMainWindow::ConnectWidgetEvents() {
|
|||||||
connect(game_list, &GameList::AddDirectory, this, &GMainWindow::OnGameListAddDirectory);
|
connect(game_list, &GameList::AddDirectory, this, &GMainWindow::OnGameListAddDirectory);
|
||||||
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
||||||
&GMainWindow::OnGameListAddDirectory);
|
&GMainWindow::OnGameListAddDirectory);
|
||||||
|
connect(game_list, &GameList::RunAutoloaderRequested, this, &GMainWindow::OnRunAutoloaderFromGameList);
|
||||||
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
|
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
|
||||||
connect(game_list, &GameList::PopulatingCompleted,
|
connect(game_list, &GameList::PopulatingCompleted,
|
||||||
[this] { multiplayer_state->UpdateGameList(game_list->GetModel()); });
|
[this] { multiplayer_state->UpdateGameList(game_list->GetModel()); });
|
||||||
@@ -1657,7 +1658,7 @@ void GMainWindow::ConnectMenuEvents() {
|
|||||||
connect_menu(ui->action_Load_File, &GMainWindow::OnMenuLoadFile);
|
connect_menu(ui->action_Load_File, &GMainWindow::OnMenuLoadFile);
|
||||||
connect_menu(ui->action_Load_Folder, &GMainWindow::OnMenuLoadFolder);
|
connect_menu(ui->action_Load_Folder, &GMainWindow::OnMenuLoadFolder);
|
||||||
connect_menu(ui->action_Install_File_NAND, &GMainWindow::OnMenuInstallToNAND);
|
connect_menu(ui->action_Install_File_NAND, &GMainWindow::OnMenuInstallToNAND);
|
||||||
connect_menu(ui->action_Install_With_Autoloader, &GMainWindow::OnMenuInstallWithAutoloader);
|
connect(ui->action_Install_With_Update_Manager, &QAction::triggered, this, &GMainWindow::OnMenuInstallWithUpdateManager);
|
||||||
connect_menu(ui->action_Trim_XCI_File, &GMainWindow::OnMenuTrimXCI);
|
connect_menu(ui->action_Trim_XCI_File, &GMainWindow::OnMenuTrimXCI);
|
||||||
connect_menu(ui->action_Exit, &QMainWindow::close);
|
connect_menu(ui->action_Exit, &QMainWindow::close);
|
||||||
connect_menu(ui->action_Load_Amiibo, &GMainWindow::OnLoadAmiibo);
|
connect_menu(ui->action_Load_Amiibo, &GMainWindow::OnLoadAmiibo);
|
||||||
@@ -4100,6 +4101,7 @@ void GMainWindow::OnConfigure() {
|
|||||||
&GMainWindow::OnLanguageChanged);
|
&GMainWindow::OnLanguageChanged);
|
||||||
|
|
||||||
const auto result = configure_dialog.exec();
|
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) {
|
!UISettings::values.reset_to_defaults) {
|
||||||
// Runs if the user hit Cancel or closed the window, and did not ever press the Apply button
|
// Runs if the user hit Cancel or closed the window, and did not ever press the Apply button
|
||||||
@@ -4119,7 +4121,7 @@ void GMainWindow::OnConfigure() {
|
|||||||
Common::FS::GetCitronPath(Common::FS::CitronPath::ConfigDir) / "custom")) {
|
Common::FS::GetCitronPath(Common::FS::CitronPath::ConfigDir) / "custom")) {
|
||||||
LOG_WARNING(Frontend, "Failed to remove custom configuration files");
|
LOG_WARNING(Frontend, "Failed to remove custom configuration files");
|
||||||
}
|
}
|
||||||
if (!Common::FS::RemoveDirRecursively(
|
if (!Common::FS::RemoveDirContentsRecursively(
|
||||||
Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list")) {
|
Common::FS::GetCitronPath(Common::FS::CitronPath::CacheDir) / "game_list")) {
|
||||||
LOG_WARNING(Frontend, "Failed to remove game metadata cache files");
|
LOG_WARNING(Frontend, "Failed to remove game metadata cache files");
|
||||||
}
|
}
|
||||||
@@ -6360,12 +6362,12 @@ void GMainWindow::RegisterAutoloaderContents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuInstallWithAutoloader() {
|
void GMainWindow::OnMenuInstallWithUpdateManager() {
|
||||||
LOG_INFO(Loader, "AUTOLOADER: Starting Autoloader installation process.");
|
LOG_INFO(Loader, "UPDATE MANAGER: Starting update installation process.");
|
||||||
|
|
||||||
const QString file_filter = tr("Nintendo Submission Package (*.nsp)");
|
const QString file_filter = tr("Nintendo Submission Package (*.nsp)");
|
||||||
QStringList filenames = QFileDialog::getOpenFileNames(
|
QStringList filenames = QFileDialog::getOpenFileNames(
|
||||||
this, tr("Select Update/DLC Files for Autoloader"),
|
this, tr("Select Update Files for Update Manager"),
|
||||||
QString::fromStdString(UISettings::values.roms_path), file_filter);
|
QString::fromStdString(UISettings::values.roms_path), file_filter);
|
||||||
|
|
||||||
if (filenames.isEmpty()) {
|
if (filenames.isEmpty()) {
|
||||||
@@ -6374,7 +6376,42 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
|
|
||||||
UISettings::values.roms_path = QFileInfo(filenames[0]).path().toStdString();
|
UISettings::values.roms_path = QFileInfo(filenames[0]).path().toStdString();
|
||||||
|
|
||||||
// Calculate the total size of all files to be installed for the progress dialog.
|
bool dlc_detected = false;
|
||||||
|
for (const QString& file : filenames) {
|
||||||
|
QString sanitized_path = file;
|
||||||
|
if (sanitized_path.contains(QLatin1String(".nsp/"))) {
|
||||||
|
sanitized_path = sanitized_path.left(sanitized_path.indexOf(QLatin1String(".nsp/")) + 4);
|
||||||
|
}
|
||||||
|
auto vfs_file = vfs->OpenFile(sanitized_path.toStdString(), FileSys::OpenMode::Read);
|
||||||
|
if (vfs_file) {
|
||||||
|
FileSys::NSP nsp(vfs_file);
|
||||||
|
if (nsp.GetStatus() == Loader::ResultStatus::Success && !nsp.GetNCAs().empty()) {
|
||||||
|
const auto& [title_id, nca_map] = *nsp.GetNCAs().begin();
|
||||||
|
const auto meta_iter = std::find_if(nca_map.begin(), nca_map.end(), [](const auto& pair){
|
||||||
|
return pair.first.second == FileSys::ContentRecordType::Meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (meta_iter != nca_map.end()) {
|
||||||
|
const auto& meta_nca = meta_iter->second;
|
||||||
|
if (meta_nca && !meta_nca->GetSubdirectories().empty() && !meta_nca->GetSubdirectories()[0]->GetFiles().empty()) {
|
||||||
|
const auto cnmt_file = meta_nca->GetSubdirectories()[0]->GetFiles()[0];
|
||||||
|
const FileSys::CNMT cnmt(cnmt_file);
|
||||||
|
if (cnmt.GetType() != FileSys::TitleType::Update) {
|
||||||
|
dlc_detected = true;
|
||||||
|
break; // Found one DLC, no need to check further.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dlc_detected) {
|
||||||
|
QMessageBox::warning(this, tr("DLC Detected"),
|
||||||
|
tr("The Update Manager is not compatible with DLC installations. Please select only update files."));
|
||||||
|
return; // Abort the operation.
|
||||||
|
}
|
||||||
|
|
||||||
qint64 total_size_bytes = 0;
|
qint64 total_size_bytes = 0;
|
||||||
for (const QString& file : filenames) {
|
for (const QString& file : filenames) {
|
||||||
QString sanitized_path = file;
|
QString sanitized_path = file;
|
||||||
@@ -6399,7 +6436,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QProgressDialog progress(tr("Installing to Autoloader..."), tr("Cancel"), 0, 100, this);
|
QProgressDialog progress(tr("Installing Updates..."), tr("Cancel"), 0, 100, this);
|
||||||
progress.setWindowModality(Qt::WindowModal);
|
progress.setWindowModality(Qt::WindowModal);
|
||||||
progress.setMinimumDuration(0);
|
progress.setMinimumDuration(0);
|
||||||
progress.setValue(0);
|
progress.setValue(0);
|
||||||
@@ -6422,25 +6459,25 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
sanitized_path = sanitized_path.left(sanitized_path.indexOf(QLatin1String(".nsp/")) + 4);
|
sanitized_path = sanitized_path.left(sanitized_path.indexOf(QLatin1String(".nsp/")) + 4);
|
||||||
}
|
}
|
||||||
const std::string file_path = sanitized_path.toStdString();
|
const std::string file_path = sanitized_path.toStdString();
|
||||||
LOG_INFO(Loader, "AUTOLOADER: Processing sanitized file path: {}", file_path);
|
LOG_INFO(Loader, "UPDATE MANAGER: Processing sanitized file path: {}", file_path);
|
||||||
|
|
||||||
auto vfs_file = vfs->OpenFile(file_path, FileSys::OpenMode::Read);
|
auto vfs_file = vfs->OpenFile(file_path, FileSys::OpenMode::Read);
|
||||||
if (!vfs_file) {
|
if (!vfs_file) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED at VFS Open. Could not open file: {}", file_path);
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED at VFS Open. Could not open file: {}", file_path);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (File Open Error)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (File Open Error)"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::NSP nsp(vfs_file);
|
FileSys::NSP nsp(vfs_file);
|
||||||
if (nsp.GetStatus() != Loader::ResultStatus::Success) {
|
if (nsp.GetStatus() != Loader::ResultStatus::Success) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED at NSP Parse for file: {}", file_path);
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED at NSP Parse for file: {}", file_path);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (NSP Parse Error)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (NSP Parse Error)"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto title_map = nsp.GetNCAs();
|
const auto title_map = nsp.GetNCAs();
|
||||||
if (title_map.empty()) {
|
if (title_map.empty()) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED, NSP contains no titles: {}", file_path);
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED, NSP contains no titles: {}", file_path);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (Empty NSP)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (Empty NSP)"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -6451,7 +6488,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!meta_nca || meta_nca->GetSubdirectories().empty() || meta_nca->GetSubdirectories()[0]->GetFiles().empty()) {
|
if (!meta_nca || meta_nca->GetSubdirectories().empty() || meta_nca->GetSubdirectories()[0]->GetFiles().empty()) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED at Metadata search for title {}: malformed.", title_id);
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED at Metadata search for title {}: malformed.", title_id);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (Malformed Metadata)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (Malformed Metadata)"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -6459,7 +6496,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
const auto cnmt_file = meta_nca->GetSubdirectories()[0]->GetFiles()[0];
|
const auto cnmt_file = meta_nca->GetSubdirectories()[0]->GetFiles()[0];
|
||||||
const FileSys::CNMT cnmt(cnmt_file);
|
const FileSys::CNMT cnmt(cnmt_file);
|
||||||
|
|
||||||
std::string type_folder = (cnmt.GetType() == FileSys::TitleType::Update) ? "Updates" : "DLC";
|
std::string type_folder = "Updates";
|
||||||
u64 program_id = FileSys::GetBaseTitleID(title_id);
|
u64 program_id = FileSys::GetBaseTitleID(title_id);
|
||||||
QString nsp_name = QFileInfo(sanitized_path).completeBaseName();
|
QString nsp_name = QFileInfo(sanitized_path).completeBaseName();
|
||||||
std::string sdmc_path = Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir);
|
std::string sdmc_path = Common::FS::GetCitronPathString(Common::FS::CitronPath::SDMCDir);
|
||||||
@@ -6467,7 +6504,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
|
|
||||||
auto dest_dir = VfsFilesystemCreateDirectoryWrapper(vfs, dest_path_str, FileSys::OpenMode::ReadWrite);
|
auto dest_dir = VfsFilesystemCreateDirectoryWrapper(vfs, dest_path_str, FileSys::OpenMode::ReadWrite);
|
||||||
if (!dest_dir) {
|
if (!dest_dir) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to create destination directory: {}", dest_path_str);
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED to create destination directory: {}", dest_path_str);
|
||||||
failed_files.append(QFileInfo(file).fileName() + tr(" (Directory Creation Error)"));
|
failed_files.append(QFileInfo(file).fileName() + tr(" (Directory Creation Error)"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -6478,13 +6515,13 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
auto dest_file = dest_dir->CreateFileRelative(source_file->GetName());
|
auto dest_file = dest_dir->CreateFileRelative(source_file->GetName());
|
||||||
|
|
||||||
if (!dest_file) {
|
if (!dest_file) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to create destination file for {}.", source_file->GetName());
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED to create destination file for {}.", source_file->GetName());
|
||||||
copy_failed = true;
|
copy_failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dest_file->Resize(source_file->GetSize())) {
|
if (!dest_file->Resize(source_file->GetSize())) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to resize destination file for {}.", source_file->GetName());
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED to resize destination file for {}.", source_file->GetName());
|
||||||
copy_failed = true;
|
copy_failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6501,7 +6538,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
const auto bytes_read = source_file->Read(buffer.data(), bytes_to_read, i);
|
const auto bytes_read = source_file->Read(buffer.data(), bytes_to_read, i);
|
||||||
|
|
||||||
if (bytes_read == 0 && i < source_file->GetSize()) {
|
if (bytes_read == 0 && i < source_file->GetSize()) {
|
||||||
LOG_ERROR(Loader, "AUTOLOADER: FAILED to read from source file {}.", source_file->GetName());
|
LOG_ERROR(Loader, "UPDATE MANAGER: FAILED to read from source file {}.", source_file->GetName());
|
||||||
copy_failed = true;
|
copy_failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6534,7 +6571,7 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
|
|
||||||
progress.close();
|
progress.close();
|
||||||
|
|
||||||
QString message = tr("Autoloader install finished.");
|
QString message = tr("Update Manager install finished.");
|
||||||
if (success_count > 0) {
|
if (success_count > 0) {
|
||||||
message += tr("\n%n file(s) successfully installed.", "", success_count);
|
message += tr("\n%n file(s) successfully installed.", "", success_count);
|
||||||
}
|
}
|
||||||
@@ -6551,3 +6588,11 @@ void GMainWindow::OnMenuInstallWithAutoloader() {
|
|||||||
void GMainWindow::OnToggleGridView() {
|
void GMainWindow::OnToggleGridView() {
|
||||||
game_list->ToggleViewMode();
|
game_list->ToggleViewMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnRunAutoloaderFromGameList() {
|
||||||
|
// This creates a temporary instance of the filesystem logic,
|
||||||
|
// calls the autoloader function, and then the instance is automatically cleaned up.
|
||||||
|
// We pass 'this' (the GMainWindow) as the parent.
|
||||||
|
ConfigureFilesystem fs_logic(this);
|
||||||
|
fs_logic.OnRunAutoloader(true);
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ public:
|
|||||||
void AcceptDropEvent(QDropEvent* event);
|
void AcceptDropEvent(QDropEvent* event);
|
||||||
MultiplayerState* GetMultiplayerState() { return multiplayer_state; }
|
MultiplayerState* GetMultiplayerState() { return multiplayer_state; }
|
||||||
Core::System* GetSystem() { return system.get(); }
|
Core::System* GetSystem() { return system.get(); }
|
||||||
|
const std::shared_ptr<FileSys::VfsFilesystem>& GetVFS() const { return vfs; }
|
||||||
bool IsEmulationRunning() const { return emulation_running; }
|
bool IsEmulationRunning() const { return emulation_running; }
|
||||||
void RefreshGameList();
|
void RefreshGameList();
|
||||||
bool ExtractZipToDirectoryPublic(const std::filesystem::path& zip_path, const std::filesystem::path& extract_path);
|
bool ExtractZipToDirectoryPublic(const std::filesystem::path& zip_path, const std::filesystem::path& extract_path);
|
||||||
@@ -153,6 +154,7 @@ public slots:
|
|||||||
void WebBrowserRequestExit();
|
void WebBrowserRequestExit();
|
||||||
void OnAppFocusStateChanged(Qt::ApplicationState state);
|
void OnAppFocusStateChanged(Qt::ApplicationState state);
|
||||||
void OnTasStateChanged();
|
void OnTasStateChanged();
|
||||||
|
void IncrementInstallProgress();
|
||||||
private:
|
private:
|
||||||
void LinkActionShortcut(QAction* action, const QString& action_name, const bool tas_allowed = false);
|
void LinkActionShortcut(QAction* action, const QString& action_name, const bool tas_allowed = false);
|
||||||
void RegisterMetaTypes();
|
void RegisterMetaTypes();
|
||||||
@@ -220,10 +222,10 @@ private slots:
|
|||||||
void OnGameListOpenPerGameProperties(const std::string& file);
|
void OnGameListOpenPerGameProperties(const std::string& file);
|
||||||
void OnMenuLoadFile();
|
void OnMenuLoadFile();
|
||||||
void OnMenuLoadFolder();
|
void OnMenuLoadFolder();
|
||||||
void IncrementInstallProgress();
|
|
||||||
void OnMenuInstallToNAND();
|
void OnMenuInstallToNAND();
|
||||||
void OnMenuTrimXCI();
|
void OnMenuTrimXCI();
|
||||||
void OnMenuInstallWithAutoloader();
|
void OnMenuInstallWithUpdateManager();
|
||||||
|
void OnRunAutoloaderFromGameList();
|
||||||
void OnMenuRecentFile();
|
void OnMenuRecentFile();
|
||||||
void OnConfigure();
|
void OnConfigure();
|
||||||
void OnConfigureTas();
|
void OnConfigureTas();
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<addaction name="action_Install_File_NAND"/>
|
<addaction name="action_Install_File_NAND"/>
|
||||||
<addaction name="action_Trim_XCI_File"/>
|
<addaction name="action_Trim_XCI_File"/>
|
||||||
<addaction name="action_Install_With_Autoloader"/>
|
<addaction name="action_Install_With_Update_Manager"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_Load_File"/>
|
<addaction name="action_Load_File"/>
|
||||||
<addaction name="action_Load_Folder"/>
|
<addaction name="action_Load_Folder"/>
|
||||||
@@ -210,12 +210,12 @@
|
|||||||
<string>&Install Files to NAND...</string>
|
<string>&Install Files to NAND...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Install_With_Autoloader">
|
<action name="action_Install_With_Update_Manager">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Install Files with &Autoloader...</string>
|
<string>Install Updates with &Update Manager</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Trim_XCI_File">
|
<action name="action_Trim_XCI_File">
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ namespace UISettings {
|
|||||||
Setting<bool> game_list_grid_view{linkage, false, "game_list_grid_view", Category::UiGameList};
|
Setting<bool> game_list_grid_view{linkage, false, "game_list_grid_view", Category::UiGameList};
|
||||||
std::atomic_bool is_game_list_reload_pending{false};
|
std::atomic_bool is_game_list_reload_pending{false};
|
||||||
Setting<bool> cache_game_list{linkage, true, "cache_game_list", Category::UiGameList};
|
Setting<bool> cache_game_list{linkage, true, "cache_game_list", Category::UiGameList};
|
||||||
|
Setting<bool> prompt_for_autoloader{linkage, true, "prompt_for_autoloader", Category::UiGameList};
|
||||||
Setting<bool> favorites_expanded{linkage, true, "favorites_expanded", Category::UiGameList};
|
Setting<bool> favorites_expanded{linkage, true, "favorites_expanded", Category::UiGameList};
|
||||||
QVector<u64> favorited_ids;
|
QVector<u64> favorited_ids;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user