Merge pull request #1344 from LittleWhite-tb/error-output

Output errors in GUI
This commit is contained in:
bunnei 2016-03-08 23:12:04 -05:00
commit 8530a2d7df
12 changed files with 95 additions and 24 deletions

View file

@ -249,22 +249,73 @@ void GMainWindow::OnDisplayTitleBars(bool show)
} }
} }
void GMainWindow::BootGame(const std::string& filename) { bool GMainWindow::InitializeSystem() {
LOG_INFO(Frontend, "Citra starting...");
// Shutdown previous session if the emu thread is still active... // Shutdown previous session if the emu thread is still active...
if (emu_thread != nullptr) if (emu_thread != nullptr)
ShutdownGame(); ShutdownGame();
// Initialize the core emulation // Initialize the core emulation
System::Init(render_window); System::Result system_result = System::Init(render_window);
if (System::Result::Success != system_result) {
switch (system_result) {
case System::Result::ErrorInitVideoCore:
QMessageBox::critical(this, tr("Error while starting Citra!"),
tr("Failed to initialize the video core!\n\n"
"Please ensure that your GPU supports OpenGL 3.3 and that you have the latest graphics driver."));
break;
// Load the game default:
if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) { QMessageBox::critical(this, tr("Error while starting Citra!"),
tr("Unknown error (please check the log)!"));
break;
}
return false;
}
return true;
}
bool GMainWindow::LoadROM(const std::string& filename) {
Loader::ResultStatus result = Loader::LoadFile(filename);
if (Loader::ResultStatus::Success != result) {
LOG_CRITICAL(Frontend, "Failed to load ROM!"); LOG_CRITICAL(Frontend, "Failed to load ROM!");
System::Shutdown(); System::Shutdown();
return;
switch (result) {
case Loader::ResultStatus::ErrorEncrypted: {
// Build the MessageBox ourselves to have clickable link
QMessageBox popup_error;
popup_error.setTextFormat(Qt::RichText);
popup_error.setWindowTitle(tr("Error while loading ROM!"));
popup_error.setText(tr("The game that you are trying to load must be decrypted before being used with Citra.<br/><br/>"
"For more information on dumping and decrypting games, please see: <a href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://citra-emu.org/wiki/Dumping-Game-Cartridges</a>"));
popup_error.setIcon(QMessageBox::Critical);
popup_error.exec();
break;
}
case Loader::ResultStatus::ErrorInvalidFormat:
QMessageBox::critical(this, tr("Error while loading ROM!"),
tr("The ROM format is not supported."));
break;
case Loader::ResultStatus::Error:
default:
QMessageBox::critical(this, tr("Error while loading ROM!"),
tr("Unknown error!"));
break;
}
return false;
} }
return true;
}
void GMainWindow::BootGame(const std::string& filename) {
LOG_INFO(Frontend, "Citra starting...");
if (!InitializeSystem())
return;
if (!LoadROM(filename))
return;
// Create and start the emulation thread // Create and start the emulation thread
emu_thread = Common::make_unique<EmuThread>(render_window); emu_thread = Common::make_unique<EmuThread>(render_window);

View file

@ -59,6 +59,8 @@ signals:
void EmulationStopping(); void EmulationStopping();
private: private:
bool InitializeSystem();
bool LoadROM(const std::string& filename);
void BootGame(const std::string& filename); void BootGame(const std::string& filename);
void ShutdownGame(); void ShutdownGame();

View file

@ -73,12 +73,11 @@ void Stop() {
} }
/// Initialize the core /// Initialize the core
int Init() { void Init() {
g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE); g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE);
g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE); g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE);
LOG_DEBUG(Core, "Initialized OK"); LOG_DEBUG(Core, "Initialized OK");
return 0;
} }
void Shutdown() { void Shutdown() {

View file

@ -52,7 +52,7 @@ void Halt(const char *msg);
void Stop(); void Stop();
/// Initialize the core /// Initialize the core
int Init(); void Init();
/// Shutdown the core /// Shutdown the core
void Shutdown(); void Shutdown();

View file

@ -137,11 +137,11 @@ ResultStatus LoadFile(const std::string& filename) {
AppLoader_NCCH app_loader(std::move(file), filename); AppLoader_NCCH app_loader(std::move(file), filename);
// Load application and RomFS // Load application and RomFS
if (ResultStatus::Success == app_loader.Load()) { ResultStatus result = app_loader.Load();
if (ResultStatus::Success == result) {
Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
return ResultStatus::Success;
} }
break; return result;
} }
// CIA file format... // CIA file format...

View file

@ -17,14 +17,16 @@
namespace System { namespace System {
void Init(EmuWindow* emu_window) { Result Init(EmuWindow* emu_window) {
Core::Init(); Core::Init();
CoreTiming::Init(); CoreTiming::Init();
Memory::Init(); Memory::Init();
HW::Init(); HW::Init();
Kernel::Init(); Kernel::Init();
HLE::Init(); HLE::Init();
VideoCore::Init(emu_window); if (!VideoCore::Init(emu_window)) {
return Result::ErrorInitVideoCore;
}
AudioCore::Init(); AudioCore::Init();
GDBStub::Init(); GDBStub::Init();
} }

View file

@ -8,7 +8,14 @@ class EmuWindow;
namespace System { namespace System {
void Init(EmuWindow* emu_window); enum class Result {
Success, ///< Everything is fine
Error, ///< Something went wrong (no module specified)
ErrorInitCore, ///< Something went wrong during core init
ErrorInitVideoCore, ///< Something went wrong during video core init
};
Result Init(EmuWindow* emu_window);
void Shutdown(); void Shutdown();
} }

View file

@ -38,7 +38,7 @@ public:
virtual void SetWindow(EmuWindow* window) = 0; virtual void SetWindow(EmuWindow* window) = 0;
/// Initialize the renderer /// Initialize the renderer
virtual void Init() = 0; virtual bool Init() = 0;
/// Shutdown the renderer /// Shutdown the renderer
virtual void ShutDown() = 0; virtual void ShutDown() = 0;

View file

@ -445,7 +445,7 @@ static void DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity,
} }
/// Initialize the renderer /// Initialize the renderer
void RendererOpenGL::Init() { bool RendererOpenGL::Init() {
render_window->MakeCurrent(); render_window->MakeCurrent();
// TODO: Make frontends initialize this, so they can use gladLoadGLLoader with their own loaders // TODO: Make frontends initialize this, so they can use gladLoadGLLoader with their own loaders
@ -462,9 +462,15 @@ void RendererOpenGL::Init() {
LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION)); LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR));
LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER));
if (!GLAD_GL_VERSION_3_3) {
return false;
}
InitOpenGLObjects(); InitOpenGLObjects();
RefreshRasterizerSetting(); RefreshRasterizerSetting();
return true;
} }
/// Shutdown the renderer /// Shutdown the renderer

