GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ObjectMetadata.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 
8 #include "InstructionOrExpressionContainerMetadata.h"
9 
10 #include <functional>
11 #include <map>
12 #include <set>
13 #include <memory>
14 
15 #include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
16 #include "GDCore/Extensions/Metadata/InstructionMetadata.h"
17 #include "GDCore/Project/Object.h"
18 #include "GDCore/Project/ObjectConfiguration.h"
19 #include "GDCore/String.h"
20 namespace gd {
21 class InstructionMetadata;
22 class MultipleInstructionMetadata;
23 class ExpressionMetadata;
24 } // namespace gd
25 
26 typedef std::function<std::unique_ptr<gd::ObjectConfiguration>()>
27  CreateFunPtr;
28 
29 namespace gd {
30 
38  public:
45  ObjectMetadata(const gd::String& extensionNamespace_,
46  const gd::String& name_,
47  const gd::String& fullname_,
48  const gd::String& description_,
49  const gd::String& icon24x24_,
50  std::shared_ptr<gd::ObjectConfiguration> blueprintObject_);
56  ObjectMetadata(const gd::String& extensionNamespace_,
57  const gd::String& name_,
58  const gd::String& fullname_,
59  const gd::String& description_,
60  const gd::String& icon24x24_);
61 
68  ObjectMetadata(const gd::String& extensionNamespace_,
69  const gd::String& name_,
70  const gd::String& fullname_,
71  const gd::String& description_,
72  const gd::String& icon24x24_,
73  CreateFunPtr createFunPtr_);
74 
75  ObjectMetadata() {}
76  virtual ~ObjectMetadata(){};
77 
83  gd::InstructionMetadata& AddCondition(const gd::String& name_,
84  const gd::String& fullname_,
85  const gd::String& description_,
86  const gd::String& sentence_,
87  const gd::String& group_,
88  const gd::String& icon_,
89  const gd::String& smallicon_) override;
90 
96  gd::InstructionMetadata& AddAction(const gd::String& name_,
97  const gd::String& fullname_,
98  const gd::String& description_,
99  const gd::String& sentence_,
100  const gd::String& group_,
101  const gd::String& icon_,
102  const gd::String& smallicon_) override;
103 
107  gd::InstructionMetadata& AddScopedCondition(const gd::String& name_,
108  const gd::String& fullname_,
109  const gd::String& description_,
110  const gd::String& sentence_,
111  const gd::String& group_,
112  const gd::String& icon_,
113  const gd::String& smallicon_) override;
114 
118  gd::InstructionMetadata& AddScopedAction(const gd::String& name_,
119  const gd::String& fullname_,
120  const gd::String& description_,
121  const gd::String& sentence_,
122  const gd::String& group_,
123  const gd::String& icon_,
124  const gd::String& smallicon_) override;
125 
129  gd::ExpressionMetadata& AddExpression(const gd::String& name_,
130  const gd::String& fullname_,
131  const gd::String& description_,
132  const gd::String& group_,
133  const gd::String& smallicon_) override;
137  gd::ExpressionMetadata& AddStrExpression(const gd::String& name_,
138  const gd::String& fullname_,
139  const gd::String& description_,
140  const gd::String& group_,
141  const gd::String& smallicon_) override;
142 
149  gd::MultipleInstructionMetadata AddExpressionAndCondition(
150  const gd::String& type,
151  const gd::String& name,
152  const gd::String& fullname,
153  const gd::String& description,
154  const gd::String& sentenceName,
155  const gd::String& group,
156  const gd::String& icon) override;
157 
166  gd::MultipleInstructionMetadata AddExpressionAndConditionAndAction(
167  const gd::String& type,
168  const gd::String& name,
169  const gd::String& fullname,
170  const gd::String& description,
171  const gd::String& sentenceName,
172  const gd::String& group,
173  const gd::String& icon) override;
174 
181  gd::InstructionMetadata& AddDuplicatedAction(
182  const gd::String& newActionName, const gd::String& copiedActionName) override;
183 
190  gd::InstructionMetadata& AddDuplicatedCondition(
191  const gd::String& newConditionName,
192  const gd::String& copiedConditionName) override;
193 
197  ObjectMetadata& SetFullName(const gd::String& fullname_) override;
198 
202  ObjectMetadata& SetDescription(const gd::String& description_) override;
203 
208  const gd::String& GetHelpPath() const override { return helpPath; }
209 
217  ObjectMetadata& SetHelpPath(const gd::String& path) override {
218  helpPath = path;
219  return *this;
220  }
221 
226  ObjectMetadata& SetCategoryFullName(const gd::String& categoryFullName_) {
227  categoryFullName = categoryFullName_;
228  return *this;
229  }
230 
234  const std::set<gd::String>& GetDefaultBehaviors() const {
235  return defaultBehaviorTypes;
236  }
237 
241  bool HasDefaultBehavior(const gd::String& behaviorType) const {
242  return defaultBehaviorTypes.find(behaviorType) != defaultBehaviorTypes.end();
243  }
244 
249  const gd::String& behaviorType) {
250  defaultBehaviorTypes.insert(behaviorType);
251  return *this;
252  }
253 
254  ObjectMetadata& ResetDefaultBehaviorsJustForTesting() {
255  defaultBehaviorTypes.clear();
256  return *this;
257  }
258 
259  const gd::String& GetName() const override { return name; }
260  const gd::String& GetFullName() const override { return fullname; }
261  const gd::String& GetCategoryFullName() const { return categoryFullName; }
262  const gd::String& GetHelpUrl() const { return helpUrl; }
263  const gd::String& GetDescription() const override { return description; }
264  const gd::String& GetIconFilename() const override { return iconFilename; }
265 
271  ObjectMetadata& SetHelpUrl(const gd::String& url);
272 
280  ObjectMetadata& SetIncludeFile(const gd::String& includeFile) override;
281 
285  ObjectMetadata& AddIncludeFile(const gd::String& includeFile) override;
286 
291  std::map<gd::String, gd::InstructionMetadata>& GetAllActions() override { return actionsInfos; };
292 
296  std::map<gd::String, gd::InstructionMetadata>& GetAllConditions() override { return conditionsInfos; };
297 
301  std::map<gd::String, gd::ExpressionMetadata>& GetAllExpressions() override { return expressionsInfos; };
302 
306  std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() override { return strExpressionsInfos; };
307 
308 
313  bool IsPrivate() const override { return isPrivate; }
314 
320  isPrivate = true;
321  return *this;
322  }
323 
330  hidden = true;
331  return *this;
332  }
333 
337  bool IsHidden() const { return hidden; }
338 
343  isRenderedIn3D = true;
344  return *this;
345  }
346 
350  bool IsRenderedIn3D() const { return isRenderedIn3D; }
351 
352  ObjectMetadata &SetOpenFullEditorLabel(const gd::String& label) {
353  openFullEditorLabel = label;
354  return *this;
355  }
356 
357  const gd::String& GetOpenFullEditorLabel() const {
358  return openFullEditorLabel;
359  }
360 
361  std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
362  std::map<gd::String, gd::InstructionMetadata> actionsInfos;
363  std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
364  std::map<gd::String, gd::ExpressionMetadata> strExpressionsInfos;
365 
366  std::vector<gd::String> includeFiles;
367  gd::String className;
368  CreateFunPtr createFunPtr = nullptr;
369 
370  private:
371  gd::String extensionNamespace;
372  gd::String name;
373  gd::String helpPath;
374  gd::String helpUrl;
375  gd::String fullname;
376  gd::String description;
377  gd::String iconFilename;
378  gd::String categoryFullName;
379  std::set<gd::String> defaultBehaviorTypes;
380  bool isPrivate = false;
381  bool hidden = false;
382  bool isRenderedIn3D = false;
383  gd::String openFullEditorLabel;
384 
385  std::shared_ptr<gd::ObjectConfiguration>
386  blueprintObject;
391 };
392 
393 } // namespace gd
Describe user-friendly information about an expression, its parameters and the function name as well ...
Definition: ExpressionMetadata.h:47
Describe user-friendly information about an instruction (action or condition), its parameters and the...
Definition: InstructionMetadata.h:39
Contains user-friendly information about instructions and expressions (usually for a behavior or an o...
Definition: InstructionOrExpressionContainerMetadata.h:30
A "composite" metadata that can be used to easily declare both an expression and a related condition ...
Definition: MultipleInstructionMetadata.h:24
Contains user-friendly information about an object type, and a function to create a new gd::Object of...
Definition: ObjectMetadata.h:37
std::map< gd::String, gd::InstructionMetadata > & GetAllActions() override
Return a reference to a map containing the names of the actions (as keys) and the metadata associated...
Definition: ObjectMetadata.h:291
bool IsHidden() const
Return true if the object must be hidden in the IDE.
Definition: ObjectMetadata.h:337
bool IsPrivate() const override
Definition: ObjectMetadata.h:313
const std::set< gd::String > & GetDefaultBehaviors() const
The "capabilities" that are offered by through behaviors.
Definition: ObjectMetadata.h:234
const gd::String & GetHelpPath() const override
Get the help path of the object, relative to the GDevelop documentation root.
Definition: ObjectMetadata.h:208
ObjectMetadata & SetHidden()
Set the object to be hidden in the IDE.
Definition: ObjectMetadata.h:329
std::map< gd::String, gd::InstructionMetadata > & GetAllConditions() override
Definition: ObjectMetadata.h:296
ObjectMetadata & MarkAsRenderedIn3D()
Declare a usage of the 3D renderer.
Definition: ObjectMetadata.h:342
bool IsRenderedIn3D() const
Return true if the object uses the 3D renderer.
Definition: ObjectMetadata.h:350
bool HasDefaultBehavior(const gd::String &behaviorType) const
Return true if object has a default behavior of the given type.
Definition: ObjectMetadata.h:241
ObjectMetadata & SetPrivate()
Definition: ObjectMetadata.h:319
std::map< gd::String, gd::ExpressionMetadata > & GetAllExpressions() override
Definition: ObjectMetadata.h:301
std::map< gd::String, gd::ExpressionMetadata > & GetAllStrExpressions() override
Definition: ObjectMetadata.h:306
ObjectMetadata & SetHelpPath(const gd::String &path) override
Set the help path of the object, relative to the GDevelop documentation root.
Definition: ObjectMetadata.h:217
ObjectMetadata & AddDefaultBehavior(const gd::String &behaviorType)
Add a "capability" that is offered by through a behavior.
Definition: ObjectMetadata.h:248
ObjectMetadata & SetCategoryFullName(const gd::String &categoryFullName_)
Set the (user friendly) name of the group this object must be categorised in.
Definition: ObjectMetadata.h:226
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24