Skip to content

Commit

Permalink
Revert "Merge pull request MegaMek#2827 from NickAragua/fix_left_clic…
Browse files Browse the repository at this point in the history
…k_issue"

This reverts commit cfc3830, reversing
changes made to 2409939.
  • Loading branch information
NickAragua committed May 6, 2021
1 parent a84cff0 commit 288daf7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 32 deletions.
28 changes: 19 additions & 9 deletions megamek/src/megamek/client/ui/swing/FiringDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
}

Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 10 additions & 8 deletions megamek/src/megamek/client/ui/swing/PhysicalDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down
16 changes: 13 additions & 3 deletions megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

Expand Down Expand Up @@ -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;
Expand Down
28 changes: 16 additions & 12 deletions megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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())) {
Expand All @@ -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();
Expand Down

0 comments on commit 288daf7

Please sign in to comment.