Skip to content

Add Battlefield Support Asset editing and printing - #2264

Merged
pavelbraginskiy merged 20 commits into
MegaMek:mainfrom
pavelbraginskiy:bfs-assets
Aug 2, 2026
Merged

Add Battlefield Support Asset editing and printing#2264
pavelbraginskiy merged 20 commits into
MegaMek:mainfrom
pavelbraginskiy:bfs-assets

Conversation

@pavelbraginskiy

@pavelbraginskiy pavelbraginskiy commented Jul 16, 2026

Copy link
Copy Markdown
Member

Must be merged with PRs MegaMek/megamek#8533, MegaMek/mekhq#9653, MegaMek/mm-data#470

Add Battlefield Support Asset editing and printing

This adds full MegaMekLab support for creating and editing standalone .bfs files,
as well as managing linked Asset sidecars from eligible standard-unit editors.
Linked editors share identity and artwork with their base unit and preserve both files
through save, Save As, undo/redo, reopening, and session tab restoration.

Battlefield Support cards are available in previews, multi-unit selection, mixed-force printing,
and PDF export using the existing record-sheet pipeline. The editor also validates Asset-specific fields and Specials,
coordinates UUID changes between linked files, and supports both US Letter and A4 output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pavelbraginskiy
pavelbraginskiy requested a review from a team as a code owner July 16, 2026 00:15
Copilot AI review requested due to automatic review settings July 16, 2026 00:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds full MegaMekLab support for Battlefield Support Assets (.bfs) including a standalone asset editor, linked base-unit sidecar workflow, and printing/preview/export integration so assets behave like first-class units in editing, session restore, and record sheet pipelines.

Changes:

  • Introduces a standalone Battlefield Support Asset editor and shared linked-asset infrastructure for eligible base-unit editors.
  • Extends save/load/undo-redo/tab-state/session-restore plumbing to track a linked .bfs sidecar alongside the base unit.
  • Adds BFS card preview and printing/export support (including tiled multi-card sheets) across selectors/queues and record-sheet preview.

