From 4a59d1cfda09ceb4b9f4988a4e4cd227926bbd5c Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Sat, 31 May 2025 22:14:02 +0100 Subject: [PATCH] add support for loading custom forwarder gif/logo from file. --- sphaira/source/app.cpp | 40 +++++++++++-------------- sphaira/source/ui/menus/filebrowser.cpp | 12 ++++++++ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/sphaira/source/app.cpp b/sphaira/source/app.cpp index 2f29378..4da6d94 100644 --- a/sphaira/source/app.cpp +++ b/sphaira/source/app.cpp @@ -896,22 +896,18 @@ void App::SetTextScrollSpeed(long index) { } auto App::Install(OwoConfig& config) -> Result { - config.nro_path = nro_add_arg_file(config.nro_path); - if (!config.icon.empty()) { - config.icon = GetNroIcon(config.icon); - } + App::Push(std::make_shared(0, "Installing Forwarder"_i18n, config.name, [config](auto pbox) mutable -> Result { + return Install(pbox, config); + }, [](Result rc){ + App::PushErrorBox(rc, "Failed to install forwarder"_i18n); - const auto rc = install_forwarder(config, App::GetInstallSdEnable() ? NcmStorageId_SdCard : NcmStorageId_BuiltInUser); + if (R_SUCCEEDED(rc)) { + App::PlaySoundEffect(SoundEffect_Install); + App::Notify("Installed!"_i18n); + } + })); - if (R_FAILED(rc)) { - App::PlaySoundEffect(SoundEffect_Error); - App::Push(std::make_shared(rc, "Failed to install forwarder"_i18n)); - } else { - App::PlaySoundEffect(SoundEffect_Install); - App::Notify("Installed!"_i18n); - } - - return rc; + R_SUCCEED(); } auto App::Install(ui::ProgressBox* pbox, OwoConfig& config) -> Result { @@ -920,17 +916,15 @@ auto App::Install(ui::ProgressBox* pbox, OwoConfig& config) -> Result { config.icon = GetNroIcon(config.icon); } - const auto rc = install_forwarder(pbox, config, GetInstallSdEnable() ? NcmStorageId_SdCard : NcmStorageId_BuiltInUser); - - if (R_FAILED(rc)) { - App::PlaySoundEffect(SoundEffect_Error); - App::Push(std::make_shared(rc, "Failed to install forwarder"_i18n)); - } else { - App::PlaySoundEffect(SoundEffect_Install); - App::Notify("Installed!"_i18n); + if (config.logo.empty()) { + fs::FsNativeSd().read_entire_file("/config/sphaira/logo/NintendoLogo.png", config.logo); } - return rc; + if (config.gif.empty()) { + fs::FsNativeSd().read_entire_file("/config/sphaira/logo/StartupMovie.gif", config.gif); + } + + return install_forwarder(pbox, config, GetInstallSdEnable() ? NcmStorageId_SdCard : NcmStorageId_BuiltInUser); } auto App::IsEmummc() -> bool { diff --git a/sphaira/source/ui/menus/filebrowser.cpp b/sphaira/source/ui/menus/filebrowser.cpp index be0b5bc..90908b2 100644 --- a/sphaira/source/ui/menus/filebrowser.cpp +++ b/sphaira/source/ui/menus/filebrowser.cpp @@ -671,7 +671,19 @@ void FsView::InstallForwarder() { config.icon = GetRomIcon(m_fs.get(), pbox, file_name, db_indexs, nro); pbox->SetImageDataConst(config.icon); + if (!db_indexs.empty()) { + fs::FsNativeSd().read_entire_file("/config/sphaira/logo/rom/NintendoLogo.png", config.logo); + fs::FsNativeSd().read_entire_file("/config/sphaira/logo/rom/StartupMovie.gif", config.gif); + } + return App::Install(pbox, config); + }, [this](Result rc){ + App::PushErrorBox(rc, "Failed to install forwarder"_i18n); + + if (R_SUCCEEDED(rc)) { + App::PlaySoundEffect(SoundEffect_Install); + App::Notify("Installed!"_i18n); + } })); } else { log_write("pressed B to skip launch...\n");