Open andreas-eberle opened 9 years ago
We already have a tooltip-API (UIPanel#getDescription(x, y)). We could simply change the return type of the tooltip from String to a (String, ECursorType)-tuple.
Well, but the cursor image does not only depend on the position, but also on the current "mouse action". For example, when scrolling over the map, the cursor image changes as soon, as the user holds the right mouse button pressed. Would this be manageable in this method?
Or should we rather subscribe to the mouse events somewhere else?
The two most important cursors are:
EImageLinkType.SETTLER, 2, 20, 1) If selected soldiers and the cursor is over enemy targets: units/buildings
EImageLinkType.SETTLER, 2, 20, 6) while saving the game, switching between menus, etc.
How about a solution much like the one for the side panel's content pane. There would be a cursor event that panels can raise and they all go to a single handler which decides what state the mouse cursor should be in. It would sit at a high enough level that it has access to the root panels and mouse listeners. It should then have all the information needed to determine the correct state and the logic can then be kept in one place. The event would need to have a few parameters such as the source.
Idea
It would be nice to have the original cursors available in the Swing UI.
A First Simple Implementation
A first implementation could be to add the following code to the end of the SwingManagedJSettlers.startJogl() method.
However, this makes it impossible to changed the cursor depending on what the user is doing. E.g. when the user is scrolling over the map, the cursor changes in the original game.
@michaelzangl: Where could we introduce a logic like this? I think it would only be needed on the SwingUI as a cursor makes no sense on Android. I think we could provide the BufferedImages to that code location, but we need access to a java.awt.Component to be able to set the cursor.