main.cpp 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <cinttypes>
  5. #include <clocale>
  6. #include <memory>
  7. #include <thread>
  8. #include <fmt/ostream.h>
  9. #include <glad/glad.h>
  10. #define QT_NO_OPENGL
  11. #include <QDesktopWidget>
  12. #include <QFileDialog>
  13. #include <QMessageBox>
  14. #include <QtGui>
  15. #include <QtWidgets>
  16. #include "common/common_paths.h"
  17. #include "common/logging/backend.h"
  18. #include "common/logging/filter.h"
  19. #include "common/logging/log.h"
  20. #include "common/logging/text_formatter.h"
  21. #include "common/microprofile.h"
  22. #include "common/scm_rev.h"
  23. #include "common/scope_exit.h"
  24. #include "common/string_util.h"
  25. #include "core/core.h"
  26. #include "core/crypto/key_manager.h"
  27. #include "core/file_sys/bis_factory.h"
  28. #include "core/file_sys/card_image.h"
  29. #include "core/file_sys/registered_cache.h"
  30. #include "core/file_sys/vfs_real.h"
  31. #include "core/gdbstub/gdbstub.h"
  32. #include "core/loader/loader.h"
  33. #include "core/settings.h"
  34. #include "video_core/debug_utils/debug_utils.h"
  35. #include "yuzu/about_dialog.h"
  36. #include "yuzu/bootmanager.h"
  37. #include "yuzu/configuration/config.h"
  38. #include "yuzu/configuration/configure_dialog.h"
  39. #include "yuzu/debugger/console.h"
  40. #include "yuzu/debugger/graphics/graphics_breakpoints.h"
  41. #include "yuzu/debugger/graphics/graphics_surface.h"
  42. #include "yuzu/debugger/profiler.h"
  43. #include "yuzu/debugger/wait_tree.h"
  44. #include "yuzu/game_list.h"
  45. #include "yuzu/hotkeys.h"
  46. #include "yuzu/main.h"
  47. #include "yuzu/ui_settings.h"
  48. #ifdef QT_STATICPLUGIN
  49. Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
  50. #endif
  51. #ifdef _WIN32
  52. extern "C" {
  53. // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable
  54. // graphics
  55. __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
  56. __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
  57. }
  58. #endif
  59. /**
  60. * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
  61. * is a bitfield "callout_flags" options, used to track if a message has already been shown to the
  62. * user. This is 32-bits - if we have more than 32 callouts, we should retire and recyle old ones.
  63. */
  64. enum class CalloutFlag : uint32_t {
  65. Telemetry = 0x1,
  66. };
  67. static void ShowCalloutMessage(const QString& message, CalloutFlag flag) {
  68. if (UISettings::values.callout_flags & static_cast<uint32_t>(flag)) {
  69. return;
  70. }
  71. UISettings::values.callout_flags |= static_cast<uint32_t>(flag);
  72. QMessageBox msg;
  73. msg.setText(message);
  74. msg.setStandardButtons(QMessageBox::Ok);
  75. msg.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  76. msg.setStyleSheet("QLabel{min-width: 900px;}");
  77. msg.exec();
  78. }
  79. void GMainWindow::ShowCallouts() {}
  80. const int GMainWindow::max_recent_files_item;
  81. GMainWindow::GMainWindow()
  82. : config(new Config()), emu_thread(nullptr),
  83. vfs(std::make_shared<FileSys::RealVfsFilesystem>()) {
  84. debug_context = Tegra::DebugContext::Construct();
  85. setAcceptDrops(true);
  86. ui.setupUi(this);
  87. statusBar()->hide();
  88. default_theme_paths = QIcon::themeSearchPaths();
  89. UpdateUITheme();
  90. InitializeWidgets();
  91. InitializeDebugWidgets();
  92. InitializeRecentFileMenuActions();
  93. InitializeHotkeys();
  94. SetDefaultUIGeometry();
  95. RestoreUIState();
  96. ConnectMenuEvents();
  97. ConnectWidgetEvents();
  98. LOG_INFO(Frontend, "yuzu Version: {} | {}-{}", Common::g_build_name, Common::g_scm_branch,
  99. Common::g_scm_desc);
  100. setWindowTitle(QString("yuzu %1| %2-%3")
  101. .arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
  102. show();
  103. // Necessary to load titles from nand in gamelist.
  104. Service::FileSystem::RegisterBIS(std::make_unique<FileSys::BISFactory>(vfs->OpenDirectory(
  105. FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), FileSys::Mode::ReadWrite)));
  106. game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
  107. // Show one-time "callout" messages to the user
  108. ShowCallouts();
  109. QStringList args = QApplication::arguments();
  110. if (args.length() >= 2) {
  111. BootGame(args[1]);
  112. }
  113. }
  114. GMainWindow::~GMainWindow() {
  115. // will get automatically deleted otherwise
  116. if (render_window->parent() == nullptr)
  117. delete render_window;
  118. }
  119. void GMainWindow::InitializeWidgets() {
  120. render_window = new GRenderWindow(this, emu_thread.get());
  121. render_window->hide();
  122. game_list = new GameList(vfs, this);
  123. ui.horizontalLayout->addWidget(game_list);
  124. // Create status bar
  125. message_label = new QLabel();
  126. // Configured separately for left alignment
  127. message_label->setVisible(false);
  128. message_label->setFrameStyle(QFrame::NoFrame);
  129. message_label->setContentsMargins(4, 0, 4, 0);
  130. message_label->setAlignment(Qt::AlignLeft);
  131. statusBar()->addPermanentWidget(message_label, 1);
  132. emu_speed_label = new QLabel();
  133. emu_speed_label->setToolTip(
  134. tr("Current emulation speed. Values higher or lower than 100% "
  135. "indicate emulation is running faster or slower than a Switch."));
  136. game_fps_label = new QLabel();
  137. game_fps_label->setToolTip(tr("How many frames per second the game is currently displaying. "
  138. "This will vary from game to game and scene to scene."));
  139. emu_frametime_label = new QLabel();
  140. emu_frametime_label->setToolTip(
  141. tr("Time taken to emulate a Switch frame, not counting framelimiting or v-sync. For "
  142. "full-speed emulation this should be at most 16.67 ms."));
  143. for (auto& label : {emu_speed_label, game_fps_label, emu_frametime_label}) {
  144. label->setVisible(false);
  145. label->setFrameStyle(QFrame::NoFrame);
  146. label->setContentsMargins(4, 0, 4, 0);
  147. statusBar()->addPermanentWidget(label, 0);
  148. }
  149. statusBar()->setVisible(true);
  150. setStyleSheet("QStatusBar::item{border: none;}");
  151. }
  152. void GMainWindow::InitializeDebugWidgets() {
  153. QMenu* debug_menu = ui.menu_View_Debugging;
  154. #if MICROPROFILE_ENABLED
  155. microProfileDialog = new MicroProfileDialog(this);
  156. microProfileDialog->hide();
  157. debug_menu->addAction(microProfileDialog->toggleViewAction());
  158. #endif
  159. graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(debug_context, this);
  160. addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget);
  161. graphicsBreakpointsWidget->hide();
  162. debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction());
  163. graphicsSurfaceWidget = new GraphicsSurfaceWidget(debug_context, this);
  164. addDockWidget(Qt::RightDockWidgetArea, graphicsSurfaceWidget);
  165. graphicsSurfaceWidget->hide();
  166. debug_menu->addAction(graphicsSurfaceWidget->toggleViewAction());
  167. waitTreeWidget = new WaitTreeWidget(this);
  168. addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget);
  169. waitTreeWidget->hide();
  170. debug_menu->addAction(waitTreeWidget->toggleViewAction());
  171. connect(this, &GMainWindow::EmulationStarting, waitTreeWidget,
  172. &WaitTreeWidget::OnEmulationStarting);
  173. connect(this, &GMainWindow::EmulationStopping, waitTreeWidget,
  174. &WaitTreeWidget::OnEmulationStopping);
  175. }
  176. void GMainWindow::InitializeRecentFileMenuActions() {
  177. for (int i = 0; i < max_recent_files_item; ++i) {
  178. actions_recent_files[i] = new QAction(this);
  179. actions_recent_files[i]->setVisible(false);
  180. connect(actions_recent_files[i], &QAction::triggered, this, &GMainWindow::OnMenuRecentFile);
  181. ui.menu_recent_files->addAction(actions_recent_files[i]);
  182. }
  183. UpdateRecentFiles();
  184. }
  185. void GMainWindow::InitializeHotkeys() {
  186. hotkey_registry.RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
  187. hotkey_registry.RegisterHotkey("Main Window", "Start Emulation");
  188. hotkey_registry.RegisterHotkey("Main Window", "Continue/Pause", QKeySequence(Qt::Key_F4));
  189. hotkey_registry.RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
  190. hotkey_registry.RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence(Qt::Key_Escape),
  191. Qt::ApplicationShortcut);
  192. hotkey_registry.RegisterHotkey("Main Window", "Toggle Speed Limit", QKeySequence("CTRL+Z"),
  193. Qt::ApplicationShortcut);
  194. hotkey_registry.LoadHotkeys();
  195. connect(hotkey_registry.GetHotkey("Main Window", "Load File", this), &QShortcut::activated,
  196. this, &GMainWindow::OnMenuLoadFile);
  197. connect(hotkey_registry.GetHotkey("Main Window", "Start Emulation", this),
  198. &QShortcut::activated, this, &GMainWindow::OnStartGame);
  199. connect(hotkey_registry.GetHotkey("Main Window", "Continue/Pause", this), &QShortcut::activated,
  200. this, [&] {
  201. if (emulation_running) {
  202. if (emu_thread->IsRunning()) {
  203. OnPauseGame();
  204. } else {
  205. OnStartGame();
  206. }
  207. }
  208. });
  209. connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window),
  210. &QShortcut::activated, ui.action_Fullscreen, &QAction::trigger);
  211. connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window),
  212. &QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger);
  213. connect(hotkey_registry.GetHotkey("Main Window", "Exit Fullscreen", this),
  214. &QShortcut::activated, this, [&] {
  215. if (emulation_running) {
  216. ui.action_Fullscreen->setChecked(false);
  217. ToggleFullscreen();
  218. }
  219. });
  220. connect(hotkey_registry.GetHotkey("Main Window", "Toggle Speed Limit", this),
  221. &QShortcut::activated, this, [&] {
  222. Settings::values.toggle_framelimit = !Settings::values.toggle_framelimit;
  223. UpdateStatusBar();
  224. });
  225. }
  226. void GMainWindow::SetDefaultUIGeometry() {
  227. // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
  228. const QRect screenRect = QApplication::desktop()->screenGeometry(this);
  229. const int w = screenRect.width() * 2 / 3;
  230. const int h = screenRect.height() / 2;
  231. const int x = (screenRect.x() + screenRect.width()) / 2 - w / 2;
  232. const int y = (screenRect.y() + screenRect.height()) / 2 - h * 55 / 100;
  233. setGeometry(x, y, w, h);
  234. }
  235. void GMainWindow::RestoreUIState() {
  236. restoreGeometry(UISettings::values.geometry);
  237. restoreState(UISettings::values.state);
  238. render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
  239. #if MICROPROFILE_ENABLED
  240. microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry);
  241. microProfileDialog->setVisible(UISettings::values.microprofile_visible);
  242. #endif
  243. game_list->LoadInterfaceLayout();
  244. ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
  245. ToggleWindowMode();
  246. ui.action_Fullscreen->setChecked(UISettings::values.fullscreen);
  247. ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar);
  248. OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
  249. ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar);
  250. game_list->setFilterVisible(ui.action_Show_Filter_Bar->isChecked());
  251. ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar);
  252. statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
  253. Debugger::ToggleConsole();
  254. }
  255. void GMainWindow::ConnectWidgetEvents() {
  256. connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
  257. connect(game_list, &GameList::OpenSaveFolderRequested, this,
  258. &GMainWindow::OnGameListOpenSaveFolder);
  259. connect(this, &GMainWindow::EmulationStarting, render_window,
  260. &GRenderWindow::OnEmulationStarting);
  261. connect(this, &GMainWindow::EmulationStopping, render_window,
  262. &GRenderWindow::OnEmulationStopping);
  263. connect(&status_bar_update_timer, &QTimer::timeout, this, &GMainWindow::UpdateStatusBar);
  264. }
  265. void GMainWindow::ConnectMenuEvents() {
  266. // File
  267. connect(ui.action_Load_File, &QAction::triggered, this, &GMainWindow::OnMenuLoadFile);
  268. connect(ui.action_Load_Folder, &QAction::triggered, this, &GMainWindow::OnMenuLoadFolder);
  269. connect(ui.action_Install_File_NAND, &QAction::triggered, this,
  270. &GMainWindow::OnMenuInstallToNAND);
  271. connect(ui.action_Select_Game_List_Root, &QAction::triggered, this,
  272. &GMainWindow::OnMenuSelectGameListRoot);
  273. connect(ui.action_Exit, &QAction::triggered, this, &QMainWindow::close);
  274. // Emulation
  275. connect(ui.action_Start, &QAction::triggered, this, &GMainWindow::OnStartGame);
  276. connect(ui.action_Pause, &QAction::triggered, this, &GMainWindow::OnPauseGame);
  277. connect(ui.action_Stop, &QAction::triggered, this, &GMainWindow::OnStopGame);
  278. connect(ui.action_Configure, &QAction::triggered, this, &GMainWindow::OnConfigure);
  279. // View
  280. connect(ui.action_Single_Window_Mode, &QAction::triggered, this,
  281. &GMainWindow::ToggleWindowMode);
  282. connect(ui.action_Display_Dock_Widget_Headers, &QAction::triggered, this,
  283. &GMainWindow::OnDisplayTitleBars);
  284. ui.action_Show_Filter_Bar->setShortcut(tr("CTRL+F"));
  285. connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar);
  286. connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible);
  287. // Fullscreen
  288. ui.action_Fullscreen->setShortcut(
  289. hotkey_registry.GetHotkey("Main Window", "Fullscreen", this)->key());
  290. connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
  291. // Help
  292. connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout);
  293. }
  294. void GMainWindow::OnDisplayTitleBars(bool show) {
  295. QList<QDockWidget*> widgets = findChildren<QDockWidget*>();
  296. if (show) {
  297. for (QDockWidget* widget : widgets) {
  298. QWidget* old = widget->titleBarWidget();
  299. widget->setTitleBarWidget(nullptr);
  300. if (old != nullptr)
  301. delete old;
  302. }
  303. } else {
  304. for (QDockWidget* widget : widgets) {
  305. QWidget* old = widget->titleBarWidget();
  306. widget->setTitleBarWidget(new QWidget());
  307. if (old != nullptr)
  308. delete old;
  309. }
  310. }
  311. }
  312. bool GMainWindow::SupportsRequiredGLExtensions() {
  313. QStringList unsupported_ext;
  314. if (!GLAD_GL_ARB_program_interface_query)
  315. unsupported_ext.append("ARB_program_interface_query");
  316. if (!GLAD_GL_ARB_separate_shader_objects)
  317. unsupported_ext.append("ARB_separate_shader_objects");
  318. if (!GLAD_GL_ARB_vertex_attrib_binding)
  319. unsupported_ext.append("ARB_vertex_attrib_binding");
  320. if (!GLAD_GL_ARB_vertex_type_10f_11f_11f_rev)
  321. unsupported_ext.append("ARB_vertex_type_10f_11f_11f_rev");
  322. if (!GLAD_GL_ARB_texture_mirror_clamp_to_edge)
  323. unsupported_ext.append("ARB_texture_mirror_clamp_to_edge");
  324. // Extensions required to support some texture formats.
  325. if (!GLAD_GL_EXT_texture_compression_s3tc)
  326. unsupported_ext.append("EXT_texture_compression_s3tc");
  327. if (!GLAD_GL_ARB_texture_compression_rgtc)
  328. unsupported_ext.append("ARB_texture_compression_rgtc");
  329. if (!GLAD_GL_ARB_texture_compression_bptc)
  330. unsupported_ext.append("ARB_texture_compression_bptc");
  331. if (!GLAD_GL_ARB_depth_buffer_float)
  332. unsupported_ext.append("ARB_depth_buffer_float");
  333. for (const QString& ext : unsupported_ext)
  334. LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString());
  335. return unsupported_ext.empty();
  336. }
  337. bool GMainWindow::LoadROM(const QString& filename) {
  338. // Shutdown previous session if the emu thread is still active...
  339. if (emu_thread != nullptr)
  340. ShutdownGame();
  341. render_window->InitRenderTarget();
  342. render_window->MakeCurrent();
  343. if (!gladLoadGL()) {
  344. QMessageBox::critical(this, tr("Error while initializing OpenGL 3.3 Core!"),
  345. tr("Your GPU may not support OpenGL 3.3, or you do not "
  346. "have the latest graphics driver."));
  347. return false;
  348. }
  349. if (!SupportsRequiredGLExtensions()) {
  350. QMessageBox::critical(
  351. this, tr("Error while initializing OpenGL Core!"),
  352. tr("Your GPU may not support one or more required OpenGL extensions. Please "
  353. "ensure you have the latest graphics driver. See the log for more details."));
  354. return false;
  355. }
  356. Core::System& system{Core::System::GetInstance()};
  357. system.SetFilesystem(vfs);
  358. system.SetGPUDebugContext(debug_context);
  359. const Core::System::ResultStatus result{system.Load(*render_window, filename.toStdString())};
  360. render_window->DoneCurrent();
  361. if (result != Core::System::ResultStatus::Success) {
  362. switch (result) {
  363. case Core::System::ResultStatus::ErrorGetLoader:
  364. LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString());
  365. QMessageBox::critical(this, tr("Error while loading ROM!"),
  366. tr("The ROM format is not supported."));
  367. break;
  368. case Core::System::ResultStatus::ErrorSystemMode:
  369. LOG_CRITICAL(Frontend, "Failed to load ROM!");
  370. QMessageBox::critical(this, tr("Error while loading ROM!"),
  371. tr("Could not determine the system mode."));
  372. break;
  373. case Core::System::ResultStatus::ErrorVideoCore:
  374. QMessageBox::critical(
  375. this, tr("An error occurred initializing the video core."),
  376. tr("yuzu has encountered an error while running the video core, please see the "
  377. "log for more details."
  378. "For more information on accessing the log, please see the following page: "
  379. "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How "
  380. "to "
  381. "Upload the Log File</a>."
  382. "Ensure that you have the latest graphics drivers for your GPU."));
  383. break;
  384. default:
  385. if (static_cast<u32>(result) >
  386. static_cast<u32>(Core::System::ResultStatus::ErrorLoader)) {
  387. LOG_CRITICAL(Frontend, "Failed to load ROM!");
  388. const u16 loader_id = static_cast<u16>(Core::System::ResultStatus::ErrorLoader);
  389. const u16 error_id = static_cast<u16>(result) - loader_id;
  390. QMessageBox::critical(
  391. this, tr("Error while loading ROM!"),
  392. QString::fromStdString(fmt::format(
  393. "While attempting to load the ROM requested, an error occured. Please "
  394. "refer to the yuzu wiki for more information or the yuzu discord for "
  395. "additional help.\n\nError Code: {:04X}-{:04X}\nError Description: {}",
  396. loader_id, error_id, static_cast<Loader::ResultStatus>(error_id))));
  397. } else {
  398. QMessageBox::critical(
  399. this, tr("Error while loading ROM!"),
  400. tr("An unknown error occurred. Please see the log for more details."));
  401. }
  402. break;
  403. }
  404. return false;
  405. }
  406. Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt");
  407. return true;
  408. }
  409. void GMainWindow::BootGame(const QString& filename) {
  410. LOG_INFO(Frontend, "yuzu starting...");
  411. StoreRecentFile(filename); // Put the filename on top of the list
  412. if (!LoadROM(filename))
  413. return;
  414. // Create and start the emulation thread
  415. emu_thread = std::make_unique<EmuThread>(render_window);
  416. emit EmulationStarting(emu_thread.get());
  417. render_window->moveContext();
  418. emu_thread->start();
  419. connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
  420. // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
  421. // before the CPU continues
  422. connect(emu_thread.get(), &EmuThread::DebugModeEntered, waitTreeWidget,
  423. &WaitTreeWidget::OnDebugModeEntered, Qt::BlockingQueuedConnection);
  424. connect(emu_thread.get(), &EmuThread::DebugModeLeft, waitTreeWidget,
  425. &WaitTreeWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection);
  426. // Update the GUI
  427. if (ui.action_Single_Window_Mode->isChecked()) {
  428. game_list->hide();
  429. }
  430. status_bar_update_timer.start(2000);
  431. render_window->show();
  432. render_window->setFocus();
  433. emulation_running = true;
  434. if (ui.action_Fullscreen->isChecked()) {
  435. ShowFullscreen();
  436. }
  437. OnStartGame();
  438. }
  439. void GMainWindow::ShutdownGame() {
  440. emu_thread->RequestStop();
  441. emit EmulationStopping();
  442. // Wait for emulation thread to complete and delete it
  443. emu_thread->wait();
  444. emu_thread = nullptr;
  445. // The emulation is stopped, so closing the window or not does not matter anymore
  446. disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
  447. // Update the GUI
  448. ui.action_Start->setEnabled(false);
  449. ui.action_Start->setText(tr("Start"));
  450. ui.action_Pause->setEnabled(false);
  451. ui.action_Stop->setEnabled(false);
  452. render_window->hide();
  453. game_list->show();
  454. game_list->setFilterFocus();
  455. // Disable status bar updates
  456. status_bar_update_timer.stop();
  457. message_label->setVisible(false);
  458. emu_speed_label->setVisible(false);
  459. game_fps_label->setVisible(false);
  460. emu_frametime_label->setVisible(false);
  461. emulation_running = false;
  462. }
  463. void GMainWindow::StoreRecentFile(const QString& filename) {
  464. UISettings::values.recent_files.prepend(filename);
  465. UISettings::values.recent_files.removeDuplicates();
  466. while (UISettings::values.recent_files.size() > max_recent_files_item) {
  467. UISettings::values.recent_files.removeLast();
  468. }
  469. UpdateRecentFiles();
  470. }
  471. void GMainWindow::UpdateRecentFiles() {
  472. const int num_recent_files =
  473. std::min(UISettings::values.recent_files.size(), max_recent_files_item);
  474. for (int i = 0; i < num_recent_files; i++) {
  475. const QString text = QString("&%1. %2").arg(i + 1).arg(
  476. QFileInfo(UISettings::values.recent_files[i]).fileName());
  477. actions_recent_files[i]->setText(text);
  478. actions_recent_files[i]->setData(UISettings::values.recent_files[i]);
  479. actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]);
  480. actions_recent_files[i]->setVisible(true);
  481. }
  482. for (int j = num_recent_files; j < max_recent_files_item; ++j) {
  483. actions_recent_files[j]->setVisible(false);
  484. }
  485. // Enable the recent files menu if the list isn't empty
  486. ui.menu_recent_files->setEnabled(num_recent_files != 0);
  487. }
  488. void GMainWindow::OnGameListLoadFile(QString game_path) {
  489. BootGame(game_path);
  490. }
  491. void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) {
  492. UNIMPLEMENTED();
  493. }
  494. void GMainWindow::OnMenuLoadFile() {
  495. QString extensions;
  496. for (const auto& piece : game_list->supported_file_extensions)
  497. extensions += "*." + piece + " ";
  498. extensions += "main ";
  499. QString file_filter = tr("Switch Executable") + " (" + extensions + ")";
  500. file_filter += ";;" + tr("All Files (*.*)");
  501. QString filename = QFileDialog::getOpenFileName(this, tr("Load File"),
  502. UISettings::values.roms_path, file_filter);
  503. if (!filename.isEmpty()) {
  504. UISettings::values.roms_path = QFileInfo(filename).path();
  505. BootGame(filename);
  506. }
  507. }
  508. void GMainWindow::OnMenuLoadFolder() {
  509. const QString dir_path =
  510. QFileDialog::getExistingDirectory(this, tr("Open Extracted ROM Directory"));
  511. if (dir_path.isNull()) {
  512. return;
  513. }
  514. const QDir dir{dir_path};
  515. const QStringList matching_main = dir.entryList(QStringList("main"), QDir::Files);
  516. if (matching_main.size() == 1) {
  517. BootGame(dir.path() + DIR_SEP + matching_main[0]);
  518. } else {
  519. QMessageBox::warning(this, tr("Invalid Directory Selected"),
  520. tr("The directory you have selected does not contain a 'main' file."));
  521. }
  522. }
  523. void GMainWindow::OnMenuInstallToNAND() {
  524. const QString file_filter =
  525. tr("Installable Switch File (*.nca *.xci);;Nintendo Content Archive (*.nca);;NX Cartridge "
  526. "Image (*.xci)");
  527. QString filename = QFileDialog::getOpenFileName(this, tr("Install File"),
  528. UISettings::values.roms_path, file_filter);
  529. if (filename.isEmpty()) {
  530. return;
  531. }
  532. const auto qt_raw_copy = [this](FileSys::VirtualFile src, FileSys::VirtualFile dest) {
  533. if (src == nullptr || dest == nullptr)
  534. return false;
  535. if (!dest->Resize(src->GetSize()))
  536. return false;
  537. std::array<u8, 0x1000> buffer{};
  538. const int progress_maximum = static_cast<int>(src->GetSize() / buffer.size());
  539. QProgressDialog progress(
  540. tr("Installing file \"%1\"...").arg(QString::fromStdString(src->GetName())),
  541. tr("Cancel"), 0, progress_maximum, this);
  542. progress.setWindowModality(Qt::WindowModal);
  543. for (size_t i = 0; i < src->GetSize(); i += buffer.size()) {
  544. if (progress.wasCanceled()) {
  545. dest->Resize(0);
  546. return false;
  547. }
  548. const int progress_value = static_cast<int>(i / buffer.size());
  549. progress.setValue(progress_value);
  550. const auto read = src->Read(buffer.data(), buffer.size(), i);
  551. dest->Write(buffer.data(), read, i);
  552. }
  553. return true;
  554. };
  555. const auto success = [this]() {
  556. QMessageBox::information(this, tr("Successfully Installed"),
  557. tr("The file was successfully installed."));
  558. game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
  559. };
  560. const auto failed = [this]() {
  561. QMessageBox::warning(
  562. this, tr("Failed to Install"),
  563. tr("There was an error while attempting to install the provided file. It "
  564. "could have an incorrect format or be missing metadata. Please "
  565. "double-check your file and try again."));
  566. };
  567. const auto overwrite = [this]() {
  568. return QMessageBox::question(this, tr("Failed to Install"),
  569. tr("The file you are attempting to install already exists "
  570. "in the cache. Would you like to overwrite it?")) ==
  571. QMessageBox::Yes;
  572. };
  573. if (filename.endsWith("xci", Qt::CaseInsensitive)) {
  574. const auto xci = std::make_shared<FileSys::XCI>(
  575. vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read));
  576. if (xci->GetStatus() != Loader::ResultStatus::Success) {
  577. failed();
  578. return;
  579. }
  580. const auto res =
  581. Service::FileSystem::GetUserNANDContents()->InstallEntry(xci, false, qt_raw_copy);
  582. if (res == FileSys::InstallResult::Success) {
  583. success();
  584. } else {
  585. if (res == FileSys::InstallResult::ErrorAlreadyExists) {
  586. if (overwrite()) {
  587. const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry(
  588. xci, true, qt_raw_copy);
  589. if (res2 == FileSys::InstallResult::Success) {
  590. success();
  591. } else {
  592. failed();
  593. }
  594. }
  595. } else {
  596. failed();
  597. }
  598. }
  599. } else {
  600. const auto nca = std::make_shared<FileSys::NCA>(
  601. vfs->OpenFile(filename.toStdString(), FileSys::Mode::Read));
  602. if (nca->GetStatus() != Loader::ResultStatus::Success) {
  603. failed();
  604. return;
  605. }
  606. const QStringList tt_options{tr("System Application"),
  607. tr("System Archive"),
  608. tr("System Application Update"),
  609. tr("Firmware Package (Type A)"),
  610. tr("Firmware Package (Type B)"),
  611. tr("Game"),
  612. tr("Game Update"),
  613. tr("Game DLC"),
  614. tr("Delta Title")};
  615. bool ok;
  616. const auto item = QInputDialog::getItem(
  617. this, tr("Select NCA Install Type..."),
  618. tr("Please select the type of title you would like to install this NCA as:\n(In "
  619. "most instances, the default 'Game' is fine.)"),
  620. tt_options, 5, false, &ok);
  621. auto index = tt_options.indexOf(item);
  622. if (!ok || index == -1) {
  623. QMessageBox::warning(this, tr("Failed to Install"),
  624. tr("The title type you selected for the NCA is invalid."));
  625. return;
  626. }
  627. if (index >= 5)
  628. index += 0x7B;
  629. const auto res = Service::FileSystem::GetUserNANDContents()->InstallEntry(
  630. nca, static_cast<FileSys::TitleType>(index), false, qt_raw_copy);
  631. if (res == FileSys::InstallResult::Success) {
  632. success();
  633. } else if (res == FileSys::InstallResult::ErrorAlreadyExists) {
  634. if (overwrite()) {
  635. const auto res2 = Service::FileSystem::GetUserNANDContents()->InstallEntry(
  636. nca, static_cast<FileSys::TitleType>(index), true, qt_raw_copy);
  637. if (res2 == FileSys::InstallResult::Success) {
  638. success();
  639. } else {
  640. failed();
  641. }
  642. }
  643. } else {
  644. failed();
  645. }
  646. }
  647. }
  648. void GMainWindow::OnMenuSelectGameListRoot() {
  649. QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
  650. if (!dir_path.isEmpty()) {
  651. UISettings::values.gamedir = dir_path;
  652. game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan);
  653. }
  654. }
  655. void GMainWindow::OnMenuRecentFile() {
  656. QAction* action = qobject_cast<QAction*>(sender());
  657. assert(action);
  658. const QString filename = action->data().toString();
  659. if (QFileInfo::exists(filename)) {
  660. BootGame(filename);
  661. } else {
  662. // Display an error message and remove the file from the list.
  663. QMessageBox::information(this, tr("File not found"),
  664. tr("File \"%1\" not found").arg(filename));
  665. UISettings::values.recent_files.removeOne(filename);
  666. UpdateRecentFiles();
  667. }
  668. }
  669. void GMainWindow::OnStartGame() {
  670. emu_thread->SetRunning(true);
  671. qRegisterMetaType<Core::System::ResultStatus>("Core::System::ResultStatus");
  672. qRegisterMetaType<std::string>("std::string");
  673. connect(emu_thread.get(), &EmuThread::ErrorThrown, this, &GMainWindow::OnCoreError);
  674. ui.action_Start->setEnabled(false);
  675. ui.action_Start->setText(tr("Continue"));
  676. ui.action_Pause->setEnabled(true);
  677. ui.action_Stop->setEnabled(true);
  678. }
  679. void GMainWindow::OnPauseGame() {
  680. emu_thread->SetRunning(false);
  681. ui.action_Start->setEnabled(true);
  682. ui.action_Pause->setEnabled(false);
  683. ui.action_Stop->setEnabled(true);
  684. }
  685. void GMainWindow::OnStopGame() {
  686. ShutdownGame();
  687. }
  688. void GMainWindow::ToggleFullscreen() {
  689. if (!emulation_running) {
  690. return;
  691. }
  692. if (ui.action_Fullscreen->isChecked()) {
  693. ShowFullscreen();
  694. } else {
  695. HideFullscreen();
  696. }
  697. }
  698. void GMainWindow::ShowFullscreen() {
  699. if (ui.action_Single_Window_Mode->isChecked()) {
  700. UISettings::values.geometry = saveGeometry();
  701. ui.menubar->hide();
  702. statusBar()->hide();
  703. showFullScreen();
  704. } else {
  705. UISettings::values.renderwindow_geometry = render_window->saveGeometry();
  706. render_window->showFullScreen();
  707. }
  708. }
  709. void GMainWindow::HideFullscreen() {
  710. if (ui.action_Single_Window_Mode->isChecked()) {
  711. statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
  712. ui.menubar->show();
  713. showNormal();
  714. restoreGeometry(UISettings::values.geometry);
  715. } else {
  716. render_window->showNormal();
  717. render_window->restoreGeometry(UISettings::values.renderwindow_geometry);
  718. }
  719. }
  720. void GMainWindow::ToggleWindowMode() {
  721. if (ui.action_Single_Window_Mode->isChecked()) {
  722. // Render in the main window...
  723. render_window->BackupGeometry();
  724. ui.horizontalLayout->addWidget(render_window);
  725. render_window->setFocusPolicy(Qt::ClickFocus);
  726. if (emulation_running) {
  727. render_window->setVisible(true);
  728. render_window->setFocus();
  729. game_list->hide();
  730. }
  731. } else {
  732. // Render in a separate window...
  733. ui.horizontalLayout->removeWidget(render_window);
  734. render_window->setParent(nullptr);
  735. render_window->setFocusPolicy(Qt::NoFocus);
  736. if (emulation_running) {
  737. render_window->setVisible(true);
  738. render_window->RestoreGeometry();
  739. game_list->show();
  740. }
  741. }
  742. }
  743. void GMainWindow::OnConfigure() {
  744. ConfigureDialog configureDialog(this, hotkey_registry);
  745. auto old_theme = UISettings::values.theme;
  746. auto result = configureDialog.exec();
  747. if (result == QDialog::Accepted) {
  748. configureDialog.applyConfiguration();
  749. if (UISettings::values.theme != old_theme)
  750. UpdateUITheme();
  751. game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
  752. config->Save();
  753. }
  754. }
  755. void GMainWindow::OnAbout() {
  756. AboutDialog aboutDialog(this);
  757. aboutDialog.exec();
  758. }
  759. void GMainWindow::OnToggleFilterBar() {
  760. game_list->setFilterVisible(ui.action_Show_Filter_Bar->isChecked());
  761. if (ui.action_Show_Filter_Bar->isChecked()) {
  762. game_list->setFilterFocus();
  763. } else {
  764. game_list->clearFilter();
  765. }
  766. }
  767. void GMainWindow::UpdateStatusBar() {
  768. if (emu_thread == nullptr) {
  769. status_bar_update_timer.stop();
  770. return;
  771. }
  772. auto results = Core::System::GetInstance().GetAndResetPerfStats();
  773. emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
  774. game_fps_label->setText(tr("Game: %1 FPS").arg(results.game_fps, 0, 'f', 0));
  775. emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2));
  776. emu_speed_label->setVisible(true);
  777. game_fps_label->setVisible(true);
  778. emu_frametime_label->setVisible(true);
  779. }
  780. void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
  781. QMessageBox::StandardButton answer;
  782. QString status_message;
  783. const QString common_message = tr(
  784. "The game you are trying to load requires additional files from your Switch to be dumped "
  785. "before playing.<br/><br/>For more information on dumping these files, please see the "
  786. "following wiki page: <a "
  787. "href='https://yuzu-emu.org/wiki/"
  788. "dumping-system-archives-and-the-shared-fonts-from-a-switch-console/'>Dumping System "
  789. "Archives and the Shared Fonts from a Switch Console</a>.<br/><br/>Would you like to quit "
  790. "back to the game list? Continuing emulation may result in crashes, corrupted save "
  791. "data, or other bugs.");
  792. switch (result) {
  793. case Core::System::ResultStatus::ErrorSystemFiles: {
  794. QString message = "yuzu was unable to locate a Switch system archive";
  795. if (!details.empty()) {
  796. message.append(tr(": %1. ").arg(details.c_str()));
  797. } else {
  798. message.append(". ");
  799. }
  800. message.append(common_message);
  801. answer = QMessageBox::question(this, tr("System Archive Not Found"), message,
  802. QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
  803. status_message = "System Archive Missing";
  804. break;
  805. }
  806. case Core::System::ResultStatus::ErrorSharedFont: {
  807. QString message = tr("yuzu was unable to locate the Switch shared fonts. ");
  808. message.append(common_message);
  809. answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message,
  810. QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
  811. status_message = "Shared Font Missing";
  812. break;
  813. }
  814. default:
  815. answer = QMessageBox::question(
  816. this, tr("Fatal Error"),
  817. tr("yuzu has encountered a fatal error, please see the log for more details. "
  818. "For more information on accessing the log, please see the following page: "
  819. "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>How to "
  820. "Upload the Log File</a>.<br/><br/>Would you like to quit back to the game list? "
  821. "Continuing emulation may result in crashes, corrupted save data, or other bugs."),
  822. QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
  823. status_message = "Fatal Error encountered";
  824. break;
  825. }
  826. if (answer == QMessageBox::Yes) {
  827. if (emu_thread) {
  828. ShutdownGame();
  829. }
  830. } else {
  831. // Only show the message if the game is still running.
  832. if (emu_thread) {
  833. emu_thread->SetRunning(true);
  834. message_label->setText(status_message);
  835. message_label->setVisible(true);
  836. }
  837. }
  838. }
  839. bool GMainWindow::ConfirmClose() {
  840. if (emu_thread == nullptr || !UISettings::values.confirm_before_closing)
  841. return true;
  842. QMessageBox::StandardButton answer =
  843. QMessageBox::question(this, tr("yuzu"), tr("Are you sure you want to close yuzu?"),
  844. QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
  845. return answer != QMessageBox::No;
  846. }
  847. void GMainWindow::closeEvent(QCloseEvent* event) {
  848. if (!ConfirmClose()) {
  849. event->ignore();
  850. return;
  851. }
  852. if (ui.action_Fullscreen->isChecked()) {
  853. UISettings::values.geometry = saveGeometry();
  854. UISettings::values.renderwindow_geometry = render_window->saveGeometry();
  855. }
  856. UISettings::values.state = saveState();
  857. #if MICROPROFILE_ENABLED
  858. UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry();
  859. UISettings::values.microprofile_visible = microProfileDialog->isVisible();
  860. #endif
  861. UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked();
  862. UISettings::values.fullscreen = ui.action_Fullscreen->isChecked();
  863. UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked();
  864. UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked();
  865. UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked();
  866. UISettings::values.first_start = false;
  867. game_list->SaveInterfaceLayout();
  868. hotkey_registry.SaveHotkeys();
  869. // Shutdown session if the emu thread is active...
  870. if (emu_thread != nullptr)
  871. ShutdownGame();
  872. render_window->close();
  873. QWidget::closeEvent(event);
  874. }
  875. static bool IsSingleFileDropEvent(QDropEvent* event) {
  876. const QMimeData* mimeData = event->mimeData();
  877. return mimeData->hasUrls() && mimeData->urls().length() == 1;
  878. }
  879. void GMainWindow::dropEvent(QDropEvent* event) {
  880. if (IsSingleFileDropEvent(event) && ConfirmChangeGame()) {
  881. const QMimeData* mimeData = event->mimeData();
  882. QString filename = mimeData->urls().at(0).toLocalFile();
  883. BootGame(filename);
  884. }
  885. }
  886. void GMainWindow::dragEnterEvent(QDragEnterEvent* event) {
  887. if (IsSingleFileDropEvent(event)) {
  888. event->acceptProposedAction();
  889. }
  890. }
  891. void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
  892. event->acceptProposedAction();
  893. }
  894. bool GMainWindow::ConfirmChangeGame() {
  895. if (emu_thread == nullptr)
  896. return true;
  897. auto answer = QMessageBox::question(
  898. this, tr("yuzu"),
  899. tr("Are you sure you want to stop the emulation? Any unsaved progress will be lost."),
  900. QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
  901. return answer != QMessageBox::No;
  902. }
  903. void GMainWindow::filterBarSetChecked(bool state) {
  904. ui.action_Show_Filter_Bar->setChecked(state);
  905. emit(OnToggleFilterBar());
  906. }
  907. void GMainWindow::UpdateUITheme() {
  908. QStringList theme_paths(default_theme_paths);
  909. if (UISettings::values.theme != UISettings::themes[0].second &&
  910. !UISettings::values.theme.isEmpty()) {
  911. const QString theme_uri(":" + UISettings::values.theme + "/style.qss");
  912. QFile f(theme_uri);
  913. if (f.open(QFile::ReadOnly | QFile::Text)) {
  914. QTextStream ts(&f);
  915. qApp->setStyleSheet(ts.readAll());
  916. GMainWindow::setStyleSheet(ts.readAll());
  917. } else {
  918. LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
  919. }
  920. theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme});
  921. QIcon::setThemeName(":/icons/" + UISettings::values.theme);
  922. } else {
  923. qApp->setStyleSheet("");
  924. GMainWindow::setStyleSheet("");
  925. theme_paths.append(QStringList{":/icons/default"});
  926. QIcon::setThemeName(":/icons/default");
  927. }
  928. QIcon::setThemeSearchPaths(theme_paths);
  929. emit UpdateThemedIcons();
  930. }
  931. #ifdef main
  932. #undef main
  933. #endif
  934. static void InitializeLogging() {
  935. Log::Filter log_filter;
  936. log_filter.ParseFilterString(Settings::values.log_filter);
  937. Log::SetGlobalFilter(log_filter);
  938. const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
  939. FileUtil::CreateFullPath(log_dir);
  940. Log::AddBackend(std::make_unique<Log::FileBackend>(log_dir + LOG_FILE));
  941. }
  942. int main(int argc, char* argv[]) {
  943. MicroProfileOnThreadCreate("Frontend");
  944. SCOPE_EXIT({ MicroProfileShutdown(); });
  945. // Init settings params
  946. QCoreApplication::setOrganizationName("yuzu team");
  947. QCoreApplication::setApplicationName("yuzu");
  948. QApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
  949. QApplication app(argc, argv);
  950. // Qt changes the locale and causes issues in float conversion using std::to_string() when
  951. // generating shaders
  952. setlocale(LC_ALL, "C");
  953. GMainWindow main_window;
  954. // After settings have been loaded by GMainWindow, apply the filter
  955. InitializeLogging();
  956. main_window.show();
  957. return app.exec();
  958. }