Don't trust the messy error checking in EmuScreen with figuring out what to do with zip files.

Ran into multiple odd bugs, the PSP init process really needs a rework..
This commit is contained in:
Henrik Rydgård 2020-07-27 16:53:02 +02:00
parent fbaba82c68
commit 0939804a23
2 changed files with 26 additions and 12 deletions

View file

@ -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"));

View file

@ -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;
}