diff --git a/engine.lisp b/engine.lisp index f1d2d66..31e11bd 100644 --- a/engine.lisp +++ b/engine.lisp @@ -39,7 +39,7 @@ overheat, or something ¯\_(ツ)_/¯" (let ((state-result (apply (car states) (cons matrix state-params)))) ;; Run the last-added state-loop. (✎:print-screen-matrix (✎:matrix-delta last-matrix matrix)) ;; Print its results. - (format *error-output* "~S~%" state-result) +;; (format *error-output* "~S~%" state-result) (force-output) (state-loop (cond ((listp state-result) diff --git a/flora-search-aurora.lisp b/flora-search-aurora.lisp index 4f98117..e3705fe 100644 --- a/flora-search-aurora.lisp +++ b/flora-search-aurora.lisp @@ -631,6 +631,13 @@ avoid triggering this." (flashback-casino-dialogue map))) +(defun cry (&optional map ring) + (nconc (list :drop 1) + (make-dialogue-state + map + (start-dialogue (mumble 'player :en "FUCK"))))) + + ;;; ——————————————————————————————————— ;;; Main-menu data diff --git a/inventory.lisp b/inventory.lisp index 2edd5c9..17c9486 100644 --- a/inventory.lisp +++ b/inventory.lisp @@ -36,7 +36,6 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE "Convert a list of items’ plists (that one might get from OVERWORLD’s map :ITEMS) into a pretty and presentable menu-grid of items, for use with 📋:MENU-STATE(-*)." - (format *error-output* "ITEMS ~S~%" item-plists) (let* ((label-width 7) (border-width 2) ;; Weird bounding, whoops! I’m so clumsy, it’s endearing instead of just annoying! … Right? =w=” @@ -54,7 +53,7 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE (getf (cdr item) :name-eo))) :selected (and (eq row 0) (eq column 0)) :selection (if (and (eq row 0) (eq column 0)) 100 0) - :return nil + :submenu 't :row row) (cdr item))) item-plists))) @@ -64,13 +63,42 @@ exceeds the size of SEQUENCE, the returned subsequence is equivalent to SEQUENCE ;;; ——————————————————————————————————— ;;; Inventory loop logic ;;; ——————————————————————————————————— -(defun inventory-state-update (map inventory-menu) +(defun submenu (item) + "Create a ITEM’s submenu, from its plist." + (nconc (when (getf item :use) + (list + (list :en "Use it!" + :eo "Uzi ĝin!" + :selected 't :selection 100 + :use 't))) + (list + (list :en "Lose it!" + :eo "Ne!" + :use nil)))) + + +(defun inventory-state-update (map inventory-menu submenu) "The input-taking/logic-handling component of the inventory state-function. Part of INVENTORY-STATE." - (if (📋:menu-state-update inventory-menu) - (list :map map :inventory inventory-menu) - (values nil - (list :map map)))) + (let ((menu-return (📋:menu-state-update (if submenu submenu inventory-menu))) + (selected-item (📋:selected-menu-item inventory-menu))) + (cond + ;; Display the pop-up menu when an item is selected. + ((and (listp menu-return) (getf menu-return :submenu)) + (list :parameters (list :map map :inventory inventory-menu + :submenu (submenu selected-item)))) + ;; User decided to use the item, let’s go! + ((and (listp menu-return) (getf menu-return :use) (getf selected-item :use)) + (funcall (…:string->symbol (getf selected-item :use)) map selected-item)) + ;; User decided not to use the item. + ((and (listp menu-return) (member :use menu-return)) + (list :parameters (list :map map :inventory inventory-menu))) + ;; Return the menu itself, if non-nil. + (menu-return + menu-return) + ;; If menu-return was non-nil, the user left the menu. Let’s leave inventory! + ('t + (list :drop 1 :parameters (list :map map)))))) @@ -92,27 +120,28 @@ the bottom of the screen." '(:x 1 :y 18) :width 70))) -(defun inventory-state-draw (matrix items) +(defun inventory-state-draw (matrix items submenu) "The drawing component of the inventory state-function. Part of INVENTORY-STATE." (📋:menu-state-draw matrix items) - (render-selected-item matrix items)) + (render-selected-item matrix items) + (when submenu + (📋:menu-state-draw matrix submenu))) ;;; ——————————————————————————————————— ;;; Inventory loop ;;; ——————————————————————————————————— -(defun inventory-state (matrix &key map inventory) +(defun inventory-state (matrix &key map inventory (submenu nil)) "A state-function for use with STATE-LOOP." (sleep .02) - (inventory-state-draw matrix inventory) - (inventory-state-update map inventory)) + (inventory-state-draw matrix inventory submenu) + (inventory-state-update map inventory submenu)) (defun make-inventory-state (map) "Return a state-function for inventory-listing, for use with STATE-LOOP." - (lambda (matrix &key (map map) (inventory (items->menu-plist (gethash :items map)))) + (lambda (matrix &key (map map) (submenu nil) (inventory (items->menu-plist (gethash :items map)))) (apply #'🎒:inventory-state - (list matrix :map map :inventory inventory)))) - + (list matrix :map map :inventory inventory :submenu submenu)))) diff --git a/menu.lisp b/menu.lisp index ee6b644..ed8d65a 100644 --- a/menu.lisp +++ b/menu.lisp @@ -145,9 +145,7 @@ That is, 0 for non-selected items and 100 for selected items." (selected-item (nth (selected-menu-item-position menu-plist) menu-plist)) (func (getf selected-item :function)) - (exec (getf selected-item :exec)) - (return-val-p (member :return selected-item)) - (return-val (getf selected-item :return))) + (exec (getf selected-item :exec))) (case (getf input :semantic) ('⌨:→ (progn (select-right-menu-item menu-plist) 't)) diff --git a/overworld.lisp b/overworld.lisp index f41a8ba..3df9f52 100644 --- a/overworld.lisp +++ b/overworld.lisp @@ -209,7 +209,7 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE." (interactee-id (car interactee)) (interaction (getf (cdr interactee) :interact))) (if interaction - (apply (string->symbol interaction) (list map interactee-id)) + (apply (…:string->symbol interaction) (list map interactee-id)) (list :parameters (list :map map))))) ('⌨:❎ (list :function (🎒:make-inventory-state map))) @@ -242,7 +242,7 @@ Very kindly removes a list of parameters to be returned by the overworld state-f (let* ((coords (getf-entity-data map '✿:player :coords)) (trigger (trigger-at-coords map (list :x (getf coords :x) :y (getf coords :y))))) (if (and trigger (getf trigger :function)) - (apply (string->symbol (getf trigger :function)) + (apply (…:string->symbol (getf trigger :function)) (list map trigger)) (list :parameters (list :map map))))) diff --git a/overworld.tiled.lisp b/overworld.tiled.lisp index 5d60116..e68fd83 100644 --- a/overworld.tiled.lisp +++ b/overworld.tiled.lisp @@ -65,7 +65,7 @@ character-scale world coordinates in plist form." (when (not (tiled-rectangle-p tiled-obj)) (let ((properties (cl-tiled:properties tiled-obj))) (append - (list (string->symbol (gethash "id" properties))) + (list (…:string->symbol (gethash "id" properties))) (loop for key being the hash-keys in properties for val being the hash-values in properties collect (intern (string-upcase key) "KEYWORD") diff --git a/packages.lisp b/packages.lisp index 1de6712..70a6289 100644 --- a/packages.lisp +++ b/packages.lisp @@ -22,6 +22,7 @@ #:plist= #:incf-0 #:at-least #:at-most + #:string->symbol #:system-language #:langcode->keysym #:getf-lang)) (defpackage :flora-search-aurora.input @@ -74,7 +75,6 @@ #:world-coords->screen-coords #:world-coords-chunk #:map->plist #:plist->map - #:string->symbol #:save-map-to-file)) (defpackage :flora-search-aurora.overworld diff --git a/res/maps/casino.tmx b/res/maps/casino.tmx index e66755e..dafef4e 100644 --- a/res/maps/casino.tmx +++ b/res/maps/casino.tmx @@ -403,6 +403,7 @@ Fojfoje mi ja ŝatas mian fakon, mdr. + diff --git a/util.lisp b/util.lisp index b4b7bc7..4cb5c65 100644 --- a/util.lisp +++ b/util.lisp @@ -123,8 +123,20 @@ minimum returns your more pitiful of moments." ;;; ——————————————————————————————————— -;;; Linguistic affirs +;;; Linguistic & symbolic affirs ;;; ——————————————————————————————————— +(defun string->symbol (string) + "Given a STRING with an optionally defined package (e.g., “package:symbol”), +return it as an appopriate symbol." + (let* ((split (str:split ":" (string-upcase string))) + (package (when (eq (length split) 2) + (car split))) + (symbol (or (cadr split) (car split)))) + (if package + (intern symbol package) + (intern symbol)))) + + (defun langcode->keysym (str) "Given a language’s code (es/cz/it/etc.), return a corresponding key symbol, if the language is among the supported. Otherwise, nil."