summaryrefslogtreecommitdiff
path: root/src/citra_qt/main.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-11-04 23:14:38 -0400
committerGravatar bunnei2016-12-21 23:29:04 -0500
commit198b6c9bdd58d76303f75a8577303907967a143e (patch)
tree0dba084e5c3418f917880fd4fc1efad37f127e9b /src/citra_qt/main.cpp
parentloader: Remove duplicate docstrings. (diff)
downloadyuzu-198b6c9bdd58d76303f75a8577303907967a143e.tar.gz
yuzu-198b6c9bdd58d76303f75a8577303907967a143e.tar.xz
yuzu-198b6c9bdd58d76303f75a8577303907967a143e.zip
core: Consolidate top-level system state into a singleton.
Diffstat (limited to 'src/citra_qt/main.cpp')
-rw-r--r--src/citra_qt/main.cpp81
1 files changed, 26 insertions, 55 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index e16d3196c..0c7723b0a 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -274,7 +274,7 @@ void GMainWindow::OnDisplayTitleBars(bool show) {
274 } 274 }
275} 275}
276 276
277bool GMainWindow::InitializeSystem(u32 system_mode) { 277bool GMainWindow::LoadROM(const std::string& filename) {
278 // Shutdown previous session if the emu thread is still active... 278 // Shutdown previous session if the emu thread is still active...
279 if (emu_thread != nullptr) 279 if (emu_thread != nullptr)
280 ShutdownGame(); 280 ShutdownGame();
@@ -284,79 +284,50 @@ bool GMainWindow::InitializeSystem(u32 system_mode) {
284 284
285 if (!gladLoadGL()) { 285 if (!gladLoadGL()) {
286 QMessageBox::critical(this, tr("Error while starting Citra!"), 286 QMessageBox::critical(this, tr("Error while starting Citra!"),
287 tr("Failed to initialize the video core!\n\n" 287 tr("Failed to initialize the video core!\n\n"
288 "Please ensure that your GPU supports OpenGL 3.3 and that you " 288 "Please ensure that your GPU supports OpenGL 3.3 and that you "
289 "have the latest graphics driver.")); 289 "have the latest graphics driver."));
290 return false; 290 return false;
291 } 291 }
292 292
293 // Initialize the core emulation 293 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 294
304 default: 295 const Core::System::ResultStatus result{ system.Load(render_window, filename) };
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 296
314bool GMainWindow::LoadROM(const std::string& filename) { 297 if (result != Core::System::ResultStatus::Success) {
315 std::unique_ptr<Loader::AppLoader> app_loader = Loader::GetLoader(filename); 298 switch (result) {
316 if (!app_loader) { 299 case Core::System::ResultStatus::ErrorGetLoader:
317 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str()); 300 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filename.c_str());
318 QMessageBox::critical(this, tr("Error while loading ROM!"), 301 QMessageBox::critical(this, tr("Error while loading ROM!"),
319 tr("The ROM format is not supported.")); 302 tr("The ROM format is not supported."));
320 return false; 303 break;
321 }
322
323 boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode();
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
331 if (!InitializeSystem(system_mode.get()))
332 return false;
333 304
334 Loader::ResultStatus result = app_loader->Load(); 305 case Core::System::ResultStatus::ErrorSystemMode:
335 if (Loader::ResultStatus::Success != result) { 306 LOG_CRITICAL(Frontend, "Failed to load ROM!");
336 System::Shutdown(); 307 QMessageBox::critical(this, tr("Error while loading ROM!"),
337 LOG_CRITICAL(Frontend, "Failed to load ROM!"); 308 tr("Could not determine the system mode."));
309 break;
338 310
339 switch (result) { 311 case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
340 case Loader::ResultStatus::ErrorEncrypted: { 312 {
341 // Build the MessageBox ourselves to have clickable link 313 // Build the MessageBox ourselves to have clickable link
342 QMessageBox popup_error; 314 QMessageBox popup_error;
343 popup_error.setTextFormat(Qt::RichText); 315 popup_error.setTextFormat(Qt::RichText);
344 popup_error.setWindowTitle(tr("Error while loading ROM!")); 316 popup_error.setWindowTitle(tr("Error while loading ROM!"));
345 popup_error.setText( 317 popup_error.setText(
346 tr("The game that you are trying to load must be decrypted before being used with " 318 tr("The game that you are trying to load must be decrypted before being used with "
347 "Citra.<br/><br/>" 319 "Citra.<br/><br/>"
348 "For more information on dumping and decrypting games, please see: <a " 320 "For more information on dumping and decrypting games, please see: <a "
349 "href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://" 321 "href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://"
350 "citra-emu.org/wiki/Dumping-Game-Cartridges</a>")); 322 "citra-emu.org/wiki/Dumping-Game-Cartridges</a>"));
351 popup_error.setIcon(QMessageBox::Critical); 323 popup_error.setIcon(QMessageBox::Critical);
352 popup_error.exec(); 324 popup_error.exec();
353 break; 325 break;
354 } 326 }
355 case Loader::ResultStatus::ErrorInvalidFormat: 327 case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
356 QMessageBox::critical(this, tr("Error while loading ROM!"), 328 QMessageBox::critical(this, tr("Error while loading ROM!"),
357 tr("The ROM format is not supported.")); 329 tr("The ROM format is not supported."));
358 break; 330 break;
359 case Loader::ResultStatus::Error:
360 331
361 default: 332 default:
362 QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!")); 333 QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Unknown error!"));