diff --git a/.claude/skills/file-loading/SKILL.md b/.claude/skills/file-loading/SKILL.md index d33a824..310c6c3 100644 --- a/.claude/skills/file-loading/SKILL.md +++ b/.claude/skills/file-loading/SKILL.md @@ -28,6 +28,7 @@ Controlled by `SupportedAssetExtensions` in `Index.razor.cs`: - **`.fnt`** — BMFont text format; stored as raw bytes. The UI parses `page` lines to show which texture files the font references (so users know what companion `.png` files to also drop) - **`.ttf`** — TrueType font; stored as raw bytes for FontStashSharp - **`.ember`** — stored as raw bytes +- **`.tmx` `.tsx` `.world` `.ldtk` `.ogmo` `.json` `.txt` `.xml`** — text/data formats (tilemap & level-editor files plus generic data); stored as raw bytes and read by user code via `TitleContainer.OpenStream` (no `Load` branch) `InMemoryContentManager.Load()` has explicit branches for `Texture2D` and `SoundEffect`. Any other type falls through to `base.Load()`, which will fail (no disk content pipeline exists). diff --git a/XnaFiddle.BlazorGL/Pages/Index.razor.cs b/XnaFiddle.BlazorGL/Pages/Index.razor.cs index a85cfc8..02b24a8 100644 --- a/XnaFiddle.BlazorGL/Pages/Index.razor.cs +++ b/XnaFiddle.BlazorGL/Pages/Index.razor.cs @@ -342,7 +342,10 @@ protected override async void OnAfterRender(bool firstRender) static readonly HashSet SupportedAssetExtensions = new(StringComparer.OrdinalIgnoreCase) { - ".achx", ".png", ".fnt", ".ttf", ".ember", ".wav", ".xnb" + ".achx", ".png", ".fnt", ".ttf", ".ember", ".wav", ".xnb", + // Text/data formats: tilemap & level-editor files plus generic data. Stored as raw + // bytes and read by user code via TitleContainer.OpenStream (issue #115). + ".tmx", ".tsx", ".world", ".ldtk", ".ogmo", ".json", ".txt", ".xml" }; static readonly string SupportedExtensionsDisplay = @@ -1583,7 +1586,7 @@ private async Task LoadFromGistId(string input) // First .cs file (fall back to first .txt) is the program; every .fx file is a // shader tab (issue #26 phase 2b). Don't break early — we must see all files. string code = null; - string txtFallback = null; + JsonProperty? txtFallback = null; // first .txt: program if no .cs, else a data asset (issue #115) var shaderFiles = new List(); // Gists can bundle image/sound/font assets alongside the code (issue #82). Collect // any file whose extension is a supported asset and register it after the loop, so @@ -1596,11 +1599,19 @@ private async Task LoadFromGistId(string input) else if (code == null && file.Name.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)) code = file.Value.GetProperty("content").GetString(); else if (txtFallback == null && file.Name.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)) - txtFallback = file.Value.GetProperty("content").GetString(); + txtFallback = file; else if (SupportedAssetExtensions.Contains(System.IO.Path.GetExtension(file.Name))) assetFiles.Add(file); } - code ??= txtFallback; + // The first .txt is the program only when no .cs was found; otherwise (now that + // .txt is an allowlisted asset) it's a bundled data file (issue #115). + if (txtFallback is JsonProperty txtFile) + { + if (code == null) + code = txtFile.Value.GetProperty("content").GetString(); + else + assetFiles.Add(txtFile); + } if (code == null) {