Hrvoje Niksic wrote:
> That breaks (FSF) Emacs compatibility. Is there an equivalent
Emacs
> function.
They don't need a function because they cannot have simultaneous TTY
and window-system frames. This is why `window-system' suffices for
FSFmacs.
> Or should I define:
>
> (defun gamegrid-window-system-p ()
> (if (fboundp 'console-on-window-system-p)
> (console-on-window-system-p)
> window-system))
This looks good to me.
Actually, the there was only one function that would have used it, so
I just used a let instead.
The attached patch is against the version in games-1.01. It includes a
fix to the font-size calculation (which may have already been applied;
I can't remember). It also includes a couple of functions which are
used for mouse operation of Sokoban (I guess I should just submit that
rather than waiting until I get around to implementing `undo').
--
Glynn Clements <glynn(a)sensei.co.uk>
--- /usr/local/lib/xemacs/packages/lisp/games/gamegrid.el Wed Jan 7 18:35:26 1998
+++ gamegrid.el Thu Apr 30 22:03:46 1998
@@ -3,7 +3,7 @@
;; Copyright (C) 1997 Glynn Clements <glynn(a)sensei.co.uk>
;; Author: Glynn Clements <glynn(a)sensei.co.uk>
-;; Version: 1.0
+;; Version: 1.01
;; Created: 1997-08-13
;; Keywords: games
@@ -28,6 +28,8 @@
;;; Commentary:
+;; Modified: 1998-01-27, added gamegrid-event-x/y
+
;; URL: ftp://sensei.co.uk/misc/elisp-games.tar.gz
;; Tested with XEmacs 20.3/4/5 and Emacs 19.34
@@ -125,6 +127,16 @@
(characterp arg)
(integerp arg)))
+(defsubst gamegrid-event-x (event)
+ (if (fboundp 'event-x)
+ (event-x event)
+ (car (posn-col-row (event-end event)))))
+
+(defsubst gamegrid-event-y (event)
+ (if (fboundp 'event-y)
+ (event-y event)
+ (cdr (posn-col-row (event-end event)))))
+
;; ;;;;;;;;;;;;; display functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun gamegrid-color (color shade)
@@ -247,23 +259,27 @@
(eq (cdr-safe (assq 'display-type (frame-parameters))) 'color)))
(defun gamegrid-display-type ()
- (cond ((and gamegrid-use-glyphs
- (eq window-system 'x)
- (featurep 'xpm))
- 'glyph)
- ((and gamegrid-use-color
- (eq window-system 'x)
- (gamegrid-color-display-p))
- 'color-x)
- ((eq window-system 'x)
- 'mono-x)
- ((and gamegrid-use-color
- (gamegrid-color-display-p))
- 'color-tty)
- ((fboundp 'set-face-property)
- 'mono-tty)
- (t
- 'emacs-tty)))
+ (let ((window-system-p
+ (or (and (fboundp 'console-on-window-system-p)
+ (console-on-window-system-p))
+ window-system)))
+ (cond ((and gamegrid-use-glyphs
+ window-system-p
+ (featurep 'xpm))
+ 'glyph)
+ ((and gamegrid-use-color
+ window-system-p
+ (gamegrid-color-display-p))
+ 'color-x)
+ (window-system-p
+ 'mono-x)
+ ((and gamegrid-use-color
+ (gamegrid-color-display-p))
+ 'color-tty)
+ ((fboundp 'set-face-property)
+ 'mono-tty)
+ (t
+ 'emacs-tty))))
(defun gamegrid-set-display-table ()
(if (fboundp 'specifierp)
@@ -291,8 +307,8 @@
(< max-height height))
(setq max-height height)))))))
(if max-height
- (while (> (font-height font-spec) max-height)
- (setq name (x-find-smaller-font name))
+ (while (and (> (font-height font-spec) max-height)
+ (setq name (x-find-smaller-font name)))
(add-spec-to-specifier font-spec name (current-buffer))))))))
(defun gamegrid-initialize-display ()