-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.h
144 lines (113 loc) · 3 KB
/
app.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef APP_H
#define APP_H
#include <memory>
#include <QObject>
#include <QElapsedTimer>
#include <QTimer>
#include "mainwindow.h"
#include "renderer.h"
#include "world.h"
#include "soundmanager.h"
#include "soundlistener.h"
#include "scriptsystem.h"
class InputHandler;
class InputSystem;
class CameraComponent;
/**
* @brief The creator of all things. This is the main class holding both the UI and the World, connecting them wherever necessary.
*/
class App : public QObject
{
Q_OBJECT
private:
// Settings
float FOV = 45.f;
public:
App();
~App();
signals:
void initScene();
public slots:
/**
* @brief Called after the renderer has created its context.
*/
void initTheRest();
/**
* @brief Global mute.
*/
void toggleMute(bool mode);
/**
* @brief Called when left clicking anywhere in the renderwindow.
*/
void mousePicking();
/**
* @brief Automatic temp save feature. Called when quitting or playing in editor.
*/
void saveSession();
private slots:
/**
* @brief The main update loop.
*/
void update();
/**
* @brief Quits the application.
*/
void quit();
/**
* @brief Calculates new perspective matrix for the cameras.
*/
void updatePerspective();
/**
* @brief Called when play is pressed.
*/
void onPlay();
/**
* @brief Called when stop is pressed.
*/
void onStop();
/**
* @brief Creates a new base scene with only a game camera and some lights.
*/
void newScene();
/**
* @brief Loads the scene at the given path.
*/
void loadScene(const std::string& path);
/**
* @brief Saves the scene to the given path.
*/
void saveScene(const std::string& path);
private:
/**
* @brief Initialize postprocessor based on settings in postprocessorsettings.json
*/
void initPostprocessorSettings();
std::map<std::string, ShaderParamType> retreiveParameters(QJsonObject object);
/**
* @brief Used to update the default settings file. Only called when changes to the file should be made.
*/
void writeDefaultPostprocessorSettings();
/**
* @brief Calculates the current FPS and time between frames using delta time and frame counting.
*/
void calculateFrames();
std::unique_ptr<MainWindow> mMainWindow;
Renderer* mRenderer;
InputSystem* mInputSystem;
std::unique_ptr<SoundManager> mSoundManager;
std::unique_ptr<SoundListener> mSoundListener;
// Handles input events in Renderer
std::shared_ptr<InputHandler> mEventHandler;
std::unique_ptr<World> mWorld;
std::unique_ptr<ResourceManager> mResourceManager;
void loadSession(const std::string& path);
QTimer mUpdateTimer; // Calls update
float mDeltaTime;
float mTotalDeltaTime;
QElapsedTimer mDeltaTimer;
QElapsedTimer mFPSTimer;
int mFrameCounter = 0;
bool currentlyUpdating = false;
bool mCurrentlyPlaying = false;
};
#endif // APP_H