blob: 54e1fb5f8533febe10d50362ad5909c8553c2ba4 (
plain)
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
|
#pragma once
#include "Camera.hpp"
#include "EditorCore.hpp"
#include "Player.hpp"
#include "PodVector.hpp"
#include "Renderer.hpp"
#include "World.hpp"
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include <deque>
#include <functional>
#include <memory>
#include <vector>
using KeyCaptureCallback = std::function<bool(int, int)>;
// TODO how should we split responsibilities between App and Editor?
class App {
friend class EditorInstance;
private:
std::deque<KeyCaptureCallback> mKeyCaptureCallbacks;
PodVector<Player*> mPlayers;
std::unique_ptr<EditorInstance> mEditor;
GameWorld mWorld;
Renderer mWorldRenderer;
Camera mMainCamera;
Camera* mActiveCamera;
// NOTE: should only be true when mEditor != nullptr
bool mEditorVisible = false;
bool mGameRunning = false;
public:
App();
~App();
EditorInstance* GetEditor() { return mEditor.get(); }
GameWorld* GetWorld() { return &mWorld; }
Camera* GetActiveCamera() const;
void BindActiveCamera(Camera* camera);
void UnbindActiveCamera();
bool IsGameRunning() const;
void SetGameRunning(bool running);
bool IsEditorVisible() const;
void SetEditorVisible(bool visible);
// Do ImGui calls
void Show();
// Do regular calls
void Update();
void Draw(float currentTime, float deltaTime);
void HandleMouse(int button, int action);
void HandleMouseMotion(double xOff, double yOff);
void HandleKey(GLFWkeyboard* keyboard, int key, int action);
void PushKeyCaptureCallback(KeyCaptureCallback callback);
};
|