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

MML Splash Screen #358

Merged
merged 14 commits into from
Oct 24, 2019
Merged

Conversation

AaronGullickson
Copy link
Member

@AaronGullickson AaronGullickson commented Oct 22, 2019

As the title says, this PR adds an initial splash screen to MegaMekLab.

Screen Shot 2019-10-22 at 3 35 06 PM

The splash screen has the same basic look and feel as the MegaMek splash screen including the use of thematic buttons and fonts and resizing based on the user's screen resolution. In order to do this I had to add the the theme and font data to the MML data section. The buttons give the player the option of loading an existing unit (from the cache) or of starting a new unit design of a specific type.

I also added a loading screen in between the pushing of the button and the full UI because I noticed there was a couple of seconds delay on my machine.

Screen Shot 2019-10-22 at 3 37 42 PM

Since I was using the loading screen here, I also changed all of the menu options in MenuBarCreator.java that load a unit of a different type to call up the loading dialog so the user will see a consistent loading screen regardless of how they load the unit.

I also made a few adjustments to how the mainUI screen is displayed. It was displaying in the upper left corner and was typically too small, forcing scroll bars which was ugly and not user friendly IMO. So I created a finishSetup() routine in MegaMekLabMainGUI.java that does all of the work of centering on the screen and making sure that the main frame is large enough to fit everything without scrollbars when possible.

Most of the work is done in StartupGUI.java and LoadingDialog.java.

I am still having one issue that I am not sure is really an issue. When the user clicks the "Load a Unit" button, it will pull up the cache loading dialog the first time and then once units are loaded this will disappear and nothing else happens. If the user hits the button a second time, it works. This is not an issue when it is done through the menu bar rather than the splash screen, despite the code being identical. However, I don't get this behavior if I launch things with the debugger, so I am not convinced it is really an issue or just something with the cache being refreshed. I will make a note in the code where this is occurring. Fixed in commit 40f38ac.

@AaronGullickson
Copy link
Member Author

I should also note that the large number of files modified/added here is because of all the theme data being pulled in.

"Memory Allocated [" +
(runtime.maxMemory() / 1000) + "]");
// Need at least 200m to run MegaMekLab
if (runtime.maxMemory() < 200000000) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is very old code that was used to brute force past a memory leak issue. I doubt it is still an issue and if so this does not seem like a very good way to handle it.


public MainUI(boolean primitive) {

super();
createNewUnit(Entity.ETYPE_AERO, primitive);
setTitle(getEntity().getChassis() + " " + getEntity().getModel() + ".blk");
menubarcreator = new MenuBarCreator(this);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the stuff deleted from this point on in all of the MainUI methods is now being done in MegaMekLabMainGUI.finishSetup()

}

private void loadUnit() {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(frame);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the place where the first time the button is pushed it shows the UnitLoadingDialog and then disappears with nothing else happening.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh, check the log stupid. Here is where the problem seems to be:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at megamek.client.ui.swing.AdvancedSearchDialog$WeaponsTableModel.getColumnClass(AdvancedSearchDialog.java:1118)
	at javax.swing.table.TableRowSorter.useToString(TableRowSorter.java:241)
	at javax.swing.DefaultRowSorter.updateUseToString(DefaultRowSorter.java:624)
	at javax.swing.DefaultRowSorter.sort(DefaultRowSorter.java:573)
	at javax.swing.DefaultRowSorter.allRowsChanged(DefaultRowSorter.java:852)
	at javax.swing.JTable.notifySorter(JTable.java:4264)
	at javax.swing.JTable.sortedTableChanged(JTable.java:4124)
	at javax.swing.JTable.tableChanged(JTable.java:4401)
	at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:296)
	at javax.swing.table.AbstractTableModel.fireTableDataChanged(AbstractTableModel.java:198)
	at megamek.client.ui.swing.AdvancedSearchDialog$WeaponsTableModel.setData(AdvancedSearchDialog.java:1138)
	at megamek.client.ui.swing.AdvancedSearchDialog.populateWeaponsAndEquipmentChoices(AdvancedSearchDialog.java:1010)
	at megamek.client.ui.swing.AdvancedSearchDialog.<init>(AdvancedSearchDialog.java:378)
	at megamek.client.ui.swing.UnitSelectorDialog.<init>(UnitSelectorDialog.java:197)
	at megameklab.com.ui.StartupGUI.loadUnit(StartupGUI.java:379)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to initialized EquipmentTypes. Fixed in commit 40f38ac.

