GDevelop JS Platform
Platform for developing HTML5/Javascript based games with GDevelop
JsCodeEvent.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "GDCore/Events/Event.h"
9 #include "GDCore/Events/Expression.h"
10 #include "GDCore/Project/MemoryTrackedRegistry.h"
11 
12 namespace gd {
13 class Instruction;
14 class Project;
15 class SerializerElement;
16 class Layout;
17 } // namespace gd
18 
19 namespace gdjs {
20 
24 class JsCodeEvent : public gd::BaseEvent {
25  public:
26  JsCodeEvent();
27  virtual ~JsCodeEvent(){};
28 
29  virtual JsCodeEvent* Clone() const { return new JsCodeEvent(*this); }
30 
31  virtual bool IsExecutable() const { return true; }
32  virtual bool CanHaveSubEvents() const { return false; }
33 
34  const gd::String& GetInlineCode() const { return inlineCode; };
35  void SetInlineCode(const gd::String& code) { inlineCode = code; };
36 
37  const gd::String& GetParameterObjects() const { return parameterObjects.GetPlainString(); };
38  void SetParameterObjects(const gd::String& objectName) {
39  parameterObjects = gd::Expression(objectName);
40  };
41 
42  virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
43  GetAllExpressionsWithMetadata();
44  virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
45  GetAllExpressionsWithMetadata() const;
46 
47  virtual void SerializeTo(gd::SerializerElement& element) const;
48  virtual void UnserializeFrom(gd::Project& project,
49  const gd::SerializerElement& element);
50  virtual bool IsUseStrict() const { return useStrict; }
51 
52  bool IsEventsSheetExpanded() const { return eventsSheetExpanded; }
53  void SetEventsSheetExpanded(bool enable) { eventsSheetExpanded = enable; };
54 
55  long GetScrollTop() const { return scrollTop; }
56  void SetScrollTop(long value) { scrollTop = value; };
57 
58  long GetCursorColumn() const { return cursorColumn; }
59  void SetCursorColumn(long value) { cursorColumn = value; };
60 
61  long GetCursorLine() const { return cursorLine; }
62  void SetCursorLine(long value) { cursorLine = value; };
63 
64 private:
65  JsCodeEvent(const JsCodeEvent& event);
66 
67  gd::String inlineCode;
68  gd::Expression parameterObjects;
70  bool useStrict = true;
73  bool eventsSheetExpanded = false;
74 
75  // These members are not serialized.
76  long scrollTop = 0;
77  long cursorColumn = 0;
78  long cursorLine = 0;
79 
80  gd::MemoryTracked _memoryTracked{this, "JsCodeEvent"};
81 };
82 
83 } // namespace gdjs
84 
Event used to insert raw javascript code into events.
Definition: JsCodeEvent.h:24