GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
WhileEvent.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #ifndef GDCORE_WHILEEVENT_H
8 #define GDCORE_WHILEEVENT_H
9 #include "GDCore/Events/Event.h"
10 #include "GDCore/Events/EventsList.h"
11 namespace gd {
12 class Instruction;
13 class Project;
14 }
15 
16 namespace gd {
17 
26 class GD_CORE_API WhileEvent : public gd::BaseEvent {
27  public:
28  WhileEvent() : infiniteLoopWarning(true), justCreatedByTheUser(true){};
29  virtual ~WhileEvent(){};
30  virtual gd::WhileEvent* Clone() const { return new WhileEvent(*this); }
31 
32  virtual bool IsExecutable() const { return true; }
33 
34  virtual bool CanHaveSubEvents() const { return true; }
35  virtual const gd::EventsList& GetSubEvents() const { return events; };
36  virtual gd::EventsList& GetSubEvents() { return events; };
37 
38  const gd::InstructionsList& GetConditions() const { return conditions; };
39  gd::InstructionsList& GetConditions() { return conditions; };
40 
41  const gd::InstructionsList& GetActions() const { return actions; };
42  gd::InstructionsList& GetActions() { return actions; };
43 
44  const gd::InstructionsList& GetWhileConditions() const {
45  return whileConditions;
46  };
47  gd::InstructionsList& GetWhileConditions() { return whileConditions; };
48  void SetWhileConditions(gd::InstructionsList& whileConditions_) {
49  whileConditions = whileConditions_;
50  };
51 
52  bool HasInfiniteLoopWarning() const { return infiniteLoopWarning; }
53 
54  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
55  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
56  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
57  const;
58  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
59 
60  virtual void SerializeTo(SerializerElement& element) const;
61  virtual void UnserializeFrom(gd::Project& project,
62  const SerializerElement& element);
63 
64  private:
65  gd::InstructionsList whileConditions;
66  gd::InstructionsList conditions;
67  gd::InstructionsList actions;
68  EventsList events;
69  bool infiniteLoopWarning;
71  bool justCreatedByTheUser;
74 
75  mutable unsigned int whileConditionsHeight;
76 
77  int GetConditionsHeight() const;
78  int GetActionsHeight() const;
79  int GetWhileConditionsHeight() const;
80 };
81 
82 } // namespace gd
83 
84 #endif // GDCORE_WHILEEVENT_H
Base class defining an event.
Definition: Event.h:44
A list of events.
Definition: EventsList.h:33
Definition: InstructionsList.h:25
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
While event is a standard event that is repeated while some conditions are true.
Definition: WhileEvent.h:26
virtual bool IsExecutable() const
Definition: WhileEvent.h:32
virtual gd::EventsList & GetSubEvents()
Definition: WhileEvent.h:36
virtual const gd::EventsList & GetSubEvents() const
Definition: WhileEvent.h:35
virtual bool CanHaveSubEvents() const
Definition: WhileEvent.h:34
virtual gd::WhileEvent * Clone() const
Definition: WhileEvent.h:30
Definition: CommonTools.h:24