View file

@ -31,7 +31,7 @@ public:
void SetWindow(EmuWindow* window) override; void SetWindow(EmuWindow* window) override;
/// Initialize the renderer /// Initialize the renderer
void Init() override; bool Init() override;
/// Shutdown the renderer /// Shutdown the renderer
void ShutDown() override; void ShutDown() override;

View file

@ -28,15 +28,19 @@ std::atomic<bool> g_hw_renderer_enabled;
std::atomic<bool> g_shader_jit_enabled; std::atomic<bool> g_shader_jit_enabled;
/// Initialize the video core /// Initialize the video core
void Init(EmuWindow* emu_window) { bool Init(EmuWindow* emu_window) {
Pica::Init(); Pica::Init();
g_emu_window = emu_window; g_emu_window = emu_window;
g_renderer = Common::make_unique<RendererOpenGL>(); g_renderer = Common::make_unique<RendererOpenGL>();
g_renderer->SetWindow(g_emu_window); g_renderer->SetWindow(g_emu_window);
g_renderer->Init(); if (g_renderer->Init()) {
LOG_DEBUG(Render, "initialized OK");
LOG_DEBUG(Render, "initialized OK"); } else {
LOG_ERROR(Render, "initialization failed !");
return false;
}
return true;
} }
/// Shutdown the video core /// Shutdown the video core

View file

@ -41,7 +41,7 @@ extern std::atomic<bool> g_shader_jit_enabled;
void Start(); void Start();
/// Initialize the video core /// Initialize the video core
void Init(EmuWindow* emu_window); bool Init(EmuWindow* emu_window);
/// Shutdown the video core /// Shutdown the video core
void Shutdown(); void Shutdown();