Skip to content

Store texture as relative path reference instead of copying into project - #33

Merged
AristurtleDev merged 1 commit into
developfrom
feature/30-texture-reference-not-copy
Mar 25, 2026
Merged

AristurtleDev merged 1 commit into
developfrom
feature/30-texture-reference-not-copy

Conversation

@AristurtleDev

Copy link
Copy Markdown
Contributor

Description

Previously, selecting a texture in the editor would copy it into the project directory. The .ember file then stored only the bare filename, requiring the texture to live alongside the .ember file at runtime. This made it impossible to reference textures in other directories (e.g., a shared spritesheet used by both particle effects and Tiled maps) without maintaining duplicate copies.

Textures are now referenced by a path relative to the .ember file and are never copied. A spritesheet at Content\maps\spritesheet.png can be referenced from Content\particles\effect.ember as ..\maps\spritesheet.png with no duplication.

Related Issues/Tickets

Changes Made

  • Removed CopyTo and IsRelativeTo from EditorContext. Texture files are no longer copied into the project directory on import.
  • AddTexture now generates the path of the selected file relative to the project directory via GetRelativePath and uses that as both the cache key and the value stored in Texture2D.Name. This is what the serializer writes to the Name attribute in the .ember XML, and what it resolves back on load.
  • LoadTexture is now private and takes an absolute path for loading and a relative path for naming. The cache is keyed by relative path, so textures from different directories that share a filename are treated as distinct entries and never conflict.
  • The overwrite confirmation dialog in ParticleEffectView has been removed entirely. With path keyed caching, filename conflicts between files in different directories cannot occur, and selecting the same file twice simply hits the cache.
  • The texture button in PropertyTable.TextureProperty now displays only the filename via Path.GetFileName, keeping the label short. The full relative path is shown in a dimmed line below the image preview in the hover tooltip for reference when needed.

Checklist

  • I have verified that there are no existing pull requests that would overlap with this pull request.
  • I have verified that I am following the guidelines as outlined in this project's contribution policy
  • I have verified that this pull request adheres to this project's code of conduct.
  • I have written a descriptive title for this pull request.
  • I have provided appropriate test coverage were applicable.

@github-actions github-actions Bot added Platform: Cross-platform All platforms Status: Review Needed Ready for code review Type: Feature New functionality labels Mar 25, 2026
@AristurtleDev
AristurtleDev merged commit 2894337 into develop Mar 25, 2026
1 check passed
@AristurtleDev
AristurtleDev deleted the feature/30-texture-reference-not-copy branch March 25, 2026 17:33
@github-actions github-actions Bot added Status: Completed Work finished and removed Status: Review Needed Ready for code review labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: Cross-platform All platforms Status: Completed Work finished Type: Feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Texture Should Be a Path Reference, Not a Copy

1 participant