diff options
| -rw-r--r-- | src/citra_qt/main.cpp | 139 | ||||
| -rw-r--r-- | src/citra_qt/main.h | 28 |
2 files changed, 100 insertions, 67 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 74feec81f..4486f0870 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -60,6 +60,36 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 60 | ui.setupUi(this); | 60 | ui.setupUi(this); |
| 61 | statusBar()->hide(); | 61 | statusBar()->hide(); |
| 62 | 62 | ||
| 63 | InitializeWidgets(); | ||
| 64 | InitializeDebugMenuActions(); | ||
| 65 | InitializeRecentFileMenuActions(); | ||
| 66 | InitializeHotkeys(); | ||
| 67 | |||
| 68 | SetDefaultUIGeometry(); | ||
| 69 | RestoreUIState(); | ||
| 70 | |||
| 71 | ConnectWidgetEvents(); | ||
| 72 | |||
| 73 | setWindowTitle(QString("Citra | %1-%2").arg(Common::g_scm_branch, Common::g_scm_desc)); | ||
| 74 | show(); | ||
| 75 | |||
| 76 | game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); | ||
| 77 | |||
| 78 | QStringList args = QApplication::arguments(); | ||
| 79 | if (args.length() >= 2) { | ||
| 80 | BootGame(args[1].toStdString()); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | GMainWindow::~GMainWindow() { | ||
| 85 | // will get automatically deleted otherwise | ||
| 86 | if (render_window->parent() == nullptr) | ||
| 87 | delete render_window; | ||
| 88 | |||
| 89 | Pica::g_debug_context.reset(); | ||
| 90 | } | ||
| 91 | |||
| 92 | void GMainWindow::InitializeWidgets() { | ||
| 63 | render_window = new GRenderWindow(this, emu_thread.get()); | 93 | render_window = new GRenderWindow(this, emu_thread.get()); |
| 64 | render_window->hide(); | 94 | render_window->hide(); |
| 65 | 95 | ||
| @@ -95,25 +125,27 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 95 | addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget); | 125 | addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget); |
| 96 | graphicsCommandsWidget->hide(); | 126 | graphicsCommandsWidget->hide(); |
| 97 | 127 | ||
| 98 | auto graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(Pica::g_debug_context, this); | 128 | graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(Pica::g_debug_context, this); |
| 99 | addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget); | 129 | addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget); |
| 100 | graphicsBreakpointsWidget->hide(); | 130 | graphicsBreakpointsWidget->hide(); |
| 101 | 131 | ||
| 102 | auto graphicsVertexShaderWidget = new GraphicsVertexShaderWidget(Pica::g_debug_context, this); | 132 | graphicsVertexShaderWidget = new GraphicsVertexShaderWidget(Pica::g_debug_context, this); |
| 103 | addDockWidget(Qt::RightDockWidgetArea, graphicsVertexShaderWidget); | 133 | addDockWidget(Qt::RightDockWidgetArea, graphicsVertexShaderWidget); |
| 104 | graphicsVertexShaderWidget->hide(); | 134 | graphicsVertexShaderWidget->hide(); |
| 105 | 135 | ||
| 106 | auto graphicsTracingWidget = new GraphicsTracingWidget(Pica::g_debug_context, this); | 136 | graphicsTracingWidget = new GraphicsTracingWidget(Pica::g_debug_context, this); |
| 107 | addDockWidget(Qt::RightDockWidgetArea, graphicsTracingWidget); | 137 | addDockWidget(Qt::RightDockWidgetArea, graphicsTracingWidget); |
| 108 | graphicsTracingWidget->hide(); | 138 | graphicsTracingWidget->hide(); |
| 109 | 139 | ||
| 110 | auto graphicsSurfaceViewerAction = new QAction(tr("Create Pica Surface Viewer"), this); | ||
| 111 | connect(graphicsSurfaceViewerAction, SIGNAL(triggered()), this, | ||
| 112 | SLOT(OnCreateGraphicsSurfaceViewer())); | ||
| 113 | |||
| 114 | waitTreeWidget = new WaitTreeWidget(this); | 140 | waitTreeWidget = new WaitTreeWidget(this); |
| 115 | addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); | 141 | addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); |
| 116 | waitTreeWidget->hide(); | 142 | waitTreeWidget->hide(); |
| 143 | } | ||
| 144 | |||
| 145 | void GMainWindow::InitializeDebugMenuActions() { | ||
| 146 | auto graphicsSurfaceViewerAction = new QAction(tr("Create Pica Surface Viewer"), this); | ||
| 147 | connect(graphicsSurfaceViewerAction, SIGNAL(triggered()), this, | ||
| 148 | SLOT(OnCreateGraphicsSurfaceViewer())); | ||
| 117 | 149 | ||
| 118 | QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging")); | 150 | QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging")); |
| 119 | debug_menu->addAction(graphicsSurfaceViewerAction); | 151 | debug_menu->addAction(graphicsSurfaceViewerAction); |
| @@ -131,19 +163,47 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 131 | debug_menu->addAction(graphicsVertexShaderWidget->toggleViewAction()); | 163 | debug_menu->addAction(graphicsVertexShaderWidget->toggleViewAction()); |
| 132 | debug_menu->addAction(graphicsTracingWidget->toggleViewAction()); | 164 | debug_menu->addAction(graphicsTracingWidget->toggleViewAction()); |
| 133 | debug_menu->addAction(waitTreeWidget->toggleViewAction()); | 165 | debug_menu->addAction(waitTreeWidget->toggleViewAction()); |
| 166 | } | ||
| 167 | |||
| 168 | void GMainWindow::InitializeRecentFileMenuActions() { | ||
| 169 | for (int i = 0; i < max_recent_files_item; ++i) { | ||
| 170 | actions_recent_files[i] = new QAction(this); | ||
| 171 | actions_recent_files[i]->setVisible(false); | ||
| 172 | connect(actions_recent_files[i], SIGNAL(triggered()), this, SLOT(OnMenuRecentFile())); | ||
| 173 | |||
| 174 | ui.menu_recent_files->addAction(actions_recent_files[i]); | ||
| 175 | } | ||
| 176 | |||
| 177 | UpdateRecentFiles(); | ||
| 178 | } | ||
| 179 | |||
| 180 | void GMainWindow::InitializeHotkeys() { | ||
| 181 | RegisterHotkey("Main Window", "Load File", QKeySequence::Open); | ||
| 182 | RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild); | ||
| 183 | RegisterHotkey("Main Window", "Start Emulation"); | ||
| 184 | LoadHotkeys(); | ||
| 185 | |||
| 186 | connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, | ||
| 187 | SLOT(OnMenuLoadFile())); | ||
| 188 | connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, | ||
| 189 | SLOT(OnStartGame())); | ||
| 190 | connect(GetHotkey("Main Window", "Swap Screens", render_window), SIGNAL(activated()), this, | ||
| 191 | SLOT(OnSwapScreens())); | ||
| 192 | } | ||
| 134 | 193 | ||
| 135 | // Set default UI state | 194 | void GMainWindow::SetDefaultUIGeometry() { |
| 136 | // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half | 195 | // geometry: 55% of the window contents are in the upper screen half, 45% in the lower half |
| 137 | QDesktopWidget* desktop = ((QApplication*)QApplication::instance())->desktop(); | 196 | const QRect screenRect = QApplication::desktop()->screenGeometry(this); |
| 138 | QRect screenRect = desktop->screenGeometry(this); | 197 | |
| 139 | int x, y, w, h; | 198 | const int w = screenRect.width() * 2 / 3; |
| 140 | w = screenRect.width() * 2 / 3; | 199 | const int h = screenRect.height() / 2; |
| 141 | h = screenRect.height() / 2; | 200 | const int x = (screenRect.x() + screenRect.width()) / 2 - w / 2; |
| 142 | x = (screenRect.x() + screenRect.width()) / 2 - w / 2; | 201 | const int y = (screenRect.y() + screenRect.height()) / 2 - h * 55 / 100; |
| 143 | y = (screenRect.y() + screenRect.height()) / 2 - h * 55 / 100; | 202 | |
| 144 | setGeometry(x, y, w, h); | 203 | setGeometry(x, y, w, h); |
| 204 | } | ||
| 145 | 205 | ||
| 146 | // Restore UI state | 206 | void GMainWindow::RestoreUIState() { |
| 147 | restoreGeometry(UISettings::values.geometry); | 207 | restoreGeometry(UISettings::values.geometry); |
| 148 | restoreState(UISettings::values.state); | 208 | restoreState(UISettings::values.state); |
| 149 | render_window->restoreGeometry(UISettings::values.renderwindow_geometry); | 209 | render_window->restoreGeometry(UISettings::values.renderwindow_geometry); |
| @@ -159,18 +219,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 159 | 219 | ||
| 160 | ui.actionDisplay_widget_title_bars->setChecked(UISettings::values.display_titlebar); | 220 | ui.actionDisplay_widget_title_bars->setChecked(UISettings::values.display_titlebar); |
| 161 | OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); | 221 | OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); |
| 222 | } | ||
| 162 | 223 | ||
| 163 | // Prepare actions for recent files | 224 | void GMainWindow::ConnectWidgetEvents() { |
| 164 | for (int i = 0; i < max_recent_files_item; ++i) { | ||
| 165 | actions_recent_files[i] = new QAction(this); | ||
| 166 | actions_recent_files[i]->setVisible(false); | ||
| 167 | connect(actions_recent_files[i], SIGNAL(triggered()), this, SLOT(OnMenuRecentFile())); | ||
| 168 | |||
| 169 | ui.menu_recent_files->addAction(actions_recent_files[i]); | ||
| 170 | } | ||
| 171 | UpdateRecentFiles(); | ||
| 172 | |||
| 173 | // Setup connections | ||
| 174 | connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)), | 225 | connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)), |
| 175 | Qt::DirectConnection); | 226 | Qt::DirectConnection); |
| 176 | connect(game_list, SIGNAL(OpenSaveFolderRequested(u64)), this, | 227 | connect(game_list, SIGNAL(OpenSaveFolderRequested(u64)), this, |
| @@ -201,40 +252,6 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { | |||
| 201 | connect(this, SIGNAL(EmulationStarting(EmuThread*)), waitTreeWidget, | 252 | connect(this, SIGNAL(EmulationStarting(EmuThread*)), waitTreeWidget, |
| 202 | SLOT(OnEmulationStarting(EmuThread*))); | 253 | SLOT(OnEmulationStarting(EmuThread*))); |
| 203 | connect(this, SIGNAL(EmulationStopping()), waitTreeWidget, SLOT(OnEmulationStopping())); | 254 | connect(this, SIGNAL(EmulationStopping()), waitTreeWidget, SLOT(OnEmulationStopping())); |
| 204 | |||
| 205 | // Setup hotkeys | ||
| 206 | RegisterHotkey("Main Window", "Load File", QKeySequence::Open); | ||
| 207 | RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild); | ||
| 208 | RegisterHotkey("Main Window", "Start Emulation"); | ||
| 209 | LoadHotkeys(); | ||
| 210 | |||
| 211 | connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, | ||
| 212 | SLOT(OnMenuLoadFile())); | ||
| 213 | connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, | ||
| 214 | SLOT(OnStartGame())); | ||
| 215 | connect(GetHotkey("Main Window", "Swap Screens", render_window), SIGNAL(activated()), this, | ||
| 216 | SLOT(OnSwapScreens())); | ||
| 217 | |||
| 218 | std::string window_title = | ||
| 219 | Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); | ||
| 220 | setWindowTitle(window_title.c_str()); | ||
| 221 | |||
| 222 | show(); | ||
| 223 | |||
| 224 | game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); | ||
| 225 | |||
| 226 | QStringList args = QApplication::arguments(); | ||
| 227 | if (args.length() >= 2) { | ||
| 228 | BootGame(args[1].toStdString()); | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | GMainWindow::~GMainWindow() { | ||
| 233 | // will get automatically deleted otherwise | ||
| 234 | if (render_window->parent() == nullptr) | ||
| 235 | delete render_window; | ||
| 236 | |||
| 237 | Pica::g_debug_context.reset(); | ||
| 238 | } | 255 | } |
| 239 | 256 | ||
| 240 | void GMainWindow::OnDisplayTitleBars(bool show) { | 257 | void GMainWindow::OnDisplayTitleBars(bool show) { |
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 035b68a35..a2fd45c47 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h | |||
| @@ -9,18 +9,21 @@ | |||
| 9 | #include <QMainWindow> | 9 | #include <QMainWindow> |
| 10 | #include "ui_main.h" | 10 | #include "ui_main.h" |
| 11 | 11 | ||
| 12 | class CallstackWidget; | ||
| 12 | class Config; | 13 | class Config; |
| 14 | class DisassemblerWidget; | ||
| 15 | class EmuThread; | ||
| 13 | class GameList; | 16 | class GameList; |
| 14 | class GImageInfo; | 17 | class GImageInfo; |
| 18 | class GPUCommandStreamWidget; | ||
| 19 | class GPUCommandListWidget; | ||
| 20 | class GraphicsBreakPointsWidget; | ||
| 21 | class GraphicsTracingWidget; | ||
| 22 | class GraphicsVertexShaderWidget; | ||
| 15 | class GRenderWindow; | 23 | class GRenderWindow; |
| 16 | class EmuThread; | ||
| 17 | class ProfilerWidget; | ||
| 18 | class MicroProfileDialog; | 24 | class MicroProfileDialog; |
| 19 | class DisassemblerWidget; | 25 | class ProfilerWidget; |
| 20 | class RegistersWidget; | 26 | class RegistersWidget; |
| 21 | class CallstackWidget; | ||
| 22 | class GPUCommandStreamWidget; | ||
| 23 | class GPUCommandListWidget; | ||
| 24 | class WaitTreeWidget; | 27 | class WaitTreeWidget; |
| 25 | 28 | ||
| 26 | class GMainWindow : public QMainWindow { | 29 | class GMainWindow : public QMainWindow { |
| @@ -60,6 +63,16 @@ signals: | |||
| 60 | void EmulationStopping(); | 63 | void EmulationStopping(); |
| 61 | 64 | ||
| 62 | private: | 65 | private: |
| 66 | void InitializeWidgets(); | ||
| 67 | void InitializeDebugMenuActions(); | ||
| 68 | void InitializeRecentFileMenuActions(); | ||
| 69 | void InitializeHotkeys(); | ||
| 70 | |||
| 71 | void SetDefaultUIGeometry(); | ||
| 72 | void RestoreUIState(); | ||
| 73 | |||
| 74 | void ConnectWidgetEvents(); | ||
| 75 | |||
| 63 | /** | 76 | /** |
| 64 | * Initializes the emulation system. | 77 | * Initializes the emulation system. |
| 65 | * @param system_mode The system mode with which to intialize the kernel. | 78 | * @param system_mode The system mode with which to intialize the kernel. |
| @@ -136,6 +149,9 @@ private: | |||
| 136 | CallstackWidget* callstackWidget; | 149 | CallstackWidget* callstackWidget; |
| 137 | GPUCommandStreamWidget* graphicsWidget; | 150 | GPUCommandStreamWidget* graphicsWidget; |
| 138 | GPUCommandListWidget* graphicsCommandsWidget; | 151 | GPUCommandListWidget* graphicsCommandsWidget; |
| 152 | GraphicsBreakPointsWidget* graphicsBreakpointsWidget; | ||
| 153 | GraphicsVertexShaderWidget* graphicsVertexShaderWidget; | ||
| 154 | GraphicsTracingWidget* graphicsTracingWidget; | ||
| 139 | WaitTreeWidget* waitTreeWidget; | 155 | WaitTreeWidget* waitTreeWidget; |
| 140 | 156 | ||
| 141 | QAction* actions_recent_files[max_recent_files_item]; | 157 | QAction* actions_recent_files[max_recent_files_item]; |