##// END OF EJS Templates
Bugfixes
naryl -
r41:097aa130 default
parent child Browse files
Show More
@@ -30,6 +30,9 b''
30 (defun make-menu-delimiter ()
30 (defun make-menu-delimiter ()
31 "<hr>")
31 "<hr>")
32
32
33 (defun copy-obj (obj)
34 (chain *j-s-o-n (parse (chain *j-s-o-n (stringify obj)))))
35
33 (defun report-error (text)
36 (defun report-error (text)
34 (alert text))
37 (alert text))
35
38
@@ -139,12 +142,15 b''
139 (setf name (chain name (to-upper-case)))
142 (setf name (chain name (to-upper-case)))
140 (with-frame
143 (with-frame
141 (with-call-args args
144 (with-call-args args
142 (funcall (getprop *locs name)))))
145 (funcall (getprop *locs name))))
146 (void))
143
147
144 (defun call-act (title)
148 (defun call-act (title)
145 (let ((*current-act title))
149 (setf *current-action title)
146 (with-frame
150 (with-frame
147 (funcall (getprop *acts title :act)))))
151 (funcall (getprop *acts title :act)))
152 (setf *current-action nil)
153 (void))
148
154
149 ;;; Text windows
155 ;;; Text windows
150
156
@@ -184,7 +190,7 b''
184 (create :title title :img img :act act :selected nil))
190 (create :title title :img img :act act :selected nil))
185 (update-acts))
191 (update-acts))
186
192
187 (defun del-act (title)
193 (defun del-act (&optional title)
188 (delete (getprop *acts (or title *current-action)))
194 (delete (getprop *acts (or title *current-action)))
189 (update-acts))
195 (update-acts))
190
196
@@ -225,7 +231,7 b''
225 v))
231 v))
226
232
227 (defun set-str-element (slot index value)
233 (defun set-str-element (slot index value)
228 (if (in index (getprop slot :indexes))
234 (if (has index (getprop slot :indexes))
229 (setf (elt (getprop slot)
235 (setf (elt (getprop slot)
230 (getprop slot :indexes index))
236 (getprop slot :indexes index))
231 value)
237 value)
@@ -16,12 +16,6 b''
16
16
17 ;;; 3expr
17 ;;; 3expr
18
18
19 (defpsmacro obj (name)
20 `(in ,name *objs))
21
22 (defpsmacro loc (name)
23 `(in ,name *locs))
24
25 (defpsmacro no (arg)
19 (defpsmacro no (arg)
26 `(- -1 ,arg))
20 `(- -1 ,arg))
27
21
@@ -115,7 +109,9 b''
115 `(api-call enable-frame :acts ,enable))
109 `(api-call enable-frame :acts ,enable))
116
110
117 (defpsmacro delact (&optional name)
111 (defpsmacro delact (&optional name)
118 `(api-call del-act ,name))
112 (if name
113 `(api-call del-act ,name)
114 `(api-call del-act)))
119
115
120 (defpsmacro cla ()
116 (defpsmacro cla ()
121 `(api-call clear-act))
117 `(api-call clear-act))
@@ -25,6 +25,12 b''
25
25
26 ;;; 3expr
26 ;;; 3expr
27
27
28 (defun obj (name)
29 (has name *objs))
30
31 (defun loc (name)
32 (has name *locs))
33
28 ;;; 4code
34 ;;; 4code
29
35
30 (defun rand (a &optional (b 1))
36 (defun rand (a &optional (b 1))
@@ -186,7 +192,7 b''
186 ;;; 14act
192 ;;; 14act
187
193
188 (defun curacts ()
194 (defun curacts ()
189 (let ((acts *acts))
195 (let ((acts (api-call copy-obj *acts)))
190 (lambda ()
196 (lambda ()
191 (setf *acts acts)
197 (setf *acts acts)
192 (void))))
198 (void))))
@@ -203,6 +209,7 b''
203
209
204 (defun delobj (name)
210 (defun delobj (name)
205 (delete (getprop *objs name))
211 (delete (getprop *objs name))
212 (api:update-objs)
206 (api-call call-serv-loc "$ONOBJDEL" name)
213 (api-call call-serv-loc "$ONOBJDEL" name)
207 (void))
214 (void))
208
215
@@ -1,12 +1,8 b''
1
1
2 (in-package sugar-qsp.main)
2 (in-package sugar-qsp.main)
3
3
4
5 (defpsmacro by-id (id)
6 `(chain document (get-element-by-id ,id)))
7
8 (defmacro+ps api-call (name &rest args)
4 (defmacro+ps api-call (name &rest args)
9 `(,(intern (string-upcase name) "API") ,@args))
5 `(,(intern (string-upcase name) "API") ,@args))
10
6
11 (defpsmacro in (key obj)
7 (defpsmacro has (key obj)
12 `(chain ,obj (has-own-property ,key)))
8 `(chain ,obj (has-own-property ,key)))
@@ -36,7 +36,6 b''
36 ;; Active locations
36 ;; Active locations
37 (var *locs (create))
37 (var *locs (create))
38
38
39 ;; Launch the game from the first location
40 (setf (@ window onload)
39 (setf (@ window onload)
41 (lambda ()
40 (lambda ()
42 (#.(intern "INIT-DOM" "SUGAR-QSP.API"))
41 (#.(intern "INIT-DOM" "SUGAR-QSP.API"))
@@ -49,3 +48,8 b''
49 (#.(intern "RUN-GAME" "SUGAR-QSP.API")
48 (#.(intern "RUN-GAME" "SUGAR-QSP.API")
50 (chain *object (keys *games) 0))
49 (chain *object (keys *games) 0))
51 (values)))
50 (values)))
51
52 ;;; Some very common utilities (for both api and lib)
53
54 (defun by-id (id)
55 (chain document (get-element-by-id id)))
@@ -6,7 +6,7 b''
6 (defpackage :sugar-qsp.main
6 (defpackage :sugar-qsp.main
7 (:use :cl :ps :sugar-qsp.js)
7 (:use :cl :ps :sugar-qsp.js)
8 (:export #:api-call #:by-id
8 (:export #:api-call #:by-id
9 #:in
9 #:has
10
10
11 #:*globals #:*objs #:*current-location #:*current-action
11 #:*globals #:*objs #:*current-location #:*current-action
12 #:*started-at #:*timer-interval #:*timer-obj #:*loaded-games
12 #:*started-at #:*timer-interval #:*timer-obj #:*loaded-games
@@ -15,7 +15,6 b''
15 (defun not-quote (char)
15 (defun not-quote (char)
16 (not (eql #\' char)))
16 (not (eql #\' char)))
17
17
18
19 (defun not-doublequote (char)
18 (defun not-doublequote (char)
20 (not (eql #\" char)))
19 (not (eql #\" char)))
21
20
General Comments 0
You need to be logged in to leave comments. Login now