Don’t over-:use packages (hee-hee)

This commit is contained in:
Jaidyn Ann 2023-06-19 14:56:13 -05:00
parent b8faba4c6a
commit 6467d9bec3
5 changed files with 28 additions and 27 deletions

View File

@ -19,10 +19,9 @@
(defpackage :flora-search-aurora.dialogue (defpackage :flora-search-aurora.dialogue
(:nicknames :fsa.dia :dialogue :💬) (:nicknames :fsa.dia :dialogue :💬)
(:use :cl (:use :cl)
:flora-search-aurora.overworld :flora-search-aurora.ui :flora-search-aurora.input)
(:export #:dialogue-state (:export #:dialogue-state
#:start-dialogue #:face #:say #:mumble)) #:start-dialogue #:face #:say #:mumble))
(in-package :flora-search-aurora.dialogue) (in-package :flora-search-aurora.dialogue)
@ -61,7 +60,7 @@
(defun pressed-enter-p () (defun pressed-enter-p ()
"Whether or not the enter/return key has been pressed recently." "Whether or not the enter/return key has been pressed recently."
(and (listen) (and (listen)
(eq (getf (normalize-char-plist (read-char-plist)) :char) (eq (getf (:normalize-char-plist (:read-char-plist)) :char)
#\return))) #\return)))
@ -71,8 +70,8 @@ If FACE is a string, used that.
If FACE is 'TALKING-FACE, then use their talking-face (if they have one). If FACE is 'TALKING-FACE, then use their talking-face (if they have one).
If FACE is 'NORMAL-FACE, then use their normal-face (if theyve got one). If FACE is 'NORMAL-FACE, then use their normal-face (if theyve got one).
If FACE is NIL guess what that does. :^)" If FACE is NIL guess what that does. :^)"
(let ((talking-face (getf-entity-data map speaker :talking-face)) (let ((talking-face (🌍:getf-entity-data map speaker :talking-face))
(normal-face (getf-entity-data map speaker :normal-face))) (normal-face (🌍:getf-entity-data map speaker :normal-face)))
(cond ((and (eq face 'talking-face) (cond ((and (eq face 'talking-face)
talking-face) talking-face)
talking-face) talking-face)
@ -90,7 +89,7 @@ talking-face or the face given by the dialogue."
(new-face (appropriate-face map speaker (getf dialogue :face)))) (new-face (appropriate-face map speaker (getf dialogue :face))))
;; Replace the face, when appropriate. ;; Replace the face, when appropriate.
(when new-face (when new-face
(setf (getf-entity-data map speaker :face) new-face)))) (setf (🌍:getf-entity-data map speaker :face) new-face))))
(defun progress-line-delivery (dialogue) (defun progress-line-delivery (dialogue)
@ -133,7 +132,7 @@ Helper function for DIALOGUE-STATE."
(progress (getf (car dialogue-list) :progress))) (progress (getf (car dialogue-list) :progress)))
(when text (when text
(:show-cursor) (:show-cursor)
(render-string-partially matrix text 0 0 :char-count progress)))) (📋:render-string-partially matrix text 0 0 :char-count progress))))

View File

@ -45,8 +45,8 @@
(dialogue (💬:start-dialogue (dialogue (💬:start-dialogue
(💬:say "literary-girl" "Blah blah, testing. A multi-lined one. For real! jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj akls djlaks jdlaksj dlakjsd") (💬:say "literary-girl" "Blah blah, testing. A multi-lined one. For real! jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj akls djlaks jdlaksj dlakjsd")
(💬:say "player" "ktp ktp jes jes?")))) (💬:say "player" "ktp ktp jes jes?"))))
(overworld-state-draw matrix map) (🌍:overworld-state-draw matrix map)
(dialogue-state matrix :map map :dialogue dialogue))) (💬:dialogue-state matrix :map map :dialogue dialogue)))
(defun state-loop (defun state-loop
@ -71,7 +71,7 @@ overheat, or something ¯\_(ツ)_/¯"
(when states (when states
(multiple-value-bind (state-result new-state-params) (multiple-value-bind (state-result new-state-params)
(apply (car states) (cons matrix state-params)) ;; Run the latest-added update/draw loop (apply (car states) (cons matrix state-params)) ;; Run the latest-added update/draw loop
(print-screen-matrix (matrix-delta last-matrix matrix)) ;; Print its results. (:print-screen-matrix (:matrix-delta last-matrix matrix)) ;; Print its results.
(force-output) (force-output)
(state-loop (state-loop
(cond ((functionp state-result) (cond ((functionp state-result)
@ -97,7 +97,7 @@ overheat, or something ¯\_(ツ)_/¯"
(FUNCTION . ,#'make-options-menu-state)) (FUNCTION . ,#'make-options-menu-state))
((LABEL . "QUIT") (RETURN . NIL))))) ((LABEL . "QUIT") (RETURN . NIL)))))
(lambda (matrix) (lambda (matrix)
(menu-state matrix main-menu)))) (📋:menu-state matrix main-menu))))
(defun make-options-menu-state () (defun make-options-menu-state ()
@ -109,14 +109,14 @@ overheat, or something ¯\_(ツ)_/¯"
((LABEL . "GO BACK") ((LABEL . "GO BACK")
(RETURN . ,NIL))))) (RETURN . ,NIL)))))
(lambda (matrix) (lambda (matrix)
(menu-state matrix options-menu)))) (📋:menu-state matrix options-menu))))
(defun make-main-overworld-state () (defun make-main-overworld-state ()
"Return a state-function for the games overworld (the majority of the game), for use "Return a state-function for the games overworld (the majority of the game), for use
with STATE-LOOP." with STATE-LOOP."
(lambda (matrix &rest args) (lambda (matrix &rest args)
(apply #'overworld-state (apply #'🌍:overworld-state
(append (list matrix) (append (list matrix)
'(:map-path #p"/home/jaidyn/.local/src/games/flora search aurora/res/map.tmx") '(:map-path #p"/home/jaidyn/.local/src/games/flora search aurora/res/map.tmx")
args)))) args))))
@ -126,8 +126,8 @@ with STATE-LOOP."
"A pathetic fascimile of a main loop. What does it do? WHAST DOES TI DODOO?" "A pathetic fascimile of a main loop. What does it do? WHAST DOES TI DODOO?"
(cl-charms:with-curses () (cl-charms:with-curses ()
(cl-charms:enable-raw-input :interpret-control-characters 't) (cl-charms:enable-raw-input :interpret-control-characters 't)
(hide-cursor) (:hide-cursor)
(clear-screen) (:clear-screen)
(state-loop (list (make-main-menu-state))))) (state-loop (list (make-main-menu-state)))))

View File

@ -18,7 +18,9 @@
(defpackage :flora-search-aurora.input (defpackage :flora-search-aurora.input
(:use :cl) (:use :cl)
(:export #:read-char-plist #:normalize-char-plist (:nicknames :fsa.i :input :)
(:export #:read-char-plist #:normalize-char-plist #:plist-char-p
:control :meta :shift
+qwerty-layout+ +dvorak-layout+)) +qwerty-layout+ +dvorak-layout+))
(in-package :flora-search-aurora.input) (in-package :flora-search-aurora.input)
@ -93,8 +95,10 @@ characters, like left arrow-key (escaped D) into ← (“LEFTWARDS ARROW”)."
(getf char-plist :char)))) (getf char-plist :char))))
;;; ~ Utilities ~
;;; ———————————————————————————————————
;;; Misc. utils
;;; ———————————————————————————————————
(defun parallel-list-item (item-a list-a list-b &key (test #'eql)) (defun parallel-list-item (item-a list-a list-b &key (test #'eql))
"Given two parallel lists and an item contained in the first list, return its "Given two parallel lists and an item contained in the first list, return its
corresponding item in the other list, by index." corresponding item in the other list, by index."

View File

@ -18,12 +18,10 @@
;;;; the primary gameplay, the RPG-ish-ish bits). ;;;; the primary gameplay, the RPG-ish-ish bits).
(defpackage :flora-search-aurora.overworld (defpackage :flora-search-aurora.overworld
(:nicknames :fsa.o :overworld) (:nicknames :fsa.o :overworld :🌍)
(:use :cl (:use :cl
:flora-search-aurora.input :flora-search-aurora.display :flora-search-aurora.ui
:flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util) :flora-search-aurora.overworld.tiled :flora-search-aurora.overworld.util)
(:export #:overworld-state #:overworld-state-draw (:export #:overworld-state #:overworld-state-draw
#:dialogue-state
#:getf-entity #:getf-entity-data #:getf-entity #:getf-entity-data
:player)) :player))
@ -117,7 +115,7 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE."
(defun process-overworld-input (map) (defun process-overworld-input (map)
"Get and process any keyboard input, modifying the map or entities as necessary." "Get and process any keyboard input, modifying the map or entities as necessary."
(if (listen) (if (listen)
(let* ((input (normalize-char-plist (read-char-plist)))) (let* ((input (:normalize-char-plist (:read-char-plist))))
(cond (cond
;; Interacting with nearby characters/entities ;; Interacting with nearby characters/entities
((plist= input '(:modifier nil :char #\return)) ((plist= input '(:modifier nil :char #\return))
@ -222,7 +220,7 @@ alist containing a character (:CHAR) and :X & :Y coordinates."
(x (if (eq direction 'right) (x (if (eq direction 'right)
(- (getf screen-coords :x) (floor (/ width 2)) 0) (- (getf screen-coords :x) (floor (/ width 2)) 0)
(- (getf screen-coords :x) (floor (/ width 2)) 0)))) (- (getf screen-coords :x) (floor (/ width 2)) 0))))
(render-line matrix face (+ x 1) y) (📋:render-line matrix face (+ x 1) y)
(ignore-errors (setf (aref matrix y x) #\|)) (ignore-errors (setf (aref matrix y x) #\|))
(ignore-errors (setf (aref matrix y (+ width x -1)) (ignore-errors (setf (aref matrix y (+ width x -1))
#\|)))) #\|))))

View File

@ -18,8 +18,8 @@
;;;; Let's get to it, we're on a deadline! ;;;; Let's get to it, we're on a deadline!
(defpackage :flora-search-aurora.ui (defpackage :flora-search-aurora.ui
(:nicknames :fsa.u :ui) (:nicknames :fsa.u :ui :📋)
(:use :cl :flora-search-aurora.display :flora-search-aurora.input :assoc-utils) (:use :cl :assoc-utils)
(:export #:menu-state (:export #:menu-state
#:render-line #:render-string #:render-string-partially #:render-line #:render-string #:render-string-partially
:label :selection :selected)) :label :selection :selected))
@ -185,7 +185,7 @@ That is, 0 for non-selected items and 100 for selected items."
(defun process-menu-input (menu-alist) (defun process-menu-input (menu-alist)
"Get and process any keyboard input, modifying the menu alist as necessary." "Get and process any keyboard input, modifying the menu alist as necessary."
(if (listen) (if (listen)
(let* ((input (normalize-char-plist (read-char-plist))) (let* ((input (:normalize-char-plist (:read-char-plist)))
(selected-item (nth (selected-menu-item-position menu-alist) (selected-item (nth (selected-menu-item-position menu-alist)
menu-alist)) menu-alist))
(func (cdr (assoc 'function selected-item))) (func (cdr (assoc 'function selected-item)))