Package megameklab.ui.battlefieldSupport
Class BFSLinkedFiles
java.lang.Object
megameklab.ui.battlefieldSupport.BFSLinkedFiles
File-side helpers for a linked Battlefield Support Asset: writing the
.bfs sidecar next to its base unit's
saved file, and offering to delete a stale sidecar when the asset has been disabled. The .bfs location is
derived from the base file so linked saving stays convenient (only the base file location is ever prompted).-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic FilecoLocatedSidecar(File baseFile) static booleanhandleSidecarOnSave(JFrame owner, BFSAssetSource source, File baseFile, String baseUnitFileUUID, boolean baseMovedOrNew, PopupMessages.UnitFileUUIDChoice baseConflictChoice) Handles the linked asset's.bfssidecar when the base unit is saved tobaseFile.static booleanisInsideZip(String path) static FileresolveSaveTarget(File baseFile, String existingAssetPath, boolean baseMovedOrNew) Resolves where the linked asset's.bfsshould be written for a base file saved tobaseFile.static StringstripExtension(String fileName)
-
Field Details
-
BFS_EXTENSION
- See Also:
-
-
Method Details
-
handleSidecarOnSave
public static boolean handleSidecarOnSave(JFrame owner, BFSAssetSource source, File baseFile, @Nullable String baseUnitFileUUID, boolean baseMovedOrNew, @Nullable PopupMessages.UnitFileUUIDChoice baseConflictChoice) throws IOException Handles the linked asset's.bfssidecar when the base unit is saved tobaseFile. When the asset is enabled it is re-linked to the base unit's final UUID and written to its resolved target; when disabled, a stale sidecar (if any) is offered for deletion.- Parameters:
owner- the owner frame for any dialogssource- the editor's asset source (carrier + enable flag + current asset file path)baseFile- the base unit file that was just savedbaseUnitFileUUID- the base unit's final unit-file UUID (the asset'slinkedUnitIdis set to this so the sidecar links to the base file it is saved alongside, even if the base adopted a different UUID during the save)baseMovedOrNew-truewhen the base was saved to a new/different file (Save As, rename, or first save) — the sidecar is then written fresh next to the new base file rather than to the asset's previous locationbaseConflictChoice- the UUID conflict choice made for the base unit (so the asset's own UUID follows the same decision on a conflict), ornullif the base save had no conflict- Throws:
IOException- if an enabled linked Asset cannot be written
-
resolveSaveTarget
public static File resolveSaveTarget(File baseFile, String existingAssetPath, boolean baseMovedOrNew) Resolves where the linked asset's.bfsshould be written for a base file saved tobaseFile.- An in-place save (base file unchanged) of an asset that already has a file writes back to that file (wherever it was loaded from), even if its name differs from the base stem.
- A Save As / rename / first save, or a newly-added asset with no file yet, writes a fresh
<baseStem>.bfsnext to the base file (self-contained co-located copy).
- Parameters:
baseFile- the just-saved base unit fileexistingAssetPath- the asset's current file path, ornullif it has nonebaseMovedOrNew- whether the base file location changed (or is a first save)- Returns:
- the
.bfsfile to write
-
coLocatedSidecar
- Returns:
- the
<baseStem>.bfsfile in the base file's directory.
-
isInsideZip
- Returns:
- whether the given path points inside a zip archive (a cached asset can't be deleted from one).
-
stripExtension
- Returns:
- the file name without its extension (the part after the last dot).
-