all repos — mgba @ 24b0e78360fcf4e2251d014b6eb51f7bbfe1b582

mGBA Game Boy Advance Emulator

src/platform/qt/Window.h (view raw)

  1/* Copyright (c) 2013-2015 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#ifndef QGBA_WINDOW
  7#define QGBA_WINDOW
  8
  9#include <QDateTime>
 10#include <QList>
 11#include <QMainWindow>
 12#include <QTimer>
 13
 14#include <functional>
 15
 16extern "C" {
 17#include "gba/gba.h"
 18}
 19
 20#include "GDBController.h"
 21#include "Display.h"
 22#include "InputController.h"
 23#include "LoadSaveState.h"
 24
 25struct GBAOptions;
 26struct GBAArguments;
 27
 28namespace QGBA {
 29
 30class ConfigController;
 31class GameController;
 32class GIFView;
 33class LogView;
 34class ShortcutController;
 35class VideoView;
 36class WindowBackground;
 37
 38class Window : public QMainWindow {
 39Q_OBJECT
 40
 41public:
 42	Window(ConfigController* config, int playerId = 0, QWidget* parent = nullptr);
 43	virtual ~Window();
 44
 45	GameController* controller() { return m_controller; }
 46
 47	void setConfig(ConfigController*);
 48	void argumentsPassed(GBAArguments*);
 49
 50	void resizeFrame(int width, int height);
 51
 52signals:
 53	void startDrawing(const uint32_t*, GBAThread*);
 54	void shutdown();
 55	void audioBufferSamplesChanged(int samples);
 56	void fpsTargetChanged(float target);
 57
 58public slots:
 59	void selectROM();
 60	void selectBIOS();
 61	void selectPatch();
 62	void enterFullScreen();
 63	void exitFullScreen();
 64	void toggleFullScreen();
 65	void loadConfig();
 66	void saveConfig();
 67
 68	void openKeymapWindow();
 69	void openSettingsWindow();
 70	void openShortcutWindow();
 71
 72	void openOverrideWindow();
 73	void openSensorWindow();
 74	void openCheatsWindow();
 75
 76#ifdef BUILD_SDL
 77	void openGamepadWindow();
 78#endif
 79
 80#ifdef USE_FFMPEG
 81	void openVideoWindow();
 82#endif
 83
 84#ifdef USE_MAGICK
 85	void openGIFWindow();
 86#endif
 87
 88#ifdef USE_GDB_STUB
 89	void gdbOpen();
 90#endif
 91
 92protected:
 93	virtual void keyPressEvent(QKeyEvent* event) override;
 94	virtual void keyReleaseEvent(QKeyEvent* event) override;
 95	virtual void resizeEvent(QResizeEvent*) override;
 96	virtual void closeEvent(QCloseEvent*) override;
 97	virtual void focusOutEvent(QFocusEvent*) override;
 98	virtual void dragEnterEvent(QDragEnterEvent*) override;
 99	virtual void dropEvent(QDropEvent*) override;
100	virtual void mouseDoubleClickEvent(QMouseEvent*) override;
101
102private slots:
103	void gameStarted(GBAThread*);
104	void gameStopped();
105	void gameCrashed(const QString&);
106	void gameFailed();
107	void unimplementedBiosCall(int);
108
109	void recordFrame();
110	void showFPS();
111
112private:
113	static const int FPS_TIMER_INTERVAL = 2000;
114	static const int FRAME_LIST_SIZE = 120;
115
116	void setupMenu(QMenuBar*);
117	void openStateWindow(LoadSave);
118
119	void attachWidget(QWidget* widget);
120	void detachWidget(QWidget* widget);
121
122	void appendMRU(const QString& fname);
123	void updateMRU();
124
125	QAction* addControlledAction(QMenu* menu, QAction* action, const QString& name);
126
127	GameController* m_controller;
128	Display* m_display;
129	QList<QAction*> m_gameActions;
130	LogView* m_logView;
131	LoadSaveState* m_stateWindow;
132	WindowBackground* m_screenWidget;
133	QPixmap m_logo;
134	ConfigController* m_config;
135	InputController m_inputController;
136	QList<QDateTime> m_frameList;
137	QTimer m_fpsTimer;
138	QList<QString> m_mruFiles;
139	QMenu* m_mruMenu;
140	ShortcutController* m_shortcutController;
141	int m_playerId;
142
143	bool m_hitUnimplementedBiosCall;
144
145#ifdef USE_FFMPEG
146	VideoView* m_videoView;
147#endif
148
149#ifdef USE_MAGICK
150	GIFView* m_gifView;
151#endif
152
153#ifdef USE_GDB_STUB
154	GDBController* m_gdbController;
155#endif
156};
157
158class WindowBackground : public QLabel {
159Q_OBJECT
160
161public:
162	WindowBackground(QWidget* parent = 0);
163
164	void setSizeHint(const QSize& size);
165	virtual QSize sizeHint() const override;
166	void setLockAspectRatio(int width, int height);
167
168protected:
169	virtual void paintEvent(QPaintEvent*) override;
170
171private:
172	QSize m_sizeHint;
173	int m_aspectWidth;
174	int m_aspectHeight;
175};
176
177}
178
179#endif