Game Develop Core: gd::BaseEvent Class Reference

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- Class List
- Class Index
- Class Hierarchy

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
gd::BaseEvent Class Reference
Events ( Classes defining the event system and some tools associated with events )

Base class defining an event. More...

`#include <Event.h>`

Inheritance diagram for gd::BaseEvent:
[legend]

## Public Member Functions

virtual gd::BaseEventSPtr | Clone () 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 std::vector < gd::BaseEventSPtr > & | GetSubEvents () const
virtual std::vector < gd::BaseEventSPtr > & | GetSubEvents ()
bool | HasSubEvents () const
| Return true if the events has sub events. More...
virtual std::vector < std::vector< Instruction > * > | GetAllConditionsVectors ()
virtual std::vector < std::vector< Instruction > * > | GetAllActionsVectors ()
virtual std::vector < gd::Expression * > | GetAllExpressions ()
Code generation
Members functions used to generate code from the event
virtual std::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 ( gd::EventMetadata::codeGeneration member ) More...
virtual void | Preprocess (gd::EventsCodeGenerator &codeGenerator, std::vector< gd::BaseEventSPtr > &eventList, unsigned int indexOfTheEventInThisList)
virtual bool | MustBePreprocessed ()
| If MustBePreprocessed is redefined to return true, the gd::EventMetadata::codeGeneration associated to the event will be called to preprocess the event. More...
Serialization
virtual void | SaveToXml (TiXmlElement *eventElem) const
virtual void | LoadFromXml (gd::Project &project, const TiXmlElement *eventElem)
Common properties
Common method shared by all events. ( No need for them to be overridden by derived classes ).
std::string | GetType () const
void | SetType (std::string type_)
void | SetDisabled (bool disable=true)
bool | IsDisabled () const

## Public Attributes

bool | folded
| Here as it must be saved. Used by events editor.
bool | eventHeightNeedUpdate
| Automatically set to true/false by the events editor.
boost::weak_ptr< gd::BaseEvent > | originalEvent
| Pointer only used for profiling events, so as to remember the original event from which it has been copied.
signed long long | totalTimeDuringLastSession
| Total time, in microseconds, used by the event during the last run. Used for profiling.
float | percentDuringLastSession
| Total time used by the event during the last run. Used for profiling.

## Protected Attributes

unsigned int | renderedHeight

## Event rendering

Method and members used to render the event
enum | EditEventReturnType { ChangesMade, Cancelled, ChangesMadeButNoNeedForEventsRecompilation }
virtual void | Render (wxDC &dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas &areas, gd::EventsEditorSelection &selection, const gd::Platform &platform)
virtual unsigned int | GetRenderedHeight (unsigned int width, const gd::Platform &platform) const
virtual EditEventReturnType | EditEvent (wxWindow *parent_, gd::Project &game_, gd::Layout &scene_, gd::MainFrameWrapper &mainFrameWrapper_)

## Detailed Description

Base class defining an event.

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

## Member Enumeration Documentation

enum gd::BaseEvent::EditEventReturnType

Used by EditEvent to describe what sort of changes have been made to the event.

See Also
  BaseEvent::EditEvent

## 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::ForEachEvent, gd::WhileEvent, gd::StandardEvent, and gd::RepeatEvent.

virtual gd::BaseEventSPtr 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 boost::shared_ptr<gd::BaseEvent>(new MyEventClass(*this));

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

virtual EditEventReturnType gd::BaseEvent::EditEvent | ( | wxWindow * | parent_,
|  | gd::Project & | game_,
|  | gd::Layout & | scene_,
|  | gd::MainFrameWrapper & | mainFrameWrapper_
| ) |  |

inlinevirtual

Called when the user want to edit the event.

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

std::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 ( gd::EventMetadata::codeGeneration member )

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< std::vector<Instruction>* > gd::BaseEvent::GetAllActionsVectors | ( | ) |  |

inlinevirtual

Event must be able to return all actions std::vector they have. Used to preprocess the actions.

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

virtual std::vector< std::vector<Instruction>* > gd::BaseEvent::GetAllConditionsVectors | ( | ) |  |

inlinevirtual

Event must be able to return all conditions std::vector they have. Used to preprocess the conditions.

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

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

inlinevirtual

Event must be able to return all expressions they have. Used to preprocess the expressions.

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

virtual unsigned int gd::BaseEvent::GetRenderedHeight | ( | unsigned int | width,
|  | const gd::Platform & | platform
| ) |  | const

inlinevirtual

Must return the height of the event when rendered.

Note
  The height of the drawing must be the same as the height of the drawing made by BaseEvent::Render

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

virtual const std::vector< gd::BaseEventSPtr >& gd::BaseEvent::GetSubEvents | ( | ) |  | const

inlinevirtual

Return the sub events, if applicable.

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

virtual std::vector< gd::BaseEventSPtr >& gd::BaseEvent::GetSubEvents | ( | ) |  |

inlinevirtual

Return the sub events, if applicable.

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

std::string gd::BaseEvent::GetType | ( | ) |  | const

inline

Return the event type

bool gd::BaseEvent::HasSubEvents | ( | ) |  | const

inline

Return true if the events has sub events.

Warning
  This is only applicable when CanHaveSubEvents() return true.

bool gd::BaseEvent::IsDisabled | ( | ) |  | const

inline

True if event is disabled

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::ForEachEvent, gd::WhileEvent, gd::StandardEvent, and gd::RepeatEvent.

virtual void gd::BaseEvent::LoadFromXml | ( | gd::Project & | project,
|  | const TiXmlElement * | eventElem
| ) |  |

inlinevirtual

Load event from XML

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

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

inlinevirtual

If MustBePreprocessed is redefined to return true, the gd::EventMetadata::codeGeneration 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,
|  | std::vector< gd::BaseEventSPtr > & | eventList,
|  | unsigned int | 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 ( gd::EventMetadata::codeGeneration member )

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

virtual void gd::BaseEvent::Render | ( | wxDC & | dc,
|  | int | x,
|  | int | y,
|  | unsigned int | width,
|  | gd::EventsEditorItemsAreas & | areas,
|  | gd::EventsEditorSelection & | selection,
|  | const gd::Platform & | platform
| ) |  |

inlinevirtual

Redefine this method to draw the event.

Parameters

  dc | The wxWidgets drawing context to be used.
  x | The x position where the events must be drawn.
  y | The y position where the events must be drawn.
  width | The width available for drawing.
  areas | Use this object to indicate the areas where items have been drawn
  selection | Give access to the current selection(s), to draw for example hovering or selecting effects.

Note
  The height of the drawing must be the same as the height returned by BaseEvent::GetRenderedHeight

See Also
  gd::EventsRenderingHelper
  EventsEditorSelection
  EventsEditorItemsAreas

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

virtual void gd::BaseEvent::SaveToXml | ( | TiXmlElement * | eventElem) |  | const

inlinevirtual

Save event to XML

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

void gd::BaseEvent::SetDisabled | ( | bool | disable = `true`) |  |

inline

Set if the event if disabled or not

void gd::BaseEvent::SetType | ( | std::string | type_) |  |

inline

Change the event type

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

- Event.h
- Event.cpp