diff options
Diffstat (limited to 'src/citra_qt/main.cpp')
| -rw-r--r-- | src/citra_qt/main.cpp | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index d5554d917..b12e6a02b 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | #include <thread> | ||
| 2 | |||
| 1 | #include <QtGui> | 3 | #include <QtGui> |
| 2 | #include <QDesktopWidget> | 4 | #include <QDesktopWidget> |
| 3 | #include <QFileDialog> | 5 | #include <QFileDialog> |
| @@ -5,8 +7,13 @@ | |||
| 5 | #include "main.hxx" | 7 | #include "main.hxx" |
| 6 | 8 | ||
| 7 | #include "common/common.h" | 9 | #include "common/common.h" |
| 10 | #include "common/logging/text_formatter.h" | ||
| 11 | #include "common/logging/log.h" | ||
| 12 | #include "common/logging/backend.h" | ||
| 13 | #include "common/logging/filter.h" | ||
| 8 | #include "common/platform.h" | 14 | #include "common/platform.h" |
| 9 | #include "common/log_manager.h" | 15 | #include "common/scope_exit.h" |
| 16 | |||
| 10 | #if EMU_PLATFORM == PLATFORM_LINUX | 17 | #if EMU_PLATFORM == PLATFORM_LINUX |
| 11 | #include <unistd.h> | 18 | #include <unistd.h> |
| 12 | #endif | 19 | #endif |
| @@ -20,7 +27,9 @@ | |||
| 20 | #include "debugger/callstack.hxx" | 27 | #include "debugger/callstack.hxx" |
| 21 | #include "debugger/ramview.hxx" | 28 | #include "debugger/ramview.hxx" |
| 22 | #include "debugger/graphics.hxx" | 29 | #include "debugger/graphics.hxx" |
| 30 | #include "debugger/graphics_breakpoints.hxx" | ||
| 23 | #include "debugger/graphics_cmdlists.hxx" | 31 | #include "debugger/graphics_cmdlists.hxx" |
| 32 | #include "debugger/graphics_framebuffer.hxx" | ||
| 24 | 33 | ||
| 25 | #include "core/settings.h" | 34 | #include "core/settings.h" |
| 26 | #include "core/system.h" | 35 | #include "core/system.h" |
| @@ -31,16 +40,12 @@ | |||
| 31 | 40 | ||
| 32 | #include "version.h" | 41 | #include "version.h" |
| 33 | 42 | ||
| 34 | |||
| 35 | GMainWindow::GMainWindow() | 43 | GMainWindow::GMainWindow() |
| 36 | { | 44 | { |
| 37 | LogManager::Init(); | 45 | Pica::g_debug_context = Pica::DebugContext::Construct(); |
| 38 | 46 | ||
| 39 | Config config; | 47 | Config config; |
| 40 | 48 | ||
| 41 | if (!Settings::values.enable_log) | ||
| 42 | LogManager::Shutdown(); | ||
| 43 | |||
| 44 | ui.setupUi(this); | 49 | ui.setupUi(this); |
| 45 | statusBar()->hide(); | 50 | statusBar()->hide(); |
| 46 | 51 | ||
| @@ -67,12 +72,22 @@ GMainWindow::GMainWindow() | |||
| 67 | addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget); | 72 | addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget); |
| 68 | graphicsCommandsWidget->hide(); | 73 | graphicsCommandsWidget->hide(); |
| 69 | 74 | ||
| 75 | auto graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(Pica::g_debug_context, this); | ||
| 76 | addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget); | ||
| 77 | graphicsBreakpointsWidget->hide(); | ||
| 78 | |||
| 79 | auto graphicsFramebufferWidget = new GraphicsFramebufferWidget(Pica::g_debug_context, this); | ||
| 80 | addDockWidget(Qt::RightDockWidgetArea, graphicsFramebufferWidget); | ||
| 81 | graphicsFramebufferWidget->hide(); | ||
| 82 | |||
| 70 | QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging")); | 83 | QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging")); |
| 71 | debug_menu->addAction(disasmWidget->toggleViewAction()); | 84 | debug_menu->addAction(disasmWidget->toggleViewAction()); |
| 72 | debug_menu->addAction(registersWidget->toggleViewAction()); | 85 | debug_menu->addAction(registersWidget->toggleViewAction()); |
| 73 | debug_menu->addAction(callstackWidget->toggleViewAction()); | 86 | debug_menu->addAction(callstackWidget->toggleViewAction()); |
| 74 | debug_menu->addAction(graphicsWidget->toggleViewAction()); | 87 | debug_menu->addAction(graphicsWidget->toggleViewAction()); |
| 75 | debug_menu->addAction(graphicsCommandsWidget->toggleViewAction()); | 88 | debug_menu->addAction(graphicsCommandsWidget->toggleViewAction()); |
| 89 | debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction()); | ||
| 90 | debug_menu->addAction(graphicsFramebufferWidget->toggleViewAction()); | ||
| 76 | 91 | ||
| 77 | // Set default UI state | 92 | // Set default UI state |
| 78 | // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half | 93 | // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half |
| @@ -131,24 +146,20 @@ GMainWindow::GMainWindow() | |||
| 131 | GMainWindow::~GMainWindow() | 146 | GMainWindow::~GMainWindow() |
| 132 | { | 147 | { |
| 133 | // will get automatically deleted otherwise | 148 | // will get automatically deleted otherwise |
| 134 | if (render_window->parent() == NULL) | 149 | if (render_window->parent() == nullptr) |
| 135 | delete render_window; | 150 | delete render_window; |
| 151 | |||
| 152 | Pica::g_debug_context.reset(); | ||
| 136 | } | 153 | } |
| 137 | 154 | ||
| 138 | void GMainWindow::BootGame(std::string filename) | 155 | void GMainWindow::BootGame(std::string filename) |
| 139 | { | 156 | { |
| 140 | NOTICE_LOG(MASTER_LOG, "Citra starting...\n"); | 157 | LOG_INFO(Frontend, "Citra starting...\n"); |
| 141 | System::Init(render_window); | 158 | System::Init(render_window); |
| 142 | 159 | ||
| 143 | if (Core::Init()) { | ||
| 144 | ERROR_LOG(MASTER_LOG, "Core initialization failed, exiting..."); | ||
| 145 | Core::Stop(); | ||
| 146 | exit(1); | ||
| 147 | } | ||
| 148 | |||
| 149 | // Load a game or die... | 160 | // Load a game or die... |
| 150 | if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) { | 161 | if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) { |
| 151 | ERROR_LOG(BOOT, "Failed to load ROM!"); | 162 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); |
| 152 | } | 163 | } |
| 153 | 164 | ||
| 154 | disasmWidget->Init(); | 165 | disasmWidget->Init(); |
| @@ -164,7 +175,7 @@ void GMainWindow::BootGame(std::string filename) | |||
| 164 | 175 | ||
| 165 | void GMainWindow::OnMenuLoadFile() | 176 | void GMainWindow::OnMenuLoadFile() |
| 166 | { | 177 | { |
| 167 | QString filename = QFileDialog::getOpenFileName(this, tr("Load file"), QString(), tr("3DS executable (*.elf *.axf *.bin *.cci *.cxi)")); | 178 | QString filename = QFileDialog::getOpenFileName(this, tr("Load file"), QString(), tr("3DS executable (*.3dsx *.elf *.axf *.bin *.cci *.cxi)")); |
| 168 | if (filename.size()) | 179 | if (filename.size()) |
| 169 | BootGame(filename.toLatin1().data()); | 180 | BootGame(filename.toLatin1().data()); |
| 170 | } | 181 | } |
| @@ -213,18 +224,21 @@ void GMainWindow::OnOpenHotkeysDialog() | |||
| 213 | void GMainWindow::ToggleWindowMode() | 224 | void GMainWindow::ToggleWindowMode() |
| 214 | { | 225 | { |
| 215 | bool enable = ui.action_Popout_Window_Mode->isChecked(); | 226 | bool enable = ui.action_Popout_Window_Mode->isChecked(); |
| 216 | if (enable && render_window->parent() != NULL) | 227 | if (enable && render_window->parent() != nullptr) |
| 217 | { | 228 | { |
| 218 | ui.horizontalLayout->removeWidget(render_window); | 229 | ui.horizontalLayout->removeWidget(render_window); |
| 219 | render_window->setParent(NULL); | 230 | render_window->setParent(nullptr); |
| 220 | render_window->setVisible(true); | 231 | render_window->setVisible(true); |
| 221 | render_window->RestoreGeometry(); | 232 | render_window->RestoreGeometry(); |
| 233 | render_window->setFocusPolicy(Qt::NoFocus); | ||
| 222 | } | 234 | } |
| 223 | else if (!enable && render_window->parent() == NULL) | 235 | else if (!enable && render_window->parent() == nullptr) |
| 224 | { | 236 | { |
| 225 | render_window->BackupGeometry(); | 237 | render_window->BackupGeometry(); |
| 226 | ui.horizontalLayout->addWidget(render_window); | 238 | ui.horizontalLayout->addWidget(render_window); |
| 227 | render_window->setVisible(true); | 239 | render_window->setVisible(true); |
| 240 | render_window->setFocusPolicy(Qt::ClickFocus); | ||
| 241 | render_window->setFocus(); | ||
| 228 | } | 242 | } |
| 229 | } | 243 | } |
| 230 | 244 | ||
| @@ -255,9 +269,21 @@ void GMainWindow::closeEvent(QCloseEvent* event) | |||
| 255 | 269 | ||
| 256 | int __cdecl main(int argc, char* argv[]) | 270 | int __cdecl main(int argc, char* argv[]) |
| 257 | { | 271 | { |
| 272 | std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger(); | ||
| 273 | Log::Filter log_filter(Log::Level::Info); | ||
| 274 | std::thread logging_thread(Log::TextLoggingLoop, logger, &log_filter); | ||
| 275 | SCOPE_EXIT({ | ||
| 276 | logger->Close(); | ||
| 277 | logging_thread.join(); | ||
| 278 | }); | ||
| 279 | |||
| 258 | QApplication::setAttribute(Qt::AA_X11InitThreads); | 280 | QApplication::setAttribute(Qt::AA_X11InitThreads); |
| 259 | QApplication app(argc, argv); | 281 | QApplication app(argc, argv); |
| 282 | |||
| 260 | GMainWindow main_window; | 283 | GMainWindow main_window; |
| 284 | // After settings have been loaded by GMainWindow, apply the filter | ||
| 285 | log_filter.ParseFilterString(Settings::values.log_filter); | ||
| 286 | |||
| 261 | main_window.show(); | 287 | main_window.show(); |
| 262 | return app.exec(); | 288 | return app.exec(); |
| 263 | } | 289 | } |