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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/net/sf/freecol/client/gui/CanvasMouseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ public void mousePressed(MouseEvent e) {
}

switch (e.getButton()) {
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

getGUI().performGoto(e.getX(), e.getY());
break;
}

// Drag and selection
// Enable dragging with button 1
// @see CanvasMouseMotionListener#mouseDragged
getGUI().prepareDrag(e.getX(), e.getY());
Expand Down
11 changes: 11 additions & 0 deletions src/net/sf/freecol/client/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,17 @@ public void clearGotoPath() {}
*/
public void performGoto(Tile tile) {}

/**
* Check if the user has GoTo mode enabled.
*
* Called from {@link CanvasMouseListener}.
*
* @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

}

/**
* Perform an immediate goto to a point on the map.
*
Expand Down
8 changes: 8 additions & 0 deletions src/net/sf/freecol/client/gui/SwingGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,14 @@ public void clearGotoPath() {
updateUnitPath();
}

/**
* {@inheritDoc}
*/
@Override
public boolean isGotoStarted() {
return canvas.isGotoStarted();
}

/**
* {@inheritDoc}
*/
Expand Down