From 5f307938459119a4aa1dbeb1487c69a933bd1a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 30 Mar 2025 15:15:37 +0200 Subject: [PATCH] Refactor a little more. --- Core/System.cpp | 21 +++++++++++++++++---- UI/EmuScreen.cpp | 47 +++++++++++++++++++---------------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index 12a392b37e..40aded8e2c 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -254,6 +254,8 @@ static void ShowCompatWarnings(const Compatibility &compat) { } } +extern const std::string INDEX_FILENAME; + // NOTE: The loader has already been fully resolved (ResolveFileLoaderTarget) and identified here. static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::string *errorString) { // Default memory settings @@ -281,6 +283,16 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin if (LoadParamSFOFromDisc()) { InitMemorySizeForGame(); } + if (type == IdentifiedFileType::PSP_DISC_DIRECTORY) { + // Check for existence of ppsspp-index.lst - if it exists, the user likely knows what they're doing. + // TODO: Better would be to check that it was loaded successfully. + if (!File::Exists(g_CoreParameter.fileToStart / INDEX_FILENAME)) { + auto sc = GetI18NCategory(I18NCat::SCREEN); + g_OSD.Show(OSDType::MESSAGE_CENTERED_WARNING, sc->T("ExtractedIsoWarning", "Extracted ISOs often don't work.\nPlay the ISO file directly."), g_CoreParameter.fileToStart.ToVisualString(), 7.0f); + } else { + INFO_LOG(Log::Loader, "Extracted ISO loaded without warning - %s is present.", INDEX_FILENAME.c_str()); + } + } break; case IdentifiedFileType::PSP_PBP: case IdentifiedFileType::PSP_PBP_DIRECTORY: @@ -319,11 +331,12 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin gameTitle = SanitizeString(g_paramSFO.GetValueString("TITLE"), StringRestriction::NoLineBreaksOrSpecials); } - std::string title = StringFromFormat("%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), gameTitle.c_str()); - INFO_LOG(Log::Loader, "%s", title.c_str()); - System_SetWindowTitle(title); + const std::string id = g_paramSFO.GetValueString("DISC_ID"); + const std::string windowTitle = id.empty() ? gameTitle : id + " : " + gameTitle; + INFO_LOG(Log::Loader, "%s", windowTitle.c_str()); + System_SetWindowTitle(windowTitle); - currentMIPS = &mipsr4k; + auto sc = GetI18NCategory(I18NCat::SCREEN); g_symbolMap = new SymbolMap(); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bd3123fe72..3bb90b69ad 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -284,33 +284,9 @@ void EmuScreen::bootGame(const Path &filename) { if (!bootAllowStorage(filename)) return; - // We don't want to boot with the wrong game specific config, so wait until info is ready. - // TODO: Actually, we read this info again during bootup, so this is not really necessary. - std::shared_ptr info = g_gameInfoCache->GetInfo(nullptr, filename, GameInfoFlags::PARAM_SFO); - if (!info->Ready(GameInfoFlags::PARAM_SFO)) { - return; - } - - auto sc = GetI18NCategory(I18NCat::SCREEN); - if (info->fileType == IdentifiedFileType::PSP_DISC_DIRECTORY) { - // Check for existence of ppsspp-index.lst - if it exists, the user likely knows what they're doing. - // TODO: Better would be to check that it was loaded successfully. - if (!File::Exists(filename / INDEX_FILENAME)) { - g_OSD.Show(OSDType::MESSAGE_CENTERED_WARNING, sc->T("ExtractedIsoWarning", "Extracted ISOs often don't work.\nPlay the ISO file directly."), gamePath_.ToVisualString(), 7.0f); - } else { - INFO_LOG(Log::Loader, "Extracted ISO loaded without warning - %s is present.", INDEX_FILENAME.c_str()); - } - } - - extraAssertInfoStr_ = info->id + " " + info->GetTitle(); - SetExtraAssertInfo(extraAssertInfoStr_.c_str()); SetAssertCancelCallback(&AssertCancelCallback, this); - if (!info->id.empty()) { - g_Discord.SetPresenceGame(info->GetTitle()); - } else { - g_Discord.SetPresenceGame(sc->T("Untitled PSP game")); - } + currentMIPS = &mipsr4k; CoreParameter coreParam{}; coreParam.cpuCore = (CPUCore)g_Config.iCpuCore; @@ -374,6 +350,24 @@ void EmuScreen::bootGame(const Path &filename) { // Only call this on successful boot. void EmuScreen::bootComplete() { + // We don't want to boot with the wrong game specific config, so wait until info is ready. + // TODO: Actually, we read this info again during bootup, so this is not really necessary. + auto sc = GetI18NCategory(I18NCat::SCREEN); + auto dev = GetI18NCategory(I18NCat::DEVELOPER); + + if (g_paramSFO.IsValid()) { + g_Discord.SetPresenceGame(SanitizeString(g_paramSFO.GetValueString("TITLE"), StringRestriction::NoLineBreaksOrSpecials)); + } else { + g_Discord.SetPresenceGame(sc->T("Untitled PSP game")); + } + + if (g_paramSFO.IsValid()) { + std::string gameTitle = SanitizeString(g_paramSFO.GetValueString("TITLE"), StringRestriction::NoLineBreaksOrSpecials, 0, 32); + std::string id = g_paramSFO.GetValueString("DISC_ID"); + extraAssertInfoStr_ = id + " " + gameTitle; + SetExtraAssertInfo(extraAssertInfoStr_.c_str()); + } + UpdateUIState(UISTATE_INGAME); System_Notify(SystemNotification::BOOT_DONE); System_Notify(SystemNotification::DISASSEMBLY); @@ -384,9 +378,6 @@ void EmuScreen::bootComplete() { autoLoad(); } - auto sc = GetI18NCategory(I18NCat::SCREEN); - auto dev = GetI18NCategory(I18NCat::DEVELOPER); - #ifndef MOBILE_DEVICE if (g_Config.bFirstRun) { g_OSD.Show(OSDType::MESSAGE_INFO, sc->T("PressESC", "Press ESC to open the pause menu"));