2019-12-31 06:17:17 +00:00
|
|
|
#pragma once
|
|
|
|
#include <QtCore/QThread>
|
|
|
|
#include <QtWidgets/QLabel>
|
|
|
|
#include <QtWidgets/QMainWindow>
|
2021-07-17 12:27:07 +00:00
|
|
|
#include <QtWidgets/QStackedWidget>
|
2019-12-31 06:17:17 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2021-03-28 03:47:10 +00:00
|
|
|
#include "core/types.h"
|
2021-07-17 12:27:07 +00:00
|
|
|
#include "qtdisplaywidget.h"
|
2019-12-31 06:17:17 +00:00
|
|
|
#include "settingsdialog.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
2020-01-24 04:49:47 +00:00
|
|
|
class QLabel;
|
2020-02-15 15:14:28 +00:00
|
|
|
class QThread;
|
2020-01-24 04:49:47 +00:00
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
class GameListWidget;
|
|
|
|
class QtHostInterface;
|
2020-08-06 12:08:22 +00:00
|
|
|
class AutoUpdaterDialog;
|
2020-09-18 14:28:07 +00:00
|
|
|
class MemoryCardEditorDialog;
|
2020-10-19 15:14:49 +00:00
|
|
|
class CheatManagerDialog;
|
2020-12-16 15:18:13 +00:00
|
|
|
class DebuggerWindow;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-06-29 16:46:57 +00:00
|
|
|
class HostDisplay;
|
2020-03-02 01:08:16 +00:00
|
|
|
struct GameListEntry;
|
|
|
|
|
2020-12-17 17:32:29 +00:00
|
|
|
class GDBServer;
|
|
|
|
|
2020-01-24 04:50:56 +00:00
|
|
|
class MainWindow final : public QMainWindow
|
2019-12-31 06:17:17 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainWindow(QtHostInterface* host_interface);
|
|
|
|
~MainWindow();
|
|
|
|
|
2020-12-29 06:29:14 +00:00
|
|
|
/// Initializes the window. Call once at startup.
|
|
|
|
void initializeAndShow();
|
|
|
|
|
2020-08-06 12:08:22 +00:00
|
|
|
/// Performs update check if enabled in settings.
|
|
|
|
void startupUpdateCheck();
|
|
|
|
|
2020-11-10 13:24:07 +00:00
|
|
|
/// Opens memory card editor with the specified paths.
|
|
|
|
void openMemoryCardEditor(const QString& card_a_path, const QString& card_b_path);
|
|
|
|
|
2021-03-03 09:14:01 +00:00
|
|
|
/// Updates the state of the controls which should be disabled by achievements challenge mode.
|
|
|
|
void onAchievementsChallengeModeToggled(bool enabled);
|
|
|
|
|
2020-08-18 14:01:57 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
/// Updates debug menu visibility (hides if disabled).
|
|
|
|
void updateDebugMenuVisibility();
|
|
|
|
|
2020-12-21 16:47:48 +00:00
|
|
|
void checkForUpdates(bool display_message);
|
|
|
|
|
2020-01-06 06:27:39 +00:00
|
|
|
private Q_SLOTS:
|
2020-02-15 15:14:30 +00:00
|
|
|
void reportError(const QString& message);
|
|
|
|
void reportMessage(const QString& message);
|
2020-02-26 09:25:57 +00:00
|
|
|
bool confirmMessage(const QString& message);
|
2020-12-26 13:22:24 +00:00
|
|
|
QtDisplayWidget* createDisplay(QThread* worker_thread, bool fullscreen, bool render_to_main);
|
2020-06-29 16:46:57 +00:00
|
|
|
QtDisplayWidget* updateDisplay(QThread* worker_thread, bool fullscreen, bool render_to_main);
|
2020-11-18 13:15:16 +00:00
|
|
|
void displaySizeRequested(qint32 width, qint32 height);
|
2020-04-22 11:13:51 +00:00
|
|
|
void destroyDisplay();
|
2020-02-26 09:26:14 +00:00
|
|
|
void focusDisplayWidget();
|
2020-12-27 04:08:13 +00:00
|
|
|
void onMouseModeRequested(bool relative_mode, bool hide_cursor);
|
2020-12-28 16:00:31 +00:00
|
|
|
void updateMouseMode(bool paused);
|
2020-06-05 17:44:57 +00:00
|
|
|
|
2021-07-09 03:05:52 +00:00
|
|
|
void onSettingsResetToDefault();
|
2020-06-05 17:44:57 +00:00
|
|
|
void onEmulationStarting();
|
2019-12-31 06:17:17 +00:00
|
|
|
void onEmulationStarted();
|
|
|
|
void onEmulationStopped();
|
|
|
|
void onEmulationPaused(bool paused);
|
2020-02-09 13:16:25 +00:00
|
|
|
void onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
|
2021-03-28 03:47:10 +00:00
|
|
|
float worst_frame_time, GPURenderer renderer, quint32 render_width,
|
|
|
|
quint32 render_height, bool render_interlaced);
|
2020-02-15 15:14:30 +00:00
|
|
|
void onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title);
|
2020-12-04 14:16:22 +00:00
|
|
|
void onApplicationStateChanged(Qt::ApplicationState state);
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2021-07-24 08:38:54 +00:00
|
|
|
void onStartFileActionTriggered();
|
2019-12-31 06:17:17 +00:00
|
|
|
void onStartDiscActionTriggered();
|
2020-03-02 01:08:16 +00:00
|
|
|
void onStartBIOSActionTriggered();
|
2020-01-24 04:50:40 +00:00
|
|
|
void onChangeDiscFromFileActionTriggered();
|
|
|
|
void onChangeDiscFromGameListActionTriggered();
|
2021-07-27 08:23:11 +00:00
|
|
|
void onChangeDiscFromDeviceActionTriggered();
|
2021-03-27 04:14:52 +00:00
|
|
|
void onChangeDiscMenuAboutToShow();
|
|
|
|
void onChangeDiscMenuAboutToHide();
|
2021-07-04 04:46:46 +00:00
|
|
|
void onLoadStateMenuAboutToShow();
|
|
|
|
void onSaveStateMenuAboutToShow();
|
2020-09-09 13:44:21 +00:00
|
|
|
void onCheatsMenuAboutToShow();
|
2020-05-19 16:32:19 +00:00
|
|
|
void onRemoveDiscActionTriggered();
|
2020-08-20 13:39:29 +00:00
|
|
|
void onViewToolbarActionToggled(bool checked);
|
2021-02-09 13:56:24 +00:00
|
|
|
void onViewLockToolbarActionToggled(bool checked);
|
2020-08-20 13:39:29 +00:00
|
|
|
void onViewStatusBarActionToggled(bool checked);
|
|
|
|
void onViewGameListActionTriggered();
|
2020-09-23 14:02:13 +00:00
|
|
|
void onViewGameGridActionTriggered();
|
2020-08-20 13:39:29 +00:00
|
|
|
void onViewSystemDisplayTriggered();
|
2020-10-13 13:20:50 +00:00
|
|
|
void onViewGamePropertiesActionTriggered();
|
2019-12-31 06:17:17 +00:00
|
|
|
void onGitHubRepositoryActionTriggered();
|
|
|
|
void onIssueTrackerActionTriggered();
|
2020-04-07 03:54:20 +00:00
|
|
|
void onDiscordServerActionTriggered();
|
2019-12-31 06:17:17 +00:00
|
|
|
void onAboutActionTriggered();
|
2020-09-14 08:25:51 +00:00
|
|
|
void onCheckForUpdatesActionTriggered();
|
2020-09-18 14:28:07 +00:00
|
|
|
void onToolsMemoryCardEditorTriggered();
|
2020-10-19 15:14:49 +00:00
|
|
|
void onToolsCheatManagerTriggered();
|
2020-09-23 14:19:54 +00:00
|
|
|
void onToolsOpenDataDirectoryTriggered();
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-03-02 01:08:16 +00:00
|
|
|
void onGameListEntrySelected(const GameListEntry* entry);
|
|
|
|
void onGameListEntryDoubleClicked(const GameListEntry* entry);
|
|
|
|
void onGameListContextMenuRequested(const QPoint& point, const GameListEntry* entry);
|
2020-10-03 13:20:48 +00:00
|
|
|
void onGameListSetCoverImageRequested(const GameListEntry* entry);
|
2020-03-02 01:08:16 +00:00
|
|
|
|
2020-08-06 12:08:22 +00:00
|
|
|
void onUpdateCheckComplete();
|
|
|
|
|
2020-12-26 14:40:28 +00:00
|
|
|
void openCPUDebugger();
|
|
|
|
void onCPUDebuggerClosed();
|
|
|
|
|
2020-01-24 04:50:56 +00:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2020-03-22 11:50:49 +00:00
|
|
|
void changeEvent(QEvent* event) override;
|
2021-03-11 16:50:17 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2020-01-24 04:50:56 +00:00
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
private:
|
2021-07-17 12:27:07 +00:00
|
|
|
ALWAYS_INLINE QWidget* getDisplayContainer() const
|
|
|
|
{
|
|
|
|
return (m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget));
|
|
|
|
}
|
|
|
|
|
2021-08-15 04:23:14 +00:00
|
|
|
void setTheme(const QString& theme);
|
2021-08-15 04:28:48 +00:00
|
|
|
void setStyleFromSettings();
|
|
|
|
void setIconThemeFromSettings();
|
2019-12-31 06:17:17 +00:00
|
|
|
void setupAdditionalUi();
|
|
|
|
void connectSignals();
|
2020-06-24 15:31:23 +00:00
|
|
|
void addThemeToMenu(const QString& name, const QString& key);
|
2021-03-03 09:14:01 +00:00
|
|
|
void updateEmulationActions(bool starting, bool running, bool cheevos_challenge_mode);
|
2020-09-23 14:02:13 +00:00
|
|
|
bool isShowingGameList() const;
|
2019-12-31 06:17:17 +00:00
|
|
|
void switchToGameListView();
|
|
|
|
void switchToEmulationView();
|
2021-03-11 16:50:17 +00:00
|
|
|
void startGameOrChangeDiscs(const std::string& path);
|
2020-09-14 07:58:04 +00:00
|
|
|
void saveStateToConfig();
|
|
|
|
void restoreStateFromConfig();
|
2020-10-03 02:10:11 +00:00
|
|
|
void saveDisplayWindowGeometryToConfig();
|
|
|
|
void restoreDisplayWindowGeometryFromConfig();
|
2020-06-29 16:46:57 +00:00
|
|
|
void destroyDisplayWidget();
|
2020-11-01 14:38:54 +00:00
|
|
|
void setDisplayFullscreen(const std::string& fullscreen_mode);
|
2020-12-06 14:06:32 +00:00
|
|
|
bool shouldHideCursorInFullscreen() const;
|
2020-01-24 04:50:53 +00:00
|
|
|
SettingsDialog* getSettingsDialog();
|
2019-12-31 06:17:17 +00:00
|
|
|
void doSettings(SettingsDialog::Category category = SettingsDialog::Category::Count);
|
2020-02-05 08:43:25 +00:00
|
|
|
void updateDebugMenuCPUExecutionMode();
|
2020-01-24 04:49:51 +00:00
|
|
|
void updateDebugMenuGPURenderer();
|
2020-10-09 07:52:05 +00:00
|
|
|
void updateDebugMenuCropMode();
|
2021-08-15 04:23:14 +00:00
|
|
|
void updateMenuSelectedTheme();
|
2021-07-27 08:11:32 +00:00
|
|
|
void ensureGameListLoaded();
|
2021-07-27 08:23:11 +00:00
|
|
|
std::string getDeviceDiscPath(const QString& title);
|
2019-12-31 06:17:17 +00:00
|
|
|
|
|
|
|
Ui::MainWindow m_ui;
|
|
|
|
|
2020-07-04 05:54:26 +00:00
|
|
|
QString m_unthemed_style_name;
|
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
QtHostInterface* m_host_interface = nullptr;
|
|
|
|
|
|
|
|
GameListWidget* m_game_list_widget = nullptr;
|
2020-04-22 11:13:51 +00:00
|
|
|
|
2020-06-29 16:46:57 +00:00
|
|
|
HostDisplay* m_host_display = nullptr;
|
2020-03-12 03:53:51 +00:00
|
|
|
QtDisplayWidget* m_display_widget = nullptr;
|
2021-07-17 12:27:07 +00:00
|
|
|
QtDisplayContainer* m_display_container = nullptr;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2020-01-24 04:49:47 +00:00
|
|
|
QLabel* m_status_speed_widget = nullptr;
|
|
|
|
QLabel* m_status_fps_widget = nullptr;
|
|
|
|
QLabel* m_status_frame_time_widget = nullptr;
|
2021-03-28 03:47:10 +00:00
|
|
|
QLabel* m_status_renderer_widget = nullptr;
|
|
|
|
QLabel* m_status_resolution_widget = nullptr;
|
2020-01-24 04:49:47 +00:00
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
SettingsDialog* m_settings_dialog = nullptr;
|
2020-08-06 12:08:22 +00:00
|
|
|
AutoUpdaterDialog* m_auto_updater_dialog = nullptr;
|
2020-09-18 14:28:07 +00:00
|
|
|
MemoryCardEditorDialog* m_memory_card_editor_dialog = nullptr;
|
2020-10-19 15:14:49 +00:00
|
|
|
CheatManagerDialog* m_cheat_manager_dialog = nullptr;
|
2020-12-16 15:18:13 +00:00
|
|
|
DebuggerWindow* m_debugger_window = nullptr;
|
2019-12-31 06:17:17 +00:00
|
|
|
|
2021-07-04 04:46:46 +00:00
|
|
|
std::string m_running_game_code;
|
|
|
|
|
2019-12-31 06:17:17 +00:00
|
|
|
bool m_emulation_running = false;
|
2020-12-04 14:16:22 +00:00
|
|
|
bool m_was_paused_by_focus_loss = false;
|
2020-12-26 14:40:28 +00:00
|
|
|
bool m_open_debugger_on_start = false;
|
2020-12-27 04:08:13 +00:00
|
|
|
bool m_relative_mouse_mode = false;
|
2020-12-28 16:00:31 +00:00
|
|
|
bool m_mouse_cursor_hidden = false;
|
2020-12-17 17:32:29 +00:00
|
|
|
|
|
|
|
GDBServer* m_gdb_server = nullptr;
|
2019-12-31 06:17:17 +00:00
|
|
|
};
|