annotate lisp/play/gamegrid.el @ 47386:18dd2c15c04c

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