qt: Add UI to view sources of system archives

Displays, color coded, the origin for each of the 0x28 archives, allowing for easy debugging.
This commit is contained in:
Zach Hilman
2019-10-15 14:38:52 -04:00
parent f06c541440
commit a85d0b6712
4 changed files with 331 additions and 0 deletions

View File

@@ -103,6 +103,9 @@ add_executable(yuzu
main.cpp
main.h
main.ui
status/system_archive.cpp
status/system_archive.h
status/system_archive.ui
uisettings.cpp
uisettings.h
util/limitable_input_dialog.cpp

View File

@@ -0,0 +1,76 @@
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <QLabel>
#include "core/file_sys/nca_metadata.h"
#include "core/file_sys/romfs_factory.h"
#include "core/file_sys/system_archive/importer.h"
#include "core/file_sys/system_archive/system_archive.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "ui_system_archive.h"
#include "yuzu/status/system_archive.h"
namespace {
enum class Source {
NAND,
XCI,
OSS,
None,
};
constexpr std::array<const char*, 4> SOURCE_FORMAT = {
"<html><head/><body><p><span style=\"color:#00aa00;\"><b>8{:02X}</b></span></p></body></html>",
"<html><head/><body><p><span style=\"color:#0055ff;\"><b>8{:02X}</b></span></p></body></html>",
"<html><head/><body><p><span style=\"color:#aa00ff;\"><b>8{:02X}</b></span></p></body></html>",
"<html><head/><body><p><span style=\"color:#aa0000;\"><b>8{:02X}</b></span></p></body></html>",
};
QWidget* CreateItemForSourceAndId(QWidget* parent, Source source, std::size_t id) {
const auto text = fmt::format(SOURCE_FORMAT.at(static_cast<std::size_t>(source)), id);
auto* out = new QLabel(QString::fromStdString(text), parent);
out->setAlignment(Qt::AlignHCenter);
return out;
}
QWidget* CreateItem(QWidget* parent, const Service::FileSystem::FileSystemController& fsc,
std::size_t suffix) {
const auto title_id = FileSys::SystemArchive::SYSTEM_ARCHIVE_BASE_TITLE_ID + suffix;
const auto nand =
fsc.OpenRomFS(title_id, FileSys::StorageId::NandSystem, FileSys::ContentRecordType::Data);
if (nand.Succeeded()) {
return CreateItemForSourceAndId(parent, Source::NAND, suffix);
}
auto archive = FileSys::SystemArchive::GetImportedSystemArchive(
fsc.GetSysdataImportedDirectory(), title_id);
if (archive != nullptr) {
return CreateItemForSourceAndId(parent, Source::XCI, suffix);
}
archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id);
if (archive != nullptr) {
return CreateItemForSourceAndId(parent, Source::OSS, suffix);
}
return CreateItemForSourceAndId(parent, Source::None, suffix);
}
} // Anonymous namespace
SystemArchiveDialog::SystemArchiveDialog(QWidget* parent,
const Service::FileSystem::FileSystemController& fsc)
: QDialog(parent), ui(new Ui::SystemArchiveDialog) {
ui->setupUi(this);
for (std::size_t i = 0; i < FileSys::SystemArchive::SYSTEM_ARCHIVE_COUNT; ++i) {
ui->grid->addWidget(CreateItem(this, fsc, i), i / 6, i % 6, 1, 1);
}
}
SystemArchiveDialog::~SystemArchiveDialog() = default;

View File

@@ -0,0 +1,28 @@
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <QDialog>
namespace Service::FileSystem {
class FileSystemController;
} // namespace Service::FileSystem
namespace Ui {
class SystemArchiveDialog;
} // namespace Ui
class SystemArchiveDialog : public QDialog {
Q_OBJECT
public:
explicit SystemArchiveDialog(QWidget* parent,
const Service::FileSystem::FileSystemController& fsc);
~SystemArchiveDialog() override;
private:
std::unique_ptr<Ui::SystemArchiveDialog> ui;
};

View File

@@ -0,0 +1,224 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SystemArchiveDialog</class>
<widget class="QDialog" name="SystemArchiveDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>422</height>
</rect>
</property>
<property name="windowTitle">
<string>System Archive Status</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>System Archive Status</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>System archives are special data files games and applications can use for common functions, such as filtering for bad words or showing Miis on screen.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>yuzu can load system archives from 3 sources:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string> 1. A real NAND dump placed into yuzu's NAND directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string> 2. Archives imported from an XCI/cartridge game</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string> 3. Open source reimplementations from the yuzu team</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>The following table shows the source for all of the system archives:</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="grid"/>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#00aa00;&quot;&gt;NAND Dump&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#0055ff;&quot;&gt;Cartridge Dump&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#aa00ff;&quot;&gt;Open Source&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#aa0000;&quot;&gt;Missing&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SystemArchiveDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SystemArchiveDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>