mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
182 Commits
v5.0.0-bet
...
v5.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a23a8904f6 | ||
![]() |
1311a8b4c5 | ||
![]() |
e8a1af0ef1 | ||
![]() |
bc1095759e | ||
![]() |
125e76bd20 | ||
![]() |
758afea620 | ||
![]() |
cf63960282 | ||
![]() |
deffe37013 | ||
![]() |
0f30c2d614 | ||
![]() |
9d015b9cd1 | ||
![]() |
fc5905b7f4 | ||
![]() |
18be9f5450 | ||
![]() |
31c8d04def | ||
![]() |
77eff757cd | ||
![]() |
c2fedf23b9 | ||
![]() |
6870a53aed | ||
![]() |
92015e8182 | ||
![]() |
2704c654d8 | ||
![]() |
e1242e5397 | ||
![]() |
51d306f98f | ||
![]() |
689904bda5 | ||
![]() |
5b53ffe015 | ||
![]() |
eb2da55504 | ||
![]() |
38cd264bf8 | ||
![]() |
c179730dc4 | ||
![]() |
8109621920 | ||
![]() |
bd0aaa73c7 | ||
![]() |
6d21753288 | ||
![]() |
6993a2f2f9 | ||
![]() |
8e538425c4 | ||
![]() |
3e7e45da41 | ||
![]() |
15eec269c3 | ||
![]() |
91072f7328 | ||
![]() |
39334c6e55 | ||
![]() |
5f1a7bd72d | ||
![]() |
9ed2665542 | ||
![]() |
ee338f6657 | ||
![]() |
8f876c51dc | ||
![]() |
23a409b80d | ||
![]() |
4e0f9ebec4 | ||
![]() |
2ca593ba2b | ||
![]() |
c63bb625e5 | ||
![]() |
c57e172299 | ||
![]() |
a9cdeae475 | ||
![]() |
931b945b21 | ||
![]() |
e2f21b8d3c | ||
![]() |
6ab2cb1384 | ||
![]() |
f8e0288a44 | ||
![]() |
ff48589661 | ||
![]() |
50bdca3c44 | ||
![]() |
00eda8ced8 | ||
![]() |
7ca5ef6e6c | ||
![]() |
ff8f7e5877 | ||
![]() |
c8739e3c24 | ||
![]() |
69eacedc2b | ||
![]() |
e5f229e3f7 | ||
![]() |
74e43f2b43 | ||
![]() |
a04f641415 | ||
![]() |
2e5a9e2cfa | ||
![]() |
cd4bfd767a | ||
![]() |
d9135636fe | ||
![]() |
88e08ab7d8 | ||
![]() |
6a3af0d57a | ||
![]() |
95b4091085 | ||
![]() |
5556766059 | ||
![]() |
1332582a03 | ||
![]() |
77177063d8 | ||
![]() |
ed7ddd2b67 | ||
![]() |
990f59d093 | ||
![]() |
6326c185f4 | ||
![]() |
9c6972ec0a | ||
![]() |
814577edff | ||
![]() |
a8ea4b8fe7 | ||
![]() |
494666e690 | ||
![]() |
e5a24e3e32 | ||
![]() |
68771be104 | ||
![]() |
9d2bff9442 | ||
![]() |
6a08fb9a86 | ||
![]() |
c96c3ff1a2 | ||
![]() |
788d557f0e | ||
![]() |
4f17d526ab | ||
![]() |
bc27364bb8 | ||
![]() |
1fd719fb41 | ||
![]() |
f7e93c2a13 | ||
![]() |
c268b19264 | ||
![]() |
6baef705eb | ||
![]() |
fe8295a6e3 | ||
![]() |
de616de3fc | ||
![]() |
9e725c58b5 | ||
![]() |
37028de2f4 | ||
![]() |
509dd8ff10 | ||
![]() |
4c38bcffa8 | ||
![]() |
90c2cc7e44 | ||
![]() |
bd6e4206a2 | ||
![]() |
9cf5755a90 | ||
![]() |
11c29f444e | ||
![]() |
11475b9cf3 | ||
![]() |
e5476f5712 | ||
![]() |
e7457c7564 | ||
![]() |
fd015f9ee4 | ||
![]() |
394eb9488c | ||
![]() |
dd771ea3d1 | ||
![]() |
140c7f52cb | ||
![]() |
cb14f7cfa5 | ||
![]() |
93e8dd4002 | ||
![]() |
b91a2da81c | ||
![]() |
d6f99c5841 | ||
![]() |
d2dc352c2a | ||
![]() |
f3dc69ea68 | ||
![]() |
f4522291fc | ||
![]() |
60d7901054 | ||
![]() |
b19e71fe85 | ||
![]() |
2b9524651f | ||
![]() |
680aa3fa6b | ||
![]() |
25f8bddfcf | ||
![]() |
a02e5952a3 | ||
![]() |
b382b99ece | ||
![]() |
f6b16da334 | ||
![]() |
130912f3c8 | ||
![]() |
49418351d4 | ||
![]() |
cbad5de106 | ||
![]() |
1e33a1c6f0 | ||
![]() |
997c251a07 | ||
![]() |
a14e854f4e | ||
![]() |
b0af6c88fe | ||
![]() |
08b1f3b5fe | ||
![]() |
b392192def | ||
![]() |
1759e85b84 | ||
![]() |
a3d223ae39 | ||
![]() |
d2fa8c43cf | ||
![]() |
dc0dcb673f | ||
![]() |
fa2c1bed79 | ||
![]() |
8489cc3e70 | ||
![]() |
0150e197b0 | ||
![]() |
f5a6ca0246 | ||
![]() |
a53b63680c | ||
![]() |
2489a26a08 | ||
![]() |
2346e41936 | ||
![]() |
0b5980d0b6 | ||
![]() |
99fc0b7b46 | ||
![]() |
fb45454951 | ||
![]() |
9abfa741ce | ||
![]() |
980081516a | ||
![]() |
f1bed6ead9 | ||
![]() |
e139c0218b | ||
![]() |
ffd0cf8808 | ||
![]() |
ae87d3298e | ||
![]() |
6b7a9dd39c | ||
![]() |
5a3686d6a3 | ||
![]() |
bfef000cc6 | ||
![]() |
c000a735bb | ||
![]() |
21e034863e | ||
![]() |
72b883654b | ||
![]() |
b1152b9059 | ||
![]() |
7d48b85d42 | ||
![]() |
fb8926dd66 | ||
![]() |
9ce195e371 | ||
![]() |
f88f8b60d6 | ||
![]() |
4eb8ddfba6 | ||
![]() |
aaab3cb212 | ||
![]() |
6b3ce705aa | ||
![]() |
988a7fdb9d | ||
![]() |
11592b11c4 | ||
![]() |
e8791fcdf9 | ||
![]() |
e661923fd3 | ||
![]() |
61c57059fa | ||
![]() |
922019eef0 | ||
![]() |
79ca28fbdb | ||
![]() |
124079c50f | ||
![]() |
2e42fc01be | ||
![]() |
770aad5672 | ||
![]() |
bef1b9fb1e | ||
![]() |
831dce0f51 | ||
![]() |
2da4e79d06 | ||
![]() |
804a07c56e | ||
![]() |
b367f13116 | ||
![]() |
581d7716f7 | ||
![]() |
19de7aefbc | ||
![]() |
57759aa1b8 | ||
![]() |
07876afc28 | ||
![]() |
b9029fba4d | ||
![]() |
c4ba357296 |
@@ -31,12 +31,17 @@ vector<gd::InstructionsList*> ForEachEvent::GetAllActionsVectors() {
|
||||
return allActions;
|
||||
}
|
||||
|
||||
vector<gd::Expression*> ForEachEvent::GetAllExpressions() {
|
||||
vector<gd::Expression*> allExpressions;
|
||||
allExpressions.push_back(&objectsToPick);
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
ForEachEvent::GetAllExpressionsWithMetadata() {
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("object");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(&objectsToPick, metadata));
|
||||
|
||||
return allExpressions;
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
vector<const gd::InstructionsList*> ForEachEvent::GetAllConditionsVectors()
|
||||
const {
|
||||
vector<const gd::InstructionsList*> allConditions;
|
||||
@@ -52,11 +57,15 @@ vector<const gd::InstructionsList*> ForEachEvent::GetAllActionsVectors() const {
|
||||
return allActions;
|
||||
}
|
||||
|
||||
vector<const gd::Expression*> ForEachEvent::GetAllExpressions() const {
|
||||
vector<const gd::Expression*> allExpressions;
|
||||
allExpressions.push_back(&objectsToPick);
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
ForEachEvent::GetAllExpressionsWithMetadata() const {
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("object");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(&objectsToPick, metadata));
|
||||
|
||||
return allExpressions;
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
void ForEachEvent::SerializeTo(SerializerElement& element) const {
|
||||
|
@@ -50,10 +50,13 @@ class GD_CORE_API ForEachEvent : public gd::BaseEvent {
|
||||
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
|
||||
const;
|
||||
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
|
||||
virtual std::vector<const gd::Expression*> GetAllExpressions() const;
|
||||
virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const;
|
||||
|
||||
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
|
||||
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
|
||||
virtual std::vector<gd::Expression*> GetAllExpressions();
|
||||
virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata();
|
||||
|
||||
virtual void SerializeTo(SerializerElement& element) const;
|
||||
virtual void UnserializeFrom(gd::Project& project,
|
||||
|
@@ -31,11 +31,15 @@ vector<gd::InstructionsList*> RepeatEvent::GetAllActionsVectors() {
|
||||
return allActions;
|
||||
}
|
||||
|
||||
vector<gd::Expression*> RepeatEvent::GetAllExpressions() {
|
||||
vector<gd::Expression*> allExpressions;
|
||||
allExpressions.push_back(&repeatNumberExpression);
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
RepeatEvent::GetAllExpressionsWithMetadata() {
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("expression");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(&repeatNumberExpression, metadata));
|
||||
|
||||
return allExpressions;
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
vector<const gd::InstructionsList*> RepeatEvent::GetAllConditionsVectors()
|
||||
@@ -53,11 +57,15 @@ vector<const gd::InstructionsList*> RepeatEvent::GetAllActionsVectors() const {
|
||||
return allActions;
|
||||
}
|
||||
|
||||
vector<const gd::Expression*> RepeatEvent::GetAllExpressions() const {
|
||||
vector<const gd::Expression*> allExpressions;
|
||||
allExpressions.push_back(&repeatNumberExpression);
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
RepeatEvent::GetAllExpressionsWithMetadata() const {
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("expression");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(&repeatNumberExpression, metadata));
|
||||
|
||||
return allExpressions;
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
void RepeatEvent::SerializeTo(SerializerElement& element) const {
|
||||
|
@@ -45,11 +45,14 @@ class GD_CORE_API RepeatEvent : public gd::BaseEvent {
|
||||
|
||||
virtual std::vector<gd::InstructionsList*> GetAllConditionsVectors();
|
||||
virtual std::vector<gd::InstructionsList*> GetAllActionsVectors();
|
||||
virtual std::vector<gd::Expression*> GetAllExpressions();
|
||||
virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata();
|
||||
|
||||
virtual std::vector<const gd::InstructionsList*> GetAllConditionsVectors()
|
||||
const;
|
||||
virtual std::vector<const gd::InstructionsList*> GetAllActionsVectors() const;
|
||||
virtual std::vector<const gd::Expression*> GetAllExpressions() const;
|
||||
virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const;
|
||||
|
||||
virtual void SerializeTo(SerializerElement& element) const;
|
||||
virtual void UnserializeFrom(gd::Project& project,
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
|
||||
#include "GDCore/Events/CodeGeneration/ExpressionCodeGenerator.h"
|
||||
@@ -539,6 +541,7 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
if (MetadataProvider::HasBehaviorAction(
|
||||
platform, behaviorType, action.GetType()) &&
|
||||
instrInfos.parameters.size() >= 2) {
|
||||
|
||||
std::vector<gd::String> realObjects =
|
||||
ExpandObjectsName(objectName, context);
|
||||
for (std::size_t i = 0; i < realObjects.size(); ++i) {
|
||||
@@ -628,7 +631,7 @@ gd::String EventsCodeGenerator::GenerateParameterCodes(
|
||||
|
||||
argOutput = "\"" + argOutput + "\"";
|
||||
} else if (ParameterMetadata::IsBehavior(metadata.type)) {
|
||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||
argOutput = GenerateGetBehaviorNameCode(parameter);
|
||||
} else if (metadata.type == "key") {
|
||||
argOutput = "\"" + ConvertToString(parameter) + "\"";
|
||||
} else if (metadata.type == "password" || metadata.type == "musicfile" ||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <vector>
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Events/InstructionsList.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class EventsList;
|
||||
@@ -127,15 +128,17 @@ class GD_CORE_API BaseEvent {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Return a list of all expressions of the event.
|
||||
* \note Used to preprocess or search in the expressions.
|
||||
* \brief Return a list of all expressions of the event, each with their associated metadata.
|
||||
* \note Used to preprocess or search in the expressions of the event.
|
||||
*/
|
||||
virtual std::vector<gd::Expression*> GetAllExpressions() {
|
||||
std::vector<gd::Expression*> noExpr;
|
||||
virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() {
|
||||
std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> > noExpr;
|
||||
return noExpr;
|
||||
};
|
||||
virtual std::vector<const gd::Expression*> GetAllExpressions() const {
|
||||
std::vector<const gd::Expression*> noExpr;
|
||||
virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const {
|
||||
std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> > noExpr;
|
||||
return noExpr;
|
||||
};
|
||||
|
||||
|
@@ -90,7 +90,7 @@ size_t ParameterMetadataTools::GetObjectParameterIndexFor(
|
||||
// the object in the list of parameters (if possible, just after).
|
||||
// Search "lastObjectName" in the codebase for other place where this
|
||||
// convention is enforced.
|
||||
for (std::size_t pNb = parameterIndex - 1; pNb < parametersMetadata.size();
|
||||
for (std::size_t pNb = parameterIndex; pNb < parametersMetadata.size();
|
||||
pNb--) {
|
||||
if (gd::ParameterMetadata::IsObject(parametersMetadata[pNb].GetType())) {
|
||||
return pNb;
|
||||
|
@@ -279,6 +279,43 @@ bool EventsRefactorer::RenameObjectInConditions(
|
||||
return somethingModified;
|
||||
}
|
||||
|
||||
bool EventsRefactorer::RenameObjectInEventParameters(
|
||||
const gd::Platform& platform,
|
||||
gd::ObjectsContainer& project,
|
||||
gd::ObjectsContainer& layout,
|
||||
gd::Expression& expression,
|
||||
gd::ParameterMetadata parameterMetadata,
|
||||
gd::String oldName,
|
||||
gd::String newName) {
|
||||
bool somethingModified = false;
|
||||
|
||||
if (gd::ParameterMetadata::IsObject(parameterMetadata.GetType()) &&
|
||||
expression.GetPlainString() == oldName)
|
||||
expression = gd::Expression(newName);
|
||||
// Replace object's name in expressions
|
||||
else if (ParameterMetadata::IsExpression(
|
||||
"number", parameterMetadata.GetType())) {
|
||||
gd::ExpressionParser2 parser(platform, project, layout);
|
||||
auto node = parser.ParseExpression("number", expression.GetPlainString());
|
||||
|
||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||
expression = ExpressionParser2NodePrinter::PrintNode(*node);
|
||||
}
|
||||
}
|
||||
// Replace object's name in text expressions
|
||||
else if (ParameterMetadata::IsExpression(
|
||||
"string", parameterMetadata.GetType())) {
|
||||
gd::ExpressionParser2 parser(platform, project, layout);
|
||||
auto node = parser.ParseExpression("string", expression.GetPlainString());
|
||||
|
||||
if (ExpressionObjectRenamer::Rename(*node, oldName, newName)) {
|
||||
expression = ExpressionParser2NodePrinter::PrintNode(*node);
|
||||
}
|
||||
}
|
||||
|
||||
return somethingModified;
|
||||
}
|
||||
|
||||
void EventsRefactorer::RenameObjectInEvents(const gd::Platform& platform,
|
||||
gd::ObjectsContainer& project,
|
||||
gd::ObjectsContainer& layout,
|
||||
@@ -300,6 +337,15 @@ void EventsRefactorer::RenameObjectInEvents(const gd::Platform& platform,
|
||||
platform, project, layout, *actionsVectors[j], oldName, newName);
|
||||
}
|
||||
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata>> expressionsWithMetadata =
|
||||
events[i].GetAllExpressionsWithMetadata();
|
||||
for (std::size_t j = 0; j < expressionsWithMetadata.size(); ++j) {
|
||||
gd::Expression* expression = expressionsWithMetadata[j].first;
|
||||
gd::ParameterMetadata parameterMetadata = expressionsWithMetadata[j].second;
|
||||
bool somethingModified = RenameObjectInEventParameters(
|
||||
platform, project, layout, *expression, parameterMetadata, oldName, newName);
|
||||
}
|
||||
|
||||
if (events[i].CanHaveSubEvents())
|
||||
RenameObjectInEvents(platform,
|
||||
project,
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "GDCore/Events/Instruction.h"
|
||||
#include "GDCore/Extensions/Metadata/InstructionMetadata.h"
|
||||
#include "GDCore/String.h"
|
||||
namespace gd {
|
||||
class EventsList;
|
||||
@@ -146,6 +147,20 @@ class GD_CORE_API EventsRefactorer {
|
||||
gd::InstructionsList& instructions,
|
||||
gd::String oldName,
|
||||
gd::String newName);
|
||||
/**
|
||||
* Replace all occurrences of an object name by another name in an expression
|
||||
* with the specified metadata
|
||||
* ( include : objects or objects in math/text expressions ).
|
||||
*
|
||||
* \return true if something was modified.
|
||||
*/
|
||||
static bool RenameObjectInEventParameters(const gd::Platform& platform,
|
||||
gd::ObjectsContainer& project,
|
||||
gd::ObjectsContainer& layout,
|
||||
gd::Expression& expression,
|
||||
gd::ParameterMetadata parameterMetadata,
|
||||
gd::String oldName,
|
||||
gd::String newName);
|
||||
|
||||
/**
|
||||
* Remove all conditions of the list using an object
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "ProjectStripper.h"
|
||||
|
||||
#include "GDCore/Project/ExternalEvents.h"
|
||||
#include "GDCore/Project/ExternalLayout.h"
|
||||
#include "GDCore/Project/Layout.h"
|
||||
@@ -20,61 +21,8 @@ void GD_CORE_API ProjectStripper::StripProjectForExport(gd::Project& project) {
|
||||
project.GetLayout(i).GetObjectGroups().Clear();
|
||||
project.GetLayout(i).GetEvents().Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GD_CORE_API ProjectStripper::StripProjectForLayoutEdition(
|
||||
gd::Project& project, const gd::String& layoutName) {
|
||||
while (project.GetExternalEventsCount() > 0)
|
||||
project.RemoveExternalEvents(project.GetExternalEvents(0).GetName());
|
||||
|
||||
for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
auto& layout = project.GetLayout(i);
|
||||
if (layoutName == layout.GetName()) continue;
|
||||
|
||||
project.GetLayout(i).GetEvents().Clear();
|
||||
project.GetLayout(i).GetInitialInstances().Clear();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < project.GetExternalEventsCount(); ++i) {
|
||||
project.GetExternalEvents(i).GetEvents().Clear();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < project.GetExternalLayoutsCount(); ++i) {
|
||||
project.GetExternalLayout(i).GetInitialInstances().Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void GD_CORE_API ProjectStripper::StripProjectForExternalLayoutEdition(
|
||||
gd::Project& project, const gd::String& externalLayoutName) {
|
||||
while (project.GetExternalEventsCount() > 0)
|
||||
project.RemoveExternalEvents(project.GetExternalEvents(0).GetName());
|
||||
|
||||
gd::String associatedLayoutName;
|
||||
if (project.HasExternalLayoutNamed(externalLayoutName)) {
|
||||
associatedLayoutName =
|
||||
project.GetExternalLayout(externalLayoutName).GetAssociatedLayout();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < project.GetLayoutsCount(); ++i) {
|
||||
auto& layout = project.GetLayout(i);
|
||||
if (!associatedLayoutName.empty() &&
|
||||
associatedLayoutName == layout.GetName())
|
||||
continue;
|
||||
|
||||
project.GetLayout(i).GetEvents().Clear();
|
||||
project.GetLayout(i).GetInitialInstances().Clear();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < project.GetExternalEventsCount(); ++i) {
|
||||
project.GetExternalEvents(i).GetEvents().Clear();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < project.GetExternalLayoutsCount(); ++i) {
|
||||
auto& externalLayout = project.GetExternalLayout(i);
|
||||
if (externalLayoutName == externalLayout.GetName()) continue;
|
||||
|
||||
externalLayout.GetInitialInstances().Clear();
|
||||
}
|
||||
project.ClearEventsFunctionsExtensions();
|
||||
}
|
||||
|
||||
} // namespace gd
|
||||
|
@@ -28,23 +28,6 @@ class GD_CORE_API ProjectStripper {
|
||||
*/
|
||||
static void StripProjectForExport(gd::Project& project);
|
||||
|
||||
/**
|
||||
* \brief Strip project to keep only the full content of the specified
|
||||
* layout. The content of other layouts, external events and external layouts
|
||||
* is removed.
|
||||
*/
|
||||
static void StripProjectForLayoutEdition(gd::Project& project,
|
||||
const gd::String& layoutName);
|
||||
|
||||
/**
|
||||
* \brief Strip project to keep only the full content of the specified
|
||||
* external layout and the associated layout.
|
||||
* The content of other layouts, external events and external layouts is
|
||||
* removed.
|
||||
*/
|
||||
static void StripProjectForExternalLayoutEdition(
|
||||
gd::Project& project, const gd::String& externalLayoutName);
|
||||
|
||||
private:
|
||||
ProjectStripper(){};
|
||||
virtual ~ProjectStripper(){};
|
||||
|
@@ -181,7 +181,7 @@ class GD_CORE_API WholeProjectRefactorer {
|
||||
bool isObjectGroup);
|
||||
|
||||
/**
|
||||
* \brief Refactor the events function after an object or group is renamed
|
||||
* \brief Refactor the events function after an object or group is removed
|
||||
*
|
||||
* This will update the events of the function and groups.
|
||||
*/
|
||||
|
@@ -521,6 +521,9 @@ void Project::RemoveEventsFunctionsExtension(const gd::String& name) {
|
||||
|
||||
eventsFunctionsExtensions.erase(eventsFunctionExtension);
|
||||
}
|
||||
void Project::ClearEventsFunctionsExtensions() {
|
||||
eventsFunctionsExtensions.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
void Project::UnserializeFrom(const SerializerElement& element) {
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#define GDCORE_PROJECT_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "GDCore/Project/LoadingScreen.h"
|
||||
#include "GDCore/Project/ObjectGroupsContainer.h"
|
||||
#include "GDCore/Project/ObjectsContainer.h"
|
||||
@@ -460,22 +461,27 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
std::size_t GetLayoutsCount() const;
|
||||
|
||||
/**
|
||||
* \brief \brief Adds a new empty layout called "name" at the specified
|
||||
* \brief Add a new empty layout called "name" at the specified
|
||||
* position in the layout list.
|
||||
*/
|
||||
gd::Layout& InsertNewLayout(const gd::String& name, std::size_t position);
|
||||
|
||||
/**
|
||||
* \brief \brief Adds a new layout constructed from the layout passed as
|
||||
* parameter. \note No pointer or reference must be kept on the layout passed
|
||||
* as parameter. \param layout The layout that must be copied and inserted
|
||||
* into the project \param position Insertion position. Even if the position
|
||||
* \brief Add a new layout constructed from the layout passed as
|
||||
* parameter.
|
||||
* \param layout The layout that must be copied and inserted
|
||||
* into the project
|
||||
* \param position Insertion position. Even if the position
|
||||
* is invalid, the layout must be inserted at the end of the layout list.
|
||||
*
|
||||
* \note No pointer or reference must be kept on the layout passed
|
||||
* as parameter.
|
||||
*
|
||||
*/
|
||||
gd::Layout& InsertLayout(const Layout& layout, std::size_t position);
|
||||
|
||||
/**
|
||||
* Must delete layout named "name".
|
||||
* \brief Delete layout named "name".
|
||||
*/
|
||||
void RemoveLayout(const gd::String& name);
|
||||
|
||||
@@ -592,7 +598,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
std::size_t position);
|
||||
|
||||
/**
|
||||
* Must delete external events named "name".
|
||||
* \brief Delete external events named "name".
|
||||
*/
|
||||
void RemoveExternalEvents(const gd::String& name);
|
||||
#endif
|
||||
@@ -673,7 +679,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
std::size_t position);
|
||||
|
||||
/**
|
||||
* Must delete external layout named "name".
|
||||
* \brief Delete external layout named "name".
|
||||
*/
|
||||
void RemoveExternalLayout(const gd::String& name);
|
||||
|
||||
@@ -694,37 +700,37 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
///@{
|
||||
#if defined(GD_IDE_ONLY)
|
||||
/**
|
||||
* Return true if events functions extension called "name" exists.
|
||||
* \brief Check if events functions extension called "name" exists.
|
||||
*/
|
||||
bool HasEventsFunctionsExtensionNamed(const gd::String& name) const;
|
||||
|
||||
/**
|
||||
* Return a reference to the events functions extension called "name".
|
||||
* \brief Return a reference to the events functions extension called "name".
|
||||
*/
|
||||
EventsFunctionsExtension& GetEventsFunctionsExtension(const gd::String& name);
|
||||
|
||||
/**
|
||||
* Return a reference to the events functions extension called "name".
|
||||
* \brief Return a reference to the events functions extension called "name".
|
||||
*/
|
||||
const EventsFunctionsExtension& GetEventsFunctionsExtension(
|
||||
const gd::String& name) const;
|
||||
|
||||
/**
|
||||
* Return a reference to the events functions extension at position "index" in
|
||||
* the list
|
||||
* \brief Return a reference to the events functions extension at position
|
||||
* "index" in the list
|
||||
*/
|
||||
EventsFunctionsExtension& GetEventsFunctionsExtension(std::size_t index);
|
||||
|
||||
/**
|
||||
* Return a reference to the events functions extension at position "index" in
|
||||
* the list
|
||||
* \brief Return a reference to the events functions extension at position
|
||||
* "index" in the list
|
||||
*/
|
||||
const EventsFunctionsExtension& GetEventsFunctionsExtension(
|
||||
std::size_t index) const;
|
||||
|
||||
/**
|
||||
* Return the position of the events functions extension called "name" in the
|
||||
* list
|
||||
* \brief Return the position of the events functions extension called "name"
|
||||
* in the list.
|
||||
*/
|
||||
std::size_t GetEventsFunctionsExtensionPosition(const gd::String& name) const;
|
||||
|
||||
@@ -736,7 +742,7 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
void SwapEventsFunctionsExtensions(std::size_t first, std::size_t second);
|
||||
|
||||
/**
|
||||
* Return the number of events functions extension.
|
||||
* \brief Returns the number of events functions extension.
|
||||
*/
|
||||
std::size_t GetEventsFunctionsExtensionsCount() const;
|
||||
|
||||
@@ -759,9 +765,14 @@ class GD_CORE_API Project : public ObjectsContainer {
|
||||
std::size_t position);
|
||||
|
||||
/**
|
||||
* Must delete the events functions extension named "name".
|
||||
* \brief Delete the events functions extension named "name".
|
||||
*/
|
||||
void RemoveEventsFunctionsExtension(const gd::String& name);
|
||||
|
||||
/**
|
||||
* \brief Remove all the events functions extensions.
|
||||
*/
|
||||
void ClearEventsFunctionsExtensions();
|
||||
#endif
|
||||
///@}
|
||||
|
||||
|
@@ -5,7 +5,9 @@
|
||||
*/
|
||||
|
||||
#include "GDCore/Project/Variable.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "GDCore/Serialization/SerializerElement.h"
|
||||
#include "GDCore/String.h"
|
||||
#include "GDCore/TinyXml/tinyxml.h"
|
||||
@@ -19,9 +21,7 @@ namespace gd {
|
||||
*/
|
||||
double Variable::GetValue() const {
|
||||
if (!isNumber) {
|
||||
stringstream ss;
|
||||
ss << str;
|
||||
ss >> value;
|
||||
value = str.To<double>();
|
||||
isNumber = true;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ double Variable::GetValue() const {
|
||||
|
||||
const gd::String& Variable::GetString() const {
|
||||
if (isNumber) {
|
||||
stringstream s;
|
||||
s << (value);
|
||||
str = s.str();
|
||||
str = gd::String::From(value);
|
||||
isNumber = false;
|
||||
}
|
||||
|
||||
@@ -76,6 +74,7 @@ const Variable& Variable::GetChild(const gd::String& name) const {
|
||||
void Variable::RemoveChild(const gd::String& name) {
|
||||
if (!isStructure) return;
|
||||
children.erase(name);
|
||||
isStructure = !children.empty();
|
||||
}
|
||||
|
||||
bool Variable::RenameChild(const gd::String& oldName,
|
||||
@@ -190,6 +189,7 @@ void Variable::RemoveRecursively(const gd::Variable& variableToRemove) {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
isStructure = !children.empty();
|
||||
}
|
||||
|
||||
Variable::Variable(const Variable& other)
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,16 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
'AdMob',
|
||||
@@ -355,7 +364,7 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -11,8 +12,18 @@
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function (
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
@@ -27,7 +38,8 @@ module.exports = {
|
||||
.setExtensionHelpPath('/objects/bbtext');
|
||||
|
||||
var objectBBText = new gd.ObjectJsImplementation();
|
||||
objectBBText.updateProperty = function(
|
||||
// $FlowExpectedError
|
||||
objectBBText.updateProperty = function (
|
||||
objectContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -35,74 +47,69 @@ module.exports = {
|
||||
if (propertyName in objectContent) {
|
||||
if (typeof objectContent[propertyName] === 'boolean')
|
||||
objectContent[propertyName] = newValue === '1';
|
||||
else if (typeof objectContent[propertyName] === 'number')
|
||||
objectContent[propertyName] = parseFloat(newValue);
|
||||
else objectContent[propertyName] = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
objectBBText.getProperties = function(objectContent) {
|
||||
var objectProperties = new gd.MapStringPropertyDescriptor();
|
||||
// $FlowExpectedError
|
||||
objectBBText.getProperties = function (objectContent) {
|
||||
const objectProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
objectProperties.set(
|
||||
'text',
|
||||
new gd.PropertyDescriptor(objectContent.text)
|
||||
.setType('textarea')
|
||||
.setLabel(_('BBCode text'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('text')
|
||||
.setValue(objectContent.text)
|
||||
.setType('textarea')
|
||||
.setLabel(_('BBCode text'));
|
||||
|
||||
objectProperties.set(
|
||||
'color',
|
||||
new gd.PropertyDescriptor(objectContent.color)
|
||||
.setType('color')
|
||||
.setLabel(_('Base color'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('color')
|
||||
.setValue(objectContent.color)
|
||||
.setType('color')
|
||||
.setLabel(_('Base color'));
|
||||
|
||||
objectProperties.set(
|
||||
'opacity',
|
||||
new gd.PropertyDescriptor(objectContent.opacity.toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Opacity (0-255)'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('opacity')
|
||||
.setValue(objectContent.opacity.toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Opacity (0-255)'));
|
||||
|
||||
objectProperties.set(
|
||||
'fontSize',
|
||||
new gd.PropertyDescriptor(objectContent.fontSize)
|
||||
.setType('number')
|
||||
.setLabel(_('Base size'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('fontSize')
|
||||
.setValue(objectContent.fontSize.toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Base size'));
|
||||
|
||||
objectProperties.set(
|
||||
'align',
|
||||
new gd.PropertyDescriptor(objectContent.align)
|
||||
.setType('choice')
|
||||
.addExtraInfo('left')
|
||||
.addExtraInfo('center')
|
||||
.addExtraInfo('right')
|
||||
.setLabel(_('Base alignment'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('align')
|
||||
.setValue(objectContent.align)
|
||||
.setType('choice')
|
||||
.addExtraInfo('left')
|
||||
.addExtraInfo('center')
|
||||
.addExtraInfo('right')
|
||||
.setLabel(_('Base alignment'));
|
||||
|
||||
objectProperties.set(
|
||||
'fontFamily',
|
||||
new gd.PropertyDescriptor(objectContent.fontFamily)
|
||||
.setType('resource')
|
||||
.addExtraInfo('font')
|
||||
.setLabel(_('Base font family'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('fontFamily')
|
||||
.setValue(objectContent.fontFamily)
|
||||
.setType('resource')
|
||||
.addExtraInfo('font')
|
||||
.setLabel(_('Base font family'));
|
||||
|
||||
objectProperties.set(
|
||||
'wordWrap',
|
||||
new gd.PropertyDescriptor(objectContent.wordWrap ? 'true' : 'false')
|
||||
.setType('boolean')
|
||||
.setLabel(_('Word wrapping'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('wordWrap')
|
||||
.setValue(objectContent.wordWrap ? 'true' : 'false')
|
||||
.setType('boolean')
|
||||
.setLabel(_('Word wrapping'));
|
||||
|
||||
objectProperties.set(
|
||||
'visible',
|
||||
new gd.PropertyDescriptor(objectContent.visible ? 'true' : 'false')
|
||||
.setType('boolean')
|
||||
.setLabel(_('Visible on start'))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('visible')
|
||||
.setValue(objectContent.visible ? 'true' : 'false')
|
||||
.setType('boolean')
|
||||
.setLabel(_('Visible on start'));
|
||||
|
||||
return objectProperties;
|
||||
};
|
||||
@@ -111,7 +118,7 @@ module.exports = {
|
||||
text:
|
||||
'[b]bold[/b] [i]italic[/i] [size=15]smaller[/size] [font=times]times[/font] font\n[spacing=12]spaced out[/spacing]\n[outline=yellow]outlined[/outline] [shadow=red]DropShadow[/shadow] ',
|
||||
opacity: 255,
|
||||
fontSize: '20',
|
||||
fontSize: 20,
|
||||
visible: true,
|
||||
color: '#000000',
|
||||
fontFamily: 'Arial',
|
||||
@@ -120,7 +127,8 @@ module.exports = {
|
||||
})
|
||||
);
|
||||
|
||||
objectBBText.updateInitialInstanceProperty = function(
|
||||
// $FlowExpectedError
|
||||
objectBBText.updateInitialInstanceProperty = function (
|
||||
objectContent,
|
||||
instance,
|
||||
propertyName,
|
||||
@@ -130,7 +138,8 @@ module.exports = {
|
||||
) {
|
||||
return false;
|
||||
};
|
||||
objectBBText.getInitialInstanceProperties = function(
|
||||
// $FlowExpectedError
|
||||
objectBBText.getInitialInstanceProperties = function (
|
||||
content,
|
||||
instance,
|
||||
project,
|
||||
@@ -161,7 +170,7 @@ module.exports = {
|
||||
* Useful for setting multiple generic properties.
|
||||
*/
|
||||
const addSettersAndGettersToObject = (gdObject, properties, objectName) => {
|
||||
properties.forEach(property => {
|
||||
properties.forEach((property) => {
|
||||
const parameterType =
|
||||
property.type === 'boolean' ? 'yesorno' : property.type;
|
||||
|
||||
@@ -173,8 +182,6 @@ module.exports = {
|
||||
property.expressionLabel,
|
||||
property.expressionDescription,
|
||||
'',
|
||||
'',
|
||||
property.iconPath,
|
||||
property.iconPath
|
||||
)
|
||||
.addParameter('object', objectName, objectName, false)
|
||||
@@ -187,8 +194,6 @@ module.exports = {
|
||||
property.expressionLabel,
|
||||
property.expressionDescription,
|
||||
'',
|
||||
'',
|
||||
property.iconPath,
|
||||
property.iconPath
|
||||
)
|
||||
.addParameter('object', objectName, objectName, false)
|
||||
@@ -392,13 +397,15 @@ module.exports = {
|
||||
* of your extension behaviors/objects by instanciating behaviors/objects
|
||||
* and setting the property to a given value.
|
||||
*
|
||||
* If you don't have any tests, you can simply return an empty array like this:
|
||||
* `runExtensionSanityTests: function(gd, extension) { return []; }`
|
||||
* If you don't have any tests, you can simply return an empty array.
|
||||
*
|
||||
* But it is recommended to create tests for the behaviors/objects properties you created
|
||||
* to avoid mistakes.
|
||||
*/
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function (
|
||||
gd /*: libGDevelop */,
|
||||
extension /*: gdPlatformExtension*/
|
||||
) {
|
||||
return [];
|
||||
},
|
||||
/**
|
||||
@@ -406,11 +413,13 @@ module.exports = {
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
registerEditorConfigurations: function(objectsEditorService) {
|
||||
registerEditorConfigurations: function (
|
||||
objectsEditorService /*: ObjectsEditorService */
|
||||
) {
|
||||
objectsEditorService.registerEditorConfiguration(
|
||||
'BBText::BBText',
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
|
||||
helpPagePath: '/objects/bbtext_object',
|
||||
helpPagePath: '/objects/bbtext',
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -419,7 +428,9 @@ module.exports = {
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
registerInstanceRenderers: function(objectsRenderingService) {
|
||||
registerInstanceRenderers: function (
|
||||
objectsRenderingService /*: ObjectsRenderingService */
|
||||
) {
|
||||
const RenderedInstance = objectsRenderingService.RenderedInstance;
|
||||
const PIXI = objectsRenderingService.PIXI;
|
||||
const MultiStyleText = objectsRenderingService.requireModule(
|
||||
@@ -478,7 +489,7 @@ module.exports = {
|
||||
/**
|
||||
* Return the path to the thumbnail of the specified object.
|
||||
*/
|
||||
RenderedBBTextInstance.getThumbnail = function(
|
||||
RenderedBBTextInstance.getThumbnail = function (
|
||||
project,
|
||||
resourcesLoader,
|
||||
object
|
||||
@@ -489,7 +500,7 @@ module.exports = {
|
||||
/**
|
||||
* This is called to update the PIXI object on the scene editor
|
||||
*/
|
||||
RenderedBBTextInstance.prototype.update = function() {
|
||||
RenderedBBTextInstance.prototype.update = function () {
|
||||
const rawText = this._associatedObject
|
||||
.getProperties(this.project)
|
||||
.get('text')
|
||||
@@ -526,11 +537,11 @@ module.exports = {
|
||||
|
||||
this._pixiResourcesLoader
|
||||
.loadFontFamily(this._project, fontResourceName)
|
||||
.then(fontFamily => {
|
||||
.then((fontFamily) => {
|
||||
// Once the font is loaded, we can use the given fontFamily.
|
||||
this._pixiObject.textStyles.default.fontFamily = fontFamily;
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
// Ignore errors
|
||||
console.warn('Unable to load font family', err);
|
||||
});
|
||||
@@ -577,14 +588,14 @@ module.exports = {
|
||||
/**
|
||||
* Return the width of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedBBTextInstance.prototype.getDefaultWidth = function() {
|
||||
RenderedBBTextInstance.prototype.getDefaultWidth = function () {
|
||||
return this._pixiObject.width;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the height of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedBBTextInstance.prototype.getDefaultHeight = function() {
|
||||
RenderedBBTextInstance.prototype.getDefaultHeight = function () {
|
||||
return this._pixiObject.height;
|
||||
};
|
||||
|
||||
|
@@ -76,6 +76,7 @@ gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateText = function() {
|
||||
|
||||
gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateColor = function() {
|
||||
this._pixiObject.textStyles.default.fill = this._object._color;
|
||||
this._pixiObject.dirty = true;
|
||||
};
|
||||
|
||||
gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateAlignment = function() {
|
||||
@@ -83,10 +84,12 @@ gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateAlignment = function() {
|
||||
this._pixiObject.dirty = true;
|
||||
};
|
||||
gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateFontFamily = function() {
|
||||
this._pixiObject.textStyles.default.fontFamily = this._object._fontFamily;
|
||||
this._pixiObject.textStyles.default.fontFamily = this._object._runtimeScene.getGame().getFontManager().getFontFamily(this._object._fontFamily);
|
||||
this._pixiObject.dirty = true;
|
||||
};
|
||||
gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updateFontSize = function() {
|
||||
this._pixiObject.textStyles.default.fontSize = this._object._fontSize + 'px';
|
||||
this._pixiObject.dirty = true;
|
||||
};
|
||||
|
||||
gdjs.BBTextRuntimeObjectPixiRenderer.prototype.updatePosition = function() {
|
||||
|
@@ -25,7 +25,8 @@ gdjs.BBTextRuntimeObject = function(runtimeScene, objectData) {
|
||||
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
|
||||
|
||||
/** @type {number} */
|
||||
this._opacity = objectData.content.opacity;
|
||||
this._opacity = parseFloat(objectData.content.opacity);
|
||||
// parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.
|
||||
/** @type {boolean} */
|
||||
this._visible = objectData.content.visible;
|
||||
/** @type {string} */
|
||||
@@ -35,7 +36,8 @@ gdjs.BBTextRuntimeObject = function(runtimeScene, objectData) {
|
||||
/** @type {string} */
|
||||
this._fontFamily = objectData.content.fontFamily;
|
||||
/** @type {number} */
|
||||
this._fontSize = objectData.content.fontSize;
|
||||
this._fontSize = parseFloat(objectData.content.fontSize);
|
||||
// parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string.
|
||||
/** @type {boolean} */
|
||||
this._wordWrap = objectData.content.wordWrap;
|
||||
/** @type {number} */
|
||||
|
File diff suppressed because one or more lines are too long
58
Extensions/DebuggerTools/JsExtension.js
Normal file
58
Extensions/DebuggerTools/JsExtension.js
Normal file
@@ -0,0 +1,58 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
'DebuggerTools',
|
||||
_('Debugger Tools'),
|
||||
_(
|
||||
'Allow to interact with the editor debugger from the game.'
|
||||
),
|
||||
'Arthur Pacaud (arthuro555)',
|
||||
'MIT'
|
||||
);
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'Pause',
|
||||
_('Pause game execution'),
|
||||
_(
|
||||
'This pauses the game, useful for inspecting the game state through the debugger. ' +
|
||||
'Note that events will be still executed until the end before the game is paused.'
|
||||
),
|
||||
_('Pause game execution'),
|
||||
_('Debugger Tools'),
|
||||
'res/actions/bug32.png',
|
||||
'res/actions/bug32.png'
|
||||
)
|
||||
.addCodeOnlyParameter("currentScene", "")
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
|
||||
.setFunctionName('gdjs.evtTools.debugger.pause');
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
},
|
||||
}
|
19
Extensions/DebuggerTools/debuggertools.js
Normal file
19
Extensions/DebuggerTools/debuggertools.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file
|
||||
* Tools for interacting with the debugger.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The namespace containing tools to interact with the debugger.
|
||||
* @namespace
|
||||
*/
|
||||
gdjs.evtTools.debugger = {};
|
||||
|
||||
/**
|
||||
* Stop the game execution.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene - The current scene.
|
||||
*/
|
||||
gdjs.evtTools.debugger.pause = function(runtimeScene) {
|
||||
runtimeScene.getGame().pause(true);
|
||||
}
|
@@ -1,17 +1,26 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
*
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
"DeviceSensors",
|
||||
@@ -445,5 +454,5 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) { return []; },
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) { return []; },
|
||||
};
|
||||
|
@@ -1,17 +1,26 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
*
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
"DeviceVibration",
|
||||
@@ -75,5 +84,5 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) { return []; },
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) { return []; },
|
||||
};
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,16 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
@@ -45,7 +54,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/DialogueTree/dialoguetools.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.min.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.js/dist/bondage.min.js')
|
||||
.setFunctionName('gdjs.dialogueTree.loadFromSceneVariable');
|
||||
|
||||
extension
|
||||
@@ -69,7 +78,7 @@ module.exports = {
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/DialogueTree/dialoguetools.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.min.js')
|
||||
.addIncludeFile('Extensions/DialogueTree/bondage.js/dist/bondage.min.js')
|
||||
.setFunctionName('gdjs.dialogueTree.loadFromJsonFile');
|
||||
|
||||
extension
|
||||
@@ -168,15 +177,14 @@ module.exports = {
|
||||
_(
|
||||
'Select option by number. Use this when the dialogue line is of type "options" and the player has pressed a button to change selected option.'
|
||||
),
|
||||
_('Select option by number'),
|
||||
_('Select option at index _PARAM0_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Option index number'), '', false)
|
||||
.setDefaultValue('0')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.selectPreviousOption');
|
||||
.setFunctionName('gdjs.dialogueTree.selectOption');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
@@ -210,18 +218,52 @@ module.exports = {
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SetVariable',
|
||||
_('Set dialogue state variable'),
|
||||
'SetStringVariable',
|
||||
_('Set dialogue state string variable'),
|
||||
_(
|
||||
'Set dialogue state variable. Use this to set a variable that the dialogue data is using.'
|
||||
'Set dialogue state string variable. Use this to set a variable that the dialogue data is using.'
|
||||
),
|
||||
_('Set dialogue state variable _PARAM0_ to _PARAM1_'),
|
||||
_('Set dialogue state string variable _PARAM0_ to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State Variable Name'), '', false)
|
||||
.addParameter('expression', _('Variable Value'), '', false)
|
||||
.addParameter('string', _('Variable string value'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.setVariable');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SetNumberVariable',
|
||||
_('Set dialogue state number variable'),
|
||||
_(
|
||||
'Set dialogue state number variable. Use this to set a variable that the dialogue data is using.'
|
||||
),
|
||||
_('Set dialogue state number variable _PARAM0_ to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State Variable Name'), '', false)
|
||||
.addParameter('expression', _('Variable number value'), '', true)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.setVariable');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'SetBooleanVariable',
|
||||
_('Set dialogue state boolean variable'),
|
||||
_(
|
||||
'Set dialogue state boolean variable. Use this to set a variable that the dialogue data is using.'
|
||||
),
|
||||
_('Set dialogue state boolean variable _PARAM0_ to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State Variable Name'), '', false)
|
||||
.addParameter('trueorfalse', _('Variable boolean value'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.setVariable');
|
||||
|
||||
@@ -257,13 +299,27 @@ module.exports = {
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.loadState');
|
||||
|
||||
extension
|
||||
.addAction(
|
||||
'ClearState',
|
||||
_('Clear dialogue state'),
|
||||
_(
|
||||
'Clear dialogue state. This resets all dialogue state accumulated by the player choices. Useful when the player is starting a new game.'
|
||||
),
|
||||
_('Clear dialogue state'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.clearState');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'LineText',
|
||||
_('Get the current dialogue line text'),
|
||||
_('Returns the current dialogue line text'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -275,7 +331,6 @@ module.exports = {
|
||||
_('Get the number of options in an options line type'),
|
||||
_('Get the number of options in an options line type'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -289,7 +344,6 @@ module.exports = {
|
||||
"Get the text of an option from an Options line type, using the option's Number. The numbers start from 0."
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Option Index Number'), '', false)
|
||||
@@ -304,7 +358,6 @@ module.exports = {
|
||||
"Get the text of all available options from an Options line type as a horizontal list. You can also pass the selected option's cursor string, which by default is ->"
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Options Selection Cursor'), '', false)
|
||||
@@ -320,7 +373,6 @@ module.exports = {
|
||||
"Get the text of all available options from an Options line type as a vertical list. You can also pass the selected option's cursor string, which by default is ->"
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Options Selection Cursor'), '', false)
|
||||
@@ -336,7 +388,6 @@ module.exports = {
|
||||
'Get the number of the currently selected option. Use this to help you render the option selection marker at the right place.'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -350,7 +401,6 @@ module.exports = {
|
||||
'Get dialogue line text clipped by the typewriter effect. Use the "Scroll clipped text" action to control the typewriter effect.'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -362,7 +412,6 @@ module.exports = {
|
||||
_('Get the title of the current branch of the running dialogue'),
|
||||
_('Get the title of the current branch of the running dialogue'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -374,7 +423,6 @@ module.exports = {
|
||||
_('Get the tags of the current branch of the running dialogue'),
|
||||
_('Get the tags of the current branch of the running dialogue'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -386,7 +434,6 @@ module.exports = {
|
||||
_('Get a tag of the current branch of the running dialogue via its index'),
|
||||
_('Get a tag of the current branch of the running dialogue via its index'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('Tag Index Number'), '', false)
|
||||
@@ -401,7 +448,6 @@ module.exports = {
|
||||
'Get the parameters of a command call - <<command withParameter anotherParameter>>'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('parameter Index Number'), '', true)
|
||||
@@ -414,7 +460,6 @@ module.exports = {
|
||||
_('Get the number of parameters in the currently passed command'),
|
||||
_('Get the number of parameters in the currently passed command'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -430,7 +475,6 @@ module.exports = {
|
||||
'Get parameter from a Tag found by the branch contains tag condition'
|
||||
),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('expression', _('parameter Index Number'), '', true)
|
||||
@@ -443,7 +487,6 @@ module.exports = {
|
||||
_('Get a list of all visited branches'),
|
||||
_('Get a list of all visited branches'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -455,7 +498,6 @@ module.exports = {
|
||||
_('Get the full raw text of the current branch'),
|
||||
_('Get the full raw text of the current branch'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -467,7 +509,6 @@ module.exports = {
|
||||
_('Get dialogue state value'),
|
||||
_('Get dialogue state value'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('Variable Name'), '', false)
|
||||
@@ -592,9 +633,9 @@ module.exports = {
|
||||
extension
|
||||
.addCondition(
|
||||
'WasBranchVisited',
|
||||
_('Branch title has been visited before'),
|
||||
_('Check if the current branch has been visited before'),
|
||||
_('Branch title _PARAM0_ has been visited before'),
|
||||
_('Branch title has been visited'),
|
||||
_('Check if a branch has been visited'),
|
||||
_('Branch title _PARAM0_ has been visited'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
@@ -605,12 +646,12 @@ module.exports = {
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CompareDialogueStateVariable',
|
||||
_('Compare dialogue state variable'),
|
||||
'CompareDialogueStateStringVariable',
|
||||
_('Compare dialogue state string variable'),
|
||||
_(
|
||||
'Compare dialogue state variable. Use this to trigger game events via dialogue variables.'
|
||||
'Compare dialogue state string variable. Use this to trigger game events via dialogue variables.'
|
||||
),
|
||||
_('Dialogue state variable _PARAM0_ is equal to _PARAM1_'),
|
||||
_('Dialogue state string variable _PARAM0_ is equal to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
@@ -620,6 +661,40 @@ module.exports = {
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.compareVariable');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CompareDialogueStateNumberVariable',
|
||||
_('Compare dialogue state number variable'),
|
||||
_(
|
||||
'Compare dialogue state number variable. Use this to trigger game events via dialogue variables.'
|
||||
),
|
||||
_('Dialogue state number variable _PARAM0_ is equal to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State variable'), '', false)
|
||||
.addParameter('expression', _('Equal to'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.compareVariable');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'CompareDialogueStateBooleanVariable',
|
||||
_('Compare dialogue state boolean variable'),
|
||||
_(
|
||||
'Compare dialogue state variable. Use this to trigger game events via dialogue variables.'
|
||||
),
|
||||
_('Dialogue state boolean variable _PARAM0_ is equal to _PARAM1_'),
|
||||
_('Dialogue Tree (experimental)'),
|
||||
'JsPlatform/Extensions/yarn24.png',
|
||||
'JsPlatform/Extensions/yarn32.png'
|
||||
)
|
||||
.addParameter('string', _('State variable'), '', false)
|
||||
.addParameter('trueorfalse', _('Equal to'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('gdjs.dialogueTree.compareVariable');
|
||||
|
||||
extension
|
||||
.addCondition(
|
||||
'HasClippedTextScrollingCompleted',
|
||||
@@ -637,7 +712,7 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
|
21
Extensions/DialogueTree/bondage.js/LICENSE.txt
Normal file
21
Extensions/DialogueTree/bondage.js/LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 j hayley
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
66
Extensions/DialogueTree/bondage.js/README.md
Normal file
66
Extensions/DialogueTree/bondage.js/README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# bondage.js [](https://travis-ci.org/jhayley/bondage.js)
|
||||
[Yarn](https://github.com/InfiniteAmmoInc/Yarn) parser for Javascript, in the same vein as [YarnSpinner](https://github.com/thesecretlab/YarnSpinner).
|
||||
|
||||
# Usage
|
||||
|
||||
#### As a Web Tool
|
||||
|
||||
To run through your yarn files in your browser, go to http://hayley.zone/bondage.js, paste your yarn data in the field, then hit "compile".
|
||||
|
||||
#### As a Command Line Tool
|
||||
Installation: `npm install -g bondage`
|
||||
|
||||
Now you can use the `bondage` command to run through Yarn files from the command line. You can load one or multiple files at a time. If you load multiple files and a two nodes are encountered with the same name, the node will be overwritten.
|
||||
|
||||
**Examples**
|
||||
|
||||
* Running a single file from the default start node (named "Start"): `bondage run yarnfile.json`
|
||||
* Running a single file from the specified node name: `bondage run -s StartNode yarnfile.json`
|
||||
* Running multiple files from the specified node name: `bondage run -s StartNode yarnfile1.json yarnfile2.json ...`
|
||||
* See the compiled ast: `bondage compile --ast yarnfile.json`
|
||||
* See the tokenized input: `bondage compile --tokens yarnfile.json`
|
||||
|
||||
#### As a Library
|
||||
|
||||
**Web**
|
||||
|
||||
Include [dist/bondage.min.js](https://github.com/jhayley/bondage.js/blob/master/dist/bondage.min.js) somewhere in your html, and the `bondage` variable will be added to the global scope. You can then access everything in the example below (such as `bondage.Runner`) through that variable.
|
||||
|
||||
**Node**
|
||||
|
||||
Installation: `npm install bondage`
|
||||
|
||||
```javascript
|
||||
const fs = require('fs');
|
||||
const bondage = require('bondage');
|
||||
|
||||
const runner = new bondage.Runner();
|
||||
const yarnData = JSON.parse(fs.readFileSync('yarnFile.json'));
|
||||
|
||||
runner.load(yarnData);
|
||||
|
||||
// Loop over the dialogue from the node titled 'Start'
|
||||
for (const result of runner.run('Start')) {
|
||||
// Do something else with the result
|
||||
if (result instanceof bondage.TextResult) {
|
||||
console.log(result.text);
|
||||
} else if (result instanceof bondage.OptionsResult) {
|
||||
// This works for both links between nodes and shortcut options
|
||||
console.log(result.options);
|
||||
|
||||
// Select based on the option's index in the array (if you don't select an option, the dialog will continue past them)
|
||||
result.select(1);
|
||||
} else if (result instanceof bondage.CommandResult) {
|
||||
// If the text was inside <<here>>, it will get returned as a CommandResult string, which you can use in any way you want
|
||||
console.log(result.text);
|
||||
}
|
||||
}
|
||||
|
||||
// Advance the dialogue manually from the node titled 'Start'
|
||||
const d = runner.run('Start')
|
||||
let result = d.next().value;
|
||||
let nextResult = d.next().value;
|
||||
// And so on
|
||||
```
|
||||
|
||||
For usage of the yarn format itself, please see the [YarnSpinner Documentation](https://github.com/thesecretlab/YarnSpinner/tree/master/Documentation), everything there should carry here too (if something does not match up, please open an issue).
|
File diff suppressed because one or more lines are too long
5
Extensions/DialogueTree/bondage.js/version.txt
Normal file
5
Extensions/DialogueTree/bondage.js/version.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
This extension is using bondage.js library to parse yarn syntax.
|
||||
https://github.com/hylyh/bondage.js
|
||||
|
||||
The current build used is built from commit 3c63e21
|
||||
|
@@ -101,7 +101,20 @@ gdjs.dialogueTree.isRunning = function() {
|
||||
gdjs.dialogueTree.scrollClippedText = function() {
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning) return;
|
||||
|
||||
if (this.dialogueText) {
|
||||
// Autoscroll commands so the user doesnt have to press again
|
||||
if (
|
||||
gdjs.dialogueTree._isLineTypeCommand() &&
|
||||
this.dialogueDataType === 'text' &&
|
||||
this.dialogueBranchTitle === this.dialogueData.data.title &&
|
||||
this.lineNum === this.dialogueData.lineNum &&
|
||||
gdjs.dialogueTree.hasClippedScrollingCompleted()
|
||||
) {
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
return
|
||||
}
|
||||
|
||||
// Increment scrolling of clipped text
|
||||
if (this.dialogueText && this.dialogueDataType === 'text' && this.clipTextEnd < this.dialogueText.length) {
|
||||
this.clipTextEnd += 1;
|
||||
}
|
||||
};
|
||||
@@ -110,7 +123,7 @@ gdjs.dialogueTree.scrollClippedText = function() {
|
||||
* Scroll the clipped text to its end, so the entire text is printed. This can be useful in keeping the event sheet logic simpler, while supporting more variation.
|
||||
*/
|
||||
gdjs.dialogueTree.completeClippedTextScrolling = function() {
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning || !this.dialogueText)
|
||||
if (this.pauseScrolling || !this.dialogueIsRunning || !this.dialogueText || this.dialogueDataType !== 'text')
|
||||
return;
|
||||
this.clipTextEnd = this.dialogueText.length;
|
||||
};
|
||||
@@ -120,9 +133,11 @@ gdjs.dialogueTree.completeClippedTextScrolling = function() {
|
||||
* Useful to prevent the user from skipping to next line before the current one has been printed fully.
|
||||
*/
|
||||
gdjs.dialogueTree.hasClippedScrollingCompleted = function() {
|
||||
if (!this.dialogueIsRunning) return false;
|
||||
if (this.dialogueData && this.dialogueText.length) {
|
||||
return this.clipTextEnd >= this.dialogueText.length;
|
||||
if (!this.dialogueIsRunning || this.dialogueDataType === '') return false;
|
||||
|
||||
if (this.dialogueData && this.dialogueText.length > 0 && this.clipTextEnd >= this.dialogueText.length) {
|
||||
if (gdjs.dialogueTree.getVariable('debug')) console.warn('Scroll completed:', this.clipTextEnd,'/', this.dialogueText.length);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -142,7 +157,6 @@ gdjs.dialogueTree.getClippedLineText = function() {
|
||||
* Note that using this instead getClippedLineText will skip any <<wait>> commands entirely.
|
||||
*/
|
||||
gdjs.dialogueTree.getLineText = function() {
|
||||
this.completeClippedTextScrolling();
|
||||
return this.dialogueIsRunning && this.dialogueText.length
|
||||
? this.dialogueText
|
||||
: '';
|
||||
@@ -163,6 +177,7 @@ gdjs.dialogueTree.commandParametersCount = function() {
|
||||
* @param {number} paramIndex The index of the parameter to get.
|
||||
*/
|
||||
gdjs.dialogueTree.getCommandParameter = function(paramIndex) {
|
||||
if (paramIndex === -1 && this.commandParameters.length > 0) return this.commandParameters[0];
|
||||
if (
|
||||
this.commandParameters &&
|
||||
this.commandParameters.length >= paramIndex + 1
|
||||
@@ -188,17 +203,20 @@ gdjs.dialogueTree.isCommandCalled = function(command) {
|
||||
|
||||
if (this.pauseScrolling || !commandCalls) return false;
|
||||
return this.commandCalls.some(function(call, index) {
|
||||
if (clipTextEnd < call.time) return false;
|
||||
if (call.cmd === 'wait' && clipTextEnd !== dialogueText.length) {
|
||||
if (clipTextEnd !== 0 && clipTextEnd < call.time) return false;
|
||||
if (call.cmd === 'wait' && (clipTextEnd === 0 || clipTextEnd !== dialogueText.length)) {
|
||||
gdjs.dialogueTree.pauseScrolling = true;
|
||||
setTimeout(function() {
|
||||
gdjs.dialogueTree.pauseScrolling = false;
|
||||
commandCalls.splice(index, 1);
|
||||
if (gdjs.dialogueTree.getVariable('debug')) console.info('CMD:', call);
|
||||
}, parseInt(call.params[1], 10));
|
||||
}
|
||||
if (call.cmd === command) {
|
||||
gdjs.dialogueTree.commandParameters = call.params;
|
||||
commandCalls.splice(index, 1);
|
||||
if (gdjs.dialogueTree.getVariable('debug')) console.info('CMD:', call);
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -339,7 +357,7 @@ gdjs.dialogueTree.selectOption = function(optionIndex) {
|
||||
if (!this.dialogueIsRunning) return;
|
||||
if (this.dialogueData.select) {
|
||||
this.selectedOption = gdjs.dialogueTree._normalizedOptionIndex(
|
||||
this.selectedOption
|
||||
optionIndex
|
||||
);
|
||||
this.selectedOptionUpdated = true;
|
||||
}
|
||||
@@ -384,16 +402,21 @@ gdjs.dialogueTree.hasSelectedOptionChanged = function() {
|
||||
* @param {string} type The type you want to check for ( one of the three above )
|
||||
*/
|
||||
gdjs.dialogueTree.isDialogueLineType = function(type) {
|
||||
if (
|
||||
this.commandCalls &&
|
||||
this.commandCalls.some(function(call) {
|
||||
return gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait';
|
||||
})
|
||||
) {
|
||||
return !this.pauseScrolling;
|
||||
if (!this.dialogueIsRunning) return false;
|
||||
if (this.commandCalls && type === 'command') {
|
||||
if (
|
||||
this.commandCalls.some(function(call) {
|
||||
return gdjs.dialogueTree.clipTextEnd > call.time && call.cmd === 'wait';
|
||||
})
|
||||
) {
|
||||
return !this.pauseScrolling;
|
||||
}
|
||||
if (this.commandCalls.length > 0 && this.commandParameters.length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return this.dialogueIsRunning ? this.dialogueDataType === type : false;
|
||||
return this.dialogueDataType === type;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -420,19 +443,27 @@ gdjs.dialogueTree.startFrom = function(startDialogueNode) {
|
||||
if (!this.hasDialogueBranch(startDialogueNode)) return;
|
||||
this.optionsCount = 0;
|
||||
this.options = [];
|
||||
this.dialogueBranchTitle = '';
|
||||
this.dialogueBranchBody = '';
|
||||
this.dialogueBranchTags = [];
|
||||
this.tagParameters = [];
|
||||
this.dialogue = this.runner.run(startDialogueNode);
|
||||
this.dialogueData = null;
|
||||
this.dialogueDataType = '';
|
||||
this.dialogueText = '';
|
||||
this.clipTextEnd = 0;
|
||||
this.commandCalls = [];
|
||||
this.commandParameters = [];
|
||||
this.pauseScrolling = false;
|
||||
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
this.dialogueBranchTags = this.dialogueData.data.tags;
|
||||
this.dialogueBranchTitle = this.dialogueData.data.title;
|
||||
this.dialogueBranchBody = this.dialogueData.data.body;
|
||||
this.lineNum = this.dialogueData.lineNum;
|
||||
if (gdjs.dialogueTree._isLineTypeText()){
|
||||
this.dialogueDataType = 'text';
|
||||
} else if (gdjs.dialogueTree._isLineTypeOptions()){
|
||||
this.dialogueDataType = 'options';
|
||||
} else {
|
||||
this.dialogueDataType = 'command';
|
||||
};
|
||||
|
||||
this.dialogueIsRunning = true;
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
};
|
||||
@@ -462,26 +493,29 @@ gdjs.dialogueTree.goToNextDialogueLine = function() {
|
||||
this.selectedOption = -1;
|
||||
this.selectedOptionUpdated = false;
|
||||
|
||||
if (gdjs.dialogueTree._isLineTypeText()) {
|
||||
if (
|
||||
this.dialogueDataType === 'options' ||
|
||||
this.dialogueDataType === 'text' ||
|
||||
!this.dialogueDataType
|
||||
) {
|
||||
this.clipTextEnd = 0;
|
||||
this.dialogueText = this.dialogueData.text;
|
||||
this.commandCalls = [];
|
||||
} else {
|
||||
if (gdjs.dialogueTree.getVariable('debug')) console.info('parsing:', this.dialogueData);
|
||||
|
||||
if (!this.dialogueData) {
|
||||
gdjs.dialogueTree.stopRunningDialogue();
|
||||
} else if (gdjs.dialogueTree._isLineTypeText()) {
|
||||
if (this.lineNum === this.dialogueData.lineNum && this.dialogueBranchTitle === this.dialogueData.data.title){
|
||||
this.clipTextEnd = this.dialogueText.length - 1;
|
||||
this.dialogueText +=
|
||||
(this.dialogueText === '' ? '' : ' ') + this.dialogueData.text;
|
||||
} else {
|
||||
this.clipTextEnd = 0;
|
||||
this.dialogueText = this.dialogueData.text;
|
||||
}
|
||||
|
||||
this.dialogueDataType = 'text';
|
||||
this.dialogueBranchTags = this.dialogueData.data.tags;
|
||||
this.dialogueBranchTitle = this.dialogueData.data.title;
|
||||
this.dialogueBranchBody = this.dialogueData.data.body;
|
||||
this.lineNum = this.dialogueData.lineNum;
|
||||
this.dialogueDataType = 'text';
|
||||
|
||||
this.dialogueData = this.dialogue.next().value;
|
||||
} else if (gdjs.dialogueTree._isLineTypeOptions()) {
|
||||
this.commandCalls = [];
|
||||
this.dialogueDataType = 'options';
|
||||
this.dialogueText = '';
|
||||
this.clipTextEnd = 0;
|
||||
@@ -490,8 +524,6 @@ gdjs.dialogueTree.goToNextDialogueLine = function() {
|
||||
this.selectedOptionUpdated = true;
|
||||
} else if (gdjs.dialogueTree._isLineTypeCommand()) {
|
||||
this.dialogueDataType = 'command';
|
||||
this.clipTextEnd = 0;
|
||||
|
||||
var command = this.dialogueData.text.split(' ');
|
||||
// If last command was to wait, increase time by one
|
||||
var offsetTime =
|
||||
@@ -509,11 +541,6 @@ gdjs.dialogueTree.goToNextDialogueLine = function() {
|
||||
} else {
|
||||
this.dialogueDataType = 'unknown';
|
||||
}
|
||||
|
||||
if (gdjs.dialogueTree._isLineTypeCommand()) {
|
||||
this.dialogueDataType = 'command';
|
||||
gdjs.dialogueTree.goToNextDialogueLine();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -631,7 +658,7 @@ gdjs.dialogueTree.getBranchText = function() {
|
||||
*/
|
||||
gdjs.dialogueTree.getVariable = function(key) {
|
||||
if (this.dialogueIsRunning && key in this.runner.variables.data) {
|
||||
return this.runner.variables.data[key];
|
||||
return this.runner.variables.get(key);
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@@ -639,11 +666,11 @@ gdjs.dialogueTree.getVariable = function(key) {
|
||||
/**
|
||||
* Check if a specific variable created by the Dialogue parses exists and is equal to a specific value.
|
||||
* @param {string} key The name of the variable you want to check the value of
|
||||
* @param {string} value The value you want to check against
|
||||
* @param {string|boolean|number} value The value you want to check against
|
||||
*/
|
||||
gdjs.dialogueTree.compareVariable = function(key, value) {
|
||||
if (this.dialogueIsRunning && key in this.runner.variables.data) {
|
||||
return this.runner.variables.data[key].toString() === value;
|
||||
return this.runner.variables.get(key) === value;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -651,11 +678,11 @@ gdjs.dialogueTree.compareVariable = function(key, value) {
|
||||
/**
|
||||
* Set a specific variable created by the Dialogue parser to a specific value.
|
||||
* @param {string} key The name of the variable you want to set the value of
|
||||
* @param {string} value The value you want to set
|
||||
* @param {string|boolean|number} value The value you want to set
|
||||
*/
|
||||
gdjs.dialogueTree.setVariable = function(key, value) {
|
||||
if (this.dialogueIsRunning && this.runner.variables.data) {
|
||||
this.runner.variables.data[key] = value;
|
||||
if (this.runner.variables) {
|
||||
this.runner.variables.set(key, value);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -666,7 +693,7 @@ gdjs.dialogueTree.setVariable = function(key, value) {
|
||||
* @param {gdjs.Variable} outputVariable The variable where to store the State
|
||||
*/
|
||||
gdjs.dialogueTree.saveState = function(outputVariable) {
|
||||
const dialogueState = {
|
||||
var dialogueState = {
|
||||
variables: gdjs.dialogueTree.runner.variables.data,
|
||||
visited: gdjs.dialogueTree.runner.visited,
|
||||
};
|
||||
@@ -677,17 +704,32 @@ gdjs.dialogueTree.saveState = function(outputVariable) {
|
||||
* Load the current State of the Dialogue Parser from a specified variable.
|
||||
* Can be used to implement persistence in dialogue through your game's Load/Save function.
|
||||
* That way you can later load all the dialogue choices the player has made.
|
||||
* @param {gdjs.Variable} inputVariable The variable where to load the State from.
|
||||
* @param {gdjs.Variable} inputVariable The structured variable where to load the State from.
|
||||
*/
|
||||
gdjs.dialogueTree.loadState = function(inputVariable) {
|
||||
const jsonData = gdjs.evtTools.network.variableStructureToJSON(inputVariable);
|
||||
var loadedState = JSON.parse(
|
||||
gdjs.evtTools.network.variableStructureToJSON(inputVariable)
|
||||
);
|
||||
if (!loadedState) {
|
||||
console.error('Load state variable is empty:', inputVariable);
|
||||
return
|
||||
}
|
||||
try {
|
||||
const loadedState = JSON.parse(
|
||||
gdjs.evtTools.network.variableStructureToJSON(inputVariable)
|
||||
);
|
||||
gdjs.dialogueTree.runner.visited = loadedState.visited;
|
||||
gdjs.dialogueTree.runner.variables.data = loadedState.variables;
|
||||
gdjs.dialogueTree.runner.variables.data = {};
|
||||
Object.keys(loadedState.variables).forEach(function(key) {
|
||||
var value = loadedState.variables[key];
|
||||
gdjs.dialogueTree.runner.variables.set(key, value);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error('Failed to load state from variable:', inputVariable, e);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the current State of the Dialogue Parser.
|
||||
*/
|
||||
gdjs.dialogueTree.clearState = function() {
|
||||
gdjs.dialogueTree.runner.visited = {};
|
||||
gdjs.dialogueTree.runner.variables.data = {};
|
||||
};
|
||||
|
@@ -1,6 +1,11 @@
|
||||
|
||||
// @ts-check
|
||||
describe('gdjs.DraggableRuntimeBehavior', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeGame = new gdjs.RuntimeGame({
|
||||
variables: [],
|
||||
resources: {resources: []},
|
||||
// @ts-ignore
|
||||
properties: {windowWidth: 800, windowHeight: 600}
|
||||
});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers:[{name:"", visibility: true}],
|
||||
@@ -10,8 +15,8 @@ describe('gdjs.DraggableRuntimeBehavior', function() {
|
||||
instances: []
|
||||
});
|
||||
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{type: "DraggableBehavior::Draggable"}]});
|
||||
var object2 = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{type: "DraggableBehavior::Draggable"}]});
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{name: "Behavior1", type: "DraggableBehavior::Draggable"}], variables: []});
|
||||
var object2 = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{name: "Behavior1", type: "DraggableBehavior::Draggable"}], variables: []});
|
||||
runtimeScene.addObject(object);
|
||||
runtimeScene.addObject(object2);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n(t.__filters={},t.PIXI)}(this,function(t,n){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform float gamma;\nuniform float contrast;\nuniform float saturation;\nuniform float brightness;\nuniform float red;\nuniform float green;\nuniform float blue;\nuniform float alpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (c.a > 0.0) {\n c.rgb /= c.a;\n\n vec3 rgb = pow(c.rgb, vec3(1. / gamma));\n rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast);\n rgb.r *= red;\n rgb.g *= green;\n rgb.b *= blue;\n c.rgb = rgb * brightness;\n\n c.rgb *= c.a;\n }\n\n gl_FragColor = c * alpha;\n}\n",i=function(t){function n(n){t.call(this,r,e),Object.assign(this,{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},n)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.apply=function(t,n,r,e){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,t.applyFilter(this,n,r,e)},n}(n.Filter);t.AdjustmentFilter=i,Object.defineProperty(t,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-adjustment.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pixi.js"),require("@pixi/filter-kawase-blur")):"function"==typeof define&&define.amd?define(["exports","pixi.js","@pixi/filter-kawase-blur"],t):t(e.__filters={},e.PIXI,e.PIXI.filters)}(this,function(e,t,r){"use strict";var o="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform float threshold;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccuracy , but good enought for this feature.\n float _max = max(max(color.r, color.g), color.b);\n float _min = min(min(color.r, color.g), color.b);\n float brightness = (_max + _min) * 0.5;\n\n if(brightness > threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n",n=function(e){function t(t){void 0===t&&(t=.5),e.call(this,o,i),this.threshold=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={threshold:{configurable:!0}};return r.threshold.get=function(){return this.uniforms.threshold},r.threshold.set=function(e){this.uniforms.threshold=e},Object.defineProperties(t.prototype,r),t}(t.Filter),l="uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n",s=function(e){function i(i){e.call(this,o,l),"number"==typeof i&&(i={threshold:i}),i=Object.assign({threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:t.settings.RESOLUTION},i),this.bloomScale=i.bloomScale,this.brightness=i.brightness;var s=i.kernels,u=i.blur,a=i.quality,c=i.pixelSize,h=i.resolution;this._extractFilter=new n(i.threshold),this._extractFilter.resolution=h,this._blurFilter=s?new r.KawaseBlurFilter(s):new r.KawaseBlurFilter(u,a),this.pixelSize=c,this.resolution=h}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var s={resolution:{configurable:!0},threshold:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return i.prototype.apply=function(e,t,r,o,i){var n=e.getRenderTarget(!0);this._extractFilter.apply(e,t,n,!0,i);var l=e.getRenderTarget(!0);this._blurFilter.apply(e,n,l,!0,i),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=l,e.applyFilter(this,t,r,o),e.returnRenderTarget(l),e.returnRenderTarget(n)},s.resolution.get=function(){return this._resolution},s.resolution.set=function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},s.threshold.get=function(){return this._extractFilter.threshold},s.threshold.set=function(e){this._extractFilter.threshold=e},s.kernels.get=function(){return this._blurFilter.kernels},s.kernels.set=function(e){this._blurFilter.kernels=e},s.blur.get=function(){return this._blurFilter.blur},s.blur.set=function(e){this._blurFilter.blur=e},s.quality.get=function(){return this._blurFilter.quality},s.quality.set=function(e){this._blurFilter.quality=e},s.pixelSize.get=function(){return this._blurFilter.pixelSize},s.pixelSize.set=function(e){this._blurFilter.pixelSize=e},Object.defineProperties(i.prototype,s),i}(t.Filter);e.AdvancedBloomFilter=s,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-advanced-bloom.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
this.PIXI=this.PIXI||{},this.PIXI.filters=this.PIXI.filters||{};var _pixi_filter_alpha=function(t,r){"use strict";var e="varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n",i=function(t){function i(i){void 0===i&&(i=1),t.call(this,r.defaultVertex,e,{uAlpha:1}),this.alpha=i}t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i;var a={alpha:{configurable:!0}};return a.alpha.get=function(){return this.uniforms.uAlpha},a.alpha.set=function(t){this.uniforms.uAlpha=t},Object.defineProperties(i.prototype,a),i}(r.Filter);return t.AlphaFilter=i,t}({},PIXI);Object.assign(this.PIXI.filters,_pixi_filter_alpha);
|
||||
//# sourceMappingURL=filter-alpha.min.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n(e.__filters={},e.PIXI)}(this,function(e,n){"use strict";var o="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform float pixelSize;\nuniform sampler2D uSampler;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n return floor( coord / size ) * size;\n}\n\nvec2 getMod(vec2 coord, vec2 size)\n{\n return mod( coord , size) / size;\n}\n\nfloat character(float n, vec2 p)\n{\n p = floor(p*vec2(4.0, -4.0) + 2.5);\n if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;\n }\n return 0.0;\n}\n\nvoid main()\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n // get the rounded color..\n vec2 pixCoord = pixelate(coord, vec2(pixelSize));\n pixCoord = unmapCoord(pixCoord);\n\n vec4 color = texture2D(uSampler, pixCoord);\n\n // determine the character to use\n float gray = (color.r + color.g + color.b) / 3.0;\n\n float n = 65536.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n\n // get the mod..\n vec2 modd = getMod(coord, vec2(pixelSize));\n\n gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0);\n\n}",t=function(e){function n(n){void 0===n&&(n=8),e.call(this,o,r),this.size=n}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var t={size:{configurable:!0}};return t.size.get=function(){return this.uniforms.pixelSize},t.size.set=function(e){this.uniforms.pixelSize=e},Object.defineProperties(n.prototype,t),n}(n.Filter);e.AsciiFilter=t,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-ascii.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],t):t(o.__filters={},o.PIXI)}(this,function(o,t){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="precision mediump float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float transformX;\nuniform float transformY;\nuniform vec3 lightColor;\nuniform float lightAlpha;\nuniform vec3 shadowColor;\nuniform float shadowAlpha;\n\nvoid main(void) {\n vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY);\n vec4 color = texture2D(uSampler, vTextureCoord);\n float light = texture2D(uSampler, vTextureCoord - transform).a;\n float shadow = texture2D(uSampler, vTextureCoord + transform).a;\n\n color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0));\n color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0));\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n",n=function(o){function n(t){void 0===t&&(t={}),o.call(this,r,i),this.uniforms.lightColor=new Float32Array(3),this.uniforms.shadowColor=new Float32Array(3),t=Object.assign({rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},t),this.rotation=t.rotation,this.thickness=t.thickness,this.lightColor=t.lightColor,this.lightAlpha=t.lightAlpha,this.shadowColor=t.shadowColor,this.shadowAlpha=t.shadowAlpha}o&&(n.__proto__=o),n.prototype=Object.create(o&&o.prototype),n.prototype.constructor=n;var e={rotation:{configurable:!0},thickness:{configurable:!0},lightColor:{configurable:!0},lightAlpha:{configurable:!0},shadowColor:{configurable:!0},shadowAlpha:{configurable:!0}};return n.prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},e.rotation.get=function(){return this._angle/t.DEG_TO_RAD},e.rotation.set=function(o){this._angle=o*t.DEG_TO_RAD,this._updateTransform()},e.thickness.get=function(){return this._thickness},e.thickness.set=function(o){this._thickness=o,this._updateTransform()},e.lightColor.get=function(){return t.utils.rgb2hex(this.uniforms.lightColor)},e.lightColor.set=function(o){t.utils.hex2rgb(o,this.uniforms.lightColor)},e.lightAlpha.get=function(){return this.uniforms.lightAlpha},e.lightAlpha.set=function(o){this.uniforms.lightAlpha=o},e.shadowColor.get=function(){return t.utils.rgb2hex(this.uniforms.shadowColor)},e.shadowColor.set=function(o){t.utils.hex2rgb(o,this.uniforms.shadowColor)},e.shadowAlpha.get=function(){return this.uniforms.shadowAlpha},e.shadowAlpha.set=function(o){this.uniforms.shadowAlpha=o},Object.defineProperties(n.prototype,e),n}(t.Filter);o.BevelFilter=n,Object.defineProperty(o,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-bevel.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n((e=e||self).__filters={},e.PIXI)}(this,function(e,n){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="uniform float radius;\nuniform float strength;\nuniform vec2 center;\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nvoid main()\n{\n vec2 coord = vTextureCoord * filterArea.xy;\n coord -= center * dimensions.xy;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += center * dimensions.xy;\n coord /= filterArea.xy;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n gl_FragColor = color;\n}\n",o=function(e){function n(n,o,i){e.call(this,t,r),this.uniforms.dimensions=new Float32Array(2),this.center=n||[.5,.5],this.radius="number"==typeof o?o:100,this.strength="number"==typeof i?i:1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var o={radius:{configurable:!0},strength:{configurable:!0},center:{configurable:!0}};return n.prototype.apply=function(e,n,t,r){this.uniforms.dimensions[0]=n.sourceFrame.width,this.uniforms.dimensions[1]=n.sourceFrame.height,e.applyFilter(this,n,t,r)},o.radius.get=function(){return this.uniforms.radius},o.radius.set=function(e){this.uniforms.radius=e},o.strength.get=function(){return this.uniforms.strength},o.strength.set=function(e){this.uniforms.strength=e},o.center.get=function(){return this.uniforms.center},o.center.set=function(e){this.uniforms.center=e},Object.defineProperties(n.prototype,o),n}(n.Filter);e.BulgePinchFilter=o,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-bulge-pinch.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
var __filters=function(e,i,t){"use strict";var o="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D colorMap;\nuniform float _mix;\nuniform float _size;\nuniform float _sliceSize;\nuniform float _slicePixelSize;\nuniform float _sliceInnerSize;\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord.xy);\n\n vec4 adjusted;\n if (color.a > 0.0) {\n color.rgb /= color.a;\n float innerWidth = _size - 1.0;\n float zSlice0 = min(floor(color.b * innerWidth), innerWidth);\n float zSlice1 = min(zSlice0 + 1.0, innerWidth);\n float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize;\n float s0 = xOffset + (zSlice0 * _sliceSize);\n float s1 = xOffset + (zSlice1 * _sliceSize);\n float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize);\n vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset));\n vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset));\n float zOffset = fract(color.b * innerWidth);\n adjusted = mix(slice0Color, slice1Color, zOffset);\n\n color.rgb *= color.a;\n }\n gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a);\n\n}",s=function(e){function s(i,t,s){void 0===t&&(t=!1),void 0===s&&(s=1),e.call(this,o,r),this._size=0,this._sliceSize=0,this._slicePixelSize=0,this._sliceInnerSize=0,this._scaleMode=null,this._nearest=!1,this.nearest=t,this.mix=s,this.colorMap=i}e&&(s.__proto__=e),s.prototype=Object.create(e&&e.prototype),s.prototype.constructor=s;var n={colorSize:{configurable:!0},colorMap:{configurable:!0},nearest:{configurable:!0}};return s.prototype.apply=function(e,i,t,o){this.uniforms._mix=this.mix,e.applyFilter(this,i,t,o)},n.colorSize.get=function(){return this._size},n.colorMap.get=function(){return this._colorMap},n.colorMap.set=function(e){e instanceof i.Texture||(e=i.Texture.from(e)),e&&e.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=!1,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e},n.nearest.get=function(){return this._nearest},n.nearest.set=function(e){this._nearest=e,this._scaleMode=e?t.SCALE_MODES.NEAREST:t.SCALE_MODES.LINEAR;var i=this._colorMap;i&&i.baseTexture&&(i.baseTexture._glTextures={},i.baseTexture.scaleMode=this._scaleMode,i.baseTexture.mipmap=!1,i._updateID++,i.baseTexture.emit("update",i.baseTexture))},s.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit("update",e.baseTexture),this.colorMap=e)},s.prototype.destroy=function(i){this._colorMap&&this._colorMap.destroy(i),e.prototype.destroy.call(this)},Object.defineProperties(s.prototype,n),s}(i.Filter);return e.ColorMapFilter=s,e}({},PIXI,PIXI);Object.assign(PIXI.filters,__filters);
|
||||
//# sourceMappingURL=filter-color-map.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(o,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],r):r((o=o||self).__filters={},o.PIXI)}(this,function(o,r){"use strict";var e="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec3 originalColor;\nuniform vec3 newColor;\nuniform float epsilon;\nvoid main(void) {\n vec4 currentColor = texture2D(uSampler, vTextureCoord);\n vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001));\n float colorDistance = length(colorDiff);\n float doReplace = step(colorDistance, epsilon);\n gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a);\n}\n",n=function(o){function n(r,n,t){void 0===r&&(r=16711680),void 0===n&&(n=0),void 0===t&&(t=.4),o.call(this,e,i),this.uniforms.originalColor=new Float32Array(3),this.uniforms.newColor=new Float32Array(3),this.originalColor=r,this.newColor=n,this.epsilon=t}o&&(n.__proto__=o),n.prototype=Object.create(o&&o.prototype),n.prototype.constructor=n;var t={originalColor:{configurable:!0},newColor:{configurable:!0},epsilon:{configurable:!0}};return t.originalColor.set=function(o){var e=this.uniforms.originalColor;"number"==typeof o?(r.utils.hex2rgb(o,e),this._originalColor=o):(e[0]=o[0],e[1]=o[1],e[2]=o[2],this._originalColor=r.utils.rgb2hex(e))},t.originalColor.get=function(){return this._originalColor},t.newColor.set=function(o){var e=this.uniforms.newColor;"number"==typeof o?(r.utils.hex2rgb(o,e),this._newColor=o):(e[0]=o[0],e[1]=o[1],e[2]=o[2],this._newColor=r.utils.rgb2hex(e))},t.newColor.get=function(){return this._newColor},t.epsilon.set=function(o){this.uniforms.epsilon=o},t.epsilon.get=function(){return this.uniforms.epsilon},Object.defineProperties(n.prototype,t),n}(r.Filter);o.ColorReplaceFilter=n,Object.defineProperty(o,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-color-replace.js.map
|
||||
|
@@ -10,4 +10,3 @@
|
||||
* Modified the minified file to work on pixi4 by renaming filterFrame to sourceFrame below
|
||||
*/
|
||||
var __filters=function(n,i){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec2 dimensions;\n\nconst float SQRT_2 = 1.414213;\n\nconst float light = 1.0;\n\nuniform float curvature;\nuniform float lineWidth;\nuniform float lineContrast;\nuniform bool verticalLine;\nuniform float noise;\nuniform float noiseSize;\n\nuniform float vignetting;\nuniform float vignettingAlpha;\nuniform float vignettingBlur;\n\nuniform float seed;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n vec2 dir = vec2(coord - vec2(0.5, 0.5));\n\n float _c = curvature > 0. ? curvature : 1.;\n float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.;\n vec2 uv = dir * k;\n\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n vec3 rgb = gl_FragColor.rgb;\n\n\n if (noise > 0.0 && noiseSize > 0.0)\n {\n pixelCoord.x = floor(pixelCoord.x / noiseSize);\n pixelCoord.y = floor(pixelCoord.y / noiseSize);\n float _noise = rand(pixelCoord * noiseSize * seed) - 0.5;\n rgb += _noise * noise;\n }\n\n if (lineWidth > 0.0) {\n float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c;\n float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast;\n rgb *= j;\n float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.);\n rgb *= 0.99 + ceil(segment) * 0.015;\n }\n\n if (vignetting > 0.0)\n {\n float outter = SQRT_2 - vignetting * SQRT_2;\n float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0);\n rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha);\n }\n\n gl_FragColor.rgb = rgb;\n}\n",r=function(n){function i(i){n.call(this,t,e),this.uniforms.dimensions=new Float32Array(2),this.time=0,this.seed=0,Object.assign(this,{curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},i)}n&&(i.__proto__=n),i.prototype=Object.create(n&&n.prototype),i.prototype.constructor=i;var r={curvature:{configurable:!0},lineWidth:{configurable:!0},lineContrast:{configurable:!0},verticalLine:{configurable:!0},noise:{configurable:!0},noiseSize:{configurable:!0},vignetting:{configurable:!0},vignettingAlpha:{configurable:!0},vignettingBlur:{configurable:!0}};return i.prototype.apply=function(n,i,t,e){this.uniforms.dimensions[0]=i.sourceFrame.width,this.uniforms.dimensions[1]=i.sourceFrame.height,this.uniforms.seed=this.seed,this.uniforms.time=this.time,n.applyFilter(this,i,t,e)},r.curvature.set=function(n){this.uniforms.curvature=n},r.curvature.get=function(){return this.uniforms.curvature},r.lineWidth.set=function(n){this.uniforms.lineWidth=n},r.lineWidth.get=function(){return this.uniforms.lineWidth},r.lineContrast.set=function(n){this.uniforms.lineContrast=n},r.lineContrast.get=function(){return this.uniforms.lineContrast},r.verticalLine.set=function(n){this.uniforms.verticalLine=n},r.verticalLine.get=function(){return this.uniforms.verticalLine},r.noise.set=function(n){this.uniforms.noise=n},r.noise.get=function(){return this.uniforms.noise},r.noiseSize.set=function(n){this.uniforms.noiseSize=n},r.noiseSize.get=function(){return this.uniforms.noiseSize},r.vignetting.set=function(n){this.uniforms.vignetting=n},r.vignetting.get=function(){return this.uniforms.vignetting},r.vignettingAlpha.set=function(n){this.uniforms.vignettingAlpha=n},r.vignettingAlpha.get=function(){return this.uniforms.vignettingAlpha},r.vignettingBlur.set=function(n){this.uniforms.vignettingBlur=n},r.vignettingBlur.get=function(){return this.uniforms.vignettingBlur},Object.defineProperties(i.prototype,r),i}(i.Filter);return n.CRTFilter=r,n}({},PIXI);Object.assign(PIXI.filters,__filters);
|
||||
//# sourceMappingURL=filter-crt.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n((e=e||self).__filters={},e.PIXI)}(this,function(e,n){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",o="precision mediump float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec4 filterArea;\nuniform sampler2D uSampler;\n\nuniform float angle;\nuniform float scale;\n\nfloat pattern()\n{\n float s = sin(angle), c = cos(angle);\n vec2 tex = vTextureCoord * filterArea.xy;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float average = (color.r + color.g + color.b) / 3.0;\n gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);\n}\n",r=function(e){function n(n,r){void 0===n&&(n=1),void 0===r&&(r=5),e.call(this,t,o),this.scale=n,this.angle=r}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var r={scale:{configurable:!0},angle:{configurable:!0}};return r.scale.get=function(){return this.uniforms.scale},r.scale.set=function(e){this.uniforms.scale=e},r.angle.get=function(){return this.uniforms.angle},r.angle.set=function(e){this.uniforms.angle=e},Object.defineProperties(n.prototype,r),n}(n.Filter);e.DotFilter=r,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-dot.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("@pixi/filter-kawase-blur"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","@pixi/filter-kawase-blur","pixi.js"],i):i(t.__filters={},t.PIXI.filters,t.PIXI)}(this,function(t,i,e){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",n="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform vec3 color;\nvoid main(void){\n vec4 sample = texture2D(uSampler, vTextureCoord);\n\n // Un-premultiply alpha before applying the color\n if (sample.a > 0.0) {\n sample.rgb /= sample.a;\n }\n\n // Premultiply alpha again\n sample.rgb = color.rgb * sample.a;\n\n // alpha user alpha\n sample *= alpha;\n\n gl_FragColor = sample;\n}",o=function(t){function o(o){o&&o.constructor!==Object&&(console.warn("DropShadowFilter now uses options instead of (rotation, distance, blur, color, alpha)"),o={rotation:o},void 0!==arguments[1]&&(o.distance=arguments[1]),void 0!==arguments[2]&&(o.blur=arguments[2]),void 0!==arguments[3]&&(o.color=arguments[3]),void 0!==arguments[4]&&(o.alpha=arguments[4])),o=Object.assign({rotation:45,distance:5,color:0,alpha:.5,shadowOnly:!1,kernels:null,blur:2,quality:3,pixelSize:1,resolution:e.settings.RESOLUTION},o),t.call(this);var l=o.kernels,a=o.blur,s=o.quality,u=o.pixelSize,c=o.resolution;this._tintFilter=new e.Filter(r,n),this._tintFilter.uniforms.color=new Float32Array(4),this._tintFilter.resolution=c,this._blurFilter=l?new i.KawaseBlurFilter(l):new i.KawaseBlurFilter(a,s),this.pixelSize=u,this.resolution=c,this.targetTransform=new e.Matrix;var p=o.shadowOnly,h=o.rotation,f=o.distance,d=o.alpha,g=o.color;this.shadowOnly=p,this.rotation=h,this.distance=f,this.alpha=d,this.color=g,this._updatePadding()}t&&(o.__proto__=t),o.prototype=Object.create(t&&t.prototype),o.prototype.constructor=o;var l={resolution:{configurable:!0},distance:{configurable:!0},rotation:{configurable:!0},alpha:{configurable:!0},color:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return o.prototype.apply=function(t,i,e,r){var n=t.getRenderTarget();n.transform=this.targetTransform,this._tintFilter.apply(t,i,n,!0),n.transform=null,this._blurFilter.apply(t,n,e,r),!0!==this.shadowOnly&&t.applyFilter(this,i,e,!1),t.returnRenderTarget(n)},o.prototype._updatePadding=function(){this.padding=this.distance+2*this.blur},o.prototype._updateTargetTransform=function(){this.targetTransform.tx=this.distance*Math.cos(this.angle),this.targetTransform.ty=this.distance*Math.sin(this.angle)},l.resolution.get=function(){return this._resolution},l.resolution.set=function(t){this._resolution=t,this._tintFilter&&(this._tintFilter.resolution=t),this._blurFilter&&(this._blurFilter.resolution=t)},l.distance.get=function(){return this._distance},l.distance.set=function(t){this._distance=t,this._updatePadding(),this._updateTargetTransform()},l.rotation.get=function(){return this.angle/e.DEG_TO_RAD},l.rotation.set=function(t){this.angle=t*e.DEG_TO_RAD,this._updateTargetTransform()},l.alpha.get=function(){return this._tintFilter.uniforms.alpha},l.alpha.set=function(t){this._tintFilter.uniforms.alpha=t},l.color.get=function(){return e.utils.rgb2hex(this._tintFilter.uniforms.color)},l.color.set=function(t){e.utils.hex2rgb(t,this._tintFilter.uniforms.color)},l.kernels.get=function(){return this._blurFilter.kernels},l.kernels.set=function(t){this._blurFilter.kernels=t},l.blur.get=function(){return this._blurFilter.blur},l.blur.set=function(t){this._blurFilter.blur=t,this._updatePadding()},l.quality.get=function(){return this._blurFilter.quality},l.quality.set=function(t){this._blurFilter.quality=t},l.pixelSize.get=function(){return this._blurFilter.pixelSize},l.pixelSize.set=function(t){this._blurFilter.pixelSize=t},Object.defineProperties(o.prototype,l),o}(e.Filter);t.DropShadowFilter=o,Object.defineProperty(t,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-drop-shadow.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],t):t(o.__filters={},o.PIXI)}(this,function(o,t){"use strict";var n="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nuniform float distance;\nuniform float outerStrength;\nuniform float innerStrength;\nuniform vec4 glowColor;\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nconst float PI = 3.14159265358979323846264;\n\nvoid main(void) {\n vec2 px = vec2(1.0 / filterArea.x, 1.0 / filterArea.y);\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\n vec4 curColor;\n float totalAlpha = 0.0;\n float maxTotalAlpha = 0.0;\n float cosAngle;\n float sinAngle;\n vec2 displaced;\n for (float angle = 0.0; angle <= PI * 2.0; angle += %QUALITY_DIST%) {\n cosAngle = cos(angle);\n sinAngle = sin(angle);\n for (float curDistance = 1.0; curDistance <= %DIST%; curDistance++) {\n displaced.x = vTextureCoord.x + cosAngle * curDistance * px.x;\n displaced.y = vTextureCoord.y + sinAngle * curDistance * px.y;\n curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));\n totalAlpha += (distance - curDistance) * curColor.a;\n maxTotalAlpha += (distance - curDistance);\n }\n }\n maxTotalAlpha = max(maxTotalAlpha, 0.0001);\n\n ownColor.a = max(ownColor.a, 0.0001);\n ownColor.rgb = ownColor.rgb / ownColor.a;\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * outerStrength * (1. - ownColor.a);\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * innerStrength * ownColor.a;\n float resultAlpha = (ownColor.a + outerGlowAlpha);\n gl_FragColor = vec4(mix(mix(ownColor.rgb, glowColor.rgb, innerGlowAlpha / ownColor.a), glowColor.rgb, outerGlowAlpha / resultAlpha) * resultAlpha, resultAlpha);\n}\n",r=function(o){function r(t,r,i,l,a){void 0===t&&(t=10),void 0===r&&(r=4),void 0===i&&(i=0),void 0===l&&(l=16777215),void 0===a&&(a=.1),o.call(this,n,e.replace(/%QUALITY_DIST%/gi,""+(1/a/t).toFixed(7)).replace(/%DIST%/gi,""+t.toFixed(7))),this.uniforms.glowColor=new Float32Array([0,0,0,1]),this.distance=t,this.color=l,this.outerStrength=r,this.innerStrength=i}o&&(r.__proto__=o),r.prototype=Object.create(o&&o.prototype),r.prototype.constructor=r;var i={color:{configurable:!0},distance:{configurable:!0},outerStrength:{configurable:!0},innerStrength:{configurable:!0}};return i.color.get=function(){return t.utils.rgb2hex(this.uniforms.glowColor)},i.color.set=function(o){t.utils.hex2rgb(o,this.uniforms.glowColor)},i.distance.get=function(){return this.uniforms.distance},i.distance.set=function(o){this.uniforms.distance=o},i.outerStrength.get=function(){return this.uniforms.outerStrength},i.outerStrength.set=function(o){this.uniforms.outerStrength=o},i.innerStrength.get=function(){return this.uniforms.innerStrength},i.innerStrength.set=function(o){this.uniforms.innerStrength=o},Object.defineProperties(r.prototype,i),r}(t.Filter);o.GlowFilter=r,Object.defineProperty(o,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-glow.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],t):t(e.__filters={},e.PIXI)}(this,function(e,t){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample top right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}",o="\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample top right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}\n",n=function(e){function n(n,l,u){void 0===n&&(n=4),void 0===l&&(l=3),void 0===u&&(u=!1),e.call(this,r,u?o:i),this.uniforms.uOffset=new Float32Array(2),this._pixelSize=new t.Point,this.pixelSize=1,this._clamp=u,this._kernels=null,Array.isArray(n)?this.kernels=n:(this._blur=n,this.quality=l)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var l={kernels:{configurable:!0},clamp:{configurable:!0},pixelSize:{configurable:!0},quality:{configurable:!0},blur:{configurable:!0}};return n.prototype.apply=function(e,t,r,i){var o,n=this.pixelSize.x/t.size.width,l=this.pixelSize.y/t.size.height;if(1===this._quality||0===this._blur)o=this._kernels[0]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,t,r,i);else{for(var u,s=e.getRenderTarget(!0),f=t,a=s,p=this._quality-1,x=0;x<p;x++)o=this._kernels[x]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,f,a,!0),u=f,f=a,a=u;o=this._kernels[p]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,f,r,i),e.returnRenderTarget(s)}},n.prototype._generateKernels=function(){var e=this._blur,t=this._quality,r=[e];if(e>0)for(var i=e,o=e/t,n=1;n<t;n++)i-=o,r.push(i);this._kernels=r},l.kernels.get=function(){return this._kernels},l.kernels.set=function(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max.apply(Math,e)):(this._kernels=[0],this._quality=1)},l.clamp.get=function(){return this._clamp},l.pixelSize.set=function(e){"number"==typeof e?(this._pixelSize.x=e,this._pixelSize.y=e):Array.isArray(e)?(this._pixelSize.x=e[0],this._pixelSize.y=e[1]):e instanceof t.Point?(this._pixelSize.x=e.x,this._pixelSize.y=e.y):(this._pixelSize.x=1,this._pixelSize.y=1)},l.pixelSize.get=function(){return this._pixelSize},l.quality.get=function(){return this._quality},l.quality.set=function(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()},l.blur.get=function(){return this._blur},l.blur.set=function(e){this._blur=e,this._generateKernels()},Object.defineProperties(n.prototype,l),n}(t.Filter);e.KawaseBlurFilter=n,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-kawase-blur.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],o):o(e.__filters={},e.PIXI)}(this,function(e,o){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 thickness;\nuniform vec4 outlineColor;\nuniform vec4 filterClamp;\n\nconst float DOUBLE_PI = 3.14159265358979323846264 * 2.;\n\nvoid main(void) {\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\n vec4 curColor;\n float maxAlpha = 0.;\n vec2 displaced;\n for (float angle = 0.; angle <= DOUBLE_PI; angle += ${angleStep}) {\n displaced.x = vTextureCoord.x + thickness.x * cos(angle);\n displaced.y = vTextureCoord.y + thickness.y * sin(angle);\n curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));\n maxAlpha = max(maxAlpha, curColor.a);\n }\n float resultAlpha = max(maxAlpha, ownColor.a);\n gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);\n}\n",n=function(e){function n(o,i,l){void 0===o&&(o=1),void 0===i&&(i=0),void 0===l&&(l=.1);var s=Math.max(l*n.MAX_SAMPLES,n.MIN_SAMPLES),a=(2*Math.PI/s).toFixed(7);e.call(this,t,r.replace(/\$\{angleStep\}/,a)),this.uniforms.thickness=new Float32Array([0,0]),this.thickness=o,this.uniforms.outlineColor=new Float32Array([0,0,0,1]),this.color=i,this.quality=l}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={color:{configurable:!0}};return n.prototype.apply=function(e,o,t,r){this.uniforms.thickness[0]=this.thickness/o.size.width,this.uniforms.thickness[1]=this.thickness/o.size.height,e.applyFilter(this,o,t,r)},i.color.get=function(){return o.utils.rgb2hex(this.uniforms.outlineColor)},i.color.set=function(e){o.utils.hex2rgb(e,this.uniforms.outlineColor)},Object.defineProperties(n.prototype,i),n}(o.Filter);n.MIN_SAMPLES=1,n.MAX_SAMPLES=100,e.OutlineFilter=n,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-outline.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
var __filters=function(e,o){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",n="precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform vec2 size;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 pixelate(vec2 coord, vec2 size)\n{\n\treturn floor( coord / size ) * size;\n}\n\nvoid main(void)\n{\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = pixelate(coord, size);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord);\n}\n",t=function(e){function o(o){void 0===o&&(o=10),e.call(this,r,n),this.size=o}e&&(o.__proto__=e),o.prototype=Object.create(e&&e.prototype),o.prototype.constructor=o;var t={size:{configurable:!0}};return t.size.get=function(){return this.uniforms.size},t.size.set=function(e){"number"==typeof e&&(e=[e,e]),this.uniforms.size=e},Object.defineProperties(o.prototype,t),o}(o.Filter);return e.PixelateFilter=t,e}({},PIXI);Object.assign(PIXI.filters,__filters);
|
||||
//# sourceMappingURL=filter-pixelate.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n((e=e||self).__filters={},e.PIXI)}(this,function(e,n){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform float uRadian;\nuniform vec2 uCenter;\nuniform float uRadius;\nuniform int uKernelSize;\n\nconst int MAX_KERNEL_SIZE = 2048;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n if (uKernelSize == 0)\n {\n gl_FragColor = color;\n return;\n }\n\n float aspect = filterArea.y / filterArea.x;\n vec2 center = uCenter.xy / filterArea.xy;\n float gradient = uRadius / filterArea.x * 0.3;\n float radius = uRadius / filterArea.x - gradient * 0.5;\n int k = uKernelSize - 1;\n\n vec2 coord = vTextureCoord;\n vec2 dir = vec2(center - coord);\n float dist = length(vec2(dir.x, dir.y * aspect));\n\n float radianStep = uRadian;\n if (radius >= 0.0 && dist > radius) {\n float delta = dist - radius;\n float gap = gradient;\n float scale = 1.0 - abs(delta / gap);\n if (scale <= 0.0) {\n gl_FragColor = color;\n return;\n }\n radianStep *= scale;\n }\n radianStep /= float(k);\n\n float s = sin(radianStep);\n float c = cos(radianStep);\n mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c));\n\n for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) {\n if (i == k) {\n break;\n }\n\n coord -= center;\n coord.y *= aspect;\n coord = rotationMatrix * coord;\n coord.y /= aspect;\n coord += center;\n\n vec4 sample = texture2D(uSampler, coord);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample;\n }\n\n gl_FragColor = color / float(uKernelSize);\n}\n",i=function(e){function n(n,i,o,a){void 0===n&&(n=0),void 0===i&&(i=[0,0]),void 0===o&&(o=5),void 0===a&&(a=-1),e.call(this,t,r),this._angle=0,this.angle=n,this.center=i,this.kernelSize=o,this.radius=a}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={angle:{configurable:!0},center:{configurable:!0},radius:{configurable:!0}};return n.prototype.apply=function(e,n,t,r){this.uniforms.uKernelSize=0!==this._angle?this.kernelSize:0,e.applyFilter(this,n,t,r)},i.angle.set=function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},i.angle.get=function(){return this._angle},i.center.get=function(){return this.uniforms.uCenter},i.center.set=function(e){this.uniforms.uCenter=e},i.radius.get=function(){return this.uniforms.uRadius},i.radius.set=function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},Object.defineProperties(n.prototype,i),n}(n.Filter);e.RadialBlurFilter=i,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-radial-blur.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n(e.__filters={},e.PIXI)}(this,function(e,n){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",t="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nuniform bool mirror;\nuniform float boundary;\nuniform vec2 amplitude;\nuniform vec2 waveLength;\nuniform vec2 alpha;\nuniform float time;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main(void)\n{\n vec2 pixelCoord = vTextureCoord.xy * filterArea.xy;\n vec2 coord = pixelCoord / dimensions;\n\n if (coord.y < boundary) {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n\n float k = (coord.y - boundary) / (1. - boundary + 0.0001);\n float areaY = boundary * dimensions.y / filterArea.y;\n float v = areaY + areaY - vTextureCoord.y;\n float y = mirror ? v : vTextureCoord.y;\n\n float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x;\n float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y;\n float _alpha = (alpha.y - alpha.x) * k + alpha.x;\n\n float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude;\n x = clamp(x, filterClamp.x, filterClamp.z);\n\n vec4 color = texture2D(uSampler, vec2(x, y));\n\n gl_FragColor = color * _alpha;\n}\n",o=function(e){function n(n){e.call(this,r,t),Object.assign(this,{mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},n)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var o={mirror:{configurable:!0},boundary:{configurable:!0},amplitude:{configurable:!0},waveLength:{configurable:!0},alpha:{configurable:!0}};return n.prototype.apply=function(e,n,r,t){this.uniforms.dimensions[0]=n.sourceFrame.width,this.uniforms.dimensions[1]=n.sourceFrame.height,this.uniforms.time=this.time,e.applyFilter(this,n,r,t)},o.mirror.set=function(e){this.uniforms.mirror=e},o.mirror.get=function(){return this.uniforms.mirror},o.boundary.set=function(e){this.uniforms.boundary=e},o.boundary.get=function(){return this.uniforms.boundary},o.amplitude.set=function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},o.amplitude.get=function(){return this.uniforms.amplitude},o.waveLength.set=function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},o.waveLength.get=function(){return this.uniforms.waveLength},o.alpha.set=function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},o.alpha.get=function(){return this.uniforms.alpha},Object.defineProperties(n.prototype,o),n}(n.Filter);e.ReflectionFilter=o,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this.__filters);
|
||||
//# sourceMappingURL=filter-reflection.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],r):r(e.__filters={},e.PIXI)}(this,function(e,r){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",n="precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nvoid main(void)\n{\n gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r;\n gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g;\n gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b;\n gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;\n}\n",o=function(e){function r(r,o,i){void 0===r&&(r=[-10,0]),void 0===o&&(o=[0,10]),void 0===i&&(i=[0,0]),e.call(this,t,n),this.red=r,this.green=o,this.blue=i}e&&(r.__proto__=e),r.prototype=Object.create(e&&e.prototype),r.prototype.constructor=r;var o={red:{configurable:!0},green:{configurable:!0},blue:{configurable:!0}};return o.red.get=function(){return this.uniforms.red},o.red.set=function(e){this.uniforms.red=e},o.green.get=function(){return this.uniforms.green},o.green.set=function(e){this.uniforms.green=e},o.blue.get=function(){return this.uniforms.blue},o.blue.set=function(e){this.uniforms.blue=e},Object.defineProperties(r.prototype,o),r}(r.Filter);e.RGBSplitFilter=o,Object.defineProperty(e,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-rgb-split.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],e):e(t.__filters={},t.PIXI)}(this,function(t,e){"use strict";var i="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float blur;\nuniform float gradientBlur;\nuniform vec2 start;\nuniform vec2 end;\nuniform vec2 delta;\nuniform vec2 texSize;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur;\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n color /= total;\n color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n",n=function(t){function n(n,o,s,l){void 0===n&&(n=100),void 0===o&&(o=600),void 0===s&&(s=null),void 0===l&&(l=null),t.call(this,i,r),this.uniforms.blur=n,this.uniforms.gradientBlur=o,this.uniforms.start=s||new e.Point(0,window.innerHeight/2),this.uniforms.end=l||new e.Point(600,window.innerHeight/2),this.uniforms.delta=new e.Point(30,30),this.uniforms.texSize=new e.Point(window.innerWidth,window.innerHeight),this.updateDelta()}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var o={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return n.prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},o.blur.get=function(){return this.uniforms.blur},o.blur.set=function(t){this.uniforms.blur=t},o.gradientBlur.get=function(){return this.uniforms.gradientBlur},o.gradientBlur.set=function(t){this.uniforms.gradientBlur=t},o.start.get=function(){return this.uniforms.start},o.start.set=function(t){this.uniforms.start=t,this.updateDelta()},o.end.get=function(){return this.uniforms.end},o.end.set=function(t){this.uniforms.end=t,this.updateDelta()},Object.defineProperties(n.prototype,o),n}(e.Filter),o=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.updateDelta=function(){var t=this.uniforms.end.x-this.uniforms.start.x,e=this.uniforms.end.y-this.uniforms.start.y,i=Math.sqrt(t*t+e*e);this.uniforms.delta.x=t/i,this.uniforms.delta.y=e/i},e}(n),s=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.updateDelta=function(){var t=this.uniforms.end.x-this.uniforms.start.x,e=this.uniforms.end.y-this.uniforms.start.y,i=Math.sqrt(t*t+e*e);this.uniforms.delta.x=-e/i,this.uniforms.delta.y=t/i},e}(n),l=function(t){function e(e,i,r,n){void 0===e&&(e=100),void 0===i&&(i=600),void 0===r&&(r=null),void 0===n&&(n=null),t.call(this),this.tiltShiftXFilter=new o(e,i,r,n),this.tiltShiftYFilter=new s(e,i,r,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={blur:{configurable:!0},gradientBlur:{configurable:!0},start:{configurable:!0},end:{configurable:!0}};return e.prototype.apply=function(t,e,i){var r=t.getRenderTarget(!0);this.tiltShiftXFilter.apply(t,e,r),this.tiltShiftYFilter.apply(t,r,i),t.returnRenderTarget(r)},i.blur.get=function(){return this.tiltShiftXFilter.blur},i.blur.set=function(t){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=t},i.gradientBlur.get=function(){return this.tiltShiftXFilter.gradientBlur},i.gradientBlur.set=function(t){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=t},i.start.get=function(){return this.tiltShiftXFilter.start},i.start.set=function(t){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=t},i.end.get=function(){return this.tiltShiftXFilter.end},i.end.set=function(t){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=t},Object.defineProperties(e.prototype,i),e}(e.Filter);t.TiltShiftFilter=l,t.TiltShiftXFilter=o,t.TiltShiftYFilter=s,t.TiltShiftAxisFilter=n,Object.defineProperty(t,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-tilt-shift.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(o,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],n):n((o=o||self).__filters={},o.PIXI)}(this,function(o,n){"use strict";var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n",t=function(o){function n(n,t,i){void 0===n&&(n=200),void 0===t&&(t=4),void 0===i&&(i=20),o.call(this,r,e),this.radius=n,this.angle=t,this.padding=i}o&&(n.__proto__=o),n.prototype=Object.create(o&&o.prototype),n.prototype.constructor=n;var t={offset:{configurable:!0},radius:{configurable:!0},angle:{configurable:!0}};return t.offset.get=function(){return this.uniforms.offset},t.offset.set=function(o){this.uniforms.offset=o},t.radius.get=function(){return this.uniforms.radius},t.radius.set=function(o){this.uniforms.radius=o},t.angle.get=function(){return this.uniforms.angle},t.angle.set=function(o){this.uniforms.angle=o},Object.defineProperties(n.prototype,t),n}(n.Filter);o.TwistFilter=t,Object.defineProperty(o,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-twist.js.map
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*/
|
||||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","pixi.js"],e):e(n.__filters={},n.PIXI)}(this,function(n,e){"use strict";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\nuniform vec2 uCenter;\nuniform float uStrength;\nuniform float uInnerRadius;\nuniform float uRadius;\n\nconst float MAX_KERNEL_SIZE = 32.0;\n\nfloat random(vec3 scale, float seed) {\n // use the fragment position for a different seed per-pixel\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main() {\n\n float minGradient = uInnerRadius * 0.3;\n float innerRadius = (uInnerRadius + minGradient * 0.5) / filterArea.x;\n\n float gradient = uRadius * 0.3;\n float radius = (uRadius - gradient * 0.5) / filterArea.x;\n\n float countLimit = MAX_KERNEL_SIZE;\n\n vec2 dir = vec2(uCenter.xy / filterArea.xy - vTextureCoord);\n float dist = length(vec2(dir.x, dir.y * filterArea.y / filterArea.x));\n\n float strength = uStrength;\n\n float delta = 0.0;\n float gap;\n if (dist < innerRadius) {\n delta = innerRadius - dist;\n gap = minGradient;\n } else if (radius >= 0.0 && dist > radius) { // radius < 0 means it's infinity\n delta = dist - radius;\n gap = gradient;\n }\n\n if (delta > 0.0) {\n float normalCount = gap / filterArea.x;\n delta = (normalCount - delta) / normalCount;\n countLimit *= delta;\n strength *= delta;\n if (countLimit < 1.0)\n {\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n return;\n }\n }\n\n // randomize the lookup values to hide the fixed number of samples\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n float total = 0.0;\n vec4 color = vec4(0.0);\n\n dir *= strength;\n\n for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) {\n float percent = (t + offset) / MAX_KERNEL_SIZE;\n float weight = 4.0 * (percent - percent * percent);\n vec2 p = vTextureCoord + dir * percent;\n vec4 sample = texture2D(uSampler, p);\n\n // switch to pre-multiplied alpha to correctly blur transparent images\n // sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n\n if (t > countLimit){\n break;\n }\n }\n\n color /= total;\n // switch back from pre-multiplied alpha\n color.rgb /= color.a + 0.00001;\n\n gl_FragColor = color;\n}\n",i=function(n){function e(e,i,o,a){void 0===e&&(e=.1),void 0===i&&(i=[0,0]),void 0===o&&(o=0),void 0===a&&(a=-1),n.call(this,t,r),this.center=i,this.strength=e,this.innerRadius=o,this.radius=a}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var i={center:{configurable:!0},strength:{configurable:!0},innerRadius:{configurable:!0},radius:{configurable:!0}};return i.center.get=function(){return this.uniforms.uCenter},i.center.set=function(n){this.uniforms.uCenter=n},i.strength.get=function(){return this.uniforms.uStrength},i.strength.set=function(n){this.uniforms.uStrength=n},i.innerRadius.get=function(){return this.uniforms.uInnerRadius},i.innerRadius.set=function(n){this.uniforms.uInnerRadius=n},i.radius.get=function(){return this.uniforms.uRadius},i.radius.set=function(n){(n<0||n===1/0)&&(n=-1),this.uniforms.uRadius=n},Object.defineProperties(e.prototype,i),e}(e.Filter);n.ZoomBlurFilter=i,Object.defineProperty(n,"__esModule",{value:!0})}),Object.assign(PIXI.filters,this?this.__filters:__filters);
|
||||
//# sourceMappingURL=filter-zoom-blur.js.map
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,19 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function (
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
'MyDummyExtension',
|
||||
@@ -22,7 +34,7 @@ module.exports = {
|
||||
);
|
||||
|
||||
// Declare effects:
|
||||
const dumyEffect = extension
|
||||
const dummyEffect = extension
|
||||
.addEffect('DummyEffect')
|
||||
.setFullName(_('Dummy effect example'))
|
||||
.setDescription(
|
||||
@@ -31,37 +43,33 @@ module.exports = {
|
||||
)
|
||||
)
|
||||
.addIncludeFile('Extensions/ExampleJsExtension/dummyeffect.js');
|
||||
const dumyEffectProperties = dumyEffect.getProperties();
|
||||
dumyEffectProperties.set(
|
||||
'opacity',
|
||||
new gd.PropertyDescriptor(/* defaultValue= */ '1')
|
||||
.setLabel(_('Opacity of the effect (between 0 and 1)'))
|
||||
.setType('number')
|
||||
.setDescription(_('This is an optional description.'))
|
||||
);
|
||||
dumyEffectProperties.set(
|
||||
'someImage',
|
||||
new gd.PropertyDescriptor(/* defaultValue= */ '')
|
||||
.setLabel(
|
||||
_("Image resource (won't be used, just for demonstration purpose)")
|
||||
)
|
||||
.setType('resource')
|
||||
.addExtraInfo('image')
|
||||
);
|
||||
dumyEffectProperties.set(
|
||||
'someColor',
|
||||
new gd.PropertyDescriptor(/* defaultValue= */ '#0022FF')
|
||||
.setLabel(_("Color (won't be used, just for demonstration purpose)"))
|
||||
.setType('color')
|
||||
.setDescription(_('Another optional description.'))
|
||||
);
|
||||
dumyEffectProperties.set(
|
||||
'someBoolean',
|
||||
new gd.PropertyDescriptor(/* defaultValue= */ 'true')
|
||||
.setLabel(_('Some setting to enable or not for the effect'))
|
||||
.setType('boolean')
|
||||
.setDescription(_('And some *optional* description.'))
|
||||
);
|
||||
const dummyEffectProperties = dummyEffect.getProperties();
|
||||
dummyEffectProperties
|
||||
.getOrCreate('opacity')
|
||||
.setValue('1')
|
||||
.setLabel(_('Opacity of the effect (between 0 and 1)'))
|
||||
.setType('number')
|
||||
.setDescription(_('This is an optional description.'));
|
||||
dummyEffectProperties
|
||||
.getOrCreate('someImage')
|
||||
.setValue('')
|
||||
.setLabel(
|
||||
_("Image resource (won't be used, just for demonstration purpose)")
|
||||
)
|
||||
.setType('resource')
|
||||
.addExtraInfo('image');
|
||||
dummyEffectProperties
|
||||
.getOrCreate('someColor')
|
||||
.setValue('#0022FF')
|
||||
.setLabel(_("Color (won't be used, just for demonstration purpose)"))
|
||||
.setType('color')
|
||||
.setDescription(_('Another optional description.'));
|
||||
dummyEffectProperties
|
||||
.getOrCreate('someBoolean')
|
||||
.setValue('true')
|
||||
.setLabel(_('Some setting to enable or not for the effect'))
|
||||
.setType('boolean')
|
||||
.setDescription(_('And some *optional* description.'));
|
||||
|
||||
// Declare conditions, actions or expressions:
|
||||
extension
|
||||
@@ -116,7 +124,8 @@ module.exports = {
|
||||
// Everything that is stored inside the behavior is in "behaviorContent" and is automatically
|
||||
// saved/loaded to JSON.
|
||||
var dummyBehavior = new gd.BehaviorJsImplementation();
|
||||
dummyBehavior.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehavior.updateProperty = function (
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -132,25 +141,24 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyBehavior.getProperties = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehavior.getProperties = function (behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
behaviorProperties.set(
|
||||
'My first property',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getStringAttribute('property1')
|
||||
)
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'My other property',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorProperties
|
||||
.getOrCreate('My first property')
|
||||
.setValue(behaviorContent.getStringAttribute('property1'));
|
||||
behaviorProperties
|
||||
.getOrCreate('My other property')
|
||||
.setValue(
|
||||
behaviorContent.getBoolAttribute('property2') ? 'true' : 'false'
|
||||
).setType('Boolean')
|
||||
);
|
||||
)
|
||||
.setType('Boolean');
|
||||
|
||||
return behaviorProperties;
|
||||
};
|
||||
dummyBehavior.initializeContent = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehavior.initializeContent = function (behaviorContent) {
|
||||
behaviorContent.setStringAttribute('property1', 'Initial value 1');
|
||||
behaviorContent.setBoolAttribute('property2', true);
|
||||
};
|
||||
@@ -177,7 +185,8 @@ module.exports = {
|
||||
// Create a new gd.BehaviorSharedDataJsImplementation object and implement the methods
|
||||
// that are called to get and set the properties of the shared data.
|
||||
var dummyBehaviorWithSharedData = new gd.BehaviorJsImplementation();
|
||||
dummyBehaviorWithSharedData.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehaviorWithSharedData.updateProperty = function (
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -189,24 +198,24 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyBehaviorWithSharedData.getProperties = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehaviorWithSharedData.getProperties = function (behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
behaviorProperties.set(
|
||||
'My behavior property',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getStringAttribute('property1')
|
||||
)
|
||||
);
|
||||
behaviorProperties
|
||||
.getOrCreate('My behavior property')
|
||||
.setValue(behaviorContent.getStringAttribute('property1'));
|
||||
|
||||
return behaviorProperties;
|
||||
};
|
||||
dummyBehaviorWithSharedData.initializeContent = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
dummyBehaviorWithSharedData.initializeContent = function (behaviorContent) {
|
||||
behaviorContent.setStringAttribute('property1', 'Initial value 1');
|
||||
};
|
||||
|
||||
var sharedData = new gd.BehaviorSharedDataJsImplementation();
|
||||
sharedData.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.updateProperty = function (
|
||||
sharedContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -218,19 +227,18 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
sharedData.getProperties = function(sharedContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.getProperties = function (sharedContent) {
|
||||
var sharedProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
sharedProperties.set(
|
||||
'My shared property',
|
||||
new gd.PropertyDescriptor(
|
||||
sharedContent.getStringAttribute('sharedProperty1')
|
||||
)
|
||||
);
|
||||
sharedProperties
|
||||
.getOrCreate('My shared property')
|
||||
.setValue(sharedContent.getStringAttribute('sharedProperty1'));
|
||||
|
||||
return sharedProperties;
|
||||
};
|
||||
sharedData.initializeContent = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.initializeContent = function (behaviorContent) {
|
||||
behaviorContent.setStringAttribute(
|
||||
'sharedProperty1',
|
||||
'Initial shared value 1'
|
||||
@@ -264,7 +272,8 @@ module.exports = {
|
||||
// Everything that is stored inside the object is in "content" and is automatically
|
||||
// saved/loaded to JSON.
|
||||
var dummyObject = new gd.ObjectJsImplementation();
|
||||
dummyObject.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
dummyObject.updateProperty = function (
|
||||
objectContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -288,34 +297,29 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyObject.getProperties = function(objectContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
dummyObject.getProperties = function (objectContent) {
|
||||
var objectProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
objectProperties.set(
|
||||
'My first property',
|
||||
new gd.PropertyDescriptor(objectContent.property1)
|
||||
);
|
||||
objectProperties.set(
|
||||
'My other property',
|
||||
new gd.PropertyDescriptor(
|
||||
objectContent.property2 ? 'true' : 'false'
|
||||
).setType('boolean')
|
||||
);
|
||||
objectProperties.set(
|
||||
'My third property',
|
||||
new gd.PropertyDescriptor(objectContent.property3.toString()).setType(
|
||||
'number'
|
||||
)
|
||||
);
|
||||
objectProperties.set(
|
||||
'myImage',
|
||||
new gd.PropertyDescriptor(objectContent.myImage)
|
||||
.setType('resource')
|
||||
.addExtraInfo('image')
|
||||
.setLabel(
|
||||
_("Image resource (won't be shown, just for demonstration purpose)")
|
||||
)
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('My first property')
|
||||
.setValue(objectContent.property1);
|
||||
objectProperties
|
||||
.getOrCreate('My other property')
|
||||
.setValue(objectContent.property2 ? 'true' : 'false')
|
||||
.setType('boolean');
|
||||
objectProperties
|
||||
.getOrCreate('My third property')
|
||||
.setValue(objectContent.property3.toString())
|
||||
.setType('number');
|
||||
objectProperties
|
||||
.getOrCreate('myImage')
|
||||
.setValue(objectContent.myImage)
|
||||
.setType('resource')
|
||||
.addExtraInfo('image')
|
||||
.setLabel(
|
||||
_("Image resource (won't be shown, just for demonstration purpose)")
|
||||
);
|
||||
|
||||
return objectProperties;
|
||||
};
|
||||
@@ -328,7 +332,8 @@ module.exports = {
|
||||
})
|
||||
);
|
||||
|
||||
dummyObject.updateInitialInstanceProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
dummyObject.updateInitialInstanceProperty = function (
|
||||
objectContent,
|
||||
instance,
|
||||
propertyName,
|
||||
@@ -347,7 +352,8 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
dummyObject.getInitialInstanceProperties = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
dummyObject.getInitialInstanceProperties = function (
|
||||
content,
|
||||
instance,
|
||||
project,
|
||||
@@ -355,18 +361,13 @@ module.exports = {
|
||||
) {
|
||||
var instanceProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
instanceProperties.set(
|
||||
'My instance property',
|
||||
new gd.PropertyDescriptor(
|
||||
instance.getRawStringProperty('instanceprop1')
|
||||
)
|
||||
);
|
||||
instanceProperties.set(
|
||||
'My other instance property',
|
||||
new gd.PropertyDescriptor(
|
||||
instance.getRawFloatProperty('instanceprop2').toString()
|
||||
).setType('number')
|
||||
);
|
||||
instanceProperties
|
||||
.getOrCreate('My instance property')
|
||||
.setValue(instance.getRawStringProperty('instanceprop1'));
|
||||
instanceProperties
|
||||
.getOrCreate('My other instance property')
|
||||
.setValue(instance.getRawFloatProperty('instanceprop2').toString())
|
||||
.setType('number');
|
||||
|
||||
return instanceProperties;
|
||||
};
|
||||
@@ -409,13 +410,15 @@ module.exports = {
|
||||
* of your extension behaviors/objects by instanciating behaviors/objects
|
||||
* and setting the property to a given value.
|
||||
*
|
||||
* If you don't have any tests, you can simply return an empty array like this:
|
||||
* `runExtensionSanityTests: function(gd, extension) { return []; }`
|
||||
* If you don't have any tests, you can simply return an empty array.
|
||||
*
|
||||
* But it is recommended to create tests for the behaviors/objects properties you created
|
||||
* to avoid mistakes.
|
||||
*/
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function (
|
||||
gd /*: libGDevelop */,
|
||||
extension /*: gdPlatformExtension*/
|
||||
) {
|
||||
const dummyBehavior = extension
|
||||
.getBehaviorMetadata('MyDummyExtension::DummyBehavior')
|
||||
.get();
|
||||
@@ -440,7 +443,9 @@ module.exports = {
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
registerEditorConfigurations: function(objectsEditorService) {
|
||||
registerEditorConfigurations: function (
|
||||
objectsEditorService /*: ObjectsEditorService */
|
||||
) {
|
||||
objectsEditorService.registerEditorConfiguration(
|
||||
'MyDummyExtension::DummyObject',
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
|
||||
@@ -453,7 +458,9 @@ module.exports = {
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
registerInstanceRenderers: function(objectsRenderingService) {
|
||||
registerInstanceRenderers: function (
|
||||
objectsRenderingService /*: ObjectsRenderingService */
|
||||
) {
|
||||
const RenderedInstance = objectsRenderingService.RenderedInstance;
|
||||
const PIXI = objectsRenderingService.PIXI;
|
||||
|
||||
@@ -498,7 +505,7 @@ module.exports = {
|
||||
/**
|
||||
* Return the path to the thumbnail of the specified object.
|
||||
*/
|
||||
RenderedDummyObjectInstance.getThumbnail = function(
|
||||
RenderedDummyObjectInstance.getThumbnail = function (
|
||||
project,
|
||||
resourcesLoader,
|
||||
object
|
||||
@@ -509,7 +516,7 @@ module.exports = {
|
||||
/**
|
||||
* This is called to update the PIXI object on the scene editor
|
||||
*/
|
||||
RenderedDummyObjectInstance.prototype.update = function() {
|
||||
RenderedDummyObjectInstance.prototype.update = function () {
|
||||
// Read a property from the object
|
||||
const property1Value = this._associatedObject
|
||||
.getProperties(this.project)
|
||||
@@ -532,14 +539,14 @@ module.exports = {
|
||||
/**
|
||||
* Return the width of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedDummyObjectInstance.prototype.getDefaultWidth = function() {
|
||||
RenderedDummyObjectInstance.prototype.getDefaultWidth = function () {
|
||||
return this._pixiObject.width;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the height of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedDummyObjectInstance.prototype.getDefaultHeight = function() {
|
||||
RenderedDummyObjectInstance.prototype.getDefaultHeight = function () {
|
||||
return this._pixiObject.height;
|
||||
};
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,16 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
@@ -361,7 +370,7 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,16 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
@@ -321,7 +330,6 @@ module.exports = {
|
||||
_('Desktop folder'),
|
||||
_('Get the path to the desktop folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -335,7 +343,6 @@ module.exports = {
|
||||
_('Documents folder'),
|
||||
_('Get the path to the documents folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -349,7 +356,6 @@ module.exports = {
|
||||
_('Pictures folder'),
|
||||
_('Get the path to the pictures folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -363,7 +369,6 @@ module.exports = {
|
||||
_('This games executable folder'),
|
||||
_('Get the path to this games executable folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -377,7 +382,6 @@ module.exports = {
|
||||
_('Userdata folder (For application settings)'),
|
||||
_('Get the path to userdata folder. (For application settings)'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -385,13 +389,24 @@ module.exports = {
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.getUserdataPath');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'UserHomePath',
|
||||
_('User\'s Home folder'),
|
||||
_('Get the path to the user home folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
.setIncludeFile('Extensions/FileSystem/filesystemtools.js')
|
||||
.setFunctionName('gdjs.fileSystem.getUserHomePath');
|
||||
|
||||
extension
|
||||
.addStrExpression(
|
||||
'TempPath',
|
||||
_('Temp folder'),
|
||||
_('Get the path to temp folder.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.addCodeOnlyParameter('currentScene', '')
|
||||
@@ -405,7 +420,6 @@ module.exports = {
|
||||
_('Path delimiter'),
|
||||
_('Get the operating system agnostic path delimiter.'),
|
||||
_('Filesystem/Windows, Linux, MacOS'),
|
||||
'JsPlatform/Extensions/filesystem_folder24.png',
|
||||
'JsPlatform/Extensions/filesystem_folder32.png'
|
||||
)
|
||||
.getCodeExtraInformation()
|
||||
@@ -414,7 +428,7 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
|
@@ -97,6 +97,23 @@ gdjs.fileSystem.getUserdataPath = function(runtimeScene) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the path to the user's home folder (on Windows `C:\Users\<USERNAME>\` for example).
|
||||
* @return {string} The path to user's "home" folder
|
||||
*/
|
||||
gdjs.fileSystem.getUserHomePath = function() {
|
||||
const electron = runtimeScene
|
||||
.getGame()
|
||||
.getRenderer()
|
||||
.getElectron();
|
||||
|
||||
if (electron) {
|
||||
return electron.remote.app.getPath('home') || '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the path to 'Temp' folder.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The current scene
|
||||
|
@@ -1,5 +1,5 @@
|
||||
describe('Inventory', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}, resources: {resources: []}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
|
||||
gdjs.evtTools.inventory.add(runtimeScene, "MyInventory", "sword");
|
||||
|
29
Extensions/JsExtensionTypes.flow.js
Normal file
29
Extensions/JsExtensionTypes.flow.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// @flow
|
||||
|
||||
/**
|
||||
* @file This file contains the (Flow) types that are used in the JavaScript
|
||||
* extensions declaration (i.e: JsExtension.js files).
|
||||
*
|
||||
* If you do changes here, run `node import-GDJS-Runtime.js` (in newIDE/app/scripts),
|
||||
* and be sure that the types declared here are reflecting the types exposed by the editor.
|
||||
*
|
||||
* Note that Flow comments are used to avoid having to preprocess this file and the
|
||||
* JsExtension.js files through Babel. This allows to keep plain JS files, while allowing
|
||||
* Flow static type checking to be run on them when integrated in the editor.
|
||||
*/
|
||||
|
||||
/*::
|
||||
export type ObjectsRenderingService = {
|
||||
gd: libGDevelop,
|
||||
PIXI: any,
|
||||
RenderedInstance: any,
|
||||
registerInstanceRenderer: (objectType: string, renderer: any) => void,
|
||||
requireModule: (dirname: string, moduleName: string) => any,
|
||||
getThumbnail: (project: gdProject, object: gdObject) => string,
|
||||
};
|
||||
|
||||
export type ObjectsEditorService = {
|
||||
registerEditorConfiguration: (objectType: string, editorConfiguration: any) => void,
|
||||
getDefaultObjectJsImplementationPropertiesEditor: ({| helpPagePath: string |}) => any,
|
||||
};
|
||||
*/
|
@@ -1,6 +1,6 @@
|
||||
|
||||
describe('gdjs.LinksManager', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}, resources: {resources: []}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers:[{name:"", visibility: true}],
|
||||
|
@@ -245,7 +245,7 @@ gdjs.PanelSpriteRuntimeObjectPixiRenderer.prototype.setTexture = function(
|
||||
texture,
|
||||
makeInsideTexture(
|
||||
new PIXI.Rectangle(
|
||||
this._borderSprites[1].width - obj._rBorder,
|
||||
texture.width - obj._rBorder,
|
||||
0,
|
||||
obj._rBorder,
|
||||
obj._tBorder
|
||||
@@ -261,7 +261,7 @@ gdjs.PanelSpriteRuntimeObjectPixiRenderer.prototype.setTexture = function(
|
||||
makeInsideTexture(
|
||||
new PIXI.Rectangle(
|
||||
0,
|
||||
this._borderSprites[5].height - obj._bBorder,
|
||||
texture.height - obj._bBorder,
|
||||
obj._lBorder,
|
||||
obj._bBorder
|
||||
)
|
||||
@@ -271,8 +271,8 @@ gdjs.PanelSpriteRuntimeObjectPixiRenderer.prototype.setTexture = function(
|
||||
texture,
|
||||
makeInsideTexture(
|
||||
new PIXI.Rectangle(
|
||||
this._borderSprites[7].width - obj._rBorder,
|
||||
this._borderSprites[7].height - obj._bBorder,
|
||||
texture.width - obj._rBorder,
|
||||
texture.height - obj._bBorder,
|
||||
obj._rBorder,
|
||||
obj._bBorder
|
||||
)
|
||||
|
@@ -133,15 +133,14 @@ class PathfindingBehaviorJsExtension : public gd::PlatformExtension {
|
||||
GetAllExpressionsForBehavior(
|
||||
"PathfindingBehavior::PathfindingObstacleBehavior");
|
||||
|
||||
autActions["PathfindingObstacleBehavior::Cost"]
|
||||
autActions["PathfindingBehavior::Cost"]
|
||||
.SetFunctionName("setCost")
|
||||
.SetGetter("getCost");
|
||||
autConditions["PathfindingObstacleBehavior::Cost"].SetFunctionName(
|
||||
"getCost");
|
||||
autActions["PathfindingObstacleBehavior::SetImpassable"].SetFunctionName(
|
||||
autConditions["PathfindingBehavior::Cost"].SetFunctionName("getCost");
|
||||
autActions["PathfindingBehavior::SetImpassable"].SetFunctionName(
|
||||
"setImpassable");
|
||||
autConditions["PathfindingObstacleBehavior::IsImpassable"]
|
||||
.SetFunctionName("isImpassable");
|
||||
autConditions["PathfindingBehavior::IsImpassable"].SetFunctionName(
|
||||
"isImpassable");
|
||||
|
||||
autExpressions["Cost"].SetFunctionName("getCost");
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,19 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function (
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
'Physics2',
|
||||
@@ -22,7 +34,8 @@ module.exports = {
|
||||
);
|
||||
|
||||
var physics2Behavior = new gd.BehaviorJsImplementation();
|
||||
physics2Behavior.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
physics2Behavior.updateProperty = function (
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -36,7 +49,9 @@ module.exports = {
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'fixedRotation') {
|
||||
behaviorContent.getChild('fixedRotation').setBoolValue(newValue === '1');
|
||||
behaviorContent
|
||||
.getChild('fixedRotation')
|
||||
.setBoolValue(newValue === '1');
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'canSleep') {
|
||||
@@ -77,11 +92,14 @@ module.exports = {
|
||||
}
|
||||
if (propertyName === 'vertices') {
|
||||
behaviorContent.addChild('vertices');
|
||||
// $FlowFixMe
|
||||
behaviorContent.setChild('vertices', gd.Serializer.fromJSON(newValue));
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'density') {
|
||||
behaviorContent.getChild('density').setDoubleValue(parseFloat(newValue));
|
||||
behaviorContent
|
||||
.getChild('density')
|
||||
.setDoubleValue(parseFloat(newValue));
|
||||
return true;
|
||||
}
|
||||
if (propertyName === 'friction') {
|
||||
@@ -123,174 +141,168 @@ module.exports = {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
physics2Behavior.getProperties = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
physics2Behavior.getProperties = function (behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
behaviorProperties.set(
|
||||
'bodyType',
|
||||
new gd.PropertyDescriptor(behaviorContent.getChild('bodyType').getStringValue())
|
||||
.setType('Choice')
|
||||
.setLabel('Type')
|
||||
.addExtraInfo('Static')
|
||||
.addExtraInfo('Dynamic')
|
||||
.addExtraInfo('Kinematic')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'bullet',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorProperties
|
||||
.getOrCreate('bodyType')
|
||||
.setValue(behaviorContent.getChild('bodyType').getStringValue())
|
||||
.setType('Choice')
|
||||
.setLabel('Type')
|
||||
.addExtraInfo('Static')
|
||||
.addExtraInfo('Dynamic')
|
||||
.addExtraInfo('Kinematic');
|
||||
behaviorProperties
|
||||
.getOrCreate('bullet')
|
||||
.setValue(
|
||||
behaviorContent.getChild('bullet').getBoolValue() ? 'true' : 'false'
|
||||
)
|
||||
.setType('Boolean')
|
||||
.setLabel('Bullet')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'fixedRotation',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('fixedRotation').getBoolValue() ? 'true' : 'false'
|
||||
.setType('Boolean')
|
||||
.setLabel('Bullet');
|
||||
behaviorProperties
|
||||
.getOrCreate('fixedRotation')
|
||||
.setValue(
|
||||
behaviorContent.getChild('fixedRotation').getBoolValue()
|
||||
? 'true'
|
||||
: 'false'
|
||||
)
|
||||
.setType('Boolean')
|
||||
.setLabel('Fixed Rotation')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'canSleep',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Boolean')
|
||||
.setLabel('Fixed Rotation');
|
||||
behaviorProperties
|
||||
.getOrCreate('canSleep')
|
||||
.setValue(
|
||||
behaviorContent.getChild('canSleep').getBoolValue() ? 'true' : 'false'
|
||||
)
|
||||
.setType('Boolean')
|
||||
.setLabel('Can Sleep')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'shape',
|
||||
new gd.PropertyDescriptor(behaviorContent.getChild('shape').getStringValue())
|
||||
.setType('Choice')
|
||||
.setLabel('Shape')
|
||||
.addExtraInfo('Box')
|
||||
.addExtraInfo('Circle')
|
||||
.addExtraInfo('Edge')
|
||||
.addExtraInfo('Polygon')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'shapeDimensionA',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('shapeDimensionA').getDoubleValue().toString(10)
|
||||
.setType('Boolean')
|
||||
.setLabel('Can Sleep');
|
||||
behaviorProperties
|
||||
.getOrCreate('shape')
|
||||
.setValue(behaviorContent.getChild('shape').getStringValue())
|
||||
.setType('Choice')
|
||||
.setLabel('Shape')
|
||||
.addExtraInfo('Box')
|
||||
.addExtraInfo('Circle')
|
||||
.addExtraInfo('Edge')
|
||||
.addExtraInfo('Polygon');
|
||||
behaviorProperties
|
||||
.getOrCreate('shapeDimensionA')
|
||||
.setValue(
|
||||
behaviorContent
|
||||
.getChild('shapeDimensionA')
|
||||
.getDoubleValue()
|
||||
.toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Shape Dimension A')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'shapeDimensionB',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('shapeDimensionB').getDoubleValue().toString(10)
|
||||
.setType('Number')
|
||||
.setLabel('Shape Dimension A');
|
||||
behaviorProperties
|
||||
.getOrCreate('shapeDimensionB')
|
||||
.setValue(
|
||||
behaviorContent
|
||||
.getChild('shapeDimensionB')
|
||||
.getDoubleValue()
|
||||
.toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Shape Dimension B')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'shapeOffsetX',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Number')
|
||||
.setLabel('Shape Dimension B');
|
||||
behaviorProperties
|
||||
.getOrCreate('shapeOffsetX')
|
||||
.setValue(
|
||||
behaviorContent.getChild('shapeOffsetX').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Shape Offset X')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'shapeOffsetY',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Number')
|
||||
.setLabel('Shape Offset X');
|
||||
behaviorProperties
|
||||
.getOrCreate('shapeOffsetY')
|
||||
.setValue(
|
||||
behaviorContent.getChild('shapeOffsetY').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Shape Offset Y')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'polygonOrigin',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.hasChild('polygonOrigin') ?
|
||||
behaviorContent.getChild('polygonOrigin').getStringValue() :
|
||||
'Center'
|
||||
.setType('Number')
|
||||
.setLabel('Shape Offset Y');
|
||||
behaviorProperties
|
||||
.getOrCreate('polygonOrigin')
|
||||
.setValue(
|
||||
behaviorContent.hasChild('polygonOrigin')
|
||||
? behaviorContent.getChild('polygonOrigin').getStringValue()
|
||||
: 'Center'
|
||||
)
|
||||
.setType('Choice')
|
||||
.setLabel('Polygon Origin')
|
||||
.addExtraInfo('Center')
|
||||
.addExtraInfo('Origin')
|
||||
.addExtraInfo('TopLeft')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'vertices',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.hasChild('vertices') ?
|
||||
gd.Serializer.toJSON(behaviorContent.getChild('vertices')) :
|
||||
'[]'
|
||||
).setLabel('Vertices')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'density',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Choice')
|
||||
.setLabel('Polygon Origin')
|
||||
.addExtraInfo('Center')
|
||||
.addExtraInfo('Origin')
|
||||
.addExtraInfo('TopLeft');
|
||||
behaviorProperties
|
||||
.getOrCreate('vertices')
|
||||
.setValue(
|
||||
behaviorContent.hasChild('vertices')
|
||||
? gd.Serializer.toJSON(behaviorContent.getChild('vertices'))
|
||||
: '[]'
|
||||
)
|
||||
.setLabel('Vertices');
|
||||
behaviorProperties
|
||||
.getOrCreate('density')
|
||||
.setValue(
|
||||
behaviorContent.getChild('density').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Density')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'friction',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Number')
|
||||
.setLabel('Density');
|
||||
behaviorProperties
|
||||
.getOrCreate('friction')
|
||||
.setValue(
|
||||
behaviorContent.getChild('friction').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Friction')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'restitution',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Number')
|
||||
.setLabel('Friction');
|
||||
behaviorProperties
|
||||
.getOrCreate('restitution')
|
||||
.setValue(
|
||||
behaviorContent.getChild('restitution').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Restitution')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'linearDamping',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('linearDamping').getDoubleValue().toString(10)
|
||||
.setType('Number')
|
||||
.setLabel('Restitution');
|
||||
behaviorProperties
|
||||
.getOrCreate('linearDamping')
|
||||
.setValue(
|
||||
behaviorContent
|
||||
.getChild('linearDamping')
|
||||
.getDoubleValue()
|
||||
.toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Linear Damping')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'angularDamping',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('angularDamping').getDoubleValue().toString(10)
|
||||
.setType('Number')
|
||||
.setLabel('Linear Damping');
|
||||
behaviorProperties
|
||||
.getOrCreate('angularDamping')
|
||||
.setValue(
|
||||
behaviorContent
|
||||
.getChild('angularDamping')
|
||||
.getDoubleValue()
|
||||
.toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Angular Damping')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'gravityScale',
|
||||
new gd.PropertyDescriptor(
|
||||
.setType('Number')
|
||||
.setLabel('Angular Damping');
|
||||
behaviorProperties
|
||||
.getOrCreate('gravityScale')
|
||||
.setValue(
|
||||
behaviorContent.getChild('gravityScale').getDoubleValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Gravity Scale')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'layers',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('layers').getIntValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Layers')
|
||||
);
|
||||
behaviorProperties.set(
|
||||
'masks',
|
||||
new gd.PropertyDescriptor(
|
||||
behaviorContent.getChild('masks').getIntValue().toString(10)
|
||||
)
|
||||
.setType('Number')
|
||||
.setLabel('Masks')
|
||||
);
|
||||
.setType('Number')
|
||||
.setLabel('Gravity Scale');
|
||||
behaviorProperties
|
||||
.getOrCreate('layers')
|
||||
.setValue(behaviorContent.getChild('layers').getIntValue().toString(10))
|
||||
.setType('Number')
|
||||
.setLabel('Layers');
|
||||
behaviorProperties
|
||||
.getOrCreate('masks')
|
||||
.setValue(behaviorContent.getChild('masks').getIntValue().toString(10))
|
||||
.setType('Number')
|
||||
.setLabel('Masks');
|
||||
|
||||
return behaviorProperties;
|
||||
};
|
||||
|
||||
physics2Behavior.initializeContent = function(behaviorContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
physics2Behavior.initializeContent = function (behaviorContent) {
|
||||
behaviorContent.addChild('bodyType').setStringValue('Dynamic');
|
||||
behaviorContent.addChild('bullet').setBoolValue(false);
|
||||
behaviorContent.addChild('fixedRotation').setBoolValue(false);
|
||||
@@ -313,7 +325,8 @@ module.exports = {
|
||||
};
|
||||
|
||||
var sharedData = new gd.BehaviorSharedDataJsImplementation();
|
||||
sharedData.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.updateProperty = function (
|
||||
sharedContent,
|
||||
propertyName,
|
||||
newValue
|
||||
@@ -345,42 +358,44 @@ module.exports = {
|
||||
|
||||
return false;
|
||||
};
|
||||
sharedData.getProperties = function(sharedContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.getProperties = function (sharedContent) {
|
||||
var sharedProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
sharedProperties.set(
|
||||
'gravityX',
|
||||
new gd.PropertyDescriptor(
|
||||
sharedProperties
|
||||
.getOrCreate('gravityX')
|
||||
.setValue(
|
||||
sharedContent.getChild('gravityX').getDoubleValue().toString(10)
|
||||
).setType('Number')
|
||||
);
|
||||
sharedProperties.set(
|
||||
'gravityY',
|
||||
new gd.PropertyDescriptor(
|
||||
)
|
||||
.setType('Number');
|
||||
sharedProperties
|
||||
.getOrCreate('gravityY')
|
||||
.setValue(
|
||||
sharedContent.getChild('gravityY').getDoubleValue().toString(10)
|
||||
).setType('Number')
|
||||
);
|
||||
sharedProperties.set(
|
||||
'scaleX',
|
||||
new gd.PropertyDescriptor(
|
||||
)
|
||||
.setType('Number');
|
||||
sharedProperties
|
||||
.getOrCreate('scaleX')
|
||||
.setValue(
|
||||
sharedContent.getChild('scaleX').getDoubleValue().toString(10)
|
||||
).setType('Number')
|
||||
);
|
||||
sharedProperties.set(
|
||||
'scaleY',
|
||||
new gd.PropertyDescriptor(
|
||||
)
|
||||
.setType('Number');
|
||||
sharedProperties
|
||||
.getOrCreate('scaleY')
|
||||
.setValue(
|
||||
sharedContent.getChild('scaleY').getDoubleValue().toString(10)
|
||||
).setType('Number')
|
||||
);
|
||||
)
|
||||
.setType('Number');
|
||||
|
||||
return sharedProperties;
|
||||
};
|
||||
sharedData.initializeContent = function(behaviorContent) {
|
||||
behaviorContent.addChild("gravityX").setDoubleValue(0);
|
||||
behaviorContent.addChild("gravityY").setDoubleValue(9.8);
|
||||
behaviorContent.addChild("scaleX").setDoubleValue(100);
|
||||
behaviorContent.addChild("scaleY").setDoubleValue(100);
|
||||
}
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
sharedData.initializeContent = function (behaviorContent) {
|
||||
behaviorContent.addChild('gravityX').setDoubleValue(0);
|
||||
behaviorContent.addChild('gravityY').setDoubleValue(9.8);
|
||||
behaviorContent.addChild('scaleX').setDoubleValue(100);
|
||||
behaviorContent.addChild('scaleY').setDoubleValue(100);
|
||||
};
|
||||
|
||||
var aut = extension
|
||||
// extension
|
||||
@@ -413,7 +428,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getGravityX');
|
||||
|
||||
@@ -442,7 +457,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getGravityY');
|
||||
|
||||
@@ -488,7 +503,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getTimeScale');
|
||||
|
||||
@@ -752,9 +767,9 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setShapeScale')
|
||||
.setFunctionName('setShapeScale')
|
||||
.setGetter('getShapeScale');
|
||||
|
||||
aut
|
||||
@@ -769,7 +784,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getDensity');
|
||||
|
||||
@@ -787,9 +802,9 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setDensity')
|
||||
.setFunctionName('setDensity')
|
||||
.setGetter('getDensity');
|
||||
|
||||
aut
|
||||
@@ -817,7 +832,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getFriction');
|
||||
|
||||
@@ -835,7 +850,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setFriction')
|
||||
.setGetter('getFriction');
|
||||
@@ -865,7 +880,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getRestitution');
|
||||
|
||||
@@ -883,7 +898,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setRestitution')
|
||||
.setGetter('getRestitution');
|
||||
@@ -913,7 +928,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearDamping');
|
||||
|
||||
@@ -931,7 +946,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setLinearDamping')
|
||||
.setGetter('getLinearDamping');
|
||||
@@ -961,7 +976,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getAngularDamping');
|
||||
|
||||
@@ -979,7 +994,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setAngularDamping')
|
||||
.setGetter('getAngularDamping');
|
||||
@@ -1009,7 +1024,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getGravityScale');
|
||||
|
||||
@@ -1027,7 +1042,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setGravityScale')
|
||||
.setGetter('getGravityScale');
|
||||
@@ -1131,7 +1146,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityX');
|
||||
|
||||
@@ -1147,7 +1162,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setLinearVelocityX')
|
||||
.setGetter('getLinearVelocityX');
|
||||
@@ -1177,7 +1192,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityY');
|
||||
|
||||
@@ -1193,7 +1208,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setLinearVelocityY')
|
||||
.setGetter('getLinearVelocityY');
|
||||
@@ -1223,7 +1238,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getLinearVelocityLength');
|
||||
|
||||
@@ -1252,7 +1267,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getAngularVelocity');
|
||||
|
||||
@@ -1268,7 +1283,7 @@ module.exports = {
|
||||
)
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setAngularVelocity')
|
||||
.setGetter('getAngularVelocity');
|
||||
@@ -1581,7 +1596,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getJointReactionForce');
|
||||
|
||||
@@ -1612,7 +1627,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('getJointReactionTorque');
|
||||
|
||||
@@ -1716,7 +1731,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setDistanceJointLength')
|
||||
.setGetter('getDistanceJointLength');
|
||||
@@ -1748,7 +1763,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setDistanceJointFrequency')
|
||||
.setGetter('getDistanceJointFrequency');
|
||||
@@ -1780,7 +1795,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setDistanceJointDampingRatio')
|
||||
.setGetter('getDistanceJointDampingRatio');
|
||||
@@ -2075,7 +2090,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setRevoluteJointMotorSpeed')
|
||||
.setGetter('getRevoluteJointMotorSpeed');
|
||||
@@ -2107,7 +2122,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setRevoluteJointMaxMotorTorque')
|
||||
.setGetter('getRevoluteJointMaxMotorTorque');
|
||||
@@ -2387,7 +2402,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setPrismaticJointMotorSpeed')
|
||||
.setGetter('getPrismaticJointMotorSpeed');
|
||||
@@ -2419,7 +2434,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setPrismaticJointMaxMotorForce')
|
||||
.setGetter('getPrismaticJointMaxMotorForce');
|
||||
@@ -2689,7 +2704,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setGearJointRatio')
|
||||
.setGetter('getGearJointRatio');
|
||||
@@ -2814,7 +2829,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMouseJointMaxForce')
|
||||
.setGetter('getMouseJointMaxForce');
|
||||
@@ -2846,7 +2861,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMouseJointFrequency')
|
||||
.setGetter('getMouseJointFrequency');
|
||||
@@ -2878,7 +2893,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMouseJointDampingRatio')
|
||||
.setGetter('getMouseJointDampingRatio');
|
||||
@@ -3047,7 +3062,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWheelJointMotorSpeed')
|
||||
.setGetter('getWheelJointMotorSpeed');
|
||||
@@ -3079,7 +3094,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWheelJointMaxMotorTorque')
|
||||
.setGetter('getWheelJointMaxMotorTorque');
|
||||
@@ -3125,7 +3140,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWheelJointFrequency')
|
||||
.setGetter('getWheelJointFrequency');
|
||||
@@ -3157,7 +3172,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWheelJointDampingRatio')
|
||||
.setGetter('getWheelJointDampingRatio');
|
||||
@@ -3253,7 +3268,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWeldJointFrequency')
|
||||
.setGetter('getWeldJointFrequency');
|
||||
@@ -3285,7 +3300,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setWeldJointDampingRatio')
|
||||
.setGetter('getWeldJointDampingRatio');
|
||||
@@ -3360,7 +3375,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setRopeJointMaxLength')
|
||||
.setGetter('getRopeJointMaxLength');
|
||||
@@ -3428,7 +3443,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setFrictionJointMaxForce')
|
||||
.setGetter('getFrictionJointMaxForce');
|
||||
@@ -3460,7 +3475,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setFrictionJointMaxTorque')
|
||||
.setGetter('getFrictionJointMaxTorque');
|
||||
@@ -3577,7 +3592,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMotorJointAngularOffset')
|
||||
.setGetter('getMotorJointAngularOffset');
|
||||
@@ -3609,7 +3624,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMotorJointMaxForce')
|
||||
.setGetter('getMotorJointMaxForce');
|
||||
@@ -3641,7 +3656,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMotorJointMaxTorque')
|
||||
.setGetter('getMotorJointMaxTorque');
|
||||
@@ -3673,7 +3688,7 @@ module.exports = {
|
||||
.addParameter('object', _('Object'), '', false)
|
||||
.addParameter('behavior', _('Behavior'), 'Physics2Behavior')
|
||||
.addParameter('expression', _('Joint ID'))
|
||||
.useStandardOperatorParameters("number")
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setMotorJointCorrectionFactor')
|
||||
.setGetter('getMotorJointCorrectionFactor');
|
||||
@@ -3714,7 +3729,10 @@ module.exports = {
|
||||
return extension;
|
||||
},
|
||||
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function (
|
||||
gd /*: libGDevelop */,
|
||||
extension /*: gdPlatformExtension*/
|
||||
) {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
|
@@ -586,7 +586,7 @@ gdjs.Physics2RuntimeBehavior.prototype.doStepPostEvents = function(
|
||||
(this._objectOldHeight !== this.owner.getHeight() &&
|
||||
this.shape !== 'Edge' &&
|
||||
!(this.shape === 'Box' && this.shapeDimensionB > 0) &&
|
||||
!(this.shape === 'Ciecle' && this.shapeDimensionA > 0))
|
||||
!(this.shape === 'Circle' && this.shapeDimensionA > 0))
|
||||
) {
|
||||
this.recreateShape();
|
||||
}
|
||||
|
@@ -181,6 +181,39 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.SetGetter("GetMaxFallingSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition(
|
||||
"LadderClimbingSpeed",
|
||||
_("Ladder climbing speed"),
|
||||
_("Compare the ladder climbing speed (in pixels per "
|
||||
"second)."),
|
||||
_("the ladder climbing speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced()
|
||||
.SetFunctionName("GetLadderClimbingSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddAction(
|
||||
"LadderClimbingSpeed",
|
||||
_("Ladder climbing speed"),
|
||||
_("Change the ladder climbing speed (in pixels per "
|
||||
"second)."),
|
||||
_("the ladder climbing speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardOperatorParameters("number")
|
||||
.MarkAsAdvanced()
|
||||
.SetFunctionName("SetLadderClimbingSpeed")
|
||||
.SetGetter("GetLadderClimbingSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition("Acceleration",
|
||||
_("Acceleration"),
|
||||
_("Compare the acceleration of the object (in pixels per "
|
||||
@@ -303,9 +336,34 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.SetGetter("GetJumpSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition(
|
||||
"JumpSustainTime",
|
||||
_("Jump sustain time"),
|
||||
_("Compare the jump sustain time of the object (in seconds)."),
|
||||
_("the jump sustain time"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddAction(
|
||||
"JumpSustainTime",
|
||||
_("Jump sustain time"),
|
||||
_("Change the jump sustain time of an object (in seconds)."),
|
||||
_("the jump sustain time"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardOperatorParameters("number");
|
||||
|
||||
aut.AddAction(
|
||||
"SetCanJump",
|
||||
_("Allow again jumping"),
|
||||
_("Allow jumping again"),
|
||||
_("When this action is executed, the object is able to jump again, "
|
||||
"even if it is in the air: this can be useful to allow a double "
|
||||
"jump for example. This is not a permanent effect: you must call "
|
||||
@@ -321,6 +379,19 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("SetCanJump")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition("CanJump",
|
||||
_("Can jump"),
|
||||
_("Check if the object can jump."),
|
||||
_("_PARAM0_ can jump"),
|
||||
"",
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.MarkAsSimple()
|
||||
.SetFunctionName("canJump")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddAction("SimulateLeftKey",
|
||||
_("Simulate left key press"),
|
||||
_("Simulate a press of the left key."),
|
||||
@@ -443,6 +514,79 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("IgnoreDefaultControls")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddAction("CanGrabPlatforms",
|
||||
_("Platform grabbing"),
|
||||
_("Enable (or disable) the ability of the object to grab platforms when falling near to one."),
|
||||
_("Allow _PARAM0_ to grab platforms: _PARAM2_"),
|
||||
_("Controls"),
|
||||
"res/conditions/keyboard24.png",
|
||||
"res/conditions/keyboard.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.AddParameter("yesorno", _("Can grab platfroms"))
|
||||
.MarkAsAdvanced();
|
||||
|
||||
aut.AddCondition("CanGrabPlatforms",
|
||||
_("Can grab platforms"),
|
||||
_("Check if the object can grab the platforms."),
|
||||
_("_PARAM0_ can grab the platforms"),
|
||||
"",
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.MarkAsSimple()
|
||||
.SetFunctionName("canGrabPlatforms")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition(
|
||||
"CurrentFallSpeed",
|
||||
_("Current falling speed"),
|
||||
_("Compare the current falling speed of the object (in pixels per "
|
||||
"second)."),
|
||||
_("the current falling speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced()
|
||||
.SetFunctionName("GetCurrentFallSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition(
|
||||
"CurrentJumpSpeed",
|
||||
_("Current jump speed"),
|
||||
_("Compare the current jump speed of the object (in pixels per "
|
||||
"second)."),
|
||||
_("the current jump speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced()
|
||||
.SetFunctionName("GetCurrentJumpSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddCondition(
|
||||
"CurrentSpeed",
|
||||
_("Current speed"),
|
||||
_("Compare the current speed of the object (in pixels per "
|
||||
"second)."),
|
||||
_("the current speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon24.png",
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.UseStandardRelationalOperatorParameters("number")
|
||||
.MarkAsAdvanced()
|
||||
.SetFunctionName("GetCurrentSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("Gravity",
|
||||
_("Gravity"),
|
||||
_("Get the gravity applied on the object"),
|
||||
@@ -463,6 +607,16 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("GetMaxFallingSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("LadderClimbingSpeed",
|
||||
_("Ladder climbing speed"),
|
||||
_("Get the ladder climbing speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.SetFunctionName("GetLadderClimbingSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("Acceleration",
|
||||
_("Acceleration"),
|
||||
_("Acceleration"),
|
||||
@@ -502,6 +656,44 @@ void DeclarePlatformBehaviorExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.SetFunctionName("GetJumpSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("JumpSustainTime",
|
||||
_("Jump sustain time"),
|
||||
_("The time during which keeping the jump button held allow the initial jump speed to be maintained."),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior");
|
||||
|
||||
aut.AddExpression("CurrentFallSpeed",
|
||||
_("Current fall speed"),
|
||||
_("Current fall speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.SetFunctionName("GetCurrentFallSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("CurrentSpeed",
|
||||
_("Current speed"),
|
||||
_("Current speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.SetFunctionName("GetCurrentSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
|
||||
aut.AddExpression("CurrentJumpSpeed",
|
||||
_("Current jump speed"),
|
||||
_("Current jump speed"),
|
||||
_("Options"),
|
||||
"CppPlatform/Extensions/platformerobjecticon16.png")
|
||||
.AddParameter("object", _("Object"))
|
||||
.AddParameter("behavior", _("Behavior"), "PlatformerObjectBehavior")
|
||||
.SetFunctionName("GetCurrentJumpSpeed")
|
||||
.SetIncludeFile("PlatformBehavior/PlatformerObjectRuntimeBehavior.h");
|
||||
#endif
|
||||
}
|
||||
{
|
||||
|
@@ -70,6 +70,12 @@ class PlatformBehaviorJsExtension : public gd::PlatformExtension {
|
||||
autExpressions["MaxFallingSpeed"].SetFunctionName("getMaxFallingSpeed");
|
||||
autConditions["PlatformBehavior::Acceleration"].SetFunctionName(
|
||||
"getAcceleration");
|
||||
autActions["PlatformBehavior::LadderClimbingSpeed"]
|
||||
.SetFunctionName("setLadderClimbingSpeed")
|
||||
.SetGetter("getLadderClimbingSpeed");
|
||||
autExpressions["LadderClimbingSpeed"].SetFunctionName("getLadderClimbingSpeed");
|
||||
autConditions["PlatformBehavior::LadderClimbingSpeed"].SetFunctionName(
|
||||
"getLadderClimbingSpeed");
|
||||
autActions["PlatformBehavior::Acceleration"]
|
||||
.SetFunctionName("setAcceleration")
|
||||
.SetGetter("getAcceleration");
|
||||
@@ -92,8 +98,29 @@ class PlatformBehaviorJsExtension : public gd::PlatformExtension {
|
||||
.SetFunctionName("setJumpSpeed")
|
||||
.SetGetter("getJumpSpeed");
|
||||
autExpressions["JumpSpeed"].SetFunctionName("getJumpSpeed");
|
||||
|
||||
autConditions["PlatformBehavior::JumpSustainTime"].SetFunctionName(
|
||||
"getJumpSustainTime");
|
||||
autActions["PlatformBehavior::JumpSustainTime"]
|
||||
.SetFunctionName("setJumpSustainTime")
|
||||
.SetGetter("getJumpSustainTime");
|
||||
autExpressions["JumpSustainTime"].SetFunctionName("getJumpSustainTime");
|
||||
autConditions["PlatformBehavior::CurrentFallSpeed"].SetFunctionName(
|
||||
"getCurrentFallSpeed");
|
||||
autExpressions["CurrentFallSpeed"].SetFunctionName("getCurrentFallSpeed");
|
||||
autConditions["PlatformBehavior::CurrentSpeed"].SetFunctionName(
|
||||
"getCurrentSpeed");
|
||||
autExpressions["CurrentSpeed"].SetFunctionName("getCurrentSpeed");
|
||||
autActions["PlatformBehavior::CanGrabPlatforms"]
|
||||
.SetFunctionName("setCanGrabPlatforms")
|
||||
.SetGetter("canGrabPlatforms");
|
||||
autConditions["PlatformBehavior::CanGrabPlatforms"].SetFunctionName(
|
||||
"canGrabPlatforms");
|
||||
autConditions["PlatformBehavior::CurrentJumpSpeed"].SetFunctionName(
|
||||
"getCurrentJumpSpeed");
|
||||
autExpressions["CurrentJumpSpeed"].SetFunctionName("getCurrentJumpSpeed");
|
||||
autActions["PlatformBehavior::SetCanJump"].SetFunctionName("setCanJump");
|
||||
autConditions["PlatformBehavior::CanJump"].SetFunctionName(
|
||||
"canJump");
|
||||
autActions["PlatformBehavior::SimulateLeftKey"].SetFunctionName(
|
||||
"simulateLeftKey");
|
||||
autActions["PlatformBehavior::SimulateRightKey"].SetFunctionName(
|
||||
|
@@ -6,11 +6,13 @@ This project is released under the MIT License.
|
||||
*/
|
||||
|
||||
#include "PlatformerObjectBehavior.h"
|
||||
|
||||
#include <SFML/Window.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCpp/Runtime/CommonTools.h"
|
||||
#include "GDCpp/Runtime/Project/Layout.h"
|
||||
@@ -22,6 +24,7 @@ This project is released under the MIT License.
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "GDCore/Project/PropertyDescriptor.h"
|
||||
#endif
|
||||
|
||||
@@ -30,10 +33,12 @@ void PlatformerObjectBehavior::InitializeContent(
|
||||
behaviorContent.SetAttribute("roundCoordinates", true);
|
||||
behaviorContent.SetAttribute("gravity", 1000);
|
||||
behaviorContent.SetAttribute("maxFallingSpeed", 700);
|
||||
behaviorContent.SetAttribute("ladderClimbingSpeed", 150);
|
||||
behaviorContent.SetAttribute("acceleration", 1500);
|
||||
behaviorContent.SetAttribute("deceleration", 1500);
|
||||
behaviorContent.SetAttribute("maxSpeed", 250);
|
||||
behaviorContent.SetAttribute("jumpSpeed", 600);
|
||||
behaviorContent.SetAttribute("jumpSustainTime", 0.2);
|
||||
behaviorContent.SetAttribute("ignoreDefaultControls", false);
|
||||
behaviorContent.SetAttribute("slopeMaxAngle", 60);
|
||||
behaviorContent.SetAttribute("canGrabPlatforms", false);
|
||||
@@ -51,8 +56,18 @@ PlatformerObjectBehavior::GetProperties(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("gravity")));
|
||||
properties[_("Jump speed")].SetValue(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("jumpSpeed")));
|
||||
properties["jumpSustainTime"]
|
||||
.SetValue(gd::String::From(
|
||||
behaviorContent.GetDoubleAttribute("jumpSustainTime", 0)))
|
||||
.SetLabel(_("Jump sustain time"))
|
||||
.SetDescription(
|
||||
_("Maximum time (in seconds) during which the jump strength is "
|
||||
"sustained if the jump key is held - allowing variable height "
|
||||
"jumps."));
|
||||
properties[_("Max. falling speed")].SetValue(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("maxFallingSpeed")));
|
||||
properties[_("Ladder climbing speed")].SetValue(gd::String::From(
|
||||
behaviorContent.GetDoubleAttribute("ladderClimbingSpeed", 150)));
|
||||
properties[_("Acceleration")].SetValue(
|
||||
gd::String::From(behaviorContent.GetDoubleAttribute("acceleration")));
|
||||
properties[_("Deceleration")].SetValue(
|
||||
@@ -91,7 +106,7 @@ bool PlatformerObjectBehavior::UpdateProperty(
|
||||
gd::Project& project) {
|
||||
if (name == _("Default controls"))
|
||||
behaviorContent.SetAttribute("ignoreDefaultControls", (value == "0"));
|
||||
if (name == _("Round coordinates"))
|
||||
else if (name == _("Round coordinates"))
|
||||
behaviorContent.SetAttribute("roundCoordinates", (value == "1"));
|
||||
else if (name == _("Can grab platform ledges"))
|
||||
behaviorContent.SetAttribute("canGrabPlatforms", (value == "1"));
|
||||
@@ -104,6 +119,8 @@ bool PlatformerObjectBehavior::UpdateProperty(
|
||||
behaviorContent.SetAttribute("gravity", value.To<double>());
|
||||
else if (name == _("Max. falling speed"))
|
||||
behaviorContent.SetAttribute("maxFallingSpeed", value.To<double>());
|
||||
else if (name == _("Ladder climbing speed"))
|
||||
behaviorContent.SetAttribute("ladderClimbingSpeed", value.To<double>());
|
||||
else if (name == _("Acceleration"))
|
||||
behaviorContent.SetAttribute("acceleration", value.To<double>());
|
||||
else if (name == _("Deceleration"))
|
||||
@@ -112,6 +129,8 @@ bool PlatformerObjectBehavior::UpdateProperty(
|
||||
behaviorContent.SetAttribute("maxSpeed", value.To<double>());
|
||||
else if (name == _("Jump speed"))
|
||||
behaviorContent.SetAttribute("jumpSpeed", value.To<double>());
|
||||
else if (name == "jumpSustainTime")
|
||||
behaviorContent.SetAttribute("jumpSustainTime", value.To<double>());
|
||||
else if (name == _("Slope max. angle")) {
|
||||
double newMaxAngle = value.To<double>();
|
||||
if (newMaxAngle < 0 || newMaxAngle >= 90) return false;
|
||||
|
@@ -27,6 +27,7 @@ PlatformerObjectRuntimeBehavior::PlatformerObjectRuntimeBehavior(
|
||||
roundCoordinates(true),
|
||||
gravity(1000),
|
||||
maxFallingSpeed(700),
|
||||
ladderClimbingSpeed(150),
|
||||
acceleration(1500),
|
||||
deceleration(1500),
|
||||
maxSpeed(250),
|
||||
@@ -64,6 +65,7 @@ PlatformerObjectRuntimeBehavior::PlatformerObjectRuntimeBehavior(
|
||||
behaviorContent.GetBoolAttribute("roundCoordinates", false);
|
||||
gravity = behaviorContent.GetDoubleAttribute("gravity");
|
||||
maxFallingSpeed = behaviorContent.GetDoubleAttribute("maxFallingSpeed");
|
||||
ladderClimbingSpeed = behaviorContent.GetDoubleAttribute("ladderClimbingSpeed");
|
||||
acceleration = behaviorContent.GetDoubleAttribute("acceleration");
|
||||
deceleration = behaviorContent.GetDoubleAttribute("deceleration");
|
||||
maxSpeed = behaviorContent.GetDoubleAttribute("maxSpeed");
|
||||
@@ -245,8 +247,8 @@ void PlatformerObjectRuntimeBehavior::DoStepPreEvents(RuntimeScene& scene) {
|
||||
!ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Up");
|
||||
downKey |=
|
||||
!ignoreDefaultControls && scene.GetInputManager().IsKeyPressed("Down");
|
||||
if (upKey) requestedDeltaY -= 150 * timeDelta;
|
||||
if (downKey) requestedDeltaY += 150 * timeDelta;
|
||||
if (upKey) requestedDeltaY -= ladderClimbingSpeed * timeDelta;
|
||||
if (downKey) requestedDeltaY += ladderClimbingSpeed * timeDelta;
|
||||
|
||||
// Coming to an extremity of a ladder
|
||||
if (!IsOverlappingLadder(potentialObjects)) {
|
||||
@@ -323,6 +325,7 @@ void PlatformerObjectRuntimeBehavior::DoStepPreEvents(RuntimeScene& scene) {
|
||||
}
|
||||
|
||||
if (jumping) {
|
||||
// TODO: Port the jump sustain feature
|
||||
requestedDeltaY -= currentJumpSpeed * timeDelta;
|
||||
currentJumpSpeed -= gravity * timeDelta;
|
||||
if (currentJumpSpeed < 0) {
|
||||
@@ -448,7 +451,7 @@ void PlatformerObjectRuntimeBehavior::DoStepPreEvents(RuntimeScene& scene) {
|
||||
// this extra check).
|
||||
bool canLand = requestedDeltaY >= 0;
|
||||
|
||||
// Check if landing on a new floor: (Exclude already overlapped jump truh)
|
||||
// Check if landing on a new floor: (Exclude already overlapped jump thru)
|
||||
std::set<PlatformRuntimeBehavior*> collidingObjects =
|
||||
GetPlatformsCollidingWith(potentialObjects, overlappedJumpThru);
|
||||
if (canLand && !collidingObjects.empty()) { // Just landed on floor
|
||||
|
@@ -33,16 +33,23 @@ class GD_EXTENSION_API PlatformerObjectRuntimeBehavior
|
||||
|
||||
double GetGravity() const { return gravity; };
|
||||
double GetMaxFallingSpeed() const { return maxFallingSpeed; };
|
||||
double GetLadderClimbingSpeed() const { return ladderClimbingSpeed; };
|
||||
double GetAcceleration() const { return acceleration; };
|
||||
double GetDeceleration() const { return deceleration; };
|
||||
double GetMaxSpeed() const { return maxSpeed; };
|
||||
double GetJumpSpeed() const { return jumpSpeed; };
|
||||
double GetCurrentFallSpeed() const { return currentFallSpeed; };
|
||||
double GetCurrentSpeed() const { return currentSpeed; };
|
||||
double GetCurrentJumpSpeed() const { return currentJumpSpeed; };
|
||||
double GetSlopeMaxAngle() const { return slopeMaxAngle; };
|
||||
bool CanGrabPlatforms() const { return canGrabPlatforms; };
|
||||
bool CanJump() const { return canJump; };
|
||||
|
||||
void SetGravity(double gravity_) { gravity = gravity_; };
|
||||
void SetMaxFallingSpeed(double maxFallingSpeed_) {
|
||||
maxFallingSpeed = maxFallingSpeed_;
|
||||
};
|
||||
void SetLadderClimbingSpeed(double ladderClimbingSpeed_) { ladderClimbingSpeed = ladderClimbingSpeed_; };
|
||||
void SetAcceleration(double acceleration_) { acceleration = acceleration_; };
|
||||
void SetDeceleration(double deceleration_) { deceleration = deceleration_; };
|
||||
void SetMaxSpeed(double maxSpeed_) { maxSpeed = maxSpeed_; };
|
||||
@@ -180,6 +187,7 @@ class GD_EXTENSION_API PlatformerObjectRuntimeBehavior
|
||||
///< X and Y axis.
|
||||
double gravity; ///< In pixels.seconds^-2
|
||||
double maxFallingSpeed; ///< In pixels.seconds^-1
|
||||
double ladderClimbingSpeed; ///<In pixels.seconds^-1
|
||||
double acceleration; ///< In pixels.seconds^-2
|
||||
double deceleration; ///< In pixels.seconds^-2
|
||||
double maxSpeed; ///< In pixels.seconds^-1
|
||||
|
@@ -31,6 +31,7 @@ gdjs.PlatformerObjectRuntimeBehavior = function(
|
||||
this._roundCoordinates = behaviorData.roundCoordinates;
|
||||
this._gravity = behaviorData.gravity;
|
||||
this._maxFallingSpeed = behaviorData.maxFallingSpeed;
|
||||
this._ladderClimbingSpeed = behaviorData.ladderClimbingSpeed || 150;
|
||||
this._acceleration = behaviorData.acceleration;
|
||||
this._deceleration = behaviorData.deceleration;
|
||||
this._maxSpeed = behaviorData.maxSpeed;
|
||||
@@ -38,6 +39,7 @@ gdjs.PlatformerObjectRuntimeBehavior = function(
|
||||
this._canGrabPlatforms = behaviorData.canGrabPlatforms || false;
|
||||
this._yGrabOffset = behaviorData.yGrabOffset || 0;
|
||||
this._xGrabTolerance = behaviorData.xGrabTolerance || 10;
|
||||
this._jumpSustainTime = behaviorData.jumpSustainTime || 0;
|
||||
this._isOnFloor = false;
|
||||
this._isOnLadder = false;
|
||||
this._floorPlatform = null;
|
||||
@@ -45,6 +47,8 @@ gdjs.PlatformerObjectRuntimeBehavior = function(
|
||||
this._currentSpeed = 0;
|
||||
this._jumping = false;
|
||||
this._currentJumpSpeed = 0;
|
||||
this._timeSinceCurrentJumpStart = 0;
|
||||
this._jumpKeyHeldSinceJumpStart = false;
|
||||
this._canJump = false;
|
||||
this._isGrabbingPlatform = false;
|
||||
this._grabbedPlatform = null;
|
||||
@@ -263,8 +267,8 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(
|
||||
.getGame()
|
||||
.getInputManager()
|
||||
.isKeyPressed(DOWNKEY);
|
||||
if (this._upKey) requestedDeltaY -= 150 * timeDelta;
|
||||
if (this._downKey) requestedDeltaY += 150 * timeDelta;
|
||||
if (this._upKey) requestedDeltaY -= this._ladderClimbingSpeed * timeDelta;
|
||||
if (this._downKey) requestedDeltaY += this._ladderClimbingSpeed * timeDelta;
|
||||
|
||||
//Coming to an extremity of a ladder
|
||||
if (!this._isOverlappingLadder()) {
|
||||
@@ -367,6 +371,8 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(
|
||||
if (this._canJump && this._jumpKey) {
|
||||
this._jumping = true;
|
||||
this._canJump = false;
|
||||
this._timeSinceCurrentJumpStart = 0;
|
||||
this._jumpKeyHeldSinceJumpStart = true;
|
||||
//this._isOnFloor = false; If floor is a very steep slope, the object could go into it.
|
||||
this._isOnLadder = false;
|
||||
this._currentJumpSpeed = this._jumpSpeed;
|
||||
@@ -375,9 +381,22 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.doStepPreEvents = function(
|
||||
//object.setY(object.getY()-1); //Useless and dangerous
|
||||
}
|
||||
|
||||
// Check if the jump key is continuously held since
|
||||
// the beginning of the jump.
|
||||
if (!this._jumpKey) this._jumpKeyHeldSinceJumpStart = false;
|
||||
|
||||
if (this._jumping) {
|
||||
this._timeSinceCurrentJumpStart += timeDelta;
|
||||
requestedDeltaY -= this._currentJumpSpeed * timeDelta;
|
||||
this._currentJumpSpeed -= this._gravity * timeDelta;
|
||||
|
||||
// Decrease jump speed after the (optional) jump sustain time is over.
|
||||
var sustainJumpSpeed =
|
||||
this._jumpKeyHeldSinceJumpStart &&
|
||||
this._timeSinceCurrentJumpStart < this._jumpSustainTime;
|
||||
if (!sustainJumpSpeed) {
|
||||
this._currentJumpSpeed -= this._gravity * timeDelta;
|
||||
}
|
||||
|
||||
if (this._currentJumpSpeed < 0) {
|
||||
this._currentJumpSpeed = 0;
|
||||
this._jumping = false;
|
||||
@@ -866,6 +885,14 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.getMaxFallingSpeed = function() {
|
||||
return this._maxFallingSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the speed used to move on Y axis when climbing a ladder.
|
||||
* @returns {number} The speed of ladder climbing.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.getLadderClimbingSpeed = function() {
|
||||
return this._ladderClimbingSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the acceleration value of the Platformer Object.
|
||||
* @returns {number} The current acceleration.
|
||||
@@ -898,6 +925,54 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.getJumpSpeed = function() {
|
||||
return this._jumpSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the jump sustain time of the Platformer Object.
|
||||
* @returns {number} The jump sustain time.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.getJumpSustainTime = function() {
|
||||
return this._jumpSustainTime;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the speed at which the object is falling. It is 0 when the object is on a floor, and non 0 as soon as the object leaves the floor.
|
||||
* @returns {number} The current fall speed.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.getCurrentFallSpeed = function() {
|
||||
return this._currentFallSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current speed of the Platformer Object.
|
||||
* @returns {number} The current speed.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.getCurrentSpeed = function() {
|
||||
return this._currentSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current jump speed of the Platformer Object.
|
||||
* @returns {number} The current jump speed.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.getCurrentJumpSpeed = function() {
|
||||
return this._currentJumpSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the Platformer Object can grab the platforms.
|
||||
* @returns {boolean} Returns true if the object can grab the platforms.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.canGrabPlatforms = function() {
|
||||
return this._canGrabPlatforms;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the Platformer Object can jump.
|
||||
* @returns {boolean} Returns true if the object can jump.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.canJump = function() {
|
||||
return this._canJump;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the gravity of the Platformer Object.
|
||||
* @param {number} gravity The new gravity.
|
||||
@@ -916,6 +991,16 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.setMaxFallingSpeed = function(
|
||||
this._maxFallingSpeed = maxFallingSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the speed used to move on Y axis when climbing a ladder.
|
||||
* @param {number} ladderClimbingSpeed The speed of ladder climbing.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.setLadderClimbingSpeed = function (
|
||||
ladderClimbingSpeed
|
||||
) {
|
||||
this._ladderClimbingSpeed = ladderClimbingSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the acceleration of the Platformer Object.
|
||||
* @param {number} acceleration The new acceleration.
|
||||
@@ -956,6 +1041,16 @@ gdjs.PlatformerObjectRuntimeBehavior.prototype.setJumpSpeed = function(
|
||||
this._jumpSpeed = jumpSpeed;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the jump sustain time of the Platformer Object.
|
||||
* @param {number} jumpSpeed The new jump sustain time.
|
||||
*/
|
||||
gdjs.PlatformerObjectRuntimeBehavior.prototype.setJumpSustainTime = function(
|
||||
jumpSustainTime
|
||||
) {
|
||||
this._jumpSustainTime = jumpSustainTime;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the maximum slope angle of the Platformer Object.
|
||||
* @param {number} slopeMaxAngle The new maximum slope angle.
|
||||
|
@@ -1,282 +1,483 @@
|
||||
const makeTestRuntimeScene = () => {
|
||||
const runtimeGame = new gdjs.RuntimeGame({
|
||||
variables: [],
|
||||
resources: {
|
||||
resources: [],
|
||||
},
|
||||
properties: { windowWidth: 800, windowHeight: 600 },
|
||||
});
|
||||
const runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{ name: '', visibility: true }],
|
||||
variables: [],
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: [],
|
||||
});
|
||||
runtimeScene._timeManager.getElapsedTime = function() {
|
||||
return (1 / 60) * 1000;
|
||||
};
|
||||
return runtimeScene;
|
||||
};
|
||||
|
||||
const addPlatformObject = runtimeScene => {
|
||||
var platform = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj2',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformBehavior',
|
||||
canBeGrabbed: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
platform.getWidth = function() {
|
||||
return 60;
|
||||
};
|
||||
platform.getHeight = function() {
|
||||
return 32;
|
||||
};
|
||||
runtimeScene.addObject(platform);
|
||||
|
||||
return platform;
|
||||
};
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: []
|
||||
});
|
||||
runtimeScene._timeManager.getElapsedTime = function() { return 1 / 60 * 1000; };
|
||||
const runtimeScene = makeTestRuntimeScene();
|
||||
|
||||
//Put a platformer object in the air.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformerObjectBehavior",
|
||||
name: "auto1",
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 1500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60
|
||||
}]});
|
||||
object.getWidth = function() { return 10; };
|
||||
object.getHeight = function() { return 20; };
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -100);
|
||||
//Put a platformer object in the air.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj1',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformerObjectBehavior',
|
||||
name: 'auto1',
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 1500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60,
|
||||
},
|
||||
],
|
||||
});
|
||||
object.getWidth = function() {
|
||||
return 10;
|
||||
};
|
||||
object.getHeight = function() {
|
||||
return 20;
|
||||
};
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -100);
|
||||
|
||||
//Put a platform
|
||||
var platform = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
}]});
|
||||
platform.getWidth = function() { return 60; };
|
||||
platform.getHeight = function() { return 32; };
|
||||
runtimeScene.addObject(platform);
|
||||
platform.setPosition(0, -10);
|
||||
//Put a platform
|
||||
const platform = addPlatformObject(runtimeScene);
|
||||
platform.setPosition(0, -10);
|
||||
|
||||
it('can fall when in the air', function() {
|
||||
for(var i = 0; i<30; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
if (i < 10) expect(object.getBehavior("auto1").isFalling()).to.be(true);
|
||||
}
|
||||
it('can fall when in the air', function() {
|
||||
for (var i = 0; i < 30; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
if (i < 10) expect(object.getBehavior('auto1').isFalling()).to.be(true);
|
||||
}
|
||||
|
||||
//Check the platform stopped the platformer object.
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getBehavior("auto1").isMoving()).to.be(false);
|
||||
//Check the platform stopped the platformer object.
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
for(var i = 0; i<35; ++i) { //Check that the platformer object can fall.
|
||||
object.getBehavior("auto1").simulateRightKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getX()).to.be.within(87.50, 87.51);
|
||||
expect(object.getY()).to.be(-24.75);
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(true);
|
||||
for (var i = 0; i < 35; ++i) {
|
||||
//Check that the platformer object can fall.
|
||||
object.getBehavior('auto1').simulateRightKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getX()).to.be.within(87.5, 87.51);
|
||||
expect(object.getY()).to.be(-24.75);
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(true);
|
||||
|
||||
for(var i = 0; i<100; ++i) { //Let the speed on X axis go back to 0.
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
});
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
//Let the speed on X axis go back to 0.
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
});
|
||||
|
||||
it('can grab, and release, a platform', function() {
|
||||
//Put the object near the right ledge of the platform.
|
||||
object.setPosition(platform.getX() + platform.getWidth() + 2, platform.getY() - 10);
|
||||
it('can grab, and release, a platform', function() {
|
||||
//Put the object near the right ledge of the platform.
|
||||
object.setPosition(
|
||||
platform.getX() + platform.getWidth() + 2,
|
||||
platform.getY() - 10
|
||||
);
|
||||
|
||||
for(var i = 0; i<35; ++i) {
|
||||
object.getBehavior("auto1").simulateLeftKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
for (var i = 0; i < 35; ++i) {
|
||||
object.getBehavior('auto1').simulateLeftKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
//Check that the object grabbed the platform
|
||||
expect(object.getX()).to.be.within(
|
||||
platform.getX() + platform.getWidth() + 1,
|
||||
platform.getX() + platform.getWidth() + 2
|
||||
);
|
||||
expect(object.getY()).to.be(platform.getY());
|
||||
//Check that the object grabbed the platform
|
||||
expect(object.getX()).to.be.within(
|
||||
platform.getX() + platform.getWidth() + 1,
|
||||
platform.getX() + platform.getWidth() + 2
|
||||
);
|
||||
expect(object.getY()).to.be(platform.getY());
|
||||
|
||||
object.getBehavior("auto1").simulateReleaseKey();
|
||||
for(var i = 0; i<10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
object.getBehavior('auto1').simulateReleaseKey();
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
//Check that the object is falling
|
||||
expect(object.getY()).to.be(1.25);
|
||||
});
|
||||
//Check that the object is falling
|
||||
expect(object.getY()).to.be(1.25);
|
||||
});
|
||||
|
||||
it('can track object height changes', function() {
|
||||
//Put the object near the right ledge of the platform.
|
||||
object.setPosition(platform.getX() + 10, platform.getY() - object.getHeight() - 1);
|
||||
it('can track object height changes', function() {
|
||||
//Put the object near the right ledge of the platform.
|
||||
object.setPosition(
|
||||
platform.getX() + 10,
|
||||
platform.getY() - object.getHeight() - 1
|
||||
);
|
||||
|
||||
for(var i = 0; i<15; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
for (var i = 0; i < 15; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getX()).to.be(10);
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getX()).to.be(10);
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
|
||||
object.getHeight = function() { return 9; }
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getY()).to.be(-19); // -19 = -10 (platform y) + -9 (object height)
|
||||
object.getHeight = function() {
|
||||
return 9;
|
||||
};
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getY()).to.be(-19); // -19 = -10 (platform y) + -9 (object height)
|
||||
|
||||
for(var i = 0; i<10; ++i) {
|
||||
object.getBehavior("auto1").simulateRightKey();
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
}
|
||||
expect(object.getY()).to.be(-19);
|
||||
expect(object.getX()).to.be.within(17.638, 17.639);
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
object.getBehavior('auto1').simulateRightKey();
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
}
|
||||
expect(object.getY()).to.be(-19);
|
||||
expect(object.getX()).to.be.within(17.638, 17.639);
|
||||
|
||||
object.getHeight = function() { return 20; }
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
});
|
||||
object.getHeight = function() {
|
||||
return 20;
|
||||
};
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
});
|
||||
});
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior, jump and jump sustain (round coordinates on)', function() {
|
||||
const runtimeScene = makeTestRuntimeScene();
|
||||
|
||||
//Put a platformer object on a platform
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj1',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformerObjectBehavior',
|
||||
name: 'auto1',
|
||||
gravity: 1500,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 900,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60,
|
||||
jumpSustainTime: 0.2,
|
||||
roundCoordinates: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
object.getWidth = function() {
|
||||
return 10;
|
||||
};
|
||||
object.getHeight = function() {
|
||||
return 20;
|
||||
};
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -32);
|
||||
|
||||
//Put a platform
|
||||
const platform = addPlatformObject(runtimeScene);
|
||||
platform.setPosition(0, -10);
|
||||
|
||||
it('can jump', function() {
|
||||
// Ensure the object falls on the platform
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
//Check the object is on the platform
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
// Jump without sustaining
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
for (var i = 0; i < 18; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
// Check that we reached the maximum height
|
||||
expect(object.getY()).to.be.within(-180, -179);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be(-180);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-180, -179);
|
||||
|
||||
// Then let the object fall
|
||||
for (var i = 0; i < 60; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30);
|
||||
});
|
||||
|
||||
it('can jump, sustaining the jump', function() {
|
||||
//Check the object is on the platform
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
// Jump with sustaining as much as possible, and
|
||||
// even more (18 frames at 60fps is greater than 0.2s)
|
||||
for (var i = 0; i < 18; ++i) {
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
// Check the height reached
|
||||
expect(object.getY()).to.be(-230);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be(-235);
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
// Verify that pressing the jump key does not change anything
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
// Check that we reached the maximum height
|
||||
expect(object.getY()).to.be(-247.5);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be(-247.5);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-247, -246);
|
||||
|
||||
// Then let the object fall
|
||||
for (var i = 0; i < 60; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30);
|
||||
});
|
||||
|
||||
it('can jump, and only sustain the jump while key held', function() {
|
||||
//Check the object is on the platform
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
// Jump with sustaining a bit (5 frames at 60fps = 0.08s), then stop
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(-101, -100);
|
||||
|
||||
// Stop holding the jump key
|
||||
runtimeScene.renderAndStep();
|
||||
|
||||
for (var i = 0; i < 13; ++i) {
|
||||
// then hold it again (but it's too late, jump sustain is gone for this jump)
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
// Check that we reached the maximum height
|
||||
expect(object.getY()).to.be.within(-206, -205);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-208, -207);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-208, -207);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-208, -207);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-206, -205);
|
||||
runtimeScene.renderAndStep();
|
||||
|
||||
// Then let the object fall
|
||||
for (var i = 0; i < 60; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior, jumpthru', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: []
|
||||
});
|
||||
runtimeScene._timeManager.getElapsedTime = function() { return 1 / 60 * 1000; };
|
||||
const runtimeScene = makeTestRuntimeScene();
|
||||
|
||||
//Put a platformer object in a platform.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformerObjectBehavior",
|
||||
name: "auto1",
|
||||
roundCoordinates: true,
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60
|
||||
}]});
|
||||
object.getWidth = function() { return 10; };
|
||||
object.getHeight = function() { return 20; };
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -30);
|
||||
//Put a platformer object in a platform.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj1',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformerObjectBehavior',
|
||||
name: 'auto1',
|
||||
roundCoordinates: true,
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60,
|
||||
},
|
||||
],
|
||||
});
|
||||
object.getWidth = function() {
|
||||
return 10;
|
||||
};
|
||||
object.getHeight = function() {
|
||||
return 20;
|
||||
};
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -30);
|
||||
|
||||
//Put a platform
|
||||
var platform = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
platformType: "Platform",
|
||||
}]});
|
||||
platform.getWidth = function() { return 60; };
|
||||
platform.getHeight = function() { return 32; };
|
||||
runtimeScene.addObject(platform);
|
||||
platform.setPosition(0, -10);
|
||||
//Put a platform
|
||||
const platform = addPlatformObject(runtimeScene);
|
||||
platform.setPosition(0, -10);
|
||||
|
||||
// Put a jump thru, higher than the platform so that the object jump from under it
|
||||
// and will land on it at the end of the jump.
|
||||
var jumpthru = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
platformType: "Jumpthru",
|
||||
}]});
|
||||
jumpthru.getWidth = function() { return 60; };
|
||||
jumpthru.getHeight = function() { return 5; };
|
||||
runtimeScene.addObject(jumpthru);
|
||||
jumpthru.setPosition(0, -33);
|
||||
// Put a jump thru, higher than the platform so that the object jump from under it
|
||||
// and will land on it at the end of the jump.
|
||||
var jumpthru = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj2',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformBehavior',
|
||||
canBeGrabbed: true,
|
||||
platformType: 'Jumpthru',
|
||||
},
|
||||
],
|
||||
});
|
||||
jumpthru.getWidth = function() {
|
||||
return 60;
|
||||
};
|
||||
jumpthru.getHeight = function() {
|
||||
return 5;
|
||||
};
|
||||
runtimeScene.addObject(jumpthru);
|
||||
jumpthru.setPosition(0, -33);
|
||||
|
||||
it('can jump through the jumpthru', function() {
|
||||
//Check the platform stopped the platformer object.
|
||||
for(var i = 0; i<5; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getBehavior("auto1").isMoving()).to.be(false);
|
||||
it('can jump through the jumpthru', function() {
|
||||
//Check the platform stopped the platformer object.
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be(-30); // -30 = -10 (platform y) + -20 (object height)
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
// Check that the jump starts properly, and is not stopped on the jumpthru
|
||||
object.getBehavior("auto1").simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-39, -38);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-47, -46);
|
||||
runtimeScene.renderAndStep();
|
||||
// At this step, the object is almost on the jumpthru (-53 + 20 (object height) = -33 (jump thru Y position)),
|
||||
// but the object should not stop.
|
||||
expect(object.getY()).to.be.within(-54, -53);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-61, -60);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-67, -66);
|
||||
expect(object.getBehavior("auto1").isJumping()).to.be(true);
|
||||
// Check that the jump starts properly, and is not stopped on the jumpthru
|
||||
object.getBehavior('auto1').simulateJumpKey();
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-39, -38);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-47, -46);
|
||||
runtimeScene.renderAndStep();
|
||||
// At this step, the object is almost on the jumpthru (-53 + 20 (object height) = -33 (jump thru Y position)),
|
||||
// but the object should not stop.
|
||||
expect(object.getY()).to.be.within(-54, -53);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-61, -60);
|
||||
runtimeScene.renderAndStep();
|
||||
expect(object.getY()).to.be.within(-67, -66);
|
||||
expect(object.getBehavior('auto1').isJumping()).to.be(true);
|
||||
|
||||
// Continue the simulation and check that position is correct in the middle of the jump
|
||||
for(var i = 0; i<20; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(-89, -88);
|
||||
// Continue the simulation and check that position is correct in the middle of the jump
|
||||
for (var i = 0; i < 20; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(-89, -88);
|
||||
|
||||
// Continue simulation and check that we arrive on the jumpthru
|
||||
for(var i = 0; i<10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(jumpthru.getY() - object.getHeight(), jumpthru.getY() - object.getHeight() + 1);
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
});
|
||||
// Continue simulation and check that we arrive on the jumpthru
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
expect(object.getY()).to.be.within(
|
||||
jumpthru.getY() - object.getHeight(),
|
||||
jumpthru.getY() - object.getHeight() + 1
|
||||
);
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gdjs.PlatformerObjectRuntimeBehavior, rounded coordinates (moving platforms)', function() {
|
||||
var runtimeGame = new gdjs.RuntimeGame({variables: [], properties: {windowWidth: 800, windowHeight: 600}});
|
||||
var runtimeScene = new gdjs.RuntimeScene(runtimeGame);
|
||||
runtimeScene.loadFromScene({
|
||||
layers: [{name: "", visibility: true}],
|
||||
variables: [],
|
||||
behaviorsSharedData: [],
|
||||
objects: [],
|
||||
instances: []
|
||||
});
|
||||
runtimeScene._timeManager.getElapsedTime = function() { return 1 / 60 * 1000; };
|
||||
const runtimeScene = makeTestRuntimeScene();
|
||||
|
||||
//Put a platformer object on a platform.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {name: "obj1", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformerObjectBehavior",
|
||||
name: "auto1",
|
||||
roundCoordinates: true,
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 1500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60
|
||||
}]});
|
||||
object.getWidth = function() { return 10; };
|
||||
object.getHeight = function() { return 20; };
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -30);
|
||||
//Put a platformer object on a platform.
|
||||
var object = new gdjs.RuntimeObject(runtimeScene, {
|
||||
name: 'obj1',
|
||||
type: '',
|
||||
behaviors: [
|
||||
{
|
||||
type: 'PlatformBehavior::PlatformerObjectBehavior',
|
||||
name: 'auto1',
|
||||
roundCoordinates: true,
|
||||
gravity: 900,
|
||||
maxFallingSpeed: 1500,
|
||||
acceleration: 500,
|
||||
deceleration: 1500,
|
||||
maxSpeed: 500,
|
||||
jumpSpeed: 1500,
|
||||
canGrabPlatforms: true,
|
||||
ignoreDefaultControls: true,
|
||||
slopeMaxAngle: 60,
|
||||
},
|
||||
],
|
||||
});
|
||||
object.getWidth = function() {
|
||||
return 10;
|
||||
};
|
||||
object.getHeight = function() {
|
||||
return 20;
|
||||
};
|
||||
runtimeScene.addObject(object);
|
||||
object.setPosition(0, -30);
|
||||
|
||||
//Put a platform
|
||||
var platform = new gdjs.RuntimeObject(runtimeScene, {name: "obj2", type: "", behaviors: [{
|
||||
type: "PlatformBehavior::PlatformBehavior",
|
||||
canBeGrabbed: true,
|
||||
}]});
|
||||
platform.getWidth = function() { return 60; };
|
||||
platform.getHeight = function() { return 32; };
|
||||
runtimeScene.addObject(platform);
|
||||
platform.setPosition(0, -10);
|
||||
//Put a platform
|
||||
const platform = addPlatformObject(runtimeScene);
|
||||
platform.setPosition(0, -10);
|
||||
|
||||
it('follows the platform', function() {
|
||||
for(var i = 0; i<30; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
it('follows the platform', function() {
|
||||
for (var i = 0; i < 30; ++i) {
|
||||
runtimeScene.renderAndStep();
|
||||
}
|
||||
|
||||
// Check the object has not moved.
|
||||
expect(object.getY()).to.be(-30);
|
||||
expect(object.getX()).to.be(0);
|
||||
expect(object.getBehavior("auto1").isOnFloor()).to.be(true);
|
||||
expect(object.getBehavior("auto1").isFalling()).to.be(false);
|
||||
expect(object.getBehavior("auto1").isMoving()).to.be(false);
|
||||
// Check the object has not moved.
|
||||
expect(object.getY()).to.be(-30);
|
||||
expect(object.getX()).to.be(0);
|
||||
expect(object.getBehavior('auto1').isOnFloor()).to.be(true);
|
||||
expect(object.getBehavior('auto1').isFalling()).to.be(false);
|
||||
expect(object.getBehavior('auto1').isMoving()).to.be(false);
|
||||
|
||||
// Check that the object follow the platform, even if the
|
||||
// movement is less than one pixel.
|
||||
platform.setX(platform.getX()+0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
platform.setX(platform.getX()+0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
platform.setX(platform.getX()+0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
// Check that the object follow the platform, even if the
|
||||
// movement is less than one pixel.
|
||||
platform.setX(platform.getX() + 0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
platform.setX(platform.getX() + 0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
platform.setX(platform.getX() + 0.12);
|
||||
runtimeScene.renderAndStep();
|
||||
|
||||
expect(object.getX()).to.be(0.36);
|
||||
});
|
||||
expect(object.getX()).to.be(0.36);
|
||||
});
|
||||
});
|
||||
|
@@ -217,7 +217,7 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
_("Begin fill path"),
|
||||
_("Begin to draw a simple one-color fill. Subsequent actions, such as \"Path line\" (in the Advanced category) can be used to draw. Be sure to use \"End fill path\" action when you're done drawing the shape."),
|
||||
_("Begins drawing filling of an advanced path "
|
||||
"with _PARAM0_"),
|
||||
"with _PARAM0_ (start: _PARAM1_;_PARAM2_)"),
|
||||
_("Advanced"),
|
||||
"res/actions/beginFillPath24.png",
|
||||
"res/actions/beginFillPath.png")
|
||||
@@ -339,6 +339,33 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.SetFunctionName("closePath")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("ClearBetweenFrames",
|
||||
_("Clear between frames"),
|
||||
_("Activate (or deactivate) the clearing of the rendered shape at the beginning of each frame."),
|
||||
_("Clear the rendered image of _PARAM0_ between each frame: PARAM1"),
|
||||
_("Setup"),
|
||||
"res/actions/visibilite24.png",
|
||||
"res/actions/visibilite.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("yesorno", _("Clear between each frame"), "", true)
|
||||
.SetDefaultValue("yes")
|
||||
.SetFunctionName("SetClearBetweenFrames")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddCondition(
|
||||
"ClearBetweenFrames",
|
||||
_("Clear between frames"),
|
||||
_("Check if the rendered image is cleared between frames."),
|
||||
_("_PARAM0_ is clearing its rendered image between each frame"),
|
||||
_("Setup"),
|
||||
"res/conditions/visibilite24.png",
|
||||
"res/conditions/visibilite.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.SetFunctionName("IsClearedBetweenFrames")
|
||||
.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("FillColor",
|
||||
_("Fill color"),
|
||||
_("Change the color used when filling"),
|
||||
|
@@ -105,6 +105,12 @@ class PrimitiveDrawingJsExtension : public gd::PlatformExtension {
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::ArcTo"]
|
||||
.SetFunctionName("drawArcTo");*/
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::ClearBetweenFrames"]
|
||||
.SetFunctionName("setClearBetweenFrames");
|
||||
GetAllConditionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::ClearBetweenFrames"]
|
||||
.SetFunctionName("isClearedBetweenFrames");
|
||||
GetAllActionsForObject(
|
||||
"PrimitiveDrawing::Drawer")["PrimitiveDrawing::FillColor"]
|
||||
.SetFunctionName("setFillColor");
|
||||
|
@@ -34,6 +34,7 @@ ShapePainterObjectBase::ShapePainterObjectBase()
|
||||
outlineColorG(0),
|
||||
outlineColorB(0),
|
||||
outlineOpacity(255),
|
||||
clearBetweenFrames(true),
|
||||
absoluteCoordinates(false) {}
|
||||
|
||||
ShapePainterObject::ShapePainterObject(gd::String name_) : gd::Object(name_) {}
|
||||
@@ -72,6 +73,7 @@ void ShapePainterObjectBase::DoUnserializeFrom(
|
||||
element.GetChild("absoluteCoordinates", 0, "AbsoluteCoordinates")
|
||||
.GetValue()
|
||||
.GetBool();
|
||||
clearBetweenFrames = element.HasChild("clearBetweenFrames") ? element.GetChild("clearBetweenFrames").GetValue().GetBool() : true;
|
||||
}
|
||||
|
||||
void ShapePainterObject::DoUnserializeFrom(
|
||||
@@ -94,6 +96,7 @@ void ShapePainterObjectBase::DoSerializeTo(
|
||||
.SetAttribute("g", (int)outlineColorG)
|
||||
.SetAttribute("b", (int)outlineColorB);
|
||||
element.AddChild("absoluteCoordinates").SetValue(absoluteCoordinates);
|
||||
element.AddChild("clearBetweenFrames").SetValue(clearBetweenFrames);
|
||||
}
|
||||
|
||||
void ShapePainterObject::DoSerializeTo(gd::SerializerElement& element) const {
|
||||
|
@@ -81,6 +81,9 @@ class GD_EXTENSION_API ShapePainterObjectBase {
|
||||
inline void SetCoordinatesRelative() { absoluteCoordinates = false; }
|
||||
inline bool AreCoordinatesAbsolute() { return absoluteCoordinates; }
|
||||
|
||||
inline void SetClearBetweenFrames(bool value) { clearBetweenFrames = value; }
|
||||
inline bool IsClearedBetweenFrames() { return clearBetweenFrames; }
|
||||
|
||||
protected:
|
||||
virtual void DoUnserializeFrom(const gd::SerializerElement& element);
|
||||
#if defined(GD_IDE_ONLY)
|
||||
@@ -102,6 +105,7 @@ class GD_EXTENSION_API ShapePainterObjectBase {
|
||||
float outlineOpacity;
|
||||
|
||||
bool absoluteCoordinates;
|
||||
bool clearBetweenFrames;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@
|
||||
* @property {number} outlineOpacity The opacity of the outline of the painted shape
|
||||
* @property {number} outlineSize The size of the outline of the painted shape, in pixels.
|
||||
* @property {boolean} absoluteCoordinates Use absolute coordinates?
|
||||
* @property {boolean} clearBetweenFrames Clear the previous render before the next draw?
|
||||
*
|
||||
* @typedef {ObjectData & ShapePainterObjectDataType} ShapePainterObjectData
|
||||
*/
|
||||
@@ -53,6 +54,9 @@ gdjs.ShapePainterRuntimeObject = function(runtimeScene, shapePainterObjectData)
|
||||
/** @type {boolean} */
|
||||
this._absoluteCoordinates = shapePainterObjectData.absoluteCoordinates;
|
||||
|
||||
/** @type {boolean} */
|
||||
this._clearBetweenFrames = shapePainterObjectData.clearBetweenFrames;
|
||||
|
||||
if (this._renderer)
|
||||
gdjs.ShapePainterRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
|
||||
else
|
||||
@@ -72,7 +76,9 @@ gdjs.ShapePainterRuntimeObject.prototype.getRendererObject = function() {
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.stepBehaviorsPreEvents = function(runtimeScene) {
|
||||
//We redefine stepBehaviorsPreEvents just to clear the graphics before running events.
|
||||
this._renderer.clear();
|
||||
if(this._clearBetweenFrames){
|
||||
this._renderer.clear();
|
||||
}
|
||||
|
||||
gdjs.RuntimeObject.prototype.stepBehaviorsPreEvents.call(this, runtimeScene);
|
||||
};
|
||||
@@ -154,6 +160,14 @@ gdjs.ShapePainterRuntimeObject.prototype.closePath = function() {
|
||||
this._renderer.closePath();
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.setClearBetweenFrames = function(value) {
|
||||
this._clearBetweenFrames = value;
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.isClearedBetweenFrames = function() {
|
||||
return this._clearBetweenFrames;
|
||||
};
|
||||
|
||||
gdjs.ShapePainterRuntimeObject.prototype.setFillColor = function(rgbColor) {
|
||||
var colors = rgbColor.split(";");
|
||||
if ( colors.length < 3 ) return;
|
||||
|
@@ -1,17 +1,26 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
*
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
* and search for any errors.
|
||||
*
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function (_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension.setExtensionInformation(
|
||||
"Screenshot",
|
||||
@@ -43,5 +52,5 @@ module.exports = {
|
||||
|
||||
return extension;
|
||||
},
|
||||
runExtensionSanityTests: function (gd, extension) { return []; },
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) { return []; },
|
||||
};
|
||||
|
@@ -42,6 +42,21 @@ void DeclareSystemInfoExtension(gd::PlatformExtension& extension) {
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.SetFunctionName("SystemInfo::IsWebGLSupported")
|
||||
.SetIncludeFile("SystemInfo/SystemInfoTools.h");
|
||||
|
||||
extension
|
||||
.AddCondition(
|
||||
"IsPreview",
|
||||
_("Is the game running as a preview"),
|
||||
_(
|
||||
"Check if the game is currently being previewed in the editor. "
|
||||
"This can be used to enable a \"Debug mode\" or do some work only in previews."
|
||||
),
|
||||
_("The game is being previewed in the editor"),
|
||||
_("System information"),
|
||||
"CppPlatform/Extensions/systeminfoicon24.png",
|
||||
"CppPlatform/Extensions/systeminfoicon16.png")
|
||||
|
||||
.AddCodeOnlyParameter("currentScene", "");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,10 @@ class SystemInfoJsExtension : public gd::PlatformExtension {
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isWebGLSupported");
|
||||
GetAllConditions()["SystemInfo::IsPreview"]
|
||||
.codeExtraInformation
|
||||
.SetIncludeFile("Extensions/SystemInfo/systeminfotools.js")
|
||||
.SetFunctionName("gdjs.evtTools.systemInfo.isPreview");
|
||||
|
||||
StripUnimplementedInstructionsAndExpressions();
|
||||
GD_COMPLETE_EXTENSION_COMPILATION_INFORMATION();
|
||||
|
@@ -36,4 +36,13 @@ gdjs.evtTools.systemInfo.isMobile = function() {
|
||||
*/
|
||||
gdjs.evtTools.systemInfo.isWebGLSupported = function(runtimeScene) {
|
||||
return runtimeScene.getGame().getRenderer().isWebGLSupported();
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the game is running as a preview, launched from an editor.
|
||||
* @param {gdjs.RuntimeScene} runtimeScene The current scene.
|
||||
* @returns {boolean} true if the game is running as a preview.
|
||||
*/
|
||||
gdjs.evtTools.systemInfo.isPreview = function(runtimeScene) {
|
||||
return runtimeScene.getGame().isPreview();
|
||||
};
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,8 +11,16 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function(_/*: (string) => string */, gd/*: libGDevelop */) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
@@ -25,6 +34,7 @@ module.exports = {
|
||||
|
||||
var tweenBehavior = new gd.BehaviorJsImplementation();
|
||||
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
tweenBehavior.updateProperty = function(
|
||||
behaviorContent,
|
||||
propertyName,
|
||||
@@ -33,11 +43,13 @@ module.exports = {
|
||||
return false;
|
||||
};
|
||||
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
tweenBehavior.getProperties = function(behaviorContent) {
|
||||
var behaviorProperties = new gd.MapStringPropertyDescriptor();
|
||||
return behaviorProperties;
|
||||
};
|
||||
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating a behavior
|
||||
tweenBehavior.initializeContent = function(behaviorContent) {};
|
||||
|
||||
const behavior = extension
|
||||
@@ -550,7 +562,6 @@ module.exports = {
|
||||
_("Progress of a tween"),
|
||||
_("Progress of a tween (between 0.0 and 1.0)"),
|
||||
"",
|
||||
"JsPlatform/Extensions/tween_behavior24.png",
|
||||
"JsPlatform/Extensions/tween_behavior32.png"
|
||||
)
|
||||
.addParameter("object", _("Object"), "", false)
|
||||
@@ -562,7 +573,7 @@ module.exports = {
|
||||
return extension;
|
||||
},
|
||||
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function(gd /*: libGDevelop */, extension /*: gdPlatformExtension*/) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
/**
|
||||
* This is a declaration of an extension for GDevelop 5.
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change
|
||||
* to this extension file or to any other *.js file that you reference inside.
|
||||
* ℹ️ Changes in this file are watched and automatically imported if the editor
|
||||
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
|
||||
*
|
||||
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
|
||||
* ⚠️ If you make a change and the extension is not loaded, open the developer console
|
||||
@@ -10,72 +11,81 @@
|
||||
*
|
||||
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
|
||||
*/
|
||||
|
||||
/*::
|
||||
// Import types to allow Flow to do static type checking on this file.
|
||||
// Extensions declaration are typed using Flow (like the editor), but the files
|
||||
// for the game engine are checked with TypeScript annotations.
|
||||
import { type ObjectsRenderingService, type ObjectsEditorService } from '../JsExtensionTypes.flow.js'
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
createExtension: function(_, gd) {
|
||||
createExtension: function (
|
||||
_ /*: (string) => string */,
|
||||
gd /*: libGDevelop */
|
||||
) {
|
||||
const extension = new gd.PlatformExtension();
|
||||
extension
|
||||
.setExtensionInformation(
|
||||
"Video",
|
||||
"Video",
|
||||
_("Display a video on the scene."),
|
||||
"Aurélien Vivet",
|
||||
"Open source (MIT License)"
|
||||
'Video',
|
||||
'Video',
|
||||
_('Display a video on the scene.'),
|
||||
'Aurélien Vivet',
|
||||
'Open source (MIT License)'
|
||||
)
|
||||
.setExtensionHelpPath("/objects/video");
|
||||
.setExtensionHelpPath('/objects/video');
|
||||
|
||||
var videoObject = new gd.ObjectJsImplementation();
|
||||
videoObject.updateProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
videoObject.updateProperty = function (
|
||||
objectContent,
|
||||
propertyName,
|
||||
newValue
|
||||
) {
|
||||
if (propertyName === "Opacity") {
|
||||
if (propertyName === 'Opacity') {
|
||||
objectContent.opacity = parseFloat(newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "Looped") {
|
||||
objectContent.loop = newValue === "1";
|
||||
if (propertyName === 'Looped') {
|
||||
objectContent.loop = newValue === '1';
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "Volume") {
|
||||
if (propertyName === 'Volume') {
|
||||
objectContent.volume = parseFloat(newValue);
|
||||
return true;
|
||||
}
|
||||
if (propertyName === "videoResource") {
|
||||
if (propertyName === 'videoResource') {
|
||||
objectContent.videoResource = newValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
videoObject.getProperties = function(objectContent) {
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
videoObject.getProperties = function (objectContent) {
|
||||
var objectProperties = new gd.MapStringPropertyDescriptor();
|
||||
|
||||
objectProperties.set(
|
||||
"Opacity",
|
||||
new gd.PropertyDescriptor(objectContent.opacity.toString())
|
||||
.setType("number")
|
||||
.setLabel(_("Video opacity (0-255)"))
|
||||
);
|
||||
objectProperties.set(
|
||||
"Looped",
|
||||
new gd.PropertyDescriptor(objectContent.loop ? "true" : "false")
|
||||
.setType("boolean")
|
||||
.setLabel(_("Loop the video"))
|
||||
);
|
||||
objectProperties.set(
|
||||
"Volume",
|
||||
new gd.PropertyDescriptor(objectContent.volume.toString())
|
||||
.setType("number")
|
||||
.setLabel(_("Video volume (0-100)"))
|
||||
);
|
||||
objectProperties.set(
|
||||
"videoResource",
|
||||
new gd.PropertyDescriptor(objectContent.videoResource)
|
||||
.setType("resource")
|
||||
.addExtraInfo("video")
|
||||
.setLabel(_("Video resource"))
|
||||
);
|
||||
objectProperties
|
||||
.getOrCreate('Opacity')
|
||||
.setValue(objectContent.opacity.toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Video opacity (0-255)'));
|
||||
objectProperties
|
||||
.getOrCreate('Looped')
|
||||
.setValue(objectContent.loop ? 'true' : 'false')
|
||||
.setType('boolean')
|
||||
.setLabel(_('Loop the video'));
|
||||
objectProperties
|
||||
.getOrCreate('Volume')
|
||||
.setValue(objectContent.volume.toString())
|
||||
.setType('number')
|
||||
.setLabel(_('Video volume (0-100)'));
|
||||
objectProperties
|
||||
.getOrCreate('videoResource')
|
||||
.setValue(objectContent.videoResource)
|
||||
.setType('resource')
|
||||
.addExtraInfo('video')
|
||||
.setLabel(_('Video resource'));
|
||||
|
||||
return objectProperties;
|
||||
};
|
||||
@@ -84,11 +94,12 @@ module.exports = {
|
||||
opacity: 255,
|
||||
loop: false,
|
||||
volume: 100,
|
||||
videoResource: ""
|
||||
videoResource: '',
|
||||
})
|
||||
);
|
||||
|
||||
videoObject.updateInitialInstanceProperty = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
videoObject.updateInitialInstanceProperty = function (
|
||||
objectContent,
|
||||
instance,
|
||||
propertyName,
|
||||
@@ -98,7 +109,8 @@ module.exports = {
|
||||
) {
|
||||
return false;
|
||||
};
|
||||
videoObject.getInitialInstanceProperties = function(
|
||||
// $FlowExpectedError - ignore Flow warning as we're creating an object
|
||||
videoObject.getInitialInstanceProperties = function (
|
||||
content,
|
||||
instance,
|
||||
project,
|
||||
@@ -110,352 +122,352 @@ module.exports = {
|
||||
|
||||
const object = extension
|
||||
.addObject(
|
||||
"VideoObject",
|
||||
_("Video"),
|
||||
_("Displays a video."),
|
||||
"JsPlatform/Extensions/videoicon32.png",
|
||||
'VideoObject',
|
||||
_('Video'),
|
||||
_('Displays a video.'),
|
||||
'JsPlatform/Extensions/videoicon32.png',
|
||||
videoObject
|
||||
)
|
||||
.setIncludeFile("Extensions/Video/videoruntimeobject.js")
|
||||
.addIncludeFile("Extensions/Video/videoruntimeobject-pixi-renderer.js")
|
||||
.addIncludeFile("Extensions/Video/videoruntimeobject-cocos-renderer.js");
|
||||
.setIncludeFile('Extensions/Video/videoruntimeobject.js')
|
||||
.addIncludeFile('Extensions/Video/videoruntimeobject-pixi-renderer.js')
|
||||
.addIncludeFile('Extensions/Video/videoruntimeobject-cocos-renderer.js');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Play",
|
||||
_("Play a video"),
|
||||
'Play',
|
||||
_('Play a video'),
|
||||
_(
|
||||
"Play a video (recommended file format is MPEG4, with H264 video codec and AAC audio codec)."
|
||||
'Play a video (recommended file format is MPEG4, with H264 video codec and AAC audio codec).'
|
||||
),
|
||||
_("Play the video of _PARAM0_"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
_('Play the video of _PARAM0_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("play");
|
||||
.setFunctionName('play');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Pause",
|
||||
_("Pause a video"),
|
||||
_("Pause the specified video."),
|
||||
_("Pause video _PARAM0_"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Pause',
|
||||
_('Pause a video'),
|
||||
_('Pause the specified video.'),
|
||||
_('Pause video _PARAM0_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("pause");
|
||||
.setFunctionName('pause');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Loop",
|
||||
_("Loop a video"),
|
||||
_("Loop the specified video."),
|
||||
_("Loop video of _PARAM0_: _PARAM1_"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Loop',
|
||||
_('Loop a video'),
|
||||
_('Loop the specified video.'),
|
||||
_('Loop video of _PARAM0_: _PARAM1_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter("yesorno", _("Activate loop"), "", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.addParameter('yesorno', _('Activate loop'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("setLoop");
|
||||
.setFunctionName('setLoop');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"Mute",
|
||||
_("Mute a video"),
|
||||
_("Mute, or unmute, the specified video."),
|
||||
_("Mute video of _PARAM0_: _PARAM1_"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Mute',
|
||||
_('Mute a video'),
|
||||
_('Mute, or unmute, the specified video.'),
|
||||
_('Mute video of _PARAM0_: _PARAM1_'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter("yesorno", _("Activate mute"), "", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.addParameter('yesorno', _('Activate mute'), '', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("mute");
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"SetTime",
|
||||
_("Set time"),
|
||||
_("Set the time of the video object in seconds"),
|
||||
_("the time"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardOperatorParameters("number")
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("setCurrentTime")
|
||||
.setGetter("getCurrentTime");
|
||||
.setFunctionName('mute');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"SetVolume",
|
||||
_("Set volume"),
|
||||
'SetTime',
|
||||
_('Set time'),
|
||||
_('Set the time of the video object in seconds'),
|
||||
_('the time'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName('setCurrentTime')
|
||||
.setGetter('getCurrentTime');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
'SetVolume',
|
||||
_('Set volume'),
|
||||
_(
|
||||
"Set the volume of the video object, between 0 (muted) and 100 (maximum)."
|
||||
'Set the volume of the video object, between 0 (muted) and 100 (maximum).'
|
||||
),
|
||||
_("the volume"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
_('the volume'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("setVolume")
|
||||
.setGetter("getVolume");
|
||||
.setFunctionName('setVolume')
|
||||
.setGetter('getVolume');
|
||||
|
||||
object
|
||||
.addExpression(
|
||||
"Volume",
|
||||
_("Get the volume"),
|
||||
'Volume',
|
||||
_('Get the volume'),
|
||||
_(
|
||||
"Get the volume of a video object, between 0 (muted) and 100 (maximum)."
|
||||
'Get the volume of a video object, between 0 (muted) and 100 (maximum).'
|
||||
),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Object"), "VideoObject", false)
|
||||
.addParameter('object', _('Object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getVolume");
|
||||
.setFunctionName('getVolume');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Play",
|
||||
_("Is played"),
|
||||
_("Check if a video is played."),
|
||||
_("_PARAM0_ is played"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Play',
|
||||
_('Is played'),
|
||||
_('Check if a video is played.'),
|
||||
_('_PARAM0_ is played'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("isPlayed");
|
||||
.setFunctionName('isPlayed');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Pause",
|
||||
_("Is paused"),
|
||||
_("Check if the video is paused."),
|
||||
_("_PARAM0_ is paused"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Pause',
|
||||
_('Is paused'),
|
||||
_('Check if the video is paused.'),
|
||||
_('_PARAM0_ is paused'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("isPaused");
|
||||
.setFunctionName('isPaused');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Loop",
|
||||
_("Is looped"),
|
||||
_("Check if the video is looped."),
|
||||
_("_PARAM0_ is looped"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Loop',
|
||||
_('Is looped'),
|
||||
_('Check if the video is looped.'),
|
||||
_('_PARAM0_ is looped'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("isLooped");
|
||||
.setFunctionName('isLooped');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Volume",
|
||||
_("Volume"),
|
||||
_("Compare the current volume of a video object."),
|
||||
_("the volume"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Volume',
|
||||
_('Volume'),
|
||||
_('Compare the current volume of a video object.'),
|
||||
_('the volume'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getVolume");
|
||||
.setFunctionName('getVolume');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Mute",
|
||||
_("Is muted"),
|
||||
_("Check if a video is muted."),
|
||||
_("_PARAM0_ is muted"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Mute',
|
||||
_('Is muted'),
|
||||
_('Check if a video is muted.'),
|
||||
_('_PARAM0_ is muted'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("isMuted");
|
||||
.setFunctionName('isMuted');
|
||||
|
||||
object
|
||||
.addExpression(
|
||||
"CurrentTime",
|
||||
_("Get current time"),
|
||||
_("Return the current time of a video object (in seconds)."),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'CurrentTime',
|
||||
_('Get current time'),
|
||||
_('Return the current time of a video object (in seconds).'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Object"), "VideoObject", false)
|
||||
.addParameter('object', _('Object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getCurrentTime");
|
||||
.setFunctionName('getCurrentTime');
|
||||
|
||||
object
|
||||
.addExpression(
|
||||
"Duration",
|
||||
_("Get the duration"),
|
||||
_("Return the duration of a video object (in seconds)."),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Duration',
|
||||
_('Get the duration'),
|
||||
_('Return the duration of a video object (in seconds).'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Object"), "VideoObject", false)
|
||||
.addParameter('object', _('Object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getDuration");
|
||||
.setFunctionName('getDuration');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Duration",
|
||||
_("Duration"),
|
||||
_("Compare the duration of a video object"),
|
||||
_("the duration (in seconds)"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Duration',
|
||||
_('Duration'),
|
||||
_('Compare the duration of a video object'),
|
||||
_('the duration (in seconds)'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getDuration");
|
||||
.setFunctionName('getDuration');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"CurrentTime",
|
||||
_("Current time"),
|
||||
_("Compare the current time of a video object"),
|
||||
_("the current time (in seconds)"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'CurrentTime',
|
||||
_('Current time'),
|
||||
_('Compare the current time of a video object'),
|
||||
_('the current time (in seconds)'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getCurrentTime");
|
||||
.setFunctionName('getCurrentTime');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"Ended",
|
||||
_("Is ended"),
|
||||
_("Check if a video is ended"),
|
||||
_("_PARAM0_ is ended"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Ended',
|
||||
_('Is ended'),
|
||||
_('Check if a video is ended'),
|
||||
_('_PARAM0_ is ended'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("isEnded");
|
||||
.setFunctionName('isEnded');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"SetOpacity",
|
||||
_("Set opacity"),
|
||||
'SetOpacity',
|
||||
_('Set opacity'),
|
||||
_(
|
||||
"Set opacity of the specified video object, between 0 (fully transparent) and 255 (opaque)."
|
||||
'Set opacity of the specified video object, between 0 (fully transparent) and 255 (opaque).'
|
||||
),
|
||||
_("the opacity"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
_('the opacity'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("setOpacity")
|
||||
.setGetter("getOpacity");
|
||||
.setFunctionName('setOpacity')
|
||||
.setGetter('getOpacity');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"GetOpacity",
|
||||
_("Opacity"),
|
||||
_("Compare the opacity of a video object"),
|
||||
_("the opacity"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'GetOpacity',
|
||||
_('Opacity'),
|
||||
_('Compare the opacity of a video object'),
|
||||
_('the opacity'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getOpacity");
|
||||
.setFunctionName('getOpacity');
|
||||
|
||||
object
|
||||
.addExpression(
|
||||
"Opacity",
|
||||
_("Get current opacity"),
|
||||
_("Return the opacity of a video object"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'Opacity',
|
||||
_('Get current opacity'),
|
||||
_('Return the opacity of a video object'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Object"), "VideoObject", false)
|
||||
.addParameter('object', _('Object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getOpacity");
|
||||
.setFunctionName('getOpacity');
|
||||
|
||||
object
|
||||
.addAction(
|
||||
"SetPlaybackSpeed",
|
||||
_("Set playback speed"),
|
||||
'SetPlaybackSpeed',
|
||||
_('Set playback speed'),
|
||||
_(
|
||||
"Set playback speed of the specified video object, (1 = the default speed, >1 = faster and <1 = slower)."
|
||||
'Set playback speed of the specified video object, (1 = the default speed, >1 = faster and <1 = slower).'
|
||||
),
|
||||
_("the playback speed"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
_('the playback speed'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("setPlaybackSpeed")
|
||||
.setGetter("getPlaybackSpeed");
|
||||
.setFunctionName('setPlaybackSpeed')
|
||||
.setGetter('getPlaybackSpeed');
|
||||
|
||||
object
|
||||
.addCondition(
|
||||
"GetPlaybackSpeed",
|
||||
_("Playback speed "),
|
||||
_("Compare the playback speed of a video object"),
|
||||
_("the playback speed"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon24.png",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'GetPlaybackSpeed',
|
||||
_('Playback speed '),
|
||||
_('Compare the playback speed of a video object'),
|
||||
_('the playback speed'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon24.png',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Video object"), "VideoObject", false)
|
||||
.useStandardRelationalOperatorParameters("number")
|
||||
.addParameter('object', _('Video object'), 'VideoObject', false)
|
||||
.useStandardRelationalOperatorParameters('number')
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getPlaybackSpeed");
|
||||
.setFunctionName('getPlaybackSpeed');
|
||||
|
||||
object
|
||||
.addExpression(
|
||||
"PlaybackSpeed",
|
||||
_("Get current playback speed"),
|
||||
_("Return the playback speed of a video object"),
|
||||
"",
|
||||
"JsPlatform/Extensions/videoicon16.png"
|
||||
'PlaybackSpeed',
|
||||
_('Get current playback speed'),
|
||||
_('Return the playback speed of a video object'),
|
||||
'',
|
||||
'JsPlatform/Extensions/videoicon16.png'
|
||||
)
|
||||
.addParameter("object", _("Object"), "VideoObject", false)
|
||||
.addParameter('object', _('Object'), 'VideoObject', false)
|
||||
.getCodeExtraInformation()
|
||||
.setFunctionName("getPlaybackSpeed");
|
||||
.setFunctionName('getPlaybackSpeed');
|
||||
|
||||
return extension;
|
||||
},
|
||||
@@ -464,13 +476,15 @@ module.exports = {
|
||||
* of your extension behaviors/objects by instanciating behaviors/objects
|
||||
* and setting the property to a given value.
|
||||
*
|
||||
* If you don't have any tests, you can simply return an empty array like this:
|
||||
* `runExtensionSanityTests: function(gd, extension) { return []; }`
|
||||
* If you don't have any tests, you can simply return an empty array.
|
||||
*
|
||||
* But it is recommended to create tests for the behaviors/objects properties you created
|
||||
* to avoid mistakes.
|
||||
*/
|
||||
runExtensionSanityTests: function(gd, extension) {
|
||||
runExtensionSanityTests: function (
|
||||
gd /*: libGDevelop */,
|
||||
extension /*: gdPlatformExtension*/
|
||||
) {
|
||||
return [];
|
||||
},
|
||||
/**
|
||||
@@ -479,11 +493,13 @@ module.exports = {
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
|
||||
registerEditorConfigurations: function(objectsEditorService) {
|
||||
registerEditorConfigurations: function (
|
||||
objectsEditorService /*: ObjectsEditorService */
|
||||
) {
|
||||
objectsEditorService.registerEditorConfiguration(
|
||||
"Video::VideoObject",
|
||||
'Video::VideoObject',
|
||||
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
|
||||
helpPagePath: "/objects/video"
|
||||
helpPagePath: '/objects/video',
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -492,7 +508,9 @@ module.exports = {
|
||||
*
|
||||
* ℹ️ Run `node import-GDJS-Runtime.js` (in newIDE/app/scripts) if you make any change.
|
||||
*/
|
||||
registerInstanceRenderers: function(objectsRenderingService) {
|
||||
registerInstanceRenderers: function (
|
||||
objectsRenderingService /*: ObjectsRenderingService */
|
||||
) {
|
||||
const RenderedInstance = objectsRenderingService.RenderedInstance;
|
||||
const PIXI = objectsRenderingService.PIXI;
|
||||
|
||||
@@ -537,19 +555,19 @@ module.exports = {
|
||||
/**
|
||||
* Return the path to the thumbnail of the specified object.
|
||||
*/
|
||||
RenderedVideoObjectInstance.getThumbnail = function(
|
||||
RenderedVideoObjectInstance.getThumbnail = function (
|
||||
project,
|
||||
resourcesLoader,
|
||||
object
|
||||
) {
|
||||
return "JsPlatform/Extensions/videoicon24.png";
|
||||
return 'JsPlatform/Extensions/videoicon24.png';
|
||||
};
|
||||
|
||||
RenderedVideoObjectInstance.prototype._getVideoTexture = function() {
|
||||
RenderedVideoObjectInstance.prototype._getVideoTexture = function () {
|
||||
// Get the video resource to use
|
||||
const videoResource = this._associatedObject
|
||||
.getProperties(this.project)
|
||||
.get("videoResource")
|
||||
.get('videoResource')
|
||||
.getValue();
|
||||
|
||||
// This returns a VideoTexture with autoPlay set to false
|
||||
@@ -562,11 +580,11 @@ module.exports = {
|
||||
/**
|
||||
* This is called to update the PIXI object on the scene editor
|
||||
*/
|
||||
RenderedVideoObjectInstance.prototype.update = function() {
|
||||
RenderedVideoObjectInstance.prototype.update = function () {
|
||||
// Check if the video resource has changed
|
||||
const videoResource = this._associatedObject
|
||||
.getProperties(this.project)
|
||||
.get("videoResource")
|
||||
.get('videoResource')
|
||||
.getValue();
|
||||
if (videoResource !== this._videoResource) {
|
||||
this._videoResource = videoResource;
|
||||
@@ -577,8 +595,8 @@ module.exports = {
|
||||
|
||||
// Try to display an error texture in case of error, though
|
||||
// for some reason "error" is never called.
|
||||
that._pixiObject.texture.on("error", function() {
|
||||
that._pixiObject.texture.off("error", this);
|
||||
that._pixiObject.texture.on('error', function () {
|
||||
that._pixiObject.texture.off('error', this);
|
||||
that._pixiObject.texture = that._pixiResourcesLoader.getInvalidPIXITexture();
|
||||
});
|
||||
}
|
||||
@@ -587,7 +605,7 @@ module.exports = {
|
||||
// Update opacity
|
||||
const opacity = this._associatedObject
|
||||
.getProperties(this.project)
|
||||
.get("Opacity")
|
||||
.get('Opacity')
|
||||
.getValue();
|
||||
this._pixiObject.alpha = opacity / 255;
|
||||
|
||||
@@ -609,14 +627,14 @@ module.exports = {
|
||||
/**
|
||||
* Return the width of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedVideoObjectInstance.prototype.getDefaultWidth = function() {
|
||||
RenderedVideoObjectInstance.prototype.getDefaultWidth = function () {
|
||||
return this._pixiObject.width;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the height of the instance, when it's not resized.
|
||||
*/
|
||||
RenderedVideoObjectInstance.prototype.getDefaultHeight = function() {
|
||||
RenderedVideoObjectInstance.prototype.getDefaultHeight = function () {
|
||||
return this._pixiObject.height;
|
||||
};
|
||||
|
||||
@@ -624,8 +642,8 @@ module.exports = {
|
||||
// because the video is never really played.
|
||||
|
||||
objectsRenderingService.registerInstanceRenderer(
|
||||
"Video::VideoObject",
|
||||
'Video::VideoObject',
|
||||
RenderedVideoObjectInstance
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@@ -18,9 +18,32 @@ using namespace std;
|
||||
|
||||
namespace gdjs {
|
||||
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
JsCodeEvent::GetAllExpressionsWithMetadata() {
|
||||
vector<pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("object");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(¶meterObjects, metadata));
|
||||
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
JsCodeEvent::GetAllExpressionsWithMetadata() const {
|
||||
vector<pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
allExpressionsWithMetadata;
|
||||
auto metadata = gd::ParameterMetadata().SetType("object");
|
||||
allExpressionsWithMetadata.push_back(
|
||||
std::make_pair(¶meterObjects, metadata));
|
||||
|
||||
return allExpressionsWithMetadata;
|
||||
}
|
||||
|
||||
void JsCodeEvent::SerializeTo(gd::SerializerElement& element) const {
|
||||
element.AddChild("inlineCode").SetValue(inlineCode);
|
||||
element.AddChild("parameterObjects").SetValue(parameterObjects);
|
||||
element.AddChild("parameterObjects")
|
||||
.SetValue(parameterObjects.GetPlainString());
|
||||
element.AddChild("useStrict").SetValue(useStrict);
|
||||
}
|
||||
|
||||
@@ -28,7 +51,9 @@ void JsCodeEvent::UnserializeFrom(gd::Project& project,
|
||||
const gd::SerializerElement& element) {
|
||||
inlineCode = element.GetChild("inlineCode").GetValue().GetString();
|
||||
parameterObjects =
|
||||
element.GetChild("parameterObjects").GetValue().GetString();
|
||||
gd::Expression(element.GetChild("parameterObjects")
|
||||
.GetValue()
|
||||
.GetString());
|
||||
|
||||
if (!element.HasChild("useStrict")) {
|
||||
// Compatibility with GD <= 5.0.0-beta68
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#ifndef JSCODEEVENT_H
|
||||
#define JSCODEEVENT_H
|
||||
#include "GDCore/Events/Event.h"
|
||||
#include "GDCore/Events/Expression.h"
|
||||
namespace gd {
|
||||
class Instruction;
|
||||
class Project;
|
||||
@@ -31,11 +32,16 @@ class JsCodeEvent : public gd::BaseEvent {
|
||||
const gd::String& GetInlineCode() const { return inlineCode; };
|
||||
void SetInlineCode(const gd::String& code) { inlineCode = code; };
|
||||
|
||||
const gd::String& GetParameterObjects() const { return parameterObjects; };
|
||||
const gd::String& GetParameterObjects() const { return parameterObjects.GetPlainString(); };
|
||||
void SetParameterObjects(const gd::String& objectName) {
|
||||
parameterObjects = objectName;
|
||||
parameterObjects = gd::Expression(objectName);
|
||||
};
|
||||
|
||||
virtual std::vector<std::pair<gd::Expression*, gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata();
|
||||
virtual std::vector<std::pair<const gd::Expression*, const gd::ParameterMetadata> >
|
||||
GetAllExpressionsWithMetadata() const;
|
||||
|
||||
virtual void SerializeTo(gd::SerializerElement& element) const;
|
||||
virtual void UnserializeFrom(gd::Project& project,
|
||||
const gd::SerializerElement& element);
|
||||
@@ -44,9 +50,9 @@ class JsCodeEvent : public gd::BaseEvent {
|
||||
private:
|
||||
void Init(const JsCodeEvent& event);
|
||||
|
||||
gd::String inlineCode; ///< Contains the Javacript code of the event.
|
||||
gd::String parameterObjects; ///< Name of the (group of) objects to pass as
|
||||
///< parameter.
|
||||
gd::String inlineCode; ///< Contains the Javacript code of the event.
|
||||
gd::Expression parameterObjects; ///< Name of the (group of) objects to pass as
|
||||
///< parameter.
|
||||
bool useStrict; ///< Should the generated JS function have "use strict". true
|
||||
///< by default. Should be removed once all the game engine
|
||||
///< is using "use strict".
|
||||
|
@@ -4,7 +4,9 @@
|
||||
* reserved. This project is released under the MIT License.
|
||||
*/
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerator.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "GDCore/CommonTools.h"
|
||||
#include "GDCore/Events/CodeGeneration/EventsCodeGenerationContext.h"
|
||||
#include "GDCore/Events/Tools/EventsCodeNameMangler.h"
|
||||
@@ -164,7 +166,7 @@ gd::String EventsCodeGenerator::GenerateBehaviorEventsFunctionCode(
|
||||
// as a parameter called "Behavior".
|
||||
"var Behavior = this.name;\n" +
|
||||
codeGenerator.GenerateEventsFunctionContext(
|
||||
eventsFunction.GetParameters(), "Object");
|
||||
eventsFunction.GetParameters(), "Object", "Behavior");
|
||||
|
||||
gd::String output = GenerateEventsListCompleteFunctionCode(
|
||||
project,
|
||||
@@ -205,7 +207,8 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionParameterDeclarationsList(
|
||||
|
||||
gd::String EventsCodeGenerator::GenerateEventsFunctionContext(
|
||||
const vector<gd::ParameterMetadata>& parameters,
|
||||
const gd::String& thisObjectName) {
|
||||
const gd::String& thisObjectName,
|
||||
const gd::String& thisBehaviorName) {
|
||||
// When running in the context of a function generated from events, we
|
||||
// need some indirection to deal with objects, behaviors and parameters in
|
||||
// general:
|
||||
@@ -214,32 +217,61 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionContext(
|
||||
// of objects.
|
||||
// * Behaviors are passed as string, representing the name of the behavior.
|
||||
// This can differ from the name used to refer to the behavior in the events
|
||||
// of the function (for example, a behavior can simply called "Behavior" in
|
||||
// of the function (for example, a behavior can simply be called "Behavior" in
|
||||
// the parameter name).
|
||||
// * For other parameters, allow to access to them without transformation.
|
||||
// Conditions/expressions are available to deal with them in events.
|
||||
|
||||
gd::String objectsGettersMap;
|
||||
gd::String behaviorsGetterMap;
|
||||
gd::String objectsCreators;
|
||||
gd::String objectArraysMap;
|
||||
gd::String behaviorNamesMap;
|
||||
gd::String argumentsGetters;
|
||||
|
||||
// If we have an object considered as the current object ("this") (usually
|
||||
// called Object in behavior events function), generate a slightly more
|
||||
// optimized getter for it (bypassing "Object" hashmap, and directly return
|
||||
// the array containing it).
|
||||
if (!thisObjectName.empty()) {
|
||||
objectsGettersMap +=
|
||||
ConvertToStringExplicit(thisObjectName) + ": " + thisObjectName + "\n";
|
||||
objectArraysMap +=
|
||||
ConvertToStringExplicit(thisObjectName) + ": thisObjectList\n";
|
||||
}
|
||||
// If we have a behavior considered as the current behavior ("this") (usually
|
||||
// called Behavior in behavior events function), generate a slightly more
|
||||
// optimized getter for it.
|
||||
if (!thisBehaviorName.empty()) {
|
||||
behaviorNamesMap += ConvertToStringExplicit(thisBehaviorName) + ": " +
|
||||
thisBehaviorName + "\n";
|
||||
}
|
||||
|
||||
for (const auto& parameter : parameters) {
|
||||
if (parameter.GetName().empty()) continue;
|
||||
|
||||
if (gd::ParameterMetadata::IsObject(parameter.GetType())) {
|
||||
if (parameter.GetName() == thisObjectName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate map that will be used to get the lists of objects passed
|
||||
// as parameters
|
||||
// as parameters (either as objects lists or array).
|
||||
gd::String comma = objectsGettersMap.empty() ? "" : ", ";
|
||||
objectsGettersMap += comma +
|
||||
ConvertToStringExplicit(parameter.GetName()) + ": " +
|
||||
parameter.GetName() + "\n";
|
||||
objectArraysMap += comma + ConvertToStringExplicit(parameter.GetName()) +
|
||||
": gdjs.objectsListsToArray(" + parameter.GetName() +
|
||||
")\n";
|
||||
} else if (gd::ParameterMetadata::IsBehavior(parameter.GetType())) {
|
||||
if (parameter.GetName() == thisBehaviorName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate map that will be used to transform from behavior name used in
|
||||
// function to the "real" behavior name from the caller.
|
||||
gd::String comma = behaviorsGetterMap.empty() ? "" : ", ";
|
||||
behaviorsGetterMap += comma +
|
||||
ConvertToStringExplicit(parameter.GetName()) +
|
||||
": " + parameter.GetName() + "\n";
|
||||
gd::String comma = behaviorNamesMap.empty() ? "" : ", ";
|
||||
behaviorNamesMap += comma + ConvertToStringExplicit(parameter.GetName()) +
|
||||
": " + parameter.GetName() + "\n";
|
||||
} else {
|
||||
argumentsGetters +=
|
||||
"if (argName === " + ConvertToStringExplicit(parameter.GetName()) +
|
||||
@@ -247,35 +279,27 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionContext(
|
||||
}
|
||||
}
|
||||
|
||||
// If we have an object considered as the current object ("this") (usually
|
||||
// called Object in behavior events function), generate a slightly more
|
||||
// optimized getter for it (bypassing "Object" hashmap, and directly return
|
||||
// the array containing it).
|
||||
gd::String thisObjectGetterCode =
|
||||
thisObjectName.empty()
|
||||
? ""
|
||||
: "if (objectName === " + ConvertToStringExplicit(thisObjectName) +
|
||||
") { return thisObjectList; }";
|
||||
|
||||
return gd::String("var eventsFunctionContext = {\n") +
|
||||
// The object name to parameter map:
|
||||
" _objectsMap: {\n" + objectsGettersMap +
|
||||
"},\n"
|
||||
// The object name to arrays map:
|
||||
" _objectArraysMap: {\n" +
|
||||
objectArraysMap +
|
||||
"},\n"
|
||||
// The behavior name to parameter map:
|
||||
" _behaviorNamesMap: {\n" +
|
||||
behaviorsGetterMap +
|
||||
behaviorNamesMap +
|
||||
"},\n"
|
||||
// Function that will be used to query objects, when a new object list
|
||||
// is needed by events.
|
||||
// is needed by events. We assume it's used a lot by the events
|
||||
// generated code, so we cache the arrays in a map.
|
||||
" getObjects: function(objectName) {\n" +
|
||||
" " + thisObjectGetterCode +
|
||||
" var objectsList = "
|
||||
"eventsFunctionContext._objectsMap[objectName];\n" +
|
||||
" return objectsList ? gdjs.objectsListsToArray(objectsList) : "
|
||||
"[];\n"
|
||||
" return eventsFunctionContext._objectArraysMap[objectName] || "
|
||||
"[];\n" +
|
||||
" },\n" +
|
||||
// Function that can be used in JS code to get the lists of objects
|
||||
// and filter/alter them.
|
||||
// and filter/alter them (not actually used in events).
|
||||
" getObjectsLists: function(objectName) {\n" +
|
||||
" return eventsFunctionContext._objectsMap[objectName] || null;\n"
|
||||
" },\n" +
|
||||
@@ -283,7 +307,6 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionContext(
|
||||
// can be different between the parameter name vs the actual behavior
|
||||
// name passed as argument).
|
||||
" getBehaviorName: function(behaviorName) {\n" +
|
||||
// TODO: Use parentEventsFunctionContext?
|
||||
" return eventsFunctionContext._behaviorNamesMap[behaviorName];\n"
|
||||
" },\n" +
|
||||
// Creator function that will be used to create new objects. We
|
||||
@@ -294,6 +317,9 @@ gd::String EventsCodeGenerator::GenerateEventsFunctionContext(
|
||||
" createObject: function(objectName) {\n"
|
||||
" var objectsList = "
|
||||
"eventsFunctionContext._objectsMap[objectName];\n" +
|
||||
// TODO: we could speed this up by storing a map of object names, but the
|
||||
// cost of creating/storing it for each events function might not be
|
||||
// worth it.
|
||||
" if (objectsList) {\n" +
|
||||
" return parentEventsFunctionContext ?\n" +
|
||||
" "
|
||||
@@ -898,24 +924,25 @@ gd::String EventsCodeGenerator::GenerateObject(
|
||||
//(references to) objects lists. We statically declare and construct them to
|
||||
// avoid re-creating them at runtime. Arrays are passed as reference in JS and
|
||||
// we always use the same static arrays, making this possible.
|
||||
auto declareMapOfObjects = [this](
|
||||
const std::vector<gd::String>& objects,
|
||||
const gd::EventsCodeGenerationContext& context) {
|
||||
gd::String objectsMapName = GetCodeNamespaceAccessor() + "mapOf";
|
||||
gd::String mapDeclaration;
|
||||
for (auto& objectName : objects) {
|
||||
// The map name must be unique for each set of objects lists.
|
||||
objectsMapName += ManObjListName(GetObjectListName(objectName, context));
|
||||
auto declareMapOfObjects =
|
||||
[this](const std::vector<gd::String>& objects,
|
||||
const gd::EventsCodeGenerationContext& context) {
|
||||
gd::String objectsMapName = GetCodeNamespaceAccessor() + "mapOf";
|
||||
gd::String mapDeclaration;
|
||||
for (auto& objectName : objects) {
|
||||
// The map name must be unique for each set of objects lists.
|
||||
objectsMapName +=
|
||||
ManObjListName(GetObjectListName(objectName, context));
|
||||
|
||||
if (!mapDeclaration.empty()) mapDeclaration += ", ";
|
||||
mapDeclaration += "\"" + ConvertToString(objectName) +
|
||||
"\": " + GetObjectListName(objectName, context);
|
||||
}
|
||||
if (!mapDeclaration.empty()) mapDeclaration += ", ";
|
||||
mapDeclaration += "\"" + ConvertToString(objectName) +
|
||||
"\": " + GetObjectListName(objectName, context);
|
||||
}
|
||||
|
||||
AddCustomCodeOutsideMain(objectsMapName + " = Hashtable.newFrom({" +
|
||||
mapDeclaration + "});");
|
||||
return objectsMapName;
|
||||
};
|
||||
AddCustomCodeOutsideMain(objectsMapName + " = Hashtable.newFrom({" +
|
||||
mapDeclaration + "});");
|
||||
return objectsMapName;
|
||||
};
|
||||
|
||||
gd::String output;
|
||||
if (type == "objectList") {
|
||||
@@ -1026,15 +1053,13 @@ gd::String EventsCodeGenerator::GenerateReferenceToUpperScopeBoolean(
|
||||
const gd::String& referenceName,
|
||||
const gd::String& referencedBoolean,
|
||||
gd::EventsCodeGenerationContext& context) {
|
||||
if (context.GetParentContext() == NULL) return "";
|
||||
if (context.GetCurrentConditionDepth() <= 0)
|
||||
return "/* Code generation error: the referenced boolean can't exist as "
|
||||
"the context has a condition depth of 0. */";
|
||||
|
||||
// FIXME: Using context.GetParentContext() generates the wrong boolean name in
|
||||
// case a condition with a custom code generator is used inside another
|
||||
// condition (i.e: as a subinstructions).
|
||||
return GenerateBooleanFullName(referenceName, context) + " = " +
|
||||
GenerateBooleanFullName(referencedBoolean,
|
||||
*context.GetParentContext()) +
|
||||
";\n";
|
||||
GetCodeNamespaceAccessor() + referencedBoolean + "_" +
|
||||
gd::String::From(context.GetCurrentConditionDepth() - 1) + ";\n";
|
||||
}
|
||||
|
||||
gd::String EventsCodeGenerator::GenerateBooleanInitializationToFalse(
|
||||
|
@@ -328,7 +328,8 @@ class EventsCodeGenerator : public gd::EventsCodeGenerator {
|
||||
*/
|
||||
gd::String GenerateEventsFunctionContext(
|
||||
const std::vector<gd::ParameterMetadata>& parameters,
|
||||
const gd::String& thisObjectName = "");
|
||||
const gd::String& thisObjectName = "",
|
||||
const gd::String& thisBehaviorName = "");
|
||||
|
||||
gd::String GenerateEventsFunctionReturn(
|
||||
const gd::EventsFunction& eventFunction);
|
||||
|
@@ -39,7 +39,10 @@ bool Exporter::ExportLayoutForPixiPreview(gd::Project& project,
|
||||
gd::Layout& layout,
|
||||
gd::String exportDir) {
|
||||
ExporterHelper helper(fs, gdjsRoot, codeOutputDir);
|
||||
return helper.ExportLayoutForPixiPreview(project, layout, exportDir, "");
|
||||
gd::SerializerElement options;
|
||||
options.AddChild("isPreview").SetBoolValue(true);
|
||||
|
||||
return helper.ExportLayoutForPixiPreview(project, layout, exportDir, gd::Serializer::ToJSON(options));
|
||||
}
|
||||
|
||||
bool Exporter::ExportExternalLayoutForPixiPreview(
|
||||
@@ -49,6 +52,7 @@ bool Exporter::ExportExternalLayoutForPixiPreview(
|
||||
gd::String exportDir) {
|
||||
gd::SerializerElement options;
|
||||
options.AddChild("injectExternalLayout").SetValue(externalLayout.GetName());
|
||||
options.AddChild("isPreview").SetBoolValue(true);
|
||||
|
||||
ExporterHelper helper(fs, gdjsRoot, codeOutputDir);
|
||||
return helper.ExportLayoutForPixiPreview(
|
||||
|
@@ -614,21 +614,23 @@ void ExporterHelper::RemoveIncludes(bool pixiRenderers,
|
||||
bool cocosRenderers,
|
||||
std::vector<gd::String> &includesFiles) {
|
||||
if (pixiRenderers) {
|
||||
for (auto it = includesFiles.begin(); it != includesFiles.end();) {
|
||||
if (it->find("pixi-renderer") != gd::String::npos ||
|
||||
it->find("pixi-filter") != gd::String::npos)
|
||||
includesFiles.erase(it++);
|
||||
for (size_t i = 0; i < includesFiles.size();) {
|
||||
const gd::String &includeFile = includesFiles[i];
|
||||
if (includeFile.find("pixi-renderer") != gd::String::npos ||
|
||||
includeFile.find("pixi-filter") != gd::String::npos)
|
||||
includesFiles.erase(includesFiles.begin() + i);
|
||||
else
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (cocosRenderers) {
|
||||
for (auto it = includesFiles.begin(); it != includesFiles.end();) {
|
||||
if (it->find("cocos-renderer") != gd::String::npos ||
|
||||
it->find("cocos-shader") != gd::String::npos)
|
||||
includesFiles.erase(it++);
|
||||
for (size_t i = 0; i < includesFiles.size();) {
|
||||
const gd::String &includeFile = includesFiles[i];
|
||||
if (includeFile.find("cocos-renderer") != gd::String::npos ||
|
||||
includeFile.find("cocos-shader") != gd::String::npos)
|
||||
includesFiles.erase(includesFiles.begin() + i);
|
||||
else
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,12 @@ function createWindow() {
|
||||
useContentSize: true,
|
||||
title: "GDJS_GAME_NAME",
|
||||
backgroundColor: '#000000'
|
||||
// To be added once upgraded to Electron 8+
|
||||
// (or custom events to be written for each usage of electron
|
||||
// in the game engine):
|
||||
// ,webPreferences: {
|
||||
// nodeIntegration: true,
|
||||
// }
|
||||
});
|
||||
|
||||
// Open external link in the OS default browser
|
||||
|
@@ -8,5 +8,10 @@
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"electron": "3.0.9"
|
||||
},
|
||||
"build": {
|
||||
"directories": {
|
||||
"buildResources": "buildResources"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
*
|
||||
* @class CocosImageManager
|
||||
* @memberof gdjs
|
||||
* @param {Object} resources The resources data of the game.
|
||||
* @param {ResourceData[]} resources The resources data of the game.
|
||||
*/
|
||||
gdjs.CocosImageManager = function(resources)
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user