Port tetris menu to Emacs

* lisp/play/tetris.el (tetris--menu-def): New constant.
(tetris-mode-menu, tetris-null-menu): Add a menu.
(tetris-mode): Remove XEmacs compat code.
(tetris-null-map, tetris-mode-map): Add docstring.
This commit is contained in:
Stefan Kangas 2019-10-17 18:49:33 +02:00
parent 96f9595219
commit dc0a218f62

View file

@ -272,13 +272,40 @@ each one of its four blocks.")
(define-key map [right] 'tetris-move-right)
(define-key map [up] 'tetris-rotate-prev)
(define-key map [down] 'tetris-move-down)
map))
map)
"Keymap for Tetris games.")
(defvar tetris-null-map
(let ((map (make-sparse-keymap 'tetris-null-map)))
(define-key map "n" 'tetris-start-game)
(define-key map "q" 'quit-window)
map))
map)
"Keymap for finished Tetris games.")
(defconst tetris--menu-def
'("Tetris"
["Start new game" tetris-start-game
:help "Start a new Tetris game"]
["End game" tetris-end-game
:active (tetris-active-p)
:help "End the current Tetris game"]
["Pause" tetris-pause-game
:active (and (tetris-active-p) (not tetris-paused))
:help "Pause running Tetris game"]
["Resume" tetris-pause-game
:active (and (tetris-active-p) tetris-paused)
:help "Resume paused Tetris game"])
"Menu for `tetris'. Used to initialize menus.")
(easy-menu-define
tetris-mode-menu tetris-mode-map
"Menu for running Tetris games."
tetris--menu-def)
(easy-menu-define
tetris-null-menu tetris-null-map
"Menu for finished Tetris games."
tetris--menu-def)
;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -599,17 +626,6 @@ Drops the shape one square, testing for collision."
(use-local-map tetris-null-map)
(unless (featurep 'emacs)
(setq mode-popup-menu
'("Tetris Commands"
["Start new game" tetris-start-game]
["End game" tetris-end-game
(tetris-active-p)]
["Pause" tetris-pause-game
(and (tetris-active-p) (not tetris-paused))]
["Resume" tetris-pause-game
(and (tetris-active-p) tetris-paused)])))
(setq show-trailing-whitespace nil)
(setq gamegrid-use-glyphs tetris-use-glyphs)