Reviewed changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
megameklab/unittests/megameklab/util/UnitMementoTest.java Adds unit tests ensuring mementos include linked asset state.
megameklab/unittests/megameklab/util/BattlefieldSupportAssetSaveTest.java Tests .bfs YAML serialization and round-trip parsing.
megameklab/unittests/megameklab/ui/util/TabUtilTest.java Tests new tab-state DB v2 format with linked assets + legacy parsing.
megameklab/unittests/megameklab/ui/generalUnit/BattlefieldSupportCardListPanelTest.java Smoke test for multi-select BFS card preview panel.
megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java Tests linked sidecar save targeting and UUID relinking rules.
megameklab/unittests/megameklab/printing/PrintBattlefieldSupportCardSheetTest.java Tests BFS card sheet pagination/rendering and SVG/PNG output.
megameklab/src/megameklab/util/UnitUtil.java Adds BFS entity type detection and .bfs YAML save path.
megameklab/src/megameklab/util/UnitPrintManager.java Adds BFS assets to sheet creation and file chooser filters.
megameklab/src/megameklab/util/UnitMemento.java Tracks/compares/restores linked asset state in mementos.
megameklab/src/megameklab/util/MMLFileDropTransferHandler.java Allows drag/drop opening of .bfs files.
megameklab/src/megameklab/ui/util/TabUtil.java Saves/restores paired base+asset tab state (new v2 db format).
megameklab/src/megameklab/ui/util/MegaMekLabFileSaver.java Adds .bfs filename/save support and shared UUID conflict resolution (incl. linked assets).
megameklab/src/megameklab/ui/supportVehicle/SVStructureTab.java Adds BFS toggle wiring and icon-change refresh notifications.
megameklab/src/megameklab/ui/supportVehicle/SVMainUI.java Implements linked-asset editor behavior for support vehicles.
megameklab/src/megameklab/ui/StartupGUI.java Adjusts unit selector dialog invocation to control asset-form offering.
megameklab/src/megameklab/ui/MenuBar.java Adds .bfs to open filters and “New/Switch to Battlefield Support Asset”.
megameklab/src/megameklab/ui/MegaMekLabTabbedUI.java Adds “New Battlefield Support Asset” to the tabbed UI new-unit menu.
megameklab/src/megameklab/ui/MegaMekLabMainUI.java Integrates linked asset into undo/redo restore and save pipeline.
megameklab/src/megameklab/ui/listeners/BuildListener.java Adds callback for BFS toggle changes from BasicInfoView.
megameklab/src/megameklab/ui/infantry/CIStructureTab.java Adds BFS toggle wiring and icon-change refresh notifications.
megameklab/src/megameklab/ui/infantry/CIMainUI.java Implements linked-asset editor behavior for conventional infantry.
megameklab/src/megameklab/ui/generalUnit/SourceView.java New reusable “Source” picker widget for asset editor reuse.
megameklab/src/megameklab/ui/generalUnit/RecordSheetPreviewPanel.java Fixes createDocument calls to use absolute page index (firstPage offset).
megameklab/src/megameklab/ui/generalUnit/PreviewTab.java Adds conditional BFS Card preview tab for linked assets.
megameklab/src/megameklab/ui/generalUnit/IconView.java Adds refresh listener to propagate icon changes to dependent views.
megameklab/src/megameklab/ui/generalUnit/BattlefieldSupportCardListPanel.java New multi-select BFS card list preview panel.
megameklab/src/megameklab/ui/generalUnit/BasicInfoView.java Adds BFS enable/disable toggle row used by eligible base editors.
megameklab/src/megameklab/ui/ForceBuildUI.java Adds asset-aware columns/rendering and BV/BSP handling for assets.
megameklab/src/megameklab/ui/dialog/UiLoader.java Adds .bfs editor creation and linked open logic (base<->asset pairing).
megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java Tags BFS assets in the print queue list UI.
megameklab/src/megameklab/ui/dialog/MegaMekLabUnitSelectorDialog.java Adds asset-form selection, BFS Cards preview tab, and improved selection rules.
megameklab/src/megameklab/ui/combatVehicle/GEStructureTab.java Adds BFS toggle wiring and icon-change refresh notifications.
megameklab/src/megameklab/ui/combatVehicle/GEMainUI.java Implements linked-asset editor behavior for gun emplacements.
megameklab/src/megameklab/ui/combatVehicle/CVStructureTab.java Adds BFS toggle wiring and icon-change refresh notifications.
megameklab/src/megameklab/ui/combatVehicle/CVMainUI.java Implements linked-asset editor behavior for combat vehicles.
megameklab/src/megameklab/ui/battlefieldSupport/BFSStructureTab.java New BFS asset construction/editor tab (standalone + linked mode).
megameklab/src/megameklab/ui/battlefieldSupport/BFSStatusBar.java New minimal status bar for standalone asset editor.
megameklab/src/megameklab/ui/battlefieldSupport/BFSMainUI.java New standalone .bfs main editor UI.
megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedOpen.java Implements counterpart auto-loading (co-located + cache UUID linking).
megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedFiles.java Implements linked sidecar save/delete behavior + path resolution.
megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedEditor.java Defines base-editor interface for linked asset tab visibility + toggle.
megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedAssetSupport.java Shared carrier/enable/path logic + shared-identity syncing for linked assets.
megameklab/src/megameklab/ui/battlefieldSupport/BFSAssetSource.java Defines the linked asset source contract used by editors and save flows.
megameklab/src/megameklab/ui/battleArmor/BAStructureTab.java Adds BFS toggle wiring and icon-change refresh notifications.
megameklab/src/megameklab/ui/battleArmor/BAMainUI.java Implements linked-asset editor behavior for battle armor.
megameklab/src/megameklab/printing/SVGMassPrinter.java Excludes BFS assets from record-sheet-only mass export flow.
megameklab/src/megameklab/printing/RecordSheetOptions.java Adds AWT Color parsing for damage color for Java2D BFS cards.
megameklab/src/megameklab/printing/PrintRecordSheet.java Makes getFirstPage() public and clarifies absolute page index usage.
megameklab/src/megameklab/printing/PrintBattlefieldSupportCardSheet.java New printable tiled BFS card sheet record-sheet implementation.
megameklab/src/megameklab/MegaMekLab.java Registers global BFS card default providers and allows opening .bfs.
megameklab/resources/megameklab/resources/Views.properties Adds new UI strings for BFS editor, toggles, and linked-file dialogs.
megameklab/resources/megameklab/resources/Dialogs.properties Adds BFS asset tag string for print queue UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread megameklab/src/megameklab/ui/util/TabUtil.java Outdated
Comment thread megameklab/src/megameklab/ui/ForceBuildUI.java
@pavelbraginskiy pavelbraginskiy added the AI ready for Review Indicates that is has been in game tested and is ready for review as it can be label Jul 16, 2026
Comment thread megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedOpen.java Fixed
Comment thread megameklab/src/megameklab/ui/util/TabUtil.java Fixed
Copilot AI review requested due to automatic review settings July 23, 2026 05:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated 1 comment.

