qt: Add Tools commands for system archive management
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "core/hle/service/am/applets/applets.h"
|
#include "core/hle/service/am/applets/applets.h"
|
||||||
#include "core/hle/service/hid/controllers/npad.h"
|
#include "core/hle/service/hid/controllers/npad.h"
|
||||||
#include "core/hle/service/hid/hid.h"
|
#include "core/hle/service/hid/hid.h"
|
||||||
|
#include "yuzu/status/system_archive.h"
|
||||||
|
|
||||||
// These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows
|
// These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows
|
||||||
// defines.
|
// defines.
|
||||||
@@ -40,6 +41,10 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
|||||||
return dir->CreateFile(path);
|
return dir->CreateFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool VfsDirectoryDeleteFileWrapper(const FileSys::VirtualDir& dir, const std::string& path) {
|
||||||
|
return dir->DeleteFile(path);
|
||||||
|
}
|
||||||
|
|
||||||
#include <fmt/ostream.h>
|
#include <fmt/ostream.h>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
@@ -83,6 +88,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
|||||||
#include "core/file_sys/romfs.h"
|
#include "core/file_sys/romfs.h"
|
||||||
#include "core/file_sys/savedata_factory.h"
|
#include "core/file_sys/savedata_factory.h"
|
||||||
#include "core/file_sys/submission_package.h"
|
#include "core/file_sys/submission_package.h"
|
||||||
|
#include "core/file_sys/system_archive/importer.h"
|
||||||
#include "core/frontend/applets/software_keyboard.h"
|
#include "core/frontend/applets/software_keyboard.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/service/am/am.h"
|
#include "core/hle/service/am/am.h"
|
||||||
@@ -760,6 +766,16 @@ void GMainWindow::ConnectMenuEvents() {
|
|||||||
connect(ui.action_Capture_Screenshot, &QAction::triggered, this,
|
connect(ui.action_Capture_Screenshot, &QAction::triggered, this,
|
||||||
&GMainWindow::OnCaptureScreenshot);
|
&GMainWindow::OnCaptureScreenshot);
|
||||||
|
|
||||||
|
// Tools
|
||||||
|
connect(ui.actionImport_Directory, &QAction::triggered, this,
|
||||||
|
&GMainWindow::OnImportDirectorySystemUpdate);
|
||||||
|
connect(ui.actionImport_Cartridge, &QAction::triggered, this,
|
||||||
|
&GMainWindow::OnImportCartridgeSystemUpdate);
|
||||||
|
connect(ui.actionClear_Imported, &QAction::triggered, this,
|
||||||
|
&GMainWindow::OnClearImportedSysdata);
|
||||||
|
connect(ui.actionView_Status, &QAction::triggered, this,
|
||||||
|
&GMainWindow::OnViewSystemArchiveStatus);
|
||||||
|
|
||||||
// Help
|
// Help
|
||||||
connect(ui.action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder);
|
connect(ui.action_Open_yuzu_Folder, &QAction::triggered, this, &GMainWindow::OnOpenYuzuFolder);
|
||||||
connect(ui.action_Rederive, &QAction::triggered, this,
|
connect(ui.action_Rederive, &QAction::triggered, this,
|
||||||
@@ -1358,6 +1374,71 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
|
|||||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://yuzu-emu.org/game/") + directory));
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://yuzu-emu.org/game/") + directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnClearImportedSysdata() {
|
||||||
|
Core::System& system{Core::System::GetInstance()};
|
||||||
|
|
||||||
|
const auto path = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + "imported" DIR_SEP;
|
||||||
|
QDir dir(QString::fromStdString(path));
|
||||||
|
const auto list = dir.entryList(QDir::Files);
|
||||||
|
for (const auto& file : list) {
|
||||||
|
if (!dir.remove(file)) {
|
||||||
|
QMessageBox::warning(this, tr("Clear Failed"),
|
||||||
|
tr("The imported sysdata directory was not able to be cleared."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::information(this, tr("Clear Successful"),
|
||||||
|
tr("The imported sysdata directory was cleared successfully."));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnImportDirectorySystemUpdate() {
|
||||||
|
Core::System& system{Core::System::GetInstance()};
|
||||||
|
|
||||||
|
const auto dir = QFileDialog::getExistingDirectory(this, tr("Select System Update Directory"));
|
||||||
|
|
||||||
|
if (dir.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto vdir = vfs->OpenDirectory(dir.toStdString(), FileSys::Mode::Read);
|
||||||
|
if (FileSys::SystemArchive::ImportDirectorySystemUpdate(
|
||||||
|
system.GetFileSystemController().GetSysdataImportedDirectory(), vdir)) {
|
||||||
|
QMessageBox::information(this, tr("Import Successful"),
|
||||||
|
tr("The system update import was successful."));
|
||||||
|
} else {
|
||||||
|
QMessageBox::warning(this, tr("Import Failed"), tr("The system update import failed."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnImportCartridgeSystemUpdate() {
|
||||||
|
Core::System& system{Core::System::GetInstance()};
|
||||||
|
|
||||||
|
const auto file = QFileDialog::getOpenFileName(this, tr("Select Cartridge File"), QString{},
|
||||||
|
QStringLiteral("Cartridge Images (*.xci)"));
|
||||||
|
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileSys::XCI xci{vfs->OpenFile(file.toStdString(), FileSys::Mode::Read)};
|
||||||
|
if (FileSys::SystemArchive::ImportXCISystemUpdate(
|
||||||
|
system.GetFileSystemController().GetSysdataImportedDirectory(), xci)) {
|
||||||
|
QMessageBox::information(this, tr("Import Successful"),
|
||||||
|
tr("The system update import was successful."));
|
||||||
|
} else {
|
||||||
|
QMessageBox::warning(this, tr("Import Failed"), tr("The system update import failed."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnViewSystemArchiveStatus() {
|
||||||
|
Core::System& system{Core::System::GetInstance()};
|
||||||
|
|
||||||
|
system.GetFileSystemController().CreateFactories(*vfs);
|
||||||
|
SystemArchiveDialog dialog(this, system.GetFileSystemController());
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void GMainWindow::OnGameListOpenDirectory(const QString& directory) {
|
void GMainWindow::OnGameListOpenDirectory(const QString& directory) {
|
||||||
QString path;
|
QString path;
|
||||||
if (directory == QStringLiteral("SDMC")) {
|
if (directory == QStringLiteral("SDMC")) {
|
||||||
|
|||||||
@@ -190,6 +190,10 @@ private slots:
|
|||||||
void OnGameListCopyTID(u64 program_id);
|
void OnGameListCopyTID(u64 program_id);
|
||||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||||
const CompatibilityList& compatibility_list);
|
const CompatibilityList& compatibility_list);
|
||||||
|
void OnClearImportedSysdata();
|
||||||
|
void OnImportDirectorySystemUpdate();
|
||||||
|
void OnImportCartridgeSystemUpdate();
|
||||||
|
void OnViewSystemArchiveStatus();
|
||||||
void OnGameListOpenDirectory(const QString& directory);
|
void OnGameListOpenDirectory(const QString& directory);
|
||||||
void OnGameListAddDirectory();
|
void OnGameListAddDirectory();
|
||||||
void OnGameListShowList(bool show);
|
void OnGameListShowList(bool show);
|
||||||
|
|||||||
@@ -104,9 +104,22 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Tools</string>
|
<string>Tools</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuSystem_Archives">
|
||||||
|
<property name="title">
|
||||||
|
<string>System Archives</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionImport_Directory"/>
|
||||||
|
<addaction name="actionImport_Cartridge"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionClear_Imported"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionView_Status"/>
|
||||||
|
</widget>
|
||||||
<addaction name="action_Rederive"/>
|
<addaction name="action_Rederive"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_Capture_Screenshot"/>
|
<addaction name="action_Capture_Screenshot"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="menuSystem_Archives"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Help">
|
<widget class="QMenu" name="menu_Help">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -293,6 +306,26 @@
|
|||||||
<string>Capture Screenshot</string>
|
<string>Capture Screenshot</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionImport_Directory">
|
||||||
|
<property name="text">
|
||||||
|
<string>Import Directory</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionImport_Cartridge">
|
||||||
|
<property name="text">
|
||||||
|
<string>Import Cartridge</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionClear_Imported">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear Imported</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionView_Status">
|
||||||
|
<property name="text">
|
||||||
|
<string>View Status</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in New Issue
Block a user