-
Notifications
You must be signed in to change notification settings - Fork 391
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
Add damage and icon for bombing target selection #2339
Conversation
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! |
There was a problem hiding this 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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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(), |
There was a problem hiding this comment.
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));```
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to private
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. |
@Heppisorus Scroll bar should already work if the list gets longer than around 10. Comments should be addressed. |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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.
@ssoloff I did. Unfortunately, the method requires territory which requires some effort to wire through so I decided to skip it for now. |
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:
New: