-
Notifications
You must be signed in to change notification settings - Fork 396
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
Show a unit tooltip when mouse-overing units on main map after 1s. #3477
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3477 +/- ##
============================================
- Coverage 21.97% 21.97% -0.01%
+ Complexity 5919 5918 -1
============================================
Files 836 837 +1
Lines 71983 72016 +33
Branches 11590 11593 +3
============================================
+ Hits 15820 15822 +2
- Misses 54075 54103 +28
- Partials 2088 2091 +3
Continue to review full report at Codecov.
|
This seems something users may want to be able to customize (Engine Preferences). I think games often give the ability to set the delay tooltip. |
1 second sounds good for me. |
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.
Code looks mostly good, just a couple of nitpicks from my side.
As I already said in the other PR, we always appreciate Screenshots when there are any UI changes for future reference.
final MouseOverUnitListener mouseOverUnitListener = (units, territory, me) -> { | ||
unitsBeingMousedOver = units; | ||
tooltipManager.updateTooltip(getUnitInfo()); | ||
}; | ||
mapPanel.addMouseOverUnitListener(mouseOverUnitListener); |
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.
Would you mind inlining this Lambda expression with the next line?
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.
+ ua.toStringShortAndOnlyImportantDifferences(unit.getOwner(), true, false); | ||
} | ||
} | ||
String unitInfo = getUnitInfo(); |
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.
Now that this calls a method, could you declare this variable final?
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.
if (unitsBeingMousedOver.size() != 1) { | ||
unitText = unitsBeingMousedOver.size() + " Units"; | ||
} | ||
unitInfo = "<b>" + unitText + "</b><br>" + unit.getType().getName() + ": " |
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 know it's copy-pasted, but I'd rather return this directly and return an empty string otherwhise.
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.
String unitText = "Unit:"; | ||
if (unitsBeingMousedOver.size() != 1) { | ||
unitText = unitsBeingMousedOver.size() + " Units"; | ||
} |
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.
The unitText assignment could be done with a ternary operator, so this variable could be declared final
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, though I find that a bit harder to read.
// Note: Timer not started yet. | ||
} | ||
|
||
/** Updates the tooltip. */ |
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.
Maybe it's just me, but I'd appreciate if this javadoc could be expanded to the "normal" 3 lines
private Popup popup; | ||
|
||
public MapUnitTooltipManager(MapPanel mapPanel) { | ||
this.mapPanel = mapPanel; |
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.
We probably want to accept a Component/JComponent as argument rather than a specific MapPanel type.
This would make it clear that we only need a "parent component" object.
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.
private String text; | ||
private Popup popup; | ||
|
||
public MapUnitTooltipManager(MapPanel mapPanel) { |
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.
We have a (perhaps outdated 😉) Style guildeline that makes all variables final which are effectively final.
This includes method and constructor parameters.
The same thing applies to all other methods you created, not going to comment them all individually
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.
I think it would be really good if there would be a menu option to turn this off. This is nice when you are noob with a game, but a lot of users just play the exact same map again and again, and will never want to see this. |
How about letting people try it and see how it feels before prematurely building the option to turn it off? Adding more options increases complexity and it seems better to see if people actually find it annoying after trying it rather than speculatively adding an option that will stay there forever. |
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.
@Cernelius has a valid point there.
Implementing a simple setting to toggle thid shouldn't be too difficult though.
I'll send you instructions on how to do it later this day, we have a "framework" for this.
(No objections on leaving this on by default though to have people try it out) |
Sure, I'll happily add a setting for it if that's the feedback after people try it out. My point is let's see how the current behaviour feels first. And the setting can be added in a follow-up PR. |
seems like initially the setting would be good. If after implementation it becomes obstructive to game play I am sure you can extend the delay. |
@asvitkine You probably want to have a look at ClientSetting.java, ClientSettingSwingUiBinding.java (and ClientSettingJavaFxUiBinding.java if you want to add the setting to the alpha UI I'm casually working on, you need to set a checkbox in the settings in the testing section to be able to see it). |
@asvitkine @RoiEXLab I'm alright with moving forward with the change as is for now. We can get it into the pre-release and have a few folks try it out. If it seems intrusive then we can look to add settings for it or increase the delay. Either way long term it would be great to have a setting to turn on/off and set the delay but I'm fine with that in a later PR once we have some feedback. Small incremental progress is fine around minor UI areas. The popup info we have currently is pretty rough and any steps to improving usability especially for more complex maps is welcome. I can see that revised only players may want to disable it but I also don't think their world will come to an end if they have to see a tooltip once in a while. |
Started testing this. Feels good. Much easier than having to click on the map then have to press a button. My initial reaction is that 1 second might be very quick for a ever present automatic function... however since the window itself does not interfere with playability it is less of a concern for me. Over-all a good addition. |
Will be very helpful for games with greater complexity. In TWW it would help a new player immensely. |
I also had a chance to play a real game with this. It also felt good to me.
(Says the person who implemented it, heh.)
My biggest observation is after being used to having these, I was expecting
them in other places like combat UI - where we don't have them now.
So we could look at wiring those in too.
On Jun 29, 2018 2:03 PM, "Hepps" <notifications@github.com> wrote:
Will be very helpful for games with greater complexity. In TWW it would
help a new player immensely.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3477 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABE8Ap_ypRd1ZsmFRHvd_shQ_sAWT7cks5uBmvngaJpZM4U1WN0>
.
|
One other issue I noticed is sometimes the tooltip will stay open when another dialog pops up over it. I can take a look at fixing that - probably by listening to focus events on the game window and hiding tooltips in that case. |
Like the ideas... this would be most helpful in the purchase screen. But I could also see it being useful on the combat window when having to choose casualties. Overall I am enjoying it. Again I think my preliminary feeling is growing the more I use this... I would likely move this to a 2 second delay. |
This is helpful for new players as well as players trying out new maps that have custom units.
The tooltip delay is set to 1 second, so it shouldn't be too intrusive.