GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Public Member Functions | Public Attributes | List of all members

Base class defining an event. More...

#include <Event.h>

Inherited by gd::CommentEvent, gd::EmptyEvent, gd::ForEachEvent, gd::GroupEvent, gd::LinkEvent, gd::RepeatEvent, gd::StandardEvent, and gd::WhileEvent.

Public Member Functions

virtual gd::BaseEventClone () const
 
Event properties

Members functions to be overridden by derived classes to expose the event properties

virtual bool IsExecutable () const
 
virtual bool CanHaveSubEvents () const
 
virtual const gd::EventsListGetSubEvents () const
 
virtual gd::EventsListGetSubEvents ()
 
bool HasSubEvents () const
 Return true if the events has sub events. More...
 
virtual std::vector
< gd::InstructionsList * > 
GetAllConditionsVectors ()
 Return a list of all conditions of the event. More...
 
virtual std::vector< const
gd::InstructionsList * > 
GetAllConditionsVectors () const
 
virtual std::vector
< gd::InstructionsList * > 
GetAllActionsVectors ()
 Return a list of all actions of the event. More...
 
virtual std::vector< const
gd::InstructionsList * > 
GetAllActionsVectors () const
 
virtual std::vector< gd::StringGetAllSearchableStrings () const
 Return a list of all strings of the event. More...
 
virtual std::vector
< gd::Expression * > 
GetAllExpressions ()
 Return a list of all expressions of the event. More...
 
virtual std::vector< const
gd::Expression * > 
GetAllExpressions () const
 
virtual const std::vector
< gd::String > & 
GetSourceFileDependencies () const
 Returns the dependencies on source files of the project. More...
 
virtual const gd::StringGetAssociatedGDManagedSourceFile (gd::Project &project) const
 Returns the name of the source file associated with the event. More...
 
Code generation

Members functions used to generate code from the event

virtual gd::String GenerateEventCode (gd::EventsCodeGenerator &codeGenerator, gd::EventsCodeGenerationContext &context)
 Generate the code event: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to generate the code event. More...
 
virtual void Preprocess (gd::EventsCodeGenerator &codeGenerator, gd::EventsList &eventList, std::size_t indexOfTheEventInThisList)
 
virtual bool MustBePreprocessed ()
 If MustBePreprocessed is redefined to return true, the gd::EventMetadata::preprocessing associated to the event will be called to preprocess the event. More...
 
Serialization
virtual void SerializeTo (SerializerElement &element) const
 Serialize event.
 
virtual void UnserializeFrom (gd::Project &project, const SerializerElement &element)
 Unserialize the event.
 
Common properties

Common method shared by all events. ( No need for them to be overridden by derived classes ).

const gd::StringGetType () const
 Return the event type.
 
void SetType (gd::String type_)
 Change the event type.
 
void SetDisabled (bool disable=true)
 Set if the event if disabled or not.
 
bool IsDisabled () const
 True if event is disabled.
 
void SetFolded (bool fold=true)
 Set if the event must be folded (i.e: sub events must be hidden in the events editor).
 
bool IsFolded () const
 True if the event should be folded in the events editor.
 

Public Attributes

std::weak_ptr< gd::BaseEventoriginalEvent
 
signed long long totalTimeDuringLastSession
 
float percentDuringLastSession
 

Detailed Description

Base class defining an event.

Events are usually not instance of Base Event, but instance of a derived class.

Member Function Documentation

virtual bool gd::BaseEvent::CanHaveSubEvents ( ) const
inlinevirtual

Derived class have to redefine this function, so as to return true, if they have sub events.

Reimplemented in gd::GroupEvent, gd::WhileEvent, gd::ForEachEvent, gd::StandardEvent, and gd::RepeatEvent.

virtual gd::BaseEvent* gd::BaseEvent::Clone ( ) const
inlinevirtual

Must return a pointer to a copy of the event. A such method is needed as the IDE may want to store copies of some events and so need a way to do polymorphic copies.

Typical implementation example:

return new MyEventClass(*this);

Reimplemented in gd::LinkEvent, gd::WhileEvent, gd::ForEachEvent, gd::GroupEvent, gd::StandardEvent, gd::CommentEvent, and gd::RepeatEvent.

gd::String gd::BaseEvent::GenerateEventCode ( gd::EventsCodeGenerator codeGenerator,
gd::EventsCodeGenerationContext context 
)
virtual

Generate the code event: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to generate the code event.

Warning
Even if this method is virtual, you should never redefine it: always provide the code generation using gd::EventMetadata. This method is virtual as some platforms could have hidden events (such as profiling events) needing code generation without declaring the event as a part of an extension.
See also
gd::EventMetadata
virtual std::vector<gd::InstructionsList*> gd::BaseEvent::GetAllActionsVectors ( )
inlinevirtual

Return a list of all actions of the event.

Note
Used to preprocess or search in the actions.

Reimplemented in gd::ForEachEvent, gd::WhileEvent, gd::RepeatEvent, and gd::StandardEvent.

virtual std::vector<gd::InstructionsList*> gd::BaseEvent::GetAllConditionsVectors ( )
inlinevirtual

Return a list of all conditions of the event.

Note
Used to preprocess or search in the conditions.

Reimplemented in gd::ForEachEvent, gd::WhileEvent, gd::RepeatEvent, and gd::StandardEvent.

virtual std::vector<gd::Expression*> gd::BaseEvent::GetAllExpressions ( )
inlinevirtual

Return a list of all expressions of the event.

Note
Used to preprocess or search in the expressions.

Reimplemented in gd::ForEachEvent, and gd::RepeatEvent.

virtual std::vector<gd::String> gd::BaseEvent::GetAllSearchableStrings ( ) const
inlinevirtual

Return a list of all strings of the event.

Note
Used to preprocess or search in the event strings.

Reimplemented in gd::GroupEvent, and gd::CommentEvent.

virtual const gd::String& gd::BaseEvent::GetAssociatedGDManagedSourceFile ( gd::Project project) const
inlinevirtual

Returns the name of the source file associated with the event.

Note
Default implementation returns an empty string. This is fine for most events that are not related to adding custom user source code.
virtual const std::vector<gd::String>& gd::BaseEvent::GetSourceFileDependencies ( ) const
inlinevirtual

Returns the dependencies on source files of the project.

Note
Default implementation returns an empty list of dependencies. This is fine for most events that are not related to adding custom user source code.
virtual const gd::EventsList& gd::BaseEvent::GetSubEvents ( ) const
inlinevirtual

Return the sub events, if applicable.

Reimplemented in gd::GroupEvent, gd::WhileEvent, gd::ForEachEvent, gd::StandardEvent, and gd::RepeatEvent.

virtual gd::EventsList& gd::BaseEvent::GetSubEvents ( )
inlinevirtual

Return the sub events, if applicable.

Reimplemented in gd::GroupEvent, gd::WhileEvent, gd::ForEachEvent, gd::StandardEvent, and gd::RepeatEvent.

bool gd::BaseEvent::HasSubEvents ( ) const

Return true if the events has sub events.

Warning
This is only applicable when CanHaveSubEvents() return true.
virtual bool gd::BaseEvent::IsExecutable ( ) const
inlinevirtual

Derived class have to redefine this function, so as to return true, if they are executable.

Reimplemented in gd::LinkEvent, gd::WhileEvent, gd::ForEachEvent, gd::GroupEvent, gd::StandardEvent, and gd::RepeatEvent.

virtual bool gd::BaseEvent::MustBePreprocessed ( )
inlinevirtual

If MustBePreprocessed is redefined to return true, the gd::EventMetadata::preprocessing associated to the event will be called to preprocess the event.

See also
gd::BaseEvent::Preprocess
gd::EventMetadata

Reimplemented in gd::LinkEvent.

void gd::BaseEvent::Preprocess ( gd::EventsCodeGenerator codeGenerator,
gd::EventsList eventList,
std::size_t  indexOfTheEventInThisList 
)
virtual

Called before events are compiled: the platform provided by codeGenerator is asked for the EventMetadata associated to the event, which is then used to preprocess the event.

This is only done if the event MustBePreprocessed() return true.

Warning
Be careful if you're iterating over a list of event, a call to Preprocess can remove the event from the list!
See also
gd::EventMetadata
gd::BaseEvent::MustBePreprocessed

Member Data Documentation

std::weak_ptr<gd::BaseEvent> gd::BaseEvent::originalEvent

Pointer only used for profiling events, so as to remember the original event from which it has been copied.

float gd::BaseEvent::percentDuringLastSession

Total time used by the event during the last run. Used for profiling.

signed long long gd::BaseEvent::totalTimeDuringLastSession

Total time, in microseconds, used by the event during the last run. Used for profiling.


The documentation for this class was generated from the following files: