forked from PCSX2/pcsx2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.h
265 lines (216 loc) · 8.7 KB
/
MainWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2022 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <functional>
#include <optional>
#include "Settings/ControllerSettingsDialog.h"
#include "Settings/SettingsDialog.h"
#include "ui_MainWindow.h"
class QProgressBar;
class AutoUpdaterDialog;
class DisplayWidget;
class DisplayContainer;
class GameListWidget;
class ControllerSettingsDialog;
class EmuThread;
namespace GameList
{
struct Entry;
}
enum class CDVD_SourceType : uint8_t;
class MainWindow final : public QMainWindow
{
Q_OBJECT
public:
/// This class is a scoped lock on the VM, which prevents it from running while
/// the object exists. Its purpose is to be used for blocking/modal popup boxes,
/// where the VM needs to exit fullscreen temporarily.
class VMLock
{
public:
VMLock(VMLock&& lock);
VMLock(const VMLock&) = delete;
~VMLock();
/// Returns the parent widget, which can be used for any popup dialogs.
__fi QWidget* getDialogParent() const { return m_dialog_parent; }
/// Cancels any pending unpause/fullscreen transition.
/// Call when you're going to destroy the VM anyway.
void cancelResume();
private:
VMLock(QWidget* dialog_parent, bool was_paused, bool was_fullscreen);
friend MainWindow;
QWidget* m_dialog_parent;
bool m_was_paused;
bool m_was_fullscreen;
};
/// Default theme name for the platform.
static const char* DEFAULT_THEME_NAME;
public:
explicit MainWindow(const QString& unthemed_style_name);
~MainWindow();
void initialize();
void connectVMThreadSignals(EmuThread* thread);
void startupUpdateCheck();
/// Locks the VM by pausing it, while a popup dialog is displayed.
VMLock pauseAndLockVM();
/// Accessors for the status bar widgets, updated by the emulation thread.
__fi QLabel* getStatusVerboseWidget() const { return m_status_verbose_widget; }
__fi QLabel* getStatusRendererWidget() const { return m_status_renderer_widget; }
__fi QLabel* getStatusResolutionWidget() const { return m_status_resolution_widget; }
__fi QLabel* getStatusFPSWidget() const { return m_status_fps_widget; }
__fi QLabel* getStatusVPSWidget() const { return m_status_vps_widget; }
public Q_SLOTS:
void checkForUpdates(bool display_message);
void refreshGameList(bool invalidate_cache);
void cancelGameListRefresh();
void invalidateSaveStateCache();
void reportError(const QString& title, const QString& message);
void runOnUIThread(const std::function<void()>& func);
bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool block_until_done = false);
void requestExit();
void checkForSettingChanges();
private Q_SLOTS:
void onUpdateCheckComplete();
DisplayWidget* createDisplay(bool fullscreen, bool render_to_main);
DisplayWidget* updateDisplay(bool fullscreen, bool render_to_main, bool surfaceless);
void displayResizeRequested(qint32 width, qint32 height);
void destroyDisplay();
void focusDisplayWidget();
void onGameListRefreshComplete();
void onGameListRefreshProgress(const QString& status, int current, int total);
void onGameListSelectionChanged();
void onGameListEntryActivated();
void onGameListEntryContextMenuRequested(const QPoint& point);
void onStartFileActionTriggered();
void onStartDiscActionTriggered();
void onStartBIOSActionTriggered();
void onChangeDiscFromFileActionTriggered();
void onChangeDiscFromGameListActionTriggered();
void onChangeDiscFromDeviceActionTriggered();
void onRemoveDiscActionTriggered();
void onChangeDiscMenuAboutToShow();
void onChangeDiscMenuAboutToHide();
void onLoadStateMenuAboutToShow();
void onSaveStateMenuAboutToShow();
void onViewToolbarActionToggled(bool checked);
void onViewLockToolbarActionToggled(bool checked);
void onViewStatusBarActionToggled(bool checked);
void onViewGameListActionTriggered();
void onViewGameGridActionTriggered();
void onViewSystemDisplayTriggered();
void onViewGamePropertiesActionTriggered();
void onGitHubRepositoryActionTriggered();
void onSupportForumsActionTriggered();
void onDiscordServerActionTriggered();
void onAboutActionTriggered();
void onCheckForUpdatesActionTriggered();
void onToolsOpenDataDirectoryTriggered();
void onThemeChanged();
void onThemeChangedFromSettings();
void onLoggingOptionChanged();
void onScreenshotActionTriggered();
void onSaveGSDumpActionTriggered();
void onBlockDumpActionToggled(bool checked);
// Input Recording
void onInputRecNewActionTriggered();
void onInputRecPlayActionTriggered();
void onInputRecStopActionTriggered();
void onInputRecOpenSettingsTriggered();
void onVMStarting();
void onVMStarted();
void onVMPaused();
void onVMResumed();
void onVMStopped();
void onGameChanged(const QString& path, const QString& serial, const QString& name, quint32 crc);
void recreate();
protected:
void showEvent(QShowEvent* event) override;
void closeEvent(QCloseEvent* event) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dropEvent(QDropEvent* event) override;
private:
enum : s32
{
NUM_SAVE_STATE_SLOTS = 10,
};
void setupAdditionalUi();
void connectSignals();
void setStyleFromSettings();
void setIconThemeFromStyle();
void saveStateToConfig();
void restoreStateFromConfig();
void updateEmulationActions(bool starting, bool running);
void updateStatusBarWidgetVisibility();
void updateWindowTitle();
void updateWindowState(bool force_visible = false);
void setProgressBar(int current, int total);
void clearProgressBar();
bool isShowingGameList() const;
bool isRenderingFullscreen() const;
bool isRenderingToMain() const;
bool shouldHideMouseCursor() const;
bool shouldHideMainWindow() const;
void switchToGameListView();
void switchToEmulationView();
QWidget* getContentParent();
QWidget* getDisplayContainer() const;
void saveDisplayWindowGeometryToConfig();
void restoreDisplayWindowGeometryFromConfig();
void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen);
void destroyDisplayWidget(bool show_game_list);
void setDisplayFullscreen(const std::string& fullscreen_mode);
SettingsDialog* getSettingsDialog();
void doSettings(const char* category = nullptr);
ControllerSettingsDialog* getControllerSettingsDialog();
void doControllerSettings(ControllerSettingsDialog::Category category = ControllerSettingsDialog::Category::Count);
QString getDiscDevicePath(const QString& title);
void startGameListEntry(const GameList::Entry* entry, std::optional<s32> save_slot = std::nullopt,
std::optional<bool> fast_boot = std::nullopt);
void setGameListEntryCoverImage(const GameList::Entry* entry);
std::optional<bool> promptForResumeState(const QString& save_state_path);
void loadSaveStateSlot(s32 slot);
void loadSaveStateFile(const QString& filename, const QString& state_filename);
void populateLoadStateMenu(QMenu* menu, const QString& filename, const QString& serial, quint32 crc);
void populateSaveStateMenu(QMenu* menu, const QString& serial, quint32 crc);
void updateSaveStateMenus(const QString& filename, const QString& serial, quint32 crc);
void doStartFile(std::optional<CDVD_SourceType> source, const QString& path);
void doDiscChange(CDVD_SourceType source, const QString& path);
Ui::MainWindow m_ui;
QString m_unthemed_style_name;
GameListWidget* m_game_list_widget = nullptr;
DisplayWidget* m_display_widget = nullptr;
DisplayContainer* m_display_container = nullptr;
SettingsDialog* m_settings_dialog = nullptr;
ControllerSettingsDialog* m_controller_settings_dialog = nullptr;
AutoUpdaterDialog* m_auto_updater_dialog = nullptr;
QProgressBar* m_status_progress_widget = nullptr;
QLabel* m_status_verbose_widget = nullptr;
QLabel* m_status_renderer_widget = nullptr;
QLabel* m_status_fps_widget = nullptr;
QLabel* m_status_vps_widget = nullptr;
QLabel* m_status_resolution_widget = nullptr;
QString m_current_disc_path;
QString m_current_game_serial;
QString m_current_game_name;
quint32 m_current_game_crc;
bool m_save_states_invalidated = false;
bool m_was_paused_on_surface_loss = false;
bool m_was_disc_change_request = false;
bool m_is_closing = false;
QString m_last_fps_status;
};
extern MainWindow* g_main_window;