Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import megamek.common.compute.Compute;
import megamek.common.compute.ComputeArc;
import megamek.common.enums.AimingMode;
import megamek.common.enums.ChargeLevel;
import megamek.common.enums.GamePhase;
import megamek.common.equipment.AmmoType;
import megamek.common.equipment.Mounted;
Expand All @@ -73,6 +72,7 @@
import megamek.common.options.OptionsConstants;
import megamek.common.rolls.TargetRoll;
import megamek.common.units.Entity;
import megamek.common.units.Tank;
import megamek.common.units.Targetable;
import megamek.common.weapons.Weapon;
import megamek.common.weapons.capitalWeapons.CapitalMissileWeapon;
Expand All @@ -97,6 +97,8 @@ public class PointblankShotDisplay extends FiringDisplay {
*/
public enum FiringCommand implements PhaseCommand {
FIRE_TWIST("fireTwist"),
FIRE_ROTATE_TURRET("fireRotateTurret"),
FIRE_ROTATE_TURRET_2("fireRotateTurret2"),
FIRE_FIRE("fireFire"),
FIRE_SKIP("fireSkip"),
FIRE_MODE("fireMode"),
Expand Down Expand Up @@ -310,6 +312,11 @@ protected ArrayList<MegaMekButton> getButtonList() {
|| cmd == FiringCommand.FIRE_CANCEL) {
continue;
}
// The rear-turret rotate button exists only for dual-turret vehicles, as in the firing phase.
if ((cmd == FiringCommand.FIRE_ROTATE_TURRET_2)
&& !((currentEntity() instanceof Tank tank) && !tank.hasNoDualTurret())) {
continue;
}

buttonList.add(buttons.get(cmd));
i++;
Expand Down Expand Up @@ -358,6 +365,8 @@ public void selectEntity(int en) {
&& currentEntity().getCrew().isActive());

setFlipArmsEnabled(currentEntity().canFlipArms());
// TW p.260 lets a hidden unit torso twist OR rotate its turret before the point-blank shot.
updateRotateTurret();
updateSearchlight();
} else {
logger.error("Tried to select non-existent entity {}", en);
Expand Down Expand Up @@ -859,6 +868,10 @@ public void actionPerformed(ActionEvent ev) {
nextWeapon();
} else if (ev.getActionCommand().equals(FiringCommand.FIRE_TWIST.getCmd())) {
twisting = true;
} else if (ev.getActionCommand().equals(FiringCommand.FIRE_ROTATE_TURRET.getCmd())) {
rotateSelectedMount();
} else if (ev.getActionCommand().equals(FiringCommand.FIRE_ROTATE_TURRET_2.getCmd())) {
rotateRearTurret();
} else if (ev.getActionCommand().equals(FiringCommand.FIRE_MORE.getCmd())) {
currentButtonGroup++;
currentButtonGroup %= numButtonGroups;
Expand Down Expand Up @@ -887,6 +900,24 @@ protected void setTwistEnabled(boolean enabled) {
clientgui.getMenuBar().setEnabled(FiringCommand.FIRE_TWIST.getCmd(), enabled);
}

@Override
protected void setRotateTurretLabel(boolean dualTurretTank) {
buttons.get(FiringCommand.FIRE_ROTATE_TURRET).setText(Messages.getString(
dualTurretTank ? "FiringDisplay.fireRotateTurretFront" : "FiringDisplay.fireRotateTurret"));
}

@Override
protected void setRotateTurretEnabled(boolean enabled) {
buttons.get(FiringCommand.FIRE_ROTATE_TURRET).setEnabled(enabled);
clientgui.getMenuBar().setEnabled(FiringCommand.FIRE_ROTATE_TURRET.getCmd(), enabled);
}

@Override
protected void setRotateRearTurretEnabled(boolean enabled) {
buttons.get(FiringCommand.FIRE_ROTATE_TURRET_2).setEnabled(enabled);
clientgui.getMenuBar().setEnabled(FiringCommand.FIRE_ROTATE_TURRET_2.getCmd(), enabled);
}

@Override
protected void setSkipEnabled(boolean enabled) {
buttons.get(FiringCommand.FIRE_SKIP).setEnabled(enabled);
Expand Down
Loading