Skip to content

Commit

Permalink
Fix stale label, minimap, and FOV on 'next unit'
Browse files Browse the repository at this point in the history
  • Loading branch information
HoneySkull committed Sep 15, 2024
1 parent 9108018 commit f8cac64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
32 changes: 12 additions & 20 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,17 @@ public synchronized void selectEntity(int en) {

currentEntity = en;
clientgui.setSelectedEntityNum(en);
gear = MovementDisplay.GEAR_LAND;
updateUnitDisplay(ce);

gear = MovementDisplay.GEAR_LAND;
clientgui.getBoardView().setHighlightColor(GUIP.getMoveDefaultColor());
clear();

clear();
updateButtonsLater();

clientgui.getBoardView().highlight(ce.getPosition());
clientgui.getBoardView().select(null);
clientgui.getBoardView().cursor(null);
updateUnitDisplayLater(ce);
if (!clientgui.getBoardView().isMovingUnits()) {
clientgui.getBoardView().centerOnHex(ce.getPosition());
}
Expand All @@ -682,6 +682,7 @@ public synchronized void selectEntity(int en) {
} else {
setStatusBarText(yourTurnMsg);
}

clientgui.clearFieldOfFire();
computeMovementEnvelope(ce);
updateMove();
Expand All @@ -697,21 +698,15 @@ private boolean isEnabled(MoveCommand c) {
}

/**
* Signals Unit Display to update later on the AWT event stack.
* See Issue:#4876 and #4444. This is done to prevent blank general tab when
* switching
* units when the map is zoomed all the way out.
* Updates the Unit Display Panels by selecting the current entity in the unit display
* and shows the MekPanelTabTrip if configured.
* @param ce
*/
private void updateUnitDisplayLater(Entity ce) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
clientgui.getUnitDisplay().displayEntity(ce);
if (GUIP.getMoveDisplayTabDuringMovePhases()) {
clientgui.getUnitDisplay().showPanel(MekPanelTabStrip.SUMMARY);
}
}
});
private void updateUnitDisplay(final Entity ce) {
clientgui.getUnitDisplay().displayEntity(ce);
if (GUIP.getMoveDisplayTabDuringMovePhases()) {
clientgui.getUnitDisplay().showPanel(MekPanelTabStrip.SUMMARY);
}
}

/**
Expand All @@ -724,13 +719,10 @@ public void run() {
*/
private void updateButtonsLater() {
SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
updateButtons();
}

;
});
}

Expand Down
10 changes: 5 additions & 5 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ public void redrawEntity(Entity entity) {
}

updateEcmList();
highlightSelectedEntity();
highlightSelectedEntity(getSelectedEntity());
scheduleRedraw();
}

Expand Down Expand Up @@ -3027,7 +3027,7 @@ void redrawAllEntities() {
// Update ECM list, to ensure that Sprites are updated with ECM info
updateEcmList();
// Re-highlight a selected entity, if present
highlightSelectedEntity();
highlightSelectedEntity(getSelectedEntity());

scheduleRedraw();
}
Expand Down Expand Up @@ -4094,9 +4094,9 @@ public void highlight(int x, int y) {
highlight(new Coords(x, y));
}

public synchronized void highlightSelectedEntity() {
public synchronized void highlightSelectedEntity(Entity e) {
for (EntitySprite sprite : entitySprites) {
sprite.setSelected(sprite.entity.equals(getSelectedEntity()));
sprite.setSelected(sprite.entity.equals(e));
}
}

Expand Down Expand Up @@ -4429,7 +4429,7 @@ public void run() {
public synchronized void selectEntity(Entity e) {
checkFoVHexImageCacheClear();
updateEcmList();
highlightSelectedEntity();
highlightSelectedEntity(e);
}

/**
Expand Down

0 comments on commit f8cac64

Please sign in to comment.