summaryrefslogtreecommitdiff
path: root/src/citra_qt/main.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-22 11:47:44 -0500
committerGravatar GitHub2016-12-22 11:47:44 -0500
commitaa47af7fb6efd0bda54cca2373ed978e538f6d61 (patch)
tree93d96872603f64925cd632f27bb5c7046cadeedf /src/citra_qt/main.cpp
parentMerge pull request #2285 from mailwl/csnd-format (diff)
parentThreadContext: Move from "core" to "arm_interface". (diff)
downloadyuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.gz
yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.xz
yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.zip
Merge pull request #2343 from bunnei/core-cleanup
Core: Top-level consolidate & misc cleanup
Diffstat (limited to 'src/citra_qt/main.cpp')
-rw-r--r--src/citra_qt/main.cpp65
1 files changed, 17 insertions, 48 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index e16d3196c..6d59cf640 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -46,7 +46,6 @@
46#include "core/gdbstub/gdbstub.h" 46#include "core/gdbstub/gdbstub.h"
47#include "core/loader/loader.h" 47#include "core/loader/loader.h"
48#include "core/settings.h" 48#include "core/settings.h"
49#include "core/system.h"
50#include "qhexedit.h" 49#include "qhexedit.h"
51#include "video_core/video_core.h" 50#include "video_core/video_core.h"
52 51
@@ -274,7 +273,7 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
274 } 273 }
275} 274}
276 275
277bool GMainWindow::InitializeSystem(u32 system_mode) { 276bool GMainWindow::LoadROM(const std::string& filename) {
278 // Shutdown previous session if the emu thread is still active... 277 // Shutdown previous session if the emu thread is still active...
279 if (emu_thread != nullptr) 278 if (emu_thread != nullptr)
280 ShutdownGame(); 279 ShutdownGame();
@@ -290,54 +289,25 @@ bool GMainWindow::InitializeSystem(u32 system_mode) {
290 return false; 289 return false;
291 } 290 }
292 291
293 // Initialize the core emulation 292 Core::System& system{Core::System::GetInstance()};
294 System::Result system_result = System::Init(render_window, system_mode);
295 if (System::Result::Success != system_result) {
296 switch (system_result) {
297 case System::Result::ErrorInitVideoCore:
298 QMessageBox::critical(this, tr("Error while starting Citra!"),
299 tr("Failed to initialize the video core!\n\n"
300 "Please ensure that your GPU supports OpenGL 3.3 and that you "
301 "have the latest graphics driver."));
302 break;
303
304 default:
305 QMessageBox::critical(this, tr("Error while starting Citra!"),
306 tr("Unknown error (please check the log)!"));
307 break;
308 }
309 return false;
310 }
311 return true;
312}
313
314bool GMainWindow::LoadROM(const std::string& filename) {
315 std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetLoader(filename);
316 if (!app_loader) {
317 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str());
318 QMessageBox::critical(this, tr("Error while loading ROM!"),
319 tr("The ROM format is not supported."));
320 return false;
321 }
322 293
323 boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode(); 294 const Core::System::ResultStatus result{system.Load(render_window, filename)};
324 if (!system_mode) {
325 LOG_CRITICAL(Frontend, "Failed to load ROM!");
326 QMessageBox::critical(this, tr("Error while loading ROM!"),
327 tr("Could not determine the system mode."));
328 return false;
329 }
330 295
331 if (!InitializeSystem(system_mode.get())) 296 if (result != Core::System::ResultStatus::Success) {
332 return false; 297 switch (result) {
298 case Core::System::ResultStatus::ErrorGetLoader:
299 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str());
300 QMessageBox::critical(this, tr("Error while loading ROM!"),
301 tr("The ROM format is not supported."));
302 break;
333 303
334 Loader::ResultStatus result = app_loader->Load(); 304 case Core::System::ResultStatus::ErrorSystemMode:
335 if (Loader::ResultStatus::Success != result) { 305 LOG_CRITICAL(Frontend, "Failed to load ROM!");
336 System::Shutdown(); 306 QMessageBox::critical(this, tr("Error while loading ROM!"),
337 LOG_CRITICAL(Frontend, "Failed to load ROM!"); 307 tr("Could not determine the system mode."));
308 break;
338 309
339 switch (result) { 310 case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted: {
340 case Loader::ResultStatus::ErrorEncrypted: {
341 // Build the MessageBox ourselves to have clickable link 311 // Build the MessageBox ourselves to have clickable link
342 QMessageBox popup_error; 312 QMessageBox popup_error;
343 popup_error.setTextFormat(Qt::RichText); 313 popup_error.setTextFormat(Qt::RichText);
@@ -352,11 +322,10 @@ bool GMainWindow::LoadROM(const std::string& filename) {
352 popup_error.exec(); 322 popup_error.exec();
353 break; 323 break;
354 } 324 }
355 case Loader::ResultStatus::ErrorInvalidFormat: 325 case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
356 QMessageBox::critical(this, tr("Error while loading ROM!"), 326 QMessageBox::critical(this, tr("Error while loading ROM!"),
357 tr("The ROM format is not supported.")); 327 tr("The ROM format is not supported."));
358 break; 328 break;
359 case Loader::ResultStatus::Error:
360 329
361 default: 330 default:
362 QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); 331 QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!"));