Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4876 Fix Unit Display General tab rendered blank when switching units. #4939

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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