aboutsummaryrefslogtreecommitdiff
path: root/ProjectBrussel/Game/App.hpp
blob: c73c5a15ec81cd8956b5167cfb6bfd62cd61bf13 (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
#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)>;

class App {
private:
	std::deque<KeyCaptureCallback> mKeyCaptureCallbacks;
	PodVector<Player*> mPlayers;
	std::unique_ptr<IEditor> 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();

	IEditor* GetEditor() { return mEditor.get(); }
	GameWorld* GetWorld() { return &mWorld; }
	Renderer* GetWorldRenderer() { return &mWorldRenderer; }

	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);
};