aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2019-10-17 18:49:33 +0200
committerStefan Kangas2019-10-17 18:49:33 +0200
commitdc0a218f62cab2eea245b1d577e1edc8e474364e (patch)
tree06d346ec124c92c1c99cb365b6bb5cb194b484a3
parent96f959521996399b7d75132d9f913577ba59cfb5 (diff)
downloademacs-dc0a218f62cab2eea245b1d577e1edc8e474364e.tar.gz
emacs-dc0a218f62cab2eea245b1d577e1edc8e474364e.zip
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.
-rw-r--r--lisp/play/tetris.el42
1 files changed, 29 insertions, 13 deletions
diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el
index a797a26d597..b5b77721ece 100644
--- a/lisp/play/tetris.el
+++ b/lisp/play/tetris.el
@@ -272,13 +272,40 @@ each one of its four blocks.")
272 (define-key map [right] 'tetris-move-right) 272 (define-key map [right] 'tetris-move-right)
273 (define-key map [up] 'tetris-rotate-prev) 273 (define-key map [up] 'tetris-rotate-prev)
274 (define-key map [down] 'tetris-move-down) 274 (define-key map [down] 'tetris-move-down)
275 map)) 275 map)
276 "Keymap for Tetris games.")
276 277
277(defvar tetris-null-map 278(defvar tetris-null-map
278 (let ((map (make-sparse-keymap 'tetris-null-map))) 279 (let ((map (make-sparse-keymap 'tetris-null-map)))
279 (define-key map "n" 'tetris-start-game) 280 (define-key map "n" 'tetris-start-game)
280 (define-key map "q" 'quit-window) 281 (define-key map "q" 'quit-window)
281 map)) 282 map)
283 "Keymap for finished Tetris games.")
284
285(defconst tetris--menu-def
286 '("Tetris"
287 ["Start new game" tetris-start-game
288 :help "Start a new Tetris game"]
289 ["End game" tetris-end-game
290 :active (tetris-active-p)
291 :help "End the current Tetris game"]
292 ["Pause" tetris-pause-game
293 :active (and (tetris-active-p) (not tetris-paused))
294 :help "Pause running Tetris game"]
295 ["Resume" tetris-pause-game
296 :active (and (tetris-active-p) tetris-paused)
297 :help "Resume paused Tetris game"])
298 "Menu for `tetris'. Used to initialize menus.")
299
300(easy-menu-define
301 tetris-mode-menu tetris-mode-map
302 "Menu for running Tetris games."
303 tetris--menu-def)
304
305(easy-menu-define
306 tetris-null-menu tetris-null-map
307 "Menu for finished Tetris games."
308 tetris--menu-def)
282 309
283;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 310;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
284 311
@@ -599,17 +626,6 @@ Drops the shape one square, testing for collision."
599 626
600 (use-local-map tetris-null-map) 627 (use-local-map tetris-null-map)
601 628
602 (unless (featurep 'emacs)
603 (setq mode-popup-menu
604 '("Tetris Commands"
605 ["Start new game" tetris-start-game]
606 ["End game" tetris-end-game
607 (tetris-active-p)]
608 ["Pause" tetris-pause-game
609 (and (tetris-active-p) (not tetris-paused))]
610 ["Resume" tetris-pause-game
611 (and (tetris-active-p) tetris-paused)])))
612
613 (setq show-trailing-whitespace nil) 629 (setq show-trailing-whitespace nil)
614 630
615 (setq gamegrid-use-glyphs tetris-use-glyphs) 631 (setq gamegrid-use-glyphs tetris-use-glyphs)