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

Add MenuBar to MML's startup GUI #1351

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
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 @@ -184,4 +153,9 @@ private void performRefresh() {
refreshAll();
}
}

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