Skip to content

Commit e8c9804

Browse files
gajopclaude
andcommitted
Only thumbnail image files in the grid
Every file cell got an `<img>` src, so browsing a non-image (the compiled `.sdz` in the Export dialog, a `.lua`) made RmlUi try to load it as a texture: `[BMP::Load] invalid bitmap ... (loaded=0)`. Give a thumbnail only to known image extensions; other files show a caption-only cell. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4bcc6de commit e8c9804

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • native/src/sbc/panels/controls

‎native/src/sbc/panels/controls/grid.rs‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ impl GridView {
318318
const ASSETS_DIR: &str = "springboard/assets";
319319
const DEFAULT_ASSET_PACK: &str = "core";
320320

321+
/// Extensions the grid can render as a thumbnail; every other file (archives,
322+
/// Lua, ...) shows a caption-only cell so RmlUi never tries to load it.
323+
const IMAGE_EXTS: &[&str] = &[
324+
"png", "jpg", "jpeg", "bmp", "tga", "dds", "tif", "tiff", "gif",
325+
];
326+
321327
/// One level of the assets tree, as `AssetView` walks it.
322328
///
323329
/// At the top there is no directory to list: the entries are the asset *packs*
@@ -469,15 +475,20 @@ fn list_entries(
469475
}
470476
let path = join_entry(dir, &entry.name);
471477
let caption = path.rsplit('/').next().unwrap_or(&path).to_string();
478+
let lower = caption.to_lowercase();
472479
let matches = extensions.is_empty()
473-
|| extensions.iter().any(|ext| {
474-
caption
475-
.to_lowercase()
476-
.ends_with(&format!(".{}", ext.to_lowercase()))
477-
});
480+
|| extensions
481+
.iter()
482+
.any(|ext| lower.ends_with(&format!(".{}", ext.to_lowercase())));
478483
if matches {
484+
// Only actual images become thumbnails; giving an archive or Lua
485+
// file an `<img>`/`<texture>` src makes RmlUi try to load it and
486+
// log `[BMP::Load] invalid bitmap`.
487+
let is_image = IMAGE_EXTS
488+
.iter()
489+
.any(|ext| lower.ends_with(&format!(".{ext}")));
479490
files.push(GridItem {
480-
image: Some(path.clone()),
491+
image: is_image.then(|| path.clone()),
481492
id: path,
482493
caption,
483494
is_directory: false,

0 commit comments

Comments
 (0)