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

Lobby/GUI work #2409

Merged
merged 58 commits into from
Apr 29, 2021
Merged

Lobby/GUI work #2409

merged 58 commits into from
Apr 29, 2021

Conversation

SJuliez
Copy link
Member

@SJuliez SJuliez commented Nov 18, 2020

OK I'm finishing this now (tentatively) to at least start the process of integrating it.

I have no clue why the Messages call in the Boardvalidator fails.

Main Changes (omitting small bug fixes in the tooltip and elsewhere):

  • Unifies the tooltip in the lobby and game (while still enabling different views, e.g. the pilot info can be omitted as is done in the lobby mek table) and moves the code out of Entity; the tooltip now shows a different symbol for capital armor. I've introduced many unicode symbols, these require the Java "Dialog" logic font, I hope they work on other systems besides Win10 as well.
  • Adds a general gui scaling float value (neutral value = 1) that is accessible in the Client Settings and, unless a modal dialog is up, with Ctrl+Numpad+ and Ctrl+Numpad- . This currently scales mainly the lobby and some dialogs in the lobby that have been revamped. The scaling can be applied by calling UIUtil.adjustDialog on any dialog, but the result depends on how complicated the dialog is and its probably better to adjust manually. I've done this with the host game dialog and the result is I guess ok.
  • Completely revamps the info in the lobby mektable, obviously. I've tried using colors that are desaturated in the hope this will make the colors readable for everyone. Also, the main colors come from methods that return different colors based on whether the current UI theme is light or dark.
  • Allows sorting the mek table by various algorithms
  • Generally shows more info directly in the table such as velocity, height, deployment, partial repairs, C3 info. I've tried to hide stuff thats unnecessary such as height in space and so on to make it all kinda useful
  • The lobby now shows if a unit has a problem such as instant death upon deployment or an unconnected C3 computer; the tooltip gives details on the problem (unit cannot survive in vacuum)
  • Makes the compact mode more useful; it now shows alomst the same info as the full mode.
  • Revamps the popup menu; it now allows some more unit settings such as C3 configuration and most operations work on multiple units
  • Adds toggles to hide unofficial and legacy game options; also adds a ToggleButton that has a checkmark or cross as the normal Java togglebuttons dont show their status really well
  • Adds searchlights automatically to all units in circumstances when they're needed
  • Revamps the player config and planetary settings dialog
  • Revamps the player table; it now allows multi-selection and direct setting of team and deployment via popup, also shows local bots with a symbol
  • Makes some dialogs rememeber their size and position such as the Unit selector and force generator
  • Adds Ctrl-S quicksave and Ctrl-L quickload. I think this is only useful for development. Ctrl-L works only from the main menu I think.
  • The mektable generally remembers column sizes
  • removes some buttons from the main interface (such as Delete All) and adds a confirm dialog to delete and various other things that shouldnt be insta-kill
  • Minefields now actually require the TacOps minefields game option to be active
  • Corrects conventional fighter weight classes, use the same as ASF (50t = medium)
  • Corrects legal deployment with double blind
  • Obviously revamps board selection to graphical dragndrop. It can deal with server-side boards (although in this case it can't actually display the real board, just an empty placeholder) and invalid boards.
  • Instead of choosing a board at random, the surprise function will now choose a board from a list of boards that can be assigned by selecting the desired boards and dragging them to the preview.
  • Board setups can now be saved. I've created some examples from the boards we have
  • Adds a smaller minimap zoom that I neede for those huge maps and a better space minimap with stars...
  • Adds a team overview pane. The table can be detached to a window. It shows the summarized strength of the teams and when one team is selected in the table it shows the relative values (87% of ...)
  • Adds ammo to the unit tooltips
  • Adds forces to MM and a force tree view to the lobby. Forces currently have no ingame effect. The game has a Forces object that controls the individual Force objects. The structure is similar to MekHQ's forces although I believe MekHQ has no owner field. Forces can be saved to MUL files and load from there correctly. However it only saves the full force every unit is in, not the forces themselves. When loading a MUL, the force structure is reconstructed from these individual force entries. Therefore, loading from a MUL will always create new forces, never integrate into existing ones. The forces from MekHQ can be transported to MM by using the String representation as Ive done in the MekHQ PR. The MekHQ PR is not required for this PR; it can be pulled later when MM actually works.
  • Units in forces and subforces can be moved up and down by Ctrl-Up and Ctrol-Down; no multi-selection.
  • The mek table and force table allow Ctrl-C to copy selected units (forces are ignored). It exports the unit, tonnage, pilot and a few values and pastes mostly well into Excel, although some units have secondary names that dont paste well such as "(3025)" which arrives as -3025 in Excel. Ive found no solution for this that also allows pasting into MM well.
  • Obviously, the mektable and force table also allow Ctrl-V. So it's easy to copy-paste units in MM.
  • Also, makes the keybinds overlay disappear in the map preview

Resolves #2384
Resolves #2385
Resolves #2340
Resolves #2327
Resolves #2322
Resolves #2306
Resolves #2277
Resolves #2428
Resolves #1996
Resolves #448
Resolves #2560
Resolves #765
Resolves #2657
Resolves #2374

I believe this also resolves #322. It does not enable a GM player to see all units during blind drop, but the team overview allows a cost/tonnage/BV comparison through all blind drop options.

image

Conflicts:
	megamek/src/megamek/client/ui/swing/ChatLounge.java
	megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
	megamek/src/megamek/client/ui/swing/GUIPreferences.java
	megamek/src/megamek/client/ui/swing/boardview/EntitySprite.java
@HammerGS
Copy link
Member

This looks great. One first impression from the screen shot, I think the unit ID would better after the unit name.

@SJuliez
Copy link
Member Author

SJuliez commented Nov 18, 2020

Thanks. Note that on the left side theres a toggle button for the unit ID, so it's easily turned off and on (took this from the CasualJoker vids) and the unit name can be very (very) long. I can try this though.

@HammerGS
Copy link
Member

Curious would this one fit into the last of UI stuff - #2183

@sixlettervariables
Copy link
Contributor

CI is failing because the source compatibility level is 8 and you have some >8 Java-isms.

@lgtm-com
Copy link

lgtm-com bot commented Nov 25, 2020

This pull request fixes 3 alerts when merging 396f96d into 7eb2d7e - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null

@HammerGS
Copy link
Member

Wanted to have a look. But looks like it has conflicts.

Auto-merging megamek/src/megamek/server/Server.java
Auto-merging megamek/src/megamek/common/Game.java
Auto-merging megamek/src/megamek/common/Entity.java
Auto-merging megamek/src/megamek/client/ui/swing/gameConnectionDialogs/HostDialog.java
Auto-merging megamek/src/megamek/client/ui/swing/gameConnectionDialogs/ConnectDialog.java
Auto-merging megamek/src/megamek/client/ui/swing/dialog/MegaMekUnitSelectorDialog.java
Auto-merging megamek/src/megamek/client/ui/swing/dialog/AbstractUnitSelectorDialog.java
Auto-merging megamek/src/megamek/client/ui/swing/boardview/BoardView1.java
Auto-merging megamek/src/megamek/client/ui/swing/MegaMekGUI.java
Removing megamek/src/megamek/client/ui/swing/MechGroupView.java
Auto-merging megamek/src/megamek/client/ui/swing/GUIPreferences.java
Auto-merging megamek/src/megamek/client/ui/swing/FiringDisplay.java
Auto-merging megamek/src/megamek/client/ui/swing/EquipChoicePanel.java
Auto-merging megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Auto-merging megamek/src/megamek/client/ui/swing/ClientGUI.java
CONFLICT (modify/delete): megamek/src/megamek/client/ui/swing/ChatLounge.java deleted in 4f5175175a282f66f2e6f36300bcf038899dfd36 and modified in HEAD. Version HEAD of megamek/src/megamek/client/ui/swing/ChatLounge.java left in tree.
Auto-merging megamek/src/megamek/client/bot/princess/Princess.java
Auto-merging megamek/i18n/megamek/client/messages.properties
Automatic merge failed; fix conflicts and then commit the result.

Conflicts:
	megamek/i18n/megamek/client/messages.properties
	megamek/src/megamek/client/ui/swing/ChatLounge.java
@SJuliez
Copy link
Member Author

SJuliez commented Dec 15, 2020

Hopefully better now. Not many changes, I struggled with the mektable popup and most of the changes there are not so visible. It'll only show certain load options when a unit type is present, like fighter squadrons. Squadrons require Capital Fighters (which Im not sure is really what the rules meant to say...). Something visible is the player config dialog. To get the most out of it, activate minefields (this option now really toggles minefields in the lobby) and double blind with exlcusive deployment and open it for a bot client.
Edit 1: Fails because of a Test class again... will have to deal with that at some point
Edit 2: Nvm the <> button and the "Carried Carrying" text on the units, thats just for debugging.

@HammerGS
Copy link
Member

Thanks, really looking forward to see this done. More I use it the harder it is to go back to the old lobby.

@lgtm-com
Copy link

lgtm-com bot commented Dec 15, 2020

This pull request introduces 4 alerts and fixes 6 when merging 6ea2194 into 30ee309 - view on LGTM.com

new alerts:

  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Contradictory type checks
  • 1 for Dereferenced variable may be null

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Dec 20, 2020

This pull request introduces 5 alerts and fixes 6 when merging d0c0d6d into 69d787c - view on LGTM.com

new alerts:

  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Useless comparison test
  • 1 for Contradictory type checks
  • 1 for Dereferenced variable may be null

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@HammerGS
Copy link
Member

Loving the improvement but think I got a bug. Running from repo, add a unit to the lobby. Right click and select view. Nothing happens. Log has the following error.

Action! javax.swing.JButton[,6,22,380x33,alignmentX=0.0,alignmentY=0.5,border=com.formdev.flatlaf.ui.FlatButtonBorder@1539f6af,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Add A Combat Unit...,defaultCapable=true]
Action! javax.swing.JButton[,183,5,137x29,alignmentX=0.0,alignmentY=0.5,border=com.formdev.flatlaf.ui.FlatButtonBorder@1539f6af,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Game Options...,defaultCapable=true]
[Fatal Error] log4j.xml:2:10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.

@lgtm-com
Copy link

lgtm-com bot commented Apr 7, 2021

This pull request introduces 2 alerts and fixes 6 when merging 5b67655 into 525c8c2 - view on LGTM.com

new alerts:

  • 2 for Spurious Javadoc @param tags

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Apr 7, 2021

This pull request fixes 6 alerts when merging b699070 into 525c8c2 - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Apr 9, 2021

This pull request fixes 6 alerts when merging 436282b into 6d9b82a - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@lgtm-com
Copy link

lgtm-com bot commented Apr 11, 2021

This pull request fixes 6 alerts when merging 10d62a9 into 6d9b82a - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@SJuliez SJuliez marked this pull request as ready for review April 11, 2021 14:41
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.

Got through about half the files. Didn't review the data files, since I wouldn't know what's correct and what isn't anyway. Will take a look at the rest of the files over the next few days.

megamek/src/megamek/client/Client.java Outdated Show resolved Hide resolved
megamek/src/megamek/client/ui/swing/CommonMenuBar.java Outdated Show resolved Hide resolved
megamek/src/megamek/client/ui/swing/RandomArmyDialog.java Outdated Show resolved Hide resolved
megamek/src/megamek/client/ui/swing/RandomArmyDialog.java Outdated Show resolved Hide resolved
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.

Round 2. 98/132 files reviewed.

megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java Outdated Show resolved Hide resolved
megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java Outdated Show resolved Hide resolved
megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/Terrains.java Show resolved Hide resolved
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.

All right, finished. Some questions and relatively minor change requests.

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

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

Went through about 2/3 of this PR (including all of the data), and made comments on it.

megamek/src/megamek/common/EntityListFile.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/EntityListFile.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/OffBoardDirection.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/Player.java Show resolved Hide resolved
for (Force force: forces) {
game.getForces().replace(force.getId(), force);
}
for (Entity entity: entities) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (Entity entity: entities) {
for (Entity entity : entities) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Not my style.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a style bit, but code accessibility. You separate out the ":" to ensure that the symbol isn't read as part of the word and then ignored, as it makes it into a separate word.

Comment on lines +1070 to +1071
Collection<Entity> entities = (Collection<Entity>) c.getObject(0);
for (Entity entity: entities) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Collection<Entity> entities = (Collection<Entity>) c.getObject(0);
for (Entity entity: entities) {
Collection<Entity> entities = (Collection<Entity>) c.getObject(0);
for (Entity entity : entities) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Could also probably just have the cast in the for loop call


for (Force force: forces) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (Force force: forces) {
for (Force force : forces) {

//create a final image for the entity
for(int id: entityIds) {
cacheImgTag(game.getEntity(id));
}
for (Force force: forces) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (Force force: forces) {
for (Force force : forces) {

megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Apr 22, 2021

This pull request fixes 6 alerts when merging 3442850 into 23ccda2 - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@SJuliez
Copy link
Member Author

SJuliez commented Apr 23, 2021

@NickAragua and @Windchild292 Went through the reviews. What I didnt comment I put in the code as suggested by the review. Nick's review changes are in two commits, Review Changes pt.1 and Nickaragua review changes; Windchild's review changes are in the latest commit.

@lgtm-com
Copy link

lgtm-com bot commented Apr 23, 2021

This pull request fixes 6 alerts when merging 609f3b8 into 23ccda2 - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

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 good from my end.

@SJuliez
Copy link
Member Author

SJuliez commented Apr 25, 2021

@Windchild292 Putting this here so we don't have to search for comments.
Accessibility means what? Someone using a screen reader to program stuff? I really don't know. If yes, has there ever been someone? Even if the : gets swallowed why would that be a problem?

And you commented on this again:
The images in this directory are temporary images used for the pilot tooltips. They can be safely deleted while not in a MegaMek game.
But this is changed in your commit. I don't see what's missing.

Any other new comments?

@Windchild292
Copy link
Contributor

Interesting... the file did not update on my end, so ignore that comment. As for the other bit, I'll explain in a PM.

Conflicts:
	megamek/src/megamek/client/ui/swing/BotConfigDialog.java
	megamek/src/megamek/client/ui/swing/ChatLounge.java
@lgtm-com
Copy link

lgtm-com bot commented Apr 29, 2021

This pull request fixes 6 alerts when merging 94e0982 into c06db39 - view on LGTM.com

fixed alerts:

  • 3 for Boxed variable is never null
  • 2 for Implicit narrowing conversion in compound assignment
  • 1 for Dereferenced variable may be null

@Windchild292 Windchild292 merged commit f38c719 into MegaMek:master Apr 29, 2021
@SJuliez SJuliez deleted the GUI branch May 26, 2021 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment