GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
BehaviorMetadata.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 <map>
11 
12 #include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
13 #include "GDCore/Extensions/Metadata/InstructionMetadata.h"
14 #include "GDCore/String.h"
15 #include "GDCore/Project/QuickCustomization.h"
16 namespace gd {
17 class Behavior;
18 class BehaviorsSharedData;
19 class MultipleInstructionMetadata;
20 class InstructionMetadata;
21 class ExpressionMetadata;
22 class PropertyDescriptor;
23 } // namespace gd
24 
25 namespace gd {
26 
33  public:
35  const gd::String& extensionNamespace,
36  const gd::String& nameWithNamespace,
37  const gd::String& fullname_,
38  const gd::String& defaultName_,
39  const gd::String& description_,
40  const gd::String& group_,
41  const gd::String& icon24x24_,
42  const gd::String& className_,
43  std::shared_ptr<gd::Behavior> instance,
44  std::shared_ptr<gd::BehaviorsSharedData> sharedDatasInstance);
45 
52  const gd::String& extensionNamespace,
53  const gd::String& nameWithNamespace,
54  const gd::String& fullname_,
55  const gd::String& defaultName_,
56  const gd::String& description_,
57  const gd::String& group_,
58  const gd::String& icon24x24_);
59 
60  BehaviorMetadata(){};
61  virtual ~BehaviorMetadata(){};
62 
68  gd::InstructionMetadata& AddCondition(const gd::String& name_,
69  const gd::String& fullname_,
70  const gd::String& description_,
71  const gd::String& sentence_,
72  const gd::String& group_,
73  const gd::String& icon_,
74  const gd::String& smallicon_) override;
75 
81  gd::InstructionMetadata& AddAction(const gd::String& name_,
82  const gd::String& fullname_,
83  const gd::String& description_,
84  const gd::String& sentence_,
85  const gd::String& group_,
86  const gd::String& icon_,
87  const gd::String& smallicon_) override;
88 
92  gd::InstructionMetadata& AddScopedCondition(const gd::String& name_,
93  const gd::String& fullname_,
94  const gd::String& description_,
95  const gd::String& sentence_,
96  const gd::String& group_,
97  const gd::String& icon_,
98  const gd::String& smallicon_) override;
99 
103  gd::InstructionMetadata& AddScopedAction(const gd::String& name_,
104  const gd::String& fullname_,
105  const gd::String& description_,
106  const gd::String& sentence_,
107  const gd::String& group_,
108  const gd::String& icon_,
109  const gd::String& smallicon_) override;
113  gd::ExpressionMetadata& AddExpression(const gd::String& name_,
114  const gd::String& fullname_,
115  const gd::String& description_,
116  const gd::String& group_,
117  const gd::String& smallicon_) override;
118 
122  gd::ExpressionMetadata& AddStrExpression(const gd::String& name_,
123  const gd::String& fullname_,
124  const gd::String& description_,
125  const gd::String& group_,
126  const gd::String& smallicon_) override;
127 
134  gd::MultipleInstructionMetadata AddExpressionAndCondition(
135  const gd::String& type,
136  const gd::String& name,
137  const gd::String& fullname,
138  const gd::String& description,
139  const gd::String& sentenceName,
140  const gd::String& group,
141  const gd::String& icon) override;
142 
151  gd::MultipleInstructionMetadata AddExpressionAndConditionAndAction(
152  const gd::String& type,
153  const gd::String& name,
154  const gd::String& fullname,
155  const gd::String& description,
156  const gd::String& sentenceName,
157  const gd::String& group,
158  const gd::String& icon) override;
159 
166  gd::InstructionMetadata& AddDuplicatedAction(
167  const gd::String& newActionName, const gd::String& copiedActionName) override;
168 
175  gd::InstructionMetadata& AddDuplicatedCondition(
176  const gd::String& newConditionName,
177  const gd::String& copiedConditionName) override;
178 
185  gd::ExpressionMetadata& AddDuplicatedExpression(
186  const gd::String& newExpressionName,
187  const gd::String& copiedExpressionName);
188 
196  gd::ExpressionMetadata& AddDuplicatedStrExpression(
197  const gd::String& newExpressionName,
198  const gd::String& copiedExpressionName);
199 
200  BehaviorMetadata& SetFullName(const gd::String& fullname_) override;
201  BehaviorMetadata& SetDefaultName(const gd::String& defaultName_);
202  BehaviorMetadata& SetDescription(const gd::String& description_) override;
203  BehaviorMetadata& SetGroup(const gd::String& group_);
204 
212  BehaviorMetadata& SetIncludeFile(const gd::String& includeFile) override;
213 
217  BehaviorMetadata& AddIncludeFile(const gd::String& includeFile) override;
218 
224  BehaviorMetadata& AddRequiredFile(const gd::String& requiredFile);
225 
230  const gd::String& GetHelpPath() const override { return helpPath; }
231 
239  BehaviorMetadata& SetHelpPath(const gd::String& path) override {
240  helpPath = path;
241  return *this;
242  }
243 
244  const gd::String& GetName() const override;
245  const gd::String& GetFullName() const override { return fullname; }
246  const gd::String& GetDefaultName() const { return defaultName; }
247  const gd::String& GetDescription() const override { return description; }
248  const gd::String& GetGroup() const { return group; }
249  const gd::String& GetIconFilename() const override { return iconFilename; }
250 
255  objectType = objectType_;
256  return *this;
257  }
258 
264  const gd::String& GetObjectType() const { return objectType; }
265 
269  const std::vector<gd::String>& GetRequiredBehaviorTypes() const;
270 
275  bool IsPrivate() const { return isPrivate; }
276 
282  isPrivate = true;
283  return *this;
284  }
285 
290  bool IsHidden() const { return isHidden; }
291 
297  isHidden = true;
298  return *this;
299  }
300 
301  QuickCustomization::Visibility GetQuickCustomizationVisibility() const {
302  return quickCustomizationVisibility;
303  }
304 
305  BehaviorMetadata &SetQuickCustomizationVisibility(QuickCustomization::Visibility visibility) {
306  quickCustomizationVisibility = visibility;
307  return *this;
308  }
309 
310  BehaviorMetadata &SetOpenFullEditorLabel(const gd::String& label) {
311  openFullEditorLabel = label;
312  return *this;
313  }
314 
315  const gd::String& GetOpenFullEditorLabel() const {
316  return openFullEditorLabel;
317  }
318 
325  gd::Behavior& Get() const;
326 
334  std::map<gd::String, gd::PropertyDescriptor> GetProperties() const;
335 
343  gd::BehaviorsSharedData* GetSharedDataInstance() const;
344 
352  std::map<gd::String, gd::PropertyDescriptor> GetSharedProperties() const;
353 
358  std::map<gd::String, gd::InstructionMetadata>& GetAllActions() override { return actionsInfos; };
359 
363  std::map<gd::String, gd::InstructionMetadata>& GetAllConditions() override { return conditionsInfos; };
364 
368  std::map<gd::String, gd::ExpressionMetadata>& GetAllExpressions() override { return expressionsInfos; };
369 
373  std::map<gd::String, gd::ExpressionMetadata>& GetAllStrExpressions() override { return strExpressionsInfos; };
374 
375  std::map<gd::String, gd::InstructionMetadata> conditionsInfos;
376  std::map<gd::String, gd::InstructionMetadata> actionsInfos;
377  std::map<gd::String, gd::ExpressionMetadata> expressionsInfos;
378  std::map<gd::String, gd::ExpressionMetadata> strExpressionsInfos;
379 
380  std::vector<gd::String> includeFiles;
381  std::vector<gd::String> requiredFiles;
382  gd::String className;
383 
384  private:
385  gd::String extensionNamespace;
386  gd::String helpPath;
387  gd::String fullname;
388  gd::String defaultName;
389  gd::String description;
390  gd::String group;
391  gd::String iconFilename;
392  gd::String objectType;
393  mutable std::vector<gd::String> requiredBehaviors;
394  bool isPrivate = false;
395  bool isHidden = false;
396  gd::String openFullEditorLabel;
397  QuickCustomization::Visibility quickCustomizationVisibility = QuickCustomization::Visibility::Default;
398 
399  // TODO: Nitpicking: convert these to std::unique_ptr to clarify ownership.
400  std::shared_ptr<gd::Behavior> instance;
401  std::shared_ptr<gd::BehaviorsSharedData> sharedDatasInstance;
402 
403  static const std::map<gd::String, gd::PropertyDescriptor> badProperties;
404 };
405 
406 } // namespace gd
Base class used to represents a behavior that can be applied to an object. It stores the content (i....
Definition: Behavior.h:23
Contains user-friendly information about a behavior type.
Definition: BehaviorMetadata.h:32
BehaviorMetadata & SetPrivate()
Definition: BehaviorMetadata.h:281
std::map< gd::String, gd::InstructionMetadata > & GetAllConditions() override
Definition: BehaviorMetadata.h:363
BehaviorMetadata & SetHidden()
Definition: BehaviorMetadata.h:296
bool IsPrivate() const
Definition: BehaviorMetadata.h:275
bool IsHidden() const
Definition: BehaviorMetadata.h:290
const gd::String & GetHelpPath() const override
Definition: BehaviorMetadata.h:230
std::map< gd::String, gd::ExpressionMetadata > & GetAllStrExpressions() override
Definition: BehaviorMetadata.h:373
const gd::String & GetObjectType() const
Get the type of the object that this behavior can be used on.
Definition: BehaviorMetadata.h:264
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: BehaviorMetadata.h:358
BehaviorMetadata & SetHelpPath(const gd::String &path) override
Definition: BehaviorMetadata.h:239
std::map< gd::String, gd::ExpressionMetadata > & GetAllExpressions() override
Definition: BehaviorMetadata.h:368
BehaviorMetadata(const gd::String &extensionNamespace, const gd::String &nameWithNamespace, const gd::String &fullname_, const gd::String &defaultName_, const gd::String &description_, const gd::String &group_, const gd::String &icon24x24_)
Construct a behavior metadata, without "blueprint" behavior.
BehaviorMetadata & SetObjectType(const gd::String &objectType_)
Set the type of the object that this behavior can be used on.
Definition: BehaviorMetadata.h:254
Base class for defining data shared by behaviors having the same type and name.
Definition: BehaviorsSharedData.h:24
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
Visibility
Definition: QuickCustomization.h:8
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24