GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
LinkEvent.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 #ifndef GDCORE_LINKEVENT_H
7 #define GDCORE_LINKEVENT_H
8 #include "GDCore/Events/Event.h"
9 #include "GDCore/String.h"
10 
11 namespace gd {
12 
17 class GD_CORE_API LinkEvent : public gd::BaseEvent {
18  public:
19  enum IncludeConfig {
20  INCLUDE_ALL = 0,
21  INCLUDE_EVENTS_GROUP = 1,
22  INCLUDE_BY_INDEX = 2 // Deprecated
23  };
24 
25  LinkEvent()
26  : BaseEvent(),
27  includeConfig(INCLUDE_ALL),
28  eventsGroupName(),
29  includeStart(gd::String::npos),
30  includeEnd(gd::String::npos),
31  linkWasInvalid(false){};
32  virtual ~LinkEvent();
33  virtual gd::LinkEvent* Clone() const override { return new LinkEvent(*this); }
34 
38  const gd::String& GetTarget() const { return target; };
39 
44  void SetTarget(const gd::String& target_) { target = target_; };
45 
49  IncludeConfig GetIncludeConfig() const { return includeConfig; }
50 
54  void SetIncludeAllEvents() { includeConfig = INCLUDE_ALL; }
55 
56  void SetIncludeEventsGroup(const gd::String& name) {
57  includeConfig = INCLUDE_EVENTS_GROUP;
58  eventsGroupName = name;
59  }
60 
65  void SetIncludeStartAndEnd(std::size_t includeStart_,
66  std::size_t includeEnd_) {
67  includeConfig = INCLUDE_BY_INDEX;
68  includeStart = includeStart_;
69  includeEnd = includeEnd_;
70  }
71 
72  gd::String GetEventsGroupName() const { return eventsGroupName; }
73 
78  std::size_t GetIncludeStart() const { return includeStart; };
79 
84  std::size_t GetIncludeEnd() const { return includeEnd; };
85 
89  virtual bool MustBePreprocessed() override { return true; }
90 
98  const EventsList* GetLinkedEvents(const gd::Project& project) const;
99 
106  void ReplaceLinkByLinkedEvents(const gd::Project& project,
107  EventsList& eventList,
108  std::size_t indexOfTheEventInThisList);
109 
110  virtual bool IsExecutable() const override { return true; };
111 
112  virtual void SerializeTo(SerializerElement& element) const override;
113  virtual void UnserializeFrom(gd::Project& project,
114  const SerializerElement& element) override;
115 
116  bool AcceptVisitor(gd::EventVisitor& eventVisitor) override;
117  void AcceptVisitor(gd::ReadOnlyEventVisitor& eventVisitor) const override;
118 
119  private:
120  gd::String
121  target;
122 
123  IncludeConfig
124  includeConfig;
125 
126  gd::String eventsGroupName;
129 
130  std::size_t includeStart;
133  std::size_t
134  includeEnd;
136 
137  bool linkWasInvalid;
140 };
141 
142 } // namespace gd
143 
144 #endif // GDCORE_LINKEVENT_H
Base class defining an event.
Definition: Event.h:43
Visitor of any kind of event.
Definition: EventVisitor.h:26
A list of events.
Definition: EventsList.h:32
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:51
Visitor of any kind of event.
Definition: EventVisitor.h:54
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24