Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@SJuliez
Copy link
Member

@SJuliez SJuliez commented Apr 29, 2024

This PR

  • moves the tooltip generation out of BoardView
  • makes the tooltip modular, i.e. allows a tooltip provider object to be set for any given BoardView. When none is set, the BoardView works but it will not display a tooltip
  • adds a specialized tooltip for the Board Editor that displays substantially more detailed info about the terrains in a hex (the normal in-game tooltip is practically unchanged)
  • moved selectedEntity and selectedWeapon to ClientGUI as they should really be centrally available and BoardView should not be a data provider
  • moves some stuff around between BoardView and its BoardViewPanel
  • adds a few guards in HexTooltip to prevent NPEs in the lobby board preview
  • changes the tooltip color settings slightly (removes one setting and renames another)

While I believe that the tooltips are working, I can't imagine that there aren't going to be any side effects, especially with moving selectedEntity and *weapon out of the BoardView

The board editor tooltip:
image

/**
* The currently selected weapon on the currently selected entity (if any), -1 otherwise
*/
private int selectedWeapon = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can -1 be made a constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

absolutely

*
* @see BoardView#setTooltipProvider(BoardViewTooltipProvider)
*/
public interface BoardViewTooltipProvider {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like we normally use "I" as the leading character in an Interface name, although I'm not sure if that's by convention or a rule.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldnt say that its a rule, rather the opposite. I try not using the I* when I can avoid it. I only use it when the fitting interface name is taken by the present class name and I want to avoid having 140 files changed because of a name change. I know its happened rather often in my PRs tho. Changing the name of Game would be a real multi-hit wonder. There'll be a time when I do that tho :)

if (GUIP.getShowMapHexPopup() && (mhex != null)) {
StringBuffer sbTerrain = new StringBuffer();
appendTerrainTooltip(sbTerrain, mhex, GUIP);
String sTrerain = sbTerrain.toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo? 'sTrerain' -> 'sTerrain'?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes indeed. Not my typo :) I corrected it

Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

Other than a few minor nitpicks, looks really good!

Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

Great!

@SJuliez SJuliez merged commit afe318f into MegaMek:master Apr 30, 2024
@SJuliez SJuliez deleted the bv-tooltip-separation2 branch May 1, 2024 17:18
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.

2 participants