Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for LDtk tilemap #4575

Merged
merged 49 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ab4e81d
refactor: rename TiledMap as TiledTileMap and add LDtkTileMap
daiyam Nov 21, 2022
f6bc811
feat: add level index UI
daiyam Nov 21, 2022
68222a9
feat: load sample1
daiyam Nov 22, 2022
39c170a
feat: support stack tiles
daiyam Nov 22, 2022
6169e69
feat: select level
daiyam Nov 23, 2022
eda42b3
test: pass all tests
daiyam Nov 23, 2022
8a2dc67
refactor: regroup files by action
daiyam Nov 23, 2022
b4d4177
style: reformat source files
daiyam Nov 23, 2022
39daf85
fix: collision map & test
daiyam Nov 23, 2022
7807eac
Merge branch 'master' into feat-ldtk
daiyam Nov 23, 2022
891fd84
refactor: improve variable names and comments
daiyam Nov 25, 2022
ffb1f93
feat: add tilemap resource
daiyam Nov 27, 2022
8cba0c0
feat: add background
daiyam Nov 27, 2022
15231d9
feat: add embedded resources mapping
daiyam Nov 28, 2022
9f4edbc
Merge branch 'master' into feat-ldtk
daiyam Nov 28, 2022
15b4bd9
fix: improve background and alpha
daiyam Nov 28, 2022
ed4cdc4
fix: correctly updating alpha
daiyam Nov 28, 2022
4276663
fix: correctly remove unused embedded resources
daiyam Nov 29, 2022
83d5859
enhance: use TileDefinition for tile stack
daiyam Dec 1, 2022
9622c19
fix: fixing bugs
daiyam Dec 2, 2022
a5e037f
fix: revert to bit flipping
daiyam Dec 2, 2022
9b0ac07
style: apply formatting
daiyam Dec 2, 2022
f5eae4a
fix: removeTile() correctly set to 0
daiyam Dec 2, 2022
791b1e4
feat: use json resource
daiyam Dec 3, 2022
d2e2843
fix: expose embedded resources in tilemap JSON
daiyam Dec 5, 2022
71d500f
chore: add flow to EmbeddedResourceSources.js
daiyam Dec 11, 2022
9edc755
chore: harden embedding resource loading
daiyam Dec 11, 2022
7e43d2d
Put back some methods in their initial order.
D8H Dec 13, 2022
b16de90
chore: revert TextureCache.ts to TileTextureCache.ts
daiyam Dec 13, 2022
6e13f63
style: format generated codes
daiyam Dec 13, 2022
91905e9
refactor: rename files/variables as instructed
daiyam Dec 16, 2022
9025f4a
chore: remove hash from TileDefinition
daiyam Dec 16, 2022
7d39444
chore: reformat files
daiyam Dec 16, 2022
18f38fe
Move TileTextureCache methods back to their original order.
D8H Dec 19, 2022
94b6998
fix: remove SetLevelIndex action
daiyam Dec 19, 2022
23a2735
refactor: rename setImage to setLevelBackgroundTexture
daiyam Dec 19, 2022
ddd424f
Merge branch 'master' into pr/4575
4ian Dec 21, 2022
50741d3
Adapt to the latest merge + various fixes
4ian Dec 21, 2022
69bb489
Fix renaming a resource not renaming the mapping to this resource in …
4ian Dec 21, 2022
bea66c8
Remove leftover debug code
4ian Dec 21, 2022
d65f67c
Fix flow
4ian Dec 22, 2022
7ef3ac2
Revert some files renaming.
D8H Dec 22, 2022
0291e59
Rebuild the library
D8H Dec 22, 2022
57d7ca5
Move back some files.
D8H Dec 22, 2022
04b10c8
Rebuild the library.
D8H Dec 22, 2022
0f77574
Scope the LevelIndex condition.
D8H Dec 22, 2022
4f2bf21
Fix type
D8H Dec 22, 2022
cb2349d
Fix useless parameter
4ian Dec 22, 2022
ca3042a
Simplify various data types
4ian Dec 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ bool SpriteObject::UpdateProperty(const gd::String& name,
return true;
}

