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 #include "GDCore/Project/VariablesContainer.h"
12 namespace gd {
13 class Instruction;
14 class Project;
15 }
16 
17 namespace gd {
18 
27 class GD_CORE_API WhileEvent : public gd::BaseEvent {
28  public:
29  WhileEvent()
30  : infiniteLoopWarning(true),
31  justCreatedByTheUser(true),
32  variables(gd::VariablesContainer::SourceType::Local){};
33  virtual ~WhileEvent(){};
34  virtual gd::WhileEvent* Clone() const { return new WhileEvent(*this); }
35 
36  virtual bool IsExecutable() const { return true; }
37 
38  virtual bool CanHaveSubEvents() const { return true; }
39  virtual const gd::EventsList& GetSubEvents() const { return events; };
40  virtual gd::EventsList& GetSubEvents() { return events; };
41 
42  virtual bool CanHaveVariables() const { return true; }
43  virtual const gd::VariablesContainer& GetVariables() const {
44  return variables;
45  };
46  virtual gd::VariablesContainer& GetVariables() { return variables; };
47 
48  const gd::InstructionsList& GetConditions() const { return conditions; };
49  gd::InstructionsList& GetConditions() { return conditions; };
50 
51  const gd::InstructionsList& GetActions() const { return actions; };
52  gd::InstructionsList& GetActions() { return actions; };
53 
54  virtual gd::InstructionsList* GetInstructionList(const gd::String& label) override;
55  virtual const gd::InstructionsList* GetInstructionList(const gd::String& label) const override;
56 
57  const gd::InstructionsList& GetWhileConditions() const {
58  return whileConditions;
59  };
60  gd::InstructionsList& GetWhileConditions() { return whileConditions; };
61  void SetWhileConditions(gd::InstructionsList& whileConditions_) {
62  whileConditions = whileConditions_;
63  };
64 
65  bool HasInfiniteLoopWarning() const { return infiniteLoopWarning; }
66 
67  const gd::String& GetLoopIndexVariableName() const { return loopIndexVariableName; }
68  void SetLoopIndexVariableName(const gd::String& name) { loopIndexVariableName = name; }
69 
70  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
71  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
72  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
73  const;
74  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
75 
76  virtual void SerializeTo(SerializerElement& element) const;
77  virtual void UnserializeFrom(gd::Project& project,
78  const SerializerElement& element);
79 
80  private:
81  gd::InstructionsList whileConditions;
82  gd::InstructionsList conditions;
83  gd::InstructionsList actions;
84  EventsList events;
85  bool infiniteLoopWarning;
87  bool justCreatedByTheUser;
90  gd::VariablesContainer variables;
91  gd::String loopIndexVariableName;
92 
93  int GetConditionsHeight() const;
94  int GetActionsHeight() const;
95  int GetWhileConditionsHeight() const;
96 };
97 
98 } // namespace gd
99 
100 #endif // GDCORE_WHILEEVENT_H
Base class defining an event.
Definition: Event.h:43
A list of events.
Definition: EventsList.h:32
Definition: InstructionsList.h:25
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:51
String represents an UTF8 encoded string.
Definition: String.h:33
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:29
While event is a standard event that is repeated while some conditions are true.
Definition: WhileEvent.h:27
virtual bool IsExecutable() const
Definition: WhileEvent.h:36
virtual gd::EventsList & GetSubEvents()
Definition: WhileEvent.h:40
virtual bool CanHaveVariables() const
Definition: WhileEvent.h:42
virtual gd::VariablesContainer & GetVariables()
Definition: WhileEvent.h:46
virtual const gd::EventsList & GetSubEvents() const
Definition: WhileEvent.h:39
virtual bool CanHaveSubEvents() const
Definition: WhileEvent.h:38
virtual const gd::VariablesContainer & GetVariables() const
Definition: WhileEvent.h:43
virtual gd::WhileEvent * Clone() const
Definition: WhileEvent.h:34
Definition: CommonTools.h:24