Mercurial > emacs
annotate lisp/play/gamegrid.el @ 47860:621b10466c9a
(ff-related-file-alist): New alias.
(ff-find-related-file): New alias.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 14 Oct 2002 01:25:16 +0000 |
parents | 7e861822d947 |
children | 0d8b17d428b5 |
rev | line source |
---|---|
38425
c6e12c6b1498
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
22490
diff
changeset
|
1 ;;; gamegrid.el --- library for implementing grid-based games on Emacs |
22490 | 2 |
3 ;; Copyright (C) 1997, 1998 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Glynn Clements <glynn@sensei.co.uk> | |
6 ;; Version: 1.02 | |
7 ;; Created: 1997-08-13 | |
8 ;; Keywords: games | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 | |
38425
c6e12c6b1498
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
22490
diff
changeset
|
29 ;;; Code: |
c6e12c6b1498
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
22490
diff
changeset
|
30 |
22490 | 31 (eval-when-compile |
32 (require 'cl)) | |
33 | |
34 ;; ;;;;;;;;;;;;; buffer-local variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
35 | |
36 (defvar gamegrid-use-glyphs t | |
37 "Non-nil means use glyphs when available.") | |
38 | |
39 (defvar gamegrid-use-color t | |
40 "Non-nil means use color when available.") | |
41 | |
42 (defvar gamegrid-font "-*-courier-medium-r-*-*-*-140-100-75-*-*-iso8859-*" | |
43 "Name of the font used in X mode.") | |
44 | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
45 (defvar gamegrid-face nil |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
46 "Indicates the face to use as a default.") |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
47 (make-variable-buffer-local 'gamegrid-face) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
48 |
22490 | 49 (defvar gamegrid-display-options nil) |
50 | |
51 (defvar gamegrid-buffer-width 0) | |
52 (defvar gamegrid-buffer-height 0) | |
53 (defvar gamegrid-blank 0) | |
54 | |
55 (defvar gamegrid-timer nil) | |
56 | |
57 (defvar gamegrid-display-mode nil) | |
58 | |
59 (defvar gamegrid-display-table) | |
60 | |
61 (defvar gamegrid-face-table nil) | |
62 | |
63 (defvar gamegrid-buffer-start 1) | |
64 | |
65 (defvar gamegrid-score-file-length 50 | |
66 "Number of high scores to keep") | |
67 | |
45085
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
68 (defvar gamegrid-user-score-file-directory "~/.emacs.d/games" |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
69 "A directory for game scores which can't be shared. |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
70 If Emacs was built without support for shared game scores, then this |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
71 directory will be used.") |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
72 |
22490 | 73 (make-variable-buffer-local 'gamegrid-use-glyphs) |
74 (make-variable-buffer-local 'gamegrid-use-color) | |
75 (make-variable-buffer-local 'gamegrid-font) | |
76 (make-variable-buffer-local 'gamegrid-display-options) | |
77 (make-variable-buffer-local 'gamegrid-buffer-width) | |
78 (make-variable-buffer-local 'gamegrid-buffer-height) | |
79 (make-variable-buffer-local 'gamegrid-blank) | |
80 (make-variable-buffer-local 'gamegrid-timer) | |
81 (make-variable-buffer-local 'gamegrid-display-mode) | |
82 (make-variable-buffer-local 'gamegrid-display-table) | |
83 (make-variable-buffer-local 'gamegrid-face-table) | |
84 (make-variable-buffer-local 'gamegrid-buffer-start) | |
85 (make-variable-buffer-local 'gamegrid-score-file-length) | |
86 | |
87 ;; ;;;;;;;;;;;;; global variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
88 | |
89 (defvar gamegrid-grid-x-face nil) | |
90 (defvar gamegrid-mono-x-face nil) | |
91 (defvar gamegrid-mono-tty-face nil) | |
92 | |
93 ;; ;;;;;;;;;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
94 | |
95 (defconst gamegrid-glyph-height 16) | |
96 | |
97 (defconst gamegrid-xpm "\ | |
98 /* XPM */ | |
99 static char *noname[] = { | |
100 /* width height ncolors chars_per_pixel */ | |
101 \"16 16 3 1\", | |
102 /* colors */ | |
103 \"+ s col1\", | |
104 \". s col2\", | |
105 \"- s col3\", | |
106 /* pixels */ | |
107 \"---------------+\", | |
108 \"--------------++\", | |
109 \"--............++\", | |
110 \"--............++\", | |
111 \"--............++\", | |
112 \"--............++\", | |
113 \"--............++\", | |
114 \"--............++\", | |
115 \"--............++\", | |
116 \"--............++\", | |
117 \"--............++\", | |
118 \"--............++\", | |
119 \"--............++\", | |
120 \"--............++\", | |
121 \"-+++++++++++++++\", | |
122 \"++++++++++++++++\" | |
123 }; | |
124 " | |
125 "XPM format image used for each square") | |
126 | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
127 (defvar gamegrid-xbm "\ |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
128 /* gamegrid XBM */ |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
129 #define gamegrid_width 16 |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
130 #define gamegrid_height 16 |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
131 static unsigned char gamegrid_bits[] = { |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
132 0xff, 0xff, 0xff, 0x7f, 0xff, 0x3f, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a, |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
133 0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a, 0x57, 0x15, 0xaf, 0x0a, |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
134 0x57, 0x15, 0x07, 0x00, 0x03, 0x00, 0x01, 0x00 };" |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
135 "XBM format image used for each square.") |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
136 |
22490 | 137 ;; ;;;;;;;;;;;;;;;; miscellaneous functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
138 | |
139 (defsubst gamegrid-characterp (arg) | |
140 (if (fboundp 'characterp) | |
141 (characterp arg) | |
142 (integerp arg))) | |
143 | |
144 (defsubst gamegrid-event-x (event) | |
145 (if (fboundp 'event-x) | |
146 (event-x event) | |
147 (car (posn-col-row (event-end event))))) | |
148 | |
149 (defsubst gamegrid-event-y (event) | |
150 (if (fboundp 'event-y) | |
151 (event-y event) | |
152 (cdr (posn-col-row (event-end event))))) | |
153 | |
154 ;; ;;;;;;;;;;;;; display functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
155 | |
156 (defun gamegrid-color (color shade) | |
157 (let* ((v (floor (* shade 255))) | |
158 (r (* v (aref color 0))) | |
159 (g (* v (aref color 1))) | |
160 (b (* v (aref color 2)))) | |
161 (format "#%02x%02x%02x" r g b))) | |
162 | |
163 (defun gamegrid-set-font (face) | |
164 (if gamegrid-font | |
165 (condition-case nil | |
166 (set-face-font face gamegrid-font) | |
43651
3075554223d1
(gamegrid-set-font, gamegrid-setup-face)
Richard M. Stallman <rms@gnu.org>
parents:
43117
diff
changeset
|
167 (error nil)))) |
22490 | 168 |
169 (defun gamegrid-setup-face (face color) | |
170 (set-face-foreground face color) | |
171 (set-face-background face color) | |
172 (gamegrid-set-font face) | |
173 (condition-case nil | |
174 (set-face-background-pixmap face [nothing]);; XEmacs | |
43651
3075554223d1
(gamegrid-set-font, gamegrid-setup-face)
Richard M. Stallman <rms@gnu.org>
parents:
43117
diff
changeset
|
175 (error nil)) |
22490 | 176 (condition-case nil |
177 (set-face-background-pixmap face nil);; Emacs | |
43651
3075554223d1
(gamegrid-set-font, gamegrid-setup-face)
Richard M. Stallman <rms@gnu.org>
parents:
43117
diff
changeset
|
178 (error nil))) |
22490 | 179 |
180 (defun gamegrid-make-mono-tty-face () | |
181 (let ((face (make-face 'gamegrid-mono-tty-face))) | |
182 (condition-case nil | |
183 (set-face-property face 'reverse t) | |
43651
3075554223d1
(gamegrid-set-font, gamegrid-setup-face)
Richard M. Stallman <rms@gnu.org>
parents:
43117
diff
changeset
|
184 (error nil)) |
22490 | 185 face)) |
186 | |
187 (defun gamegrid-make-color-tty-face (color) | |
47380
05670dbe9339
(gamegrid-make-color-tty-face): Handle string as COLOR arg.
Richard M. Stallman <rms@gnu.org>
parents:
45085
diff
changeset
|
188 (let* ((color-str (if (symbolp color) (symbol-value color) color)) |
43117
7541bec297e3
(gamegrid-display-type): Treat any
Eli Zaretskii <eliz@gnu.org>
parents:
41560
diff
changeset
|
189 (name (intern (format "gamegrid-color-tty-face-%s" color-str))) |
22490 | 190 (face (make-face name))) |
43117
7541bec297e3
(gamegrid-display-type): Treat any
Eli Zaretskii <eliz@gnu.org>
parents:
41560
diff
changeset
|
191 (gamegrid-setup-face face color-str) |
22490 | 192 face)) |
193 | |
194 (defun gamegrid-make-grid-x-face () | |
195 (let ((face (make-face 'gamegrid-x-border-face))) | |
196 (gamegrid-set-font face) | |
197 face)) | |
198 | |
199 (defun gamegrid-make-mono-x-face () | |
200 (let ((face (make-face 'gamegrid-mono-x-face)) | |
201 (color (face-foreground 'default))) | |
202 (if (null color) | |
203 (setq color | |
204 (cdr-safe (assq 'foreground-color (frame-parameters))))) | |
205 (gamegrid-setup-face face color) | |
206 face)) | |
207 | |
208 (defun gamegrid-make-color-x-face (color) | |
209 (let* ((hex (gamegrid-color color 1.0)) | |
210 (name (intern (format "gamegrid-color-x-face-%s" hex))) | |
211 (face (make-face name))) | |
43117
7541bec297e3
(gamegrid-display-type): Treat any
Eli Zaretskii <eliz@gnu.org>
parents:
41560
diff
changeset
|
212 (gamegrid-setup-face face hex) |
22490 | 213 face)) |
214 | |
215 (defun gamegrid-make-face (data-spec-list color-spec-list) | |
216 (let ((data (gamegrid-match-spec-list data-spec-list)) | |
217 (color (gamegrid-match-spec-list color-spec-list))) | |
218 (case data | |
219 ('color-x | |
220 (gamegrid-make-color-x-face color)) | |
221 ('grid-x | |
222 (unless gamegrid-grid-x-face | |
223 (setq gamegrid-grid-x-face (gamegrid-make-grid-x-face))) | |
224 gamegrid-grid-x-face) | |
225 ('mono-x | |
226 (unless gamegrid-mono-x-face | |
227 (setq gamegrid-mono-x-face (gamegrid-make-mono-x-face))) | |
228 gamegrid-mono-x-face) | |
229 ('color-tty | |
230 (gamegrid-make-color-tty-face color)) | |
231 ('mono-tty | |
232 (unless gamegrid-mono-tty-face | |
233 (setq gamegrid-mono-tty-face (gamegrid-make-mono-tty-face))) | |
234 gamegrid-mono-tty-face)))) | |
235 | |
236 (defun gamegrid-colorize-glyph (color) | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
237 (find-image `((:type xpm :data ,gamegrid-xpm |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
238 :ascent center |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
239 :color-symbols |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
240 (("col1" . ,(gamegrid-color color 0.6)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
241 ("col2" . ,(gamegrid-color color 0.8)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
242 ("col3" . ,(gamegrid-color color 1.0)))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
243 (:type xbm :data ,gamegrid-xbm |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
244 :ascent center |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
245 :foreground ,(gamegrid-color color 1.0) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
246 :background ,(gamegrid-color color 0.5))))) |
22490 | 247 |
248 (defun gamegrid-match-spec (spec) | |
249 (let ((locale (car spec)) | |
250 (value (cadr spec))) | |
251 (and (or (eq locale t) | |
252 (and (listp locale) | |
253 (memq gamegrid-display-mode locale)) | |
254 (and (symbolp locale) | |
255 (eq gamegrid-display-mode locale))) | |
256 value))) | |
257 | |
258 (defun gamegrid-match-spec-list (spec-list) | |
259 (and spec-list | |
260 (or (gamegrid-match-spec (car spec-list)) | |
261 (gamegrid-match-spec-list (cdr spec-list))))) | |
262 | |
263 (defun gamegrid-make-glyph (data-spec-list color-spec-list) | |
264 (let ((data (gamegrid-match-spec-list data-spec-list)) | |
265 (color (gamegrid-match-spec-list color-spec-list))) | |
266 (cond ((gamegrid-characterp data) | |
267 (vector data)) | |
268 ((eq data 'colorize) | |
269 (gamegrid-colorize-glyph color)) | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
270 ((listp data) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
271 (find-image data)) ;untested! |
22490 | 272 ((vectorp data) |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
273 (gamegrid-make-image-from-vector data))))) |
22490 | 274 |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
275 (defun gamegrid-make-image-from-vector (vect) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
276 "Convert an XEmacs style \"glyph\" to an image-spec." |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
277 (let ((l (list 'image :type))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
278 (dotimes (n (length vect)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
279 (setf l (nconc l (list (aref vect n))))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
280 (nconc l (list :ascent 'center)))) |
22490 | 281 |
282 (defun gamegrid-display-type () | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
283 (cond ((and gamegrid-use-glyphs |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
284 (display-images-p)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
285 'glyph) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
286 ((and gamegrid-use-color |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
287 (display-graphic-p) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
288 (display-color-p)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
289 'color-x) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
290 ((display-graphic-p) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
291 'mono-x) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
292 ((and gamegrid-use-color |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
293 (display-color-p)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
294 'color-tty) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
295 ((display-multi-font-p) ;??? |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
296 'mono-tty) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
297 (t |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
298 'emacs-tty))) |
22490 | 299 |
300 (defun gamegrid-set-display-table () | |
301 (if (fboundp 'specifierp) | |
302 (add-spec-to-specifier current-display-table | |
303 gamegrid-display-table | |
304 (current-buffer) | |
305 nil | |
306 'remove-locale) | |
307 (setq buffer-display-table gamegrid-display-table))) | |
308 | |
309 (defun gamegrid-setup-default-font () | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
310 (setq gamegrid-face |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
311 (copy-face 'default |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
312 (intern (concat "gamegrid-face-" (buffer-name))))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
313 (when (eq gamegrid-display-mode 'glyph) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
314 (let ((max-height nil)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
315 (loop for c from 0 to 255 do |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
316 (let ((glyph (aref gamegrid-display-table c))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
317 (when (and (listp glyph) (eq (car glyph) 'image)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
318 (let ((height (cdr (image-size glyph)))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
319 (if (or (null max-height) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
320 (< max-height height)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
321 (setq max-height height)))))) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
322 (when (and max-height (< max-height 1)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
323 (set-face-attribute gamegrid-face nil :height max-height))))) |
22490 | 324 |
325 (defun gamegrid-initialize-display () | |
326 (setq gamegrid-display-mode (gamegrid-display-type)) | |
327 (setq gamegrid-display-table (make-display-table)) | |
328 (setq gamegrid-face-table (make-vector 256 nil)) | |
329 (loop for c from 0 to 255 do | |
330 (let* ((spec (aref gamegrid-display-options c)) | |
331 (glyph (gamegrid-make-glyph (car spec) (caddr spec))) | |
332 (face (gamegrid-make-face (cadr spec) (caddr spec)))) | |
333 (aset gamegrid-face-table c face) | |
334 (aset gamegrid-display-table c glyph))) | |
335 (gamegrid-setup-default-font) | |
336 (gamegrid-set-display-table) | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
337 (setq cursor-type nil)) |
22490 | 338 |
339 | |
340 (defun gamegrid-set-face (c) | |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
341 (if (eq gamegrid-display-mode 'glyph) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
342 (add-text-properties (1- (point)) (point) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
343 (list 'display (list (aref gamegrid-display-table c)))) |
22490 | 344 (put-text-property (1- (point)) |
345 (point) | |
346 'face | |
347 (aref gamegrid-face-table c)))) | |
348 | |
349 (defun gamegrid-cell-offset (x y) | |
350 (+ gamegrid-buffer-start | |
351 (* (1+ gamegrid-buffer-width) y) | |
352 x)) | |
353 | |
354 ;; ;;;;;;;;;;;;;;;; grid functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
355 | |
356 (defun gamegrid-get-cell (x y) | |
357 (char-after (gamegrid-cell-offset x y))) | |
358 | |
359 (defun gamegrid-set-cell (x y c) | |
360 (save-excursion | |
361 (let ((buffer-read-only nil)) | |
362 (goto-char (gamegrid-cell-offset x y)) | |
363 (delete-char 1) | |
364 (insert-char c 1) | |
365 (gamegrid-set-face c)))) | |
366 | |
367 (defun gamegrid-init-buffer (width height blank) | |
368 (setq gamegrid-buffer-width width | |
369 gamegrid-buffer-height height) | |
370 (let ((line (concat | |
371 (make-string width blank) | |
372 "\n")) | |
373 (buffer-read-only nil)) | |
374 (erase-buffer) | |
375 (setq gamegrid-buffer-start (point)) | |
376 (dotimes (i height) | |
41560
7428670426b2
(gamegrid-init-buffer): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents:
38425
diff
changeset
|
377 (insert line)) |
47587
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
378 ;; Adjust the height of the default face to the height of the |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
379 ;; images. Unlike XEmacs, Emacs doesn't allow to make the default |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
380 ;; face buffer-local; so we do this with an overlay. |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
381 (when (eq gamegrid-display-mode 'glyph) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
382 (overlay-put (make-overlay (point-min) (point-max)) |
7e861822d947
(gamegrid-face): new variable to emulate a buffer-local default face.
Richard M. Stallman <rms@gnu.org>
parents:
47380
diff
changeset
|
383 'face gamegrid-face)) |
22490 | 384 (goto-char (point-min)))) |
385 | |
386 (defun gamegrid-init (options) | |
387 (setq buffer-read-only t | |
388 truncate-lines t | |
389 gamegrid-display-options options) | |
390 (buffer-disable-undo (current-buffer)) | |
391 (gamegrid-initialize-display)) | |
392 | |
393 ;; ;;;;;;;;;;;;;;;; timer functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
394 | |
395 (defun gamegrid-start-timer (period func) | |
396 (setq gamegrid-timer | |
397 (if (featurep 'itimer) | |
398 (start-itimer "Gamegrid" | |
399 func | |
400 period | |
401 period | |
402 nil | |
403 t | |
404 (current-buffer)) | |
405 (run-with-timer period | |
406 period | |
407 func | |
408 (current-buffer))))) | |
409 | |
410 (defun gamegrid-set-timer (delay) | |
411 (if gamegrid-timer | |
412 (if (featurep 'itimer) | |
413 (set-itimer-restart gamegrid-timer delay) | |
414 (timer-set-time gamegrid-timer | |
415 (list (aref gamegrid-timer 1) | |
416 (aref gamegrid-timer 2) | |
417 (aref gamegrid-timer 3)) | |
418 delay)))) | |
419 | |
420 (defun gamegrid-kill-timer () | |
421 (if gamegrid-timer | |
422 (if (featurep 'itimer) | |
423 (delete-itimer gamegrid-timer) | |
424 (timer-set-time gamegrid-timer '(0 0 0) nil))) | |
425 (setq gamegrid-timer nil)) | |
426 | |
427 ;; ;;;;;;;;;;;;;;; high score functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
428 | |
429 (defun gamegrid-add-score (file score) | |
430 "Add the current score to the high score file." | |
44565
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
431 (case system-type |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
432 ((ms-dos windows-nt) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
433 (gamegrid-add-score-insecure file score)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
434 (t |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
435 (gamegrid-add-score-with-update-game-score file score)))) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
436 |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
437 (defun gamegrid-add-score-with-update-game-score (file score) |
44989
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
438 (let* ((result nil) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
439 (errbuf (generate-new-buffer " *update-game-score loss*")) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
440 (have-shared-game-dir |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
441 (not (zerop (logand (file-modes |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
442 (expand-file-name "update-game-score" |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
443 exec-directory)) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
444 #o4000)))) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
445 (target (if have-shared-game-dir |
45085
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
446 (expand-file-name file shared-game-score-directory) |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
447 (let ((f (expand-file-name |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
448 gamegrid-user-score-file-directory))) |
44989
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
449 (when (file-writable-p f) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
450 (unless (eq (car-safe (file-attributes f)) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
451 t) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
452 (make-directory f)) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
453 (setq f (expand-file-name file f)) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
454 (unless (file-exists-p f) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
455 (write-region "" nil f nil 'silent nil 'excl))) |
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
456 f)))) |
44483
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
457 (let ((default-directory "/")) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
458 (apply |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
459 'call-process |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
460 (append |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
461 (list |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
462 (expand-file-name "update-game-score" exec-directory) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
463 nil errbuf nil |
44989
78b836bc2213
(gamegrid-add-score-with-update-game-score): Test whether or not
Colin Walters <walters@gnu.org>
parents:
44792
diff
changeset
|
464 "-m" (int-to-string gamegrid-score-file-length) |
45085
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
465 "-d" (if have-shared-game-dir |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
466 (expand-file-name shared-game-score-directory) |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
467 (file-name-directory target)) |
9cd63d47f45f
(gamegrid-user-score-file-directory): New variable.
Colin Walters <walters@gnu.org>
parents:
44989
diff
changeset
|
468 file |
44483
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
469 (int-to-string score) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
470 (concat |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
471 (user-full-name) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
472 " <" |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
473 (cond ((fboundp 'user-mail-address) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
474 (user-mail-address)) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
475 ((boundp 'user-mail-address) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
476 user-mail-address) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
477 (t "")) |
366f1df9138b
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
Colin Walters <walters@gnu.org>
parents:
43651
diff
changeset
|
478 "> " |
44494 | 479 (current-time-string)))))) |
480 (if (buffer-modified-p errbuf) | |
481 (progn | |
482 (display-buffer errbuf) | |
483 (error "Failed to update game score file")) | |
484 (kill-buffer errbuf)) | |
485 (save-excursion | |
44792
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
486 (let ((buf (find-buffer-visiting target))) |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
487 (if buf |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
488 (progn |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
489 (with-current-buffer buf |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
490 (revert-buffer nil t nil)) |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
491 (display-buffer buf)) |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
492 (find-file-read-only-other-window target)))))) |
4648f6129f7f
(gamegrid-add-score-with-update-game-score): Handle the case where
Colin Walters <walters@gnu.org>
parents:
44565
diff
changeset
|
493 |
44565
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
494 (defun gamegrid-add-score-insecure (file score) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
495 (save-excursion |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
496 (setq file (expand-file-name file temporary-file-directory)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
497 (find-file-other-window file) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
498 (setq buffer-read-only nil) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
499 (goto-char (point-max)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
500 (insert (format "%05d\t%s\t%s <%s>\n" |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
501 score |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
502 (current-time-string) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
503 (user-full-name) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
504 (cond ((fboundp 'user-mail-address) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
505 (user-mail-address)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
506 ((boundp 'user-mail-address) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
507 user-mail-address) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
508 (t "")))) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
509 (sort-numeric-fields 1 (point-min) (point-max)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
510 (reverse-region (point-min) (point-max)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
511 (goto-line (1+ gamegrid-score-file-length)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
512 (delete-region (point) (point-max)) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
513 (setq buffer-read-only t) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
514 (save-buffer))) |
9bdd94e7a205
(gamegrid-add-score-with-update-game-score): Renamed from `gamegrid-add-score'.
Colin Walters <walters@gnu.org>
parents:
44494
diff
changeset
|
515 |
22490 | 516 |
517 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
518 | |
519 (provide 'gamegrid) | |
38425
c6e12c6b1498
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
22490
diff
changeset
|
520 |
c6e12c6b1498
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
22490
diff
changeset
|
521 ;;; gamegrid.el ends here |