GDevelop JS Platform
Platform for developing HTML5/Javascript based games with GDevelop
JsCodeEvent.h
Go to the documentation of this file.
1 
6 #ifndef JSCODEEVENT_H
7 #define JSCODEEVENT_H
8 #include "GDCore/Events/Event.h"
9 #include "GDCore/Events/Expression.h"
10 namespace gd {
11 class Instruction;
12 class Project;
13 class SerializerElement;
14 class Layout;
15 } // namespace gd
16 
17 namespace gdjs {
18 
22 class JsCodeEvent : public gd::BaseEvent {
23  public:
24  JsCodeEvent();
25  virtual ~JsCodeEvent(){};
26 
27  virtual JsCodeEvent* Clone() const { return new JsCodeEvent(*this); }
28 
29  virtual bool IsExecutable() const { return true; }
30  virtual bool CanHaveSubEvents() const { return false; }
31 
32  const gd::String& GetInlineCode() const { return inlineCode; };
33  void SetInlineCode(const gd::String& code) { inlineCode = code; };
34 
35  const gd::String& GetParameterObjects() const { return parameterObjects.GetPlainString(); };
36  void SetParameterObjects(const gd::String& objectName) {
37  parameterObjects = gd::Expression(objectName);
38  };
39 
40  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
41  GetAllExpressionsWithMetadata();
42  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
43  GetAllExpressionsWithMetadata() const;
44 
45  virtual void SerializeTo(gd::SerializerElement& element) const;
46  virtual void UnserializeFrom(gd::Project& project,
47  const gd::SerializerElement& element);
48  virtual bool IsUseStrict() const { return useStrict; }
49 
50  bool IsEventsSheetExpanded() const { return eventsSheetExpanded; }
51  void SetEventsSheetExpanded(bool enable) { eventsSheetExpanded = enable; };
52 
53  private:
54  void Init(const JsCodeEvent& event);
55 
56  gd::String inlineCode;
57  gd::Expression parameterObjects;
59  bool useStrict;
62  bool eventsSheetExpanded;
63 };
64 
65 } // namespace gdjs
66 
67 #endif // JSCODEEVENT_H
Event used to insert raw javascript code into events.
Definition: JsCodeEvent.h:22