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

Fixes issue #23 whereby left clicks were ignored on goto mode #51

Merged
merged 4 commits into from
Dec 29, 2019

Conversation

TropicalBastos
Copy link
Contributor

Fixes issue #23 whereby left clicks were ignored on goto mode.

The patch makes it so whenever a left click is actioned, if the goto mode is enabled (with the hotkey G) and a unit is selected and has available moves, it moves the unit to the selected tile. The patch does nothing to affect the normal left click behaviour when Goto mode is disabled

Copy link
Member

@HighwayofLife HighwayofLife left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!!

* @return True if the user has toggled GoTo mode.
*/
public boolean isGotoStarted() {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused by this code block. The comment says it will return true if the user has toggled GoTo mode, but this method returns false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its the base class, since it required a method body I thought it would be reasonable to default it to false. Check SwingGUI.java for the override. Actually speaking of, let me patch it with an Override annotation

case MouseEvent.BUTTON1: // Drag and selection
case MouseEvent.BUTTON1:
// If we have GoTo mode enabled then GoTo takes precedence
if (getGUI().isGotoStarted()) {
Copy link
Member

Choose a reason for hiding this comment

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

The method only returns false? So this would never evaluate to true, or am I missing something?

Copy link
Contributor Author

@TropicalBastos TropicalBastos Dec 29, 2019

Choose a reason for hiding this comment

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

The base class returns false, however the subclass SwingGUI checks the canvas if Goto is enabled and returns true if it is. SwingGUI is the object type that is evaluated at runtime when it performs that check in the mouse event

@HighwayofLife HighwayofLife merged commit 2c1f9b7 into FreeCol:master Dec 29, 2019
@HighwayofLife HighwayofLife mentioned this pull request Jan 5, 2020
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