Skip to content

Commit

Permalink
GUI: fixed rare error while draging/moving card on first play (close #…
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDi85 committed Jan 4, 2025
1 parent 281086b commit fbd5cca
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ enum EnlargedWindowState {
private MageCard prevCardPanel;
private boolean startedDragging;
private boolean isDragging; // TODO: remove drag hand code to the hand panels
private Point initialCardPos;
private Point initialMousePos;
private Point initialCardPos = null;
private Point initialMousePos = null;
private final Set<MageCard> draggingCards = new HashSet<>();

public MageActionCallback() {
Expand Down Expand Up @@ -351,6 +351,11 @@ public void mouseDragged(MouseEvent e, TransferData data) {
return;
}

if (this.initialMousePos == null || this.initialCardPos == null) {
// only allow really mouse pressed, e.g. ignore draft/game update on active card draging/pressing
return;
}

Point mouse = new Point(e.getX(), e.getY());
SwingUtilities.convertPointToScreen(mouse, data.getComponent());
if (!isDragging
Expand Down

0 comments on commit fbd5cca

Please sign in to comment.