Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .claude/skills/file-loading/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>` branch)

`InMemoryContentManager.Load<T>()` has explicit branches for `Texture2D` and `SoundEffect`. Any other type falls through to `base.Load<T>()`, which will fail (no disk content pipeline exists).

Expand Down
19 changes: 15 additions & 4 deletions XnaFiddle.BlazorGL/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ protected override async void OnAfterRender(bool firstRender)

static readonly HashSet<string> 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 =
Expand Down Expand Up @@ -1583,7 +1586,7 @@ private async Task<bool> 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<ShaderFile>();
// 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
Expand All @@ -1596,11 +1599,19 @@ private async Task<bool> 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)
{
Expand Down