mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
26 Commits
96ca91e35e
...
object-cap
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d0dd8b8a18 | ||
![]() |
e60545c146 | ||
![]() |
4225df8203 | ||
![]() |
34495bbdb5 | ||
![]() |
968c6be9d7 | ||
![]() |
3b28cc6c63 | ||
![]() |
8c83677671 | ||
![]() |
5154936baf | ||
![]() |
2311d94207 | ||
![]() |
b47d38d75b | ||
![]() |
592c5555c3 | ||
![]() |
05671dd8b8 | ||
![]() |
9be969b263 | ||
![]() |
47835c7a99 | ||
![]() |
aff102e52f | ||
![]() |
715287abef | ||
![]() |
3c80a5d7da | ||
![]() |
f840a337ce | ||
![]() |
03186b66fb | ||
![]() |
483d768962 | ||
![]() |
568b2cd129 | ||
![]() |
d1b2a4d9d2 | ||
![]() |
40a194656f | ||
![]() |
a8fafef48e | ||
![]() |
3cfd831d45 | ||
![]() |
b305acddba |
@@ -295,17 +295,17 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
gd::String objectInParameter =
|
||||
condition.GetParameter(pNb).GetPlainString();
|
||||
|
||||
auto& parameterObjectType = instrInfos.parameters[pNb].GetValueTypeMetadata().GetObjectType().GetName();
|
||||
if (!GetObjectsAndGroups().HasObjectNamed(objectInParameter) &&
|
||||
!GetGlobalObjectsAndGroups().HasObjectNamed(objectInParameter) &&
|
||||
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
||||
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
||||
objectInParameter)) {
|
||||
return "/* Unknown object - skipped. */";
|
||||
} else if (!instrInfos.parameters[pNb].GetExtraInfo().empty() &&
|
||||
} else if (!parameterObjectType.empty() && parameterObjectType !=
|
||||
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
||||
GetObjectsAndGroups(),
|
||||
objectInParameter) !=
|
||||
instrInfos.parameters[pNb].GetExtraInfo()) {
|
||||
objectInParameter)) {
|
||||
return "/* Mismatched object type - skipped. */";
|
||||
}
|
||||
}
|
||||
@@ -323,11 +323,8 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
if (objInfo.IsSupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
conditionCode +=
|
||||
"/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
@@ -344,6 +341,9 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
context);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
} else {
|
||||
conditionCode +=
|
||||
"/* Object with unsupported capability - skipped. */\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -485,17 +485,18 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||
if (ParameterMetadata::IsObject(instrInfos.parameters[pNb].GetType())) {
|
||||
gd::String objectInParameter = action.GetParameter(pNb).GetPlainString();
|
||||
|
||||
auto& parameterObjectType = instrInfos.parameters[pNb].GetValueTypeMetadata().GetObjectType().GetName();
|
||||
if (!GetObjectsAndGroups().HasObjectNamed(objectInParameter) &&
|
||||
!GetGlobalObjectsAndGroups().HasObjectNamed(objectInParameter) &&
|
||||
!GetObjectsAndGroups().GetObjectGroups().Has(objectInParameter) &&
|
||||
!GetGlobalObjectsAndGroups().GetObjectGroups().Has(
|
||||
objectInParameter)) {
|
||||
return "/* Unknown object - skipped. */";
|
||||
} else if (!instrInfos.parameters[pNb].GetExtraInfo().empty() &&
|
||||
} else if (!parameterObjectType.empty() && parameterObjectType !=
|
||||
gd::GetTypeOfObject(GetGlobalObjectsAndGroups(),
|
||||
GetObjectsAndGroups(),
|
||||
objectInParameter) !=
|
||||
instrInfos.parameters[pNb].GetExtraInfo()) {
|
||||
objectInParameter)) {
|
||||
return "/* Mismatched object type - skipped. */";
|
||||
}
|
||||
}
|
||||
@@ -515,10 +516,8 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
const ObjectMetadata& objInfo =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
if (objInfo.IsSupportedBaseObjectCapability(
|
||||
instrInfos.GetRequiredBaseObjectCapability())) {
|
||||
actionCode += "/* Object with unsupported capability - skipped. */\n";
|
||||
} else {
|
||||
AddIncludeFiles(objInfo.includeFiles);
|
||||
context.SetCurrentObject(realObjects[i]);
|
||||
context.ObjectsListNeeded(realObjects[i]);
|
||||
@@ -535,6 +534,8 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
optionalAsyncCallbackName);
|
||||
|
||||
context.SetNoCurrentObject();
|
||||
} else {
|
||||
actionCode += "/* Object with unsupported capability - skipped. */\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1057,7 +1058,7 @@ gd::String EventsCodeGenerator::GenerateObjectCondition(
|
||||
// Prepare call
|
||||
// Add a static_cast if necessary
|
||||
gd::String objectFunctionCallNamePart =
|
||||
(!instrInfos.parameters[0].GetExtraInfo().empty())
|
||||
(!instrInfos.parameters[0].GetValueTypeMetadata().GetObjectType().IsBaseObject())
|
||||
? "static_cast<" + objInfo.className + "*>(" +
|
||||
GetObjectListName(objectName, context) + "[i])->" +
|
||||
instrInfos.codeExtraInformation.functionCallName
|
||||
|
@@ -270,11 +270,8 @@ gd::String ExpressionCodeGenerator::GenerateObjectFunctionCode(
|
||||
const ObjectMetadata& objInfo = MetadataProvider::GetObjectMetadata(
|
||||
codeGenerator.GetPlatform(), objectType);
|
||||
|
||||
if (objInfo.IsUnsupportedBaseObjectCapability(
|
||||
if (objInfo.IsSupportedBaseObjectCapability(
|
||||
expressionMetadata.GetRequiredBaseObjectCapability())) {
|
||||
// Do nothing, skipping objects not supporting the capability required by
|
||||
// this expression.
|
||||
} else {
|
||||
codeGenerator.AddIncludeFiles(objInfo.includeFiles);
|
||||
functionOutput = codeGenerator.GenerateObjectFunctionCall(
|
||||
realObjects[i],
|
||||
@@ -283,6 +280,9 @@ gd::String ExpressionCodeGenerator::GenerateObjectFunctionCode(
|
||||
parametersCode,
|
||||
functionOutput,
|
||||
context);
|
||||
} else {
|
||||
// Do nothing, skipping objects not supporting the capability required by
|
||||
// this expression.
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,8 +29,20 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.SetIcon("res/actions/force24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Variables"))
|
||||
.SetIcon("res/conditions/var24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Timers"))
|
||||
.SetIcon("res/actions/timer24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Visibility"))
|
||||
.SetIcon("res/actions/visibilite24.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Position"))
|
||||
.SetIcon("res/actions/position24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Angle"))
|
||||
.SetIcon("res/actions/direction24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Size"))
|
||||
.SetIcon("res/actions/scale24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Scale"))
|
||||
.SetIcon("res/actions/scale24_black.png");
|
||||
extension.AddInstructionOrExpressionGroupMetadata(_("Animations and images"))
|
||||
.SetIcon("res/conditions/animation24.png");
|
||||
|
||||
gd::ObjectMetadata& obj = extension.AddObject<gd::ObjectConfiguration>(
|
||||
"", _("Base object"), _("Base object"), "res/objeticon24.png");
|
||||
@@ -1101,6 +1113,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Largeur",
|
||||
_("Width"),
|
||||
_("Width of the object"),
|
||||
@@ -1116,6 +1129,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Hauteur",
|
||||
_("Height"),
|
||||
_("Height of the object"),
|
||||
@@ -1201,7 +1215,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
obj.AddExpression("ObjectTimerElapsedTime",
|
||||
_("Object timer value"),
|
||||
_("Value of an object timer"),
|
||||
_("Object timers"),
|
||||
_("Timers"),
|
||||
"res/actions/time.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("identifier", _("Timer's name"), "objectTimer");
|
||||
@@ -1262,7 +1276,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetRequiredBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectDoubleParameter",
|
||||
_("Effect parameter (number)"),
|
||||
@@ -1278,7 +1292,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("expression", _("New value"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetRequiredBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectStringParameter",
|
||||
_("Effect parameter (string)"),
|
||||
@@ -1295,7 +1309,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("string", _("New value"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetRequiredBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetEffectBooleanParameter",
|
||||
_("Effect parameter (enable or disable)"),
|
||||
@@ -1311,7 +1325,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("objectEffectParameterName", _("Parameter name"))
|
||||
.AddParameter("yesorno", _("Enable?"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetRequiredBaseObjectCapability("effect");
|
||||
|
||||
obj.AddCondition("IsEffectEnabled",
|
||||
_("Effect is enabled"),
|
||||
@@ -1323,7 +1337,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("objectEffectName", _("Effect name"))
|
||||
.MarkAsSimple()
|
||||
.SetRequiresBaseObjectCapability("effect");
|
||||
.SetRequiredBaseObjectCapability("effect");
|
||||
|
||||
obj.AddAction("SetIncludedInParentCollisionMask",
|
||||
_("Include in parent collision mask"),
|
||||
@@ -1668,6 +1682,297 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
|
||||
"",
|
||||
"res/actions/layer.png")
|
||||
.AddParameter("object", _("Object"));
|
||||
|
||||
// Instruction for Resizable capability.
|
||||
{
|
||||
obj.AddAction("SetWidth",
|
||||
_("Width"),
|
||||
_("Change the width of the object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/actions/scaleWidth24_black.png",
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("resizable")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.SetRequiredBaseObjectCapability("resizable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Compare the width of the object."),
|
||||
_("the width"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleWidth24_black.png",
|
||||
"res/conditions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("resizable")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.SetRequiredBaseObjectCapability("resizable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("SetHeight",
|
||||
_("Height"),
|
||||
_("Change the height of the object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/actions/scaleHeight24_black.png",
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("resizable")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.SetRequiredBaseObjectCapability("resizable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Compare the height of the object."),
|
||||
_("the height"),
|
||||
_("Size"),
|
||||
"res/conditions/scaleHeight24_black.png",
|
||||
"res/conditions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("resizable")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.SetRequiredBaseObjectCapability("resizable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Change the size of an object."),
|
||||
_("Change the size of _PARAM0_: set to _PARAM1_ x _PARAM2_"),
|
||||
_("Size"),
|
||||
"res/actions/scale24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("resizable")
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.SetRequiredBaseObjectCapability("resizable")
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
// Instruction for Scalable capability.
|
||||
{
|
||||
obj.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"Scale",
|
||||
_("Scale"),
|
||||
_("the scale of the object (default scale is 1)"),
|
||||
_("the scale"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("scalable")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetRequiredBaseObjectCapability("scalable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"ScaleX",
|
||||
_("Scale on X axis"),
|
||||
_("the scale on X axis of the object (default scale is 1)"),
|
||||
_("the scale on X axis"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("scalable")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetRequiredBaseObjectCapability("scalable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddExpressionAndConditionAndAction(
|
||||
"number",
|
||||
"ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
_("the scale on Y axis of the object (default scale is 1)"),
|
||||
_("the scale on Y axis"),
|
||||
_("Scale"),
|
||||
"res/actions/scale24_black.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("scalable")
|
||||
.UseStandardParameters(
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetRequiredBaseObjectCapability("scalable")
|
||||
.MarkAsAdvanced();
|
||||
}
|
||||
// Instruction for Flippable capability.
|
||||
{
|
||||
obj.AddAction("FlipX",
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip horizontally _PARAM0_: _PARAM1_"),
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("flippable")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetRequiredBaseObjectCapability("flippable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("FlipY",
|
||||
_("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
_("Flip vertically _PARAM0_: _PARAM1_"),
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("flippable")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetRequiredBaseObjectCapability("flippable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("FlippedX",
|
||||
_("Horizontally flipped"),
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"),
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("flippable")
|
||||
.SetRequiredBaseObjectCapability("flippable");
|
||||
|
||||
obj.AddCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"),
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("flippable")
|
||||
.SetRequiredBaseObjectCapability("flippable");
|
||||
}
|
||||
// Instruction for Animable capability.
|
||||
{
|
||||
obj.AddExpressionAndConditionAndAction(
|
||||
"number", "AnimationIndex",
|
||||
_("Animation (by number)"),
|
||||
_("the number of the animation played by the object (the number from "
|
||||
"the animations list)"),
|
||||
_("the number of the animation"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("SetAnimationName",
|
||||
_("Animation (by name)"),
|
||||
_("Change the animation played by the object, using the name of the "
|
||||
"animation."),
|
||||
_("Change the animation of _PARAM0_ to _PARAM1_"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png",
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition("AnimationName",
|
||||
_("Animation (by name)"),
|
||||
_("Check the animation played by the object."),
|
||||
_("The animation of _PARAM0_ is _PARAM1_"),
|
||||
_("Animations and images"),
|
||||
"res/conditions/animation24.png",
|
||||
"res/conditions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddExpression("AnimationName",
|
||||
_("Animation (by name)"),
|
||||
_("the name of animation played by the object"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.SetRequiredBaseObjectCapability("animable");
|
||||
|
||||
obj.AddAction("PauseAnimation", _("Pause the animation"),
|
||||
_("Pause the animation of the object"),
|
||||
_("Pause the animation of _PARAM0_"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png",
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("PlayAnimation", _("Resume the animation"),
|
||||
_("Resume the animation of the object"),
|
||||
_("Resume the animation of _PARAM0_"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png",
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddExpressionAndConditionAndAction(
|
||||
"number", "AnimationSpeedScale",
|
||||
_("Animation speed scale"),
|
||||
_("the animation speed scale (1 = the default speed, >1 = faster and "
|
||||
"<1 = slower)"),
|
||||
_("the animation speed scale"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation24.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.UseStandardParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Speed scale")))
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("IsAnimationPaused",
|
||||
_("Animation paused"),
|
||||
_("Check if the animation of an object is paused."),
|
||||
_("The animation of _PARAM0_ is paused"),
|
||||
_("Animations and images"),
|
||||
"res/conditions/animation24.png",
|
||||
"res/conditions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("HasAnimationEnded",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
"is finished."),
|
||||
_("The animation of _PARAM0_ is finished"),
|
||||
_("Animations and images"),
|
||||
"res/conditions/animation24.png",
|
||||
"res/conditions/animation.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddRequiredObjectCapabilityOnLastParameter("animable")
|
||||
.SetRequiredBaseObjectCapability("animable")
|
||||
.MarkAsSimple();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -32,7 +32,11 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Animated object which can be used for "
|
||||
"most elements of a game"),
|
||||
"CppPlatform/Extensions/spriteicon.png")
|
||||
.SetCategoryFullName(_("General"));
|
||||
.SetCategoryFullName(_("General"))
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable")
|
||||
.MarkBaseObjectCapabilityAsSupported("scalable")
|
||||
.MarkBaseObjectCapabilityAsSupported("flippable")
|
||||
.MarkBaseObjectCapabilityAsSupported("animable");
|
||||
|
||||
obj.AddAction("Opacity",
|
||||
_("Sprite opacity"),
|
||||
@@ -50,6 +54,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Opacity (0-255)")))
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeAnimation",
|
||||
_("Change the animation"),
|
||||
_("Change the animation of the object, using the animation "
|
||||
@@ -62,8 +67,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetAnimationName",
|
||||
_("Change the animation (by name)"),
|
||||
_("Change the animation of the object, using the name of the "
|
||||
@@ -75,6 +82,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
@@ -107,6 +115,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("PauseAnimation",
|
||||
_("Pause the animation"),
|
||||
_("Pause the animation of the object"),
|
||||
@@ -116,8 +125,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("PlayAnimation",
|
||||
_("Play the animation"),
|
||||
_("Play the animation of the object"),
|
||||
@@ -127,8 +138,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ChangeAnimationSpeedScale",
|
||||
_("Animation speed scale"),
|
||||
@@ -143,8 +156,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.UseStandardOperatorParameters(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(_("Speed scale")))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("TourneVersPos",
|
||||
"Rotate an object toward a position",
|
||||
"Rotate an object towards a position.",
|
||||
@@ -159,8 +174,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("expression", _("Angular speed (degrees per second)"))
|
||||
.SetDefaultValue("0")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden(); // Deprecated
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScale",
|
||||
_("Scale"),
|
||||
_("Modify the scale of the specified object."),
|
||||
@@ -174,8 +190,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScaleWidth",
|
||||
_("Scale on X axis"),
|
||||
_("Modify the scale of the width of an object."),
|
||||
@@ -189,8 +207,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeScaleHeight",
|
||||
_("Scale on Y axis"),
|
||||
_("Modify the scale of the height of an object."),
|
||||
@@ -204,8 +224,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number",
|
||||
ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeWidth",
|
||||
_("Width"),
|
||||
_("Change the width of a Sprite object."),
|
||||
@@ -217,8 +239,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Compare the width of a Sprite object."),
|
||||
@@ -230,8 +254,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("ChangeHeight",
|
||||
_("Height"),
|
||||
_("Change the height of a Sprite object."),
|
||||
@@ -243,8 +269,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Compare the height of a Sprite object."),
|
||||
@@ -256,8 +284,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Change the size of an object."),
|
||||
@@ -269,8 +299,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.MarkAsAdvanced();
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition(
|
||||
"Animation",
|
||||
_("Current animation"),
|
||||
@@ -283,8 +315,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationName",
|
||||
_("Current animation name"),
|
||||
_("Check the animation played by the object."),
|
||||
@@ -295,6 +329,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectAnimationName", _("Animation name"))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddCondition(
|
||||
@@ -328,6 +363,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"number", ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimStopped",
|
||||
_("Animation paused"),
|
||||
_("Check if the animation of an object is paused."),
|
||||
@@ -337,8 +373,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/conditions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationEnded",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
@@ -352,6 +390,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.MarkAsSimple()
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("AnimationEnded2",
|
||||
_("Animation finished"),
|
||||
_("Check if the animation being played by the Sprite object "
|
||||
@@ -362,6 +401,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/conditions/animation.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("ScaleWidth",
|
||||
@@ -456,9 +496,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("FlipY",
|
||||
@@ -468,9 +508,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("FlippedX",
|
||||
@@ -480,8 +520,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
@@ -490,9 +530,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.SetHidden();
|
||||
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("TourneVers",
|
||||
"Rotate an object toward another",
|
||||
"Rotate an object towards another.",
|
||||
@@ -504,7 +545,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectPtr", "Rotate toward this object")
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetHidden(); // Deprecated
|
||||
.SetHidden();
|
||||
|
||||
obj.AddExpression("X",
|
||||
_("X position of a point"),
|
||||
@@ -542,6 +583,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.AddParameter("object", _("Object"), "Sprite")
|
||||
.AddParameter("objectPointName", _("Name of the point"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Direc",
|
||||
_("Direction"),
|
||||
_("Direction of the object"),
|
||||
@@ -550,6 +592,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Direction",
|
||||
_("Direction"),
|
||||
_("Direction of the object"),
|
||||
@@ -559,6 +602,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
// interface.
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("Anim",
|
||||
_("Animation"),
|
||||
_("Animation of the object"),
|
||||
@@ -567,20 +611,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("Animation",
|
||||
_("Animation"),
|
||||
_("Animation of the object"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddStrExpression("AnimationName",
|
||||
_("Animation name"),
|
||||
_("Name of the animation of the object"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("Sprite",
|
||||
_("Image"),
|
||||
_("Current frame of the animation of the object"),
|
||||
@@ -595,27 +625,6 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsSpriteExtension(
|
||||
"res/actions/sprite.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("AnimationSpeedScale",
|
||||
_("Animation speed scale"),
|
||||
_("Animation speed scale"),
|
||||
_("Animations and images"),
|
||||
"res/actions/animation.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("ScaleX",
|
||||
_("Scale of the width of an object"),
|
||||
_("Scale of the width of an object"),
|
||||
_("Size"),
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("ScaleY",
|
||||
_("Scale of the height of an object"),
|
||||
_("Scale of the height of an object"),
|
||||
_("Size"),
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"), "Sprite");
|
||||
|
||||
obj.AddExpression("Opacity",
|
||||
_("Opacity"),
|
||||
_("Opacity"),
|
||||
|
@@ -13,8 +13,6 @@
|
||||
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "ParameterMetadata.h"
|
||||
#include "ParameterOptions.h"
|
||||
|
||||
namespace gd {
|
||||
class Project;
|
||||
@@ -22,6 +20,7 @@ class Layout;
|
||||
class EventsCodeGenerator;
|
||||
class EventsCodeGenerationContext;
|
||||
class SerializerElement;
|
||||
class ObjectType;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
@@ -63,7 +62,13 @@ public:
|
||||
* \see gd::InstructionMetadata::SetParameterExtraInfo
|
||||
*/
|
||||
virtual AbstractFunctionMetadata &
|
||||
SetParameterExtraInfo(const gd::String &defaultValue) = 0;
|
||||
SetParameterExtraInfo(const gd::String &extraInfo) = 0;
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetParameterObjectType
|
||||
*/
|
||||
virtual AbstractFunctionMetadata &
|
||||
SetParameterObjectType(const gd::ObjectType &objectType) = 0;
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetParameterLongDescription
|
||||
|
@@ -11,7 +11,9 @@
|
||||
|
||||
#include "GDCore/Extensions/Metadata/ExpressionMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/Project/ObjectType.h"
|
||||
#include "GDCore/String.h"
|
||||
|
||||
namespace gd {
|
||||
class Behavior;
|
||||
class BehaviorsSharedData;
|
||||
@@ -247,7 +249,7 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
/**
|
||||
* \brief Set the type of the object that this behavior can be used on.
|
||||
*/
|
||||
BehaviorMetadata& SetObjectType(const gd::String& objectType_) {
|
||||
BehaviorMetadata& SetObjectType(const gd::ObjectType& objectType_) {
|
||||
objectType = objectType_;
|
||||
return *this;
|
||||
}
|
||||
@@ -257,7 +259,7 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
*
|
||||
* \note An empty string means the base object, so any object.
|
||||
*/
|
||||
const gd::String& GetObjectType() const { return objectType; }
|
||||
const gd::ObjectType& GetObjectType() const { return objectType; }
|
||||
|
||||
/**
|
||||
* Check if the behavior is private - it can't be used outside of its
|
||||
@@ -329,7 +331,7 @@ class GD_CORE_API BehaviorMetadata : public InstructionOrExpressionContainerMeta
|
||||
gd::String description;
|
||||
gd::String group;
|
||||
gd::String iconFilename;
|
||||
gd::String objectType;
|
||||
gd::ObjectType objectType;
|
||||
bool isPrivate = false;
|
||||
|
||||
// TODO: Nitpicking: convert these to std::unique_ptr to clarify ownership.
|
||||
|
@@ -42,21 +42,25 @@ gd::ExpressionMetadata& ExpressionMetadata::AddParameter(
|
||||
info.description = description;
|
||||
info.codeOnly = false;
|
||||
info.SetOptional(parameterIsOptional);
|
||||
info.SetExtraInfo(
|
||||
|
||||
gd::String fixedSupplementaryInformation =
|
||||
// For objects/behavior, the supplementary information
|
||||
// parameter is an object/behavior type...
|
||||
((gd::ParameterMetadata::IsObject(type) ||
|
||||
gd::ParameterMetadata::IsBehavior(type))
|
||||
gd::ParameterMetadata::IsBehavior(type))
|
||||
// Prefix with the namespace if it's not already there.
|
||||
&& !(supplementaryInformation.rfind(extensionNamespace, 0) == 0))
|
||||
? (supplementaryInformation.empty()
|
||||
? ""
|
||||
: extensionNamespace +
|
||||
supplementaryInformation //... so prefix it with the extension
|
||||
// namespace.
|
||||
)
|
||||
: supplementaryInformation); // Otherwise don't change anything
|
||||
|
||||
//... so prefix it with the extension namespace.
|
||||
: extensionNamespace + supplementaryInformation)
|
||||
// Otherwise don't change anything
|
||||
: supplementaryInformation;
|
||||
if (gd::ParameterMetadata::IsObject(type)) {
|
||||
info.GetValueTypeMetadata().GetObjectType().SetName(fixedSupplementaryInformation);
|
||||
} else {
|
||||
info.SetExtraInfo(fixedSupplementaryInformation);
|
||||
}
|
||||
// TODO: Assert against supplementaryInformation === "emsc" (when running with
|
||||
// Emscripten), and warn about a missing argument when calling addParameter.
|
||||
|
||||
@@ -75,8 +79,7 @@ gd::ExpressionMetadata& ExpressionMetadata::AddCodeOnlyParameter(
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
gd::ExpressionMetadata& ExpressionMetadata::SetRequiresBaseObjectCapability(
|
||||
gd::ExpressionMetadata& ExpressionMetadata::SetRequiredBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
requiredBaseObjectCapability = capability;
|
||||
return *this;
|
||||
|
@@ -224,13 +224,41 @@ class GD_CORE_API ExpressionMetadata : public gd::AbstractFunctionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the type of object accepted by the last parameter (only apply
|
||||
* for object parameter).
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
ExpressionMetadata &
|
||||
SetParameterObjectType(const gd::ObjectType &objectType) override {
|
||||
if (!parameters.empty()) {
|
||||
parameters.back().GetValueTypeMetadata().SetObjectType(objectType);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the capabilities of the objects accepted by the last parameter
|
||||
* (only apply for object parameter).
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
ExpressionMetadata &
|
||||
AddRequiredObjectCapabilityOnLastParameter(const gd::String &capability) {
|
||||
if (!parameters.empty()) {
|
||||
parameters.back().GetValueTypeMetadata().GetObjectType().AddCapability(capability);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mark this (object) expression as requiring the specified capability,
|
||||
* offered by the base object.
|
||||
* This is useful for some objects that don't support this capability, so that
|
||||
* the editor can hide the expression as it does not apply to them.
|
||||
*/
|
||||
ExpressionMetadata& SetRequiresBaseObjectCapability(
|
||||
ExpressionMetadata& SetRequiredBaseObjectCapability(
|
||||
const gd::String& capability);
|
||||
|
||||
/**
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/Tools/Log.h"
|
||||
#include "ParameterMetadata.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadata.h"
|
||||
|
||||
namespace gd {
|
||||
InstructionMetadata::InstructionMetadata()
|
||||
@@ -60,22 +60,25 @@ InstructionMetadata& InstructionMetadata::AddParameter(
|
||||
info.description = description;
|
||||
info.codeOnly = false;
|
||||
info.SetOptional(parameterIsOptional);
|
||||
info.SetExtraInfo(
|
||||
|
||||
gd::String fixedSupplementaryInformation =
|
||||
// For objects/behavior, the supplementary information
|
||||
// parameter is an object/behavior type...
|
||||
((gd::ParameterMetadata::IsObject(type) ||
|
||||
gd::ParameterMetadata::IsBehavior(type))
|
||||
gd::ParameterMetadata::IsBehavior(type))
|
||||
// Prefix with the namespace if it's not already there.
|
||||
&& !(supplementaryInformation.rfind(extensionNamespace, 0) == 0))
|
||||
? (supplementaryInformation.empty()
|
||||
? ""
|
||||
: extensionNamespace +
|
||||
supplementaryInformation //... so prefix it with the
|
||||
// extension
|
||||
// namespace.
|
||||
)
|
||||
: supplementaryInformation); // Otherwise don't change anything
|
||||
|
||||
//... so prefix it with the extension namespace.
|
||||
: extensionNamespace + supplementaryInformation)
|
||||
// Otherwise don't change anything
|
||||
: supplementaryInformation;
|
||||
if (gd::ParameterMetadata::IsObject(type)) {
|
||||
info.GetValueTypeMetadata().GetObjectType().SetName(fixedSupplementaryInformation);
|
||||
} else {
|
||||
info.SetExtraInfo(fixedSupplementaryInformation);
|
||||
}
|
||||
// TODO: Assert against supplementaryInformation === "emsc" (when running with
|
||||
// Emscripten), and warn about a missing argument when calling addParameter.
|
||||
|
||||
@@ -212,7 +215,7 @@ InstructionMetadata::UseStandardRelationalOperatorParameters(
|
||||
return *this;
|
||||
}
|
||||
|
||||
InstructionMetadata& InstructionMetadata::SetRequiresBaseObjectCapability(
|
||||
InstructionMetadata& InstructionMetadata::SetRequiredBaseObjectCapability(
|
||||
const gd::String& capability) {
|
||||
if (!IsObjectInstruction() && !IsBehaviorInstruction()) {
|
||||
gd::LogError("Tried to add capability \"" + capability +
|
||||
|
@@ -24,7 +24,7 @@ class Layout;
|
||||
class EventsCodeGenerator;
|
||||
class EventsCodeGenerationContext;
|
||||
class SerializerElement;
|
||||
} // namespace gd
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -36,17 +36,14 @@ namespace gd {
|
||||
* \ingroup Events
|
||||
*/
|
||||
class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Construct a new instruction metadata.
|
||||
*/
|
||||
InstructionMetadata(const gd::String &extensionNamespace,
|
||||
const gd::String &name,
|
||||
const gd::String &fullname,
|
||||
const gd::String &description,
|
||||
const gd::String &sentence,
|
||||
const gd::String &group,
|
||||
const gd::String &icon,
|
||||
const gd::String &name, const gd::String &fullname,
|
||||
const gd::String &description, const gd::String &sentence,
|
||||
const gd::String &group, const gd::String &icon,
|
||||
const gd::String &smallIcon);
|
||||
|
||||
/**
|
||||
@@ -229,11 +226,10 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
*
|
||||
* \see EventsCodeGenerator::GenerateParametersCodes
|
||||
*/
|
||||
InstructionMetadata &AddParameter(
|
||||
const gd::String &type,
|
||||
const gd::String &label,
|
||||
const gd::String &supplementaryInformation = "",
|
||||
bool parameterIsOptional = false) override;
|
||||
InstructionMetadata &
|
||||
AddParameter(const gd::String &type, const gd::String &label,
|
||||
const gd::String &supplementaryInformation = "",
|
||||
bool parameterIsOptional = false) override;
|
||||
|
||||
/**
|
||||
* \brief Add a parameter not displayed in editor.
|
||||
@@ -246,8 +242,9 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
*
|
||||
* \see EventsCodeGenerator::GenerateParametersCodes
|
||||
*/
|
||||
InstructionMetadata &AddCodeOnlyParameter(
|
||||
const gd::String &type, const gd::String &supplementaryInformation) override;
|
||||
InstructionMetadata &
|
||||
AddCodeOnlyParameter(const gd::String &type,
|
||||
const gd::String &supplementaryInformation) override;
|
||||
|
||||
/**
|
||||
* \brief Set the default value used in editor (or if an optional parameter is
|
||||
@@ -255,8 +252,10 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &SetDefaultValue(const gd::String &defaultValue_) override {
|
||||
if (!parameters.empty()) parameters.back().SetDefaultValue(defaultValue_);
|
||||
InstructionMetadata &
|
||||
SetDefaultValue(const gd::String &defaultValue_) override {
|
||||
if (!parameters.empty())
|
||||
parameters.back().SetDefaultValue(defaultValue_);
|
||||
return *this;
|
||||
};
|
||||
|
||||
@@ -266,8 +265,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &SetParameterLongDescription(
|
||||
const gd::String &longDescription) override {
|
||||
InstructionMetadata &
|
||||
SetParameterLongDescription(const gd::String &longDescription) override {
|
||||
if (!parameters.empty())
|
||||
parameters.back().SetLongDescription(longDescription);
|
||||
return *this;
|
||||
@@ -280,8 +279,38 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &SetParameterExtraInfo(const gd::String &extraInfo) override {
|
||||
if (!parameters.empty()) parameters.back().SetExtraInfo(extraInfo);
|
||||
InstructionMetadata &
|
||||
SetParameterExtraInfo(const gd::String &extraInfo) override {
|
||||
if (!parameters.empty())
|
||||
parameters.back().SetExtraInfo(extraInfo);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the type of object accepted by the last parameter (only apply
|
||||
* for object parameter).
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &
|
||||
SetParameterObjectType(const gd::ObjectType &objectType) override {
|
||||
if (!parameters.empty()) {
|
||||
parameters.back().GetValueTypeMetadata().SetObjectType(objectType);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the capabilities of the objects accepted by the last parameter
|
||||
* (only apply for object parameter).
|
||||
*
|
||||
* \see AddParameter
|
||||
*/
|
||||
InstructionMetadata &
|
||||
AddRequiredObjectCapabilityOnLastParameter(const gd::String &capability) {
|
||||
if (!parameters.empty()) {
|
||||
parameters.back().GetValueTypeMetadata().GetObjectType().AddCapability(capability);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -292,8 +321,9 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
* \note The type "string" can be declined in several subtypes.
|
||||
* \see ParameterMetadata
|
||||
*/
|
||||
InstructionMetadata &UseStandardOperatorParameters(
|
||||
const gd::String &type, const ParameterOptions &options);
|
||||
InstructionMetadata &
|
||||
UseStandardOperatorParameters(const gd::String &type,
|
||||
const ParameterOptions &options);
|
||||
|
||||
/**
|
||||
* \brief Add the default parameters for an instruction comparing the
|
||||
@@ -302,8 +332,9 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
* \note The type "string" can be declined in several subtypes.
|
||||
* \see ParameterMetadata
|
||||
*/
|
||||
InstructionMetadata &UseStandardRelationalOperatorParameters(
|
||||
const gd::String &type, const ParameterOptions &options);
|
||||
InstructionMetadata &
|
||||
UseStandardRelationalOperatorParameters(const gd::String &type,
|
||||
const ParameterOptions &options);
|
||||
|
||||
/**
|
||||
* \brief Mark the instruction as an object instruction. Automatically called
|
||||
@@ -339,8 +370,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
* that don't support this capability, so that the editor can hide the
|
||||
* instruction as it does not apply to them.
|
||||
*/
|
||||
InstructionMetadata &SetRequiresBaseObjectCapability(
|
||||
const gd::String &capability);
|
||||
InstructionMetadata &
|
||||
SetRequiredBaseObjectCapability(const gd::String &capability);
|
||||
|
||||
/**
|
||||
* \brief Get the required specified capability for this (object) instruction,
|
||||
@@ -384,8 +415,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
/**
|
||||
* \brief Defines information about how generate the code for an instruction
|
||||
*/
|
||||
class ExtraInformation {
|
||||
public:
|
||||
class ExtraInformation {
|
||||
public:
|
||||
enum AccessType { Reference, MutatorAndOrAccessor, Mutators };
|
||||
ExtraInformation() : accessType(Reference), hasCustomCodeGenerator(false){};
|
||||
virtual ~ExtraInformation(){};
|
||||
@@ -399,19 +430,20 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
std::map<gd::String, gd::String> optionalMutators;
|
||||
bool hasCustomCodeGenerator;
|
||||
std::function<gd::String(Instruction &instruction,
|
||||
gd::EventsCodeGenerator &codeGenerator,
|
||||
gd::EventsCodeGenerationContext &context)>
|
||||
gd::EventsCodeGenerator &codeGenerator,
|
||||
gd::EventsCodeGenerationContext &context)>
|
||||
customCodeGenerator;
|
||||
std::vector<gd::String> includeFiles;
|
||||
};
|
||||
ExtraInformation codeExtraInformation; ///< Information about how generate
|
||||
///< code for the instruction
|
||||
ExtraInformation codeExtraInformation; ///< Information about how generate
|
||||
///< code for the instruction
|
||||
|
||||
/**
|
||||
* Set the name of the function which will be called in the generated code.
|
||||
* \param functionName the name of the function to call.
|
||||
*/
|
||||
InstructionMetadata &SetFunctionName(const gd::String &functionName_) override {
|
||||
InstructionMetadata &
|
||||
SetFunctionName(const gd::String &functionName_) override {
|
||||
codeExtraInformation.functionCallName = functionName_;
|
||||
return *this;
|
||||
}
|
||||
@@ -445,12 +477,12 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
return codeExtraInformation.asyncFunctionCallName;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Declare if the instruction being declared is somewhat manipulating
|
||||
* in a standard way.
|
||||
*
|
||||
* \param type "number" or "string"
|
||||
*/
|
||||
/**
|
||||
* \brief Declare if the instruction being declared is somewhat manipulating
|
||||
* in a standard way.
|
||||
*
|
||||
* \param type "number" or "string"
|
||||
*/
|
||||
InstructionMetadata &SetManipulatedType(const gd::String &type_) {
|
||||
codeExtraInformation.type = type_;
|
||||
return *this;
|
||||
@@ -485,8 +517,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
InstructionMetadata &SetMutators(
|
||||
const std::map<gd::String, gd::String> &mutators) {
|
||||
InstructionMetadata &
|
||||
SetMutators(const std::map<gd::String, gd::String> &mutators) {
|
||||
codeExtraInformation.optionalMutators = mutators;
|
||||
codeExtraInformation.accessType = codeExtraInformation.Mutators;
|
||||
return *this;
|
||||
@@ -505,8 +537,9 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
* \brief Add a file to the already existing include files.
|
||||
*/
|
||||
InstructionMetadata &AddIncludeFile(const gd::String &includeFile) override {
|
||||
if (std::find(codeExtraInformation.includeFiles.begin(), codeExtraInformation.includeFiles.end(), includeFile) ==
|
||||
codeExtraInformation.includeFiles.end())
|
||||
if (std::find(codeExtraInformation.includeFiles.begin(),
|
||||
codeExtraInformation.includeFiles.end(),
|
||||
includeFile) == codeExtraInformation.includeFiles.end())
|
||||
codeExtraInformation.includeFiles.push_back(includeFile);
|
||||
|
||||
return *this;
|
||||
@@ -521,8 +554,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
|
||||
InstructionMetadata &SetCustomCodeGenerator(
|
||||
std::function<gd::String(Instruction &instruction,
|
||||
gd::EventsCodeGenerator &codeGenerator,
|
||||
gd::EventsCodeGenerationContext &context)>
|
||||
gd::EventsCodeGenerator &codeGenerator,
|
||||
gd::EventsCodeGenerationContext &context)>
|
||||
codeGenerator) {
|
||||
codeExtraInformation.hasCustomCodeGenerator = true;
|
||||
codeExtraInformation.customCodeGenerator = codeGenerator;
|
||||
@@ -532,26 +565,28 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
InstructionMetadata &RemoveCustomCodeGenerator() {
|
||||
codeExtraInformation.hasCustomCodeGenerator = false;
|
||||
std::function<gd::String(Instruction & instruction,
|
||||
gd::EventsCodeGenerator & codeGenerator,
|
||||
gd::EventsCodeGenerationContext & context)>
|
||||
gd::EventsCodeGenerator & codeGenerator,
|
||||
gd::EventsCodeGenerationContext & context)>
|
||||
emptyFunction;
|
||||
codeExtraInformation.customCodeGenerator = emptyFunction;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool HasCustomCodeGenerator() const { return codeExtraInformation.hasCustomCodeGenerator; }
|
||||
bool HasCustomCodeGenerator() const {
|
||||
return codeExtraInformation.hasCustomCodeGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return the structure containing the information about code
|
||||
* generation for the instruction.
|
||||
*
|
||||
*
|
||||
* \deprecated
|
||||
*/
|
||||
InstructionMetadata &GetCodeExtraInformation() { return *this; }
|
||||
|
||||
std::vector<ParameterMetadata> parameters;
|
||||
|
||||
private:
|
||||
private:
|
||||
gd::String fullname;
|
||||
gd::String description;
|
||||
gd::String helpPath;
|
||||
@@ -562,8 +597,8 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
bool canHaveSubInstructions;
|
||||
gd::String extensionNamespace;
|
||||
bool hidden;
|
||||
int usageComplexity; ///< Evaluate the instruction from 0 (simple&easy to
|
||||
///< use) to 10 (complex to understand)
|
||||
int usageComplexity; ///< Evaluate the instruction from 0 (simple&easy to
|
||||
///< use) to 10 (complex to understand)
|
||||
bool isPrivate;
|
||||
bool isObjectInstruction;
|
||||
bool isBehaviorInstruction;
|
||||
@@ -571,4 +606,4 @@ class GD_CORE_API InstructionMetadata : public gd::AbstractFunctionMetadata {
|
||||
gd::String relevantContext;
|
||||
};
|
||||
|
||||
} // namespace gd
|
||||
} // namespace gd
|
||||
|
@@ -85,13 +85,47 @@ class GD_CORE_API MultipleInstructionMetadata : public AbstractFunctionMetadata
|
||||
* \see gd::InstructionMetadata::SetParameterExtraInfo
|
||||
*/
|
||||
MultipleInstructionMetadata &SetParameterExtraInfo(
|
||||
const gd::String &defaultValue) override {
|
||||
if (expression) expression->SetParameterExtraInfo(defaultValue);
|
||||
if (condition) condition->SetParameterExtraInfo(defaultValue);
|
||||
if (action) action->SetParameterExtraInfo(defaultValue);
|
||||
const gd::String &extraInfo) override {
|
||||
if (expression) expression->SetParameterExtraInfo(extraInfo);
|
||||
if (condition) condition->SetParameterExtraInfo(extraInfo);
|
||||
if (action) action->SetParameterExtraInfo(extraInfo);
|
||||
return *this;
|
||||
};
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetParameterObjectType
|
||||
*/
|
||||
MultipleInstructionMetadata &
|
||||
SetParameterObjectType(const gd::ObjectType &objectType) override {
|
||||
if (expression) {
|
||||
expression->SetParameterObjectType(objectType);
|
||||
}
|
||||
if (condition) {
|
||||
condition->SetParameterObjectType(objectType);
|
||||
}
|
||||
if (action) {
|
||||
action->SetParameterObjectType(objectType);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::AddRequiredObjectCapabilityOnLastParameter
|
||||
*/
|
||||
MultipleInstructionMetadata &
|
||||
AddRequiredObjectCapabilityOnLastParameter(const gd::String &capability) {
|
||||
if (expression) {
|
||||
expression->AddRequiredObjectCapabilityOnLastParameter(capability);
|
||||
}
|
||||
if (condition) {
|
||||
condition->AddRequiredObjectCapabilityOnLastParameter(capability);
|
||||
}
|
||||
if (action) {
|
||||
action->AddRequiredObjectCapabilityOnLastParameter(capability);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetParameterLongDescription
|
||||
*/
|
||||
@@ -114,13 +148,13 @@ class GD_CORE_API MultipleInstructionMetadata : public AbstractFunctionMetadata
|
||||
};
|
||||
|
||||
/**
|
||||
* \see gd::InstructionMetadata::SetRequiresBaseObjectCapability
|
||||
* \see gd::InstructionMetadata::SetRequiredBaseObjectCapability
|
||||
*/
|
||||
MultipleInstructionMetadata &SetRequiresBaseObjectCapability(
|
||||
MultipleInstructionMetadata &SetRequiredBaseObjectCapability(
|
||||
const gd::String &capability) {
|
||||
if (expression) expression->SetRequiresBaseObjectCapability(capability);
|
||||
if (condition) condition->SetRequiresBaseObjectCapability(capability);
|
||||
if (action) action->SetRequiresBaseObjectCapability(capability);
|
||||
if (expression) expression->SetRequiredBaseObjectCapability(capability);
|
||||
if (condition) condition->SetRequiredBaseObjectCapability(capability);
|
||||
if (action) action->SetRequiredBaseObjectCapability(capability);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,7 @@ ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
return blueprintObject_->Clone();
|
||||
}) {
|
||||
blueprintObject = blueprintObject_;
|
||||
supportedBaseObjectCapabilities.insert("effect");
|
||||
}
|
||||
|
||||
ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
@@ -56,7 +57,9 @@ ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
"Error: Event-based objects don't have blueprint. "
|
||||
"This method should not never be called.");
|
||||
return nullptr;
|
||||
}) {}
|
||||
}) {
|
||||
supportedBaseObjectCapabilities.insert("effect");
|
||||
}
|
||||
|
||||
ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
const gd::String& name_,
|
||||
@@ -70,6 +73,7 @@ ObjectMetadata::ObjectMetadata(const gd::String& extensionNamespace_,
|
||||
extensionNamespace(extensionNamespace_) {
|
||||
SetFullName(gd::String(fullname_));
|
||||
SetDescription(gd::String(description_));
|
||||
supportedBaseObjectCapabilities.insert("effect");
|
||||
}
|
||||
|
||||
gd::InstructionMetadata& ObjectMetadata::AddCondition(
|
||||
|
@@ -225,29 +225,41 @@ class GD_CORE_API ObjectMetadata : public InstructionOrExpressionContainerMetada
|
||||
|
||||
/**
|
||||
* \brief The "capabilities" that are offered by the base object that are
|
||||
* *not* supported by this object, and should be hidden in the editor
|
||||
* supported by this object, and should *not* be hidden in the editor
|
||||
* interface.
|
||||
*/
|
||||
const std::set<gd::String>& GetUnsupportedBaseObjectCapabilities() const {
|
||||
return unsupportedBaseObjectCapabilities;
|
||||
const std::set<gd::String>& GetSupportedBaseObjectCapabilities() const {
|
||||
return supportedBaseObjectCapabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Add a "capability" that is offered by the base object that is *not*
|
||||
* supported by this object, and should be hidden in the editor interface.
|
||||
* \brief Add a "capability" that is offered by the base object that is
|
||||
* supported by this object, and should *not* be hidden in the editor interface.
|
||||
*/
|
||||
ObjectMetadata& AddUnsupportedBaseObjectCapability(
|
||||
ObjectMetadata& MarkBaseObjectCapabilityAsSupported(
|
||||
const gd::String& capability) {
|
||||
unsupportedBaseObjectCapabilities.insert(capability);
|
||||
supportedBaseObjectCapabilities.insert(capability);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if a "capability" that is offered by the base object is *not*
|
||||
* \brief Remove a "capability" that is offered by the base object that is *not*
|
||||
* supported by this object, and should be hidden in the editor interface.
|
||||
*/
|
||||
bool IsUnsupportedBaseObjectCapability(const gd::String& capability) const {
|
||||
return unsupportedBaseObjectCapabilities.find(capability) != unsupportedBaseObjectCapabilities.end();
|
||||
ObjectMetadata& MarkBaseObjectCapabilityAsUnsupported(
|
||||
const gd::String& capability) {
|
||||
supportedBaseObjectCapabilities.erase(capability);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if a "capability" that is offered by the base object is
|
||||
* supported by this object, and should *not* be hidden in the editor interface.
|
||||
*/
|
||||
bool IsSupportedBaseObjectCapability(const gd::String& capability) const {
|
||||
return capability.empty() ||
|
||||
supportedBaseObjectCapabilities.find(capability) !=
|
||||
supportedBaseObjectCapabilities.end();
|
||||
}
|
||||
|
||||
const gd::String& GetName() const override { return name; }
|
||||
@@ -331,7 +343,7 @@ class GD_CORE_API ObjectMetadata : public InstructionOrExpressionContainerMetada
|
||||
gd::String description;
|
||||
gd::String iconFilename;
|
||||
gd::String categoryFullName;
|
||||
std::set<gd::String> unsupportedBaseObjectCapabilities;
|
||||
std::set<gd::String> supportedBaseObjectCapabilities;
|
||||
bool hidden = false;
|
||||
|
||||
std::shared_ptr<gd::ObjectConfiguration>
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/Extensions/Metadata/ValueTypeMetadata.h"
|
||||
#include "GDCore/Project/ObjectType.h"
|
||||
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
@@ -34,6 +35,11 @@ class GD_CORE_API ParameterMetadata {
|
||||
*/
|
||||
gd::ValueTypeMetadata &GetValueTypeMetadata() { return valueTypeMetadata; }
|
||||
|
||||
/**
|
||||
* \brief Return the metadata of the parameter type.
|
||||
*/
|
||||
const gd::ValueTypeMetadata &GetValueTypeMetadata() const { return valueTypeMetadata; }
|
||||
|
||||
/**
|
||||
* \brief Set the metadata of the parameter type.
|
||||
*/
|
||||
|
@@ -27,9 +27,10 @@ void ParameterMetadataTools::ParametersToObjectsContainer(
|
||||
if (parameter.GetName().empty()) continue;
|
||||
|
||||
if (gd::ParameterMetadata::IsObject(parameter.GetType())) {
|
||||
// TODO Declare object capabilities
|
||||
outputObjectsContainer.InsertNewObject(
|
||||
project,
|
||||
parameter.GetExtraInfo(),
|
||||
parameter.GetValueTypeMetadata().GetObjectType().GetName(),
|
||||
parameter.GetName(),
|
||||
outputObjectsContainer.GetObjectsCount());
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadata.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
@@ -17,6 +18,9 @@ void ValueTypeMetadata::SerializeTo(SerializerElement& element) const {
|
||||
if (!supplementaryInformation.empty()) {
|
||||
element.SetAttribute("supplementaryInformation", supplementaryInformation);
|
||||
}
|
||||
if (gd::ParameterMetadata::IsObject(name)) {
|
||||
objectType.SerializeTo(element);
|
||||
}
|
||||
if (optional) {
|
||||
element.SetAttribute("optional", optional);
|
||||
}
|
||||
@@ -29,6 +33,16 @@ void ValueTypeMetadata::UnserializeFrom(const SerializerElement& element) {
|
||||
name = element.GetStringAttribute("type");
|
||||
supplementaryInformation =
|
||||
element.GetStringAttribute("supplementaryInformation");
|
||||
if (gd::ParameterMetadata::IsObject(name)) {
|
||||
objectType.UnserializeFrom(element);
|
||||
// Compatibility with GD <= 4.2.166
|
||||
if (!element.HasAttribute("objectType") && !supplementaryInformation.empty()) {
|
||||
objectType.SetName(supplementaryInformation);
|
||||
supplementaryInformation = "";
|
||||
}
|
||||
std::cout << "Unserialized object type: " << objectType.GetName() << std::endl;
|
||||
}
|
||||
// end of compatibility code
|
||||
optional = element.GetBoolAttribute("optional");
|
||||
defaultValue = element.GetStringAttribute("defaultValue");
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "GDCore/Project/ObjectType.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
@@ -58,6 +59,23 @@ class GD_CORE_API ValueTypeMetadata {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the object type.
|
||||
*/
|
||||
gd::ObjectType& GetObjectType() { return objectType; };
|
||||
|
||||
/**
|
||||
* \brief Get the type of the object.
|
||||
*/
|
||||
const gd::ObjectType& GetObjectType() const { return objectType; }
|
||||
|
||||
/**
|
||||
* \brief Set the type of the object.
|
||||
*/
|
||||
void SetObjectType(const gd::ObjectType& objectType_) {
|
||||
objectType = objectType_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Return true if the parameter is optional.
|
||||
*/
|
||||
@@ -237,6 +255,7 @@ class GD_CORE_API ValueTypeMetadata {
|
||||
private:
|
||||
gd::String name; ///< Parameter type
|
||||
gd::String supplementaryInformation; ///< Used if needed
|
||||
gd::ObjectType objectType;
|
||||
bool optional; ///< True if the parameter is optional
|
||||
gd::String defaultValue; ///< Used as a default value in editor or if an
|
||||
///< optional parameter is empty.
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/ExternalEvents.h"
|
||||
#include "GDCore/IDE/DependenciesAnalyzer.h"
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -97,8 +99,9 @@ class GD_CORE_API IdentifierFinderExpressionNodeWorker
|
||||
auto& parameterNode = node.parameters[parameterIndex];
|
||||
++parameterIndex;
|
||||
|
||||
if (considerFunction && parameterMetadata.GetType() == "identifier"
|
||||
&& parameterMetadata.GetExtraInfo() == identifierType) {
|
||||
if (considerFunction &&
|
||||
parameterMetadata.GetType() == "identifier" &&
|
||||
parameterMetadata.GetExtraInfo() == identifierType) {
|
||||
// Store the value of the parameter
|
||||
results.insert(
|
||||
gd::ExpressionParser2NodePrinter::PrintNode(*parameterNode));
|
||||
@@ -149,8 +152,8 @@ class GD_CORE_API IdentifierFinderEventWorker
|
||||
platform, instruction.GetType());
|
||||
for (std::size_t pNb = 0; pNb < instrInfos.parameters.size(); ++pNb) {
|
||||
// The parameter has the searched type...
|
||||
if (instrInfos.parameters[pNb].GetType() == "identifier"
|
||||
&& instrInfos.parameters[pNb].GetExtraInfo() == identifierType) {
|
||||
if (instrInfos.parameters[pNb].GetType() == "identifier" &&
|
||||
instrInfos.parameters[pNb].GetExtraInfo() == identifierType) {
|
||||
//...remember the value of the parameter.
|
||||
if (objectName.empty() || lastObjectParameter == objectName) {
|
||||
results.insert(instruction.GetParameter(pNb).GetPlainString());
|
||||
@@ -158,9 +161,9 @@ class GD_CORE_API IdentifierFinderEventWorker
|
||||
}
|
||||
// Search in expressions
|
||||
else if (ParameterMetadata::IsExpression(
|
||||
"number", instrInfos.parameters[pNb].GetType()) ||
|
||||
ParameterMetadata::IsExpression(
|
||||
"string", instrInfos.parameters[pNb].GetType())) {
|
||||
"number", instrInfos.parameters[pNb].GetType()) ||
|
||||
ParameterMetadata::IsExpression(
|
||||
"string", instrInfos.parameters[pNb].GetType())) {
|
||||
auto node = instruction.GetParameter(pNb).GetRootNode();
|
||||
|
||||
IdentifierFinderExpressionNodeWorker searcher(
|
||||
@@ -174,7 +177,7 @@ class GD_CORE_API IdentifierFinderEventWorker
|
||||
}
|
||||
// Remember the value of the last "object" parameter.
|
||||
else if (gd::ParameterMetadata::IsObject(
|
||||
instrInfos.parameters[pNb].GetType())) {
|
||||
instrInfos.parameters[pNb].GetType())) {
|
||||
lastObjectParameter =
|
||||
instruction.GetParameter(pNb).GetPlainString();
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ ExpressionValidator::Type ExpressionValidator::ValidateFunction(const gd::Functi
|
||||
const gd::ObjectMetadata &objectMetadata =
|
||||
MetadataProvider::GetObjectMetadata(platform, objectType);
|
||||
|
||||
if (objectMetadata.IsUnsupportedBaseObjectCapability(
|
||||
if (!objectMetadata.IsSupportedBaseObjectCapability(
|
||||
metadata.GetRequiredBaseObjectCapability())) {
|
||||
RaiseTypeError(
|
||||
_("This expression exists, but it can't be used on this object."),
|
||||
|
@@ -15,8 +15,8 @@ namespace gd {
|
||||
|
||||
void BehaviorObjectTypeRenamer::DoVisitEventBasedBehavior(
|
||||
gd::EventsBasedBehavior &eventsBasedBehavior) {
|
||||
if (eventsBasedBehavior.GetObjectType() == oldObjectType) {
|
||||
eventsBasedBehavior.SetObjectType(newObjectType);
|
||||
if (eventsBasedBehavior.GetObjectType().GetName() == oldObjectType) {
|
||||
eventsBasedBehavior.GetObjectType().SetName(newObjectType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,15 +10,17 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
void FunctionParameterObjectTypeRenamer::DoVisitEventsFunction(
|
||||
gd::EventsFunction &eventsFunction) {
|
||||
for (auto &¶meter : eventsFunction.GetParameters()) {
|
||||
auto &objectType = parameter.GetValueTypeMetadata().GetObjectType();
|
||||
if (gd::ParameterMetadata::IsObject(parameter.GetType()) &&
|
||||
parameter.GetExtraInfo() == oldObjectType) {
|
||||
parameter.SetExtraInfo(newObjectType);
|
||||
objectType.GetName() == oldObjectType) {
|
||||
objectType.SetName(newObjectType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "GDCore/Project/EventsBasedObject.h"
|
||||
#include "GDCore/Project/EventsFunctionsExtension.h"
|
||||
#include "GDCore/Project/EventsFunction.h"
|
||||
#include "GDCore/Project/ObjectType.h"
|
||||
#include "GDCore/Project/Project.h"
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#include "GDCore/String.h"
|
||||
@@ -32,14 +33,16 @@ void PropertyFunctionGenerator::GenerateObjectGetterAndSetter(
|
||||
gd::Project &project, gd::EventsFunctionsExtension &extension,
|
||||
gd::EventsBasedObject &eventsBasedObject,
|
||||
const gd::NamedPropertyDescriptor &property) {
|
||||
GenerateGetterAndSetter(project, extension, eventsBasedObject, property, "",
|
||||
gd::ObjectType objectType;
|
||||
objectType.SetName(gd::PlatformExtension::GetObjectFullType(extension.GetName(), eventsBasedObject.GetName()));
|
||||
GenerateGetterAndSetter(project, extension, eventsBasedObject, property, objectType,
|
||||
false, false);
|
||||
}
|
||||
|
||||
void PropertyFunctionGenerator::GenerateGetterAndSetter(
|
||||
gd::Project &project, gd::EventsFunctionsExtension &extension,
|
||||
gd::AbstractEventsBasedEntity &eventsBasedEntity,
|
||||
const gd::NamedPropertyDescriptor &property, const gd::String &objectType,
|
||||
const gd::NamedPropertyDescriptor &property, const gd::ObjectType &objectType,
|
||||
bool isBehavior, bool isSharedProperties) {
|
||||
auto &propertyName = property.GetName();
|
||||
auto &functionsContainer = eventsBasedEntity.GetEventsFunctions();
|
||||
@@ -151,7 +154,8 @@ void PropertyFunctionGenerator::GenerateGetterAndSetter(
|
||||
objectParameter.SetType("object")
|
||||
.SetName("Object")
|
||||
.SetDescription("Object")
|
||||
.SetExtraInfo(objectType);
|
||||
.GetValueTypeMetadata()
|
||||
.SetObjectType(objectType);
|
||||
if (!isBehavior) {
|
||||
gd::String objectFullType = gd::PlatformExtension::GetObjectFullType(
|
||||
extension.GetName(), eventsBasedEntity.GetName());
|
||||
|
@@ -16,6 +16,7 @@ class EventsBasedObject;
|
||||
class AbstractEventsBasedEntity;
|
||||
class PropertyDescriptor;
|
||||
class NamedPropertyDescriptor;
|
||||
class ObjectType;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
@@ -60,7 +61,7 @@ class GD_CORE_API PropertyFunctionGenerator {
|
||||
gd::EventsFunctionsExtension &extension,
|
||||
gd::AbstractEventsBasedEntity &eventsBasedEntity,
|
||||
const gd::NamedPropertyDescriptor &property,
|
||||
const gd::String &objectType,
|
||||
const gd::ObjectType &objectType,
|
||||
bool isBehavior,
|
||||
bool isSharedProperties);
|
||||
|
||||
|
@@ -102,7 +102,8 @@ void WholeProjectRefactorer::EnsureBehaviorEventsFunctionsProperParameters(
|
||||
.SetType("object")
|
||||
.SetName(behaviorObjectParameterName)
|
||||
.SetDescription("Object")
|
||||
.SetExtraInfo(eventsBasedBehavior.GetObjectType());
|
||||
.GetValueTypeMetadata()
|
||||
.SetObjectType(eventsBasedBehavior.GetObjectType());
|
||||
parameters[1]
|
||||
.SetType("behavior")
|
||||
.SetName("Behavior")
|
||||
|
@@ -17,7 +17,7 @@ EventsBasedBehavior::EventsBasedBehavior()
|
||||
|
||||
void EventsBasedBehavior::SerializeTo(SerializerElement& element) const {
|
||||
AbstractEventsBasedEntity::SerializeTo(element);
|
||||
element.SetAttribute("objectType", objectType);
|
||||
objectType.SerializeTo(element);
|
||||
if (isPrivate) {
|
||||
element.SetBoolAttribute("private", isPrivate);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ void EventsBasedBehavior::SerializeTo(SerializerElement& element) const {
|
||||
void EventsBasedBehavior::UnserializeFrom(gd::Project& project,
|
||||
const SerializerElement& element) {
|
||||
AbstractEventsBasedEntity::UnserializeFrom(project, element);
|
||||
objectType = element.GetStringAttribute("objectType");
|
||||
objectType.UnserializeFrom(element);
|
||||
isPrivate = element.GetBoolAttribute("private");
|
||||
sharedPropertyDescriptors.UnserializeElementsFrom(
|
||||
"propertyDescriptor", element.GetChild("sharedPropertyDescriptors"));
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "GDCore/Project/NamedPropertyDescriptor.h"
|
||||
#include "GDCore/Tools/SerializableWithNameList.h"
|
||||
#include "GDCore/Project/EventsFunctionsContainer.h"
|
||||
#include "GDCore/Project/ObjectType.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
@@ -63,15 +64,12 @@ class GD_CORE_API EventsBasedBehavior: public AbstractEventsBasedEntity {
|
||||
/**
|
||||
* \brief Get the object type the behavior should be used with.
|
||||
*/
|
||||
const gd::String& GetObjectType() const { return objectType; };
|
||||
gd::ObjectType& GetObjectType() { return objectType; };
|
||||
|
||||
/**
|
||||
* \brief Set the object type the behavior should be used with.
|
||||
* \brief Get the object type the behavior should be used with.
|
||||
*/
|
||||
EventsBasedBehavior& SetObjectType(const gd::String& objectType_) {
|
||||
objectType = objectType_;
|
||||
return *this;
|
||||
}
|
||||
const gd::ObjectType& GetObjectType() const { return objectType; };
|
||||
|
||||
/**
|
||||
* \brief Check if the behavior is private - it can't be used outside of its
|
||||
@@ -138,7 +136,7 @@ class GD_CORE_API EventsBasedBehavior: public AbstractEventsBasedEntity {
|
||||
const SerializerElement& element) override;
|
||||
|
||||
private:
|
||||
gd::String objectType;
|
||||
gd::ObjectType objectType;
|
||||
bool isPrivate = false;
|
||||
SerializableWithNameList<NamedPropertyDescriptor> sharedPropertyDescriptors;
|
||||
};
|
||||
|
88
Core/GDCore/Project/ObjectType.cpp
Normal file
88
Core/GDCore/Project/ObjectType.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ObjectType.h"
|
||||
#include "EventsFunctionsContainer.h"
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/Tools/MakeUnique.h"
|
||||
#include "GDCore/Extensions/Metadata/MetadataProvider.h"
|
||||
#include "GDCore/Extensions/Metadata/ObjectMetadata.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
#include "GDCore/Extensions/Platform.h"
|
||||
|
||||
namespace gd {
|
||||
|
||||
ObjectType::ObjectType() {}
|
||||
|
||||
bool ObjectType::HasCapability(const gd::String& name) const {
|
||||
return std::find(capabilities.begin(), capabilities.end(), name) !=
|
||||
capabilities.end();
|
||||
}
|
||||
|
||||
ObjectType& ObjectType::AddCapability(const gd::String& name) {
|
||||
if (!HasCapability(name)) capabilities.push_back(name);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void ObjectType::RemoveCapability(const gd::String& name) {
|
||||
capabilities.erase(
|
||||
std::remove(capabilities.begin(), capabilities.end(), name),
|
||||
capabilities.end());
|
||||
}
|
||||
|
||||
void ObjectType::SerializeTo(SerializerElement& element) const {
|
||||
element.SetAttribute("objectType", name);
|
||||
|
||||
SerializerElement& capabilitiesElement = element.AddChild("capabilities");
|
||||
capabilitiesElement.ConsiderAsArrayOf("object");
|
||||
for (auto& name : capabilities) {
|
||||
capabilitiesElement.AddChild("capability").SetAttribute("name", name);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectType::UnserializeFrom(const SerializerElement& element) {
|
||||
name = element.GetStringAttribute("objectType");
|
||||
SerializerElement& capabilitiesElement = element.GetChild("capabilities");
|
||||
capabilitiesElement.ConsiderAsArrayOf("capability");
|
||||
for (std::size_t j = 0; j < capabilitiesElement.GetChildrenCount(); ++j)
|
||||
AddCapability(capabilitiesElement.GetChild(j).GetStringAttribute("name"));
|
||||
}
|
||||
|
||||
bool ObjectType::IsMatchedBy(
|
||||
const gd::Platform& platform,
|
||||
const ObjectsContainer& globalObjectsContainer,
|
||||
const ObjectsContainer& objectsContainer,
|
||||
const gd::String& objectName) {
|
||||
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectName,
|
||||
false);
|
||||
|
||||
if (!IsBaseObject() && name != objectType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (capabilities.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO Handle groups
|
||||
|
||||
auto& objectMetadata = gd::MetadataProvider::GetObjectMetadata(
|
||||
platform,
|
||||
objectType
|
||||
);
|
||||
|
||||
for (auto& capability : capabilities) {
|
||||
if (!objectMetadata.IsSupportedBaseObjectCapability(capability)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace gd
|
73
Core/GDCore/Project/ObjectType.h
Normal file
73
Core/GDCore/Project/ObjectType.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* GDevelop Core
|
||||
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "GDCore/String.h"
|
||||
#include <vector>
|
||||
|
||||
namespace gd {
|
||||
class SerializerElement;
|
||||
class Platform;
|
||||
class ObjectsContainer;
|
||||
} // namespace gd
|
||||
|
||||
namespace gd {
|
||||
|
||||
/**
|
||||
* \brief
|
||||
*
|
||||
* \ingroup PlatformDefinition
|
||||
*/
|
||||
class GD_CORE_API ObjectType {
|
||||
public:
|
||||
ObjectType();
|
||||
virtual ~ObjectType(){};
|
||||
|
||||
/**
|
||||
* \brief Get the object type the behavior should be used with.
|
||||
*/
|
||||
const gd::String &GetName() const { return name; };
|
||||
|
||||
/**
|
||||
* \brief Set the object type the behavior should be used with.
|
||||
*/
|
||||
ObjectType &SetName(const gd::String &name_) {
|
||||
name = name_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IsBaseObject() const { return name.empty(); }
|
||||
|
||||
bool IsMatchedBy(const gd::Platform &platform,
|
||||
const ObjectsContainer &globalObjectsContainer,
|
||||
const ObjectsContainer &objectsContainer,
|
||||
const gd::String &objectName);
|
||||
|
||||
/**
|
||||
* \brief Return true if an object is found inside the ObjectGroup.
|
||||
*/
|
||||
bool HasCapability(const gd::String &name) const;
|
||||
|
||||
/**
|
||||
* \brief Add an object name to the group.
|
||||
*/
|
||||
ObjectType &AddCapability(const gd::String &name);
|
||||
|
||||
/**
|
||||
* \brief Remove an object name from the group
|
||||
*/
|
||||
void RemoveCapability(const gd::String &name);
|
||||
|
||||
void SerializeTo(SerializerElement &element) const;
|
||||
|
||||
void UnserializeFrom(const SerializerElement &element);
|
||||
|
||||
private:
|
||||
gd::String name;
|
||||
std::vector<gd::String> capabilities;
|
||||
};
|
||||
|
||||
} // namespace gd
|
@@ -37,7 +37,7 @@ void AddEventsBasedExtension(gd::Project &project) {
|
||||
"MyEventsBasedBehavior", 0);
|
||||
eventsBasedBehavior.SetFullName("My events based behavior");
|
||||
eventsBasedBehavior.SetDescription("An events based behavior for test");
|
||||
eventsBasedBehavior.SetObjectType("");
|
||||
eventsBasedBehavior.GetObjectType().SetName("");
|
||||
eventsBasedBehavior.GetPropertyDescriptors()
|
||||
.InsertNew("MyProperty", 0)
|
||||
.SetType("Number");
|
||||
|
@@ -122,7 +122,7 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
"")
|
||||
.AddParameter("object", _("Object"), "")
|
||||
.AddParameter("expression", _("Number parameter"))
|
||||
.SetRequiresBaseObjectCapability("effect")
|
||||
.SetRequiredBaseObjectCapability("effect")
|
||||
.SetFunctionName("getSomethingRequiringEffectCapability");
|
||||
baseObject
|
||||
.AddExpression("GetFromBaseExpression",
|
||||
@@ -403,7 +403,8 @@ void SetupProjectWithDummyPlatform(gd::Project& project,
|
||||
"FakeObjectWithUnsupportedCapability",
|
||||
"This is FakeObjectWithUnsupportedCapability",
|
||||
"")
|
||||
.AddUnsupportedBaseObjectCapability("effect");
|
||||
.MarkBaseObjectCapabilityAsUnsupported("effect")
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable");
|
||||
}
|
||||
|
||||
// Actions and expressions with several parameter types.
|
||||
|
@@ -26,7 +26,7 @@ CreateBehavior(gd::EventsFunctionsExtension &eventsExtension) {
|
||||
"MyEventsBasedBehavior", 0);
|
||||
eventsBasedBehavior.SetFullName("My events based behavior");
|
||||
eventsBasedBehavior.SetDescription("An events based behavior for test");
|
||||
eventsBasedBehavior.SetObjectType("");
|
||||
eventsBasedBehavior.GetObjectType().SetName("");
|
||||
return eventsBasedBehavior;
|
||||
};
|
||||
|
||||
@@ -486,8 +486,9 @@ TEST_CASE("PropertyFunctionGenerator", "[common]") {
|
||||
auto &objectParameter = setter.GetParameters().at(0);
|
||||
REQUIRE(objectParameter.GetName() == "Object");
|
||||
REQUIRE(objectParameter.GetType() == "object");
|
||||
REQUIRE(objectParameter.GetExtraInfo() ==
|
||||
"MyEventsExtension::MyEventsBasedObject");
|
||||
REQUIRE(
|
||||
objectParameter.GetValueTypeMetadata().GetObjectType().GetName() ==
|
||||
"MyEventsExtension::MyEventsBasedObject");
|
||||
auto &valueParameter = setter.GetParameters().at(1);
|
||||
REQUIRE(valueParameter.GetName() == "Value");
|
||||
REQUIRE(valueParameter.GetType() == "yesorno");
|
||||
|
@@ -76,6 +76,12 @@ const gd::String &GetEventFirstActionType(const gd::BaseEvent &event) {
|
||||
return actions.Get(0).GetType();
|
||||
}
|
||||
|
||||
gd::ParameterMetadata &SetObjectType(gd::ParameterMetadata &objectParameter,
|
||||
const gd::String type) {
|
||||
objectParameter.GetValueTypeMetadata().GetObjectType().SetName(type);
|
||||
return objectParameter;
|
||||
}
|
||||
|
||||
enum TestEvent {
|
||||
FreeFunctionAction,
|
||||
FreeFunctionWithExpression,
|
||||
@@ -860,27 +866,25 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
"MyEventsBasedBehavior", 0);
|
||||
eventsBasedBehavior.SetFullName("My events based behavior");
|
||||
eventsBasedBehavior.SetDescription("An events based behavior for test");
|
||||
eventsBasedBehavior.SetObjectType("MyEventsExtension::MyEventsBasedObject");
|
||||
eventsBasedBehavior.GetObjectType().SetName("MyEventsExtension::MyEventsBasedObject");
|
||||
|
||||
// Add functions, and parameters that should be there by convention.
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
auto &behaviorAction = behaviorEventsFunctions.InsertNewEventsFunction(
|
||||
"MyBehaviorEventsFunction", 0);
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Behavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
SetObjectType(gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("OtherBehavior")
|
||||
@@ -893,11 +897,9 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
behaviorEventsFunctions
|
||||
.InsertNewEventsFunction("MyBehaviorEventsFunctionExpression", 1)
|
||||
.SetFunctionType(gd::EventsFunction::Expression);
|
||||
behaviorExpression.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorExpression.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorExpression.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Behavior")
|
||||
@@ -951,16 +953,12 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
auto &objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
|
||||
auto &objectAction = objectEventsFunctions.InsertNewEventsFunction(
|
||||
"MyObjectEventsFunction", 0);
|
||||
objectAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
objectAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("OtherObject")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
objectAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
objectAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("OtherObject").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
objectAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("OtherBehavior")
|
||||
@@ -971,11 +969,9 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
objectEventsFunctions
|
||||
.InsertNewEventsFunction("MyObjectEventsFunctionExpression", 1)
|
||||
.SetFunctionType(gd::EventsFunction::Expression);
|
||||
objectExpression.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
objectExpression.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
|
||||
auto &objectExpressionAndCondition =
|
||||
objectEventsFunctions
|
||||
@@ -1011,17 +1007,15 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
"MyOtherEventsBasedBehavior", 0);
|
||||
eventsBasedBehavior.SetFullName("My events based behavior");
|
||||
eventsBasedBehavior.SetDescription("An events based behavior for test");
|
||||
eventsBasedBehavior.SetObjectType("MyEventsExtension::MyEventsBasedObject");
|
||||
eventsBasedBehavior.GetObjectType().SetName("MyEventsExtension::MyEventsBasedObject");
|
||||
|
||||
// Add functions, and parameters that should be there by convention.
|
||||
auto &behaviorEventsFunctions = eventsBasedBehavior.GetEventsFunctions();
|
||||
auto &behaviorAction = behaviorEventsFunctions.InsertNewEventsFunction(
|
||||
"MyBehaviorEventsFunction", 0);
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Behavior")
|
||||
@@ -1029,20 +1023,18 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
// Define the same objects as in the layout to be consistent with events.
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyExtension::Sprite"));
|
||||
SetObjectType(gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object"),
|
||||
"MyExtension::Sprite"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyBehavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
behaviorAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyCustomObject")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
behaviorAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("MyCustomObject").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
}
|
||||
|
||||
// Add an other events based object that uses previously defined events based
|
||||
@@ -1057,11 +1049,9 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
auto &objectEventsFunctions = eventsBasedObject.GetEventsFunctions();
|
||||
auto &objectAction = objectEventsFunctions.InsertNewEventsFunction(
|
||||
"MyObjectEventsFunction", 0);
|
||||
objectAction.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyOtherEventsBasedObject"));
|
||||
objectAction.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyOtherEventsBasedObject"));
|
||||
|
||||
// Add a child-object with the same names the one from the scene
|
||||
// to be able to use the same events list.
|
||||
@@ -1083,11 +1073,9 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
.SetName("currentScene")
|
||||
.SetType("")
|
||||
.SetCodeOnly(true));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Object")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
action.GetParameters().push_back(SetObjectType(
|
||||
gd::ParameterMetadata().SetName("Object").SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("Behavior")
|
||||
@@ -1126,20 +1114,20 @@ SetupProjectWithEventsFunctionExtension(gd::Project &project) {
|
||||
eventsExtension.InsertNewEventsFunction("MyOtherEventsFunction", 0);
|
||||
// Define the same objects as in the layout to be consistent with events.
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
SetObjectType(gd::ParameterMetadata()
|
||||
.SetName("ObjectWithMyBehavior")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyExtension::Sprite"));
|
||||
.SetType("object"),
|
||||
"MyExtension::Sprite"));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
.SetName("MyBehavior")
|
||||
.SetType("behavior")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedBehavior"));
|
||||
action.GetParameters().push_back(
|
||||
gd::ParameterMetadata()
|
||||
SetObjectType(gd::ParameterMetadata()
|
||||
.SetName("MyCustomObject")
|
||||
.SetType("object")
|
||||
.SetExtraInfo("MyEventsExtension::MyEventsBasedObject"));
|
||||
.SetType("object"),
|
||||
"MyEventsExtension::MyEventsBasedObject"));
|
||||
auto &group = action.GetObjectGroups().InsertNew("GroupWithMyBehavior");
|
||||
group.AddObject("ObjectWithMyBehavior");
|
||||
}
|
||||
@@ -1839,7 +1827,7 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
"MyOtherEventsBasedBehavior", 0);
|
||||
copiedBehavior.SetFullName("My events based behavior");
|
||||
copiedBehavior.SetDescription("An events based behavior for test");
|
||||
copiedBehavior.SetObjectType("MyEventsExtension::MyEventsBasedObject");
|
||||
copiedBehavior.GetObjectType().SetName("MyEventsExtension::MyEventsBasedObject");
|
||||
|
||||
// Add the copied events.
|
||||
auto &behaviorEventsFunctions = copiedBehavior.GetEventsFunctions();
|
||||
@@ -1876,8 +1864,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
auto &myEventsFunction =
|
||||
project.GetEventsFunctionsExtension("MyEventsExtension")
|
||||
.GetEventsFunction("MyEventsFunction");
|
||||
REQUIRE(myEventsFunction.GetParameters().at(1).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myEventsFunction.GetParameters()
|
||||
.at(1)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() == "MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myEventsFunction.GetParameters().at(2).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedBehavior");
|
||||
|
||||
@@ -1889,8 +1880,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
.Get("MyEventsBasedBehavior")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyBehaviorEventsFunction");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(2).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters()
|
||||
.at(2)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() == "MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(3).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedBehavior");
|
||||
}
|
||||
@@ -1903,8 +1897,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
.Get("MyEventsBasedObject")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyObjectEventsFunction");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(1).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters()
|
||||
.at(1)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() == "MyRenamedExtension::MyEventsBasedObject");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(2).GetExtraInfo() ==
|
||||
"MyRenamedExtension::MyEventsBasedBehavior");
|
||||
}
|
||||
@@ -1922,7 +1919,8 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
REQUIRE(project.GetEventsFunctionsExtension("MyEventsExtension")
|
||||
.GetEventsBasedBehaviors()
|
||||
.Get("MyEventsBasedBehavior")
|
||||
.GetObjectType() == "MyRenamedExtension::MyEventsBasedObject");
|
||||
.GetObjectType()
|
||||
.GetName() == "MyRenamedExtension::MyEventsBasedObject");
|
||||
}
|
||||
|
||||
SECTION("(Free) events action renamed") {
|
||||
@@ -2247,8 +2245,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
auto &myEventsFunction =
|
||||
project.GetEventsFunctionsExtension("MyEventsExtension")
|
||||
.GetEventsFunction("MyEventsFunction");
|
||||
REQUIRE(myEventsFunction.GetParameters().at(1).GetExtraInfo() ==
|
||||
"MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
REQUIRE(myEventsFunction.GetParameters()
|
||||
.at(1)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() == "MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
|
||||
// Behavior function
|
||||
{
|
||||
@@ -2258,7 +2259,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
.Get("MyEventsBasedBehavior")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyBehaviorEventsFunction");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(2).GetExtraInfo() ==
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters()
|
||||
.at(2)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() ==
|
||||
"MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
}
|
||||
|
||||
@@ -2270,7 +2275,11 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
.Get("MyEventsBasedObject")
|
||||
.GetEventsFunctions()
|
||||
.GetEventsFunction("MyObjectEventsFunction");
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters().at(1).GetExtraInfo() ==
|
||||
REQUIRE(myBehaviorEventsFunction.GetParameters()
|
||||
.at(1)
|
||||
.GetValueTypeMetadata()
|
||||
.GetObjectType()
|
||||
.GetName() ==
|
||||
"MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
}
|
||||
}
|
||||
@@ -2290,8 +2299,8 @@ TEST_CASE("WholeProjectRefactorer", "[common]") {
|
||||
REQUIRE(project.GetEventsFunctionsExtension("MyEventsExtension")
|
||||
.GetEventsBasedBehaviors()
|
||||
.Get("MyEventsBasedBehavior")
|
||||
.GetObjectType() ==
|
||||
"MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
.GetObjectType()
|
||||
.GetName() == "MyEventsExtension::MyRenamedEventsBasedObject");
|
||||
}
|
||||
// TODO: Check that this works when behaviors are attached to a child-object.
|
||||
SECTION("Events based behavior renamed (other behaviors properties update)") {
|
||||
|
@@ -48,7 +48,11 @@ module.exports = {
|
||||
new gd.Model3DObjectConfiguration()
|
||||
)
|
||||
.setCategoryFullName(_('3D'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
.markBaseObjectCapabilityAsUnsupported('effect')
|
||||
.markBaseObjectCapabilityAsSupported('resizable')
|
||||
.markBaseObjectCapabilityAsSupported('scalable')
|
||||
.markBaseObjectCapabilityAsSupported('flippable')
|
||||
.markBaseObjectCapabilityAsSupported('animable')
|
||||
.setIncludeFile('Extensions/3D/A_RuntimeObject3D.js')
|
||||
.addIncludeFile('Extensions/3D/A_RuntimeObject3DRenderer.js')
|
||||
.addIncludeFile('Extensions/3D/Model3DRuntimeObject.js')
|
||||
@@ -85,6 +89,7 @@ module.exports = {
|
||||
.setFunctionName('setDepth')
|
||||
.setGetter('getDepth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetWidth',
|
||||
@@ -100,10 +105,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setWidth')
|
||||
.setGetter('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Width',
|
||||
@@ -119,9 +126,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetHeight',
|
||||
@@ -137,10 +146,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Height',
|
||||
@@ -156,9 +167,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -171,9 +184,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject', false)
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.setHidden()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Scale',
|
||||
@@ -191,10 +206,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -212,10 +229,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -233,6 +252,7 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
@@ -258,6 +278,7 @@ module.exports = {
|
||||
.setFunctionName('setScaleZ')
|
||||
.setGetter('getScaleZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipX',
|
||||
@@ -270,9 +291,11 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.setHidden()
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipY',
|
||||
@@ -285,6 +308,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.setHidden()
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipY');
|
||||
|
||||
@@ -303,6 +327,7 @@ module.exports = {
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedX',
|
||||
@@ -314,8 +339,10 @@ module.exports = {
|
||||
'res/actions/flipX.png'
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedY',
|
||||
@@ -327,6 +354,7 @@ module.exports = {
|
||||
'res/actions/flipY.png'
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedY');
|
||||
|
||||
object
|
||||
@@ -438,6 +466,7 @@ module.exports = {
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationIndex')
|
||||
.setGetter('getAnimationIndex');
|
||||
|
||||
@@ -459,6 +488,7 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationName')
|
||||
.setGetter('getAnimationName');
|
||||
|
||||
@@ -474,6 +504,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('pauseAnimation');
|
||||
|
||||
object
|
||||
@@ -488,6 +519,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('resumeAnimation');
|
||||
|
||||
object
|
||||
@@ -508,6 +540,7 @@ module.exports = {
|
||||
gd.ParameterOptions.makeNewOptions().setDescription(_('Speed scale'))
|
||||
)
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('setAnimationSpeedScale')
|
||||
.setGetter('getAnimationSpeedScale');
|
||||
|
||||
@@ -523,6 +556,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('isAnimationPaused');
|
||||
|
||||
object
|
||||
@@ -539,6 +573,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('3D model'), 'Model3DObject')
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('hasAnimationEnded');
|
||||
}
|
||||
|
||||
@@ -864,7 +899,10 @@ module.exports = {
|
||||
Cube3DObject
|
||||
)
|
||||
.setCategoryFullName(_('3D'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
.markBaseObjectCapabilityAsUnsupported('effect')
|
||||
.markBaseObjectCapabilityAsSupported('resizable')
|
||||
.markBaseObjectCapabilityAsSupported('scalable')
|
||||
.markBaseObjectCapabilityAsSupported('flippable')
|
||||
.setIncludeFile('Extensions/3D/A_RuntimeObject3D.js')
|
||||
.addIncludeFile('Extensions/3D/A_RuntimeObject3DRenderer.js')
|
||||
.addIncludeFile('Extensions/3D/Cube3DRuntimeObject.js')
|
||||
@@ -901,6 +939,7 @@ module.exports = {
|
||||
.setFunctionName('setDepth')
|
||||
.setGetter('getDepth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetWidth',
|
||||
@@ -916,10 +955,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setWidth')
|
||||
.setGetter('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Width',
|
||||
@@ -935,9 +976,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'SetHeight',
|
||||
@@ -953,10 +996,12 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setHeight')
|
||||
.setGetter('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'Height',
|
||||
@@ -972,9 +1017,11 @@ module.exports = {
|
||||
'number',
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('getHeight');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Scale',
|
||||
@@ -992,10 +1039,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1013,10 +1062,12 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -1034,6 +1085,7 @@ module.exports = {
|
||||
_('Scale (1 by default)')
|
||||
)
|
||||
)
|
||||
.setHidden()
|
||||
.markAsAdvanced()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
@@ -1059,6 +1111,7 @@ module.exports = {
|
||||
.setFunctionName('setScaleZ')
|
||||
.setGetter('getScaleZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipX',
|
||||
@@ -1072,8 +1125,10 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'FlipY',
|
||||
@@ -1087,6 +1142,7 @@ module.exports = {
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.addParameter('yesorno', _('Activate flipping'))
|
||||
.markAsSimple()
|
||||
.setHidden()
|
||||
.setFunctionName('flipY');
|
||||
|
||||
object
|
||||
@@ -1104,6 +1160,7 @@ module.exports = {
|
||||
.markAsSimple()
|
||||
.setFunctionName('flipZ');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedX',
|
||||
@@ -1115,8 +1172,10 @@ module.exports = {
|
||||
'res/actions/flipX.png'
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedCondition(
|
||||
'FlippedY',
|
||||
@@ -1128,6 +1187,7 @@ module.exports = {
|
||||
'res/actions/flipY.png'
|
||||
)
|
||||
.addParameter('object', _('3D cube'), 'Cube3DObject')
|
||||
.setHidden()
|
||||
.setFunctionName('isFlippedY');
|
||||
|
||||
object
|
||||
|
@@ -38,7 +38,8 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
"from "
|
||||
"the full image."),
|
||||
"CppPlatform/Extensions/PanelSpriteIcon.png")
|
||||
.SetCategoryFullName(_("General"));
|
||||
.SetCategoryFullName(_("General"))
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable");
|
||||
|
||||
obj.AddCondition("Opacity",
|
||||
_("Opacity"),
|
||||
@@ -90,6 +91,7 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.AddParameter("color", _("Tint"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Modify the width of a Panel Sprite."),
|
||||
@@ -101,9 +103,11 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetWidth")
|
||||
.SetGetter("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Check the width of a Panel Sprite."),
|
||||
@@ -115,8 +119,10 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Modify the height of a Panel Sprite."),
|
||||
@@ -128,9 +134,11 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Check the height of a Panel Sprite."),
|
||||
@@ -142,6 +150,7 @@ void DeclarePanelSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "PanelSprite")
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
|
@@ -31,6 +31,9 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Allows you to draw simple shapes on the screen using the "
|
||||
"events."),
|
||||
"CppPlatform/Extensions/primitivedrawingicon.png")
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable")
|
||||
.MarkBaseObjectCapabilityAsSupported("scalable")
|
||||
.MarkBaseObjectCapabilityAsSupported("flippable")
|
||||
.SetCategoryFullName(_("Advanced"));
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
@@ -612,6 +615,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.SetFunctionName("AreCoordinatesRelative");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Scale",
|
||||
_("Scale"),
|
||||
_("Modify the scale of the specified object."),
|
||||
@@ -624,8 +628,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpressionAndConditionAndAction("number",
|
||||
"ScaleX",
|
||||
_("Scale on X axis"),
|
||||
@@ -638,8 +644,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpressionAndConditionAndAction("number",
|
||||
"ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
@@ -652,6 +660,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction("FlipX",
|
||||
@@ -663,6 +672,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddAction("FlipY",
|
||||
@@ -674,6 +684,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.SetHidden()
|
||||
.MarkAsSimple();
|
||||
|
||||
obj.AddCondition("FlippedX",
|
||||
@@ -683,7 +694,8 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Effects"),
|
||||
"res/actions/flipX24.png",
|
||||
"res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), "Drawer");
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.SetHidden();
|
||||
|
||||
obj.AddCondition("FlippedY",
|
||||
_("Vertically flipped"),
|
||||
@@ -692,8 +704,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Effects"),
|
||||
"res/actions/flipY24.png",
|
||||
"res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), "Drawer");
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.SetHidden();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Change the width of an object."),
|
||||
@@ -704,8 +718,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Change the height of an object."),
|
||||
@@ -716,6 +732,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "Drawer")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.MarkAsAdvanced();
|
||||
|
||||
obj.AddAction(
|
||||
|
@@ -283,7 +283,7 @@ module.exports = {
|
||||
textInputObject
|
||||
)
|
||||
.setCategoryFullName(_('User interface'))
|
||||
.addUnsupportedBaseObjectCapability('effect')
|
||||
.markBaseObjectCapabilityAsUnsupported('effect')
|
||||
.setIncludeFile('Extensions/TextInput/textinputruntimeobject.js')
|
||||
.addIncludeFile(
|
||||
'Extensions/TextInput/textinputruntimeobject-pixi-renderer.js'
|
||||
|
@@ -78,6 +78,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("police", _("Font"))
|
||||
.SetFunctionName("ChangeFont");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("ScaleX",
|
||||
_("Scale on X axis"),
|
||||
_("Compare the scale of the text on the X axis"),
|
||||
@@ -91,8 +92,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale to compare to (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ScaleX",
|
||||
_("Scale on X axis"),
|
||||
@@ -107,8 +110,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
_("Compare the scale of the text on the Y axis"),
|
||||
@@ -122,8 +127,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale to compare to (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleY");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"ScaleY",
|
||||
_("Scale on Y axis"),
|
||||
@@ -138,8 +145,10 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScaleY");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction(
|
||||
"Scale",
|
||||
_("Scale"),
|
||||
@@ -154,6 +163,7 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"number",
|
||||
gd::ParameterOptions::MakeNewOptions().SetDescription(
|
||||
_("Scale (1 by default)")))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetScale");
|
||||
|
||||
obj.AddAction(
|
||||
@@ -497,20 +507,24 @@ void DeclareTextObjectExtension(gd::PlatformExtension& extension) {
|
||||
"res/actions/textPadding_black.png")
|
||||
.AddParameter("object", _("Object"), "Text");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("ScaleX",
|
||||
_("X Scale of a Text object"),
|
||||
_("X Scale of a Text object"),
|
||||
_("Scale"),
|
||||
"res/actions/scaleWidth_black.png")
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleX");
|
||||
|
||||
// Deprecated
|
||||
obj.AddExpression("ScaleY",
|
||||
_("Y Scale of a Text object"),
|
||||
_("Y Scale of a Text object"),
|
||||
_("Scale"),
|
||||
"res/actions/scaleHeight_black.png")
|
||||
.AddParameter("object", _("Object"), "Text")
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetScaleY");
|
||||
|
||||
obj.AddExpression("Opacity",
|
||||
|
@@ -205,6 +205,8 @@ const defineTileMap = function (
|
||||
objectTileMap
|
||||
)
|
||||
.setCategoryFullName(_('Advanced'))
|
||||
.markBaseObjectCapabilityAsSupported("resizable")
|
||||
.markBaseObjectCapabilityAsSupported("scalable")
|
||||
.setIncludeFile('Extensions/TileMap/tilemapruntimeobject.js')
|
||||
.addIncludeFile('Extensions/TileMap/TileMapRuntimeManager.js')
|
||||
.addIncludeFile('Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js')
|
||||
@@ -495,6 +497,7 @@ const defineTileMap = function (
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getAnimationFps');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Scale',
|
||||
@@ -513,10 +516,12 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -535,9 +540,11 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -556,9 +563,11 @@ const defineTileMap = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Width',
|
||||
@@ -575,9 +584,11 @@ const defineTileMap = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addAction(
|
||||
'Height',
|
||||
@@ -594,6 +605,7 @@ const defineTileMap = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setHeight');
|
||||
};
|
||||
@@ -789,6 +801,8 @@ const defineCollisionMask = function (
|
||||
collisionMaskObject
|
||||
)
|
||||
.setCategoryFullName(_('Advanced'))
|
||||
.markBaseObjectCapabilityAsSupported("resizable")
|
||||
.markBaseObjectCapabilityAsSupported("scalable")
|
||||
.setIncludeFile('Extensions/TileMap/tilemapcollisionmaskruntimeobject.js')
|
||||
.addIncludeFile('Extensions/TileMap/TileMapRuntimeManager.js')
|
||||
.addIncludeFile('Extensions/TileMap/pako/dist/pako.min.js')
|
||||
@@ -909,6 +923,7 @@ const defineCollisionMask = function (
|
||||
.setFunctionName('setScale')
|
||||
.setGetter('getScale');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -932,9 +947,11 @@ const defineCollisionMask = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleX')
|
||||
.setGetter('getScaleX');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addExpressionAndConditionAndAction(
|
||||
'number',
|
||||
@@ -958,9 +975,11 @@ const defineCollisionMask = function (
|
||||
)
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.setFunctionName('setScaleY')
|
||||
.setGetter('getScaleY');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Width',
|
||||
@@ -982,9 +1001,11 @@ const defineCollisionMask = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWidth');
|
||||
|
||||
// Deprecated
|
||||
object
|
||||
.addScopedAction(
|
||||
'Height',
|
||||
@@ -1006,6 +1027,7 @@ const defineCollisionMask = function (
|
||||
gd.ParameterOptions.makeNewOptions()
|
||||
)
|
||||
.markAsAdvanced()
|
||||
.setHidden()
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setHeight');
|
||||
};
|
||||
|
@@ -34,6 +34,7 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
_("Tiled Sprite"),
|
||||
_("Displays an image repeated over an area."),
|
||||
"CppPlatform/Extensions/TiledSpriteIcon.png")
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable")
|
||||
.SetCategoryFullName(_("General"));
|
||||
|
||||
obj.AddCondition("Opacity",
|
||||
@@ -86,6 +87,7 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.AddParameter("color", _("Tint"));
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Width",
|
||||
_("Width"),
|
||||
_("Modify the width of a Tiled Sprite."),
|
||||
@@ -97,9 +99,11 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetWidth")
|
||||
.SetGetter("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Width",
|
||||
_("Width"),
|
||||
_("Test the width of a Tiled Sprite."),
|
||||
@@ -111,8 +115,10 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetWidth");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("Height",
|
||||
_("Height"),
|
||||
_("Modify the height of a Tiled Sprite."),
|
||||
@@ -124,9 +130,11 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetHeight")
|
||||
.SetGetter("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddCondition("Height",
|
||||
_("Height"),
|
||||
_("Test the height of a Tiled Sprite."),
|
||||
@@ -138,8 +146,10 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.UseStandardRelationalOperatorParameters(
|
||||
"number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("GetHeight");
|
||||
|
||||
// Deprecated
|
||||
obj.AddAction("SetSize",
|
||||
_("Size"),
|
||||
_("Modify the size of a Tiled Sprite."),
|
||||
@@ -151,6 +161,7 @@ void DeclareTiledSpriteObjectExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("object", _("Object"), "TiledSprite")
|
||||
.AddParameter("expression", _("Width"))
|
||||
.AddParameter("expression", _("Height"))
|
||||
.SetHidden()
|
||||
.SetFunctionName("SetSize");
|
||||
|
||||
// Deprecated: now available for all objects.
|
||||
|
@@ -19,6 +19,7 @@ gd::String BehaviorCodeGenerator::GenerateRuntimeBehaviorCompleteCode(
|
||||
const std::map<gd::String, gd::String>& behaviorMethodMangledNames,
|
||||
std::set<gd::String>& includeFiles,
|
||||
bool compilationForRuntime) {
|
||||
std::cout << "GenerateRuntimeBehaviorCompleteCode" << std::endl;
|
||||
auto& eventsFunctionsVector =
|
||||
eventsBasedBehavior.GetEventsFunctions().GetInternalVector();
|
||||
|
||||
|
@@ -107,12 +107,16 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
// several categories, we can assume it"s not scoped correctly.
|
||||
// Note: EventsFunctionsExtension should be used instead of
|
||||
// PlatformExtension but this line will be removed soon.
|
||||
.SetCategoryFullName(extension.GetCategory());
|
||||
.SetCategoryFullName(extension.GetCategory())
|
||||
.MarkBaseObjectCapabilityAsSupported("resizable")
|
||||
.MarkBaseObjectCapabilityAsSupported("scalable")
|
||||
.MarkBaseObjectCapabilityAsSupported("flippable");
|
||||
|
||||
// TODO EBO Use full type to identify object to avoid collision.
|
||||
// Objects are identified by their name alone.
|
||||
const gd::String &objectType = eventsBasedObject.GetName();
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("Width", _("Width"), _("Change the width of an object."),
|
||||
_("the width"), _("Size"),
|
||||
@@ -122,6 +126,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setWidth")
|
||||
.SetGetter("getWidth");
|
||||
|
||||
@@ -131,14 +136,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("the width"), _("Size"),
|
||||
"res/actions/scaleWidth24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setWidth")
|
||||
.SetGetter("getWidth");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("Height", _("Height"),
|
||||
_("Change the height of an object."), _("the height"),
|
||||
@@ -148,6 +154,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setHeight")
|
||||
.SetGetter("getHeight");
|
||||
|
||||
@@ -157,14 +164,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("the height"), _("Size"),
|
||||
"res/actions/scaleHeight24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setHeight")
|
||||
.SetGetter("getHeight");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction(
|
||||
"Scale", _("Scale"), _("Modify the scale of the specified object."),
|
||||
@@ -174,6 +182,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale");
|
||||
|
||||
@@ -183,14 +192,15 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Modify the scale of the specified object."), _("the scale"),
|
||||
_("Size"), "res/actions/scale24_black.png",
|
||||
"res/actions/scale_black.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardOperatorParameters("number",
|
||||
gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScale")
|
||||
.SetGetter("getScale");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddExpressionAndConditionAndAction(
|
||||
"number", "ScaleX", _("Scale on X axis"),
|
||||
@@ -199,9 +209,11 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScaleX")
|
||||
.SetGetter("getScaleX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddExpressionAndConditionAndAction(
|
||||
"number", "ScaleY", _("Scale on Y axis"),
|
||||
@@ -210,9 +222,11 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.UseStandardParameters("number", gd::ParameterOptions::MakeNewOptions())
|
||||
.MarkAsAdvanced()
|
||||
.SetHidden()
|
||||
.SetFunctionName("setScaleY")
|
||||
.SetGetter("getScaleY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("FlipX", _("Flip the object horizontally"),
|
||||
_("Flip the object horizontally"),
|
||||
@@ -221,6 +235,7 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipX");
|
||||
|
||||
// Deprecated
|
||||
@@ -229,12 +244,13 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Flip the object horizontally"),
|
||||
_("Flip horizontally _PARAM0_: _PARAM1_"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedAction("FlipY", _("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
@@ -243,8 +259,10 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddAction("FlipY", _("Flip the object vertically"),
|
||||
_("Flip the object vertically"),
|
||||
@@ -254,14 +272,17 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.AddParameter("yesorno", _("Activate flipping"))
|
||||
.MarkAsSimple()
|
||||
.SetHidden()
|
||||
.SetFunctionName("flipY");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedCondition("FlippedX", _("Horizontally flipped"),
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedX");
|
||||
|
||||
// Deprecated
|
||||
@@ -270,16 +291,18 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Check if the object is horizontally flipped"),
|
||||
_("_PARAM0_ is horizontally flipped"), _("Effects"),
|
||||
"res/actions/flipX24.png", "res/actions/flipX.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedX");
|
||||
|
||||
// Deprecated
|
||||
objectMetadata
|
||||
.AddScopedCondition("FlippedY", _("Vertically flipped"),
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"), _("Effects"),
|
||||
"res/actions/flipY24.png", "res/actions/flipY.png")
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedY");
|
||||
|
||||
// Deprecated
|
||||
@@ -288,8 +311,8 @@ gd::ObjectMetadata &MetadataDeclarationHelper::DeclareObjectMetadata(
|
||||
_("Check if the object is vertically flipped"),
|
||||
_("_PARAM0_ is vertically flipped"), _("Effects"),
|
||||
"res/actions/flipY24.png", "res/actions/flipY.png")
|
||||
.SetHidden()
|
||||
.AddParameter("object", _("Object"), objectType)
|
||||
.SetHidden()
|
||||
.SetFunctionName("isFlippedY");
|
||||
|
||||
objectMetadata
|
||||
@@ -1019,7 +1042,7 @@ void MetadataDeclarationHelper::
|
||||
// as this method is prefixing the value passed with the extension
|
||||
// namespace (this was done to ease extension declarations when dealing
|
||||
// with object).
|
||||
.SetParameterExtraInfo(eventsBasedBehavior.GetObjectType());
|
||||
.SetParameterObjectType(eventsBasedBehavior.GetObjectType());
|
||||
|
||||
// By convention, second parameter is always the behavior:
|
||||
instructionOrExpression.AddParameter("behavior", "Behavior",
|
||||
@@ -1200,7 +1223,8 @@ void MetadataDeclarationHelper::AddParameter(
|
||||
// addCodeOnlyParameter) as these methods are prefixing the value passed
|
||||
// with the extension namespace (this was done to ease extension
|
||||
// declarations when dealing with object).
|
||||
.SetParameterExtraInfo(parameter.GetExtraInfo());
|
||||
.SetParameterExtraInfo(parameter.GetExtraInfo())
|
||||
.SetParameterObjectType(parameter.GetValueTypeMetadata().GetObjectType());
|
||||
instructionOrExpression.SetParameterLongDescription(
|
||||
parameter.GetLongDescription());
|
||||
instructionOrExpression.SetDefaultValue(parameter.GetDefaultValue());
|
||||
|
@@ -27,14 +27,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
std::map<gd::String, gd::ExpressionMetadata> &objectStrExpressions =
|
||||
GetAllStrExpressionsForObject("");
|
||||
|
||||
objectActions["MettreX"]
|
||||
.SetFunctionName("setX")
|
||||
.SetGetter("getX")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreY"]
|
||||
.SetFunctionName("setY")
|
||||
.SetGetter("getY")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreX"].SetFunctionName("setX").SetGetter("getX");
|
||||
objectActions["MettreY"].SetFunctionName("setY").SetGetter("getY");
|
||||
objectConditions["PosX"].SetFunctionName("getX").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectConditions["PosY"].SetFunctionName("getY").SetIncludeFile(
|
||||
@@ -47,13 +41,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectActions["SetCenterY"]
|
||||
.SetFunctionName("setCenterYInScene")
|
||||
.SetGetter("getCenterYInScene");
|
||||
objectActions["SetAngle"]
|
||||
.SetFunctionName("setAngle")
|
||||
.SetGetter("getAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Angle"]
|
||||
.SetFunctionName("getAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetAngle"].SetFunctionName("setAngle").SetGetter("getAngle");
|
||||
objectConditions["Angle"].SetFunctionName("getAngle");
|
||||
objectConditions["BoundingBoxLeft"].SetFunctionName("getAABBLeft");
|
||||
objectConditions["BoundingBoxTop"].SetFunctionName("getAABBTop");
|
||||
objectConditions["BoundingBoxRight"].SetFunctionName("getAABBRight");
|
||||
@@ -62,142 +51,71 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectConditions["BoundingBoxCenterY"].SetFunctionName("getAABBCenterY");
|
||||
objectActions["Rotate"].SetFunctionName("rotate").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectActions["RotateTowardAngle"]
|
||||
.SetFunctionName("rotateTowardAngle")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RotateTowardPosition"]
|
||||
.SetFunctionName("rotateTowardPosition")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ChangeLayer"]
|
||||
.SetFunctionName("setLayer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Layer"]
|
||||
.SetFunctionName("isOnLayer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RotateTowardAngle"].SetFunctionName("rotateTowardAngle");
|
||||
objectActions["RotateTowardPosition"].SetFunctionName("rotateTowardPosition");
|
||||
objectActions["ChangeLayer"].SetFunctionName("setLayer");
|
||||
objectConditions["Layer"].SetFunctionName("isOnLayer");
|
||||
objectActions["ChangePlan"]
|
||||
.SetFunctionName("setZOrder")
|
||||
.SetGetter("getZOrder")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Plan"]
|
||||
.SetFunctionName("getZOrder")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
.SetGetter("getZOrder");
|
||||
objectConditions["Plan"].SetFunctionName("getZOrder");
|
||||
objectActions["Cache"].SetFunctionName("hide").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectActions["Montre"].SetFunctionName("hide").SetIncludeFile(
|
||||
"runtimeobject.js");
|
||||
objectConditions["Visible"]
|
||||
.SetFunctionName("isVisible")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Invisible"]
|
||||
.SetFunctionName("isHidden")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["IsEffectEnabled"]
|
||||
.SetFunctionName("isEffectEnabled")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Visible"].SetFunctionName("isVisible");
|
||||
objectConditions["Invisible"].SetFunctionName("isHidden");
|
||||
objectConditions["IsEffectEnabled"].SetFunctionName("isEffectEnabled");
|
||||
objectActions["Delete"].SetFunctionName("deleteFromScene");
|
||||
objectActions["MettreAutourPos"].SetFunctionName("putAround");
|
||||
objectActions["MettreAutour"]
|
||||
.SetFunctionName("putAroundObject")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjet"]
|
||||
.SetFunctionName("getVariableNumber")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjetTxt"]
|
||||
.SetFunctionName("getVariableString")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableAsBoolean"]
|
||||
.SetFunctionName("getVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["VarObjetDef"]
|
||||
.SetFunctionName("hasVariable")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceXY"]
|
||||
.SetFunctionName("addForce")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceAL"]
|
||||
.SetFunctionName("addPolarForce")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceVersPos"]
|
||||
.SetFunctionName("addForceTowardPosition")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["AddForceVers"]
|
||||
.SetFunctionName("addForceTowardObject")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Arreter"]
|
||||
.SetFunctionName("clearForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Arret"]
|
||||
.SetFunctionName("hasNoForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["Vitesse"]
|
||||
.SetFunctionName("getAverageForce().getLength")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["AngleOfDisplacement"]
|
||||
.SetFunctionName("averageForceAngleIs")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SeparateFromObjects"]
|
||||
.SetFunctionName("separateFromObjectsList")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Ecarter"] // Deprecated
|
||||
.SetFunctionName("separateObjectsWithoutForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["Rebondir"] // Deprecated
|
||||
.SetFunctionName("separateObjectsWithForces")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["BehaviorActivated"]
|
||||
.SetFunctionName("behaviorActivated")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ActivateBehavior"]
|
||||
.SetFunctionName("activateBehavior")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableChildExists"]
|
||||
.SetFunctionName("variableChildExists")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableRemoveChild"]
|
||||
.SetFunctionName("variableRemoveChild")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableClearChildren"]
|
||||
.SetFunctionName("variableClearChildren")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["CollisionPoint"]
|
||||
.SetFunctionName("isCollidingWithPoint")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectTimer"] // deprecated
|
||||
.SetFunctionName("timerElapsedTime")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["CompareObjectTimer"]
|
||||
.SetFunctionName("getTimerElapsedTimeInSecondsOrNaN")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectTimerPaused"]
|
||||
.SetFunctionName("timerPaused")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ResetObjectTimer"]
|
||||
.SetFunctionName("resetTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["PauseObjectTimer"]
|
||||
.SetFunctionName("pauseTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["UnPauseObjectTimer"]
|
||||
.SetFunctionName("unpauseTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["RemoveObjectTimer"]
|
||||
.SetFunctionName("removeTimer")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["EnableEffect"]
|
||||
.SetFunctionName("enableEffect")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectDoubleParameter"]
|
||||
.SetFunctionName("setEffectDoubleParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectStringParameter"]
|
||||
.SetFunctionName("setEffectStringParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetEffectBooleanParameter"]
|
||||
.SetFunctionName("setEffectBooleanParameter")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetIncludedInParentCollisionMask"]
|
||||
.SetFunctionName("setIncludedInParentCollisionMask")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["MettreAutour"].SetFunctionName("putAroundObject");
|
||||
objectConditions["VarObjet"].SetFunctionName("getVariableNumber");
|
||||
objectConditions["VarObjetTxt"].SetFunctionName("getVariableString");
|
||||
objectConditions["ObjectVariableAsBoolean"].SetFunctionName(
|
||||
"getVariableBoolean");
|
||||
objectConditions["VarObjetDef"].SetFunctionName("hasVariable");
|
||||
objectActions["AddForceXY"].SetFunctionName("addForce");
|
||||
objectActions["AddForceAL"].SetFunctionName("addPolarForce");
|
||||
objectActions["AddForceVersPos"].SetFunctionName("addForceTowardPosition");
|
||||
objectActions["AddForceVers"].SetFunctionName("addForceTowardObject");
|
||||
objectActions["Arreter"].SetFunctionName("clearForces");
|
||||
objectConditions["Arret"].SetFunctionName("hasNoForces");
|
||||
objectConditions["Vitesse"].SetFunctionName("getAverageForce().getLength");
|
||||
objectConditions["AngleOfDisplacement"].SetFunctionName(
|
||||
"averageForceAngleIs");
|
||||
objectActions["SeparateFromObjects"].SetFunctionName(
|
||||
"separateFromObjectsList");
|
||||
// Deprecated
|
||||
objectActions["Ecarter"].SetFunctionName("separateObjectsWithoutForces");
|
||||
// Deprecated
|
||||
objectActions["Rebondir"].SetFunctionName("separateObjectsWithForces");
|
||||
objectConditions["BehaviorActivated"].SetFunctionName("behaviorActivated");
|
||||
objectActions["ActivateBehavior"].SetFunctionName("activateBehavior");
|
||||
objectConditions["ObjectVariableChildExists"].SetFunctionName(
|
||||
"variableChildExists");
|
||||
objectActions["ObjectVariableRemoveChild"].SetFunctionName(
|
||||
"variableRemoveChild");
|
||||
objectActions["ObjectVariableClearChildren"].SetFunctionName(
|
||||
"variableClearChildren");
|
||||
objectConditions["CollisionPoint"].SetFunctionName("isCollidingWithPoint");
|
||||
// deprecated
|
||||
objectConditions["ObjectTimer"].SetFunctionName("timerElapsedTime");
|
||||
objectConditions["CompareObjectTimer"].SetFunctionName(
|
||||
"getTimerElapsedTimeInSecondsOrNaN");
|
||||
objectConditions["ObjectTimerPaused"].SetFunctionName("timerPaused");
|
||||
objectActions["ResetObjectTimer"].SetFunctionName("resetTimer");
|
||||
objectActions["PauseObjectTimer"].SetFunctionName("pauseTimer");
|
||||
objectActions["UnPauseObjectTimer"].SetFunctionName("unpauseTimer");
|
||||
objectActions["RemoveObjectTimer"].SetFunctionName("removeTimer");
|
||||
objectActions["EnableEffect"].SetFunctionName("enableEffect");
|
||||
objectActions["SetEffectDoubleParameter"].SetFunctionName(
|
||||
"setEffectDoubleParameter");
|
||||
objectActions["SetEffectStringParameter"].SetFunctionName(
|
||||
"setEffectStringParameter");
|
||||
objectActions["SetEffectBooleanParameter"].SetFunctionName(
|
||||
"setEffectBooleanParameter");
|
||||
objectActions["SetIncludedInParentCollisionMask"].SetFunctionName(
|
||||
"setIncludedInParentCollisionMask");
|
||||
|
||||
objectExpressions["X"].SetFunctionName("getX");
|
||||
objectExpressions["Y"].SetFunctionName("getY");
|
||||
@@ -210,11 +128,14 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectExpressions["BoundingBoxCenterX"].SetFunctionName("getAABBCenterX");
|
||||
objectExpressions["BoundingBoxCenterY"].SetFunctionName("getAABBCenterY");
|
||||
objectExpressions["ZOrder"].SetFunctionName("getZOrder");
|
||||
objectExpressions["Plan"].SetFunctionName("getZOrder"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Plan"].SetFunctionName("getZOrder");
|
||||
objectExpressions["Width"].SetFunctionName("getWidth");
|
||||
objectExpressions["Height"].SetFunctionName("getHeight");
|
||||
objectExpressions["Largeur"].SetFunctionName("getWidth"); // Deprecated
|
||||
objectExpressions["Hauteur"].SetFunctionName("getHeight"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Largeur"].SetFunctionName("getWidth");
|
||||
// Deprecated
|
||||
objectExpressions["Hauteur"].SetFunctionName("getHeight");
|
||||
objectExpressions["Variable"]
|
||||
.SetFunctionName("gdjs.RuntimeObject.getVariableNumber")
|
||||
.SetStatic();
|
||||
@@ -242,8 +163,8 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
objectExpressions["Angle"].SetFunctionName("getAngle");
|
||||
objectExpressions["ForceLength"].SetFunctionName(
|
||||
"getAverageForce().getLength");
|
||||
objectExpressions["Longueur"].SetFunctionName(
|
||||
"getAverageForce().getLength"); // Deprecated
|
||||
// Deprecated
|
||||
objectExpressions["Longueur"].SetFunctionName("getAverageForce().getLength");
|
||||
objectExpressions["Distance"].SetFunctionName("getDistanceToObject");
|
||||
objectExpressions["SqDistance"].SetFunctionName("getSqDistanceToObject");
|
||||
objectExpressions["DistanceToPosition"].SetFunctionName(
|
||||
@@ -265,11 +186,12 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
"gdjs.evtTools.object.createObjectOnScene");
|
||||
GetAllActions()["CreateByName"].SetFunctionName(
|
||||
"gdjs.evtTools.object.createObjectFromGroupOnScene");
|
||||
|
||||
// Deprecated
|
||||
GetAllExpressions()["Count"].SetFunctionName(
|
||||
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
|
||||
"gdjs.evtTools.object.pickedObjectsCount");
|
||||
// Deprecated
|
||||
GetAllConditions()["NbObjet"].SetFunctionName(
|
||||
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
|
||||
"gdjs.evtTools.object.pickedObjectsCount");
|
||||
|
||||
GetAllExpressions()["SceneInstancesCount"].SetFunctionName(
|
||||
"gdjs.evtTools.object.getSceneInstancesCount");
|
||||
@@ -315,42 +237,69 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
{"-", "sub"},
|
||||
{"*", "mul"},
|
||||
{"/", "div"},
|
||||
})
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
});
|
||||
objectActions["ModVarObjetTxt"]
|
||||
.SetFunctionName("returnVariable")
|
||||
.SetManipulatedType("string")
|
||||
.SetMutators({
|
||||
{"=", "setString"},
|
||||
{"+", "concatenate"},
|
||||
})
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
});
|
||||
|
||||
objectActions["SetObjectVariableAsBoolean"]
|
||||
.SetFunctionName("setVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ToggleObjectVariableAsBoolean"]
|
||||
.SetFunctionName("toggleVariableBoolean")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["SetObjectVariableAsBoolean"].SetFunctionName(
|
||||
"setVariableBoolean");
|
||||
objectActions["ToggleObjectVariableAsBoolean"].SetFunctionName(
|
||||
"toggleVariableBoolean");
|
||||
|
||||
objectActions["ObjectVariablePush"]
|
||||
.SetFunctionName("variablePushCopy")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushString"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushNumber"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePushBool"]
|
||||
.SetFunctionName("valuePush")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariableRemoveAt"]
|
||||
.SetFunctionName("variableRemoveAt")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectConditions["ObjectVariableChildCount"]
|
||||
.SetFunctionName("getVariableChildCount")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
objectActions["ObjectVariablePush"].SetFunctionName("variablePushCopy");
|
||||
objectActions["ObjectVariablePushString"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariablePushNumber"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariablePushBool"].SetFunctionName("valuePush");
|
||||
objectActions["ObjectVariableRemoveAt"].SetFunctionName("variableRemoveAt");
|
||||
objectConditions["ObjectVariableChildCount"].SetFunctionName(
|
||||
"getVariableChildCount");
|
||||
|
||||
// Instructions for the Resizable capability
|
||||
objectActions["SetSize"].SetFunctionName("setSize");
|
||||
objectConditions["Width"].SetFunctionName("getWidth");
|
||||
objectActions["SetWidth"].SetFunctionName("setWidth");
|
||||
objectConditions["Height"].SetFunctionName("getHeight");
|
||||
objectActions["SetHeight"].SetFunctionName("setHeight");
|
||||
|
||||
// Instructions for the Scalable capability
|
||||
objectExpressions["Scale"].SetFunctionName("getScale");
|
||||
objectConditions["Scale"].SetFunctionName("getScale");
|
||||
objectActions["SetScale"].SetFunctionName("setScale");
|
||||
objectExpressions["ScaleX"].SetFunctionName("getScaleX");
|
||||
objectConditions["ScaleX"].SetFunctionName("getScaleX");
|
||||
objectActions["SetScaleX"].SetFunctionName("setScaleX");
|
||||
objectExpressions["ScaleY"].SetFunctionName("getScaleY");
|
||||
objectConditions["ScaleY"].SetFunctionName("getScaleY");
|
||||
objectActions["SetScaleY"].SetFunctionName("setScaleY");
|
||||
|
||||
// Instructions for the Flippable capability
|
||||
objectActions["FlipX"].SetFunctionName("flipX");
|
||||
objectActions["FlipY"].SetFunctionName("flipY");
|
||||
objectConditions["FlippedX"].SetFunctionName("isFlippedX");
|
||||
objectConditions["FlippedY"].SetFunctionName("isFlippedY");
|
||||
|
||||
// Instructions for the Animable capability
|
||||
objectExpressions["AnimationIndex"].SetFunctionName("getAnimationIndex");
|
||||
objectConditions["AnimationIndex"].SetFunctionName("getAnimationIndex");
|
||||
objectActions["SetAnimationIndex"].SetFunctionName("setAnimationIndex");
|
||||
objectStrExpressions["AnimationName"].SetFunctionName("getAnimationName");
|
||||
objectConditions["AnimationName"].SetFunctionName("isCurrentAnimationName");
|
||||
objectActions["SetAnimationName"].SetFunctionName("setAnimationName");
|
||||
objectActions["PauseAnimation"].SetFunctionName("pauseAnimation");
|
||||
objectActions["PlayAnimation"].SetFunctionName("resumeAnimation");
|
||||
objectExpressions["AnimationSpeedScale"].SetFunctionName(
|
||||
"getAnimationSpeedScale");
|
||||
objectConditions["AnimationSpeedScale"].SetFunctionName(
|
||||
"getAnimationSpeedScale");
|
||||
objectActions["SetAnimationSpeedScale"].SetFunctionName(
|
||||
"setAnimationSpeedScale");
|
||||
objectConditions["IsAnimationPaused"].SetFunctionName("isAnimationPaused");
|
||||
objectConditions["HasAnimationEnded"].SetFunctionName("hasAnimationEnded");
|
||||
|
||||
GetAllActions()["MoveObjects"].SetCustomCodeGenerator(
|
||||
[](gd::Instruction &,
|
||||
@@ -481,4 +430,4 @@ BaseObjectExtension::BaseObjectExtension() {
|
||||
StripUnimplementedInstructionsAndExpressions();
|
||||
}
|
||||
|
||||
} // namespace gdjs
|
||||
} // namespace gdjs
|
||||
|
@@ -45,7 +45,7 @@ SpriteExtension::SpriteExtension() {
|
||||
spriteConditions["AnimationName"].SetFunctionName("isCurrentAnimationName");
|
||||
spriteConditions["Direction"].SetFunctionName("getDirectionOrAngle");
|
||||
spriteConditions["Sprite"].SetFunctionName("getAnimationFrame");
|
||||
spriteConditions["AnimationEnded"].SetFunctionName("hasAnimationEnded");
|
||||
spriteConditions["AnimationEnded"].SetFunctionName("hasAnimationEndedLegacy");
|
||||
spriteConditions["AnimationEnded2"].SetFunctionName("hasAnimationEnded2");
|
||||
spriteActions["PauseAnimation"].SetFunctionName("pauseAnimation");
|
||||
spriteActions["PlayAnimation"].SetFunctionName("playAnimation");
|
||||
@@ -105,14 +105,8 @@ SpriteExtension::SpriteExtension() {
|
||||
"getDirectionOrAngle"); // Deprecated
|
||||
spriteExpressions["Direction"].SetFunctionName("getDirectionOrAngle");
|
||||
spriteExpressions["Anim"].SetFunctionName("getAnimation"); // Deprecated
|
||||
spriteExpressions["Animation"].SetFunctionName("getAnimation");
|
||||
spriteStrExpressions["AnimationName"].SetFunctionName("getAnimationName");
|
||||
spriteExpressions["Sprite"].SetFunctionName("getAnimationFrame");
|
||||
spriteExpressions["AnimationFrameCount"].SetFunctionName("getAnimationFrameCount");
|
||||
spriteExpressions["AnimationSpeedScale"].SetFunctionName(
|
||||
"getAnimationSpeedScale");
|
||||
spriteExpressions["ScaleX"].SetFunctionName("getScaleX");
|
||||
spriteExpressions["ScaleY"].SetFunctionName("getScaleY");
|
||||
spriteExpressions["Opacity"].SetFunctionName("getOpacity");
|
||||
}
|
||||
|
||||
|
131
GDJS/Runtime/ObjectCapabilities.d.ts
vendored
Normal file
131
GDJS/Runtime/ObjectCapabilities.d.ts
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* GDevelop JS Platform
|
||||
* Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
||||
* This project is released under the MIT License.
|
||||
*/
|
||||
declare namespace gdjs {
|
||||
export interface Resizable {
|
||||
/**
|
||||
* Change the width of the object. This changes the scale on X axis of the object.
|
||||
*
|
||||
* @param newWidth The new width of the object, in pixels.
|
||||
*/
|
||||
setWidth(newWidth: float): void;
|
||||
|
||||
/**
|
||||
* Change the height of the object. This changes the scale on Y axis of the object.
|
||||
*
|
||||
* @param newHeight The new height of the object, in pixels.
|
||||
*/
|
||||
setHeight(newHeight: float): void;
|
||||
|
||||
/**
|
||||
* Change the size of the object.
|
||||
*
|
||||
* @param newWidth The new width of the object, in pixels.
|
||||
* @param newHeight The new height of the object, in pixels.
|
||||
*/
|
||||
setSize(newWidth: float, newHeight: float): void;
|
||||
}
|
||||
|
||||
export interface Scalable {
|
||||
/**
|
||||
* Change the scale on X and Y axis of the object.
|
||||
*
|
||||
* @param newScale The new scale (must be greater than 0).
|
||||
*/
|
||||
setScale(newScale: number): void;
|
||||
|
||||
/**
|
||||
* Change the scale on X axis of the object (changing its width).
|
||||
*
|
||||
* @param newScale The new scale (must be greater than 0).
|
||||
*/
|
||||
setScaleX(newScale: number): void;
|
||||
|
||||
/**
|
||||
* Change the scale on Y axis of the object (changing its height).
|
||||
*
|
||||
* @param newScale The new scale (must be greater than 0).
|
||||
*/
|
||||
setScaleY(newScale: number): void;
|
||||
|
||||
/**
|
||||
* Get the scale of the object (or the average of the X and Y scale in case they are different).
|
||||
*
|
||||
* @return the scale of the object (or the average of the X and Y scale in case they are different).
|
||||
*/
|
||||
getScale(): number;
|
||||
|
||||
/**
|
||||
* Get the scale of the object on Y axis.
|
||||
*
|
||||
* @return the scale of the object on Y axis
|
||||
*/
|
||||
getScaleY(): float;
|
||||
|
||||
/**
|
||||
* Get the scale of the object on X axis.
|
||||
*
|
||||
* @return the scale of the object on X axis
|
||||
*/
|
||||
getScaleX(): float;
|
||||
}
|
||||
|
||||
export interface Flippable {
|
||||
flipX(enable: boolean): void;
|
||||
|
||||
flipY(enable: boolean): void;
|
||||
|
||||
isFlippedX(): boolean;
|
||||
|
||||
isFlippedY(): boolean;
|
||||
}
|
||||
|
||||
export interface Animable {
|
||||
/**
|
||||
* Get the index of the animation being played.
|
||||
* @return The index of the new animation being played
|
||||
*/
|
||||
getAnimationIndex(): number;
|
||||
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param animationIndex The index of the new animation to be played
|
||||
*/
|
||||
setAnimationIndex(animationIndex: number): void;
|
||||
|
||||
/**
|
||||
* Get the name of the animation being played.
|
||||
* @return The name of the new animation being played
|
||||
*/
|
||||
getAnimationName(): string;
|
||||
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param newAnimationName The name of the new animation to be played
|
||||
*/
|
||||
setAnimationName(newAnimationName: string): void;
|
||||
|
||||
isCurrentAnimationName(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Return true if animation has ended.
|
||||
* The animation had ended if:
|
||||
* - it's not configured as a loop;
|
||||
* - the current frame is the last frame;
|
||||
* - the last frame has been displayed long enough.
|
||||
*/
|
||||
hasAnimationEnded(): boolean;
|
||||
|
||||
isAnimationPaused(): boolean;
|
||||
|
||||
pauseAnimation(): void;
|
||||
|
||||
resumeAnimation(): void;
|
||||
|
||||
getAnimationSpeedScale(): float;
|
||||
|
||||
setAnimationSpeedScale(ratio: float): void;
|
||||
}
|
||||
}
|
@@ -153,7 +153,8 @@ namespace gdjs {
|
||||
* A `gdjs.RuntimeObject` should not be instantiated directly, always a child class
|
||||
* (because gdjs.RuntimeObject don't call onCreated at the end of its constructor).
|
||||
*/
|
||||
export class RuntimeObject implements EffectsTarget {
|
||||
export class RuntimeObject
|
||||
implements EffectsTarget, gdjs.Resizable, gdjs.Scalable, gdjs.Flippable {
|
||||
name: string;
|
||||
type: string;
|
||||
x: float = 0;
|
||||
@@ -1201,18 +1202,6 @@ namespace gdjs {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the object, if applicable.
|
||||
* @param width The new width in pixels.
|
||||
*/
|
||||
setWidth(width: float): void {}
|
||||
|
||||
/**
|
||||
* Set the height of the object, if applicable.
|
||||
* @param height The new height in pixels.
|
||||
*/
|
||||
setHeight(height: float): void {}
|
||||
|
||||
/**
|
||||
* Return the width of the object.
|
||||
* @return The width of the object
|
||||
@@ -2548,6 +2537,85 @@ namespace gdjs {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implementation of the Resizable interface.
|
||||
setWidth(width: float): void {}
|
||||
setHeight(height: float): void {}
|
||||
setSize(newWidth: number, newHeight: number): void {}
|
||||
|
||||
// Implementation of the Scalable interface.
|
||||
setScale(newScale: number): void {}
|
||||
setScaleX(newScale: number): void {}
|
||||
setScaleY(newScale: number): void {}
|
||||
getScale(): number {
|
||||
const scaleX = Math.abs(this.getScaleX());
|
||||
const scaleY = Math.abs(this.getScaleY());
|
||||
return scaleX === scaleY ? scaleX : Math.sqrt(scaleX * scaleY);
|
||||
}
|
||||
getScaleY(): number {
|
||||
return 1;
|
||||
}
|
||||
getScaleX(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Implementation of the Flippable interface.
|
||||
flipX(enable: boolean) {}
|
||||
flipY(enable: boolean) {}
|
||||
isFlippedX(): boolean {
|
||||
return false;
|
||||
}
|
||||
isFlippedY(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Implementation of the Animable interface.
|
||||
/**
|
||||
* Get the index of the animation being played.
|
||||
* @return The index of the new animation being played
|
||||
*/
|
||||
getAnimationIndex(): number {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param animationIndex The index of the new animation to be played
|
||||
*/
|
||||
setAnimationIndex(animationIndex: number): void {}
|
||||
/**
|
||||
* Get the name of the animation being played.
|
||||
* @return The name of the new animation being played
|
||||
*/
|
||||
getAnimationName(): string {
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param newAnimationName The name of the new animation to be played
|
||||
*/
|
||||
setAnimationName(newAnimationName: string): void {}
|
||||
isCurrentAnimationName(name: string): boolean {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Return true if animation has ended.
|
||||
* The animation had ended if:
|
||||
* - it's not configured as a loop;
|
||||
* - the current frame is the last frame;
|
||||
* - the last frame has been displayed long enough.
|
||||
*/
|
||||
hasAnimationEnded(): boolean {
|
||||
return false;
|
||||
}
|
||||
isAnimationPaused() {
|
||||
return false;
|
||||
}
|
||||
pauseAnimation() {}
|
||||
resumeAnimation() {}
|
||||
getAnimationSpeedScale() {
|
||||
return 1;
|
||||
}
|
||||
setAnimationSpeedScale(ratio: float): void {}
|
||||
|
||||
/**
|
||||
* Get the identifier associated to an object name.
|
||||
* Some features may want to compare objects name a large number of time. In this case,
|
||||
|
@@ -416,7 +416,7 @@ namespace gdjs {
|
||||
//Make sure to delete already existing animations which are not used anymore.
|
||||
this._updateAnimationFrame();
|
||||
if (!this._animationFrame) {
|
||||
this.setAnimation(0);
|
||||
this.setAnimationIndex(0);
|
||||
}
|
||||
this.invalidateHitboxes();
|
||||
return true;
|
||||
@@ -435,7 +435,7 @@ namespace gdjs {
|
||||
) {
|
||||
const extraData = initialInstanceData.numberProperties[i];
|
||||
if (extraData.name === 'animation') {
|
||||
this.setAnimation(extraData.value);
|
||||
this.setAnimationIndex(extraData.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,8 +614,13 @@ namespace gdjs {
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param newAnimation The index of the new animation to be played
|
||||
* @deprecated Use `setAnimationIndex` instead
|
||||
*/
|
||||
setAnimation(newAnimation: number): void {
|
||||
this.setAnimationIndex(newAnimation);
|
||||
}
|
||||
|
||||
setAnimationIndex(newAnimation: number): void {
|
||||
newAnimation = newAnimation | 0;
|
||||
if (
|
||||
newAnimation < this._animations.length &&
|
||||
@@ -633,17 +638,14 @@ namespace gdjs {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the animation being played.
|
||||
* @param newAnimationName The name of the new animation to be played
|
||||
*/
|
||||
setAnimationName(newAnimationName: string): void {
|
||||
if (!newAnimationName) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < this._animations.length; ++i) {
|
||||
if (this._animations[i].name === newAnimationName) {
|
||||
return this.setAnimation(i);
|
||||
this.setAnimationIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -651,15 +653,16 @@ namespace gdjs {
|
||||
/**
|
||||
* Get the index of the animation being played.
|
||||
* @return The index of the new animation being played
|
||||
* @deprecated Use `getAnimationIndex` instead
|
||||
*/
|
||||
getAnimation(): number {
|
||||
return this.getAnimationIndex();
|
||||
}
|
||||
|
||||
getAnimationIndex(): number {
|
||||
return this._currentAnimation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the animation being played.
|
||||
* @return The name of the new animation being played
|
||||
*/
|
||||
getAnimationName(): string {
|
||||
if (this._currentAnimation >= this._animations.length) {
|
||||
return '';
|
||||
@@ -667,7 +670,7 @@ namespace gdjs {
|
||||
return this._animations[this._currentAnimation].name;
|
||||
}
|
||||
|
||||
isCurrentAnimationName(name): boolean {
|
||||
isCurrentAnimationName(name: string): boolean {
|
||||
return this.getAnimationName() === name;
|
||||
}
|
||||
|
||||
@@ -768,10 +771,10 @@ namespace gdjs {
|
||||
/**
|
||||
* @deprecated
|
||||
* Return true if animation has ended.
|
||||
* Prefer using hasAnimationEnded2. This method returns true as soon as
|
||||
* Prefer using `hasAnimationEnded2`. This method returns true as soon as
|
||||
* the animation enters the last frame, not at the end of the last frame.
|
||||
*/
|
||||
hasAnimationEnded(): boolean {
|
||||
hasAnimationEndedLegacy(): boolean {
|
||||
if (
|
||||
this._currentAnimation >= this._animations.length ||
|
||||
this._currentDirection >=
|
||||
@@ -794,8 +797,14 @@ namespace gdjs {
|
||||
* - it's not configured as a loop;
|
||||
* - the current frame is the last frame;
|
||||
* - the last frame has been displayed long enough.
|
||||
*
|
||||
* @deprecated Use `hasAnimationEnded` instead.
|
||||
*/
|
||||
hasAnimationEnded2(): boolean {
|
||||
return this.hasAnimationEnded();
|
||||
}
|
||||
|
||||
hasAnimationEnded(): boolean {
|
||||
if (
|
||||
this._currentAnimation >= this._animations.length ||
|
||||
this._currentDirection >=
|
||||
@@ -815,15 +824,29 @@ namespace gdjs {
|
||||
);
|
||||
}
|
||||
|
||||
animationPaused() {
|
||||
/**
|
||||
* @deprecated Use `isAnimationPaused` instead.
|
||||
*/
|
||||
animationPaused(): boolean {
|
||||
return this.isAnimationPaused();
|
||||
}
|
||||
|
||||
isAnimationPaused(): boolean {
|
||||
return this._animationPaused;
|
||||
}
|
||||
|
||||
pauseAnimation() {
|
||||
pauseAnimation(): void {
|
||||
this._animationPaused = true;
|
||||
}
|
||||
|
||||
playAnimation() {
|
||||
/**
|
||||
* @deprecated Use `resumeAnimation` instead.
|
||||
*/
|
||||
playAnimation(): void {
|
||||
this.resumeAnimation();
|
||||
}
|
||||
|
||||
resumeAnimation(): void {
|
||||
this._animationPaused = false;
|
||||
}
|
||||
|
||||
@@ -831,7 +854,7 @@ namespace gdjs {
|
||||
return this._animationSpeedScale;
|
||||
}
|
||||
|
||||
setAnimationSpeedScale(ratio): void {
|
||||
setAnimationSpeedScale(ratio: float): void {
|
||||
this._animationSpeedScale = ratio;
|
||||
}
|
||||
|
||||
|
@@ -1285,6 +1285,7 @@ interface AbstractFunctionMetadata {
|
||||
[Ref] AbstractFunctionMetadata SetDefaultValue([Const] DOMString defaultValue);
|
||||
[Ref] AbstractFunctionMetadata SetParameterLongDescription([Const] DOMString longDescription);
|
||||
[Ref] AbstractFunctionMetadata SetParameterExtraInfo([Const] DOMString extraInfo);
|
||||
[Ref] AbstractFunctionMetadata SetParameterObjectType([Const, Ref] ObjectType extraInfo);
|
||||
|
||||
[Ref] AbstractFunctionMetadata SetHidden();
|
||||
[Ref] AbstractFunctionMetadata SetPrivate();
|
||||
@@ -1336,11 +1337,12 @@ interface InstructionMetadata {
|
||||
[Ref] InstructionMetadata SetDefaultValue([Const] DOMString defaultValue);
|
||||
[Ref] InstructionMetadata SetParameterLongDescription([Const] DOMString longDescription);
|
||||
[Ref] InstructionMetadata SetParameterExtraInfo([Const] DOMString extraInfo);
|
||||
[Ref] InstructionMetadata AddRequiredObjectCapabilityOnLastParameter([Const] DOMString capability);
|
||||
|
||||
[Ref] InstructionMetadata UseStandardOperatorParameters([Const] DOMString type, [Const, Ref] ParameterOptions options);
|
||||
[Ref] InstructionMetadata UseStandardRelationalOperatorParameters([Const] DOMString type, [Const, Ref] ParameterOptions options);
|
||||
|
||||
[Ref] InstructionMetadata SetRequiresBaseObjectCapability([Const] DOMString capability);
|
||||
[Ref] InstructionMetadata SetRequiredBaseObjectCapability([Const] DOMString capability);
|
||||
[Const, Ref] DOMString GetRequiredBaseObjectCapability();
|
||||
|
||||
[Ref] InstructionMetadata MarkAsSimple();
|
||||
@@ -1404,8 +1406,9 @@ interface ExpressionMetadata {
|
||||
[Ref] ExpressionMetadata SetDefaultValue([Const] DOMString defaultValue);
|
||||
[Ref] ExpressionMetadata SetParameterLongDescription([Const] DOMString longDescription);
|
||||
[Ref] ExpressionMetadata SetParameterExtraInfo([Const] DOMString extraInfo);
|
||||
[Ref] ExpressionMetadata AddRequiredObjectCapabilityOnLastParameter([Const] DOMString capability);
|
||||
|
||||
[Ref] ExpressionMetadata SetRequiresBaseObjectCapability([Const] DOMString capability);
|
||||
[Ref] ExpressionMetadata SetRequiredBaseObjectCapability([Const] DOMString capability);
|
||||
[Const, Ref] DOMString GetRequiredBaseObjectCapability();
|
||||
|
||||
[Ref] ExpressionMetadata GetCodeExtraInformation();
|
||||
@@ -1429,6 +1432,7 @@ interface MultipleInstructionMetadata {
|
||||
[Ref] MultipleInstructionMetadata SetDefaultValue([Const] DOMString defaultValue);
|
||||
[Ref] MultipleInstructionMetadata SetParameterLongDescription([Const] DOMString longDescription);
|
||||
[Ref] MultipleInstructionMetadata SetParameterExtraInfo([Const] DOMString extraInfo);
|
||||
[Ref] MultipleInstructionMetadata AddRequiredObjectCapabilityOnLastParameter([Const] DOMString capability);
|
||||
|
||||
[Ref] MultipleInstructionMetadata UseStandardParameters([Const] DOMString type, [Const, Ref] ParameterOptions options);
|
||||
|
||||
@@ -1506,6 +1510,8 @@ interface ValueTypeMetadata {
|
||||
[Ref] ValueTypeMetadata SetName([Const] DOMString name_);
|
||||
[Const, Ref] DOMString GetExtraInfo();
|
||||
[Ref] ValueTypeMetadata SetExtraInfo([Const] DOMString extraInfo_);
|
||||
[Ref] ObjectType GetObjectType();
|
||||
void SetObjectType([Const, Ref] ObjectType objectType);
|
||||
boolean IsOptional();
|
||||
[Ref] ValueTypeMetadata SetOptional(boolean optional_);
|
||||
[Const, Ref] DOMString GetDefaultValue();
|
||||
@@ -1633,14 +1639,30 @@ interface ObjectMetadata {
|
||||
[Ref] ObjectMetadata SetIncludeFile([Const] DOMString includeFile);
|
||||
[Ref] ObjectMetadata AddIncludeFile([Const] DOMString includeFile);
|
||||
|
||||
[Const, Ref] SetString GetUnsupportedBaseObjectCapabilities();
|
||||
[Ref] ObjectMetadata AddUnsupportedBaseObjectCapability([Const] DOMString capability);
|
||||
boolean IsUnsupportedBaseObjectCapability([Const] DOMString capability);
|
||||
[Const, Ref] SetString GetSupportedBaseObjectCapabilities();
|
||||
[Ref] ObjectMetadata MarkBaseObjectCapabilityAsUnsupported([Const] DOMString capability);
|
||||
[Ref] ObjectMetadata MarkBaseObjectCapabilityAsSupported([Const] DOMString capability);
|
||||
boolean IsSupportedBaseObjectCapability([Const] DOMString capability);
|
||||
|
||||
[Ref] ObjectMetadata SetHidden();
|
||||
boolean IsHidden();
|
||||
};
|
||||
|
||||
interface ObjectType {
|
||||
[Ref] ObjectType SetName([Const] DOMString objectType);
|
||||
[Const, Ref] DOMString GetName();
|
||||
|
||||
[Ref] ObjectType AddCapability([Const] DOMString capability);
|
||||
void RemoveCapability([Const] DOMString capability);
|
||||
boolean HasCapability([Const] DOMString capability);
|
||||
|
||||
boolean IsBaseObject();
|
||||
boolean IsMatchedBy([ Const, Ref ] Platform platform,
|
||||
[ Const, Ref ] ObjectsContainer globalObjectsContainer,
|
||||
[ Const, Ref ] ObjectsContainer objectsContainer,
|
||||
[Const] DOMString objectName);
|
||||
};
|
||||
|
||||
interface BehaviorMetadata {
|
||||
[Const, Ref] DOMString GetName();
|
||||
[Const, Ref] DOMString GetFullName();
|
||||
@@ -1736,8 +1758,8 @@ interface BehaviorMetadata {
|
||||
[Ref] BehaviorMetadata AddIncludeFile([Const] DOMString includeFile);
|
||||
[Ref] BehaviorMetadata AddRequiredFile([Const] DOMString resourceFile);
|
||||
|
||||
[Ref] BehaviorMetadata SetObjectType([Const] DOMString objectType);
|
||||
[Const, Ref] DOMString GetObjectType();
|
||||
[Ref] BehaviorMetadata SetObjectType([Const, Ref] ObjectType objectType);
|
||||
[Const, Ref] ObjectType GetObjectType();
|
||||
|
||||
boolean IsPrivate();
|
||||
[Ref] BehaviorMetadata SetPrivate();
|
||||
@@ -2601,8 +2623,7 @@ interface EventsBasedBehavior {
|
||||
[Const, Ref] DOMString GetName();
|
||||
[Ref] EventsBasedBehavior SetFullName([Const] DOMString fullName);
|
||||
[Const, Ref] DOMString GetFullName();
|
||||
[Ref] EventsBasedBehavior SetObjectType([Const] DOMString fullName);
|
||||
[Const, Ref] DOMString GetObjectType();
|
||||
[Ref] ObjectType GetObjectType();
|
||||
[Ref] EventsBasedBehavior SetPrivate(boolean isPrivate);
|
||||
boolean IsPrivate();
|
||||
|
||||
|
@@ -72,6 +72,7 @@
|
||||
#include <GDCore/Project/MeasurementUnitElement.h>
|
||||
#include <GDCore/Project/NamedPropertyDescriptor.h>
|
||||
#include <GDCore/Project/Object.h>
|
||||
#include <GDCore/Project/ObjectType.h>
|
||||
#include <GDCore/Project/ObjectConfiguration.h>
|
||||
#include <GDCore/Project/CustomObjectConfiguration.h>
|
||||
#include <GDCore/Project/Project.h>
|
||||
|
@@ -13,7 +13,7 @@ endif()
|
||||
|
||||
# Compilation flags (https://emscripten.org/docs/tools_reference/emcc.html):
|
||||
add_compile_options(-O2) # Optimizations during compilation
|
||||
# add_compile_options(-g --profiling) # Uncomment for debugging + profiling support
|
||||
#add_compile_options(-g --profiling) # Uncomment for debugging + profiling support
|
||||
# add_compile_options(--profiling) # Uncomment for profiling support
|
||||
|
||||
# Common directories:
|
||||
|
@@ -137,7 +137,7 @@ module.exports = {
|
||||
'',
|
||||
fakeObject
|
||||
)
|
||||
.addUnsupportedBaseObjectCapability('effect');
|
||||
.markBaseObjectCapabilityAsUnsupported('effect');
|
||||
|
||||
platform.addNewExtension(extension);
|
||||
extension.delete(); // Release the extension as it was copied inside gd.JsPlatform
|
||||
|
@@ -4058,7 +4058,7 @@ describe('libGD.js', function () {
|
||||
parameter3.setDescription(
|
||||
'This parameter will be skipped, as it has no name'
|
||||
);
|
||||
parameter3.setExtraInfo('Sprite');
|
||||
parameter3.getValueTypeMetadata().getObjectType().setName('Sprite');
|
||||
const parameter4 = new gd.ParameterMetadata();
|
||||
parameter4.setType('string');
|
||||
parameter4.setName('MyString');
|
||||
@@ -4067,7 +4067,7 @@ describe('libGD.js', function () {
|
||||
parameter5.setType('objectList');
|
||||
parameter5.setName('MySpriteObject');
|
||||
parameter5.setDescription('The second object to be used, a sprite');
|
||||
parameter5.setExtraInfo('Sprite');
|
||||
parameter5.getValueTypeMetadata().getObjectType().setName('Sprite');
|
||||
|
||||
parameters.push_back(parameter1);
|
||||
parameters.push_back(parameter2);
|
||||
|
@@ -409,7 +409,7 @@ describe('libGD.js - GDJS related tests', function () {
|
||||
parameter3.setType('objectList');
|
||||
parameter3.setName('MySprite');
|
||||
parameter3.setDescription('The second object to be used, a sprite');
|
||||
parameter3.setExtraInfo('Sprite');
|
||||
parameter3.getValueTypeMetadata().getObjectType().setName('Sprite');
|
||||
const parameter4 = new gd.ParameterMetadata();
|
||||
parameter4.setType('string');
|
||||
parameter4.setName('MyString');
|
||||
@@ -534,7 +534,7 @@ describe('libGD.js - GDJS related tests', function () {
|
||||
parameter2.setType('objectList');
|
||||
parameter2.setName('MySprite');
|
||||
parameter2.setDescription('The second object to be used, a sprite');
|
||||
parameter2.setExtraInfo('Sprite');
|
||||
parameter2.getValueTypeMetadata().getObjectType().setName('Sprite');
|
||||
parameters.push_back(parameter1);
|
||||
parameters.push_back(parameter2);
|
||||
|
||||
|
@@ -2428,7 +2428,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
@@ -2492,7 +2492,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
@@ -2556,7 +2556,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
@@ -2712,7 +2712,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
@@ -3210,7 +3210,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
@@ -3466,7 +3466,7 @@ describe('libGD.js - GDJS Async Code Generation integration tests', function ()
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
parameter.setType('object');
|
||||
parameter.setName('MyParamObject');
|
||||
parameter.setExtraInfo(
|
||||
parameter.getValueTypeMetadata().getObjectType().setName(
|
||||
'FakeObjectWithAsyncAction::FakeObjectWithAsyncAction'
|
||||
);
|
||||
eventsFunction.getParameters().push_back(parameter);
|
||||
|
@@ -1356,7 +1356,7 @@ describe('MetadataDeclarationHelper', () => {
|
||||
|
||||
expect(action.getParametersCount()).toBe(3);
|
||||
expect(action.getParameter(0).getType()).toBe('object');
|
||||
expect(action.getParameter(0).getExtraInfo()).toBe('MyObject');
|
||||
expect(action.getParameter(0).getValueTypeMetadata().getObjectType().getName()).toBe('MyObject');
|
||||
expect(action.getParameter(1).getType()).toBe('operator');
|
||||
expect(action.getParameter(2).getType()).toBe('string');
|
||||
|
||||
@@ -1379,7 +1379,7 @@ describe('MetadataDeclarationHelper', () => {
|
||||
|
||||
expect(condition.getParametersCount()).toBe(3);
|
||||
expect(condition.getParameter(0).getType()).toBe('object');
|
||||
expect(condition.getParameter(0).getExtraInfo()).toBe('MyObject');
|
||||
expect(condition.getParameter(0).getValueTypeMetadata().getObjectType().getName()).toBe('MyObject');
|
||||
expect(condition.getParameter(1).getType()).toBe('relationalOperator');
|
||||
expect(condition.getParameter(2).getType()).toBe('string');
|
||||
|
||||
@@ -1397,7 +1397,7 @@ describe('MetadataDeclarationHelper', () => {
|
||||
|
||||
expect(expression.getParametersCount()).toBe(1);
|
||||
expect(expression.getParameter(0).getType()).toBe('object');
|
||||
expect(expression.getParameter(0).getExtraInfo()).toBe('MyObject');
|
||||
expect(expression.getParameter(0).getValueTypeMetadata().getObjectType().getName()).toBe('MyObject');
|
||||
|
||||
extension.delete();
|
||||
project.delete();
|
||||
@@ -1450,7 +1450,7 @@ describe('MetadataDeclarationHelper', () => {
|
||||
|
||||
expect(action.getParametersCount()).toBe(2);
|
||||
expect(action.getParameter(0).getType()).toBe('object');
|
||||
expect(action.getParameter(0).getExtraInfo()).toBe('MyObject');
|
||||
expect(action.getParameter(0).getValueTypeMetadata().getObjectType().getName()).toBe('MyObject');
|
||||
expect(action.getParameter(1).getType()).toBe('yesorno');
|
||||
|
||||
expect(
|
||||
@@ -1471,7 +1471,7 @@ describe('MetadataDeclarationHelper', () => {
|
||||
|
||||
expect(condition.getParametersCount()).toBe(1);
|
||||
expect(condition.getParameter(0).getType()).toBe('object');
|
||||
expect(condition.getParameter(0).getExtraInfo()).toBe('MyObject');
|
||||
expect(condition.getParameter(0).getValueTypeMetadata().getObjectType().getName()).toBe('MyObject');
|
||||
|
||||
extension.delete();
|
||||
project.delete();
|
||||
|
@@ -5,6 +5,7 @@ declare class gdAbstractFunctionMetadata {
|
||||
setDefaultValue(defaultValue: string): gdAbstractFunctionMetadata;
|
||||
setParameterLongDescription(longDescription: string): gdAbstractFunctionMetadata;
|
||||
setParameterExtraInfo(extraInfo: string): gdAbstractFunctionMetadata;
|
||||
setParameterObjectType(extraInfo: gdObjectType): gdAbstractFunctionMetadata;
|
||||
setHidden(): gdAbstractFunctionMetadata;
|
||||
setPrivate(): gdAbstractFunctionMetadata;
|
||||
setFunctionName(functionName: string): gdAbstractFunctionMetadata;
|
||||
|
@@ -26,8 +26,8 @@ declare class gdBehaviorMetadata {
|
||||
setIncludeFile(includeFile: string): gdBehaviorMetadata;
|
||||
addIncludeFile(includeFile: string): gdBehaviorMetadata;
|
||||
addRequiredFile(resourceFile: string): gdBehaviorMetadata;
|
||||
setObjectType(objectType: string): gdBehaviorMetadata;
|
||||
getObjectType(): string;
|
||||
setObjectType(objectType: gdObjectType): gdBehaviorMetadata;
|
||||
getObjectType(): gdObjectType;
|
||||
isPrivate(): boolean;
|
||||
setPrivate(): gdBehaviorMetadata;
|
||||
get(): gdBehavior;
|
||||
|
@@ -7,8 +7,7 @@ declare class gdEventsBasedBehavior extends gdAbstractEventsBasedEntity {
|
||||
getName(): string;
|
||||
setFullName(fullName: string): gdEventsBasedBehavior;
|
||||
getFullName(): string;
|
||||
setObjectType(fullName: string): gdEventsBasedBehavior;
|
||||
getObjectType(): string;
|
||||
getObjectType(): gdObjectType;
|
||||
setPrivate(isPrivate: boolean): gdEventsBasedBehavior;
|
||||
isPrivate(): boolean;
|
||||
getSharedPropertyDescriptors(): gdNamedPropertyDescriptorsList;
|
||||
|
@@ -27,7 +27,8 @@ declare class gdExpressionMetadata extends gdAbstractFunctionMetadata {
|
||||
setDefaultValue(defaultValue: string): gdExpressionMetadata;
|
||||
setParameterLongDescription(longDescription: string): gdExpressionMetadata;
|
||||
setParameterExtraInfo(extraInfo: string): gdExpressionMetadata;
|
||||
setRequiresBaseObjectCapability(capability: string): gdExpressionMetadata;
|
||||
addRequiredObjectCapabilityOnLastParameter(capability: string): gdExpressionMetadata;
|
||||
setRequiredBaseObjectCapability(capability: string): gdExpressionMetadata;
|
||||
getRequiredBaseObjectCapability(): string;
|
||||
getCodeExtraInformation(): gdExpressionMetadata;
|
||||
setFunctionName(functionName: string): gdExpressionMetadata;
|
||||
|
@@ -34,9 +34,10 @@ declare class gdInstructionMetadata extends gdAbstractFunctionMetadata {
|
||||
setDefaultValue(defaultValue: string): gdInstructionMetadata;
|
||||
setParameterLongDescription(longDescription: string): gdInstructionMetadata;
|
||||
setParameterExtraInfo(extraInfo: string): gdInstructionMetadata;
|
||||
addRequiredObjectCapabilityOnLastParameter(capability: string): gdInstructionMetadata;
|
||||
useStandardOperatorParameters(type: string, options: gdParameterOptions): gdInstructionMetadata;
|
||||
useStandardRelationalOperatorParameters(type: string, options: gdParameterOptions): gdInstructionMetadata;
|
||||
setRequiresBaseObjectCapability(capability: string): gdInstructionMetadata;
|
||||
setRequiredBaseObjectCapability(capability: string): gdInstructionMetadata;
|
||||
getRequiredBaseObjectCapability(): string;
|
||||
markAsSimple(): gdInstructionMetadata;
|
||||
markAsAdvanced(): gdInstructionMetadata;
|
||||
|
@@ -5,6 +5,7 @@ declare class gdMultipleInstructionMetadata extends gdAbstractFunctionMetadata {
|
||||
setDefaultValue(defaultValue: string): gdMultipleInstructionMetadata;
|
||||
setParameterLongDescription(longDescription: string): gdMultipleInstructionMetadata;
|
||||
setParameterExtraInfo(extraInfo: string): gdMultipleInstructionMetadata;
|
||||
addRequiredObjectCapabilityOnLastParameter(capability: string): gdMultipleInstructionMetadata;
|
||||
useStandardParameters(type: string, options: gdParameterOptions): gdMultipleInstructionMetadata;
|
||||
setHidden(): gdMultipleInstructionMetadata;
|
||||
setFunctionName(functionName: string): gdMultipleInstructionMetadata;
|
||||
|
@@ -21,9 +21,10 @@ declare class gdObjectMetadata {
|
||||
getAllStrExpressions(): gdMapStringExpressionMetadata;
|
||||
setIncludeFile(includeFile: string): gdObjectMetadata;
|
||||
addIncludeFile(includeFile: string): gdObjectMetadata;
|
||||
getUnsupportedBaseObjectCapabilities(): gdSetString;
|
||||
addUnsupportedBaseObjectCapability(capability: string): gdObjectMetadata;
|
||||
isUnsupportedBaseObjectCapability(capability: string): boolean;
|
||||
getSupportedBaseObjectCapabilities(): gdSetString;
|
||||
markBaseObjectCapabilityAsUnsupported(capability: string): gdObjectMetadata;
|
||||
markBaseObjectCapabilityAsSupported(capability: string): gdObjectMetadata;
|
||||
isSupportedBaseObjectCapability(capability: string): boolean;
|
||||
setHidden(): gdObjectMetadata;
|
||||
isHidden(): boolean;
|
||||
delete(): void;
|
||||
|
12
GDevelop.js/types/gdobjecttype.js
Normal file
12
GDevelop.js/types/gdobjecttype.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdObjectType {
|
||||
setName(objectType: string): gdObjectType;
|
||||
getName(): string;
|
||||
addCapability(capability: string): gdObjectType;
|
||||
removeCapability(capability: string): void;
|
||||
hasCapability(capability: string): boolean;
|
||||
isBaseObject(): boolean;
|
||||
isMatchedBy(platform: gdPlatform, globalObjectsContainer: gdObjectsContainer, objectsContainer: gdObjectsContainer, objectName: string): boolean;
|
||||
delete(): void;
|
||||
ptr: number;
|
||||
};
|
@@ -5,6 +5,8 @@ declare class gdValueTypeMetadata {
|
||||
setName(name_: string): gdValueTypeMetadata;
|
||||
getExtraInfo(): string;
|
||||
setExtraInfo(extraInfo_: string): gdValueTypeMetadata;
|
||||
getObjectType(): gdObjectType;
|
||||
setObjectType(objectType: gdObjectType): void;
|
||||
isOptional(): boolean;
|
||||
setOptional(optional_: boolean): gdValueTypeMetadata;
|
||||
getDefaultValue(): string;
|
||||
|
@@ -132,6 +132,7 @@ declare class libGDevelop {
|
||||
ParameterMetadataTools: Class<gdParameterMetadataTools>;
|
||||
EventsFunctionTools: Class<gdEventsFunctionTools>;
|
||||
ObjectMetadata: Class<gdObjectMetadata>;
|
||||
ObjectType: Class<gdObjectType>;
|
||||
BehaviorMetadata: Class<gdBehaviorMetadata>;
|
||||
EffectMetadata: Class<gdEffectMetadata>;
|
||||
EventMetadata: Class<gdEventMetadata>;
|
||||
|
@@ -10,7 +10,7 @@ import {
|
||||
|
||||
type Props = {|
|
||||
project: gdProject,
|
||||
objectType: string,
|
||||
objectType: ?gdObjectType,
|
||||
value: string,
|
||||
onChange: string => void,
|
||||
disabled?: boolean,
|
||||
@@ -57,7 +57,10 @@ export default class BehaviorTypeSelector extends React.Component<
|
||||
value={metadata.type}
|
||||
label={metadata.fullName}
|
||||
disabled={
|
||||
metadata.objectType !== '' && metadata.objectType !== objectType
|
||||
objectType
|
||||
? !metadata.objectType.isBaseObject &&
|
||||
metadata.objectType !== objectType.getName()
|
||||
: true
|
||||
}
|
||||
/>
|
||||
))}
|
||||
|
@@ -6,7 +6,7 @@ export type EnumeratedBehaviorMetadata = {|
|
||||
extension: gdPlatformExtension,
|
||||
behaviorMetadata: gdBehaviorMetadata,
|
||||
type: string,
|
||||
objectType: string,
|
||||
objectType: gdObjectType,
|
||||
defaultName: string,
|
||||
fullName: string,
|
||||
description: string,
|
||||
|
@@ -183,8 +183,8 @@ export default function NewBehaviorDialog({
|
||||
const canBehaviorBeUsed = (behaviorMetadata: EnumeratedBehaviorMetadata) => {
|
||||
// An empty object type means the base object, i.e: any object.
|
||||
return (
|
||||
(behaviorMetadata.objectType === '' ||
|
||||
behaviorMetadata.objectType === objectType) &&
|
||||
(behaviorMetadata.objectType.isBaseObject() ||
|
||||
behaviorMetadata.objectType.getName() === objectType) &&
|
||||
!isAmongObjectBehaviors(behaviorMetadata)
|
||||
);
|
||||
};
|
||||
|
@@ -86,7 +86,7 @@ type Props = {|
|
||||
isSceneProperties?: boolean,
|
||||
onPropertiesUpdated?: () => void,
|
||||
onRenameProperty: (oldName: string, newName: string) => void,
|
||||
behaviorObjectType?: string,
|
||||
behaviorObjectType?: gdObjectType,
|
||||
|};
|
||||
|
||||
const validatePropertyName = (
|
||||
@@ -694,7 +694,7 @@ export default function EventsBasedBehaviorPropertiesEditor(props: Props) {
|
||||
<BehaviorTypeSelector
|
||||
project={props.project}
|
||||
objectType={
|
||||
props.behaviorObjectType || ''
|
||||
props.behaviorObjectType
|
||||
}
|
||||
value={
|
||||
property.getExtraInfo().size() ===
|
||||
|
@@ -12,6 +12,7 @@ import DismissableAlertMessage from '../UI/DismissableAlertMessage';
|
||||
import AlertMessage from '../UI/AlertMessage';
|
||||
import { ColumnStackLayout } from '../UI/Layout';
|
||||
import useForceUpdate from '../Utils/UseForceUpdate';
|
||||
import CapabilitiesEditor from '../EventsFunctionsExtensionEditor/EventsFunctionConfigurationEditor/CapabilitiesEditor';
|
||||
|
||||
const gd: libGDevelop = global.gd;
|
||||
|
||||
@@ -91,9 +92,9 @@ export default function EventsBasedBehaviorEditor({
|
||||
<Trans>Object on which this behavior can be used</Trans>
|
||||
}
|
||||
project={project}
|
||||
value={eventsBasedBehavior.getObjectType()}
|
||||
value={eventsBasedBehavior.getObjectType().getName()}
|
||||
onChange={(objectType: string) => {
|
||||
eventsBasedBehavior.setObjectType(objectType);
|
||||
eventsBasedBehavior.getObjectType().setName(objectType);
|
||||
forceUpdate();
|
||||
}}
|
||||
allowedObjectTypes={
|
||||
@@ -109,6 +110,11 @@ export default function EventsBasedBehaviorEditor({
|
||||
] /* More than one type of object are using the behavior. Only "any object" can be used on this behavior */
|
||||
}
|
||||
/>
|
||||
{eventsBasedBehavior.getObjectType().getName().length === 0 && (
|
||||
<CapabilitiesEditor
|
||||
objectType={eventsBasedBehavior.getObjectType()}
|
||||
/>
|
||||
)}
|
||||
{allObjectTypes.length > 1 && (
|
||||
<AlertMessage kind="info">
|
||||
<Trans>
|
||||
|
@@ -0,0 +1,92 @@
|
||||
// @flow
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { I18n } from '@lingui/react';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ColumnStackLayout,
|
||||
LineStackLayout,
|
||||
ResponsiveLineStackLayout,
|
||||
} from '../../UI/Layout';
|
||||
import ListIcon from '../../UI/ListIcon';
|
||||
import Checkbox from '../../UI/Checkbox';
|
||||
import useForceUpdate from '../../Utils/UseForceUpdate';
|
||||
|
||||
type Props = {|
|
||||
objectType: gdObjectType,
|
||||
|};
|
||||
|
||||
export default function CapabilitiesEditor({ objectType }: Props) {
|
||||
const forceUpdate = useForceUpdate();
|
||||
|
||||
const setCapability = React.useCallback(
|
||||
(capability, hasCapability) => {
|
||||
if (hasCapability) {
|
||||
objectType.addCapability(capability);
|
||||
} else {
|
||||
objectType.removeCapability(capability);
|
||||
}
|
||||
forceUpdate();
|
||||
},
|
||||
[forceUpdate, objectType]
|
||||
);
|
||||
|
||||
return (
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<ColumnStackLayout noMargin>
|
||||
<ResponsiveLineStackLayout noMargin>
|
||||
<Checkbox
|
||||
label={
|
||||
<LineStackLayout noMargin alignItems="center">
|
||||
<ListIcon
|
||||
iconSize={24}
|
||||
src={'res/actions/scale24_black.png'}
|
||||
/>
|
||||
<Trans>Resizable</Trans>
|
||||
</LineStackLayout>
|
||||
}
|
||||
checked={objectType.hasCapability('resizable')}
|
||||
onCheck={(e, checked) => setCapability('resizable', checked)}
|
||||
/>
|
||||
<Checkbox
|
||||
label={
|
||||
<LineStackLayout noMargin alignItems="center">
|
||||
<ListIcon
|
||||
iconSize={24}
|
||||
src={'res/actions/scale24_black.png'}
|
||||
/>
|
||||
<Trans>Scalable</Trans>
|
||||
</LineStackLayout>
|
||||
}
|
||||
checked={objectType.hasCapability('scalable')}
|
||||
onCheck={(e, checked) => setCapability('scalable', checked)}
|
||||
/>
|
||||
<Checkbox
|
||||
label={
|
||||
<LineStackLayout noMargin alignItems="center">
|
||||
<ListIcon iconSize={24} src={'res/actions/flipX24.png'} />
|
||||
<Trans>Flippable</Trans>
|
||||
</LineStackLayout>
|
||||
}
|
||||
checked={objectType.hasCapability('flippable')}
|
||||
onCheck={(e, checked) => setCapability('flippable', checked)}
|
||||
/>
|
||||
<Checkbox
|
||||
label={
|
||||
<LineStackLayout noMargin alignItems="center">
|
||||
<ListIcon
|
||||
iconSize={24}
|
||||
src={'res/conditions/animation24.png'}
|
||||
/>
|
||||
<Trans>Animable</Trans>
|
||||
</LineStackLayout>
|
||||
}
|
||||
checked={objectType.hasCapability('animable')}
|
||||
onCheck={(e, checked) => setCapability('animable', checked)}
|
||||
/>
|
||||
</ResponsiveLineStackLayout>
|
||||
</ColumnStackLayout>
|
||||
)}
|
||||
</I18n>
|
||||
);
|
||||
}
|
@@ -478,7 +478,7 @@ export default class EventsFunctionPropertiesEditor extends React.Component<
|
||||
onTypeUpdated={() => {
|
||||
if (onConfigurationUpdated) onConfigurationUpdated();
|
||||
}}
|
||||
getLastObjectParameterObjectType={() => ''}
|
||||
getLastObjectParameterObjectType={() => null}
|
||||
/>
|
||||
)}
|
||||
{eventsFunction.isAsync() && (
|
||||
|
@@ -11,6 +11,7 @@ import BehaviorTypeSelector from '../../BehaviorTypeSelector';
|
||||
import { ColumnStackLayout, ResponsiveLineStackLayout } from '../../UI/Layout';
|
||||
import StringArrayEditor from '../../StringArrayEditor';
|
||||
import useForceUpdate from '../../Utils/UseForceUpdate';
|
||||
import CapabilitiesEditor from './CapabilitiesEditor';
|
||||
|
||||
type Props = {|
|
||||
project: gdProject,
|
||||
@@ -19,7 +20,7 @@ type Props = {|
|
||||
disabled?: boolean,
|
||||
isTypeSelectorShown: boolean,
|
||||
isExpressionType?: boolean,
|
||||
getLastObjectParameterObjectType: () => string,
|
||||
getLastObjectParameterObjectType: () => ?gdObjectType,
|
||||
|};
|
||||
|
||||
const getExtraInfoArray = (type: gdValueTypeMetadata) => {
|
||||
@@ -125,9 +126,9 @@ export default function ValueTypeEditor({
|
||||
{valueTypeMetadata.isObject() && (
|
||||
<ObjectTypeSelector
|
||||
project={project}
|
||||
value={valueTypeMetadata.getExtraInfo()}
|
||||
value={valueTypeMetadata.getObjectType().getName()}
|
||||
onChange={(value: string) => {
|
||||
valueTypeMetadata.setExtraInfo(value);
|
||||
valueTypeMetadata.getObjectType().setName(value);
|
||||
forceUpdate();
|
||||
onTypeUpdated();
|
||||
}}
|
||||
@@ -232,6 +233,12 @@ export default function ValueTypeEditor({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{valueTypeMetadata.isObject() &&
|
||||
valueTypeMetadata.getObjectType().getName().length === 0 && (
|
||||
<CapabilitiesEditor
|
||||
objectType={valueTypeMetadata.getObjectType()}
|
||||
/>
|
||||
)}
|
||||
</ColumnStackLayout>
|
||||
)}
|
||||
</I18n>
|
||||
|
@@ -164,6 +164,7 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
// Initialize this "context" of objects with the function
|
||||
// (as done during code generation).
|
||||
if (eventsBasedBehavior) {
|
||||
console.trace();
|
||||
gd.EventsFunctionTools.behaviorEventsFunctionToObjectsContainer(
|
||||
project,
|
||||
eventsBasedBehavior,
|
||||
|
@@ -13,6 +13,7 @@ type EnumeratedProperty = {|
|
||||
isHidden: boolean,
|
||||
|};
|
||||
|
||||
// TODO Remove this function as it seems to be a dead code.
|
||||
/**
|
||||
* Transform a gdNamedPropertyDescriptorsList into a JS object.
|
||||
* **Don't use this** unless you explicitly need to deal with JS objects.
|
||||
|
@@ -85,14 +85,17 @@ export const setupFunctionFromEvents = ({
|
||||
const newParameter = new gd.ParameterMetadata();
|
||||
newParameter.setType('objectList');
|
||||
newParameter.setName(objectName);
|
||||
newParameter.setExtraInfo(
|
||||
gd.getTypeOfObject(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectName,
|
||||
true
|
||||
)
|
||||
);
|
||||
newParameter
|
||||
.getValueTypeMetadata()
|
||||
.getObjectType()
|
||||
.setName(
|
||||
gd.getTypeOfObject(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectName,
|
||||
true
|
||||
)
|
||||
);
|
||||
parameters.push_back(newParameter);
|
||||
|
||||
const behaviorNames: Array<string> = eventsContext
|
||||
|
@@ -292,23 +292,30 @@ const Instruction = (props: Props) => {
|
||||
expressionValidator.getAllErrors().size() === 0;
|
||||
expressionValidator.delete();
|
||||
} else if (gd.ParameterMetadata.isObject(parameterType)) {
|
||||
const objectType = parameterMetadata
|
||||
.getValueTypeMetadata()
|
||||
.getObjectType();
|
||||
|
||||
const objectOrGroupName = instruction
|
||||
.getParameter(parameterIndex)
|
||||
.getPlainString();
|
||||
expressionIsValid =
|
||||
// Object exists.
|
||||
(globalObjectsContainer.hasObjectNamed(objectOrGroupName) ||
|
||||
objectsContainer.hasObjectNamed(objectOrGroupName) ||
|
||||
globalObjectsContainer
|
||||
.getObjectGroups()
|
||||
.has(objectOrGroupName) ||
|
||||
objectsContainer.getObjectGroups().has(objectOrGroupName)) &&
|
||||
(!parameterMetadata.getExtraInfo() ||
|
||||
// Object type matches.
|
||||
(objectType.isBaseObject() ||
|
||||
gd.getTypeOfObject(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectOrGroupName,
|
||||
/*searchInGroups=*/ true
|
||||
) === parameterMetadata.getExtraInfo());
|
||||
) === objectType.getName());
|
||||
// TODO Check that object capability matches
|
||||
} else if (
|
||||
gd.ParameterMetadata.isExpression('resource', parameterType)
|
||||
) {
|
||||
|
@@ -163,6 +163,7 @@ export default class InstructionOrObjectSelector extends React.PureComponent<
|
||||
this._scrollView.current.scrollTo(this._selectedItem.current);
|
||||
}
|
||||
const { allObjectsList, allGroupsList } = enumerateObjectsAndGroups(
|
||||
this.props.project.getCurrentPlatform(),
|
||||
this.props.globalObjectsContainer,
|
||||
this.props.objectsContainer
|
||||
);
|
||||
@@ -292,6 +293,7 @@ export default class InstructionOrObjectSelector extends React.PureComponent<
|
||||
const isOutsideLayout = globalObjectsContainer !== project;
|
||||
|
||||
const { allObjectsList, allGroupsList } = enumerateObjectsAndGroups(
|
||||
project.getCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer
|
||||
);
|
||||
|
@@ -42,7 +42,7 @@ export default React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
|
||||
: undefined;
|
||||
|
||||
const allowedObjectType = parameterMetadata
|
||||
? parameterMetadata.getExtraInfo()
|
||||
? parameterMetadata.getValueTypeMetadata().getObjectType()
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
@@ -53,16 +53,9 @@ export default React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
|
||||
onChange={props.onChange}
|
||||
onRequestClose={props.onRequestClose}
|
||||
onApply={props.onApply}
|
||||
// Some instructions apply to all objects BUT not some objects
|
||||
// lacking a specific capability usually offered by all objects.
|
||||
allowedObjectType={allowedObjectType}
|
||||
requiredObjectCapability={
|
||||
// Some instructions apply to all objects BUT not some objects
|
||||
// lacking a specific capability usually offered by all objects.
|
||||
props.instructionMetadata
|
||||
? props.instructionMetadata.getRequiredBaseObjectCapability()
|
||||
: props.expressionMetadata
|
||||
? props.expressionMetadata.getRequiredBaseObjectCapability()
|
||||
: undefined
|
||||
}
|
||||
globalObjectsContainer={props.globalObjectsContainer}
|
||||
objectsContainer={props.objectsContainer}
|
||||
floatingLabelText={description}
|
||||
@@ -74,7 +67,7 @@ export default React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
|
||||
}
|
||||
fullWidth
|
||||
errorTextIfInvalid={
|
||||
allowedObjectType ? (
|
||||
allowedObjectType && allowedObjectType.getName() ? (
|
||||
<Trans>The object does not exist or can't be used here.</Trans>
|
||||
) : (
|
||||
<Trans>Enter the name of an object.</Trans>
|
||||
|
@@ -62,16 +62,19 @@ export const getLastObjectParameterValue = ({
|
||||
export const getLastObjectParameterObjectType = (
|
||||
parameters: gdVectorParameterMetadata,
|
||||
parameterIndex: number
|
||||
) => {
|
||||
): ?gdObjectType => {
|
||||
const objectParameterIndex = gd.ParameterMetadataTools.getObjectParameterIndexFor(
|
||||
parameters,
|
||||
parameterIndex
|
||||
);
|
||||
if (objectParameterIndex < 0 || objectParameterIndex >= parameters.size()) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
return parameters.at(objectParameterIndex).getExtraInfo();
|
||||
return parameters
|
||||
.at(objectParameterIndex)
|
||||
.getValueTypeMetadata()
|
||||
.getObjectType();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -236,9 +236,11 @@ const getAutocompletionsForObject = function(
|
||||
gd,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
project,
|
||||
} = expressionAutocompletionContext;
|
||||
|
||||
const { allObjectsList, allGroupsList } = enumerateObjectsAndGroups(
|
||||
project.getCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer
|
||||
);
|
||||
|
@@ -25,14 +25,54 @@ const enumerateExpressionMetadataMap = (
|
||||
|
||||
if (
|
||||
scope.objectMetadata &&
|
||||
scope.objectMetadata.isUnsupportedBaseObjectCapability(
|
||||
!scope.objectMetadata.isSupportedBaseObjectCapability(
|
||||
exprMetadata.getRequiredBaseObjectCapability()
|
||||
)
|
||||
)
|
||||
return null; // Skip expressions not supported by the object.
|
||||
|
||||
var parameters = [];
|
||||
for (var i = 0; i < exprMetadata.getParametersCount(); i++) {
|
||||
let parameters = [];
|
||||
for (let i = 0; i < exprMetadata.getParametersCount(); i++) {
|
||||
if (scope.objectMetadata && i === 0) continue;
|
||||
if (scope.behaviorMetadata && i <= 1) continue; //Skip object and behavior parameters
|
||||
if (exprMetadata.getParameter(i).isCodeOnly()) continue;
|
||||
|
||||
parameters.push(exprMetadata.getParameter(i));
|
||||
}
|
||||
|
||||
const groupName = exprMetadata.getGroup();
|
||||
|
||||
return {
|
||||
type: expressionType,
|
||||
name: expressionType,
|
||||
displayedName: exprMetadata.getFullName(),
|
||||
fullGroupName: [prefix, groupName].filter(Boolean).join(GROUP_DELIMITER),
|
||||
iconFilename: exprMetadata.getSmallIconFilename(),
|
||||
metadata: exprMetadata,
|
||||
parameters: parameters,
|
||||
scope,
|
||||
isPrivate: exprMetadata.isPrivate(),
|
||||
isRelevantForLayoutEvents: exprMetadata.isRelevantForLayoutEvents(),
|
||||
isRelevantForFunctionEvents: exprMetadata.isRelevantForFunctionEvents(),
|
||||
isRelevantForAsynchronousFunctionEvents: exprMetadata.isRelevantForAsynchronousFunctionEvents(),
|
||||
isRelevantForCustomObjectEvents: exprMetadata.isRelevantForCustomObjectEvents(),
|
||||
};
|
||||
}).filter(Boolean);
|
||||
};
|
||||
|
||||
const enumerateExpressionMetadataMapWithAnyCapabilities = (
|
||||
prefix: string,
|
||||
expressions: gdMapStringExpressionMetadata,
|
||||
scope: InstructionOrExpressionScope
|
||||
): Array<EnumeratedExpressionMetadata> => {
|
||||
return mapVector(expressions.keys(), expressionType => {
|
||||
const exprMetadata = expressions.get(expressionType);
|
||||
if (!exprMetadata.isShown()) {
|
||||
return null; // Skip hidden expressions
|
||||
}
|
||||
|
||||
let parameters = [];
|
||||
for (let i = 0; i < exprMetadata.getParametersCount(); i++) {
|
||||
if (scope.objectMetadata && i === 0) continue;
|
||||
if (scope.behaviorMetadata && i <= 1) continue; //Skip object and behavior parameters
|
||||
if (exprMetadata.getParameter(i).isCodeOnly()) continue;
|
||||
@@ -109,13 +149,13 @@ export const enumerateObjectExpressions = (
|
||||
const scope = { extension, objectMetadata };
|
||||
|
||||
let objectsExpressions = [
|
||||
...(!shouldOnlyBeNumberType(type)
|
||||
? enumerateExpressionMetadataMap(
|
||||
...(shouldOnlyBeNumberType(type)
|
||||
? []
|
||||
: enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllStrExpressionsForObject(objectType),
|
||||
scope
|
||||
)
|
||||
: []),
|
||||
)),
|
||||
...enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllExpressionsForObject(objectType),
|
||||
@@ -133,13 +173,13 @@ export const enumerateObjectExpressions = (
|
||||
|
||||
objectsExpressions = [
|
||||
...objectsExpressions,
|
||||
...(!shouldOnlyBeNumberType(type)
|
||||
? enumerateExpressionMetadataMap(
|
||||
...(shouldOnlyBeNumberType(type)
|
||||
? []
|
||||
: enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllStrExpressionsForObject(baseObjectType),
|
||||
scope
|
||||
)
|
||||
: []),
|
||||
)),
|
||||
...enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllExpressionsForObject(baseObjectType),
|
||||
@@ -165,13 +205,13 @@ export const enumerateBehaviorExpressions = (
|
||||
const scope = { extension, behaviorMetadata };
|
||||
|
||||
return [
|
||||
...(!shouldOnlyBeNumberType(type)
|
||||
? enumerateExpressionMetadataMap(
|
||||
...(shouldOnlyBeNumberType(type)
|
||||
? []
|
||||
: enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllStrExpressionsForBehavior(behaviorType),
|
||||
scope
|
||||
)
|
||||
: []),
|
||||
)),
|
||||
...enumerateExpressionMetadataMap(
|
||||
'',
|
||||
extension.getAllExpressionsForBehavior(behaviorType),
|
||||
@@ -202,7 +242,7 @@ export const enumerateAllExpressions = (
|
||||
if (!shouldOnlyBeNumberType(type))
|
||||
objectsExpressions.push.apply(
|
||||
objectsExpressions,
|
||||
enumerateExpressionMetadataMap(
|
||||
enumerateExpressionMetadataMapWithAnyCapabilities(
|
||||
prefix,
|
||||
extension.getAllStrExpressionsForObject(objectType),
|
||||
scope
|
||||
@@ -210,7 +250,7 @@ export const enumerateAllExpressions = (
|
||||
);
|
||||
objectsExpressions.push.apply(
|
||||
objectsExpressions,
|
||||
enumerateExpressionMetadataMap(
|
||||
enumerateExpressionMetadataMapWithAnyCapabilities(
|
||||
prefix,
|
||||
extension.getAllExpressionsForObject(objectType),
|
||||
scope
|
||||
|
@@ -67,6 +67,9 @@ describe('EnumerateExpressions', () => {
|
||||
expect(filterExpressions(spriteObjectExpressions, 'PointX')).toHaveLength(
|
||||
1
|
||||
);
|
||||
expect(
|
||||
filterExpressions(spriteObjectExpressions, 'AnimationSpeedScale')
|
||||
).toHaveLength(1);
|
||||
expect(
|
||||
filterExpressions(spriteObjectExpressions, 'AnimationName')
|
||||
).toHaveLength(1);
|
||||
|
@@ -220,7 +220,7 @@ const enumerateExtensionInstructions = (
|
||||
|
||||
if (
|
||||
scope.objectMetadata &&
|
||||
scope.objectMetadata.isUnsupportedBaseObjectCapability(
|
||||
!scope.objectMetadata.isSupportedBaseObjectCapability(
|
||||
instrMetadata.getRequiredBaseObjectCapability()
|
||||
)
|
||||
)
|
||||
@@ -234,6 +234,29 @@ const enumerateExtensionInstructions = (
|
||||
return allInstructions;
|
||||
};
|
||||
|
||||
const enumerateExtensionInstructionsWithAnyCapabilities = (
|
||||
prefix: string,
|
||||
instructions: gdMapStringInstructionMetadata,
|
||||
scope: InstructionOrExpressionScope
|
||||
): Array<EnumeratedInstructionMetadata> => {
|
||||
//Get the map containing the metadata of the instructions provided by the extension...
|
||||
const instructionsTypes = instructions.keys();
|
||||
const allInstructions = [];
|
||||
|
||||
//... and add each instruction
|
||||
for (let j = 0; j < instructionsTypes.size(); ++j) {
|
||||
const type = instructionsTypes.at(j);
|
||||
const instrMetadata = instructions.get(type);
|
||||
if (instrMetadata.isHidden()) continue;
|
||||
|
||||
allInstructions.push(
|
||||
enumerateInstruction(prefix, type, instrMetadata, scope)
|
||||
);
|
||||
}
|
||||
|
||||
return allInstructions;
|
||||
};
|
||||
|
||||
/**
|
||||
* List all the instructions available.
|
||||
*/
|
||||
@@ -277,7 +300,7 @@ export const enumerateAllInstructions = (
|
||||
const scope = { extension, objectMetadata };
|
||||
allInstructions = [
|
||||
...allInstructions,
|
||||
...enumerateExtensionInstructions(
|
||||
...enumerateExtensionInstructionsWithAnyCapabilities(
|
||||
prefix,
|
||||
isCondition
|
||||
? extension.getAllConditionsForObject(objectType)
|
||||
|
@@ -13,24 +13,43 @@ describe('EnumerateInstructions', () => {
|
||||
const instructions = enumerateAllInstructions(true);
|
||||
|
||||
// Test for the proper presence of a few conditions
|
||||
expect(instructions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
displayedName: 'Animation finished',
|
||||
fullGroupName: 'General/Sprite/Animations and images',
|
||||
type: 'AnimationEnded2',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
displayedName: 'Trigger once while true',
|
||||
fullGroupName: 'Advanced/Events and control flow',
|
||||
type: 'BuiltinCommonInstructions::Once',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
displayedName: 'The cursor/touch is on an object',
|
||||
fullGroupName: 'General/Objects/Mouse and touch',
|
||||
type: 'SourisSurObjet',
|
||||
}),
|
||||
])
|
||||
expect(
|
||||
instructions.find(instruction => instruction.type === 'HasAnimationEnded')
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
displayedName: 'Animation finished',
|
||||
fullGroupName: 'General/Objects/Animations and images',
|
||||
type: 'HasAnimationEnded',
|
||||
})
|
||||
);
|
||||
expect(
|
||||
instructions.find(instruction => instruction.type === 'Sprite')
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
displayedName: 'Current frame',
|
||||
fullGroupName: 'General/Sprite/Animations and images',
|
||||
type: 'Sprite',
|
||||
})
|
||||
);
|
||||
expect(
|
||||
instructions.find(
|
||||
instruction => instruction.type === 'BuiltinCommonInstructions::Once'
|
||||
)
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
displayedName: 'Trigger once while true',
|
||||
fullGroupName: 'Advanced/Events and control flow',
|
||||
type: 'BuiltinCommonInstructions::Once',
|
||||
})
|
||||
);
|
||||
expect(
|
||||
instructions.find(instruction => instruction.type === 'SourisSurObjet')
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
displayedName: 'The cursor/touch is on an object',
|
||||
fullGroupName: 'General/Objects/Mouse and touch',
|
||||
type: 'SourisSurObjet',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -106,7 +125,7 @@ describe('EnumerateInstructions', () => {
|
||||
expect(getObjectParameterIndex(triggerOnce.metadata)).toBe(-1);
|
||||
|
||||
const spriteAnimationEnded = conditions.filter(
|
||||
({ type }) => type === 'AnimationEnded2'
|
||||
({ type }) => type === 'HasAnimationEnded'
|
||||
)[0];
|
||||
expect(spriteAnimationEnded).not.toBeUndefined();
|
||||
expect(getObjectParameterIndex(spriteAnimationEnded.metadata)).toBe(0);
|
||||
@@ -129,7 +148,7 @@ describe('EnumerateInstructions', () => {
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
displayedName: 'Animation finished',
|
||||
type: 'AnimationEnded2',
|
||||
type: 'HasAnimationEnded',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
displayedName: 'The cursor/touch is on an object',
|
||||
|
@@ -73,9 +73,12 @@ describe('setupInstructionParameters', () => {
|
||||
);
|
||||
|
||||
// Check that parameters were created and the object name set
|
||||
expect(instruction.getParametersCount()).toBe(2);
|
||||
expect(instruction.getParametersCount()).toBe(3);
|
||||
expect(instruction.getParameter(0).getPlainString()).toBe(objectName);
|
||||
// Operator
|
||||
expect(instruction.getParameter(1).getPlainString()).toBe('');
|
||||
// Operand
|
||||
expect(instruction.getParameter(2).getPlainString()).toBe('');
|
||||
});
|
||||
|
||||
it('sets the proper parameters for a behavior', () => {
|
||||
|
@@ -185,12 +185,12 @@ const InnerDialog = (props: InnerDialogProps) => {
|
||||
label: <Trans>Variables</Trans>,
|
||||
value: 'variables',
|
||||
},
|
||||
objectMetadata.isUnsupportedBaseObjectCapability('effect')
|
||||
? null
|
||||
: {
|
||||
objectMetadata.isSupportedBaseObjectCapability('effect')
|
||||
? {
|
||||
label: <Trans>Effects</Trans>,
|
||||
value: 'effects',
|
||||
},
|
||||
}
|
||||
: null,
|
||||
].filter(Boolean)}
|
||||
/>
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ import { mapFor } from '../Utils/MapFor';
|
||||
import flatten from 'lodash/flatten';
|
||||
import { type SelectedTags, hasStringAllTags } from '../Utils/TagsHelper';
|
||||
import { type RequiredExtension } from '../AssetStore/InstallAsset';
|
||||
|
||||
const gd: libGDevelop = global.gd;
|
||||
|
||||
export type EnumeratedObjectMetadata = {|
|
||||
@@ -219,30 +220,35 @@ export const enumerateGroups = (
|
||||
};
|
||||
|
||||
export const enumerateObjectsAndGroups = (
|
||||
platform: ?gdPlatform,
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
type: ?string = undefined
|
||||
objectType: ?gdObjectType = undefined,
|
||||
requiredObjectCapabilities: Array<string> = []
|
||||
) => {
|
||||
const filterObject = (object: gdObject): boolean => {
|
||||
return (
|
||||
!type ||
|
||||
gd.getTypeOfObject(
|
||||
!objectType ||
|
||||
!platform ||
|
||||
objectType.isMatchedBy(
|
||||
platform,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
object.getName(),
|
||||
false
|
||||
) === type
|
||||
object.getName()
|
||||
)
|
||||
);
|
||||
};
|
||||
const filterGroup = (group: gdObjectGroup): boolean => {
|
||||
return (
|
||||
!type ||
|
||||
!objectType ||
|
||||
objectType.isBaseObject() ||
|
||||
gd.getTypeOfObject(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
group.getName(),
|
||||
true
|
||||
) === type
|
||||
) === objectType.getName()
|
||||
// TODO Check capabilities intersection of groups
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -9,26 +9,24 @@ import SemiControlledAutoComplete, {
|
||||
type SemiControlledAutoCompleteInterface,
|
||||
} from '../UI/SemiControlledAutoComplete';
|
||||
import ListIcon from '../UI/ListIcon';
|
||||
import getObjectByName from '../Utils/GetObjectByName';
|
||||
import ObjectsRenderingService from '../ObjectsRendering/ObjectsRenderingService';
|
||||
import { type MessageDescriptor } from '../Utils/i18n/MessageDescriptor.flow';
|
||||
import { useShouldAutofocusInput } from '../UI/Reponsive/ScreenTypeMeasurer';
|
||||
import SelectField from '../UI/SelectField';
|
||||
import SelectOption from '../UI/SelectOption';
|
||||
const gd: libGDevelop = global.gd;
|
||||
|
||||
type Props = {|
|
||||
project: ?gdProject,
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
|
||||
/** If specified, only this object type should be allowed to be selected. */
|
||||
allowedObjectType?: ?string,
|
||||
/**
|
||||
* If specified, an object without this required capability won't be selectable.
|
||||
* If specified, only this object type should be allowed to be selected.
|
||||
*
|
||||
* An object without this required capability won't be selectable.
|
||||
* Note that this does not work with groups - which are assumed to have all capabilities.
|
||||
*/
|
||||
requiredObjectCapability?: ?string,
|
||||
allowedObjectType?: gdObjectType,
|
||||
|
||||
noGroups?: boolean,
|
||||
|
||||
@@ -66,10 +64,11 @@ const getObjectsAndGroupsDataSource = ({
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
noGroups: ?boolean,
|
||||
allowedObjectType: ?string,
|
||||
allowedObjectType: ?gdObjectType,
|
||||
excludedObjectOrGroupNames: ?Array<string>,
|
||||
|}): DataSource => {
|
||||
const list = enumerateObjectsAndGroups(
|
||||
project && project.getCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
allowedObjectType || undefined
|
||||
@@ -113,43 +112,6 @@ const getObjectsAndGroupsDataSource = ({
|
||||
: fullList;
|
||||
};
|
||||
|
||||
const checkHasRequiredCapability = ({
|
||||
project,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
requiredObjectCapability,
|
||||
objectName,
|
||||
}: {|
|
||||
project: ?gdProject,
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
requiredObjectCapability: ?string,
|
||||
objectName: string,
|
||||
|}) => {
|
||||
if (!requiredObjectCapability) return true;
|
||||
if (!project) return true;
|
||||
|
||||
const object = getObjectByName(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectName
|
||||
);
|
||||
if (!object) {
|
||||
// Either the object does not exist or it's a group - not a problem because:
|
||||
// - if the object does not exist, we can't know its capabilities, we assume it has all.
|
||||
// - a group is assumed to have all the capabilities.
|
||||
return true;
|
||||
}
|
||||
|
||||
const objectMetadata = gd.MetadataProvider.getObjectMetadata(
|
||||
project.getCurrentPlatform(),
|
||||
object.getType()
|
||||
);
|
||||
return !objectMetadata.isUnsupportedBaseObjectCapability(
|
||||
requiredObjectCapability
|
||||
);
|
||||
};
|
||||
|
||||
export type ObjectSelectorInterface = {| focus: FieldFocusFunction |};
|
||||
|
||||
const ObjectSelector = React.forwardRef<Props, ObjectSelectorInterface>(
|
||||
@@ -171,7 +133,6 @@ const ObjectSelector = React.forwardRef<Props, ObjectSelectorInterface>(
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
allowedObjectType,
|
||||
requiredObjectCapability,
|
||||
noGroups,
|
||||
errorTextIfInvalid,
|
||||
margin,
|
||||
@@ -197,13 +158,15 @@ const ObjectSelector = React.forwardRef<Props, ObjectSelectorInterface>(
|
||||
choice => choice.text !== undefined && value === choice.text
|
||||
).length !== 0;
|
||||
|
||||
const hasObjectWithRequiredCapability = checkHasRequiredCapability({
|
||||
project,
|
||||
requiredObjectCapability,
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
objectName: value,
|
||||
});
|
||||
const hasObjectWithRequiredCapability =
|
||||
!project ||
|
||||
!allowedObjectType ||
|
||||
allowedObjectType.isMatchedBy(
|
||||
project.getCurrentPlatform(),
|
||||
globalObjectsContainer,
|
||||
objectsContainer,
|
||||
value
|
||||
);
|
||||
|
||||
const errorText = !hasObjectWithRequiredCapability ? (
|
||||
<Trans>This object exists, but can't be used here.</Trans>
|
||||
|
@@ -739,9 +739,7 @@ const ObjectsList = React.forwardRef<Props, ObjectsListInterface>(
|
||||
{
|
||||
label: i18n._(t`Edit effects`),
|
||||
click: () => onEditObject(object, 'effects'),
|
||||
enabled: !objectMetadata.isUnsupportedBaseObjectCapability(
|
||||
'effect'
|
||||
),
|
||||
enabled: objectMetadata.isSupportedBaseObjectCapability('effect'),
|
||||
},
|
||||
eventsFunctionsExtensionWriter &&
|
||||
project.hasEventsBasedObject(object.getType())
|
||||
|
@@ -43,7 +43,7 @@ type Props = {|
|
||||
|};
|
||||
|
||||
/**
|
||||
* A text field based on Material-UI text field.
|
||||
* A checkbox based on Material-UI checkbox.
|
||||
*/
|
||||
const Checkbox = (props: Props) => {
|
||||
const { onCheck } = props;
|
||||
|
@@ -228,7 +228,8 @@ export const makeTestExtensions = (gd: libGDevelop) => {
|
||||
fakeBehavior,
|
||||
new gd.BehaviorsSharedData()
|
||||
)
|
||||
.setObjectType('TextObject::Text');
|
||||
.getObjectType()
|
||||
.setName('TextObject::Text');
|
||||
|
||||
platform.addNewExtension(extension);
|
||||
extension.delete(); // Release the extension as it was copied inside gd.JsPlatform
|
||||
@@ -300,7 +301,7 @@ export const makeTestExtensions = (gd: libGDevelop) => {
|
||||
'',
|
||||
fakeObject
|
||||
)
|
||||
.addUnsupportedBaseObjectCapability('effect');
|
||||
.markBaseObjectCapabilityAsUnsupported('effect');
|
||||
|
||||
platform.addNewExtension(extension);
|
||||
extension.delete(); // Release the extension as it was copied inside gd.JsPlatform
|
||||
|
@@ -44,6 +44,7 @@ export type TestProject = {|
|
||||
colorRelationalOperatorParameterMetadata: gdParameterMetadata,
|
||||
unknownRelationalOperatorParameterMetadata: gdParameterMetadata,
|
||||
emptyObjectsContainer: gdObjectsContainer,
|
||||
textObjectType: gdObjectType
|
||||
|};
|
||||
*/
|
||||
|
||||
@@ -687,7 +688,7 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
testEventsBasedBehavior.setDescription(
|
||||
'This is a test events based behavior.\n\nIt does a lot of cool things. It applies to SpriteObject only.'
|
||||
);
|
||||
testEventsBasedBehavior.setObjectType('Sprite');
|
||||
testEventsBasedBehavior.getObjectType().setName('Sprite');
|
||||
|
||||
// Add some properties
|
||||
testEventsBasedBehavior
|
||||
@@ -820,6 +821,9 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
'whatever-this-is-not-recognised'
|
||||
);
|
||||
|
||||
const textObjectType = new gd.ObjectType();
|
||||
textObjectType.setName('TextObject::Text');
|
||||
|
||||
return {
|
||||
project,
|
||||
shapePainterObjectConfiguration: shapePainterObject.getConfiguration(),
|
||||
@@ -863,5 +867,6 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
colorRelationalOperatorParameterMetadata,
|
||||
unknownRelationalOperatorParameterMetadata,
|
||||
emptyObjectsContainer: new gd.ObjectsContainer(),
|
||||
textObjectType,
|
||||
};
|
||||
};
|
||||
|
@@ -2617,7 +2617,7 @@ storiesOf('BehaviorTypeSelector', module)
|
||||
project={testProject.project}
|
||||
value={''}
|
||||
onChange={action('change')}
|
||||
objectType=""
|
||||
objectType={null}
|
||||
/>
|
||||
))
|
||||
.add('with a non existing behavior selected, for a base object', () => (
|
||||
@@ -2625,7 +2625,7 @@ storiesOf('BehaviorTypeSelector', module)
|
||||
project={testProject.project}
|
||||
value={'MyCustomExtension::BehaviorThatIsNotYetLoaded'}
|
||||
onChange={action('change')}
|
||||
objectType=""
|
||||
objectType={null}
|
||||
/>
|
||||
))
|
||||
.add('default, for a text object', () => (
|
||||
@@ -2633,7 +2633,7 @@ storiesOf('BehaviorTypeSelector', module)
|
||||
project={testProject.project}
|
||||
value={''}
|
||||
onChange={action('change')}
|
||||
objectType="TextObject::Text"
|
||||
objectType={testProject.textObjectType}
|
||||
/>
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user