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

Show a unit tooltip when mouse-overing units on main map after 1s. #3477

Merged
merged 3 commits into from
Jun 28, 2018
Merged

Conversation

asvitkine
Copy link
Contributor

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.

@codecov-io
Copy link

codecov-io commented Jun 25, 2018

Codecov Report

Merging #3477 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...n/java/games/strategy/triplea/ui/TripleAFrame.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...mes/strategy/triplea/ui/MapUnitTooltipManager.java 0% <0%> (ø) 0 <0> (?)
...rategy/triplea/attachments/UnitTypeComparator.java 46.15% <0%> (-7.7%) 12% <0%> (-1%)
...me-core/src/main/java/games/strategy/net/Node.java 75.51% <0%> (-2.76%) 16% <0%> (+1%)
.../strategy/triplea/odds/calculator/DummyPlayer.java 35.22% <0%> (-1.14%) 9% <0%> (-1%)
...tegy/engine/framework/lookandfeel/LookAndFeel.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
...rc/main/java/games/strategy/net/nio/NioWriter.java 71.92% <0%> (+3.5%) 20% <0%> (ø) ⬇️

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 b59e309...d25b1cd. Read the comment docs.

@Cernelius
Copy link
Contributor

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.

@Cernelius
Copy link
Contributor

1 second sounds good for me.

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.

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);
Copy link
Member

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?

Copy link
Contributor Author

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();
Copy link
Member

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?

Copy link
Contributor Author

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() + ": "
Copy link
Member

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.

Copy link
Contributor Author

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";
}
Copy link
Member

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

Copy link
Contributor Author

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. */
Copy link
Member

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;
Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@asvitkine
Copy link
Contributor Author

Thanks. Comments addressed.

Here's a screenshot of how this looks.

screen shot 2018-06-27 at 10 37 01 pm

@Cernelius
Copy link
Contributor

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.
I'm thinking the delay should be 1 s if optional or 2 s if you can't turn it off.

@asvitkine
Copy link
Contributor Author

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.

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.

@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.

@RoiEXLab
Copy link
Member

(No objections on leaving this on by default though to have people try it out)

@asvitkine
Copy link
Contributor Author

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.

@Heppisorus
Copy link
Contributor

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.

@RoiEXLab
Copy link
Member

@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).
All you need to do is to add an entry for the desired setting in the desired category.
After that you should be able to query the current setting using ClientSetting.SETTING_NAME.value() or something.

@ron-murhammer
Copy link
Member

@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.

@ron-murhammer ron-murhammer dismissed RoiEXLab’s stale review June 28, 2018 22:22

Can look to have follow on PR.

@ron-murhammer ron-murhammer merged commit 06c97c3 into triplea-game:master Jun 28, 2018
@Heppisorus
Copy link
Contributor

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.

@Heppisorus
Copy link
Contributor

Will be very helpful for games with greater complexity. In TWW it would help a new player immensely.

@asvitkine
Copy link
Contributor Author

asvitkine commented Jun 29, 2018 via email

@asvitkine
Copy link
Contributor Author

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.

@Heppisorus
Copy link
Contributor

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.

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