2016-09-06 00:12:56 +01:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
2016-07-26 15:20:18 +01:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QKeyEvent>
|
2017-02-25 15:48:49 +00:00
|
|
|
#include <QDir>
|
2016-07-26 15:20:18 +01:00
|
|
|
|
|
|
|
#include "AppConfig.h"
|
2016-07-02 03:12:06 +03:00
|
|
|
#include "PS2VM.h"
|
2017-03-25 21:53:28 +00:00
|
|
|
#include "ElidedLabel.h"
|
2018-10-05 13:35:24 -04:00
|
|
|
#include "ContinuationChecker.h"
|
2018-08-07 19:18:19 -04:00
|
|
|
|
2018-11-19 13:20:46 -05:00
|
|
|
#include "InputProviderQtKey.h"
|
2023-04-20 19:03:13 -04:00
|
|
|
#include "InputProviderQtMouse.h"
|
2019-08-16 08:27:30 -04:00
|
|
|
#include "ScreenShotUtils.h"
|
2018-11-19 13:20:46 -05:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class MainWindow;
|
2016-09-06 00:12:56 +01:00
|
|
|
}
|
|
|
|
|
2020-11-13 17:00:58 -05:00
|
|
|
class OutputWindow;
|
|
|
|
|
2019-03-21 17:52:43 -04:00
|
|
|
#ifdef DEBUGGER_INCLUDED
|
2019-12-09 19:07:36 +00:00
|
|
|
class QtDebugger;
|
2020-02-02 19:46:03 +00:00
|
|
|
class QtFramedebugger;
|
2019-03-21 17:52:43 -04:00
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
2022-05-05 20:04:05 -04:00
|
|
|
class DebugDockMenu;
|
2019-03-21 17:52:43 -04:00
|
|
|
class DebugMenu;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-06 00:12:56 +01:00
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
Q_OBJECT
|
2016-09-06 00:12:56 +01:00
|
|
|
|
|
|
|
public:
|
2018-08-01 13:05:47 -04:00
|
|
|
explicit MainWindow(QWidget* parent = nullptr);
|
2018-04-30 21:01:23 +01:00
|
|
|
~MainWindow();
|
2016-07-01 05:28:39 +03:00
|
|
|
|
2019-10-16 20:51:11 -04:00
|
|
|
void BootElf(fs::path);
|
2018-10-08 02:43:23 +01:00
|
|
|
void BootCDROM();
|
2019-10-16 20:51:11 -04:00
|
|
|
void LoadCDROM(fs::path filePath);
|
2022-10-08 16:33:19 -04:00
|
|
|
void BootArcadeMachine(fs::path);
|
2019-06-27 20:50:49 -04:00
|
|
|
void loadState(int);
|
|
|
|
|
2019-03-21 17:52:43 -04:00
|
|
|
#ifdef DEBUGGER_INCLUDED
|
2022-05-05 20:04:05 -04:00
|
|
|
void ShowMainWindow();
|
2019-03-21 17:52:43 -04:00
|
|
|
void ShowDebugger();
|
|
|
|
void ShowFrameDebugger();
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path GetFrameDumpDirectoryPath();
|
2019-03-25 12:41:48 -04:00
|
|
|
void DumpNextFrame();
|
2019-03-25 12:57:31 -04:00
|
|
|
void ToggleGsDraw();
|
2019-03-21 17:52:43 -04:00
|
|
|
#endif
|
2018-10-08 02:43:23 +01:00
|
|
|
|
2016-07-01 05:28:39 +03:00
|
|
|
private:
|
2020-12-17 15:58:19 -05:00
|
|
|
enum class BootType
|
2019-03-04 22:20:04 -05:00
|
|
|
{
|
|
|
|
CD,
|
2022-10-08 16:33:19 -04:00
|
|
|
ELF,
|
|
|
|
ARCADE,
|
2019-03-04 22:20:04 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LastOpenCommand
|
|
|
|
{
|
|
|
|
LastOpenCommand() = default;
|
2019-10-16 20:51:11 -04:00
|
|
|
LastOpenCommand(BootType type, fs::path path)
|
2019-03-04 22:20:04 -05:00
|
|
|
: type(type)
|
|
|
|
, path(path)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
BootType type = BootType::CD;
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path path;
|
2019-03-04 22:20:04 -05:00
|
|
|
};
|
|
|
|
|
2019-09-12 15:11:52 -04:00
|
|
|
void SetOutputWindowSize();
|
2018-04-30 21:01:23 +01:00
|
|
|
void CreateStatusBar();
|
2018-08-01 13:05:38 -04:00
|
|
|
void InitVirtualMachine();
|
|
|
|
void SetupGsHandler();
|
2018-04-30 21:01:23 +01:00
|
|
|
void SetupSoundHandler();
|
|
|
|
void SetupSaveLoadStateSlots();
|
2019-03-13 12:30:21 -04:00
|
|
|
QString GetSaveStateInfo(int);
|
2019-04-04 19:14:16 -04:00
|
|
|
void EmitOnExecutableChange();
|
2020-05-20 11:11:19 -04:00
|
|
|
bool IsExecutableLoaded() const;
|
2018-04-30 21:01:23 +01:00
|
|
|
void UpdateUI();
|
2022-01-21 10:52:40 -05:00
|
|
|
void UpdateCpuUsageLabel();
|
2018-04-30 21:01:23 +01:00
|
|
|
void RegisterPreferences();
|
|
|
|
void saveState(int);
|
2020-12-20 19:22:04 -05:00
|
|
|
void buildResizeWindowMenu();
|
|
|
|
void resizeWindow(unsigned int, unsigned int);
|
2024-10-20 12:52:46 +01:00
|
|
|
void UpdateGSHandlerLabel();
|
2022-01-13 23:58:16 +00:00
|
|
|
void SetupBootableView();
|
2022-05-05 20:04:05 -04:00
|
|
|
void SetupDebugger();
|
2016-07-01 05:21:58 +03:00
|
|
|
|
2022-05-05 20:04:05 -04:00
|
|
|
Ui::MainWindow* ui = nullptr;
|
2016-07-26 15:20:18 +01:00
|
|
|
|
2020-11-13 17:00:58 -05:00
|
|
|
OutputWindow* m_outputwindow = nullptr;
|
2018-08-02 08:56:07 -04:00
|
|
|
QLabel* m_fpsLabel = nullptr;
|
2024-10-20 14:18:00 +01:00
|
|
|
QLabel* m_scaleFactorLabel = nullptr;
|
2022-01-10 15:57:45 -05:00
|
|
|
QLabel* m_cpuUsageLabel = nullptr;
|
2020-02-12 17:29:37 +00:00
|
|
|
QLabel* m_gsLabel = nullptr;
|
2019-07-25 12:50:25 -04:00
|
|
|
#ifdef PROFILE
|
|
|
|
QLabel* m_profileStatsLabel = nullptr;
|
|
|
|
#endif
|
2018-08-02 08:56:07 -04:00
|
|
|
ElidedLabel* m_msgLabel = nullptr;
|
2018-08-07 19:17:28 -04:00
|
|
|
QTimer* m_fpsTimer = nullptr;
|
2018-10-05 13:35:24 -04:00
|
|
|
CContinuationChecker* m_continuationChecker = nullptr;
|
2018-08-01 12:59:11 -04:00
|
|
|
CPS2VM* m_virtualMachine = nullptr;
|
2018-04-30 21:01:23 +01:00
|
|
|
bool m_deactivatePause = false;
|
|
|
|
bool m_pauseFocusLost = true;
|
2018-11-19 13:20:46 -05:00
|
|
|
std::shared_ptr<CInputProviderQtKey> m_qtKeyInputProvider;
|
2023-04-20 19:03:13 -04:00
|
|
|
std::shared_ptr<CInputProviderQtMouse> m_qtMouseInputProvider;
|
2018-09-22 22:30:15 -04:00
|
|
|
LastOpenCommand m_lastOpenCommand;
|
2019-10-16 20:51:11 -04:00
|
|
|
fs::path m_lastPath;
|
2018-04-30 21:01:23 +01:00
|
|
|
|
2019-08-16 17:11:35 -04:00
|
|
|
Framework::CSignal<void()>::Connection m_OnExecutableChangeConnection;
|
2024-01-12 13:50:34 -05:00
|
|
|
CPS2VM::NewFrameEvent::Connection m_OnNewFrameConnection;
|
|
|
|
CGSHandler::NewFrameEvent::Connection m_OnGsNewFrameConnection;
|
2019-08-16 08:27:30 -04:00
|
|
|
CScreenShotUtils::Connection m_screenShotCompleteConnection;
|
2022-01-14 15:03:27 +00:00
|
|
|
CVirtualMachine::RunningStateChangeEvent::Connection m_onRunningStateChangeConnection;
|
2019-06-20 00:40:28 +01:00
|
|
|
|
2019-03-21 17:52:43 -04:00
|
|
|
#ifdef DEBUGGER_INCLUDED
|
2019-12-20 16:24:37 +00:00
|
|
|
std::unique_ptr<QtDebugger> m_debugger;
|
2020-02-02 19:46:03 +00:00
|
|
|
std::unique_ptr<QtFramedebugger> m_frameDebugger;
|
2022-05-05 20:04:05 -04:00
|
|
|
Ui::DebugDockMenu* debugDockMenuUi = nullptr;
|
2019-03-21 17:52:43 -04:00
|
|
|
Ui::DebugMenu* debugMenuUi = nullptr;
|
|
|
|
#endif
|
|
|
|
|
2016-07-01 05:28:39 +03:00
|
|
|
protected:
|
2018-04-30 21:01:23 +01:00
|
|
|
void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE;
|
2023-04-25 09:14:03 -04:00
|
|
|
void changeEvent(QEvent*) Q_DECL_OVERRIDE;
|
2016-06-26 23:42:21 -04:00
|
|
|
|
2019-04-04 19:14:16 -04:00
|
|
|
signals:
|
|
|
|
void onExecutableChange();
|
2019-04-04 19:32:48 -04:00
|
|
|
|
2016-07-26 15:20:18 +01:00
|
|
|
public slots:
|
2019-09-12 15:11:52 -04:00
|
|
|
void outputWindow_resized();
|
2019-07-24 19:35:46 -04:00
|
|
|
void updateStats();
|
2016-07-26 15:20:18 +01:00
|
|
|
|
|
|
|
private slots:
|
2018-09-28 08:17:24 -04:00
|
|
|
void on_actionBoot_DiscImage_triggered();
|
2018-10-16 13:08:52 -04:00
|
|
|
void on_actionBoot_DiscImage_S3_triggered();
|
2018-09-28 12:00:02 -04:00
|
|
|
void on_actionBoot_cdrom0_triggered();
|
2018-04-30 21:01:23 +01:00
|
|
|
void on_actionBoot_ELF_triggered();
|
|
|
|
void on_actionExit_triggered();
|
2018-07-30 13:25:08 -04:00
|
|
|
void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
|
|
|
|
void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE;
|
2018-04-30 21:01:23 +01:00
|
|
|
void on_actionSettings_triggered();
|
|
|
|
void on_actionPause_Resume_triggered();
|
|
|
|
void on_actionAbout_triggered();
|
|
|
|
void focusOutEvent(QFocusEvent*) Q_DECL_OVERRIDE;
|
|
|
|
void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE;
|
2023-04-20 19:03:13 -04:00
|
|
|
void outputWindow_doubleClickEvent(QMouseEvent*);
|
|
|
|
void outputWindow_mouseMoveEvent(QMouseEvent*);
|
|
|
|
void outputWindow_mousePressEvent(QMouseEvent*);
|
|
|
|
void outputWindow_mouseReleaseEvent(QMouseEvent*);
|
2018-04-30 21:01:23 +01:00
|
|
|
void on_actionPause_when_focus_is_lost_triggered(bool checked);
|
|
|
|
void on_actionReset_triggered();
|
|
|
|
void on_actionMemory_Card_Manager_triggered();
|
|
|
|
void on_actionVFS_Manager_triggered();
|
|
|
|
void on_actionController_Manager_triggered();
|
2023-04-25 09:14:03 -04:00
|
|
|
void on_actionToggleFullscreen_triggered();
|
2018-04-30 21:01:23 +01:00
|
|
|
void on_actionCapture_Screen_triggered();
|
2019-04-04 19:14:16 -04:00
|
|
|
void HandleOnExecutableChange();
|
2019-01-16 20:00:10 +00:00
|
|
|
void on_actionList_Bootables_triggered();
|
2016-09-06 00:12:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|