Skip to content

Commit

Permalink
Fix load from file to not destroy all tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbraginskiy committed Jan 1, 2025
1 parent 8d8ecf5 commit fdf0bcd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions megameklab/src/megameklab/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,10 @@ public void loadFile(File unitFile) {
warnOnInvalid(loadedUnit);

newRecentUnit(unitFile.toString());
if (isStartupGui() || (loadedUnit.getEntityType() != owner.getEntity().getEntityType())) {
if (owner instanceof MegaMekLabTabbedUI tabbedUi) {
tabbedUi.addUnit(loadedUnit, unitFile.toString());
refresh();
} else if (isStartupGui() || (loadedUnit.getEntityType() != owner.getEntity().getEntityType())) {
owner.getFrame().setVisible(false);
owner.getFrame().dispose();
UiLoader.loadUi(loadedUnit, unitFile.toString());
Expand All @@ -1231,9 +1234,6 @@ public void loadFile(File unitFile) {
UnitUtil.updateLoadedUnit(getUnitMainUi().getEntity());
reload();
refresh();
} else if (owner instanceof MegaMekLabTabbedUI tabbedUi) {
tabbedUi.addUnit(loadedUnit, unitFile.toString());
refresh();
}
} catch (Exception ex) {
PopupMessages.showFileReadError(owner.getFrame(), unitFile.toString(), ex.getMessage());
Expand Down

0 comments on commit fdf0bcd

Please sign in to comment.