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/Extensions/Metadata/InGameEditorResourceMetadata.h"
18 #include "GDCore/Project/Object.h"
19 #include "GDCore/Project/ObjectConfiguration.h"
20 #include "GDCore/String.h"
21 namespace gd {
22 class InstructionMetadata;
23 class MultipleInstructionMetadata;
24 class ExpressionMetadata;
25 } // namespace gd
26 
27 typedef std::function<std::unique_ptr<gd::ObjectConfiguration>()>
28  CreateFunPtr;
29 
30 namespace gd {
31 
39  public:
46  ObjectMetadata(const gd::String& extensionNamespace_,
47  const gd::String& name_,
48  const gd::String& fullname_,
49  const gd::String& description_,
50  const gd::String& icon24x24_,
51  std::shared_ptr<gd::ObjectConfiguration> blueprintObject_);
57  ObjectMetadata(const gd::String& extensionNamespace_,
58  const gd::String& name_,
59  const gd::String& fullname_,
60  const gd::String& description_,
61  const gd::String& icon24x24_);
62 
69  ObjectMetadata(const gd::String& extensionNamespace_,
70  const gd::String& name_,
71  const gd::String& fullname_,
72  const gd::String& description_,
73  const gd::String& icon24x24_,
74  CreateFunPtr createFunPtr_);
75 
76  ObjectMetadata() {}
77  virtual ~ObjectMetadata(){};
78 
84  gd::InstructionMetadata& AddCondition(const gd::String& name_,
85  const gd::String& fullname_,
86  const gd::String& description_,
87  const gd::String& sentence_,
88  const gd::String& group_,
89  const gd::String& icon_,
90  const gd::String& smallicon_) override;
91 
97  gd::InstructionMetadata& AddAction(const gd::String& name_,
98  const gd::String& fullname_,
99  const gd::String& description_,
100  const gd::String& sentence_,
101  const gd::String& group_,
102  const gd::String& icon_,
103  const gd::String& smallicon_) override;
104 
108  gd::InstructionMetadata& AddScopedCondition(const gd::String& name_,
109  const gd::String& fullname_,
110  const gd::String& description_,
111  const gd::String& sentence_,
112  const gd::String& group_,
113  const gd::String& icon_,
114  const gd::String& smallicon_) override;
115 
119  gd::InstructionMetadata& AddScopedAction(const gd::String& name_,
120  const gd::String& fullname_,
121  const gd::String& description_,
122  const gd::String& sentence_,
123  const gd::String& group_,
124  const gd::String& icon_,
125  const gd::String& smallicon_) override;
126 
130  gd::ExpressionMetadata& AddExpression(const gd::String& name_,
131  const gd::String& fullname_,
132  const gd::String& description_,
133  const gd::String& group_,
134  const gd::String& smallicon_) override;
138  gd::ExpressionMetadata& AddStrExpression(const gd::String& name_,
139  const gd::String& fullname_,
140  const gd::String& description_,
141  const gd::String& group_,
142  const gd::String& smallicon_) override;
143 
150  gd::MultipleInstructionMetadata AddExpressionAndCondition(
151  const gd::String& type,
152  const gd::String& name,
153  const gd::String& fullname,
154  const gd::String& description,
155  const gd::String& sentenceName,
156  const gd::String& group,
157  const gd::String& icon) override;
158 
167  gd::MultipleInstructionMetadata AddExpressionAndConditionAndAction(
168  const gd::String& type,
169  const gd::String& name,
170  const gd::String& fullname,
171  const gd::String& description,
172  const gd::String& sentenceName,
173  const gd::String& group,
174  const gd::String& icon) override;
175 
182  gd::InstructionMetadata& AddDuplicatedAction(
183  const gd::String& newActionName, const gd::String& copiedActionName) override;
184 
191  gd::InstructionMetadata& AddDuplicatedCondition(
192  const gd::String& newConditionName,
193  const gd::String& copiedConditionName) override;
194 
198  ObjectMetadata& SetFullName(const gd::String& fullname_) override;
199 
203  ObjectMetadata& SetDescription(const gd::String& description_) override;
204 
209  const gd::String& GetHelpPath() const override { return helpPath; }
210 
218  ObjectMetadata& SetHelpPath(const gd::String& path) override {
219  helpPath = path;
220  return *this;
221  }
222 
227  ObjectMetadata& SetCategoryFullName(const gd::String& categoryFullName_) {
228  categoryFullName = categoryFullName_;
229  return *this;
230  }
231 
235  const std::set<gd::String>& GetDefaultBehaviors() const {
236  return defaultBehaviorTypes;
237  }
238 
242  bool HasDefaultBehavior(const gd::String& behaviorType) const {
243  return defaultBehaviorTypes.find(behaviorType) != defaultBehaviorTypes.end();
244  }
245 
250  const gd::String& behaviorType) {
251  defaultBehaviorTypes.insert(behaviorType);
252  return *this;
253  }
254 
255  ObjectMetadata& ResetDefaultBehaviorsJustForTesting() {
256  defaultBehaviorTypes.clear();
257  return *this;
258  }
259 
260  const gd::String& GetName() const override { return name; }
261  const gd::String& GetFullName() const override { return fullname; }
262  const gd::String& GetCategoryFullName() const { return categoryFullName; }
263  const gd::String& GetHelpUrl() const { return helpUrl; }
264  const gd::String& GetDescription() const override { return description; }
265  const gd::String& GetIconFilename() const override { return iconFilename; }
266 
272  ObjectMetadata& SetHelpUrl(const gd::String& url);
273 
281  ObjectMetadata& SetIncludeFile(const gd::String& includeFile) override;
282 
286  ObjectMetadata& AddIncludeFile(const gd::String& includeFile) override;
287 
292  std::map<gd::String, gd::InstructionMetadata>& GetAllActions() override { return actionsInfos; };
293 
297  std::map<gd::String, gd::InstructionMetadata>& GetAllConditions() override { return conditionsInfos; };
298 
302  std::map<gd::String, gd::ExpressionMetadata>& GetAllExpressions() override { return expressionsInfos; };
303 
307  std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() override { return strExpressionsInfos; };
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 
365  InGameEditorResourceMetadata newInGameEditorResource;
366  inGameEditorResources.push_back(newInGameEditorResource);
367  return inGameEditorResources.back();
368  }
369 
370  const std::vector<gd::InGameEditorResourceMetadata>& GetInGameEditorResources() const {
371  return inGameEditorResources;
372  }
373 
374  std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
375  std::map<gd::String, gd::InstructionMetadata> actionsInfos;
376  std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
377  std::map<gd::String, gd::ExpressionMetadata> strExpressionsInfos;
378 
379  std::vector<gd::String> includeFiles;
380  gd::String className;
381  CreateFunPtr createFunPtr = nullptr;
382 
383  private:
384  gd::String extensionNamespace;
385  gd::String name;
386  gd::String helpPath;
387  gd::String helpUrl;
388  gd::String fullname;
389  gd::String description;
390  gd::String iconFilename;
391  gd::String categoryFullName;
392  std::set<gd::String> defaultBehaviorTypes;
393  bool isPrivate = false;
394  bool hidden = false;
395  bool isRenderedIn3D = false;
396  gd::String openFullEditorLabel;
397  std::vector<gd::InGameEditorResourceMetadata> inGameEditorResources;
398 
399  std::shared_ptr<gd::ObjectConfiguration>
400  blueprintObject;
405 };
406 
407 } // namespace gd
Describe user-friendly information about an expression, its parameters and the function name as well ...
Definition: ExpressionMetadata.h:47
Describe a resource to be used in the in-game editor.
Definition: InGameEditorResourceMetadata.h:14
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:38
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:292
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:235
const gd::String & GetHelpPath() const override
Get the help path of the object, relative to the GDevelop documentation root.
Definition: ObjectMetadata.h:209
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:297
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:242
InGameEditorResourceMetadata & AddInGameEditorResource()
Declare a new resource to be used in the in-game editor.
Definition: ObjectMetadata.h:364
ObjectMetadata & SetPrivate()
Definition: ObjectMetadata.h:319
std::map< gd::String, gd::ExpressionMetadata > & GetAllExpressions() override
Definition: ObjectMetadata.h:302
std::map< gd::String, gd::ExpressionMetadata > & GetAllStrExpressions() override
Definition: ObjectMetadata.h:307
ObjectMetadata & SetHelpPath(const gd::String &path) override
Set the help path of the object, relative to the GDevelop documentation root.
Definition: ObjectMetadata.h:218
ObjectMetadata & AddDefaultBehavior(const gd::String &behaviorType)
Add a "capability" that is offered by through a behavior.
Definition: ObjectMetadata.h:249
ObjectMetadata & SetCategoryFullName(const gd::String &categoryFullName_)
Set the (user friendly) name of the group this object must be categorised in.
Definition: ObjectMetadata.h:227
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24