Skip to content

Commit

Permalink
Merge pull request #4939 from HoneySkull/general_tab_blank
Browse files Browse the repository at this point in the history
#4876 Fix Unit Display General tab rendered blank when switching units.
  • Loading branch information
NickAragua authored Dec 5, 2023
2 parents c045637 + 1832806 commit b7747cd
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,16 +751,16 @@ public synchronized void selectEntity(int en) {
cen = en;
clientgui.setSelectedEntityNum(en);
gear = MovementDisplay.GEAR_LAND;
Color walkColor = GUIP.getMoveDefaultColor();
clientgui.getBoardView().setHighlightColor(walkColor);

clientgui.getBoardView().setHighlightColor(GUIP.getMoveDefaultColor());
clear();

updateButtons();
updateButtonsLater();

clientgui.getBoardView().highlight(ce.getPosition());
clientgui.getBoardView().select(null);
clientgui.getBoardView().cursor(null);
clientgui.getUnitDisplay().displayEntity(ce);
clientgui.getUnitDisplay().showPanel("movement");
updateUnitDisplayLater(ce);
if (!clientgui.getBoardView().isMovingUnits()) {
clientgui.getBoardView().centerOnHex(ce.getPosition());
}
Expand Down Expand Up @@ -792,6 +792,36 @@ private boolean isEnabled(MoveCommand c) {
return buttons.get(c).isEnabled();
}

/**
* 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.
*/
private void updateUnitDisplayLater(Entity ce) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
clientgui.getUnitDisplay().displayEntity(ce);
clientgui.getUnitDisplay().showPanel("movement");
}
});
}

/**
* Sets buttons to their proper state, but lets Swing do this later after all the
* current BoardView repaints and updates are complete. This is done to prevent some
* buttons from painting correctly when the maps is zoomed way out. See Issue: #4444
*/
private void updateButtonsLater() {
SwingUtilities.invokeLater(new Runnable() {

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

/**
* Sets the buttons to their proper states
*/
Expand Down

0 comments on commit b7747cd

Please sign in to comment.