2021-12-13 12:12:54 +00:00
|
|
|
/* 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
|
|
|
|
|
2022-04-03 13:46:05 +00:00
|
|
|
#include <QtWidgets/QLabel>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <QtWidgets/QMainWindow>
|
2022-04-06 10:49:00 +00:00
|
|
|
#include <functional>
|
2021-12-13 12:12:54 +00:00
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include "Settings/ControllerSettingsDialog.h"
|
|
|
|
#include "Settings/SettingsDialog.h"
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
|
|
|
|
class QProgressBar;
|
|
|
|
|
2022-04-04 11:27:23 +00:00
|
|
|
class AutoUpdaterDialog;
|
2021-12-13 12:12:54 +00:00
|
|
|
class DisplayWidget;
|
|
|
|
class DisplayContainer;
|
|
|
|
class GameListWidget;
|
|
|
|
class ControllerSettingsDialog;
|
|
|
|
|
|
|
|
class EmuThread;
|
|
|
|
|
|
|
|
namespace GameList
|
|
|
|
{
|
|
|
|
struct Entry;
|
|
|
|
}
|
|
|
|
|
2022-06-28 13:34:45 +00:00
|
|
|
enum class CDVD_SourceType : uint8_t;
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
class MainWindow final : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-05-07 03:52:13 +00:00
|
|
|
/// 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.
|
2021-12-13 12:12:54 +00:00
|
|
|
static const char* DEFAULT_THEME_NAME;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainWindow(const QString& unthemed_style_name);
|
|
|
|
~MainWindow();
|
|
|
|
|
2022-07-24 13:52:22 +00:00
|
|
|
/// Sets application theme according to settings.
|
|
|
|
static void updateApplicationTheme();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
void initialize();
|
|
|
|
void connectVMThreadSignals(EmuThread* thread);
|
2022-04-04 11:27:23 +00:00
|
|
|
void startupUpdateCheck();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-05-07 03:52:13 +00:00
|
|
|
/// Locks the VM by pausing it, while a popup dialog is displayed.
|
|
|
|
VMLock pauseAndLockVM();
|
|
|
|
|
2022-07-03 13:30:03 +00:00
|
|
|
/// 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; }
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
public Q_SLOTS:
|
2022-04-04 11:27:23 +00:00
|
|
|
void checkForUpdates(bool display_message);
|
2021-12-13 12:12:54 +00:00
|
|
|
void refreshGameList(bool invalidate_cache);
|
2022-05-15 08:16:24 +00:00
|
|
|
void cancelGameListRefresh();
|
2021-12-13 12:12:54 +00:00
|
|
|
void invalidateSaveStateCache();
|
|
|
|
void reportError(const QString& title, const QString& message);
|
2022-04-06 10:49:00 +00:00
|
|
|
void runOnUIThread(const std::function<void()>& func);
|
2022-03-25 10:14:23 +00:00
|
|
|
bool requestShutdown(bool allow_confirm = true, bool allow_save_to_state = true, bool block_until_done = false);
|
2022-03-04 10:40:03 +00:00
|
|
|
void requestExit();
|
2022-05-15 08:15:27 +00:00
|
|
|
void checkForSettingChanges();
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
2022-04-04 11:27:23 +00:00
|
|
|
void onUpdateCheckComplete();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
DisplayWidget* createDisplay(bool fullscreen, bool render_to_main);
|
2022-05-06 11:03:16 +00:00
|
|
|
DisplayWidget* updateDisplay(bool fullscreen, bool render_to_main, bool surfaceless);
|
2021-12-13 12:12:54 +00:00
|
|
|
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();
|
2022-06-28 13:34:45 +00:00
|
|
|
void onStartDiscActionTriggered();
|
2021-12-13 12:12:54 +00:00
|
|
|
void onStartBIOSActionTriggered();
|
|
|
|
void onChangeDiscFromFileActionTriggered();
|
|
|
|
void onChangeDiscFromGameListActionTriggered();
|
|
|
|
void onChangeDiscFromDeviceActionTriggered();
|
2022-06-28 14:00:51 +00:00
|
|
|
void onRemoveDiscActionTriggered();
|
2021-12-13 12:12:54 +00:00
|
|
|
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();
|
2022-07-24 13:52:22 +00:00
|
|
|
void updateTheme();
|
2022-03-04 09:46:47 +00:00
|
|
|
void onLoggingOptionChanged();
|
2022-05-12 21:53:40 +00:00
|
|
|
void onScreenshotActionTriggered();
|
2022-05-16 11:10:34 +00:00
|
|
|
void onSaveGSDumpActionTriggered();
|
2022-05-24 12:22:15 +00:00
|
|
|
void onBlockDumpActionToggled(bool checked);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-04-04 00:06:59 +00:00
|
|
|
// Input Recording
|
|
|
|
void onInputRecNewActionTriggered();
|
|
|
|
void onInputRecPlayActionTriggered();
|
|
|
|
void onInputRecStopActionTriggered();
|
|
|
|
void onInputRecOpenSettingsTriggered();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
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:
|
2022-06-04 16:13:05 +00:00
|
|
|
void showEvent(QShowEvent* event) override;
|
2022-03-04 08:04:05 +00:00
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2022-05-26 07:49:40 +00:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum : s32
|
|
|
|
{
|
|
|
|
NUM_SAVE_STATE_SLOTS = 10,
|
|
|
|
};
|
|
|
|
|
2022-07-24 13:52:22 +00:00
|
|
|
static void setStyleFromSettings();
|
|
|
|
static void setIconThemeFromStyle();
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
void setupAdditionalUi();
|
|
|
|
void connectSignals();
|
|
|
|
|
|
|
|
void saveStateToConfig();
|
|
|
|
void restoreStateFromConfig();
|
|
|
|
|
|
|
|
void updateEmulationActions(bool starting, bool running);
|
2022-04-03 13:46:05 +00:00
|
|
|
void updateStatusBarWidgetVisibility();
|
2021-12-13 12:12:54 +00:00
|
|
|
void updateWindowTitle();
|
2022-06-28 12:16:45 +00:00
|
|
|
void updateWindowState(bool force_visible = false);
|
2021-12-13 12:12:54 +00:00
|
|
|
void setProgressBar(int current, int total);
|
|
|
|
void clearProgressBar();
|
|
|
|
|
|
|
|
bool isShowingGameList() const;
|
2022-05-06 11:03:16 +00:00
|
|
|
bool isRenderingFullscreen() const;
|
|
|
|
bool isRenderingToMain() const;
|
2022-05-15 08:15:27 +00:00
|
|
|
bool shouldHideMouseCursor() const;
|
2022-07-09 09:14:48 +00:00
|
|
|
bool shouldHideMainWindow() const;
|
2021-12-13 12:12:54 +00:00
|
|
|
void switchToGameListView();
|
|
|
|
void switchToEmulationView();
|
|
|
|
|
2022-07-09 06:59:13 +00:00
|
|
|
QWidget* getContentParent();
|
2021-12-13 12:12:54 +00:00
|
|
|
QWidget* getDisplayContainer() const;
|
|
|
|
void saveDisplayWindowGeometryToConfig();
|
|
|
|
void restoreDisplayWindowGeometryFromConfig();
|
2022-07-09 06:59:13 +00:00
|
|
|
void createDisplayWidget(bool fullscreen, bool render_to_main, bool is_exclusive_fullscreen);
|
|
|
|
void destroyDisplayWidget(bool show_game_list);
|
2021-12-13 12:12:54 +00:00
|
|
|
void setDisplayFullscreen(const std::string& fullscreen_mode);
|
|
|
|
|
|
|
|
SettingsDialog* getSettingsDialog();
|
2022-02-15 14:29:18 +00:00
|
|
|
void doSettings(const char* category = nullptr);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
ControllerSettingsDialog* getControllerSettingsDialog();
|
|
|
|
void doControllerSettings(ControllerSettingsDialog::Category category = ControllerSettingsDialog::Category::Count);
|
|
|
|
|
2022-06-28 13:34:45 +00:00
|
|
|
QString getDiscDevicePath(const QString& title);
|
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
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);
|
|
|
|
|
2022-05-07 12:56:44 +00:00
|
|
|
std::optional<bool> promptForResumeState(const QString& save_state_path);
|
2021-12-13 12:12:54 +00:00
|
|
|
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);
|
2022-06-28 13:34:45 +00:00
|
|
|
void doStartFile(std::optional<CDVD_SourceType> source, const QString& path);
|
|
|
|
void doDiscChange(CDVD_SourceType source, const QString& path);
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
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;
|
2022-04-04 11:27:23 +00:00
|
|
|
AutoUpdaterDialog* m_auto_updater_dialog = nullptr;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
QProgressBar* m_status_progress_widget = nullptr;
|
2022-07-03 13:30:03 +00:00
|
|
|
QLabel* m_status_verbose_widget = nullptr;
|
|
|
|
QLabel* m_status_renderer_widget = nullptr;
|
2022-04-03 13:46:05 +00:00
|
|
|
QLabel* m_status_fps_widget = nullptr;
|
2022-07-03 13:30:03 +00:00
|
|
|
QLabel* m_status_vps_widget = nullptr;
|
|
|
|
QLabel* m_status_resolution_widget = nullptr;
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
QString m_current_disc_path;
|
|
|
|
QString m_current_game_serial;
|
|
|
|
QString m_current_game_name;
|
|
|
|
quint32 m_current_game_crc;
|
2022-06-28 12:53:26 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
bool m_save_states_invalidated = false;
|
2022-05-06 11:03:16 +00:00
|
|
|
bool m_was_paused_on_surface_loss = false;
|
2022-05-06 13:34:07 +00:00
|
|
|
bool m_was_disc_change_request = false;
|
2022-06-29 02:44:10 +00:00
|
|
|
bool m_is_closing = false;
|
2022-04-03 13:46:05 +00:00
|
|
|
|
|
|
|
QString m_last_fps_status;
|
2021-12-13 12:12:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern MainWindow* g_main_window;
|