Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates MegaMekLab’s armor UI to better support patchwork armor workflows across multiple unit types, including aligning panel placement, improving patchwork selection visibility, and clarifying patchwork-specific weight behavior (per #1803).
Changes:
- Reorganizes armor-related panels (armor view, patchwork selector, allocation) for CV/ASF/BM and adjusts layout to keep heights consistent by hiding patchwork-irrelevant controls.
- Improves patchwork selection UX by refreshing the patchwork selector when an ineligible armor choice is rejected.
- Updates i18n strings and adds a patchwork help notice (“armor weight is calculated from the assigned points”).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| megameklab/src/megameklab/ui/supportVehicle/SVArmorTab.java | Patchwork rejection dialog parent + refresh patchwork selector after reset. |
| megameklab/src/megameklab/ui/mek/BMStructureTab.java | Panel order tweak; patchwork rejection dialog parent + patchwork selector refresh. |
| megameklab/src/megameklab/ui/largeAero/WSStructureTab.java | Removes no-op patchworkChanged override. |
| megameklab/src/megameklab/ui/largeAero/DSStructureTab.java | Removes no-op patchworkChanged override. |
| megameklab/src/megameklab/ui/generalUnit/PatchworkArmorView.java | Layout tweaks, filtering cleanup, prototype sizing, and minor refactor helpers. |
| megameklab/src/megameklab/ui/generalUnit/MVFArmorView.java | Patchwork-mode UI hides irrelevant fields and shows patchwork info; i18n cleanup. |
| megameklab/src/megameklab/ui/generalUnit/ArmorAllocationView.java | Uses display fields + i18n cleanup; hides non-patchwork-relevant controls in patchwork mode. |
| megameklab/src/megameklab/ui/fighterAero/ASStructureTab.java | Moves transport panel; refreshes patchwork selector on rejection; uses setFromEntity(..., true) when refreshing armor view. |
| megameklab/src/megameklab/ui/combatVehicle/CVStructureTab.java | Reorders panels to standardize armor UI placement. |
| megameklab/resources/megameklab/resources/Views.properties | Updates labels and adds patchwork info string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (getMek().getEmptyCriticalSlots(location) < crits) { | ||
| JOptionPane.showMessageDialog( | ||
| null, armor.getName() | ||
| + " does not fit in location " | ||
| + getMek().getLocationName(location) | ||
| + ". Resetting to Standard Armor in this location.", | ||
| JOptionPane.showMessageDialog(this, | ||
| "%s does not fit in location %s. Resetting to Standard Armor in this location." | ||
| .formatted(armor.getName(), getMek().getLocationName(location)), | ||
| "Error", | ||
| JOptionPane.INFORMATION_MESSAGE); | ||
| UnitUtil.resetArmor(getMek(), location); | ||
| panPatchwork.setFromEntity(getMek()); | ||
| } else { |
There was a problem hiding this comment.
After the failure path (getEmptyCriticalSlots < crits), the method calls UnitUtil.resetArmor(...) and then refreshes the UI. However, later in this method panArmor.setFromEntity(getMek()) (outside this hunk) may clear the patchwork checkbox / hide the patchwork UI when the entity no longer reports hasPatchworkArmor() after the reset. Other tabs call panArmor.setFromEntity(..., true) in similar situations to keep the user-selected patchwork mode stable. Consider updating the armor view refresh in this flow to use the ignoreEntityPatchwork=true overload so the reset-to-standard outcome is visible without exiting patchwork mode.
There was a problem hiding this comment.
this is valid; the patchwork checkbox should not become unchecked by selecting some armor type in a location (but it does happen), but this seemed like a complicated issue and I did not want to address it herein
| * @return True when the patchwork checkbox is selected; this is not equivalent to the unit having patchwork | ||
| * armor (entity.hasPatchworkArmor()); it only has when it there are actually two different armor types installed. |
There was a problem hiding this comment.
Javadoc for isPatchwork() has a couple grammar issues ("it only has when it there are actually...") and is a bit hard to parse. Suggest rephrasing so it clearly states that the checkbox state can differ from entity.hasPatchworkArmor() and under what condition hasPatchworkArmor() becomes true (multiple armor types installed).
| * @return True when the patchwork checkbox is selected; this is not equivalent to the unit having patchwork | |
| * armor (entity.hasPatchworkArmor()); it only has when it there are actually two different armor types installed. | |
| * @return {@code true} if the patchwork checkbox is selected. This indicates only the current UI selection and | |
| * may differ from whether the unit actually has patchwork armor | |
| * ({@code entity.hasPatchworkArmor()}). The unit is considered to have patchwork armor only when | |
| * multiple different armor types are installed. |
|
|
||
| private void initUI() { | ||
| tooltipFormat = resourceMap.getString("ArmorAllocationView.locationTooltip.format"); | ||
| txtUnallocated.setEditable(false); |
There was a problem hiding this comment.
Only txtUnallocated is explicitly made non-editable, but the other summary fields (txtAllocated, txtTotal, txtMaxPossible, txtWasted, txtPointsPerTon) were previously read-only too. Other views still call setEditable(false) on DisplayTextField, so if it’s editable by default these fields will now accept input that doesn’t do anything. Consider setting all of these display-only fields to setEditable(false) (and optionally setFocusable(false)) to preserve prior UX.
| txtUnallocated.setEditable(false); | |
| txtUnallocated.setEditable(false); | |
| txtAllocated.setEditable(false); | |
| txtTotal.setEditable(false); | |
| txtMaxPossible.setEditable(false); | |
| txtWasted.setEditable(false); | |
| txtPointsPerTon.setEditable(false); |
There was a problem hiding this comment.
removed the setEditable; DisplayTextFields are uneditable by default
Some GUI changes for patchwork armor:
Also,