Game Develop Core: Event.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Event.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_EVENT_H
6 #define GDCORE_EVENT_H
7
8 #include <iostream>
9 #include <vector>
10 #include <string>
11 #include <vector>
12 #include <boost/shared_ptr.hpp>
13 #include <boost/weak_ptr.hpp>
14 #include "GDCore/Events/Instruction.h"
15 namespace gd { class MainFrameWrapper; }
16 namespace gd { class Project; }
17 namespace gd { class Layout; }
18 namespace gd { class EventsCodeGenerator; }
19 namespace gd { class EventsCodeGenerationContext; }
20 namespace gd { class Platform; }
21 class wxWindow;
22 namespace gd { class EventsEditorItemsAreas; }
23 namespace gd { class EventsEditorSelection; }
24 namespace gd { class Instruction; }
25 class TiXmlElement;
26 class wxDC;
27
28 namespace gd
29 {
30
31 class BaseEvent;
32 typedef boost::shared_ptr<BaseEvent> BaseEventSPtr;
33
41 class GD_CORE_API BaseEvent
42 {
43 public:
44 BaseEvent();
45 virtual ~BaseEvent() {};
46
56 virtual gd::BaseEventSPtr Clone() const { return boost::shared_ptr<gd::BaseEvent>(new BaseEvent(*this));}
57
61
66 virtual bool IsExecutable() const {return false;};
67
71 virtual bool CanHaveSubEvents() const {return false;}
72
76 virtual const std::vector < gd::BaseEventSPtr > & GetSubEvents() const {return badSubEvents;};
77
81 virtual std::vector < gd::BaseEventSPtr > & GetSubEvents() {return badSubEvents;};
82
87 bool HasSubEvents() const { return !GetSubEvents().empty(); }
88
93 virtual std::vector < std::vector<Instruction>* > GetAllConditionsVectors() { std::vector < std::vector<Instruction>* > noConditions; return noConditions; };
94
99 virtual std::vector < std::vector<Instruction>* > GetAllActionsVectors() { std::vector < std::vector<Instruction>* > noActions; return noActions; };
100
105 virtual std::vector < gd::Expression* > GetAllExpressions() { std::vector < gd::Expression* > noExpr; return noExpr;};
106
108
112
124 virtual std::string GenerateEventCode(gd::EventsCodeGenerator & codeGenerator, gd::EventsCodeGenerationContext & context);
125
137 virtual void Preprocess(gd::EventsCodeGenerator & codeGenerator, std::vector < gd::BaseEventSPtr > & eventList, unsigned int indexOfTheEventInThisList);
138
146 virtual bool MustBePreprocessed() { return false;}
148
151
156 virtual void SaveToXml(TiXmlElement * eventElem) const {}
157
161 virtual void LoadFromXml(gd::Project & project, const TiXmlElement * eventElem) {}
162
164
168
173 std::string GetType() const { return type; };
174
178 void SetType(std::string type_) { type = type_; };
179
183 void SetDisabled(bool disable = true) { disabled = disable; }
184
188 bool IsDisabled() const { return disabled; }
189
191
195
213 virtual void Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform) {return;}
214
220 virtual unsigned int GetRenderedHeight(unsigned int width, const gd::Platform & platform) const {return 0;};
221
226 enum EditEventReturnType
227 {
228 ChangesMade,
229 Cancelled,
230 ChangesMadeButNoNeedForEventsRecompilation
231 };
232
236 virtual EditEventReturnType EditEvent(wxWindow* parent_, gd::Project & game_, gd::Layout & scene_, gd::MainFrameWrapper & mainFrameWrapper_) { return ChangesMade; };
237
239
240 bool folded;
241 mutable bool eventHeightNeedUpdate;
242
243 boost::weak_ptr<gd::BaseEvent> originalEvent;
244 signed long long totalTimeDuringLastSession;
245 float percentDuringLastSession;
246
247 protected:
248 mutable unsigned int renderedHeight;
249
250 private:
251 bool disabled;
252 std::string type;
253
254 static std::vector <BaseEventSPtr> badSubEvents;
255 };
256
264 BaseEventSPtr GD_CORE_API CloneRememberingOriginalEvent(gd::BaseEventSPtr event);
265
272 std::vector < gd::BaseEventSPtr > GD_CORE_API CloneVectorOfEvents(const std::vector < gd::BaseEventSPtr > & events);
273
278 class EmptyEvent : public BaseEvent
279 {
280 public:
281 EmptyEvent() : BaseEvent() {};
282 virtual ~EmptyEvent() {};
283 };
284
285 }
286
287 #endif // GDCORE_EVENT_H