Fix launching applets and titles with updates

This commit is contained in:
Maschell 2022-01-09 13:37:36 +01:00
parent 02d34db212
commit df88cf8d69
3 changed files with 92 additions and 52 deletions

View File

@ -45,21 +45,21 @@ GameSplashScreen::GameSplashScreen(int32_t w, int32_t h, gameInfo *info, bool on
} }
void GameSplashScreen::OnSplashScreenFadeInDone(GuiElement *element) { void GameSplashScreen::OnSplashScreenFadeInDone(GuiElement *element) {
// we need to wait one more frame becaus the effects get calculated before drawing. // we need to wait one more frame because the effects get calculated before drawing.
launchGame = true; launchGame = true;
} }
void GameSplashScreen::draw(CVideo *v) { void GameSplashScreen::draw(CVideo *v) {
GuiFrame::draw(v); GuiFrame::draw(v);
bool triggerLaunch = onTV; // Only the trigger the launch when calling for the TV.
if (launchGame && frameCounter++ > 1) { if (launchGame && frameCounter++ > 1) {
DEBUG_FUNCTION_LINE("Launch game %d\n", onTV); launchGame = false;
gameGameSplashScreenFinished(this, info, onTV); gameGameSplashScreenFinished(this, info, triggerLaunch);
} }
} }
GameSplashScreen::~GameSplashScreen() { GameSplashScreen::~GameSplashScreen() {
DEBUG_FUNCTION_LINE("Destroy me\n"); DEBUG_FUNCTION_LINE("Destroy me");
if (splashScreenData) { if (splashScreenData) {
AsyncExecutor::pushForDelete(splashScreenData); AsyncExecutor::pushForDelete(splashScreenData);
} }

View File

@ -25,6 +25,7 @@
#include <sysapp/launch.h> #include <sysapp/launch.h>
#include <future> #include <future>
#include <coreinit/title.h> #include <coreinit/title.h>
#include <nn/acp/title.h>
#include "utils/AsyncExecutor.h" #include "utils/AsyncExecutor.h"
#include "GameSplashScreen.h" #include "GameSplashScreen.h"
@ -346,6 +347,7 @@ void MainWindow::OnOpenEffectFinish(GuiElement *element) {
} }
void MainWindow::OnCloseEffectFinish(GuiElement *element) { void MainWindow::OnCloseEffectFinish(GuiElement *element) {
DEBUG_FUNCTION_LINE("Remove %08X", element);
//! remove element from draw list and push to delete queue //! remove element from draw list and push to delete queue
remove(element); remove(element);
AsyncExecutor::pushForDelete(element); AsyncExecutor::pushForDelete(element);
@ -366,39 +368,25 @@ void MainWindow::OnGameSelectionChange(GuiTitleBrowser *element, uint64_t select
} }
} }
#define HBL_TITLE_ID (0x0005000013374842)
#define MII_MAKER_JPN_TITLE_ID (0x000500101004A000)
#define MII_MAKER_USA_TITLE_ID (0x000500101004A100)
#define MII_MAKER_EUR_TITLE_ID (0x000500101004A200)
extern "C" void _SYSLaunchTitleByPathFromLauncher(const char *path, int len, int);
void MainWindow::OnGameLaunchSplashScreen(GuiTitleBrowser *element, uint64_t titleID) { void MainWindow::OnGameLaunchSplashScreen(GuiTitleBrowser *element, uint64_t titleID) {
DEBUG_FUNCTION_LINE("");
gameInfo *info = gameList.getGameInfo(titleID); gameInfo *info = gameList.getGameInfo(titleID);
if (info != nullptr) { if (info != nullptr) {
uint64_t ownTitleId = OSGetTitleID(); auto *splashScreenDRC = new GameSplashScreen(width, height, info, false);
if (ownTitleId == HBL_TITLE_ID || splashScreenDRC->setEffect(EFFECT_FADE, 15, 255);
ownTitleId == MII_MAKER_JPN_TITLE_ID || splashScreenDRC->setState(GuiElement::STATE_DISABLED);
ownTitleId == MII_MAKER_USA_TITLE_ID || splashScreenDRC->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish);
ownTitleId == MII_MAKER_EUR_TITLE_ID) { splashScreenDRC->gameGameSplashScreenFinished.connect(this, &MainWindow::OnGameLaunchSplashScreenFinished);
OnGameLaunch(titleID); appendDrc(splashScreenDRC);
} else {
GameSplashScreen *gameSettingsDRC = new GameSplashScreen(width, height, info, false);
gameSettingsDRC->setEffect(EFFECT_FADE, 15, 255);
gameSettingsDRC->setState(GuiElement::STATE_DISABLED);
gameSettingsDRC->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish);
gameSettingsDRC->gameGameSplashScreenFinished.connect(this, &MainWindow::OnGameLaunchSplashScreenFinished);
appendDrc(gameSettingsDRC);
GameSplashScreen *gameSettingsTV = new GameSplashScreen(width, height, info, true); auto *splashScreenTV = new GameSplashScreen(width, height, info, true);
gameSettingsTV->setEffect(EFFECT_FADE, 15, 255); splashScreenTV->setEffect(EFFECT_FADE, 15, 255);
gameSettingsTV->setState(GuiElement::STATE_DISABLED); splashScreenTV->setState(GuiElement::STATE_DISABLED);
gameSettingsTV->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish); splashScreenTV->effectFinished.connect(this, &MainWindow::OnOpenEffectFinish);
gameSettingsTV->gameGameSplashScreenFinished.connect(this, &MainWindow::OnGameLaunchSplashScreenFinished); splashScreenTV->gameGameSplashScreenFinished.connect(this, &MainWindow::OnGameLaunchSplashScreenFinished);
appendTv(gameSettingsTV); appendTv(splashScreenTV);
}
} else { } else {
DEBUG_FUNCTION_LINE("Failed to find gameInfo for titleId %016llX\n", titleID); DEBUG_FUNCTION_LINE("Failed to find gameInfo for titleId %016llX", titleID);
} }
} }
@ -410,26 +398,78 @@ void MainWindow::OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo
OnGameLaunch(info->titleId); OnGameLaunch(info->titleId);
} }
if (element) { if (element) {
element->setState(GuiElement::STATE_DISABLED); // immediately remove the splashScreen
element->setEffect(EFFECT_FADE, 15, 255); MainWindow::OnCloseEffectFinish(element);
element->effectFinished.connect(this, &MainWindow::OnCloseEffectFinish);
} }
} }
void MainWindow::OnGameLaunch(uint64_t titleID) { extern "C" int32_t SYSSwitchToBrowser(void *);
gameInfo *info = gameList.getGameInfo(titleID); extern "C" int32_t SYSSwitchToEShop(void *);
if (info != nullptr) { extern "C" int32_t _SYSSwitchTo(uint32_t pfid);
uint64_t titleID = OSGetTitleID();
if (titleID == HBL_TITLE_ID || void MainWindow::OnGameLaunch(uint64_t titleId) {
titleID == MII_MAKER_JPN_TITLE_ID || DEBUG_FUNCTION_LINE("Launch GAME!!");
titleID == MII_MAKER_USA_TITLE_ID ||
titleID == MII_MAKER_EUR_TITLE_ID) { if (titleId == 0x0005001010040000L ||
SYSLaunchTitle(info->titleId); titleId == 0x0005001010040100L ||
} else { titleId == 0x0005001010040200L) {
const char *path = info->gamePath.c_str(); DEBUG_FUNCTION_LINE("Skip launching the Wii U Menu");
_SYSLaunchTitleByPathFromLauncher(path, strlen(path), 0); return;
} }
} else {
DEBUG_FUNCTION_LINE("Failed to find gameInfo for titleId %016llX\n", titleID); if (titleId == 0x000500301001220AL ||
titleId == 0x000500301001210AL ||
titleId == 0x000500301001200AL) {
DEBUG_FUNCTION_LINE("Launching the browser");
SYSSwitchToBrowser(nullptr);
return;
} }
if (titleId == 0x000500301001400AL ||
titleId == 0x000500301001410AL ||
titleId == 0x000500301001420AL) {
DEBUG_FUNCTION_LINE("Launching the Eshop");
SYSSwitchToEShop(nullptr);
return;
}
if (titleId == 0x000500301001800AL ||
titleId == 0x000500301001810AL ||
titleId == 0x000500301001820AL) {
DEBUG_FUNCTION_LINE("Launching the Download Management");
_SYSSwitchTo(12);
return;
}
if (titleId == 0x000500301001600AL ||
titleId == 0x000500301001610AL ||
titleId == 0x000500301001620AL) {
DEBUG_FUNCTION_LINE("Launching Miiverse");
_SYSSwitchTo(9);
return;
}
if (titleId == 0x000500301001500AL ||
titleId == 0x000500301001510AL ||
titleId == 0x000500301001520AL) {
DEBUG_FUNCTION_LINE("Launching Friendlist");
_SYSSwitchTo(11);
return;
}
if (titleId == 0x000500301001300AL ||
titleId == 0x000500301001310AL ||
titleId == 0x000500301001320AL) {
DEBUG_FUNCTION_LINE("Launching TVii");
_SYSSwitchTo(3);
return;
}
MCPTitleListType titleInfo;
int32_t handle = MCP_Open();
auto err = MCP_GetTitleInfo(handle, titleId, &titleInfo);
MCP_Close(handle);
if (err == 0) {
ACPAssignTitlePatch(&titleInfo);
_SYSLaunchTitleWithStdArgsInNoSplash(titleId, nullptr);
return;
}
DEBUG_FUNCTION_LINE("Failed launch titleId %016llX", titleId);
} }

View File

@ -128,7 +128,7 @@ private:
void OnCloseEffectFinish(GuiElement *element); void OnCloseEffectFinish(GuiElement *element);
void OnGameLaunch(uint64_t titleId); static void OnGameLaunch(uint64_t titleId);
void OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo *info, bool launchGame); void OnGameLaunchSplashScreenFinished(GuiElement *element, gameInfo *info, bool launchGame);