mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
2 Commits
experiment
...
perf/expor
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c53aaa04d1 | ||
![]() |
f898023b92 |
@@ -330,10 +330,10 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
}
|
||||
|
||||
// Generate object condition if available
|
||||
gd::String objectName = condition.GetParameters().empty()
|
||||
const gd::String& objectName = condition.GetParameters().empty()
|
||||
? ""
|
||||
: condition.GetParameter(0).GetPlainString();
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
const gd::String& objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), objectName);
|
||||
if (!objectName.empty() &&
|
||||
MetadataProvider::HasObjectCondition(
|
||||
@@ -365,7 +365,7 @@ gd::String EventsCodeGenerator::GenerateConditionCode(
|
||||
}
|
||||
|
||||
// Generate behavior condition if available
|
||||
gd::String behaviorType =
|
||||
const gd::String& behaviorType =
|
||||
gd::GetTypeOfBehavior(GetGlobalObjectsAndGroups(),
|
||||
GetObjectsAndGroups(),
|
||||
condition.GetParameters().size() < 2
|
||||
@@ -502,10 +502,10 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
}
|
||||
|
||||
// Call object function if available
|
||||
gd::String objectName = action.GetParameters().empty()
|
||||
const gd::String& objectName = action.GetParameters().empty()
|
||||
? ""
|
||||
: action.GetParameter(0).GetPlainString();
|
||||
gd::String objectType = gd::GetTypeOfObject(
|
||||
const gd::String& objectType = gd::GetTypeOfObject(
|
||||
GetGlobalObjectsAndGroups(), GetObjectsAndGroups(), objectName);
|
||||
if (MetadataProvider::HasObjectAction(
|
||||
platform, objectType, action.GetType()) &&
|
||||
@@ -531,7 +531,7 @@ gd::String EventsCodeGenerator::GenerateActionCode(
|
||||
}
|
||||
|
||||
// Assign to a behavior member function if found
|
||||
gd::String behaviorType =
|
||||
const gd::String& behaviorType =
|
||||
gd::GetTypeOfBehavior(GetGlobalObjectsAndGroups(),
|
||||
GetObjectsAndGroups(),
|
||||
action.GetParameters().size() < 2
|
||||
|
@@ -422,17 +422,18 @@ std::vector<gd::String> GetHiddenLayers(const Layout& layout) {
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
gd::String GD_CORE_API GetTypeOfObject(const gd::ObjectsContainer& project,
|
||||
const gd::String& GD_CORE_API GetTypeOfObject(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
gd::String name,
|
||||
const gd::String& name,
|
||||
bool searchInGroups) {
|
||||
gd::String type;
|
||||
static gd::String empty; //TODO
|
||||
const gd::String* type;
|
||||
|
||||
// Search in objects
|
||||
if (layout.HasObjectNamed(name))
|
||||
type = layout.GetObject(name).GetType();
|
||||
type = &layout.GetObject(name).GetType();
|
||||
else if (project.HasObjectNamed(name))
|
||||
type = project.GetObject(name).GetType();
|
||||
type = &project.GetObject(name).GetType();
|
||||
|
||||
// Search in groups
|
||||
if (searchInGroups) {
|
||||
@@ -443,22 +444,22 @@ gd::String GD_CORE_API GetTypeOfObject(const gd::ObjectsContainer& project,
|
||||
|
||||
vector<gd::String> groupsObjects =
|
||||
layout.GetObjectGroups()[i].GetAllObjectsNames();
|
||||
gd::String previousType =
|
||||
const gd::String& previousType =
|
||||
groupsObjects.empty()
|
||||
? ""
|
||||
? empty
|
||||
: GetTypeOfObject(project, layout, groupsObjects[0], false);
|
||||
|
||||
for (std::size_t j = 0; j < groupsObjects.size(); ++j) {
|
||||
if (GetTypeOfObject(project, layout, groupsObjects[j], false) !=
|
||||
previousType)
|
||||
return ""; // The group has more than one type.
|
||||
return empty; // The group has more than one type.
|
||||
}
|
||||
|
||||
if (!type.empty() && previousType != type)
|
||||
return ""; // The group has objects of different type, so the group
|
||||
// has not any type.
|
||||
if (!type->empty() && previousType != *type)
|
||||
return empty; // The group has objects of different type, so the group
|
||||
// has not any type.
|
||||
|
||||
type = previousType;
|
||||
type = &previousType;
|
||||
}
|
||||
}
|
||||
for (std::size_t i = 0; i < project.GetObjectGroups().size(); ++i) {
|
||||
@@ -468,33 +469,34 @@ gd::String GD_CORE_API GetTypeOfObject(const gd::ObjectsContainer& project,
|
||||
|
||||
vector<gd::String> groupsObjects =
|
||||
project.GetObjectGroups()[i].GetAllObjectsNames();
|
||||
gd::String previousType =
|
||||
const gd::String& previousType =
|
||||
groupsObjects.empty()
|
||||
? ""
|
||||
? empty
|
||||
: GetTypeOfObject(project, layout, groupsObjects[0], false);
|
||||
|
||||
for (std::size_t j = 0; j < groupsObjects.size(); ++j) {
|
||||
if (GetTypeOfObject(project, layout, groupsObjects[j], false) !=
|
||||
previousType)
|
||||
return ""; // The group has more than one type.
|
||||
return empty; // The group has more than one type.
|
||||
}
|
||||
|
||||
if (!type.empty() && previousType != type)
|
||||
return ""; // The group has objects of different type, so the group
|
||||
if (!type->empty() && previousType != *type)
|
||||
return empty; // The group has objects of different type, so the group
|
||||
// has not any type.
|
||||
|
||||
type = previousType;
|
||||
type = &previousType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
return *type;
|
||||
}
|
||||
|
||||
gd::String GD_CORE_API GetTypeOfBehavior(const gd::ObjectsContainer& project,
|
||||
const gd::String& GD_CORE_API GetTypeOfBehavior(const gd::ObjectsContainer& project,
|
||||
const gd::ObjectsContainer& layout,
|
||||
gd::String name,
|
||||
const gd::String& name,
|
||||
bool searchInGroups) {
|
||||
static gd::String empty; //TODO
|
||||
for (std::size_t i = 0; i < layout.GetObjectsCount(); ++i) {
|
||||
vector<gd::String> behaviors = layout.GetObject(i).GetAllBehaviorNames();
|
||||
for (std::size_t j = 0; j < behaviors.size(); ++j) {
|
||||
@@ -511,7 +513,7 @@ gd::String GD_CORE_API GetTypeOfBehavior(const gd::ObjectsContainer& project,
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
return empty;
|
||||
}
|
||||
|
||||
vector<gd::String> GD_CORE_API
|
||||
|
@@ -478,18 +478,18 @@ std::vector<gd::String> GetHiddenLayers(const Layout& layout);
|
||||
*
|
||||
* @return Type of the object/group.
|
||||
*/
|
||||
gd::String GD_CORE_API GetTypeOfObject(const ObjectsContainer& game,
|
||||
const gd::String& GD_CORE_API GetTypeOfObject(const ObjectsContainer& game,
|
||||
const ObjectsContainer& layout,
|
||||
gd::String objectName,
|
||||
const gd::String& objectName,
|
||||
bool searchInGroups = true);
|
||||
|
||||
/**
|
||||
* \brief Get a type from a behavior name
|
||||
* @return Type of the behavior.
|
||||
*/
|
||||
gd::String GD_CORE_API GetTypeOfBehavior(const ObjectsContainer& game,
|
||||
const gd::String& GD_CORE_API GetTypeOfBehavior(const ObjectsContainer& game,
|
||||
const ObjectsContainer& layout,
|
||||
gd::String behaviorName,
|
||||
const gd::String& behaviorName,
|
||||
bool searchInGroups = true);
|
||||
|
||||
/**
|
||||
|
@@ -79,12 +79,14 @@ export default {
|
||||
if (this._isExternalURL(source)) return true;
|
||||
|
||||
source = this._translateURL(source);
|
||||
try {
|
||||
if (source !== dest) fs.copySync(source, dest);
|
||||
} catch (e) {
|
||||
console.log('copyFile(' + source + ', ' + dest + ') failed: ' + e);
|
||||
return false;
|
||||
if (source !== dest) {
|
||||
fs.copy(source, dest, err => {
|
||||
if (err) {
|
||||
console.log('copyFile(' + source + ', ' + dest + ') failed: ' + err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
copyDir: function(source, dest) {
|
||||
@@ -104,12 +106,12 @@ export default {
|
||||
// return true;
|
||||
},
|
||||
writeToFile: function(file, contents) {
|
||||
try {
|
||||
fs.outputFileSync(file, contents);
|
||||
} catch (e) {
|
||||
console.log('writeToFile(' + file + ', ...) failed: ' + e);
|
||||
return false;
|
||||
}
|
||||
fs.outputFile(file, contents, err => {
|
||||
if (err) {
|
||||
console.error('writeToFile(' + file + ', ...) failed: ' + err);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
readFile: function(file) {
|
||||
|
Reference in New Issue
Block a user