##// END OF EJS Templates
Update TODO...
Update TODO...

File last commit:

r34:fac4b25b default
r35:abfb7f68 default
Show More
api.ps
547 lines | 16.2 KiB | application/postscript | PostScriptLexer
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (in-package sugar-qsp.api)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
;;; API deals with DOM manipulation and some bookkeeping for the
;;; intrinsics, namely variables
;;; API is an implementation detail and has no QSP documentation. It
;;; doesn't call intrinsics
Tutorial game works!
r6 ;;; Utils
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun make-act-html (title img)
Special variables and locations
r32 (+ "<a class='qsp-act' href='" (href-call call-act title) "' onmouseover='" (inline-call select-act title) "'>"
MENU
r30 (if img (+ "<img src='" img "'>") "")
Tutorial game works!
r6 title
"</a>"))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun make-menu-item-html (num title img loc)
Special variables and locations
r32 (+ "<a href='" (href-call finish-menu loc) "'>"
MENU
r30 (if img (+ "<img src='" img "'>") "")
Menu, game saving
r11 title
"</a>"))
Special variables and locations
r32 (defun make-obj (title img selected)
Bugfixes, remaining font stuff
r33 (+ "<li onclick='" (inline-call select-obj title img) "'>"
"<a class='qsp-obj" (if selected " qsp-obj-selected" "") "'>"
Special variables and locations
r32 (if img (+ "<img src='" img "'>") "")
Bugfixes, remaining font stuff
r33 title
Special variables and locations
r32 "</a>"))
MENU
r30 (defun make-menu-delimiter ()
"<hr>")
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun report-error (text)
Finishing lib
r20 (alert text))
Working WAIT without busy-wait
r29 (defun start-sleeping ()
MENU
r30 (chain (by-id "qsp") class-list (add "disable")))
Working WAIT without busy-wait
r29
(defun finish-sleeping ()
MENU
r30 (chain (by-id "qsp") class-list (remove "disable")))
Working WAIT without busy-wait
r29
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun sleep (msec)
MENU
r30 (with-sleep (resume)
(set-timeout resume msec)))
WAIT with async
r24
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun init-dom ()
Some DOM stuff, VIEW
r18 ;; Save/load buttons
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let ((btn (by-id "qsp-btn-save")))
(setf (@ btn onclick) savegame)
(setf (@ btn href) "#"))
(let ((btn (by-id "qsp-btn-open")))
(setf (@ btn onclick) opengame)
(setf (@ btn href) "#"))
Some DOM stuff, VIEW
r18 ;; Close image on click
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ (by-id "qsp-image-container") onclick)
Special variables and locations
r32 show-image)
Bugfixes, remaining font stuff
r33 ;; Enter in input field
Special variables and locations
r32 (setf (@ (get-frame :input) onkeyup)
on-input-key)
Some DOM stuff, VIEW
r18 ;; Close the dropdown on any click
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ window onclick)
Some DOM stuff, VIEW
r18 (lambda (event)
MENU
r30 (setf (@ window mouse)
(list (@ event page-x)
(@ event page-y)))
(finish-menu nil))))
Some DOM stuff, VIEW
r18
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun call-serv-loc (var-name &rest args)
(let ((loc-name (get-var var-name 0 :str)))
Finishing lib
r20 (when loc-name
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let ((loc (getprop (root locs) loc-name)))
Finishing lib
r20 (when loc
Special variables and locations
r32 (call-loc loc-name args))))))
Menu, game saving
r11
Multiple sources, multiple games, openqst/addqst/killqst
r31 (defun filename-game (filename)
(let ((game-name (chain filename (match "(.*/)?([^.]+)(\\.[a-zA-Z]+)?") 2))))
(getprop (root games) game-name))
(defun run-game (name)
(let ((game (filename-game name)))
(setf (root main-game) name)
;; Replace locations with the new game's
(setf (root locs) game)
(funcall (getprop game
(chain *object (keys game) 0))
(list))))
A better UI
r9 ;;; Misc
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun newline (key)
(append-id (key-to-id key) "<br>" t))
Bugfixes
r22
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun clear-id (id)
(setf (inner-html (by-id id)) ""))
Bugfixes
r22
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defvar text-escaper (chain document (create-element :textarea)))
Bugfixes
r22
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun prepare-contents (s &optional force-html)
(if (or force-html (get-var "USEHTML" 0 :num))
Bugfixes
r22 s
(progn
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ text-escaper text-content) s)
(inner-html text-escaper))))
A better UI
r9
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-id (id &optional force-html)
(inner-html (by-id id)))
A better UI
r9
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun set-id (id contents &optional force-html)
(setf (inner-html (by-id id)) (prepare-contents contents force-html)))
A better UI
r9
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun append-id (id contents &optional force-html)
Bugfixes
r22 (when contents
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (incf (inner-html (by-id id)) (prepare-contents contents force-html))))
A better UI
r9
Special variables and locations
r32 (defun on-input-key (ev)
(when (= 13 (@ ev key-code))
(chain ev (prevent-default))
(call-serv-loc "USERCOM")))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; Function calls
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun init-args (args)
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 (dotimes (i (length args))
Properly handle stringly-indexed arrays
r16 (let ((arg (elt args i)))
(if (numberp arg)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (set-var args i :num arg)
(set-var args i :str arg)))))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-result ()
Fixed saves...
r26 (if (not (equal "" (get-var "RESULT" 0 :str)))
(get-var "RESULT" 0 :str)
(get-var "RESULT" 0 :num)))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun call-loc (name args)
MENU
r30 (setf name (chain name (to-upper-case)))
Remove cl-uglify-js
r23 (with-frame
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (with-call-args args
Special variables and locations
r32 (funcall (getprop (root locs) name)))))
Remove cl-uglify-js
r23
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun call-act (title)
MENU
r30 (with-frame
Special variables and locations
r32 (funcall (getprop (root acts) title :act))))
The Box bugfixes
r21
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; Text windows
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun key-to-id (key)
Tutorial game works!
r6 (case key
Special variables and locations
r32 (:all "qsp")
Tutorial game works!
r6 (:main "qsp-main")
(:stat "qsp-stat")
Menu, game saving
r11 (:objs "qsp-objs")
(:acts "qsp-acts")
(:input "qsp-input")
MENU
r30 (:image "qsp-image")
Menu, game saving
r11 (:dropdown "qsp-dropdown")
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (t (report-error "Internal error!"))))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-frame (key)
(by-id (key-to-id key)))
Menu, game saving
r11
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun add-text (key text)
(append-id (key-to-id key) text))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-text (key)
(get-id (key-to-id key)))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun clear-text (key)
(clear-id (key-to-id key)))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun enable-frame (key enable)
(let ((obj (get-frame key)))
(setf (@ obj style display) (if enable "block" "none"))
Removing unnecessary returns
r27 (void)))
Menu, game saving
r11
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1 ;;; Actions
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun add-act (title img act)
(setf (getprop (root acts) title)
Special variables and locations
r32 (create :title title :img img :act act :selected nil))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (update-acts))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun del-act (title)
(delete (getprop (root acts) title))
(update-acts))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun clear-act ()
(setf (root acts) (create))
Special variables and locations
r32 (update-acts))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun update-acts ()
(clear-id "qsp-acts")
(let ((elt (by-id "qsp-acts")))
(for-in (title (root acts))
(let ((obj (getprop (root acts) title)))
(incf (inner-html elt) (make-act-html title (getprop obj :img)))))))
Special variables and locations
r32 (defun select-act (title)
(loop :for (k v) :of (root acts)
Bugfixes, remaining font stuff
r33 :do (setf (getprop v :selected) nil))
Special variables and locations
r32 (setf (getprop (root acts) title :selected) t)
(call-serv-loc "ONACTSEL"))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
API call for FOR loop to make the main code less cluttered
r19 ;;; "Syntax"
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun qspfor (name index from to step body)
(for ((i from))
((< i to))
((incf i step))
(set-var name index :num i)
(unless (funcall body)
(return-from qspfor))))
API call for FOR loop to make the main code less cluttered
r19
Properly handle stringly-indexed arrays
r16 ;;; Variable class
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun *var (name)
Properly handle stringly-indexed arrays
r16 ;; From strings to numbers
Special variables and locations
r32 (setf (@ this :indexes) (create))
Properly handle stringly-indexed arrays
r16 ;; From numbers to {num: 0, str: ""} objects
Special variables and locations
r32 (setf (@ this :values) (list))
Removing unnecessary returns
r27 (void))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun new-value ()
(create :num 0 :str ""))
100% parser, 100% macros, 50% intrinsics, 10% api, 0% misc
r1
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ *var prototype index-num)
(lambda (index)
(let ((num-index
(if (stringp index)
Special variables and locations
r32 (if (in index (@ this :indexes))
(getprop (@ this :indexes) index)
(let ((n (length (@ this :values))))
(setf (getprop (@ this :indexes) index) n)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 n))
index)))
Special variables and locations
r32 (unless (in num-index (@ this :values))
(setf (elt (@ this :values) num-index) (new-value)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 num-index)))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ *var prototype get)
(lambda (index slot)
(unless (or index (= 0 index))
Special variables and locations
r32 (setf index (1- (length (@ this :values)))))
(getprop (@ this :values) (chain this (index-num index)) slot)))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ *var prototype set)
(lambda (index slot value)
(unless (or index (= 0 index))
Special variables and locations
r32 (setf index (length (@ this :values))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (case slot
(:num (setf value (chain *number (parse-int value))))
(:str (setf value (chain value (to-string)))))
Special variables and locations
r32 (setf (getprop (@ this :values)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain this (index-num index))
slot) value)
Removing unnecessary returns
r27 (void)))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ *var prototype kill)
(lambda (index)
Special variables and locations
r32 (setf (elt (@ this :values) (chain this (index-num index)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (new-value))
Special variables and locations
r32 (delete (getprop 'this :indexes index))))
Properly handle stringly-indexed arrays
r16
;;; Variables
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun var-real-name (name)
(if (= (@ name 0) #\$)
(values (chain name (substr 1)) :str)
Properly handle stringly-indexed arrays
r16 (values name :num)))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun ensure-var (name)
MENU
r30 (setf name (chain name (to-upper-case)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let ((store (var-ref name)))
Locals
r14 (unless store
Removing unnecessary returns
r27 (setf store (new (*var name)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (getprop (root vars) name) store))
Properly handle stringly-indexed arrays
r16 store))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun var-ref (name)
(let ((local-store (current-local-frame)))
The Box bugfixes
r21 (cond ((and local-store (in name local-store))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (getprop local-store name))
Properly handle stringly-indexed arrays
r16 ((in name (root vars))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (getprop (root vars) name))
Locals
r14 (t nil))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-var (name index slot)
(chain (ensure-var name) (get index slot)))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun set-var (name index slot value)
(chain (ensure-var name) (set index slot value))
Special variables and locations
r32 (let ((serv-var (getprop serv-vars name)))
(when serv-var
Bugfixes, remaining font stuff
r33 (funcall (@ serv-var :body)
Special variables and locations
r32 (get-var name index (@ serv-var :slot))
index)))
Removing unnecessary returns
r27 (void))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun get-array (name)
MENU
r30 (setf name (chain name (to-upper-case)))
Special variables and locations
r32 (ensure-var name))
Menu, game saving
r11
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun set-array (name value)
MENU
r30 (setf name (chain name (to-upper-case)))
Special variables and locations
r32 (let ((store (ensure-var name)))
(setf (@ store :values) (@ value :values))
(setf (@ store :indexes) (@ value :indexes)))
Removing unnecessary returns
r27 (void))
Locals
r14
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun kill-var (name &optional index)
MENU
r30 (setf name (chain name (to-upper-case)))
Properly handle stringly-indexed arrays
r16 (if (and index (not (= 0 index)))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain (getprop (root vars) name) (kill index))
(delete (getprop (root vars) name)))
Removing unnecessary returns
r27 (void))
Tutorial game works!
r6
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun array-size (name)
Special variables and locations
r32 (@ (var-ref name) :values length))
Properly handle stringly-indexed arrays
r16
;;; Locals
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun push-local-frame ()
(chain (root locals) (push (create)))
Removing unnecessary returns
r27 (void))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun pop-local-frame ()
(chain (root locals) (pop))
Removing unnecessary returns
r27 (void))
Properly handle stringly-indexed arrays
r16
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun current-local-frame ()
Properly handle stringly-indexed arrays
r16 (elt (root locals) (1- (length (root locals)))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun new-local (name)
(let ((frame (current-local-frame)))
Properly handle stringly-indexed arrays
r16 (unless (in name frame)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (getprop frame name) (create)))
Removing unnecessary returns
r27 (void)))
Menu, game saving
r11
Tutorial game works!
r6 ;;; Objects
Special variables and locations
r32 (defun select-obj (title img)
(loop :for (k v) :of (root objs)
Bugfixes, remaining font stuff
r33 :do (setf (getprop v :selected) nil))
Special variables and locations
r32 (setf (getprop (root objs) title :selected) t)
(call-serv-loc "ONOBJSEL" title img))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun update-objs ()
(let ((elt (by-id "qsp-objs")))
(setf (inner-html elt) "<ul>")
Bugfixes, remaining font stuff
r33 (loop :for (name obj) :of (root objs)
Special variables and locations
r32 :do (incf (inner-html elt)
Bugfixes, remaining font stuff
r33 (make-obj name (@ obj :img) (@ obj :selected))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (incf (inner-html elt) "</ul>")))
Menu, game saving
r11
;;; Menu
MENU
r30 (defun open-menu (menu-data)
(let ((elt (get-frame :dropdown))
Menu, game saving
r11 (i 0))
(loop :for item :in menu-data
:do (incf i)
MENU
r30 :do (incf (inner-html elt)
(if (eq item :delimiter)
(make-menu-delimiter i)
(make-menu-item-html i
(@ item :text)
(@ item :icon)
(@ item :loc)))))
(let ((mouse (@ window mouse)))
(setf (@ elt style left) (+ (elt mouse 0) "px"))
(setf (@ elt style top) (+ (elt mouse 1) "px"))
;; Make sure it's inside the viewport
(when (> (@ document body inner-width)
(+ (elt mouse 0) (@ elt inner-width)))
(incf (@ elt style left) (@ elt inner-width)))
(when (> (@ document body inner-height)
(+ (elt mouse 0) (@ elt inner-height)))
(incf (@ elt style top) (@ elt inner-height))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ elt style display) "block")))
Sounds, save/load UI buttons
r12
MENU
r30 (defun finish-menu (loc)
(when (root menu-resume)
(let ((elt (get-frame :dropdown)))
(setf (inner-html elt) "")
(setf (@ elt style display) "none")
(funcall (root menu-resume))
(setf (root menu-resume) nil))
(when loc
(call-loc loc)))
(void))
(defun menu (menu-data)
(with-sleep (resume)
(open-menu menu-data)
(setf (root menu-resume) resume))
(void))
Sounds, save/load UI buttons
r12 ;;; Content
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun clean-audio ()
(loop :for k :in (chain *object (keys (root playing)))
:for v := (getprop (root playing) k)
:do (when (@ v ended)
(delete (@ (root playing) k)))))
Locals
r14
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun show-image (path)
MENU
r30 (let ((img (get-frame :image)))
Some DOM stuff, VIEW
r18 (cond (path
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ img src) path)
(setf (@ img style display) "flex"))
Some DOM stuff, VIEW
r18 (t
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (setf (@ img src) "")
(setf (@ img style display) "hidden")))))
Some DOM stuff, VIEW
r18
IMG and *IMG
r34 (defun show-inline-images (frame-name images)
(let ((frame (get-frame frame-name))
(text ""))
(incf text "<div style='position:relative; display: inline-block'>")
(incf text (+ "<img src='" (@ images 0) "'>"))
(loop :for image :in (chain images (slice 1))
:do (incf text
(+ "<img style='position:absolute' src='" image "'>")))
(incf text "</div>")
(incf (inner-html frame) text)))
Special variables and locations
r32 (defun rgb-string (rgb)
Bugfixes, remaining font stuff
r33 (let ((red (ps::>> rgb 16))
(green (logand (ps::>> rgb 8) 255))
(blue (logand rgb 255)))
Special variables and locations
r32 (flet ((rgb-to-hex (comp)
(let ((hex (chain (*number comp) (to-string 16))))
(if (< (length hex) 2)
(+ "0" hex)
hex))))
(+ "#" (rgb-to-hex red) (rgb-to-hex green) (rgb-to-hex red)))))
Some DOM stuff, VIEW
r18 ;;; Saves
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun opengame ()
(let ((element (chain document (create-element :input))))
(chain element (set-attribute :type :file))
(chain element (set-attribute :id :qsp-opengame))
(chain element (set-attribute :tabindex -1))
(chain element (set-attribute "aria-hidden" t))
(setf (@ element style display) :block)
(setf (@ element style visibility) :hidden)
(setf (@ element style position) :fixed)
(setf (@ element onchange)
Some DOM stuff, VIEW
r18 (lambda (event)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let* ((file (@ event target files 0))
(reader (new (*file-reader))))
(setf (@ reader onload)
Some DOM stuff, VIEW
r18 (lambda (ev)
(block nil
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (let ((target (@ ev current-target)))
(unless (@ target result)
(return))
(base64-to-state (@ target result))
(unstash-state)))))
(chain reader (read-as-text file)))))
(chain document body (append-child element))
(chain element (click))
(chain document body (remove-child element))))
Some DOM stuff, VIEW
r18
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun savegame ()
(let ((element (chain document (create-element :a))))
(chain element (set-attribute :href (+ "data:text/plain;charset=utf-8," (state-to-base64))))
(chain element (set-attribute :download "savegame.sav"))
(setf (@ element style display) :none)
(chain document body (append-child element))
(chain element (click))
(chain document body (remove-child element))))
Finishing lib
r20
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun stash-state (args)
(call-serv-loc "ONGSAVE")
Finishing lib
r20 (setf (root state-stash)
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (chain *j-s-o-n (stringify
Removing unnecessary returns
r27 (create :vars (root vars)
:objs (root objs)
:loc-args args
:msecs (- (chain *date (now)) (root started-at))
:timer-interval (root timer-interval)
:main-html (inner-html
MENU
r30 (get-frame :main))
Removing unnecessary returns
r27 :stat-html (inner-html
MENU
r30 (get-frame :stat))
Removing unnecessary returns
r27 :next-location (root current-location)))))
(void))
Finishing lib
r20
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun unstash-state ()
(let ((data (chain *j-s-o-n (parse (root state-stash)))))
(clear-act)
Removing unnecessary returns
r27 (setf (root vars) (@ data :vars))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (loop :for k :in (chain *object (keys (root vars)))
:do (chain *object (set-prototype-of (getprop (root vars) k)
(@ *var prototype))))
Removing unnecessary returns
r27 (setf (root started-at) (- (chain *date (now)) (@ data :msecs)))
(setf (root objs) (@ data :objs))
(setf (root current-location) (@ data :next-location))
MENU
r30 (setf (inner-html (get-frame :main))
Removing unnecessary returns
r27 (@ data :main-html))
MENU
r30 (setf (inner-html (get-frame :stat))
Removing unnecessary returns
r27 (@ data :stat-html))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (update-objs)
Removing unnecessary returns
r27 (set-timer (@ data :timer-interval))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (call-serv-loc "ONGLOAD")
Removing unnecessary returns
r27 (call-loc (root current-location) (@ data :loc-args))
(void)))
Finishing lib
r20
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun state-to-base64 ()
Finishing lib
r20 (btoa (encode-u-r-i-component (root state-stash))))
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun base64-to-state (data)
Finishing lib
r20 (setf (root state-stash) (decode-u-r-i-component (atob data))))
;;; Timers
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (defun set-timer (interval)
Finishing lib
r20 (setf (root timer-interval) interval)
(clear-interval (root timer-obj))
(setf (root timer-obj)
(set-interval
(lambda ()
Use Parenscript's minifier and obfuscator... and namespaces. SAVES CURRENTLY BROKEN
r25 (call-serv-loc "COUNTER"))
Finishing lib
r20 interval)))
Special variables and locations
r32
;;; Special variables
Bugfixes, remaining font stuff
r33 (defvar serv-vars (create))
Special variables and locations
r32 (define-serv-var backimage (:str path)
(setf (@ (get-frame :main) style background-image) path))
(define-serv-var bcolor (:num color)
(setf (@ (get-frame :all) style background-color) (rgb-string color)))
(define-serv-var fcolor (:num color)
(setf (@ (get-frame :all) style color) (rgb-string color)))
(define-serv-var lcolor (:num color)
(setf (@ (get-frame :style) inner-text)
(+ "a { color: " (rgb-string color) ";}")))
Bugfixes, remaining font stuff
r33
(define-serv-var fsize (:num size)
(setf (@ (get-frame :all) style font-size) size))
(define-serv-var fname (:str font-name)
(setf (@ (get-frame :all) style font-family) (+ font-name ",serif")))