Rework system title handling with up-to-date title list and region detection support. (#6356)

This commit is contained in:
Steveice10 2023-03-29 04:55:29 -07:00 committed by GitHub
parent b5d6f645bd
commit 5346ca27b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 1292 additions and 806 deletions

View file

@ -15,10 +15,8 @@
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/ptm/ptm.h"
#include "core/hw/aes/key.h"
#include "core/system_titles.h"
#include "ui_configure_system.h"
#ifdef ENABLE_WEB_SERVICE
#include "web_service/nus_titles.h"
#endif
static const std::array<int, 12> days_in_month = {{
31,
@ -246,7 +244,9 @@ ConfigureSystem::ConfigureSystem(QWidget* parent)
SetupPerGameUI();
ui->combo_download_mode->setCurrentIndex(1); // set to Recommended
ui->combo_download_set->setCurrentIndex(0); // set to Minimal
ui->combo_download_region->setCurrentIndex(0); // set to the base region
bool keys_available = true;
HW::AES::InitKeys(true);
for (u8 i = 0; i < HW::AES::MaxCommonKeySlot; i++) {
@ -258,11 +258,13 @@ ConfigureSystem::ConfigureSystem(QWidget* parent)
}
if (keys_available) {
ui->button_start_download->setEnabled(true);
ui->combo_download_mode->setEnabled(true);
ui->combo_download_set->setEnabled(true);
ui->combo_download_region->setEnabled(true);
ui->label_nus_download->setText(tr("Download System Files from Nintendo servers"));
} else {
ui->button_start_download->setEnabled(false);
ui->combo_download_mode->setEnabled(false);
ui->combo_download_set->setEnabled(false);
ui->combo_download_region->setEnabled(false);
ui->label_nus_download->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->label_nus_download->setOpenExternalLinks(true);
ui->label_nus_download->setText(
@ -343,6 +345,9 @@ void ConfigureSystem::ReadSystemSettings() {
// set play coin
play_coin = Service::PTM::Module::GetPlayCoins();
ui->spinBox_play_coins->setValue(play_coin);
// set firmware download region
ui->combo_download_region->setCurrentIndex(static_cast<int>(cfg->GetRegionValue()));
}
void ConfigureSystem::ApplyConfiguration() {
@ -535,8 +540,10 @@ void ConfigureSystem::DownloadFromNUS() {
#ifdef ENABLE_WEB_SERVICE
ui->button_start_download->setEnabled(false);
const auto mode = static_cast<Title::Mode>(ui->combo_download_mode->currentIndex());
const std::vector<u64> titles = BuildFirmwareTitleList(mode, cfg->GetRegionValue());
const auto mode =
static_cast<Core::SystemTitleSet>(1 << ui->combo_download_set->currentIndex());
const auto region = static_cast<u32>(ui->combo_download_region->currentIndex());
const std::vector<u64> titles = Core::GetSystemTitleIds(mode, region);
QProgressDialog progress(tr("Downloading files..."), tr("Cancel"), 0,
static_cast<int>(titles.size()), this);

View file

@ -371,22 +371,61 @@
<item row="15" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_nus_download">
<item>
<widget class="QComboBox" name="combo_download_mode">
<item>
<property name="text">
<string>All</string>
</property>
</item>
<item>
<property name="text">
<string>Recommended</string>
</property>
</item>
<widget class="QComboBox" name="combo_download_set">
<item>
<property name="text">
<string>Minimal</string>
</property>
</item>
<item>
<property name="text">
<string>Old 3DS</string>
</property>
</item>
<item>
<property name="text">
<string>New 3DS</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_download_region">
<item>
<property name="text">
<string>JPN</string>
</property>
</item>
<item>
<property name="text">
<string>USA</string>
</property>
</item>
<item>
<property name="text">
<string>EUR</string>
</property>
</item>
<item>
<property name="text">
<string>AUS</string>
</property>
</item>
<item>
<property name="text">
<string>CHN</string>
</property>
</item>
<item>
<property name="text">
<string>KOR</string>
</property>
</item>
<item>
<property name="text">
<string>TWN</string>
</property>
</item>
</widget>
</item>
<item>

View file

@ -94,6 +94,7 @@
#include "core/loader/loader.h"
#include "core/movie.h"
#include "core/savestate.h"
#include "core/system_titles.h"
#include "game_list_p.h"
#include "input_common/main.h"
#include "network/network_settings.h"
@ -747,7 +748,10 @@ void GMainWindow::ConnectMenuEvents() {
// File
connect_menu(ui->action_Load_File, &GMainWindow::OnMenuLoadFile);
connect_menu(ui->action_Install_CIA, &GMainWindow::OnMenuInstallCIA);
connect_menu(ui->action_Boot_Home_Menu, &GMainWindow::OnMenuBootHomeMenu);
for (u32 region = 0; region < Core::NUM_SYSTEM_TITLE_REGIONS; region++) {
connect_menu(ui->menu_Boot_Home_Menu->actions().at(region),
[this, region] { OnMenuBootHomeMenu(region); });
}
connect_menu(ui->action_Exit, &QMainWindow::close);
connect_menu(ui->action_Load_Amiibo, &GMainWindow::OnLoadAmiibo);
connect_menu(ui->action_Remove_Amiibo, &GMainWindow::OnRemoveAmiibo);
@ -1633,18 +1637,8 @@ void GMainWindow::OnMenuInstallCIA() {
InstallCIA(filepaths);
}
static std::string GetHomeMenuPath() {
static const std::array<u64, 7> home_menu_tids = {
0x0004003000008202, 0x0004003000008F02, 0x0004003000009802, 0x0004003000009802,
0x000400300000A102, 0x000400300000A902, 0x000400300000B102};
Service::CFG::Module cfg{};
return Service::AM::GetTitleContentPath(Service::FS::MediaType::NAND,
home_menu_tids[cfg.GetRegionValue()]);
}
void GMainWindow::OnMenuBootHomeMenu() {
BootGame(QString::fromStdString(GetHomeMenuPath()));
void GMainWindow::OnMenuBootHomeMenu(u32 region) {
BootGame(QString::fromStdString(Core::GetHomeMenuNcchPath(region)));
}
void GMainWindow::InstallCIA(QStringList filepaths) {
@ -2292,9 +2286,13 @@ void GMainWindow::UpdateStatusBar() {
}
void GMainWindow::UpdateBootHomeMenuState() {
const std::string home_menu_path = GetHomeMenuPath();
ui->action_Boot_Home_Menu->setEnabled(!home_menu_path.empty() &&
FileUtil::Exists(GetHomeMenuPath()));
const auto current_region = Settings::values.region_value.GetValue();
for (u32 region = 0; region < Core::NUM_SYSTEM_TITLE_REGIONS; region++) {
const auto path = Core::GetHomeMenuNcchPath(region);
ui->menu_Boot_Home_Menu->actions().at(region)->setEnabled(
(current_region == Settings::REGION_VALUE_AUTO_SELECT || current_region == region) &&
!path.empty() && FileUtil::Exists(path));
}
}
void GMainWindow::HideMouseCursor() {

View file

@ -196,7 +196,7 @@ private slots:
void OnConfigurePerGame();
void OnMenuLoadFile();
void OnMenuInstallCIA();
void OnMenuBootHomeMenu();
void OnMenuBootHomeMenu(u32 region);
void OnUpdateProgress(std::size_t written, std::size_t total);
void OnCIAInstallReport(Service::AM::InstallStatus status, QString filepath);
void OnCIAInstallFinished();

View file

@ -52,6 +52,18 @@
<property name="title">
<string>&amp;File</string>
</property>
<widget class="QMenu" name="menu_Boot_Home_Menu">
<property name="title">
<string>Boot Home Menu</string>
</property>
<addaction name="action_Boot_Home_Menu_JPN"/>
<addaction name="action_Boot_Home_Menu_USA"/>
<addaction name="action_Boot_Home_Menu_EUR"/>
<addaction name="action_Boot_Home_Menu_AUS"/>
<addaction name="action_Boot_Home_Menu_CHN"/>
<addaction name="action_Boot_Home_Menu_KOR"/>
<addaction name="action_Boot_Home_Menu_TWN"/>
</widget>
<widget class="QMenu" name="menu_recent_files">
<property name="title">
<string>Recent Files</string>
@ -66,7 +78,7 @@
</widget>
<addaction name="action_Load_File"/>
<addaction name="action_Install_CIA"/>
<addaction name="action_Boot_Home_Menu"/>
<addaction name="menu_Boot_Home_Menu"/>
<addaction name="separator"/>
<addaction name="menu_recent_files"/>
<addaction name="separator"/>
@ -210,9 +222,39 @@
<string>Install CIA...</string>
</property>
</action>
<action name="action_Boot_Home_Menu">
<action name="action_Boot_Home_Menu_JPN">
<property name="text">
<string>Boot Home Menu</string>
<string>JPN</string>
</property>
</action>
<action name="action_Boot_Home_Menu_USA">
<property name="text">
<string>USA</string>
</property>
</action>
<action name="action_Boot_Home_Menu_EUR">
<property name="text">
<string>EUR</string>
</property>
</action>
<action name="action_Boot_Home_Menu_AUS">
<property name="text">
<string>AUS</string>
</property>
</action>
<action name="action_Boot_Home_Menu_CHN">
<property name="text">
<string>CHN</string>
</property>
</action>
<action name="action_Boot_Home_Menu_KOR">
<property name="text">
<string>KOR</string>
</property>
</action>
<action name="action_Boot_Home_Menu_TWN">
<property name="text">
<string>TWN</string>
</property>
</action>
<action name="action_Exit">