Comment thread megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedFiles.java
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 23, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated 2 comments.

Comment thread megameklab/src/megameklab/util/UnitUtil.java Outdated
Comment thread megameklab/src/megameklab/ui/battlefieldSupport/BFSStatusBar.java Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 55 changed files in this pull request and generated 4 comments.

Comment thread megameklab/src/megameklab/ui/generalUnit/BasicInfoView.java
Comment thread megameklab/src/megameklab/ui/generalUnit/SourceView.java
Comment thread megameklab/src/megameklab/ui/MegaMekLabMainUI.java Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 56 out of 56 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

megameklab/unittests/megameklab/printing/PrintBattlefieldSupportCardSheetTest.java:147

  • This unit test writes SVG/PNG artifacts into build/bfs-cards-sheet/ unconditionally. That creates non-essential side effects during CI runs and can make tests slower or flaky in constrained environments.

Consider gating artifact writes behind a system property/env var (default off), or removing the file writes entirely while keeping the in-memory SVG/PNG assertions.
megameklab/unittests/megameklab/printing/PrintBattlefieldSupportCardSheetTest.java:173

  • This unit test writes SVG/PNG artifacts into build/bfs-cards-sheet/ unconditionally. That creates non-essential side effects during CI runs and can make tests slower or flaky in constrained environments.

Consider gating artifact writes behind a system property/env var (default off), or removing the file writes entirely while keeping the in-memory SVG/PNG assertions.

Comment thread megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedFiles.java
Copilot AI review requested due to automatic review settings July 26, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 26, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

pavelbraginskiy and others added 2 commits July 26, 2026 14:07
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 57 out of 57 changed files in this pull request and generated 2 comments.

Comment thread megameklab/src/megameklab/printing/PrintBattlefieldSupportCardSheet.java Outdated
Comment thread megameklab/src/megameklab/printing/RecordSheetTask.java Outdated
Copilot AI review requested due to automatic review settings July 26, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 26, 2026 22:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 27, 2026 02:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 63 out of 63 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (4)

