Skip to content

Commit

Permalink
Fixing the gamepad input in the level up overlay (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt authored Nov 28, 2022
1 parent c120e5e commit 5fb5136
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class LevelUpOverlay extends WindowOverlay {
public LevelUpOverlay(Player player) {
this.player = player;
background = null;
canCancelOverlay = false; // Don't allow the gamepad to close this!
}

@Override
Expand Down Expand Up @@ -139,7 +140,7 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
Actions.fadeIn(0.2f),
Actions.moveTo(xLocation, 0, 0.1f + attributeNum * 0.1f, Interpolation.exp5),
Actions.delay(0.01f + (2 - attributeNum) * 0.9f),
Actions.addListener(cardClickListener, true)
Actions.addListener(cardClickListener, false)
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class GamepadEvent extends InputEvent {}
protected Array<Actor> buttonOrder = new Array<Actor>();
protected ArrayMap<Actor, Label> buttonLabels = new ArrayMap<Actor, Label>();

public boolean canCancelOverlay = true;
public boolean animateBackground = true;
public boolean animate = true;
protected int align = Align.center;
Expand Down Expand Up @@ -76,10 +77,11 @@ public void tick(float delta) {
controllerState = Game.gamepadManager.controllerState;

// Allow all overlays to be exited via the menu cancel button
if (Game.gamepadManager.controllerState.menuButtonEvents.contains(ControllerState.MenuButtons.CANCEL, true)) {
if (canCancelOverlay && Game.gamepadManager.controllerState.menuButtonEvents.contains(ControllerState.MenuButtons.CANCEL, true)) {
back();
Game.gamepadManager.controllerState.clearEvents();
Game.gamepadManager.controllerState.resetState();
return;
}

// Translate keyboard directions into gamepad directions
Expand Down

0 comments on commit 5fb5136

Please sign in to comment.