summaryrefslogtreecommitdiff
path: root/lisp/play/bubbles.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/play/bubbles.el')
-rw-r--r--lisp/play/bubbles.el156
1 files changed, 67 insertions, 89 deletions
diff --git a/lisp/play/bubbles.el b/lisp/play/bubbles.el
index dc93ef90310..e695a75e083 100644
--- a/lisp/play/bubbles.el
+++ b/lisp/play/bubbles.el
@@ -72,9 +72,6 @@
;;; Code:
-(defconst bubbles-version "0.5" "Version number of bubbles.el.")
-(make-obsolete-variable 'bubbles-version nil "28.1")
-
(require 'gamegrid)
;; User options
@@ -772,117 +769,46 @@ static char * dot3d_xpm[] = {
(defun bubbles-set-graphics-theme-ascii ()
"Set graphics theme to `ascii'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'ascii)
(bubbles--update-faces-or-images))
(defun bubbles-set-graphics-theme-circles ()
"Set graphics theme to `circles'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'circles)
(bubbles--initialize-images)
(bubbles--update-faces-or-images))
(defun bubbles-set-graphics-theme-squares ()
"Set graphics theme to `squares'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'squares)
(bubbles--initialize-images)
(bubbles--update-faces-or-images))
(defun bubbles-set-graphics-theme-diamonds ()
"Set graphics theme to `diamonds'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'diamonds)
(bubbles--initialize-images)
(bubbles--update-faces-or-images))
(defun bubbles-set-graphics-theme-balls ()
"Set graphics theme to `balls'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'balls)
(bubbles--initialize-images)
(bubbles--update-faces-or-images))
(defun bubbles-set-graphics-theme-emacs ()
"Set graphics theme to `emacs'."
- (interactive)
+ (interactive nil bubbles-mode)
(setq bubbles-graphics-theme 'emacs)
(bubbles--initialize-images)
(bubbles--update-faces-or-images))
-;; game theme menu
-(defvar bubbles-game-theme-menu
- (let ((menu (make-sparse-keymap "Game Theme")))
- (define-key menu [bubbles-set-game-userdefined]
- (list 'menu-item "User defined" 'bubbles-set-game-userdefined
- :button '(:radio . (eq bubbles-game-theme 'user-defined))))
- (define-key menu [bubbles-set-game-hard]
- (list 'menu-item "Hard" 'bubbles-set-game-hard
- :button '(:radio . (eq bubbles-game-theme 'hard))))
- (define-key menu [bubbles-set-game-difficult]
- (list 'menu-item "Difficult" 'bubbles-set-game-difficult
- :button '(:radio . (eq bubbles-game-theme 'difficult))))
- (define-key menu [bubbles-set-game-medium]
- (list 'menu-item "Medium" 'bubbles-set-game-medium
- :button '(:radio . (eq bubbles-game-theme 'medium))))
- (define-key menu [bubbles-set-game-easy]
- (list 'menu-item "Easy" 'bubbles-set-game-easy
- :button '(:radio . (eq bubbles-game-theme 'easy))))
- menu)
- "Map for bubbles game theme menu.")
-
-;; graphics theme menu
-(defvar bubbles-graphics-theme-menu
- (let ((menu (make-sparse-keymap "Graphics Theme")))
- (define-key menu [bubbles-set-graphics-theme-ascii]
- (list 'menu-item "ASCII" 'bubbles-set-graphics-theme-ascii
- :button '(:radio . (eq bubbles-graphics-theme 'ascii))))
- (define-key menu [bubbles-set-graphics-theme-emacs]
- (list 'menu-item "Emacs" 'bubbles-set-graphics-theme-emacs
- :button '(:radio . (eq bubbles-graphics-theme 'emacs))))
- (define-key menu [bubbles-set-graphics-theme-balls]
- (list 'menu-item "Balls" 'bubbles-set-graphics-theme-balls
- :button '(:radio . (eq bubbles-graphics-theme 'balls))))
- (define-key menu [bubbles-set-graphics-theme-diamonds]
- (list 'menu-item "Diamonds" 'bubbles-set-graphics-theme-diamonds
- :button '(:radio . (eq bubbles-graphics-theme 'diamonds))))
- (define-key menu [bubbles-set-graphics-theme-squares]
- (list 'menu-item "Squares" 'bubbles-set-graphics-theme-squares
- :button '(:radio . (eq bubbles-graphics-theme 'squares))))
- (define-key menu [bubbles-set-graphics-theme-circles]
- (list 'menu-item "Circles" 'bubbles-set-graphics-theme-circles
- :button '(:radio . (eq bubbles-graphics-theme 'circles))))
- menu)
- "Map for bubbles graphics theme menu.")
-
-;; menu
-(defvar bubbles-menu
- (let ((menu (make-sparse-keymap "Bubbles")))
- (define-key menu [bubbles-quit]
- (list 'menu-item "Quit" 'bubbles-quit))
- (define-key menu [bubbles]
- (list 'menu-item "New game" 'bubbles))
- (define-key menu [bubbles-separator-1]
- '("--"))
- (define-key menu [bubbles-save-settings]
- (list 'menu-item "Save all settings" 'bubbles-save-settings))
- (define-key menu [bubbles-customize]
- (list 'menu-item "Edit all settings" 'bubbles-customize))
- (define-key menu [bubbles-game-theme-menu]
- (list 'menu-item "Game Theme" bubbles-game-theme-menu))
- (define-key menu [bubbles-graphics-theme-menu]
- (list 'menu-item "Graphics Theme" bubbles-graphics-theme-menu
- :enable 'bubbles--playing))
- (define-key menu [bubbles-separator-2]
- '("--"))
- (define-key menu [bubbles-undo]
- (list 'menu-item "Undo last move" 'bubbles-undo
- :enable '(and bubbles--playing (listp buffer-undo-list))))
- menu)
- "Map for bubbles menu.")
-
-;; bubbles mode map
+
(defvar bubbles-mode-map
(let ((map (make-sparse-keymap 'bubbles-mode-map)))
;; (suppress-keymap map t)
@@ -897,12 +823,59 @@ static char * dot3d_xpm[] = {
(define-key map "n" 'next-line)
(define-key map "f" 'forward-char)
(define-key map "b" 'backward-char)
- ;; bind menu to mouse
- (define-key map [down-mouse-3] bubbles-menu)
- ;; Put menu in menu-bar
- (define-key map [menu-bar Bubbles] (cons "Bubbles" bubbles-menu))
map)
- "Mode map for bubbles.")
+ "Mode map for `bubbles'.")
+
+(easy-menu-define bubbles-menu bubbles-mode-map
+ "Menu for `bubbles'."
+ '("Bubbles"
+ ["Undo last move" bubbles-undo
+ :enable '(and bubbles--playing (listp buffer-undo-list))]
+ "---"
+ ("Graphics Theme"
+ :enable bubbles--playing
+ ["Circles" bubbles-set-graphics-theme-circles
+ :style radio
+ :selected (eq bubbles-graphics-theme 'circles)]
+ ["Squares" bubbles-set-graphics-theme-squares
+ :style radio
+ :selected (eq bubbles-graphics-theme 'squares)]
+ ["Diamonds" bubbles-set-graphics-theme-diamonds
+ :style radio
+ :selected (eq bubbles-graphics-theme 'diamonds)]
+ ["Balls" bubbles-set-graphics-theme-balls
+ :style radio
+ :selected (eq bubbles-graphics-theme 'balls)]
+ ["Emacs" bubbles-set-graphics-theme-emacs
+ :style radio
+ :selected (eq bubbles-graphics-theme 'emacs)]
+ ["ASCII" bubbles-set-graphics-theme-ascii
+ :style radio
+ :selected (eq bubbles-graphics-theme 'ascii)])
+ ("Game Theme"
+ ["Easy" bubbles-set-game-easy
+ :style radio
+ :selected (eq bubbles-game-theme 'easy)]
+ ["Medium" bubbles-set-game-medium
+ :style radio
+ :selected (eq bubbles-game-theme 'medium)]
+ ["Difficult" bubbles-set-game-difficult
+ :style radio
+ :selected (eq bubbles-game-theme 'difficult)]
+ ["Hard" bubbles-set-game-hard
+ :style radio
+ :selected (eq bubbles-game-theme 'hard)]
+ ["User defined" bubbles-set-game-userdefined
+ :style radio
+ :selected (eq bubbles-game-theme 'user-defined)])
+ ["Edit all settings" bubbles-customize]
+ ["Save all settings" bubbles-save-settings]
+ "---"
+ ["New game" bubbles]
+ ["Quit" bubbles-quit]))
+
+;; bind menu to mouse
+(define-key bubbles-mode-map [down-mouse-3] bubbles-menu)
(define-derived-mode bubbles-mode nil "Bubbles"
"Major mode for playing bubbles.
@@ -938,7 +911,7 @@ columns on its right towards the left.
(defun bubbles-quit ()
"Quit Bubbles."
- (interactive)
+ (interactive nil bubbles-mode)
(message "bubbles-quit")
(bury-buffer))
@@ -1189,7 +1162,7 @@ Use optional parameter POS instead of point if given."
(defun bubbles-plop ()
"Remove active bubbles region."
- (interactive)
+ (interactive nil bubbles-mode)
(when (and bubbles--playing
(> bubbles--neighborhood-score 0))
(setq bubbles--save-data (list bubbles--score (buffer-string)))
@@ -1273,7 +1246,7 @@ Use optional parameter POS instead of point if given."
(defun bubbles-undo ()
"Undo last move."
- (interactive)
+ (interactive nil bubbles-mode)
(when bubbles--save-data
(let ((inhibit-read-only t)
(pos (point)))
@@ -1429,6 +1402,11 @@ Return t if new char is non-empty."
(forward-char 1)))
(put-text-property (point-min) (point-max) 'pointer 'arrow)))))
+;; Obsolete.
+
+(defconst bubbles-version "0.5" "Version number of bubbles.el.")
+(make-obsolete-variable 'bubbles-version 'emacs-version "28.1")
+
(provide 'bubbles)
;;; bubbles.el ends here