Allow undoing moves via backspace key

This commit is contained in:
Trevor Slocum 2024-09-16 17:04:07 -07:00
parent 25d2c6f11a
commit d19aeaef1b
2 changed files with 7 additions and 0 deletions

View file

@ -1,5 +1,7 @@
1.4.1:
- Fix locale detection on Windows and Linux
- Support undoing moves using backspace key
- Support confirming moves using enter key
1.4.0:
- Auto-scale font size to fit text

View file

@ -2221,6 +2221,11 @@ func (g *Game) handleInput(keys []ebiten.Key) error {
return nil
}
}
case ebiten.KeyBackspace:
if len(inputBuffer.Text()) == 0 && !g.board.gameState.Spectating && g.board.gameState.Turn == g.board.gameState.PlayerNumber && len(g.board.gameState.Moves) > 0 && !g.board.menuGrid.Visible() && !g.board.settingsGrid.Visible() && !g.board.changePasswordGrid.Visible() && !g.board.leaveGameGrid.Visible() {
g.board.selectUndo()
return nil
}
case ebiten.KeyEnter:
if g.board.changePasswordGrid.Visible() {
g.board.selectChangePassword()