From 288daf7822421bb499044f98f0db1b3f8fb8b225 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 May 2021 22:09:05 -0400 Subject: [PATCH] Revert "Merge pull request #2827 from NickAragua/fix_left_click_issue" This reverts commit cfc3830d59b93e6934e8cb934022d61e6315662f, reversing changes made to 2409939c9d8f467602e2775e20e1427a01946d2d. --- .../client/ui/swing/FiringDisplay.java | 28 +++++++++++++------ .../client/ui/swing/PhysicalDisplay.java | 18 ++++++------ .../ui/swing/PointblankShotDisplay.java | 16 +++++++++-- .../ui/swing/TargetingPhaseDisplay.java | 28 +++++++++++-------- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/FiringDisplay.java b/megamek/src/megamek/client/ui/swing/FiringDisplay.java index 220de4f7b0d..b7df280a9f5 100644 --- a/megamek/src/megamek/client/ui/swing/FiringDisplay.java +++ b/megamek/src/megamek/client/ui/swing/FiringDisplay.java @@ -125,6 +125,8 @@ public String toString() { // is the shift key held? protected boolean shiftheld; + protected boolean twisting; + protected Entity[] visibleTargets = null; protected int lastTargetID = -1; @@ -2045,9 +2047,17 @@ public void hexMoused(BoardViewEvent b) { shiftheld = (b.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0; } - if ((b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) || - (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED)) { - clientgui.getBoardView().select(b.getCoords()); + if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) { + if (shiftheld || twisting) { + updateFlipArms(false); + torsoTwist(b.getCoords()); + } + clientgui.getBoardView().cursor(b.getCoords()); + } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { + twisting = false; + if (!shiftheld) { + clientgui.getBoardView().select(b.getCoords()); + } } } @@ -2192,6 +2202,8 @@ public void actionPerformed(ActionEvent ev) { fire(); } else if (ev.getActionCommand().equals(FiringCommand.FIRE_SKIP.getCmd())) { nextWeapon(); + } else if (ev.getActionCommand().equals(FiringCommand.FIRE_TWIST.getCmd())) { + twisting = true; } else if (ev.getActionCommand().equals(FiringCommand.FIRE_NEXT.getCmd())) { selectEntity(clientgui.getClient().getNextEntityNum(cen)); } else if (ev.getActionCommand().equals(FiringCommand.FIRE_MORE.getCmd())) { @@ -2240,13 +2252,11 @@ void updateFlipArms(boolean armsFlipped) { return; } - // clear attacks clears all non-firing actions, e.g. torso twists and arm flips as well, - // so we have to push/pop facing - int secondaryFacing = ce().getSecondaryFacing(); - + twisting = false; + + torsoTwist(null); + clearAttacks(); - - ce().setSecondaryFacing(secondaryFacing); ce().setArmsFlipped(armsFlipped); attacks.addElement(new FlipArmsAction(cen, armsFlipped)); updateTarget(); diff --git a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java index eb4e839007d..4886445b289 100644 --- a/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PhysicalDisplay.java @@ -1473,18 +1473,20 @@ public void hexMoused(BoardViewEvent b) { return; } - if (!clientgui.getClient().isMyTurn()) { - return; - } - // control pressed means a line of sight check. if ((b.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0) { return; } - - if ((b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) || - (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED)) { - clientgui.getBoardView().select(b.getCoords()); + if (clientgui.getClient().isMyTurn() + && ((b.getModifiers() & InputEvent.BUTTON1_DOWN_MASK) != 0)) { + if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) { + if (!b.getCoords().equals( + clientgui.getBoardView().getLastCursor())) { + clientgui.getBoardView().cursor(b.getCoords()); + } + } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { + clientgui.getBoardView().select(b.getCoords()); + } } } diff --git a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java index 772074059f5..ca21fad07f7 100644 --- a/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java +++ b/megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java @@ -935,9 +935,17 @@ public void hexMoused(BoardViewEvent b) { shiftheld = (b.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0; } - if ((b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) || - (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED)) { - clientgui.getBoardView().select(b.getCoords()); + if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) { + if (shiftheld || twisting) { + updateFlipArms(false); + torsoTwist(b.getCoords()); + } + clientgui.getBoardView().cursor(b.getCoords()); + } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { + twisting = false; + if (!shiftheld) { + clientgui.getBoardView().select(b.getCoords()); + } } } @@ -993,6 +1001,8 @@ public void actionPerformed(ActionEvent ev) { fire(); } else if (ev.getActionCommand().equals(FiringCommand.FIRE_SKIP.getCmd())) { nextWeapon(); + } else if (ev.getActionCommand().equals(FiringCommand.FIRE_TWIST.getCmd())) { + twisting = true; } else if (ev.getActionCommand().equals(FiringCommand.FIRE_MORE.getCmd())) { currentButtonGroup++; currentButtonGroup %= numButtonGroups; diff --git a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java index 8f57672a267..db9b6f7ee42 100644 --- a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java @@ -131,6 +131,8 @@ public String toString() { // is the shift key held? private boolean shiftheld; + private boolean twisting; + private final IGame.Phase phase; private Entity[] visibleTargets; @@ -1307,8 +1309,14 @@ public void hexMoused(BoardViewEvent b) { shiftheld = (b.getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0; } - if ((b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) || - (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED)) { + if (b.getType() == BoardViewEvent.BOARD_HEX_DRAGGED) { + if (shiftheld || twisting) { + updateFlipArms(false); + torsoTwist(b.getCoords()); + } + clientgui.getBoardView().cursor(b.getCoords()); + } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { + twisting = false; clientgui.getBoardView().select(b.getCoords()); } } @@ -1492,6 +1500,8 @@ public void actionPerformed(ActionEvent ev) { fire(); } else if (ev.getActionCommand().equals(TargetingCommand.FIRE_SKIP.getCmd())) { nextWeapon(); + } else if (ev.getActionCommand().equals(TargetingCommand.FIRE_TWIST.getCmd())) { + twisting = true; } else if (ev.getActionCommand().equals(TargetingCommand.FIRE_NEXT.getCmd())) { selectEntity(clientgui.getClient().getNextEntityNum(cen)); } else if (ev.getActionCommand().equals(TargetingCommand.FIRE_NEXT_TARG.getCmd())) { @@ -1514,21 +1524,15 @@ public void actionPerformed(ActionEvent ev) { } private void updateFlipArms(boolean armsFlipped) { - if (ce() == null) { - return; - } - if (armsFlipped == ce().getArmsFlipped()) { return; } - // clear attacks clears all non-firing actions, e.g. torso twists and arm flips as well, - // so we have to push/pop facing - int secondaryFacing = ce().getSecondaryFacing(); - + twisting = false; + + torsoTwist(null); + clearAttacks(); - - ce().setSecondaryFacing(secondaryFacing); ce().setArmsFlipped(armsFlipped); attacks.addElement(new FlipArmsAction(cen, armsFlipped)); updateTarget();