diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5c34224cc0..31936b64dd 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -77,7 +77,6 @@ #include "UI/ControlMappingScreen.h" #include "UI/DisplayLayoutScreen.h" #include "UI/GameSettingsScreen.h" -#include "UI/InstallZipScreen.h" #include "UI/ProfilerDraw.h" #include "UI/DiscordIntegration.h" #include "UI/ChatScreen.h" @@ -1163,14 +1162,6 @@ void EmuScreen::update() { } if (errorMessage_.size()) { - // Special handling for ZIP files. It's not very robust to check an error message but meh, - // at least it's pre-translation. - if (errorMessage_.find("ZIP") != std::string::npos) { - screenManager()->push(new InstallZipScreen(gamePath_)); - errorMessage_ = ""; - quit_ = true; - return; - } auto err = GetI18NCategory("Error"); std::string errLoadingFile = gamePath_ + "\n"; errLoadingFile.append(err->T("Error loading file", "Could not load game")); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 43535913d7..83c8b28afb 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -52,6 +52,7 @@ #include "UI/DisplayLayoutScreen.h" #include "UI/SavedataScreen.h" #include "UI/Store.h" +#include "UI/InstallZipScreen.h" #include "Core/Config.h" #include "Core/Loaders.h" #include "GPU/GPUInterface.h" @@ -74,6 +75,29 @@ bool MainScreen::showHomebrewTab = false; +bool LaunchFile(ScreenManager *screenManager, std::string path) { + // Depending on the file type, we don't want to launch EmuScreen at all. + auto loader = ConstructFileLoader(path); + if (!loader) { + return false; + } + + IdentifiedFileType type = Identify_File(loader); + delete loader; + + switch (type) { + case IdentifiedFileType::ARCHIVE_ZIP: + // Special handling for ZIP files. It's not very robust to check an error message but meh, + // at least it's pre-translation. + screenManager->push(new InstallZipScreen(path)); + break; + default: + // Let the EmuScreen take care of it. + screenManager->switchScreen(new EmuScreen(path)); + break; + } +} + static bool IsTempPath(const std::string &str) { std::string item = str; @@ -1155,7 +1179,7 @@ void MainScreen::sendMessage(const char *message, const char *value) { if (screenManager()->topScreen() == this) { if (!strcmp(message, "boot")) { - screenManager()->switchScreen(new EmuScreen(value)); + LaunchFile(screenManager(), std::string(value)); } if (!strcmp(message, "browse_folderSelect")) { int tab = tabHolder_->GetCurrentTab(); @@ -1304,8 +1328,7 @@ UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) { #else std::string path = e.s; #endif - // Go directly into the game. - screenManager()->switchScreen(new EmuScreen(path)); + LaunchFile(screenManager(), path); return UI::EVENT_DONE; }