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 damage and icon for bombing target selection #2339

Merged

Conversation

ron-murhammer
Copy link
Member

Fixes #2333.

If someone wants to play around with trying to get the damage number to appear over the image, feel free to. This is at least a step in the right direction.

Old:
image

New:
image

@Heppisorus
Copy link
Contributor

Looks great! That's incredible progress for less than 24 hours. I mean having the damage represented over the actual unit image would be ideal, but this covers off the requirements of the issue and adds value with the unit imagery in the window. Well done!

Copy link
Member

@RoiEXLab RoiEXLab left a comment

Choose a reason for hiding this comment

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

Just one minor comment, otherwise LGTM.

@@ -924,6 +929,37 @@ public Unit getStrategicBombingRaidTarget(final Territory territory, final Colle
return selected.get();
}

@SuppressWarnings("serial")
Copy link
Member

Choose a reason for hiding this comment

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

You should have eclipse generate a serialVersionUID for you instead of supressing this warning

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@DanVanAtta DanVanAtta left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me as well. I agree with RoiEx's comment. I've a couple quick more, though they are relatively minor. Nice work!

final boolean isSelected, final boolean cellHasFocus) {

setText(unit.toString() + ", damage=" + TripleAUnit.get(unit).getUnitDamage());
final Optional<ImageIcon> icon = uiContext.getUnitImageFactory().getIcon(unit.getType(), unit.getOwner(),
Copy link
Member

Choose a reason for hiding this comment

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

very minor, you can write the optional + if statement in one statement:

           Matches.unitHasTakenSomeBombingUnitDamage().match(unit), Matches.unitIsDisabled().match(unit)).ifPresent(icon -> setIcon(icon));```

Copy link
Member Author

Choose a reason for hiding this comment

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

Gonna leave it on separate lines as I think its a little easier to read

}
setBorder(new EmptyBorder(0, 0, 0, 10));

if (isSelected) {
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 fully understand why we are setting foreground/background colors. Likely not terribly important, though a comment here may help to capture that context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comment

}

@Override
public Component getListCellRendererComponent(final JList<? extends Unit> list, final Unit unit, final int index,
Copy link
Member

Choose a reason for hiding this comment

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

A quick comment here might be good, summarize that we are building a dialog with the unit image next to name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comment to class

@@ -924,6 +929,37 @@ public Unit getStrategicBombingRaidTarget(final Territory territory, final Colle
return selected.get();
}

@SuppressWarnings("serial")
class UnitRenderer extends JLabel implements ListCellRenderer<Unit> {
Copy link
Member

Choose a reason for hiding this comment

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

This class is only used within TripleAFrame and can thus be private. That would also allow you to give the constructor default accessibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to private

@Heppisorus
Copy link
Contributor

As a final note Cernel did bring up a valuable point regarding the addition of a scroll bar in the event there are more targets than available space in the pop up window. Seems like a prudent addition given that if it happens it will show up here again as a bug.

@ron-murhammer
Copy link
Member Author

@Heppisorus Scroll bar should already work if the list gets longer than around 10.

Comments should be addressed.

@codecov-io
Copy link

Codecov Report

Merging #2339 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2339      +/-   ##
============================================
- Coverage     20.07%   20.05%   -0.03%     
- Complexity     5710     5711       +1     
============================================
  Files           807      807              
  Lines         73956    74041      +85     
  Branches      12478    12507      +29     
============================================
+ Hits          14845    14846       +1     
- Misses        57053    57137      +84     
  Partials       2058     2058
Impacted Files Coverage Δ Complexity Δ
...n/java/games/strategy/triplea/ui/TripleAFrame.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ames/strategy/engine/lobby/server/LobbyServer.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...trategy/engine/lobby/server/db/UserController.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...tegy/engine/lobby/server/db/BadWordController.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...ames/strategy/engine/lobby/server/db/Database.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...gy/engine/lobby/server/db/BannedMacController.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
src/main/java/games/strategy/net/nio/Decoder.java 68.62% <0%> (+0.98%) 25% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5795a09...616b441. Read the comment docs.

Copy link
Member

@ssoloff ssoloff 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, @ron-murhammer.

Not sure if you saw @Cernelius's comment on the forum about adding max damage to the end of the string (e.g. , damage=0/6). That would be useful, but I don't know if it's easy to do via TripleAUnit#getHowMuchDamageCanThisUnitTakeTotal(). Don't worry about it if you think it's out of scope.

@ron-murhammer
Copy link
Member Author

@ssoloff I did. Unfortunately, the method requires territory which requires some effort to wire through so I decided to skip it for now.

@ron-murhammer ron-murhammer merged commit b0df46b into master Sep 9, 2017
@RoiEXLab RoiEXLab deleted the Add_Damage_And_Icon_For_Bombing_Target_Selection branch September 9, 2017 05:34
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.

6 participants