Loader, Frontends: Refactor loader creation and game loading

This allows frontends to keep a single loader and use it multiple times
e.g. for code loading and SMDH parsing.
This commit is contained in:
Emmanuel Gil Peyrot 2016-05-17 23:06:33 +01:00
parent 51ee2d2eb1
commit 8fc9c03126
6 changed files with 37 additions and 49 deletions

View file

@ -272,7 +272,15 @@ bool GMainWindow::InitializeSystem() {
}
bool GMainWindow::LoadROM(const std::string& filename) {
Loader::ResultStatus result = Loader::LoadFile(filename);
std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetFileLoader(filename);
if (!app_loader) {
LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str());
QMessageBox::critical(this, tr("Error while loading ROM!"),
tr("The ROM format is not supported."));
return false;
}
Loader::ResultStatus result = app_loader->Load();
if (Loader::ResultStatus::Success != result) {
LOG_CRITICAL(Frontend, "Failed to load ROM!");
System::Shutdown();