Add Tiled Import and Export functionality#15
Merged
wernerbihl merged 12 commits intomainfrom May 5, 2026
Merged
Conversation
- Refactor useTiledProjectImport hook to support both zip and raw Tiled project files. - Implement directory file selection for linked resources. - Add validation for Tiled project files and improve error handling. - Introduce a dialog for resolving missing resources during import. - Update import-export action utilities to handle directory file picking. - Create a new function to prepare Tiled project imports with better resource management. - Add tests for the new import functionality and ensure coverage for missing resource handling. - Refactor project creation logic to use a dedicated function for initializing empty projects.
…ated animation note from TODO
There was a problem hiding this comment.
Pull request overview
Adds Tiled project-level import/export support to the app’s import/export layer and wires file-based import entry points into the editor UI. It also refactors a few map-canvas helpers and expands test coverage around the new flows.
Changes:
- Adds Tiled project archive import/export, missing-resource resolution, and imported-project session replacement.
- Extends map/tileset UI to support file-based import from dialogs and drag-and-drop.
- Refactors map canvas rendering helpers and adds tests for project import/export behavior.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| TODO.txt | Updates roadmap items. |
| tests/features/project-management/lib/project.test.ts | Adds coverage for empty-project creation. |
| tests/features/map-editor/components/MapCanvas/draw-layer-entries.test.ts | Adds active-layer redraw regression coverage. |
| tests/features/import-export/lib/imported-tiled-project-session.test.ts | Tests imported Tiled project replacement flow. |
| tests/features/import-export/lib/import-export-tiled-project.test.ts | Adds Tiled project import/export tests. |
| tests/features/import-export/lib/import-export-gamemaker.test.ts | Expands GameMaker export coverage for GMX. |
| tests/features/import-export/lib/import-export-action-utils.test.ts | Tests picker helpers, including directory selection. |
| tests/features/import-export/lib/gamemaker-map-import.test.ts | Expands GameMaker GMX import coverage. |
| tests/features/import-export/hooks/use-tiled-map-import.test.ts | Adds hook tests for Tiled project import UX. |
| src/features/project-management/lib/project.ts | Extracts reusable empty-project factory. |
| src/features/project-management/components/ProjectDialog.tsx | Switches project creation to shared helper. |
| src/features/map-editor/types/map-panel.ts | Threads map-file import callbacks through panel props. |
| src/features/map-editor/types/map-canvas-rendering.ts | Adds paint-buffer input to active-layer rendering params. |
| src/features/map-editor/types/dialogs.ts | Extends new-map dialog props for file import. |
| src/features/map-editor/dialogs/NewMapDialog.tsx | Adds “From File” tab with picker/drop-zone import. |
| src/features/map-editor/components/TilesetPanel.tsx | Enables tileset import from non-image files and drag-drop. |
| src/features/map-editor/components/MapPanel/MapPanelWorkspace.tsx | Adds map-file drag-drop import surface. |
| src/features/map-editor/components/MapPanel/MapPanelDialogs.tsx | Passes new map import callback into dialog layer. |
| src/features/map-editor/components/MapPanel.tsx | Wires map-file import callback through panel. |
| src/features/map-editor/components/MapCanvas/use-map-canvas-imperative-handle.ts | Extracts imperative paint-canvas helpers. |
| src/features/map-editor/components/MapCanvas/use-animation-elapsed-ms.ts | Extracts animated-tile timer hook. |
| src/features/map-editor/components/MapCanvas/index.tsx | Adopts extracted hooks and paint-buffer redraw path. |
| src/features/map-editor/components/MapCanvas/draw-layer-entries.ts | Merges live paint buffer into active-layer redraws. |
| src/features/import-export/types/index.ts | Adds Tiled project import state/dialog/result types. |
| src/features/import-export/lib/tiled-project-action-utils.ts | Adds project-level Tiled export helper. |
| src/features/import-export/lib/imported-tiled-project-session.ts | Replaces current editor session with imported Tiled project data. |
| src/features/import-export/lib/import-export-tiled-project.ts | Implements Tiled project import/export bundle logic. |
| src/features/import-export/lib/import-export-options.ts | Marks Tiled project option as supported. |
| src/features/import-export/lib/import-export-action-utils.ts | Refactors picker helpers and adds directory picker support. |
| src/features/import-export/index.ts | Re-exports new Tiled project dialog. |
| src/features/import-export/hooks/use-unity-tileset-import.ts | Allows preselected Unity tileset files. |
| src/features/import-export/hooks/use-unity-map-import.ts | Allows preselected Unity map files. |
| src/features/import-export/hooks/use-tiled-tileset-import.ts | Allows preselected Tiled tileset files. |
| src/features/import-export/hooks/use-tiled-project-import.ts | Adds Tiled project import hook and dialog state flow. |
| src/features/import-export/hooks/use-tiled-map-import.ts | Allows preselected Tiled map files. |
| src/features/import-export/hooks/use-tide-map-import.ts | Allows preselected tIDE map files. |
| src/features/import-export/hooks/use-mappy-map-import.ts | Allows preselected Mappy map files. |
| src/features/import-export/hooks/use-import-export-actions.ts | Integrates Tiled project flows and generic file-based map/tileset import routing. |
| src/features/import-export/hooks/use-godot-tileset-import.ts | Allows preselected Godot tileset files. |
| src/features/import-export/hooks/use-godot-map-import.ts | Allows preselected Godot map files. |
| src/features/import-export/hooks/use-gamemaker-map-import.ts | Allows preselected GameMaker map files. |
| src/features/import-export/hooks/use-defold-tileset-import.ts | Allows preselected Defold tileset files. |
| src/features/import-export/hooks/use-defold-map-import.ts | Allows preselected Defold map files. |
| src/features/import-export/components/TiledProjectFilesDialog.tsx | Adds folder-selection dialog for raw Tiled project imports. |
| src/features/import-export/components/TiledMissingResourcesDialog.tsx | Allows custom dialog description text. |
| src/features/app-shell/components/AppShell.tsx | Wires new import handlers and lazy-loaded Tiled project dialog into the shell. |
| AGENTS.md | Adds code-search/workflow guidance. |
Comment on lines
+126
to
+133
| for (const entry of entries) { | ||
| if (entry.path === expectedMapPath) { | ||
| const uniquePath = getUniqueArchivePath(entry.path, seenPaths); | ||
| archiveEntries.push({ path: uniquePath, data: entry.data }); | ||
| } else if (!seenPaths.has(entry.path)) { | ||
| seenPaths.add(entry.path); | ||
| archiveEntries.push(entry); | ||
| } |
Comment on lines
+48
to
+55
| function detectMapFormat(fileName: string): TiledMapFormat | null { | ||
| const lower = fileName.toLowerCase(); | ||
| if (lower.endsWith(".tmx") || lower.endsWith(".xml")) return "xml"; | ||
| if (lower.endsWith(".tmj")) return "json"; | ||
| if (lower.endsWith(".js")) return "js"; | ||
| if (lower.endsWith(".lua")) return "lua"; | ||
| return null; | ||
| } |
Comment on lines
+179
to
+187
|
|
||
| export async function prepareTiledProjectImport( | ||
| entries: readonly ImportExportArchiveEntry[], | ||
| ): Promise<TiledProjectImportPreparationResult> { | ||
| const mapPaths = entries | ||
| .map((entry) => entry.path) | ||
| .filter((path) => { | ||
| if (isTilesetOrImageEntry(path)) return false; | ||
| if (path.toLowerCase().endsWith(".tiled-project")) return false; |
| ): Promise<void> { | ||
| const targetProject = createEmptyProject( | ||
| suggestedProjectName, | ||
| result.maps[0]?.map.tileSize ?? 32, |
Comment on lines
+26
to
+33
| for (const mapImport of result.maps) { | ||
| mergeImportedMapData( | ||
| mapImport, | ||
| targetProject, | ||
| targetMapGroupId, | ||
| targetTilesetGroupId, | ||
| setState, | ||
| ); |
Comment on lines
+47
to
+49
| async function handleImportFile(file: File) { | ||
| await onImportMapFromFile(file); | ||
| onOpenChange(false); |
Comment on lines
20
to
21
| label: "Tiled Project (.tiled-project)", | ||
| description: "Tiled multi-map project container.", |
Comment on lines
+5
to
+9
| `bash | ||
| semble search "authentication flow" ./my-project | ||
| semble search "save_pretrained" ./my-project | ||
| semble search "save model to disk" ./my-project --top-k 10 | ||
| ` |
Comment on lines
+13
to
+15
| `bash | ||
| semble find-related src/auth.py 42 ./my-project | ||
| ` |
Comment on lines
+198
to
+208
| <div | ||
| className={`flex min-h-32 cursor-pointer flex-col items-center justify-center gap-3 rounded-md border-2 border-dashed p-6 transition-colors ${ | ||
| isDroppingFile | ||
| ? "border-primary bg-primary/10" | ||
| : "border-muted-foreground/30 hover:border-muted-foreground/50" | ||
| }`} | ||
| onDragOver={handleDragOver} | ||
| onDragLeave={handleDragLeave} | ||
| onDrop={(e) => void handleDrop(e)} | ||
| onClick={() => importFileInputRef.current?.click()} | ||
| > |
Collaborator
Author
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/2dtiler/app/sessions/53dde639-c91f-49c7-b8a2-54f06f55b600 Co-authored-by: wernerbihl <1950410+wernerbihl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/2dtiler/app/sessions/53dde639-c91f-49c7-b8a2-54f06f55b600 Co-authored-by: wernerbihl <1950410+wernerbihl@users.noreply.github.com>
Contributor
Applied all 9 fixes from the review thread in commit
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce comprehensive import and export capabilities for Tiled projects, enhancing support for various map and tileset formats. Implement improved error handling, resource management, and user dialogs for missing resources. Update related utilities and add tests to ensure functionality and coverage. Refactor existing code for better maintainability and clarity.