feat(viewer): directory-tree browser + plain-text viewer
Explorer drawer was a flat list of all 353 disc files and only textures had a preview. Two additions: 1. Directory tree — the left drawer is now a collapsible `📁` tree, rebuilt each frame from the path list (ui.rs: build_tree / split_for_tree / render_dir). Filtering narrows leaves and auto-expands matches; `.p00…p04` data segments nest under a virtual `<stem>.pak` node. Selection still keys off the original file index, so the loader pipeline is untouched. 2. Plain-text viewer — config.ini and any file that sniffs as text now show read-only, selectable, monospace content with a Wrap toggle and an encoding label. Detection/decoding live in the Bevy-free formats crate: vfs::is_probably_text + vfs::decode_text (BOM-aware UTF-8/UTF-16LE/BE, BOM-less UTF-16LE heuristic, NUL-reject + 95%-printable fallback) — pure std, WASM-safe, unit-tested (6 new tests), and reused by the CLI sniffer (new cyan `txt`). New TextPreview resource (registered unconditionally so it exists on wasm); populated in apply_loaded_texture with a 2 MiB char-boundary-safe cap. Also fixes a latent bug: switching from a texture to a non-texture left stale preview state — both texture and text state now reset on every selection. ViewerState gains text_wrap. Formats tests: 22 pass; workspace compiles. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,8 @@ pub struct ViewerState {
|
||||
pub current_mode: ViewMode,
|
||||
/// Whether to render meshes in wireframe mode (toggle with F2).
|
||||
pub wireframe: bool,
|
||||
/// Whether the plain-text viewer wraps long lines.
|
||||
pub text_wrap: bool,
|
||||
}
|
||||
|
||||
impl Default for ViewerState {
|
||||
@@ -39,6 +41,7 @@ impl Default for ViewerState {
|
||||
Self {
|
||||
current_mode: ViewMode::Textures,
|
||||
wireframe: false,
|
||||
text_wrap: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user