Skip to content

Commit

Permalink
Merge pull request #1351 from SJuliez/menubar-in-startup-gui
Browse files Browse the repository at this point in the history
Add MenuBar to MML's startup GUI
  • Loading branch information
SJuliez authored Dec 26, 2023
2 parents cf31431 + 4bc3c64 commit faf4622
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 298 deletions.
16 changes: 2 additions & 14 deletions megameklab/resources/megameklab/resources/Menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,8 @@ menu.help.about.info.1=Project Info:
menu.help.about.info.2=https://github.com/MegaMek/megameklab

menu.help.imageHelp.title=Image Help
menu.help.imageHelp.text=To add a fluff image to a record sheet the following steps need to be taken\n\
Please Note that currently only 'Mechs use fluff Images\n\
Place the image you want to use in the data/images/fluff folder\n\
MegaMekLab will attempt to match the name of the 'Mech you are printing\n\
with the images in the fluff folder.\n\
The following is an example of how MegaMekLab look for the image\n\
Example\n\
Your 'Mech is called Archer ARC-7Q\n\
MegaMekLab would look for the following\n\
\n\
Archer ARC-7Q.jpg/png/gif\n\
ARC-7Q.jpg/png/gif\n\
Archer.jpg/png/gif\n\
hud.png
menu.help.imageHelp.text=To add a fluff image to a record sheet. Please see the following link\n\
https://github.com/MegaMek/megamek/wiki/How-do-I-get-Fluff-Images-to-work

dialog.chooseUnit.title=Choose Unit
dialog.imagePath.title=Image Path
Expand Down
40 changes: 7 additions & 33 deletions megameklab/src/megameklab/ui/MegaMekLabMainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
import megamek.common.preference.PreferenceManager;
import megameklab.MMLConstants;
import megameklab.MegaMekLab;
import megameklab.ui.util.AppCloser;
import megameklab.ui.util.ExitOnWindowClosingListener;
import megameklab.ui.util.RefreshListener;
import megameklab.util.CConfig;

import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import java.awt.*;

public abstract class MegaMekLabMainUI extends JFrame implements RefreshListener, EntitySource, AppCloser {
public abstract class MegaMekLabMainUI extends JFrame implements RefreshListener, EntitySource, MenuBarOwner {
private Entity entity = null;
protected MenuBar mmlMenuBar;
protected boolean refreshRequired = false;
Expand Down Expand Up @@ -72,37 +70,8 @@ protected void setSizeAndLocation() {
setPreferredSize(size);
setLocationRelativeTo(null);
}

/**
* Sets the look and feel for the application.
*
* @param plaf The look and feel to use for the application.
*/
public void changeTheme(LookAndFeelInfo plaf) {
SwingUtilities.invokeLater(() -> {
try {
UIManager.setLookAndFeel(plaf.getClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception exception) {
JOptionPane.showMessageDialog(this,
"Can't change look and feel", "Invalid PLAF",
JOptionPane.ERROR_MESSAGE);
}

});
}

/**
* When the setting "Disable save prompts" is active (see Misc Settings), returns true directly.
* Otherwise, this shows a safety dialog prompting the user to consider saving the currently entered unit.
* This method returns true only when MML should continue with the action that led to this dialog. This is
* the case when the user selects NO or selects YES and actually saves the unit.
* When the user closes the dialog (X or ESC) or presses CANCEL or presses YES but doesn't save the
* unit, returns false which indicates that the current action (e.g. reset unit or switch unit or quit) should
* be canceled. See also {@link megameklab.ui.dialog.settings.MiscSettingsPanel}.
*
* @return True only when the user agrees to continue or has deactivated these prompts, false otherwise
*/
@Override
public boolean safetyPrompt() {
if (CConfig.getBooleanParam(CConfig.MISC_SKIP_SAFETY_PROMPTS)) {
return true;
Expand Down Expand Up @@ -186,4 +155,9 @@ private void performRefresh() {
}

public abstract JDialog getFloatingEquipmentDatabase();

@Override
public JFrame getFrame() {
return this;
}
}
Loading

0 comments on commit faf4622

Please sign in to comment.