TazGraph Project v0.1.0
Loading...
Searching...
No Matches
IScene.h
1#pragma once
2
3#include "./ScreenIndices.h"
4#include "../DataManager/DataManager.h"
5
6#include "../GECS/Core/GECSManager.h"
7
8#define SCENE_INDEX_NO_SCENE -1
9
10class AppInterface;
11
12enum class SceneState {
13 NONE,
14 RUNNING,
15 EXIT_APPLICATION,
16 CHANGE_NEXT,
17 CHANGE_PREVIOUS
18};
19
20#define ON_HOVER 0
21#define CTRLD_LEFT_CLICK -1
22#define HOLD_TIME_FOR_SELECTION 1000
23#define SELECT_DISTANCE 300000.0f
24
25class IScene {
26public:
27 friend class SceneList;
28 IScene() {
29
30 }
31 virtual ~IScene() {
32
33 }
34
35 //Returns the index of the next or previous screen when changing screens
36 virtual int getNextSceneIndex() const = 0;
37 virtual int getPreviousSceneIndex() const = 0;
38
39 //Called at beginning and end of application
40 virtual void build() = 0;
41 virtual void destroy() = 0;
42
43 //Called when a screen enters and exits focus
44 virtual void onEntry() = 0;
45 virtual void onExit() = 0;
46
47 virtual void checkInput() = 0;
48
49 virtual void update(float deltaTime) = 0;
50 virtual void prepareDraw(int index) = 0;
51 virtual void renderDraw(int index) = 0;
52
53 virtual void SwapBufferDraw() = 0;
54
55 virtual void BeginRender() = 0;
56 virtual void updateUI(float deltaTime) = 0;
57 virtual void drawUI() = 0;
58 virtual void EndRender() = 0;
59
60 virtual void disposeRenderers(int index) {
61 frameDataBuffers[index].planeColorRenderer.dispose();
62 frameDataBuffers[index].lineRenderer.dispose();
63 frameDataBuffers[index].planeColorRenderer.dispose();
64 frameDataBuffers[index].lightRenderer.dispose();
65 };
66
67 int getSceneIndex() const {
68 return _sceneIndex;
69 }
70 void setRunning() {
71 currentState = SceneState::RUNNING;
72 }
73
74 SceneState getState() const { return currentState; }
75
76 void setParentApp(AppInterface* app) { _app = app; }
77
78 AppInterface* getApp() const { return _app; }
79
80 virtual bool setManager(std::string m_managerName) {
81 if (!m_managerName.empty()) {
82 auto it = managers.find(m_managerName);
83 if (it == managers.end()) {
84 managers[m_managerName] = new Manager();
85 }
86 editingManager = managers[m_managerName];
87 }
88 return false;
89 };
90
91 std::unordered_map<std::string, Manager*> managers = {
92 };
93
94 Manager* editingManager = nullptr; // Currently active (render thread uses this)
95 Manager* manager = nullptr;
96
97 bool last_renderDebug = false;
98 bool renderDebug = false;
99
100 bool showGrid = true;
101 bool last_showGrid = false;
102
103 SceneState currentState = SceneState::NONE;
104
105 float backgroundColor[4] = { 0.8f, 0.8f, 0.8f, 1.0f };
106
107 bool requestExit = false;
108
109 Taz::FrameRenderData frameDataBuffers[2];
110 Taz::FrameRenderData minimap_frameDataBuffers[2];
111
112protected:
113 AppInterface* _app = nullptr;
114 int _sceneIndex = -1;
115
116};
Definition AppInterface.h:20
Definition IScene.h:25
Definition GECSManager.h:20
Definition SceneList.h:9
Definition DataManager.h:15