Skip to content

Commit

Permalink
Merge pull request #5621 from SJuliez/always-renew-unit-display
Browse files Browse the repository at this point in the history
Renewing Unit Display and Keybinds in Physical Phase
  • Loading branch information
IllianiCBT authored Jun 23, 2024
2 parents 1a62656 + 6cda321 commit 07dfe9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions megamek/src/megamek/client/ui/swing/PhysicalDisplay.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.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
import megamek.client.ui.swing.widget.IndexedRadioButton;
import megamek.client.ui.swing.widget.MegamekButton;
import megamek.common.*;
Expand Down Expand Up @@ -127,6 +128,20 @@ public PhysicalDisplay(ClientGUI clientgui) {
setButtonsTooltips();

setupButtonPanel();

MegaMekController controller = clientgui.controller;

controller.registerCommandAction(KeyCommandBind.NEXT_UNIT, this,
() -> selectEntity(clientgui.getClient().getNextEntityNum(currentEntity)));
controller.registerCommandAction(KeyCommandBind.PREV_UNIT, this,
() -> selectEntity(clientgui.getClient().getPrevEntityNum(currentEntity)));
controller.registerCommandAction(KeyCommandBind.CANCEL, this::shouldPerformClearKeyCommand, this::clear);
}

protected boolean shouldPerformClearKeyCommand() {
return !clientgui.getBoardView().getChatterBoxActive()
&& !isIgnoringEvents()
&& isVisible();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boo
* Displays the specified entity in the panel.
*/
public void displayEntity(Entity en) {
if ((en == null) || (currentlyDisplaying == en)) {
if (en == null) {
return;
}
currentlyDisplaying = en;
Expand Down

0 comments on commit 07dfe9d

Please sign in to comment.