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

Fix LDtk tile map resources export with the fast loading #5951

Merged
merged 6 commits into from
Nov 28, 2023

Conversation

D8H
Copy link
Collaborator

@D8H D8H commented Nov 24, 2023

@D8H D8H marked this pull request as ready for review November 24, 2023 19:15
@D8H D8H requested a review from 4ian as a code owner November 24, 2023 19:15
@D8H D8H changed the title Fix LDtk tile map export with the fast loading Fix LDtk tile map resources export with the fast loading Nov 24, 2023
instruction.SetParameter(parameterIndex, updatedParameterValue);
} else if (parameterMetadata.GetType() == "tilemapResource") {
gd::String updatedParameterValue = parameterValue;
worker.ExposeTilemap(updatedParameterValue);
worker.ExposeEmbeddeds(updatedParameterValue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only those 2 types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only these kind of resources are depending on external files.

Comment on lines 18 to 20
// TODO Refactor this to avoid to list all project resources as files.
gd::ResourcesManager* resourcesManager = &(project.GetResourcesManager());
resourceWorker.ExposeResources(resourcesManager);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth adding and doing a

Suggested change
// TODO Refactor this to avoid to list all project resources as files.
gd::ResourcesManager* resourcesManager = &(project.GetResourcesManager());
resourceWorker.ExposeResources(resourcesManager);
// TODO Refactor this to avoid to list all project resources as files.
gd::ResourcesManager* resourcesManager = &(project.GetResourcesManager());
resourceWorker.SetResourcesManager(resourcesManager);

To avoid all the calls to ExposeResource that will uselessly list all project resources as files?

@4ian 4ian mentioned this pull request Nov 27, 2023
Comment on lines 30 to 31
gd::ResourcesAbsolutePathChecker absolutePathChecker(originalProject.GetResourcesManager(), fs);
gd::ResourceExposer::ExposeWholeProjectResources(originalProject, absolutePathChecker);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is useless since quite a bit of time (it was used years ago to ask the user what to do with absolute filenames, but pretty sure it's not used anymore)

Comment on lines 29 to 34
gd::Project& project = originalProject;
if (!updateOriginalProject) {
std::shared_ptr<gd::Project> clonedProject(new gd::Project(originalProject));
project = *clonedProject;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect and is probably linked to issue you may have encountered:

A reference can't be changed after it's set. So when you do gd::Project& project = originalProject, any further assignement will change the originalProject. I.e: when you do project = *cloneProject, you modify originalProject to be equal to clonedProject (which is itself made from originalProject).

When a reference is first assigned, it says to which object it points to. But then when you change it, it modifies the object itself, not the reference.

if (updateOriginalProject) {
gd::ResourceExposer::ExposeWholeProjectResources(originalProject, resourcesMergingHelper);
} else {
std::shared_ptr<gd::Project> project(new gd::Project(originalProject));
Copy link
Owner

@4ian 4ian Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I think this is a overly complicated way of writing:
gd::Project project = originalProject; // i.e.: you make a copy.

preserveAbsoluteFilenames, preserveDirectoryStructure);
} else {
gd::Project clonedProject = originalProject;
gd::ProjectResourcesCopier::CopyAllResourcesTo(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@D8H D8H merged commit ba95f66 into master Nov 28, 2023
5 of 6 checks passed
@D8H D8H deleted the fix-tile-map-export branch November 28, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants