00001
00027 #ifndef FUNCTIONEVENT_H
00028 #define FUNCTIONEVENT_H
00029
00030
00031
00032
00033
00034 #include "GDL/Event.h"
00035 class RuntimeScene;
00036 class ObjectsConcerned;
00037 class Instruction;
00038 class Evaluateur;
00039 class TiXmlElement;
00040
00041 #if defined(GDE)
00042 class Scene;
00043 class MainEditorCommand;
00044 class wxWindow;
00045 #endif
00046
00051 class FunctionEvent : public BaseEvent
00052 {
00053 public:
00054 FunctionEvent();
00055 FunctionEvent(const FunctionEvent & event);
00056 virtual ~FunctionEvent();
00057
00058 FunctionEvent& operator=(const FunctionEvent & event);
00059 virtual BaseEventSPtr Clone() { return boost::shared_ptr<BaseEvent>(new FunctionEvent(*this));}
00060
00061 virtual bool IsExecutable() const {return true;}
00062 virtual void Execute( RuntimeScene & scene, ObjectsConcerned & objectsConcerned ) {};
00063
00064 virtual void Preprocess(const Game & game, RuntimeScene & scene, std::vector < BaseEventSPtr > & eventList, unsigned int indexOfTheEventInThisList);
00065 virtual void Launch( RuntimeScene & scene, ObjectsConcerned & objectsConcerned, std::vector < string > parameters_ );
00066
00067 static std::map < const Scene* , std::map < std::string, FunctionEvent* > > functionsList;
00068 static std::map < const Scene* , std::vector < std::string >* > currentFunctionParameter;
00069 void UnreferenceFunction();
00070 void ReferenceFunction(Scene *);
00071
00072 virtual bool CanHaveSubEvents() const {return true;}
00073 virtual const vector < BaseEventSPtr > & GetSubEvents() const {return events;};
00074 virtual vector < BaseEventSPtr > & GetSubEvents() {return events;};
00075 void SetSubEvents(vector < BaseEventSPtr > & subEvents_) {events = subEvents_;};
00076
00077 const vector < Instruction > & GetConditions() const { return conditions; };
00078 vector < Instruction > & GetConditions() { return conditions; };
00079 void SetConditions(vector < Instruction > & conditions_) { conditions = conditions_; };
00080
00081 const vector < Instruction > & GetActions() const { return actions; };
00082 vector < Instruction > & GetActions() { return actions; };
00083 void SetActions(vector < Instruction > & actions_) { actions = actions_; };
00084
00085 string GetName() const { return name; };
00086 string GetName() { return name; };
00087 void SetName(string name_) { name = name_; };
00088
00089 virtual vector < vector<Instruction>* > GetAllConditionsVectors();
00090 virtual vector < vector<Instruction>* > GetAllActionsVectors();
00091
00092 #if defined(GDE)
00093 virtual void SaveToXml(TiXmlElement * eventElem) const;
00094 #endif
00095 virtual void LoadFromXml(const TiXmlElement * eventElem);
00096
00097 #if defined(GDE)
00098
00101 virtual void Render(wxBufferedPaintDC & dc, int x, int y, unsigned int width) const;
00102
00106 virtual unsigned int GetRenderedHeight(unsigned int width) const;
00107
00111 virtual void OnSingleClick(int x, int y, vector < boost::tuple< vector < BaseEventSPtr > *, unsigned int, vector < Instruction > *, unsigned int > > & eventsSelected,
00112 bool & conditionsSelected, bool & instructionsSelected);
00113
00117 virtual void EditEvent(wxWindow* parent_, Game & game_, Scene & scene_, MainEditorCommand & mainEditorCommand_);
00118 #endif
00119
00120 private:
00121 void Init(const FunctionEvent & event);
00122 bool ExecuteConditions( RuntimeScene & scene, ObjectsConcerned & objectsConcerned );
00123 void ExecuteActions( RuntimeScene & scene, ObjectsConcerned & objectsConcerned );
00124
00125 string name;
00126 vector < Instruction > conditions;
00127 vector < Instruction > actions;
00128 vector < BaseEventSPtr > events;
00129
00130 #ifdef GDE
00131 bool nameSelected;
00132 #endif
00133 };
00134
00135 #endif // FUNCTIONEVENT_H