Skip to content

Commit

Permalink
Merge pull request #3955 from kuronekochomusuke/issue961
Browse files Browse the repository at this point in the history
fix #961
  • Loading branch information
NickAragua authored Nov 3, 2022
2 parents 40b6e39 + c5b1f0f commit 0b41a3f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
12 changes: 8 additions & 4 deletions megamek/src/megamek/client/ui/swing/FiringDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import megamek.client.event.BoardViewEvent;
import megamek.client.ui.Messages;
import megamek.client.ui.SharedUtility;
import megamek.client.ui.swing.unitDisplay.WeaponPanel;
import megamek.client.ui.swing.util.CommandAction;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
Expand Down Expand Up @@ -1867,18 +1868,21 @@ public void updateTarget() {
toHit = WeaponAttackAction.toHit(game, cen, target,
weaponId, ash.getAimingAt(), ash.getAimingMode(),
false);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName()
+ " (" + ash.getAimingLocation() + ")");

String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName() + " (" + ash.getAimingLocation() + ")");
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
} else {
toHit = WeaponAttackAction.toHit(game, cen, target, weaponId, Entity.LOC_NONE,
AimingMode.NONE, false);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName());
String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName());
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
}
ash.setPartialCover(toHit.getCover());
} else {
toHit = WeaponAttackAction.toHit(game, cen, target, weaponId,
Entity.LOC_NONE, AimingMode.NONE, false);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName());
String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName());
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
}
int effectiveDistance = Compute.effectiveDistance(game, ce(), target);
clientgui.getUnitDisplay().wPan.wRangeR.setText("" + effectiveDistance);
Expand Down
13 changes: 9 additions & 4 deletions megamek/src/megamek/client/ui/swing/PointblankShotDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import megamek.client.event.BoardViewEvent;
import megamek.client.ui.Messages;
import megamek.client.ui.swing.unitDisplay.WeaponPanel;
import megamek.client.ui.swing.util.CommandAction;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
Expand Down Expand Up @@ -810,20 +811,24 @@ public void updateTarget() {
toHit = WeaponAttackAction.toHit(game, cen, target,
weaponId, ash.getAimingAt(), ash.getAimingMode(),
false, false, null, null, false, true);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName() + " ("
+ ash.getAimingLocation() + ")");
String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName() + " (" + ash.getAimingLocation() + ")");
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
} else {
toHit = WeaponAttackAction.toHit(game, cen, target, weaponId, Entity.LOC_NONE,
AimingMode.NONE, false, false,
null, null, false, true);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName());

String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName());
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
}
ash.setPartialCover(toHit.getCover());
} else {
toHit = WeaponAttackAction.toHit(game, cen, target, weaponId, Entity.LOC_NONE,
AimingMode.NONE, false, false, null,
null, false, true);
clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName());

String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName());
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
}
int effectiveDistance = Compute.effectiveDistance(game, ce(), target);
clientgui.getUnitDisplay().wPan.wRangeR.setText("" + effectiveDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import megamek.client.ui.Messages;
import megamek.client.ui.SharedUtility;
import megamek.client.ui.swing.FiringDisplay.FiringCommand;
import megamek.client.ui.swing.unitDisplay.WeaponPanel;
import megamek.client.ui.swing.util.CommandAction;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
Expand Down Expand Up @@ -971,8 +972,9 @@ public void updateTarget() {
target.getTargetId(), weaponId, clientgui.getClient().getGame());
flightTimeText = String.format("(%d turns)", aaa.getTurnsTilHit());
}

clientgui.getUnitDisplay().wPan.wTargetR.setText(target.getDisplayName());

String t = String.format("<html><div WIDTH=%d>%s</div></html>", WeaponPanel.TARGET_DISPLAY_WIDTH, target.getDisplayName());
clientgui.getUnitDisplay().wPan.wTargetR.setText(t);
clientgui.getUnitDisplay().wPan.wRangeR.setText(String.format("%d %s", targetDistance, flightTimeText));

Game game = clientgui.getClient().getGame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ public void sort(Comparator<Mounted> comparator) {
private int minTopMargin = 8;
private int minLeftMargin = 8;

public static final int TARGET_DISPLAY_WIDTH = 200;

WeaponPanel(UnitDisplay unitDisplay) {

this.unitDisplay = unitDisplay;
Expand Down

0 comments on commit 0b41a3f

Please sign in to comment.