setVisible(true);
repaint();
refreshAll();
finishSetup();
MechSummaryCache.getInstance();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neoancient Some of the MainUI() methods had this line at the end, even though this is actually called at the very top of the constructor for MegaMekLabMainUI from which all of these inherit. Is it redundant or is something else going on here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason for it. I must not have paid close attention to the code I was copying.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually having had time to thing about it I think the idea is to start the cache loading thread to cut or eliminate the wait the first time a unit is loaded from the cache. It would be better placed somewhere in the application startup process if it isn't already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is already done in the super() constructor.

@NickAragua
Copy link
Member

I gotta ask, what's the deal with the 755 files? Don't we usually handle that stuff by pulling it from the megamek repo at build-time?

@AaronGullickson
Copy link
Member Author

I am not sure how it works at build time, but if you want MML to run properly in eclipse then all those data files have to be there I think.

@neoancient
Copy link
Member

I don't have time to look at this tonight, but I think there should be some way to provide a reasonable default behavior if those files are missing.

@AaronGullickson
Copy link
Member Author

The easiest thing to do would be to just put the default skin data in MML as there is currently no way to change it from within MML anyway. Let me know what you want me to do.

@AaronGullickson
Copy link
Member Author

@neoancient @NickAragua I did some experimentation and I was able to remove most of the excess files for the skin themes, just leaving the defaults that are needed for the splash screen. That cut the number of file changes down to 33.

This should allow the stand-alone MML build to work correctly. In the full MHQ build the user will have access to the full theme data and a change made in MM will then show up here as well through the mmconf.

Copy link
Member

@NickAragua NickAragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, although I'd prefer neo get a look at it as well.

@AaronGullickson
Copy link
Member Author

Ok, waiting for @neoancient feedback.

Copy link
Member

@neoancient neoancient left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the packaging script already copies all the contents of data and mmconf, so there shouldn't be any need to modify it to include the new files.

JOptionPane.showMessageDialog(frame,
resourceMap.getString("message.abortUnitLoad.text"));
}
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in latest

setVisible(true);
repaint();
refreshAll();
finishSetup();
MechSummaryCache.getInstance();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason for it. I must not have paid close attention to the code I was copying.

btnNewPbi.text=New Infantry Unit
btnNewAero.text=New Aero Fighter
btnNewDropper.text=New Dropship/Small Craft
btnNewLargeCraft.text=New Large Craft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A large craft is any aerospace unit >= 200 tons, which includes dropships. In the construction rules the units in this category are called "advanced aerospace," which is the term I used in the code. I think "capital ship" is a more natural-sounding name for them, but I don't remember that name being used in a BT context. I try not to be too uptight about things where the meaning is obvious, but many of our users are more tied to pedantry than that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think capital ship is more natural than "advanced aerospace" units although its weird to all a space station a capitol ship.

Copy link
Member

@HammerGS HammerGS Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might seem like an odd idea, but a button for Space Stations that jumps to the same starting point, but changes the drop down to pre-select space station. Or even button for JS,WS,SS that does that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that we are pretty maxed out on buttons already and any space we have I would rather reserve for other future things that @neoancient will code for us 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there's a really good solution for it. I raise it because being nitpicky can be asset when doing this sort of thing as long as you're not being a jerk about it (and I try not to be). If it goes out like this and people's feathers get ruffled it's no big deal to change it later. As far as what may get added in the future, I think we're down to mobile structures and handheld weapons, and HHWs may actually work better as part of mech construction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to "Capital-Scale Craft" which I think is accurate since these are all units that use capital scale armor.

Image imgSplash;
BufferedImage backgroundIcon;

private MegamekButton btnLoadUnit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button fields aren't ever used outside initComponents() and can be converted to local variables.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest

src/megameklab/com/ui/MegaMekLabMainUI.java Show resolved Hide resolved
public MegaMekLabMainUI() {

EquipmentType.initializeTypes();
MechSummaryCache.getInstance();
new CConfig();
UnitUtil.loadFonts();
System.out.println("Starting MegaMekLab version: " + MegaMekLab.VERSION);

System.out.println("Starting MegaMekLab version: " + MegaMekLab.VERSION);
setLookAndFeel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't get called until after the main splash screen, which means that when you click the button to load the unit, the unit selector dialog can have a different look and feel than the the rest of the ui. I don't think it really belongs here in the first place, since it doesn't need to run every time the unit type changes, but now it needs to move to somewhere before the startup splash screen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably in the startup method of MegaMekLab.java. The System.out.println should also be there I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved setLookandFeel() and 'system.out.println` to MegaMekLab.startup()

@AaronGullickson AaronGullickson merged commit 745254b into MegaMek:master Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants