Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opening multiple units in tabs #1673

Merged
merged 15 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
/megameklab/docs/mml-revision.txt
/megameklab/MegaMekLab.l4j.ini
units.cache
.mml_tmp
71 changes: 48 additions & 23 deletions megameklab/docs/UserDirHelp.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<HTML><H2>How to Use the User Data Directory</H2>

<P>Use this directory for resources you want to share between different installs or versions of MegaMek, MegaMekLab and MekHQ. Fonts, units, camos, portraits and unit fluff images will also be loaded from this directory (in addition to what is loaded from MegaMek's own data). The directory should be an absolute path such as D:/MyBTStuff (in other words, not relative to your MegaMek directory).</P>
<P>Use this directory for resources you want to share between different installs or versions of MegaMek, MegaMekLab and MekHQ. The files listed below will also be loaded from this directory (in addition to what is loaded from MegaMek's own data). The directory should be an absolute path such as D:/MyBTStuff (in other words, not relative to your MegaMek directory).</P>

<P>How to place files within the user data directory:
<P>Generally, all content from the user directory is added to the pre-defined content. In some cases, added content may replace pre-defined content when it has the same name or file path.</P>

<P>How to place files within the user data directory:</P>
<UL>
<LI><B>Fonts</B> can be placed anywhere in the user data directory (i.e., in the directory itself or in any subfolder)

Expand All @@ -13,27 +15,50 @@
<LI><B>Portrait</B> images must be placed in &lt;user data directory&gt;/data/images/portraits/. In this subfolder, further subfolders can be used (optional).

<LI><B>Unit fluff</B> images must be placed in &lt;user data directory&gt;/data/images/fluff/&lt;unit type&gt;/. To find the exact subfolders to use, go to your megamek folder and open /data/images/fluff/.

<LI><B>Skin</B> definition files (.xml) can be placed anywhere in the user data directory

<LI><B>Rank Systems</B> may be defined in &lt;user data directory&gt;/data/universe/ranks.xml

<LI><B>Award</B> definition files (.xml) can be placed in &lt;user data directory&gt;/data/universe/awards
</UL>

<P>
Additionally, the user directory is used to restore your most recent session in MegaMekLab.
If you set the startup mode of MML to "Restore Tabs", a hidden folder called ".mml_tmp" will be created in your user directory.
You should not touch this folder. Changing the contents of this folder may cause MML to fail to start.
If you have "Restore Tabs" set and MML is failing to start, try deleting the ".mml_tmp" folder, in case it was corrupted somehow.
</P>

<P>This is an example of a suitable directory structure with a few example files:
<BR><BR>
D:/myBTStuff<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Oxanium.ttf<BR>
&nbsp;&nbsp;&nbsp;&nbsp;Exo.ttf<BR>
&nbsp;&nbsp;&nbsp;&nbsp;/campaign_units<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Atlas AS8-XT.mtf<BR>
&nbsp;&nbsp;&nbsp;&nbsp;/data<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Jura.ttf<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/images<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/camo<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myForceCamo.png<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/oldcamo<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Here be dragons!<BR>
</P>
</HTML>
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ConfigurationDialog.chkSummaryFormatTRO.tooltip=When checked, text exports are f
ConfigurationDialog.chkSkipSavePrompts.text=Disable save prompts. Use at your own risk!
ConfigurationDialog.chkSkipSavePrompts.tooltip=When checked, no safety dialogs warning about losing changes when switching unit or unit type will be shown.
ConfigurationDialog.startup.text=MML Startup:
ConfigurationDialog.startup.tooltip=Depending on the startup type selected, MML will start in the main menu or, alternatively, directly load the most recent unit or start with a new unit instead of the main menu.
ConfigurationDialog.startup.tooltip=<html>Depending on the startup type selected, MML will start in the main menu or, alternatively, directly load the most recent unit or start with a new unit instead of the main menu, or restore all of your opened tabs.<br>Restoring tabs restores the state of the entities as they were in the editor, not as you saved them!</html>
ConfigurationDialog.mekChassis.text=Mek Chassis Arrangement:
ConfigurationDialog.mekChassis.tooltip=Meks with a Clan and an IS chassis name will print their chassis in the selected arrangement. Meks with no clan chassis name will always just print their chassis.
ConfigurationDialog.cbMulOpenBehaviour.text=MUL file open behaviour:
Expand Down
4 changes: 4 additions & 0 deletions megameklab/resources/megameklab/resources/Menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ MenuBar.accessibleName=Main Menu Bar
### File Menu
fileMenu.text=File
miResetCurrentUnit.text=Reset Current Unit
miNewTab.text=New Tab
miCloseTab.text=Close Tab
miReopenTab.text=Reopen Closed Tab
## Switch Unit Type Menu
switchUnitTypeMenu.text=Switch Unit Type
miSwitchToMek.text=Mek
Expand Down Expand Up @@ -107,6 +110,7 @@ message.exportingInvalidUnit.text=Warning: Exporting an invalid unit!
# The following values are used programatically by MMLStartUp
MMLStartUp.SPLASH_SCREEN=MML Main UI
MMLStartUp.RECENT_UNIT=Last Unit
MMLStartUp.RESTORE_TABS=Restore Tabs
MMLStartUp.NEW_MEK=New Mek
MMLStartUp.NEW_TANK=New Combat Vehicle
MMLStartUp.NEW_BATTLEARMOR=New BattleArmor
Expand Down
1 change: 1 addition & 0 deletions megameklab/src/megameklab/MegaMekLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ private static void startup(String[] args) {
new StartupGUI().setVisible(true);
}
}
case RESTORE_TABS -> UiLoader.restoreTabbedUi();
default -> {
new StartupGUI().setVisible(true);
}
Expand Down
3 changes: 2 additions & 1 deletion megameklab/src/megameklab/ui/MMLStartUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum MMLStartUp {

SPLASH_SCREEN,
RECENT_UNIT,
RESTORE_TABS,
NEW_MEK,
NEW_TANK,
NEW_BATTLEARMOR,
Expand Down Expand Up @@ -62,4 +63,4 @@ public static MMLStartUp parse(String startUpName) {
return SPLASH_SCREEN;
}
}
}
}
13 changes: 11 additions & 2 deletions megameklab/src/megameklab/ui/MegaMekLabMainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class MegaMekLabMainUI extends JFrame implements RefreshListener
protected MenuBar mmlMenuBar;
protected boolean refreshRequired = false;
private String originalName = "";
private MegaMekLabTabbedUI owner = null;

public MegaMekLabMainUI() {
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Expand All @@ -52,13 +53,13 @@ protected void finishSetup() {

protected void setSizeAndLocation() {
pack();
restrictToScrenSize();
restrictToScreenSize();
setLocationRelativeTo(null);
CConfig.getMainUiWindowSize(this).ifPresent(this::setSize);
CConfig.getMainUiWindowPosition(this).ifPresent(this::setLocation);
}

private void restrictToScrenSize() {
private void restrictToScreenSize() {
DisplayMode currentMonitor = getGraphicsConfiguration().getDevice().getDisplayMode();
int scaledMonitorW = UIUtil.getScaledScreenWidth(currentMonitor);
int scaledMonitorH = UIUtil.getScaledScreenHeight(currentMonitor);
Expand Down Expand Up @@ -128,6 +129,10 @@ public boolean exit() {
public void refreshHeader() {
String fileInfo = fileName.isBlank() ? "" : " (" + fileName + ")";
setTitle(getEntity().getFullChassis() + " " + getEntity().getModel() + fileInfo);
if (owner != null) {
getEntity().generateDisplayName();
owner.setTabName(getEntity().getDisplayName());
}
}

@Override
Expand Down Expand Up @@ -203,4 +208,8 @@ public boolean hasEntityNameChanged() {
public MenuBar getMMLMenuBar() {
return mmlMenuBar;
}

public void setOwner(MegaMekLabTabbedUI owner) {
this.owner = owner;
}
}
Loading
Loading