GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ForEachEvent.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 FOREACHEVENT_H
8 #define FOREACHEVENT_H
9 #include <vector>
10 
11 #include "GDCore/Events/Event.h"
12 #include "GDCore/Events/EventsList.h"
13 namespace gd {
14 class Instruction;
15 class Project;
16 class Layout;
17 }
18 
19 namespace gd {
20 
27 class GD_CORE_API ForEachEvent : public gd::BaseEvent {
28  public:
29  ForEachEvent();
30  virtual ~ForEachEvent(){};
31  virtual gd::ForEachEvent* Clone() const { return new ForEachEvent(*this); }
32 
33  virtual bool IsExecutable() const { return true; }
34 
35  virtual bool CanHaveSubEvents() const { return true; }
36  virtual const gd::EventsList& GetSubEvents() const { return events; };
37  virtual gd::EventsList& GetSubEvents() { return events; };
38 
39  const gd::InstructionsList& GetConditions() const { return conditions; };
40  gd::InstructionsList& GetConditions() { return conditions; };
41 
42  const gd::InstructionsList& GetActions() const { return actions; };
43  gd::InstructionsList& GetActions() { return actions; };
44 
45  const gd::String& GetObjectToPick() const {
46  return objectsToPick.GetPlainString();
47  };
48  void SetObjectToPick(gd::String objectsToPick_) {
49  objectsToPick = gd::Expression(objectsToPick_);
50  };
51 
52  virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
53  const;
54  virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
55  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
56  GetAllExpressionsWithMetadata() const;
57 
58  virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
59  virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
60  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
61  GetAllExpressionsWithMetadata();
62 
63  virtual void SerializeTo(SerializerElement& element) const;
64  virtual void UnserializeFrom(gd::Project& project,
65  const SerializerElement& element);
66 
67  private:
68  gd::Expression objectsToPick;
69  gd::InstructionsList conditions;
70  gd::InstructionsList actions;
71  gd::EventsList events;
72 };
73 
74 } // namespace gd
75 
76 #endif // FOREACHEVENT_H
Base class defining an event.
Definition: Event.h:44
A list of events.
Definition: EventsList.h:33
Class representing an expression used as a parameter of a gd::Instruction. This class is nothing more...
Definition: Expression.h:30
Event repeated for each object of a list.
Definition: ForEachEvent.h:27
virtual gd::EventsList & GetSubEvents()
Definition: ForEachEvent.h:37
virtual bool IsExecutable() const
Definition: ForEachEvent.h:33
virtual const gd::EventsList & GetSubEvents() const
Definition: ForEachEvent.h:36
virtual gd::ForEachEvent * Clone() const
Definition: ForEachEvent.h:31
virtual bool CanHaveSubEvents() const
Definition: ForEachEvent.h:35
Definition: InstructionsList.h:25
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:50
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24