From e9a97bfa19bc9b99d9c6ea963f1cc4e021159cf5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-C2SG422\\Tim" Date: Sat, 3 Jun 2023 11:56:55 -0700 Subject: [PATCH 1/3] add updateMove --- .../client/ui/swing/MovementDisplay.java | 116 +++++++++++------- 1 file changed, 70 insertions(+), 46 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index 560d2c724da..e2b1d97c07c 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -426,7 +426,7 @@ public void performAction() { shiftheld = true; currentMove(target); shiftheld = false; - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } }); @@ -456,7 +456,7 @@ public void performAction() { shiftheld = true; currentMove(target); shiftheld = false; - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } }); @@ -626,7 +626,7 @@ public void performAction() { } } adjustConvertSteps(nextMode); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } }); } @@ -957,6 +957,11 @@ private void updateButtons() { updateDonePanel(); } + private void updateMove(MovePath cmd) { + clientgui.getBoardView().drawMovementData(ce(), cmd); + updateDonePanel(); + } + private void updateAeroButtons() { if (ce() != null && ce().isAero()) { getBtn(MoveCommand.MOVE_THRUST).setEnabled(true); @@ -978,9 +983,26 @@ private void updateAeroButtons() { /** toggles the status of the Done and No Nag buttons based on if the current move order is valid */ @Override protected void updateDonePanel() { + +// // Set the button's label to "Done" +// // if the entire move is impossible. +// MovePath possible = cmd.clone(); +// possible.clipToPossible(); +// if (possible.length() == 0) { +// updateDonePanel(); +// } + + if (cmd == null || cmd.length() == 0) { updateDonePanelButtons( Messages.getString("MovementDisplay.Move"), Messages.getString("MovementDisplay.Skip"), false); - } else { + return; + } + MovePath possible = cmd.clone(); + possible.clipToPossible(); + if (possible.length() == 0) { + //FIXME SHOW INVALID? + updateDonePanelButtons( Messages.getString("MovementDisplay.Move"), Messages.getString("MovementDisplay.Skip"), false); + } else { boolean psrCheck = (!SharedUtility.doPSRCheck(cmd.clone()).isBlank()) || (!SharedUtility.doThrustCheck(cmd.clone(), clientgui.getClient()).isBlank()); boolean damageCheck = cmd.shouldMechanicalJumpCauseFallDamage() @@ -1246,6 +1268,7 @@ private void removeLastStep() { clientgui.getBoardView().setWeaponFieldOfFire(entity, cmd); clientgui.getBoardView().setSensorRange(entity, cmd.getFinalCoords()); + //FIXME what is this // Set the button's label to "Done" // if the entire move is impossible. MovePath possible = cmd.clone(); @@ -1766,15 +1789,16 @@ public synchronized void hexMoused(BoardViewEvent b) { // either turn or move if (ce != null) { currentMove(b.getCoords()); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { Coords moveto = b.getCoords(); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); if (shiftheld || (gear == MovementDisplay.GEAR_TURN)) { updateDonePanel(); + //FIXME what is this // Set the button's label to "Done" // if the entire move is impossible. MovePath possible = cmd.clone(); @@ -4438,7 +4462,7 @@ public synchronized void actionPerformed(ActionEvent ev) { } } adjustConvertSteps(nextMode); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_LEG.getCmd())) { if ((ce.getEntityType() & Entity.ETYPE_QUAD_MECH) == Entity.ETYPE_QUAD_MECH) { adjustConvertSteps(EntityMovementMode.QUAD); @@ -4447,7 +4471,7 @@ public synchronized void actionPerformed(ActionEvent ev) { } else if ((ce.getEntityType() & Entity.ETYPE_BIPED_MECH) == Entity.ETYPE_BIPED_MECH) { adjustConvertSteps(EntityMovementMode.BIPED); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_VEE.getCmd())) { if (ce instanceof QuadVee && ((QuadVee) ce).getMotiveType() == QuadVee.MOTIVE_WHEEL) { adjustConvertSteps(EntityMovementMode.WHEELED); @@ -4458,12 +4482,12 @@ public synchronized void actionPerformed(ActionEvent ev) { && ((LandAirMech) ce).getLAMType() == LandAirMech.LAM_STANDARD) { adjustConvertSteps(EntityMovementMode.WIGE); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_AIR.getCmd())) { if (ce instanceof LandAirMech) { adjustConvertSteps(EntityMovementMode.AERODYNE); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_TURN.getCmd())) { gear = MovementDisplay.GEAR_TURN; } else if (actionCmd.equals(MoveCommand.MOVE_BACK_UP.getCmd())) { @@ -4596,20 +4620,20 @@ public synchronized void actionPerformed(ActionEvent ev) { } } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_GO_PRONE.getCmd())) { gear = MovementDisplay.GEAR_LAND; if (!cmd.getFinalProne()) { cmd.addStep(MoveStepType.GO_PRONE); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); updateDonePanel(); } else if (actionCmd.equals(MoveCommand.MOVE_HULL_DOWN.getCmd())) { gear = MovementDisplay.GEAR_LAND; if (!cmd.getFinalHullDown()) { cmd.addStep(MoveStepType.HULL_DOWN); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); updateDonePanel(); } else if (actionCmd.equals(MoveCommand.MOVE_BRACE.getCmd())) { var options = ce().getValidBraceLocations(); @@ -4694,7 +4718,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Entity other = getLoadedUnit(); if (other != null) { cmd.addStep(MoveStepType.LOAD); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); gear = MovementDisplay.GEAR_LAND; } // else - didn't find a unit to load } else if (actionCmd.equals(MoveCommand.MOVE_TOW.getCmd())) { @@ -4703,14 +4727,14 @@ public synchronized void actionPerformed(ActionEvent ev) { Entity other = getTowedUnit(); if (other != null) { cmd.addStep(MoveStepType.TOW); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } // else - didn't find a unit to tow } else if (actionCmd.equals(MoveCommand.MOVE_DISCONNECT.getCmd())) { // Ask the user if we're carrying multiple units. Entity other = getDisconnectedUnit(); if (other != null) { cmd.addStep(MoveStepType.DISCONNECT, other); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } // else - didn't find a unit to tow } else if (actionCmd.equals(MoveCommand.MOVE_MOUNT.getCmd())) { Entity other = getMountedUnit(); @@ -4731,19 +4755,19 @@ public synchronized void actionPerformed(ActionEvent ev) { // unloading unit will get // another turn for further unloading later cmd.addStep(MoveStepType.UNLOAD, other, pos); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); ready(); } } else { // some different handling for small craft/dropship // unloading cmd.addStep(MoveStepType.UNLOAD, other); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } } // else - Player canceled the unload. } else if (actionCmd.equals(MoveCommand.MOVE_RAISE_ELEVATION.getCmd())) { cmd.addStep(MoveStepType.UP); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_LOWER_ELEVATION.getCmd())) { if (ce.isAero() && (null != cmd.getLastStep()) @@ -4754,7 +4778,7 @@ public synchronized void actionPerformed(ActionEvent ev) { cmd.addStep(MoveStepType.ACC, true); } cmd.addStep(MoveStepType.DOWN); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_CLIMB_MODE.getCmd())) { MoveStep ms = cmd.getLastStep(); if ((ms != null) @@ -4776,7 +4800,7 @@ public synchronized void actionPerformed(ActionEvent ev) { } else { cmd.addStep(MoveStepType.CLIMB_MODE_ON); } - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); computeMovementEnvelope(ce); } else if (actionCmd.equals(MoveCommand.MOVE_LAY_MINE.getCmd())) { int i = chooseMineToLay(); @@ -4798,23 +4822,23 @@ public synchronized void actionPerformed(ActionEvent ev) { computeMovementEnvelope(ce); } cmd.addStep(MoveStepType.LAY_MINE, i); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } else if (actionCmd.equals(MoveCommand.MOVE_CALL_SUPPORT.getCmd())) { ((Infantry) ce).createLocalSupport(); clientgui.getClient().sendUpdateEntity(ce()); } else if (actionCmd.equals(MoveCommand.MOVE_DIG_IN.getCmd())) { cmd.addStep(MoveStepType.DIG_IN); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_FORTIFY.getCmd())) { cmd.addStep(MoveStepType.FORTIFY); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_TAKE_COVER.getCmd())) { cmd.addStep(MoveStepType.TAKE_COVER); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_SHAKE_OFF.getCmd())) { cmd.addStep(MoveStepType.SHAKE_OFF_SWARMERS); - clientgui.getBoardView().drawMovementData(ce(), cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_RECKLESS.getCmd())) { cmd.setCareful(false); } else if (actionCmd.equals(MoveCommand.MOVE_STRAFE.getCmd())) { @@ -4825,25 +4849,25 @@ public synchronized void actionPerformed(ActionEvent ev) { } cmd.setVTOLBombStep(cmd.getFinalCoords()); cmd.compile(clientgui.getClient().getGame(), ce, false); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_ACCN.getCmd())) { cmd.addStep(MoveStepType.ACCN); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_DECN.getCmd())) { cmd.addStep(MoveStepType.DECN); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_ACC.getCmd())) { cmd.addStep(MoveStepType.ACC); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_DEC.getCmd())) { cmd.addStep(MoveStepType.DEC); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_EVADE.getCmd())) { cmd.addStep(MoveStepType.EVADE); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_BOOTLEGGER.getCmd())) { cmd.addStep(MoveStepType.BOOTLEGGER); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_SHUTDOWN.getCmd())) { if (clientgui.doYesNoDialog( Messages.getString("MovementDisplay.ShutdownDialog.title"), @@ -4868,11 +4892,11 @@ public synchronized void actionPerformed(ActionEvent ev) { } } else if (actionCmd.equals(MoveCommand.MOVE_EVADE_AERO.getCmd())) { cmd.addStep(MoveStepType.EVADE); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); setEvadeAeroEnabled(false); } else if (actionCmd.equals(MoveCommand.MOVE_ROLL.getCmd())) { cmd.addStep(MoveStepType.ROLL); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_HOVER.getCmd())) { cmd.addStep(MoveStepType.HOVER); if (ce instanceof LandAirMech @@ -4880,7 +4904,7 @@ public synchronized void actionPerformed(ActionEvent ev) { && ce.isAirborne()) { gear = GEAR_LAND; } - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MANEUVER.getCmd())) { ManeuverChoiceDialog choiceDialog = new ManeuverChoiceDialog( clientgui.frame, @@ -4911,7 +4935,7 @@ public synchronized void actionPerformed(ActionEvent ev) { choiceDialog.setVisible(true); int manType = choiceDialog.getChoice(); if ((manType > ManeuverType.MAN_NONE) && addManeuver(manType)) { - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } else if (actionCmd.equals(MoveCommand.MOVE_LAUNCH.getCmd())) { TreeMap> undocked = getUndockedUnits(); @@ -4923,7 +4947,7 @@ public synchronized void actionPerformed(ActionEvent ev) { cmd.addStep(MoveStepType.LAUNCH, launched); } if (!launched.isEmpty() || !undocked.isEmpty()) { - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } else if (actionCmd.equals(MoveCommand.MOVE_RECOVER.getCmd()) || actionCmd.equals(MoveCommand.MOVE_DOCK.getCmd())) { @@ -4932,7 +4956,7 @@ public synchronized void actionPerformed(ActionEvent ev) { int recoverer = getRecoveryUnit(); if (recoverer != -1) { cmd.addStep(MoveStepType.RECOVER, recoverer, -1); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } if (actionCmd.equals(MoveCommand.MOVE_DOCK.getCmd())) { cmd.getLastStep().setDocking(true); @@ -4941,7 +4965,7 @@ public synchronized void actionPerformed(ActionEvent ev) { TreeMap> dropped = getDroppedUnits(); if (!dropped.isEmpty()) { cmd.addStep(MoveStepType.DROP, dropped); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } else if (actionCmd.equals(MoveCommand.MOVE_JOIN.getCmd())) { // if more than one unit is available as a carrier @@ -4949,24 +4973,24 @@ public synchronized void actionPerformed(ActionEvent ev) { int joined = getUnitJoined(); if (joined != -1) { cmd.addStep(MoveStepType.JOIN, joined, -1); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } } else if (actionCmd.equals(MoveCommand.MOVE_TURN_LEFT.getCmd())) { cmd.addStep(MoveStepType.TURN_LEFT); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_TURN_RIGHT.getCmd())) { cmd.addStep(MoveStepType.TURN_RIGHT); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_THRUST.getCmd())) { cmd.addStep(MoveStepType.THRUST); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_YAW.getCmd())) { cmd.addStep(MoveStepType.YAW); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_END_OVER.getCmd())) { cmd.addStep(MoveStepType.YAW); cmd.addStep(MoveStepType.ROLL); - clientgui.getBoardView().drawMovementData(ce, cmd); + updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_DUMP.getCmd())) { dumpBombs(); } else if (actionCmd.equals(MoveCommand.MOVE_TAKE_OFF.getCmd())) { From b4288d5c3df67a6dda0a86b1055d1b28ae103bd6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-C2SG422\\Tim" Date: Sun, 4 Jun 2023 14:30:25 -0700 Subject: [PATCH 2/3] centralize addStep calls to make sure they trigger UI updates --- .../i18n/megamek/client/messages.properties | 1 + .../client/ui/swing/ActionPhaseDisplay.java | 6 +- .../client/ui/swing/MovementDisplay.java | 366 +++++++++--------- 3 files changed, 191 insertions(+), 182 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 4091335f22c..a090d80055b 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -2460,6 +2460,7 @@ MovementDisplay.FlyOffDialog.message=Do you want to fly off the map? MovementDisplay.FlyOffDialog.title=Fly Away? MovementDisplay.IceLanding=Landing on ice will break through on 4+ on 1d6.\n MovementDisplay.IceMoving=Crossing ice will break through on 6+ on 1d6.\n +MovementDisplay.IllegalMove=Illegal Move MovementDisplay.its_others_turn=It''s {0}''s turn to move. MovementDisplay.its_your_turn=It's your turn to move. MovementDisplay.loadUnitBayNumberDialog.message=Which of {0}'s bays do you wish to load into? diff --git a/megamek/src/megamek/client/ui/swing/ActionPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/ActionPhaseDisplay.java index 743c04e7106..ef5e3f4bef4 100644 --- a/megamek/src/megamek/client/ui/swing/ActionPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ActionPhaseDisplay.java @@ -151,8 +151,10 @@ protected void updateDonePanelButtons(String doneButtonLabel, String skipButtonL } butSkipTurn.setText("" + skipButtonLabel + ""); - // enable/disable - if (this.isDoingAction || ignoreNoActionNag) { + if (!clientgui.getClient().isMyTurn()) { + butDone.setEnabled(false); + butSkipTurn.setEnabled(false); + } else if (this.isDoingAction || ignoreNoActionNag) { butDone.setEnabled(true); butSkipTurn.setEnabled(false); } else { diff --git a/megamek/src/megamek/client/ui/swing/MovementDisplay.java b/megamek/src/megamek/client/ui/swing/MovementDisplay.java index e2b1d97c07c..706a761bdff 100644 --- a/megamek/src/megamek/client/ui/swing/MovementDisplay.java +++ b/megamek/src/megamek/client/ui/swing/MovementDisplay.java @@ -426,7 +426,7 @@ public void performAction() { shiftheld = true; currentMove(target); shiftheld = false; - updateMove(cmd); + updateMove(); } }); @@ -456,7 +456,7 @@ public void performAction() { shiftheld = true; currentMove(target); shiftheld = false; - updateMove(cmd); + updateMove(); } }); @@ -575,7 +575,7 @@ public void performAction() { clear(); } if (!cmd.isJumping()) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); } gear = MovementDisplay.GEAR_JUMP; Color jumpColor = GUIP.getMoveJumpColor(); @@ -626,7 +626,6 @@ public void performAction() { } } adjustConvertSteps(nextMode); - updateMove(cmd); } }); } @@ -957,8 +956,73 @@ private void updateButtons() { updateDonePanel(); } - private void updateMove(MovePath cmd) { - clientgui.getBoardView().drawMovementData(ce(), cmd); + private void addStepToMovePath(MoveStepType moveStep) { + cmd.addStep(moveStep); + updateMove(); + } + + private void addStepsToMovePath(MoveStepType ... moveSteps ) { + for (MoveStepType moveStep : moveSteps) { + cmd.addStep(moveStep); + } + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, Entity entity) { + cmd.addStep(moveStep, entity); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, TreeMap> targets) { + cmd.addStep(moveStep, targets); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, boolean noCost) { + cmd.addStep(moveStep, noCost); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, boolean noCost, boolean isManeuver) { + cmd.addStep(moveStep, noCost, isManeuver); + updateMove(); + } + + private void addStepsToMovePath(boolean noCost, boolean isManeuver, MoveStepType ... moveSteps) { + for (MoveStepType moveStep : moveSteps) { + cmd.addStep(moveStep, noCost, isManeuver); + } + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, Entity entity, Coords coords) { + cmd.addStep(moveStep, entity, coords); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, Minefield minefield) { + cmd.addStep(moveStep, minefield); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, int additionalIntData) { + cmd.addStep(moveStep, additionalIntData); + updateMove(); + } + + private void addStepToMovePath(MoveStepType moveStep, int recover ,int mineToLay) { + cmd.addStep(moveStep, recover, mineToLay); + updateMove(); + } + + private void updateMove() { + updateMove(true); + } + + private void updateMove(boolean redrawMovement) { + if (redrawMovement) { + clientgui.getBoardView().drawMovementData(ce(), cmd); + } updateDonePanel(); } @@ -983,37 +1047,24 @@ private void updateAeroButtons() { /** toggles the status of the Done and No Nag buttons based on if the current move order is valid */ @Override protected void updateDonePanel() { - -// // Set the button's label to "Done" -// // if the entire move is impossible. -// MovePath possible = cmd.clone(); -// possible.clipToPossible(); -// if (possible.length() == 0) { -// updateDonePanel(); -// } - - if (cmd == null || cmd.length() == 0) { updateDonePanelButtons( Messages.getString("MovementDisplay.Move"), Messages.getString("MovementDisplay.Skip"), false); return; - } - MovePath possible = cmd.clone(); - possible.clipToPossible(); - if (possible.length() == 0) { - //FIXME SHOW INVALID? - updateDonePanelButtons( Messages.getString("MovementDisplay.Move"), Messages.getString("MovementDisplay.Skip"), false); - } else { - boolean psrCheck = (!SharedUtility.doPSRCheck(cmd.clone()).isBlank()) - || (!SharedUtility.doThrustCheck(cmd.clone(), clientgui.getClient()).isBlank()); - boolean damageCheck = cmd.shouldMechanicalJumpCauseFallDamage() - || cmd.hasActiveMASC() - || (!(ce() instanceof VTOL) && cmd.hasActiveSupercharger()) - || cmd.willCrushBuildings(); - - String moveMsg = Messages.getString("MovementDisplay.Move") - + (psrCheck ? "*" : "") - + (damageCheck ? " !" : ""); - updateDonePanelButtons(moveMsg, Messages.getString("MovementDisplay.Skip"), true); + } else { + MovePath possible = cmd.clone(); + possible.clipToPossible(); + if (possible.length() == 0) { + updateDonePanelButtons(Messages.getString("MovementDisplay.Move"), Messages.getString("MovementDisplay.Skip"), false); + } else if (!possible.isMoveLegal()) { + updateDonePanelButtons(Messages.getString("MovementDisplay.IllegalMove"), Messages.getString("MovementDisplay.Skip"), false); + } else { + int mp = possible.countMp(possible.isJumping()); + boolean psrCheck = (!SharedUtility.doPSRCheck(cmd.clone()).isBlank()) || (!SharedUtility.doThrustCheck(cmd.clone(), clientgui.getClient()).isBlank()); + boolean damageCheck = cmd.shouldMechanicalJumpCauseFallDamage() || cmd.hasActiveMASC() || (!(ce() instanceof VTOL) && cmd.hasActiveSupercharger()) || cmd.willCrushBuildings(); + String moveMsg = Messages.getString("MovementDisplay.Move") + + " (" + mp + "MP)" + (psrCheck ? "*" : "") + (psrCheck ? "*" : "") + (damageCheck ? "!" : ""); + updateDonePanelButtons(moveMsg, Messages.getString("MovementDisplay.Skip"), true); + } } } @@ -1183,7 +1234,7 @@ public void clear() { Color walkColor = GUIP.getMoveDefaultColor(); clientgui.getBoardView().setHighlightColor(walkColor); } else if (!cmd.isJumping()) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); } // update some GUI elements @@ -1256,9 +1307,9 @@ private void removeLastStep() { } else if (cmd.length() == 0) { clear(); if ((gear == MovementDisplay.GEAR_JUMP) && !cmd.isJumping()) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); } else if (entity.isConvertingNow()) { - cmd.addStep(MoveStepType.CONVERT_MODE); + addStepToMovePath(MoveStepType.CONVERT_MODE); } } else { // clear board cursors @@ -1577,7 +1628,7 @@ && ce().getGame().getBoard().getHex(cmd.getFinalCoords()) } if (isUsingChaff) { - cmd.addStep(MoveStepType.CHAFF); + addStepToMovePath(MoveStepType.CHAFF); isUsingChaff = false; } @@ -1684,7 +1735,7 @@ private void currentMove(Coords dest) { if (cmd.getFinalCoords().equals(dest) && (cmd.getLastStep().getType() != MoveStepType.CHARGE)) { cmd.removeLastStep(); - cmd.addStep(MoveStepType.CHARGE); + addStepToMovePath(MoveStepType.CHARGE); } } else if (gear == GEAR_DFA) { cmd.findPathTo(dest, MoveStepType.DFA); @@ -1692,23 +1743,25 @@ private void currentMove(Coords dest) { if (cmd.getFinalCoords().equals(dest) && (cmd.getLastStep().getType() != MoveStepType.DFA)) { cmd.removeLastStep(); - cmd.addStep(MoveStepType.DFA); + addStepToMovePath(MoveStepType.DFA); } } else if (gear == GEAR_SWIM) { cmd.findPathTo(dest, MoveStepType.SWIM); } else if (gear == GEAR_RAM) { cmd.findPathTo(dest, MoveStepType.FORWARDS); } else if (gear == GEAR_IMMEL) { - cmd.addStep(MoveStepType.UP, true, true); - cmd.addStep(MoveStepType.UP, true, true); - cmd.addStep(MoveStepType.DEC, true, true); - cmd.addStep(MoveStepType.DEC, true, true); + addStepsToMovePath(true, true, + MoveStepType.UP, + MoveStepType.UP, + MoveStepType.DEC, + MoveStepType.DEC); cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true); gear = GEAR_LAND; } else if (gear == GEAR_SPLIT_S) { - cmd.addStep(MoveStepType.DOWN, true, true); - cmd.addStep(MoveStepType.DOWN, true, true); - cmd.addStep(MoveStepType.ACC, true, true); + addStepsToMovePath(true, true, + MoveStepType.DOWN, + MoveStepType.DOWN, + MoveStepType.ACC); cmd.rotatePathfinder(cmd.getFinalCoords().direction(dest), true); gear = GEAR_LAND; } @@ -1789,12 +1842,12 @@ public synchronized void hexMoused(BoardViewEvent b) { // either turn or move if (ce != null) { currentMove(b.getCoords()); - updateMove(cmd); + updateMove(); } } } else if (b.getType() == BoardViewEvent.BOARD_HEX_CLICKED) { Coords moveto = b.getCoords(); - updateMove(cmd); + updateMove(); if (shiftheld || (gear == MovementDisplay.GEAR_TURN)) { updateDonePanel(); @@ -1828,7 +1881,7 @@ public synchronized void hexMoused(BoardViewEvent b) { cmd.clipToPossible(); } - cmd.addStep(MoveStepType.RAM); + addStepToMovePath(MoveStepType.RAM); ToHitData toHit = new RamAttackAction(cen, target.getTargetType(), target.getId(), @@ -1980,7 +2033,6 @@ public synchronized void hexMoused(BoardViewEvent b) { return; } updateDonePanel(); - butDone.setEnabled(clientgui.getClient().isMyTurn()); updateProneButtons(); updateChaffButton(); updateRACButton(); @@ -4106,13 +4158,13 @@ private boolean addManeuver(int type) { cmd.addManeuver(type); switch (type) { case ManeuverType.MAN_HAMMERHEAD: - cmd.addStep(MoveStepType.YAW, true, true); + addStepToMovePath(MoveStepType.YAW, true, true); return true; case ManeuverType.MAN_HALF_ROLL: - cmd.addStep(MoveStepType.ROLL, true, true); + addStepToMovePath(MoveStepType.ROLL, true, true); return true; case ManeuverType.MAN_BARREL_ROLL: - cmd.addStep(MoveStepType.DEC, true, true); + addStepToMovePath(MoveStepType.DEC, true, true); return true; case ManeuverType.MAN_IMMELMAN: gear = MovementDisplay.GEAR_IMMEL; @@ -4131,23 +4183,23 @@ private boolean addManeuver(int type) { vel = last.getVelocityLeft(); } while (vel > 0) { - cmd.addStep(MoveStepType.DEC, true, true); + addStepToMovePath(MoveStepType.DEC, true, true); vel--; } - cmd.addStep(MoveStepType.UP); + addStepToMovePath(MoveStepType.UP); return true; case ManeuverType.MAN_SIDE_SLIP_LEFT: // If we are on a ground map, slide slip works slightly differently // See Total Warfare pg 85 if (clientgui.getClient().getGame().getBoard().getType() == Board.T_GROUND) { for (int i = 0; i < 8; i++) { - cmd.addStep(MoveStepType.LATERAL_LEFT, true, true); + addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true); } for (int i = 0; i < 8; i++) { - cmd.addStep(MoveStepType.FORWARDS, true, true); + addStepToMovePath(MoveStepType.FORWARDS, true, true); } } else { - cmd.addStep(MoveStepType.LATERAL_LEFT, true, true); + addStepToMovePath(MoveStepType.LATERAL_LEFT, true, true); } return true; case ManeuverType.MAN_SIDE_SLIP_RIGHT: @@ -4155,17 +4207,17 @@ private boolean addManeuver(int type) { // See Total Warfare pg 85 if (clientgui.getClient().getGame().getBoard().getType() == Board.T_GROUND) { for (int i = 0; i < 8; i++) { - cmd.addStep(MoveStepType.LATERAL_RIGHT, true, true); + addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true); } for (int i = 0; i < 8; i++) { - cmd.addStep(MoveStepType.FORWARDS, true, true); + addStepToMovePath(MoveStepType.FORWARDS, true, true); } } else { - cmd.addStep(MoveStepType.LATERAL_RIGHT, true, true); + addStepToMovePath(MoveStepType.LATERAL_RIGHT, true, true); } return true; case ManeuverType.MAN_LOOP: - cmd.addStep(MoveStepType.LOOP, true, true); + addStepToMovePath(MoveStepType.LOOP, true, true); return true; default: return false; @@ -4405,7 +4457,7 @@ public synchronized void actionPerformed(ActionEvent ev) { // gear = Compute.GEAR_LAND; setUnjamEnabled(false); } else if (clientgui.doYesNoDialog(title, msg)) { - cmd.addStep(MoveStepType.UNJAM_RAC); + addStepToMovePath(MoveStepType.UNJAM_RAC); isUnJammingRAC = true; ready(); // If ready() fires, it will call endMyTurn, which sets cen to @@ -4418,7 +4470,7 @@ public synchronized void actionPerformed(ActionEvent ev) { } } } else if (actionCmd.equals(MoveCommand.MOVE_SEARCHLIGHT.getCmd())) { - cmd.addStep(MoveStepType.SEARCHLIGHT); + addStepToMovePath(MoveStepType.SEARCHLIGHT); } else if (actionCmd.equals(MoveCommand.MOVE_WALK.getCmd())) { if ((gear == MovementDisplay.GEAR_JUMP) || (gear == MovementDisplay.GEAR_SWIM)) { gear = MovementDisplay.GEAR_LAND; @@ -4436,7 +4488,7 @@ public synchronized void actionPerformed(ActionEvent ev) { clear(); } if (!cmd.isJumping()) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); } gear = MovementDisplay.GEAR_JUMP; Color jumpColor = GUIP.getMoveJumpColor(); @@ -4446,7 +4498,7 @@ public synchronized void actionPerformed(ActionEvent ev) { if (gear != MovementDisplay.GEAR_SWIM) { clear(); } - // dcmd.addStep(MoveStepType.SWIM); + // daddStepToMovePath(MoveStepType.SWIM); gear = MovementDisplay.GEAR_SWIM; ce.setMovementMode((ce instanceof BipedMech) ? EntityMovementMode.BIPED_SWIM : EntityMovementMode.QUAD_SWIM); @@ -4462,7 +4514,6 @@ public synchronized void actionPerformed(ActionEvent ev) { } } adjustConvertSteps(nextMode); - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_LEG.getCmd())) { if ((ce.getEntityType() & Entity.ETYPE_QUAD_MECH) == Entity.ETYPE_QUAD_MECH) { adjustConvertSteps(EntityMovementMode.QUAD); @@ -4471,7 +4522,6 @@ public synchronized void actionPerformed(ActionEvent ev) { } else if ((ce.getEntityType() & Entity.ETYPE_BIPED_MECH) == Entity.ETYPE_BIPED_MECH) { adjustConvertSteps(EntityMovementMode.BIPED); } - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_VEE.getCmd())) { if (ce instanceof QuadVee && ((QuadVee) ce).getMotiveType() == QuadVee.MOTIVE_WHEEL) { adjustConvertSteps(EntityMovementMode.WHEELED); @@ -4482,12 +4532,10 @@ public synchronized void actionPerformed(ActionEvent ev) { && ((LandAirMech) ce).getLAMType() == LandAirMech.LAM_STANDARD) { adjustConvertSteps(EntityMovementMode.WIGE); } - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MODE_AIR.getCmd())) { if (ce instanceof LandAirMech) { adjustConvertSteps(EntityMovementMode.AERODYNE); } - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_TURN.getCmd())) { gear = MovementDisplay.GEAR_TURN; } else if (actionCmd.equals(MoveCommand.MOVE_BACK_UP.getCmd())) { @@ -4563,7 +4611,7 @@ public synchronized void actionPerformed(ActionEvent ev) { String title = Messages.getString("MovementDisplay.ClearMinefieldDialog.title"); String msg = Messages.getString("MovementDisplay.ClearMinefieldDialog.message", clear, boom); if ((null != mf) && clientgui.doYesNoDialog(title, msg)) { - cmd.addStep(MoveStepType.CLEAR_MINEFIELD, mf); + addStepToMovePath(MoveStepType.CLEAR_MINEFIELD, mf); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_CHARGE.getCmd())) { @@ -4579,7 +4627,7 @@ public synchronized void actionPerformed(ActionEvent ev) { gear = MovementDisplay.GEAR_DFA; computeMovementEnvelope(ce); if (!cmd.isJumping()) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); } } else if (actionCmd.equals(MoveCommand.MOVE_RAM.getCmd())) { if (gear != MovementDisplay.GEAR_LAND) { @@ -4606,40 +4654,33 @@ public synchronized void actionPerformed(ActionEvent ev) { if (response.getAnswer()) { ce.setCarefulStand(true); if (cmd.getFinalProne() || cmd.getFinalHullDown()) { - cmd.addStep(MoveStepType.CAREFUL_STAND); + addStepToMovePath(MoveStepType.CAREFUL_STAND); } } else { if (cmd.getFinalProne() || cmd.getFinalHullDown()) { - cmd.addStep(MoveStepType.GET_UP); + addStepToMovePath(MoveStepType.GET_UP); } } } else { updateDonePanel(); if (cmd.getFinalProne() || cmd.getFinalHullDown()) { - cmd.addStep(MoveStepType.GET_UP); + addStepToMovePath(MoveStepType.GET_UP); } } - - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_GO_PRONE.getCmd())) { gear = MovementDisplay.GEAR_LAND; if (!cmd.getFinalProne()) { - cmd.addStep(MoveStepType.GO_PRONE); + addStepToMovePath(MoveStepType.GO_PRONE); } - updateMove(cmd); - updateDonePanel(); } else if (actionCmd.equals(MoveCommand.MOVE_HULL_DOWN.getCmd())) { gear = MovementDisplay.GEAR_LAND; if (!cmd.getFinalHullDown()) { - cmd.addStep(MoveStepType.HULL_DOWN); + addStepToMovePath(MoveStepType.HULL_DOWN); } - updateMove(cmd); - updateDonePanel(); } else if (actionCmd.equals(MoveCommand.MOVE_BRACE.getCmd())) { var options = ce().getValidBraceLocations(); if (options.size() == 1) { - cmd.addStep(MoveStepType.BRACE, options.get(0)); - updateDonePanel(); + addStepToMovePath(MoveStepType.BRACE, options.get(0)); } else if (options.size() > 1) { String[] locationNames = new String[options.size()]; @@ -4656,7 +4697,7 @@ public synchronized void actionPerformed(ActionEvent ev) { // Verify that we have a valid option... if (option != null) { int id = options.get(Arrays.asList(locationNames).indexOf(option)); - cmd.addStep(MoveStepType.BRACE, id); + addStepToMovePath(MoveStepType.BRACE, id); updateDonePanel(); } } @@ -4666,7 +4707,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.EscapeDialog.message"))) { clear(); - cmd.addStep(MoveStepType.FLEE); + addStepToMovePath(MoveStepType.FLEE); ready(); } else if (actionCmd.equals(MoveCommand.MOVE_FLY_OFF.getCmd()) && clientgui.doYesNoDialog( @@ -4676,9 +4717,9 @@ public synchronized void actionPerformed(ActionEvent ev) { && clientgui.doYesNoDialog( Messages.getString("MovementDisplay.ReturnFly.title"), Messages.getString("MovementDisplay.ReturnFly.message"))) { - cmd.addStep(MoveStepType.RETURN); + addStepToMovePath(MoveStepType.RETURN); } else { - cmd.addStep(MoveStepType.OFF); + addStepToMovePath(MoveStepType.OFF); } ready(); } else if (actionCmd.equals(MoveCommand.MOVE_EJECT.getCmd())) { @@ -4687,7 +4728,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.AbandonDialog.title"), Messages.getString("MovementDisplay.AbandonDialog.message"))) { clear(); - cmd.addStep(MoveStepType.EJECT); + addStepToMovePath(MoveStepType.EJECT); ready(); } } else if (ce.isLargeCraft()) { @@ -4698,9 +4739,9 @@ public synchronized void actionPerformed(ActionEvent ev) { // If we're abandoning while grounded, find a legal position to put an EjectedCrew unit if (!ce.isSpaceborne() && ce.getAltitude() == 0) { Coords pos = getEjectPosition(ce); - cmd.addStep(MoveStepType.EJECT, ce, pos); + addStepToMovePath(MoveStepType.EJECT, ce, pos); } else { - cmd.addStep(MoveStepType.EJECT); + addStepToMovePath(MoveStepType.EJECT); } ready(); } @@ -4709,7 +4750,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.AbandonDialog1.title"), Messages.getString("MovementDisplay.AbandonDialog1.message"))) { clear(); - cmd.addStep(MoveStepType.EJECT); + addStepToMovePath(MoveStepType.EJECT); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_LOAD.getCmd())) { @@ -4717,8 +4758,7 @@ public synchronized void actionPerformed(ActionEvent ev) { // to our local list of loaded units, and then stop. Entity other = getLoadedUnit(); if (other != null) { - cmd.addStep(MoveStepType.LOAD); - updateMove(cmd); + addStepToMovePath(MoveStepType.LOAD); gear = MovementDisplay.GEAR_LAND; } // else - didn't find a unit to load } else if (actionCmd.equals(MoveCommand.MOVE_TOW.getCmd())) { @@ -4726,20 +4766,18 @@ public synchronized void actionPerformed(ActionEvent ev) { // to our local list of loaded units, and then stop. Entity other = getTowedUnit(); if (other != null) { - cmd.addStep(MoveStepType.TOW); - updateMove(cmd); + addStepToMovePath(MoveStepType.TOW); } // else - didn't find a unit to tow } else if (actionCmd.equals(MoveCommand.MOVE_DISCONNECT.getCmd())) { // Ask the user if we're carrying multiple units. Entity other = getDisconnectedUnit(); if (other != null) { - cmd.addStep(MoveStepType.DISCONNECT, other); - updateMove(cmd); + addStepToMovePath(MoveStepType.DISCONNECT, other); } // else - didn't find a unit to tow } else if (actionCmd.equals(MoveCommand.MOVE_MOUNT.getCmd())) { Entity other = getMountedUnit(); if (other != null) { - cmd.addStep(MoveStepType.MOUNT, other); + addStepToMovePath(MoveStepType.MOUNT, other); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_UNLOAD.getCmd())) { @@ -4754,20 +4792,17 @@ public synchronized void actionPerformed(ActionEvent ev) { // set other's position and end this turn - the // unloading unit will get // another turn for further unloading later - cmd.addStep(MoveStepType.UNLOAD, other, pos); - updateMove(cmd); + addStepToMovePath(MoveStepType.UNLOAD, other, pos); ready(); } } else { // some different handling for small craft/dropship // unloading - cmd.addStep(MoveStepType.UNLOAD, other); - updateMove(cmd); + addStepToMovePath(MoveStepType.UNLOAD, other); } } // else - Player canceled the unload. } else if (actionCmd.equals(MoveCommand.MOVE_RAISE_ELEVATION.getCmd())) { - cmd.addStep(MoveStepType.UP); - updateMove(cmd); + addStepToMovePath(MoveStepType.UP); } else if (actionCmd.equals(MoveCommand.MOVE_LOWER_ELEVATION.getCmd())) { if (ce.isAero() && (null != cmd.getLastStep()) @@ -4775,10 +4810,9 @@ public synchronized void actionPerformed(ActionEvent ev) { && (cmd.getLastStep().getVelocity() < 12) && !(((IAero) ce).isSpheroid() || clientgui.getClient() .getGame().getPlanetaryConditions().isVacuum())) { - cmd.addStep(MoveStepType.ACC, true); + addStepToMovePath(MoveStepType.ACC, true); } - cmd.addStep(MoveStepType.DOWN); - updateMove(cmd); + addStepToMovePath(MoveStepType.DOWN); } else if (actionCmd.equals(MoveCommand.MOVE_CLIMB_MODE.getCmd())) { MoveStep ms = cmd.getLastStep(); if ((ms != null) @@ -4791,16 +4825,15 @@ public synchronized void actionPerformed(ActionEvent ev) { // This affects how the StepSprite gets rendered, so it's more clear to keep a climb step // once one has been added if (lastStep.getType() == MoveStepType.CLIMB_MODE_ON) { - cmd.addStep(MoveStepType.CLIMB_MODE_OFF); + addStepToMovePath(MoveStepType.CLIMB_MODE_OFF); } else { - cmd.addStep(MoveStepType.CLIMB_MODE_ON); + addStepToMovePath(MoveStepType.CLIMB_MODE_ON); } } else if (cmd.getFinalClimbMode()) { - cmd.addStep(MoveStepType.CLIMB_MODE_OFF); + addStepToMovePath(MoveStepType.CLIMB_MODE_OFF); } else { - cmd.addStep(MoveStepType.CLIMB_MODE_ON); + addStepToMovePath(MoveStepType.CLIMB_MODE_ON); } - updateMove(cmd); computeMovementEnvelope(ce); } else if (actionCmd.equals(MoveCommand.MOVE_LAY_MINE.getCmd())) { int i = chooseMineToLay(); @@ -4815,64 +4848,53 @@ public synchronized void actionPerformed(ActionEvent ev) { if (cmd.getLastStep() == null && ce instanceof BattleArmor && ce.getMovementMode().equals(EntityMovementMode.INF_JUMP)) { - cmd.addStep(MoveStepType.START_JUMP); + addStepToMovePath(MoveStepType.START_JUMP); gear = GEAR_JUMP; Color jumpColor = GUIP.getMoveJumpColor(); clientgui.getBoardView().setHighlightColor(jumpColor); computeMovementEnvelope(ce); } - cmd.addStep(MoveStepType.LAY_MINE, i); - updateMove(cmd); + addStepToMovePath(MoveStepType.LAY_MINE, i); } } else if (actionCmd.equals(MoveCommand.MOVE_CALL_SUPPORT.getCmd())) { ((Infantry) ce).createLocalSupport(); clientgui.getClient().sendUpdateEntity(ce()); } else if (actionCmd.equals(MoveCommand.MOVE_DIG_IN.getCmd())) { - cmd.addStep(MoveStepType.DIG_IN); - updateMove(cmd); + addStepToMovePath(MoveStepType.DIG_IN); } else if (actionCmd.equals(MoveCommand.MOVE_FORTIFY.getCmd())) { - cmd.addStep(MoveStepType.FORTIFY); - updateMove(cmd); + addStepToMovePath(MoveStepType.FORTIFY); } else if (actionCmd.equals(MoveCommand.MOVE_TAKE_COVER.getCmd())) { - cmd.addStep(MoveStepType.TAKE_COVER); - updateMove(cmd); + addStepToMovePath(MoveStepType.TAKE_COVER); } else if (actionCmd.equals(MoveCommand.MOVE_SHAKE_OFF.getCmd())) { - cmd.addStep(MoveStepType.SHAKE_OFF_SWARMERS); - updateMove(cmd); + addStepToMovePath(MoveStepType.SHAKE_OFF_SWARMERS); } else if (actionCmd.equals(MoveCommand.MOVE_RECKLESS.getCmd())) { cmd.setCareful(false); } else if (actionCmd.equals(MoveCommand.MOVE_STRAFE.getCmd())) { gear = GEAR_STRAFE; } else if (actionCmd.equals(MoveCommand.MOVE_BOMB.getCmd())) { if (cmd.getLastStep() == null) { - cmd.addStep(MoveStepType.NONE); + addStepToMovePath(MoveStepType.NONE); } cmd.setVTOLBombStep(cmd.getFinalCoords()); cmd.compile(clientgui.getClient().getGame(), ce, false); - updateMove(cmd); + updateMove(); } else if (actionCmd.equals(MoveCommand.MOVE_ACCN.getCmd())) { - cmd.addStep(MoveStepType.ACCN); - updateMove(cmd); + addStepToMovePath(MoveStepType.ACCN); } else if (actionCmd.equals(MoveCommand.MOVE_DECN.getCmd())) { - cmd.addStep(MoveStepType.DECN); - updateMove(cmd); + addStepToMovePath(MoveStepType.DECN); } else if (actionCmd.equals(MoveCommand.MOVE_ACC.getCmd())) { - cmd.addStep(MoveStepType.ACC); - updateMove(cmd); + addStepToMovePath(MoveStepType.ACC); } else if (actionCmd.equals(MoveCommand.MOVE_DEC.getCmd())) { - cmd.addStep(MoveStepType.DEC); - updateMove(cmd); + addStepToMovePath(MoveStepType.DEC); } else if (actionCmd.equals(MoveCommand.MOVE_EVADE.getCmd())) { - cmd.addStep(MoveStepType.EVADE); - updateMove(cmd); + addStepToMovePath(MoveStepType.EVADE); } else if (actionCmd.equals(MoveCommand.MOVE_BOOTLEGGER.getCmd())) { - cmd.addStep(MoveStepType.BOOTLEGGER); - updateMove(cmd); + addStepToMovePath(MoveStepType.BOOTLEGGER); } else if (actionCmd.equals(MoveCommand.MOVE_SHUTDOWN.getCmd())) { if (clientgui.doYesNoDialog( Messages.getString("MovementDisplay.ShutdownDialog.title"), Messages.getString("MovementDisplay.ShutdownDialog.message"))) { - cmd.addStep(MoveStepType.SHUTDOWN); + addStepToMovePath(MoveStepType.SHUTDOWN); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_STARTUP.getCmd())) { @@ -4880,31 +4902,28 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.StartupDialog.title"), Messages.getString("MovementDisplay.StartupDialog.message"))) { clear(); - cmd.addStep(MoveStepType.STARTUP); + addStepToMovePath(MoveStepType.STARTUP); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_SELF_DESTRUCT.getCmd())) { if (clientgui.doYesNoDialog( Messages.getString("MovementDisplay.SelfDestructDialog.title"), Messages.getString("MovementDisplay.SelfDestructDialog.message"))) { - cmd.addStep(MoveStepType.SELF_DESTRUCT); + addStepToMovePath(MoveStepType.SELF_DESTRUCT); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_EVADE_AERO.getCmd())) { - cmd.addStep(MoveStepType.EVADE); - updateMove(cmd); + addStepToMovePath(MoveStepType.EVADE); setEvadeAeroEnabled(false); } else if (actionCmd.equals(MoveCommand.MOVE_ROLL.getCmd())) { - cmd.addStep(MoveStepType.ROLL); - updateMove(cmd); + addStepToMovePath(MoveStepType.ROLL); } else if (actionCmd.equals(MoveCommand.MOVE_HOVER.getCmd())) { - cmd.addStep(MoveStepType.HOVER); + addStepToMovePath(MoveStepType.HOVER); if (ce instanceof LandAirMech && ce.getMovementMode() == EntityMovementMode.WIGE && ce.isAirborne()) { gear = GEAR_LAND; } - updateMove(cmd); } else if (actionCmd.equals(MoveCommand.MOVE_MANEUVER.getCmd())) { ManeuverChoiceDialog choiceDialog = new ManeuverChoiceDialog( clientgui.frame, @@ -4934,20 +4953,15 @@ public synchronized void actionPerformed(ActionEvent ev) { distance, clientgui.getClient().getGame(), cmd); choiceDialog.setVisible(true); int manType = choiceDialog.getChoice(); - if ((manType > ManeuverType.MAN_NONE) && addManeuver(manType)) { - updateMove(cmd); - } + updateMove((manType > ManeuverType.MAN_NONE) && addManeuver(manType)); } else if (actionCmd.equals(MoveCommand.MOVE_LAUNCH.getCmd())) { TreeMap> undocked = getUndockedUnits(); if (!undocked.isEmpty()) { - cmd.addStep(MoveStepType.UNDOCK, undocked); + addStepToMovePath(MoveStepType.UNDOCK, undocked); } TreeMap> launched = getLaunchedUnits(); if (!launched.isEmpty()) { - cmd.addStep(MoveStepType.LAUNCH, launched); - } - if (!launched.isEmpty() || !undocked.isEmpty()) { - updateMove(cmd); + addStepToMovePath(MoveStepType.LAUNCH, launched); } } else if (actionCmd.equals(MoveCommand.MOVE_RECOVER.getCmd()) || actionCmd.equals(MoveCommand.MOVE_DOCK.getCmd())) { @@ -4955,8 +4969,7 @@ public synchronized void actionPerformed(ActionEvent ev) { // then bring up an option dialog int recoverer = getRecoveryUnit(); if (recoverer != -1) { - cmd.addStep(MoveStepType.RECOVER, recoverer, -1); - updateMove(cmd); + addStepToMovePath(MoveStepType.RECOVER, recoverer, -1); } if (actionCmd.equals(MoveCommand.MOVE_DOCK.getCmd())) { cmd.getLastStep().setDocking(true); @@ -4964,33 +4977,25 @@ public synchronized void actionPerformed(ActionEvent ev) { } else if (actionCmd.equals(MoveCommand.MOVE_DROP.getCmd())) { TreeMap> dropped = getDroppedUnits(); if (!dropped.isEmpty()) { - cmd.addStep(MoveStepType.DROP, dropped); - updateMove(cmd); + addStepToMovePath(MoveStepType.DROP, dropped); } } else if (actionCmd.equals(MoveCommand.MOVE_JOIN.getCmd())) { // if more than one unit is available as a carrier // then bring up an option dialog int joined = getUnitJoined(); if (joined != -1) { - cmd.addStep(MoveStepType.JOIN, joined, -1); - updateMove(cmd); + addStepToMovePath(MoveStepType.JOIN, joined, -1); } } else if (actionCmd.equals(MoveCommand.MOVE_TURN_LEFT.getCmd())) { - cmd.addStep(MoveStepType.TURN_LEFT); - updateMove(cmd); + addStepToMovePath(MoveStepType.TURN_LEFT); } else if (actionCmd.equals(MoveCommand.MOVE_TURN_RIGHT.getCmd())) { - cmd.addStep(MoveStepType.TURN_RIGHT); - updateMove(cmd); + addStepToMovePath(MoveStepType.TURN_RIGHT); } else if (actionCmd.equals(MoveCommand.MOVE_THRUST.getCmd())) { - cmd.addStep(MoveStepType.THRUST); - updateMove(cmd); + addStepToMovePath(MoveStepType.THRUST); } else if (actionCmd.equals(MoveCommand.MOVE_YAW.getCmd())) { - cmd.addStep(MoveStepType.YAW); - updateMove(cmd); + addStepToMovePath(MoveStepType.YAW); } else if (actionCmd.equals(MoveCommand.MOVE_END_OVER.getCmd())) { - cmd.addStep(MoveStepType.YAW); - cmd.addStep(MoveStepType.ROLL); - updateMove(cmd); + addStepsToMovePath(MoveStepType.YAW, MoveStepType.ROLL); } else if (actionCmd.equals(MoveCommand.MOVE_DUMP.getCmd())) { dumpBombs(); } else if (actionCmd.equals(MoveCommand.MOVE_TAKE_OFF.getCmd())) { @@ -5007,7 +5012,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.TakeOffDialog.title"), Messages.getString("MovementDisplay.TakeOffDialog.message"))) { clear(); - cmd.addStep(MoveStepType.TAKEOFF); + addStepToMovePath(MoveStepType.TAKEOFF); ready(); } } @@ -5016,7 +5021,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.TakeOffDialog.title"), Messages.getString("MovementDisplay.TakeOffDialog.message"))) { clear(); - cmd.addStep(MoveStepType.VTAKEOFF); + addStepToMovePath(MoveStepType.VTAKEOFF); ready(); } } else if (actionCmd.equals(MoveCommand.MOVE_LAND.getCmd())) { @@ -5031,7 +5036,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.LandDialog.title"), Messages.getString("MovementDisplay.LandDialog.message"))) { clear(); - cmd.addStep(MoveStepType.LAND); + addStepToMovePath(MoveStepType.LAND); ready(); } } @@ -5047,7 +5052,7 @@ public synchronized void actionPerformed(ActionEvent ev) { Messages.getString("MovementDisplay.LandDialog.title"), Messages.getString("MovementDisplay.LandDialog.message"))) { clear(); - cmd.addStep(MoveStepType.VLAND); + addStepToMovePath(MoveStepType.VLAND); ready(); } } @@ -5169,13 +5174,14 @@ private void adjustConvertSteps(EntityMovementMode endMode) { } clear(); ce().setConvertingNow(true); - cmd.addStep(MoveStepType.CONVERT_MODE); + addStepToMovePath(MoveStepType.CONVERT_MODE); if (cmd.getFinalConversionMode() != endMode) { - cmd.addStep(MoveStepType.CONVERT_MODE); + addStepToMovePath(MoveStepType.CONVERT_MODE); } if (ce() instanceof Mech && ((Mech) ce()).hasTracks()) { ce().setMovementMode(endMode); } + updateMove(); } /** From bae067d9fdfe6f4fe33dd8ad5df3f40995451a03 Mon Sep 17 00:00:00 2001 From: "DESKTOP-C2SG422\\Tim" Date: Mon, 5 Jun 2023 18:48:18 -0700 Subject: [PATCH 3/3] torso twist does not trigger Done --- .../src/megamek/client/ui/swing/AttackPhaseDisplay.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/AttackPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/AttackPhaseDisplay.java index 8da94e4b28f..e1689a9ce60 100644 --- a/megamek/src/megamek/client/ui/swing/AttackPhaseDisplay.java +++ b/megamek/src/megamek/client/ui/swing/AttackPhaseDisplay.java @@ -50,7 +50,12 @@ protected AttackPhaseDisplay(ClientGUI cg) { @Override protected void updateDonePanel() { - updateDonePanelButtons(getDoneButtonLabel(), getSkipTurnButtonLabel(), !attacks.isEmpty()); + if (attacks.isEmpty() || (attacks.size() == 1 && attacks.firstElement() instanceof TorsoTwistAction)){ + // a torso twist alone should not trigger Done button + updateDonePanelButtons(getDoneButtonLabel(), getSkipTurnButtonLabel(), false); + } else { + updateDonePanelButtons(getDoneButtonLabel(), getSkipTurnButtonLabel(), true); + } } protected void removeAttack(Object o)