megameklab/src/megameklab/ui/battlefieldSupport/BFSLinkedFiles.java:154

  • The zip-archive warning dialog uses hard-coded title/message strings (while the rest of this class uses the Views resource bundle) and the block’s indentation is inconsistent. Consider moving the strings into Views.properties (similar to the delete prompts) so they are localizable and keeping indentation consistent.
        for (File candidate : candidates) {
            if (isInsideZip(candidate.getPath())) {
                JOptionPane.showMessageDialog(owner,
                      "The Battlefield Support Asset data for this unit is stored inside a zip archive (" +
                            candidate.getName() + ") and cannot be removed from MegaMekLab. Re-enable the asset to " +
                            "keep it, or remove the data from the archive manually.",
                      "Asset Data In Archive", JOptionPane.WARNING_MESSAGE);
                    resolved = false;
                    continue;
            }

megameklab/src/megameklab/ui/util/TabUtil.java:304

  • The parseTabStateDb Javadoc block is missing the usual leading * alignment on several lines, making the documentation hard to read. Reformat to standard Javadoc layout.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:231
  • This block has multiple assertions with inconsistent indentation (extra leading spaces). Reformatting keeps the unit test readable and consistent with the rest of the file.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:257
  • This section has indentation issues (several lines are over-indented), which makes the test harder to scan. Align these assertions with the surrounding style.

Comment thread megameklab/src/megameklab/ui/util/TabUtil.java
Copilot AI review requested due to automatic review settings August 2, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 63 out of 63 changed files in this pull request and generated no new comments.

Suppressed comments (9)

megameklab/src/megameklab/ui/util/TabUtil.java:306

  • This Javadoc block has misaligned leading * on several lines (e.g. the continued description after the first line). This is inconsistent with the rest of the file and may break Checkstyle's Javadoc formatting rules.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:232
  • The assertEquals continuation indentation is inconsistent here (the assertEquals line is shifted left compared to surrounding code). This is likely to fail Checkstyle indentation rules.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:239
  • Several assertions in this block are mis-indented (e.g. the assertTrue(...) and assertEquals(...) lines at the same nesting level). This is likely to violate Checkstyle indentation rules.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:254
  • The assertNull(...) line is significantly over-indented compared to adjacent assertions. This is likely to violate Checkstyle indentation rules.
    megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:258
  • This block has inconsistent indentation (the assertTrue(...) lines are over-indented compared to their surrounding scope). This is likely to violate Checkstyle indentation rules.
    megameklab/src/megameklab/ui/MegaMekLabMainUI.java:437
  • This block has inconsistent indentation (including a mis-indented overload and body) which is likely to fail the repo's Checkstyle/formatting rules and makes the overload easy to miss during review. Reformat it to match the surrounding class style.
    public void adoptLinkedBattlefieldSupportAsset(@Nullable BattlefieldSupportAsset asset,
          @Nullable String assetFilePath) {
                adoptLinkedBattlefieldSupportAsset(asset, assetFilePath, asset != null);
        }

        /** Restores the complete linked-asset state, including a disabled carrier. */
        public void adoptLinkedBattlefieldSupportAsset(@Nullable BattlefieldSupportAsset asset,
                    @Nullable String assetFilePath, boolean enabled) {
        BFSAssetSource source = getBattlefieldSupportAssetSource();
        if (source != null) {
            source.adoptAsset(asset);
            source.setBattlefieldSupportAssetEnabled(enabled);
            source.setAssetFilePath(assetFilePath);
        }
    }

megameklab/src/megameklab/ui/util/TabUtil.java:296

  • The chained StringBuilder.append(...) calls have inconsistent continuation indentation, which is likely to fail Checkstyle's indentation rules. Re-indent the chain consistently.
    megameklab/src/megameklab/ui/util/TabUtil.java:86
  • The Javadoc indentation here is inconsistent (misaligned leading *), which is likely to trigger Checkstyle's Javadoc/Indentation rules. Align the asterisks with the rest of the file's Javadocs.

This issue also appears on line 300 of the same file.
megameklab/unittests/megameklab/ui/battlefieldSupport/BFSLinkedFilesTest.java:214

  • Indentation is inconsistent within this assertion block (the assertNull line is over-indented), which is likely to violate Checkstyle indentation rules for tests.

This issue also appears in the following locations of the same file:

  • line 229
  • line 234
  • line 252
  • line 255

pavelbraginskiy added a commit to MegaMek/megamek that referenced this pull request Aug 2, 2026
Must be merged with PRs MegaMek/megameklab#2264. MegaMek/mekhq#9653,
MegaMek/mm-data#470

## Add Battlefield Support Assets

This adds Battlefield Support Assets as a first-class unit type,
using a new `.bfs` YAML format for their card-based stats and UUID links
to corresponding standard units.
Assets are integrated into the unit cache and selector,
include Advanced Search filters, render printable BFS cards, and support
standalone or linked unit forms.

The update also adds lobby selection and configuration, Regular/Veteran
crews and costs,
persistent damage and MUL round-tripping, distinctive camouflage
overlays,
and dedicated Summary, TRO, and BFS Card views.
This PR provides the data model and non-gameplay infrastructure;
the Asset movement and combat rules will follow separately.
@pavelbraginskiy
pavelbraginskiy merged commit 4835542 into MegaMek:main Aug 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI ready for Review Indicates that is has been in game tested and is ready for review as it can be

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants