From 2fa53ec1d90ab6b2c126fbe42ac73b4ea74cc726 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Sun, 1 Oct 2023 11:59:50 -0600 Subject: [PATCH] yuzu: Allow to launch album applet from firmware --- src/core/hle/service/am/am.cpp | 20 ++++++++++++++++++++ src/core/hle/service/am/am.h | 1 + src/yuzu/main.cpp | 25 +++++++++++++++++++++++++ src/yuzu/main.h | 1 + src/yuzu/main.ui | 6 ++++++ 5 files changed, 53 insertions(+) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 819dea6a70..a92243fc7f 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1493,6 +1493,9 @@ ILibraryAppletSelfAccessor::ILibraryAppletSelfAccessor(Core::System& system_) case Applets::AppletId::MiiEdit: PushInShowMiiEditData(); break; + case Applets::AppletId::PhotoViewer: + PushInShowAlbum(); + break; default: break; } @@ -1569,6 +1572,23 @@ void ILibraryAppletSelfAccessor::GetCallerAppletIdentityInfo(HLERequestContext& rb.PushRaw(applet_info); } +void ILibraryAppletSelfAccessor::PushInShowAlbum() { + const Applets::CommonArguments arguments{ + .arguments_version = Applets::CommonArgumentVersion::Version3, + .size = Applets::CommonArgumentSize::Version3, + .library_version = 1, + .theme_color = Applets::ThemeColor::BasicBlack, + .play_startup_sound = true, + .system_tick = system.CoreTiming().GetClockTicks(), + }; + + std::vector argument_data(sizeof(arguments)); + std::vector settings_data{2}; + std::memcpy(argument_data.data(), &arguments, sizeof(arguments)); + queue_data.emplace_back(std::move(argument_data)); + queue_data.emplace_back(std::move(settings_data)); +} + void ILibraryAppletSelfAccessor::PushInShowCabinetData() { const Applets::CommonArguments arguments{ .arguments_version = Applets::CommonArgumentVersion::Version3, diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 349482dcc8..62994a13f8 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -327,6 +327,7 @@ private: void ExitProcessAndReturn(HLERequestContext& ctx); void GetCallerAppletIdentityInfo(HLERequestContext& ctx); + void PushInShowAlbum(); void PushInShowCabinetData(); void PushInShowMiiEditData(); diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 16fa92e2c0..55f61f98ef 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1553,6 +1553,7 @@ void GMainWindow::ConnectMenuEvents() { // Tools connect_menu(ui->action_Rederive, std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); + connect_menu(ui->action_Load_Album, &GMainWindow::OnAlbum); connect_menu(ui->action_Load_Cabinet_Nickname_Owner, [this]() { OnCabinet(Service::NFP::CabinetMode::StartNicknameAndOwnerSettings); }); connect_menu(ui->action_Load_Cabinet_Eraser, @@ -1590,6 +1591,7 @@ void GMainWindow::UpdateMenuState() { }; const std::array applet_actions{ + ui->action_Load_Album, ui->action_Load_Cabinet_Nickname_Owner, ui->action_Load_Cabinet_Eraser, ui->action_Load_Cabinet_Restorer, @@ -4157,6 +4159,29 @@ void GMainWindow::OnToggleStatusBar() { statusBar()->setVisible(ui->action_Show_Status_Bar->isChecked()); } +void GMainWindow::OnAlbum() { + constexpr u64 AlbumId = 0x010000000000100Dull; + auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); + if (!bis_system) { + QMessageBox::warning(this, tr("No firmware available"), + tr("Please install the firmware to use the Album applet.")); + return; + } + + auto album_nca = bis_system->GetEntry(AlbumId, FileSys::ContentRecordType::Program); + if (!album_nca) { + QMessageBox::warning(this, tr("Album Applet"), + tr("Album applet is not available. Please reinstall firmware.")); + return; + } + + system->GetAppletManager().SetCurrentAppletId(Service::AM::Applets::AppletId::PhotoViewer); + + const auto filename = QString::fromStdString(album_nca->GetFullPath()); + UISettings::values.roms_path = QFileInfo(filename).path(); + BootGame(filename); +} + void GMainWindow::OnCabinet(Service::NFP::CabinetMode mode) { constexpr u64 CabinetId = 0x0100000000001002ull; auto bis_system = system->GetFileSystemController().GetSystemNANDContents(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 52028234c7..6450beb653 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -369,6 +369,7 @@ private slots: void ResetWindowSize720(); void ResetWindowSize900(); void ResetWindowSize1080(); + void OnAlbum(); void OnCabinet(Service::NFP::CabinetMode mode); void OnMiiEdit(); void OnCaptureScreenshot(); diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 31c3de9ef9..88684ffb58 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui @@ -160,6 +160,7 @@ + @@ -380,6 +381,11 @@ &Capture Screenshot + + + Open &Album + + &Set Nickname and Owner