Merge branch 'fixPropertiesWindowScaling' into 'main'

fix: Properties Window Scaling

See merge request citron/emulator!75
This commit is contained in:
Zephyron
2025-10-03 10:53:00 +10:00
3 changed files with 527 additions and 474 deletions

View File

@@ -53,7 +53,7 @@
<item>
<widget class="QComboBox" name="profile_player_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -88,7 +88,7 @@
<item>
<widget class="QComboBox" name="profile_player_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -123,7 +123,7 @@
<item>
<widget class="QComboBox" name="profile_player_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -158,7 +158,7 @@
<item>
<widget class="QComboBox" name="profile_player_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -193,7 +193,7 @@
<item>
<widget class="QComboBox" name="profile_player_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -228,7 +228,7 @@
<item>
<widget class="QComboBox" name="profile_player_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -263,7 +263,7 @@
<item>
<widget class="QComboBox" name="profile_player_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -298,7 +298,7 @@
<item>
<widget class="QComboBox" name="profile_player_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@@ -51,28 +51,33 @@
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::string& file_name,
std::vector<VkDeviceInfo::Record>& vk_device_records,
Core::System& system_)
: QDialog(parent),
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_},
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
tab_group{std::make_shared<std::vector<ConfigurationShared::Tab*>>()} {
: QDialog(parent),
ui(std::make_unique<Ui::ConfigurePerGame>()), title_id{title_id_}, system{system_},
builder{std::make_unique<ConfigurationShared::Builder>(this, !system_.IsPoweredOn())},
tab_group{std::make_shared<std::vector<ConfigurationShared::Tab*>>()} {
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);
: fmt::format("{:016X}", title_id);
game_config = std::make_unique<QtConfig>(config_file_name, Config::ConfigType::PerGameConfig);
addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this);
audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, *builder, this);
cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, *builder, this);
graphics_advanced_tab =
std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this);
std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *builder, this);
graphics_tab = std::make_unique<ConfigureGraphics>(
system_, vk_device_records, [&]() { graphics_advanced_tab->ExposeComputeOption(); },
[](Settings::AspectRatio, Settings::ResolutionSetup) {}, tab_group, *builder, this);
[](Settings::AspectRatio, Settings::ResolutionSetup) {}, tab_group, *builder, this);
input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this);
linux_tab = std::make_unique<ConfigureLinuxTab>(system_, tab_group, *builder, this);
system_tab = std::make_unique<ConfigureSystem>(system_, tab_group, *builder, this);
ui->setupUi(this);
// THIS IS THE NEW FIX: Force a minimum height on the window.
setMinimumHeight(400);
layout()->setSizeConstraint(QLayout::SetDefaultConstraint);
ui->tabWidget->addTab(addons_tab.get(), tr("Add-Ons"));
ui->tabWidget->addTab(system_tab.get(), tr("System"));
ui->tabWidget->addTab(cpu_tab.get(), tr("CPU"));
@@ -83,10 +88,10 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
// Only show Linux tab on Unix
linux_tab->setVisible(false);
#ifdef __unix__
#ifdef __unix__
linux_tab->setVisible(true);
ui->tabWidget->addTab(linux_tab.get(), tr("Linux"));
#endif
#endif
setFocusPolicy(Qt::ClickFocus);
setWindowTitle(tr("Properties"));
@@ -115,15 +120,15 @@ void ConfigurePerGame::ApplyConfiguration() {
input_tab->ApplyConfiguration();
if (Settings::IsDockedMode() && Settings::values.players.GetValue()[0].controller_type ==
Settings::ControllerType::Handheld) {
Settings::ControllerType::Handheld) {
Settings::values.use_docked_mode.SetValue(Settings::ConsoleMode::Handheld);
Settings::values.use_docked_mode.SetGlobal(true);
}
Settings::values.use_docked_mode.SetGlobal(true);
}
system.ApplySettings();
Settings::LogSettings();
system.ApplySettings();
Settings::LogSettings();
game_config->SaveAllValues();
game_config->SaveAllValues();
}
void ConfigurePerGame::changeEvent(QEvent* event) {
@@ -159,300 +164,300 @@ void ConfigurePerGame::LoadConfiguration() {
QStringLiteral("%1").arg(title_id, 16, 16, QLatin1Char{'0'}).toUpper());
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
system.GetContentProvider()};
const auto control = pm.GetControlMetadata();
const auto loader = Loader::GetLoader(system, file);
system.GetContentProvider()};
const auto control = pm.GetControlMetadata();
const auto loader = Loader::GetLoader(system, file);
if (control.first != nullptr) {
ui->display_version->setText(QString::fromStdString(control.first->GetVersionString()));
ui->display_name->setText(QString::fromStdString(control.first->GetApplicationName()));
ui->display_developer->setText(QString::fromStdString(control.first->GetDeveloperName()));
} else {
std::string title;
if (loader->ReadTitle(title) == Loader::ResultStatus::Success)
ui->display_name->setText(QString::fromStdString(title));
if (control.first != nullptr) {
ui->display_version->setText(QString::fromStdString(control.first->GetVersionString()));
ui->display_name->setText(QString::fromStdString(control.first->GetApplicationName()));
ui->display_developer->setText(QString::fromStdString(control.first->GetDeveloperName()));
} else {
std::string title;
if (loader->ReadTitle(title) == Loader::ResultStatus::Success)
ui->display_name->setText(QString::fromStdString(title));
FileSys::NACP nacp;
if (loader->ReadControlData(nacp) == Loader::ResultStatus::Success)
ui->display_developer->setText(QString::fromStdString(nacp.GetDeveloperName()));
FileSys::NACP nacp;
if (loader->ReadControlData(nacp) == Loader::ResultStatus::Success)
ui->display_developer->setText(QString::fromStdString(nacp.GetDeveloperName()));
ui->display_version->setText(QStringLiteral("1.0.0"));
}
ui->display_version->setText(QStringLiteral("1.0.0"));
}
if (control.second != nullptr) {
scene->clear();
QPixmap map;
const auto bytes = control.second->ReadAllBytes();
map.loadFromData(bytes.data(), static_cast<u32>(bytes.size()));
scene->addPixmap(map.scaled(ui->icon_view->width(), ui->icon_view->height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
} else {
std::vector<u8> bytes;
if (loader->ReadIcon(bytes) == Loader::ResultStatus::Success) {
if (control.second != nullptr) {
scene->clear();
QPixmap map;
const auto bytes = control.second->ReadAllBytes();
map.loadFromData(bytes.data(), static_cast<u32>(bytes.size()));
scene->addPixmap(map.scaled(ui->icon_view->width(), ui->icon_view->height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
}
} else {
std::vector<u8> bytes;
if (loader->ReadIcon(bytes) == Loader::ResultStatus::Success) {
scene->clear();
ui->display_filename->setText(QString::fromStdString(file->GetName()));
QPixmap map;
map.loadFromData(bytes.data(), static_cast<u32>(bytes.size()));
ui->display_format->setText(
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())));
const auto valueText = ReadableByteSize(file->GetSize());
ui->display_size->setText(valueText);
// Display Build ID(s) if available
std::string base_build_id_hex;
std::string update_build_id_hex;
// Try to get build ID based on file type
const auto file_type = loader->GetFileType();
if (file_type == Loader::FileType::NSO) {
// For NSO files, read the build ID directly from the header
if (file->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (file->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
// Build ID is at offset 0x40 in NSO header
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
scene->addPixmap(map.scaled(ui->icon_view->width(), ui->icon_view->height(),
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
}
} else if (file_type == Loader::FileType::DeconstructedRomDirectory) {
// For deconstructed ROM directories, read from the main NSO file
const auto main_dir = file->GetContainingDirectory();
if (main_dir) {
const auto main_nso = main_dir->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
ui->display_filename->setText(QString::fromStdString(file->GetName()));
ui->display_format->setText(
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())));
const auto valueText = ReadableByteSize(file->GetSize());
ui->display_size->setText(valueText);
// Display Build ID(s) if available
std::string base_build_id_hex;
std::string update_build_id_hex;
// Try to get build ID based on file type
const auto file_type = loader->GetFileType();
if (file_type == Loader::FileType::NSO) {
// For NSO files, read the build ID directly from the header
if (file->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
if (file->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
// Build ID is at offset 0x40 in NSO header
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
} else if (file_type == Loader::FileType::DeconstructedRomDirectory) {
// For deconstructed ROM directories, read from the main NSO file
const auto main_dir = file->GetContainingDirectory();
if (main_dir) {
const auto main_nso = main_dir->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
// Build ID is at offset 0x40 in NSO header
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
} else {
// For other file types (XCI, NSP, NCA), try to extract build ID directly
try {
if (file_type == Loader::FileType::XCI) {
// For XCI files, try to construct with the proper parameters
try {
// First try to get the program ID from the XCI to use proper parameters
FileSys::XCI xci_temp(file);
if (xci_temp.GetStatus() == Loader::ResultStatus::Success) {
// Try to get the program NCA from the secure partition
FileSys::XCI xci(file, title_id, 0); // Use detected title_id
if (xci.GetStatus() == Loader::ResultStatus::Success) {
auto program_nca = xci.GetNCAByType(FileSys::NCAContentType::Program);
if (program_nca && program_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = program_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
}
} catch (...) {
// XCI might be encrypted or have other issues
// Fall back to checking if it's installed in the content provider
const auto& content_provider = system.GetContentProvider();
auto base_nca = content_provider.GetEntry(title_id, FileSys::ContentRecordType::Program);
if (base_nca && base_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = base_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
} else if (file_type == Loader::FileType::NSP) {
// For NSP files, try to construct and parse directly
FileSys::NSP nsp(file);
if (nsp.GetStatus() == Loader::ResultStatus::Success) {
auto exefs = nsp.GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
} else if (file_type == Loader::FileType::NCA) {
// For NCA files, try to construct and parse directly
FileSys::NCA nca(file);
if (nca.GetStatus() == Loader::ResultStatus::Success) {
auto exefs = nca.GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
} catch (...) {
// If anything fails, continue without the build ID
}
}
} else {
// For other file types (XCI, NSP, NCA), try to extract build ID directly
// Try to get update build ID from patch manager and content provider
try {
if (file_type == Loader::FileType::XCI) {
// For XCI files, try to construct with the proper parameters
try {
// First try to get the program ID from the XCI to use proper parameters
FileSys::XCI xci_temp(file);
if (xci_temp.GetStatus() == Loader::ResultStatus::Success) {
// Try to get the program NCA from the secure partition
FileSys::XCI xci(file, title_id, 0); // Use detected title_id
if (xci.GetStatus() == Loader::ResultStatus::Success) {
auto program_nca = xci.GetNCAByType(FileSys::NCAContentType::Program);
if (program_nca && program_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = program_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
}
} catch (...) {
// XCI might be encrypted or have other issues
// Fall back to checking if it's installed in the content provider
const auto& content_provider = system.GetContentProvider();
auto base_nca = content_provider.GetEntry(title_id, FileSys::ContentRecordType::Program);
if (base_nca && base_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = base_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
} else if (file_type == Loader::FileType::NSP) {
// For NSP files, try to construct and parse directly
FileSys::NSP nsp(file);
if (nsp.GetStatus() == Loader::ResultStatus::Success) {
auto exefs = nsp.GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
// Method 1: Try through patch manager (more reliable for updates)
const FileSys::PatchManager pm_update{title_id, system.GetFileSystemController(),
system.GetContentProvider()};
// Check if patch manager has update information
const auto update_version = pm_update.GetGameVersion();
if (update_version.has_value() && update_version.value() > 0) {
// There's an update, try to get its build ID through the patch manager
// The patch manager should have access to the update NCA
// Try to get the update NCA through the patch manager's content provider
const auto& content_provider = system.GetContentProvider();
const auto update_title_id = FileSys::GetUpdateTitleID(title_id);
auto update_nca = content_provider.GetEntry(update_title_id, FileSys::ContentRecordType::Program);
if (update_nca && update_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = update_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
update_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
} else if (file_type == Loader::FileType::NCA) {
// For NCA files, try to construct and parse directly
FileSys::NCA nca(file);
if (nca.GetStatus() == Loader::ResultStatus::Success) {
auto exefs = nca.GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
base_build_id_hex = Common::HexToString(build_id, false);
// Method 2: If patch manager approach didn't work, try direct content provider access
if (update_build_id_hex.empty()) {
const auto& content_provider = system.GetContentProvider();
const auto update_title_id = FileSys::GetUpdateTitleID(title_id);
auto update_nca = content_provider.GetEntry(update_title_id, FileSys::ContentRecordType::Program);
if (update_nca && update_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = update_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
update_build_id_hex = Common::HexToString(build_id, false);
}
}
}
}
}
}
// Method 3: Try to use the patch manager's GetPatches to detect updates
if (update_build_id_hex.empty()) {
const auto patches = pm_update.GetPatches();
for (const auto& patch : patches) {
if (patch.type == FileSys::PatchType::Update && patch.enabled) {
// There's an enabled update patch, but we couldn't get its build ID
// This indicates an update is available but not currently loaded
break;
}
}
}
} catch (...) {
// If anything fails, continue without the build ID
// If update build ID extraction fails, continue with just base
}
}
// Try to get update build ID from patch manager and content provider
try {
// Method 1: Try through patch manager (more reliable for updates)
const FileSys::PatchManager pm_update{title_id, system.GetFileSystemController(),
system.GetContentProvider()};
// Try to get the actual running build ID from system (this will be the update if one is applied)
const auto& system_build_id = system.GetApplicationProcessBuildID();
const auto system_build_id_hex = Common::HexToString(system_build_id, false);
// Check if patch manager has update information
const auto update_version = pm_update.GetGameVersion();
if (update_version.has_value() && update_version.value() > 0) {
// There's an update, try to get its build ID through the patch manager
// The patch manager should have access to the update NCA
// Try to get the update NCA through the patch manager's content provider
const auto& content_provider = system.GetContentProvider();
const auto update_title_id = FileSys::GetUpdateTitleID(title_id);
auto update_nca = content_provider.GetEntry(update_title_id, FileSys::ContentRecordType::Program);
if (update_nca && update_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = update_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
update_build_id_hex = Common::HexToString(build_id, false);
}
}
}
// If we have a system build ID and it's different from the base, it's likely the update
if (!system_build_id_hex.empty() && system_build_id_hex != std::string(64, '0')) {
if (!base_build_id_hex.empty() && system_build_id_hex != base_build_id_hex) {
// System build ID is different from base, so it's the update
update_build_id_hex = system_build_id_hex;
} else if (base_build_id_hex.empty()) {
// No base build ID found, use system as base
base_build_id_hex = system_build_id_hex;
}
}
// Method 2: If patch manager approach didn't work, try direct content provider access
if (update_build_id_hex.empty()) {
const auto& content_provider = system.GetContentProvider();
const auto update_title_id = FileSys::GetUpdateTitleID(title_id);
auto update_nca = content_provider.GetEntry(update_title_id, FileSys::ContentRecordType::Program);
if (update_nca && update_nca->GetStatus() == Loader::ResultStatus::Success) {
auto exefs = update_nca->GetExeFS();
if (exefs) {
auto main_nso = exefs->GetFile("main");
if (main_nso && main_nso->GetSize() >= 0x100) {
std::array<u8, 0x100> header_data{};
if (main_nso->ReadBytes(header_data.data(), 0x100, 0) == 0x100) {
std::array<u8, 0x20> build_id{};
std::memcpy(build_id.data(), header_data.data() + 0x40, 0x20);
update_build_id_hex = Common::HexToString(build_id, false);
}
}
}
// Additional check: if we still don't have an update build ID but we know there's an update
// (from the Add-Ons tab showing v1.0.1 etc), try alternative detection methods
bool update_detected = false;
if (update_build_id_hex.empty() && !base_build_id_hex.empty()) {
// Check if the patch manager indicates an update is available
const auto update_version = pm.GetGameVersion();
if (update_version.has_value() && update_version.value() > 0) {
update_detected = true;
}
}
// Method 3: Try to use the patch manager's GetPatches to detect updates
if (update_build_id_hex.empty()) {
const auto patches = pm_update.GetPatches();
// Also check patches
const auto patches = pm.GetPatches();
for (const auto& patch : patches) {
if (patch.type == FileSys::PatchType::Update && patch.enabled) {
// There's an enabled update patch, but we couldn't get its build ID
// This indicates an update is available but not currently loaded
update_detected = true;
break;
}
}
}
} catch (...) {
// If update build ID extraction fails, continue with just base
}
// Try to get the actual running build ID from system (this will be the update if one is applied)
const auto& system_build_id = system.GetApplicationProcessBuildID();
const auto system_build_id_hex = Common::HexToString(system_build_id, false);
// Display the Build IDs in separate fields
bool has_base = !base_build_id_hex.empty() && base_build_id_hex != std::string(64, '0');
bool has_update = !update_build_id_hex.empty() && update_build_id_hex != std::string(64, '0');
// If we have a system build ID and it's different from the base, it's likely the update
if (!system_build_id_hex.empty() && system_build_id_hex != std::string(64, '0')) {
if (!base_build_id_hex.empty() && system_build_id_hex != base_build_id_hex) {
// System build ID is different from base, so it's the update
update_build_id_hex = system_build_id_hex;
} else if (base_build_id_hex.empty()) {
// No base build ID found, use system as base
base_build_id_hex = system_build_id_hex;
}
}
// Additional check: if we still don't have an update build ID but we know there's an update
// (from the Add-Ons tab showing v1.0.1 etc), try alternative detection methods
bool update_detected = false;
if (update_build_id_hex.empty() && !base_build_id_hex.empty()) {
// Check if the patch manager indicates an update is available
const auto update_version = pm.GetGameVersion();
if (update_version.has_value() && update_version.value() > 0) {
update_detected = true;
// Set Base Build ID
if (has_base) {
ui->display_build_id->setText(QString::fromStdString(base_build_id_hex));
} else {
ui->display_build_id->setText(tr("Not Available"));
}
// Also check patches
const auto patches = pm.GetPatches();
for (const auto& patch : patches) {
if (patch.type == FileSys::PatchType::Update && patch.enabled) {
update_detected = true;
break;
}
// Set Update Build ID
if (has_update) {
ui->display_update_build_id->setText(QString::fromStdString(update_build_id_hex));
} else if (update_detected) {
ui->display_update_build_id->setText(tr("Available (Run game to show)"));
} else {
ui->display_update_build_id->setText(tr("Not Available"));
}
}
// Display the Build IDs in separate fields
bool has_base = !base_build_id_hex.empty() && base_build_id_hex != std::string(64, '0');
bool has_update = !update_build_id_hex.empty() && update_build_id_hex != std::string(64, '0');
// Set Base Build ID
if (has_base) {
ui->display_build_id->setText(QString::fromStdString(base_build_id_hex));
} else {
ui->display_build_id->setText(tr("Not Available"));
}
// Set Update Build ID
if (has_update) {
ui->display_update_build_id->setText(QString::fromStdString(update_build_id_hex));
} else if (update_detected) {
ui->display_update_build_id->setText(tr("Available (Run game to show)"));
} else {
ui->display_update_build_id->setText(tr("Not Available"));
}
}

View File

@@ -23,220 +23,262 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Info</string>
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QGraphicsView" name="icon_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="interactive">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="6" column="1">
<widget class="QLineEdit" name="display_size">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="display_version">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Title ID</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="display_title_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="display_filename">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="display_format">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="display_name">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="display_developer">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Version</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Developer</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_build_id">
<property name="text">
<string>Base Build ID</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="display_build_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_update_build_id">
<property name="text">
<string>Update Build ID</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="display_update_build_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</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>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>318</width>
<height>538</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<!-- The original GroupBox is now INSIDE the scroll area -->
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Info</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QGraphicsView" name="icon_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>256</width>
<height>256</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="interactive">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="6" column="1">
<widget class="QLineEdit" name="display_size">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="display_version">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Title ID</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="display_title_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="display_filename">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="display_format">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="display_name">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="display_developer">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Version</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Developer</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_build_id">
<property name="text">
<string>Base Build ID</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="display_build_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_update_build_id">
<property name="text">
<string>Update Build ID</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="display_update_build_id">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</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>
</widget>
</item>
</layout>
</widget>
</widget>
<!-- END OF NEW SCROLL AREA -->
</item>
<item>
<layout class="QVBoxLayout" name="VerticalLayout">
@@ -248,6 +290,12 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>-1</number>
</property>