Persist per-file view settings (codec, mode, zoom, canvas, offset, palette)#35
Closed
Greengoblin007 wants to merge 3 commits intotoruzz:masterfrom
Closed
Persist per-file view settings (codec, mode, zoom, canvas, offset, palette)#35Greengoblin007 wants to merge 3 commits intotoruzz:masterfrom
Greengoblin007 wants to merge 3 commits intotoruzz:masterfrom
Conversation
Three small fixes that surface together when opening files
on macOS / Linux:
1. XMLParser: set validating=false and install a no-op
EntityResolver. The resources XML references a relative
DTD path with a backslash ("resources\\tmres.dtd") which
the JDK parser tries to resolve as a URI; on non-Windows
systems this throws "no protocol" IOException, the
per-file resources fail to load, and bookmarks/palettes
silently disappear.
2. TMFileResources.toXML: stop emitting the DTD declaration
line — without validation it serves no purpose, and
keeping it propagates the broken reference to every newly
written XML.
3. TMView componentResized listener: guard against null
editorCanvas. The listener is registered before
editorCanvas is initialised in the constructor, so any
layout pass that fires a resize between those points
NPEs. Cheap defensive check.
4. TMUI.openFile: if loading the per-file resources XML
throws, the FileImage was left without a TMFileResources,
so closing the file produced no XML at all (and any
newly-added bookmarks were lost). Fall back to default
resources after a failed load.
Add a ViewSettings holder serialised inside the existing per-file ./resources/<filename>.xml. Captures and reapplies: - View > Codec - View > Mode (1D/2D) - View > Zoom - Image > Canvas Size (cols × rows) - Slider/byte offset - Palette > Import From > Another File (path + offset + size + codec ID + endianness) The settings are loaded automatically when the file is reopened (overriding the file-filter defaults) and captured silently when the file is closed (or the application exits through doCloseAll). Mirrors how bookmarks and palettes are already persisted. Each field is optional: an old XML without <viewsettings> loads as before. Codec IDs and external palette files that no longer exist are ignored without error. Motivation: opening a ROM today forces re-selecting codec, zoom, canvas size and the external palette every single time.
Two small UX tweaks that pair naturally with the per-file view settings feature; kept as a separate commit so they can be reverted independently. - addViewToDesktop now calls view.setMaximum(true) after setSelected, so a freshly opened file fills the MDI area instead of starting in a small floating frame. - The Open File dialog now defaults to the "All Files (*.*)" filter rather than "All Supported Formats". The supported- formats filter is still listed and selectable; this only changes the initial selection. Most files used with TM are ROM dumps with extensions the bundled filters do not match, so users had to switch to "All Files" by hand every open.
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.
Summary
Tile Molester already persists bookmarks and palette folders per file in
./resources/<filename>.xml. This PR extends the same XML with a<viewsettings>element that captures the rest of the view state, so reopening a file restores the workspace exactly where you left it instead of reverting to the file-filter defaults.Depends on #34 (the XML parser fix). Without it, the new
<viewsettings>element loads correctly on Windows but is silently dropped on macOS/Linux. If #34 lands first, this PR's diff against master will shrink to just the feature.What gets remembered
View > CodecView > ModeView > ZoomImage > Canvas Size...Palette > Import From > Another File...(path + offset + size + codec ID + endianness)Behaviour
<viewsettings>exists, it is applied right after the view is created, overriding the file-filter defaults. Missing or unknown values (e.g. a codec ID that no longer exists, or an external palette file that was moved) are skipped silently — never an error dialog.saveResourcesflow. No new save action, no extra prompts.<viewsettings>open exactly as before.Two extra UX commits (separable)
Kept as their own commits so they can be dropped on review:
addViewToDesktopcallsview.setMaximum(true)so a freshly opened file fills the MDI area.If either of these is unwanted, drop the second commit (
1bd57f1) — the core feature stands on its own.Test plan
mvn package(Java 17)<viewsettings>→ bookmarks still load, defaults apply<viewsettings>parsing) → no crash, just ignored🤖 Generated with Claude Code