Emulator/Emulator.hpp
1 #ifndef CPP3DS_EMULATOR_EMU_HPP
2 #define CPP3DS_EMULATOR_EMU_HPP
3 
4 #include <QtWidgets>
5 #include <SFML/Graphics.hpp>
6 #include <cpp3ds/Emulator/ui_emulator.h>
7 #include <cpp3ds/Emulator/SFMLWidget.hpp>
8 
9 #define EMU_OUTLINE_THICKNESS 1
10 
11 extern "C" int __real_main(int argc, char **argv);
12 
13 namespace cpp3ds {
14 
15 enum EmulatorState {
16  EMU_PLAYING,
17  EMU_PAUSED,
18  EMU_STOPPED
19 };
20 
21 class Emulator : public QMainWindow, private Ui::EmuWindow{
22  Q_OBJECT
23 private:
24  QSlider* slider3D;
25  QWidget* spacer;
26 
27  sf::Thread* thread;
28  sf::Mutex mutex;
29 
30  sf::Texture pausedFrameTexture;
31  sf::Sprite pausedFrame;
32 
33  EmulatorState state = EMU_STOPPED;
34 
35  bool initialized = false;
36 
37  void showEvent(QShowEvent *);
38  void runGame();
39  void checkThreadState();
40  void saveScreenshot();
41 
42  void drawPausedFrame();
43 
44 private slots:
45  void on_actionScreenshot_triggered(bool checked = false);
46  void on_actionToggle_3D_triggered(bool checked = false);
47  void on_actionPlay_Pause_triggered(bool checked = false);
48  void on_actionStop_triggered(bool checked = false);
49  void on_toolBar_orientationChanged(Qt::Orientation orientation);
50 
51 public:
52  QSFMLCanvas *screen;
53 
54  volatile bool isThreadRunning = false;
55 
56  Emulator(QWidget *parent = 0);
57  ~Emulator();
58  void run();
59  void play();
60  void pause();
61  void stop();
62  float get_slider3d();
63  void updatePausedFrame();
64 
65  EmulatorState getState(){ return state; }
66 };
67 
68 // Emulator global to be accessed in-game
69 extern Emulator* _emulator;
70 
71 }
72 
73 #endif
74