Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #ifndef INCLUDED_VIEW
19 : #define INCLUDED_VIEW
20 :
21 : #include <map>
22 :
23 : #include "graphics/Camera.h"
24 : #include "maths/Rect.h"
25 :
26 : #include "Messages.h"
27 : #include "simulation2/system/Entity.h"
28 :
29 : class CCanvas2D;
30 : class CUnit;
31 : class CSimulation2;
32 :
33 : class AtlasViewGame;
34 : class AtlasViewActor;
35 :
36 : /**
37 : * Superclass for all Atlas game views.
38 : */
39 0 : class AtlasView
40 : {
41 : public:
42 : virtual ~AtlasView();
43 0 : virtual void Update(float UNUSED(realFrameLength)) { };
44 0 : virtual void Render() { };
45 0 : virtual void DrawCinemaPathTool() { };
46 0 : virtual void DrawOverlays(CCanvas2D& UNUSED(canvas)) { };
47 : virtual CCamera& GetCamera() = 0;
48 0 : virtual CSimulation2* GetSimulation2() { return NULL; }
49 0 : virtual entity_id_t GetEntityId(AtlasMessage::ObjectID obj) { return (entity_id_t)obj; }
50 0 : virtual bool WantsHighFramerate() { return false; }
51 0 : virtual void SetEnabled(bool UNUSED(enabled)) {}
52 :
53 : virtual void SetParam(const std::wstring& name, bool value);
54 : virtual void SetParam(const std::wstring& name, int value);
55 0 : virtual void SetParam(const std::wstring& UNUSED(name), float UNUSED(value)) {}
56 : virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value);
57 : virtual void SetParam(const std::wstring& name, const std::wstring& value);
58 :
59 : // These always return a valid (not NULL) object
60 : static AtlasView* GetView(int /*eRenderView*/ view);
61 : static AtlasView* GetView_None();
62 : static AtlasViewGame* GetView_Game();
63 : static AtlasViewActor* GetView_Actor();
64 :
65 : // Invalidates any AtlasView objects previously returned by this class
66 : static void DestroyViews();
67 : };
68 :
69 : //////////////////////////////////////////////////////////////////////////
70 :
71 0 : class AtlasViewNone : public AtlasView
72 : {
73 : public:
74 0 : virtual CCamera& GetCamera() { return dummyCamera; }
75 : private:
76 : CCamera dummyCamera;
77 : };
78 :
79 : //////////////////////////////////////////////////////////////////////////
80 :
81 : class SimState;
82 :
83 : /**
84 : * Main editor/game view of Atlas. Editing the world/scenario and simulation testing happens here.
85 : */
86 : class AtlasViewGame : public AtlasView
87 : {
88 : public:
89 : AtlasViewGame();
90 : virtual ~AtlasViewGame();
91 : virtual void Update(float realFrameLength);
92 : virtual void Render();
93 : virtual void DrawCinemaPathTool();
94 : virtual void DrawOverlays(CCanvas2D& canvas);
95 : virtual CCamera& GetCamera();
96 : virtual CSimulation2* GetSimulation2();
97 : virtual bool WantsHighFramerate();
98 :
99 : virtual void SetParam(const std::wstring& name, bool value);
100 : virtual void SetParam(const std::wstring& name, float value);
101 : virtual void SetParam(const std::wstring& name, const std::wstring& value);
102 :
103 : void SetSpeedMultiplier(float speedMultiplier);
104 : void SetTesting(bool testing);
105 : void SaveState(const std::wstring& label);
106 : void RestoreState(const std::wstring& label);
107 : std::wstring DumpState(bool binary);
108 : void SetBandbox(bool visible, float x0, float y0, float x1, float y1);
109 :
110 : private:
111 : float m_SpeedMultiplier;
112 : bool m_IsTesting;
113 : std::map<std::wstring, SimState*> m_SavedStates;
114 : std::string m_DisplayPassability;
115 :
116 : CRect m_Bandbox;
117 : bool m_DrawMoveTool;
118 : CVector3D m_MoveTool;
119 : };
120 :
121 : //////////////////////////////////////////////////////////////////////////
122 :
123 : class ActorViewer;
124 :
125 : /**
126 : * Actor Viewer window in Atlas. Dedicated view for examining a single actor/entity and its variations,
127 : * animations, etc. in more detail.
128 : */
129 : class AtlasViewActor : public AtlasView
130 : {
131 : public:
132 : AtlasViewActor();
133 : ~AtlasViewActor();
134 :
135 : virtual void Update(float realFrameLength);
136 : virtual void Render();
137 : virtual CCamera& GetCamera();
138 : virtual CSimulation2* GetSimulation2();
139 : virtual entity_id_t GetEntityId(AtlasMessage::ObjectID obj);
140 : virtual bool WantsHighFramerate();
141 : virtual void SetEnabled(bool enabled);
142 :
143 : virtual void SetParam(const std::wstring& name, bool value);
144 : virtual void SetParam(const std::wstring& name, int value);
145 : virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value);
146 :
147 : void SetSpeedMultiplier(float speedMultiplier);
148 : ActorViewer& GetActorViewer();
149 :
150 : private:
151 : float m_SpeedMultiplier;
152 : CCamera m_Camera;
153 : ActorViewer* m_ActorViewer;
154 : };
155 :
156 : #endif // INCLUDED_VIEW
|