void SpriteObject::ExposeResources(
gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager* resourcesManager) {
void SpriteObject::ExposeResources(gd::ArbitraryResourceWorker& worker) {
for (std::size_t j = 0; j < GetAnimationsCount(); j++) {
for (std::size_t k = 0; k < GetAnimation(j).GetDirectionsCount(); k++) {
for (std::size_t l = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class GD_CORE_API SpriteObject : public gd::ObjectConfiguration {
return gd::make_unique<SpriteObject>(*this);
}

void ExposeResources(gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager* resourcesManager) override;
void ExposeResources(gd::ArbitraryResourceWorker& worker) override;

std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
bool UpdateProperty(const gd::String& name,
Expand Down
8 changes: 4 additions & 4 deletions Core/GDCore/IDE/Project/ArbitraryResourceWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ void ArbitraryResourceWorker::ExposeResources(
}
}

void ArbitraryResourceWorker::ExposeEmbeddeds(
gd::String& resourceName,
gd::ResourcesManager* resourcesManager) {
if (!resourcesManager) return;
void ArbitraryResourceWorker::ExposeEmbeddeds(gd::String& resourceName) {
if (resourcesManagers.empty()) return;
gd::ResourcesManager* resourcesManager = resourcesManagers[0];
daiyam marked this conversation as resolved.
Show resolved Hide resolved

// TODO: can this be avoided?
gd::Resource& resource = resourcesManager->GetResource(resourceName);

if (!resource.GetMetadata().empty()) {
Expand Down
5 changes: 2 additions & 3 deletions Core/GDCore/IDE/Project/ArbitraryResourceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ class GD_CORE_API ArbitraryResourceWorker {
virtual void ExposeFile(gd::String &resourceFileName) = 0;

/**
* \brief Expose the embedded resources
* \brief Expose the embedded resources of the specified resource.
*/
virtual void ExposeEmbeddeds(gd::String &resourceName,
gd::ResourcesManager *resourcesManager);
virtual void ExposeEmbeddeds(gd::String &resourceName);

protected:
const std::vector<gd::ResourcesManager *> &GetResources() {
Expand Down
10 changes: 4 additions & 6 deletions Core/GDCore/Project/CustomObjectConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gd::ObjectConfiguration &CustomObjectConfiguration::GetChildObjectConfiguration(
return badObjectConfiguration;
}
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());

if (!eventsBasedObject.HasObjectNamed(objectName)) {
gd::LogError("Tried to get the configuration of a child-object:" + objectName
+ " that doesn't exist in the event-based object: " + GetType());
Expand Down Expand Up @@ -78,7 +78,7 @@ bool CustomObjectConfiguration::UpdateProperty(const gd::String& propertyName,
}
const auto &eventsBasedObject = project->GetEventsBasedObject(GetType());
const auto &properties = eventsBasedObject.GetPropertyDescriptors();

return gd::CustomConfigurationHelper::UpdateProperty(
properties,
objectContent,
Expand Down Expand Up @@ -125,9 +125,7 @@ void CustomObjectConfiguration::DoUnserializeFrom(Project& project,
}
}

void CustomObjectConfiguration::ExposeResources(
gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager* resourcesManager) {
void CustomObjectConfiguration::ExposeResources(gd::ArbitraryResourceWorker& worker) {
std::map<gd::String, gd::PropertyDescriptor> properties = GetProperties();

for (auto& property : properties) {
Expand Down Expand Up @@ -169,6 +167,6 @@ void CustomObjectConfiguration::ExposeResources(

for (auto& childObject : eventsBasedObject.GetObjects()) {
auto &configuration = GetChildObjectConfiguration(childObject->GetName());
configuration.ExposeResources(worker, resourcesManager);
configuration.ExposeResources(worker);
}
}
7 changes: 3 additions & 4 deletions Core/GDCore/Project/CustomObjectConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class CustomObjectConfiguration : public gd::ObjectConfiguration {
gd::Project& project,
gd::Layout& scene) override;

void ExposeResources(gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager* resourcesManager) override;
void ExposeResources(gd::ArbitraryResourceWorker& worker) override;

gd::ObjectConfiguration &GetChildObjectConfiguration(const gd::String& objectName);

Expand All @@ -88,9 +87,9 @@ class CustomObjectConfiguration : public gd::ObjectConfiguration {
/**
* Initialize configuration using another configuration. Used by copy-ctor
* and assign-op.
*
*
* Don't forget to update me if members were changed!
*
*
* It's needed because there is no default copy for childObjectConfigurations
* and it must be a deep copy.
*/
Expand Down
3 changes: 1 addition & 2 deletions Core/GDCore/Project/ObjectConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ class GD_CORE_API ObjectConfiguration {
*
* \see ArbitraryResourceWorker
*/
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager* resourcesManager) { return; };
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker) { return; };
///@}

/** \name Serialization
Expand Down
4 changes: 2 additions & 2 deletions Core/GDCore/Project/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {
for (std::size_t s = 0; s < GetLayoutsCount(); s++) {
for (std::size_t j = 0; j < GetLayout(s).GetObjectsCount();
++j) { // Add objects resources
GetLayout(s).GetObject(j).GetConfiguration().ExposeResources(worker, resourcesManager);
GetLayout(s).GetObject(j).GetConfiguration().ExposeResources(worker);
}

LaunchResourceWorkerOnEvents(*this, GetLayout(s).GetEvents(), worker);
Expand All @@ -1012,7 +1012,7 @@ void Project::ExposeResources(gd::ArbitraryResourceWorker& worker) {

// Add global objects resources
for (std::size_t j = 0; j < GetObjectsCount(); ++j) {
GetObject(j).GetConfiguration().ExposeResources(worker, resourcesManager);
GetObject(j).GetConfiguration().ExposeResources(worker);
}

// Add loading screen background image if present
Expand Down
3 changes: 1 addition & 2 deletions Extensions/PanelSpriteObject/PanelSpriteObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ void PanelSpriteObject::DoSerializeTo(gd::SerializerElement& element) const {
}

void PanelSpriteObject::ExposeResources(
gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager *resourcesManager) {
gd::ArbitraryResourceWorker& worker) {
worker.ExposeImage(textureName);
}
#endif
5 changes: 1 addition & 4 deletions Extensions/PanelSpriteObject/PanelSpriteObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ class GD_EXTENSION_API PanelSpriteObject : public gd::ObjectConfiguration {
new PanelSpriteObject(*this));
}

#if defined(GD_IDE_ONLY)
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker,
gd::ResourcesManager *resourcesManager);
#endif
virtual void ExposeResources(gd::ArbitraryResourceWorker &worker);

double GetWidth() const { return width; };
double GetHeight() const { return height; };
Expand Down
3 changes: 1 addition & 2 deletions Extensions/ParticleSystem/ParticleEmitterObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ void ParticleEmitterBase::SerializeParticleEmitterBaseTo(
ParticleEmitterBase::~ParticleEmitterBase() {}

void ParticleEmitterObject::ExposeResources(
gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager *resourcesManager) {
gd::ArbitraryResourceWorker& worker) {
gd::String texture = GetParticleTexture();
worker.ExposeImage(texture);
SetParticleTexture(texture);
Expand Down
3 changes: 1 addition & 2 deletions Extensions/ParticleSystem/ParticleEmitterObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ class GD_EXTENSION_API ParticleEmitterObject : public gd::ObjectConfiguration,
return gd::make_unique<ParticleEmitterObject>(*this);
}

virtual void ExposeResources(gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager *resourcesManager);
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker);

private:
virtual void DoUnserializeFrom(gd::Project& project,
Expand Down
3 changes: 1 addition & 2 deletions Extensions/TextObject/TextObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ void TextObject::DoSerializeTo(gd::SerializerElement& element) const {
}

void TextObject::ExposeResources(
gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager *resourcesManager) {
gd::ArbitraryResourceWorker& worker) {
worker.ExposeFont(fontName);
}
#endif
5 changes: 1 addition & 4 deletions Extensions/TextObject/TextObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ class GD_EXTENSION_API TextObject : public gd::ObjectConfiguration {
return gd::make_unique<TextObject>(*this);
}

#if defined(GD_IDE_ONLY)
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker,
gd::ResourcesManager *resourcesManager);
#endif
virtual void ExposeResources(gd::ArbitraryResourceWorker& worker);

/** \brief Change the text.
*/
Expand Down
Loading