From 23297ecfba7837f7af3745c7b96b6fe6ce60fa46 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sun, 2 Jul 2023 18:31:35 -0500 Subject: [PATCH] Support display of multi-row menus --- flora-search-aurora.lisp | 5 +++-- menu.lisp | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/flora-search-aurora.lisp b/flora-search-aurora.lisp index 2f80768..9109cde 100644 --- a/flora-search-aurora.lisp +++ b/flora-search-aurora.lisp @@ -416,9 +416,10 @@ avoid triggering this." `((:en "PLAY" :eo "EKLUDI" :selection 100 :selected t :return ,(🌍:make-overworld-state *casino-map*)) - (:en "SUBMENU" :eo "SUBMENUO" + (:en "SUBMENU" :eo "SUBMENUO" :row 1 :return ,(📋:make-menu-state (submenu))) - (:en "QUIT" :eo "REZIGNI" + (:en "TERURE" :eo "BADLY" :row 1) + (:en "QUIT" :eo "REZIGNI" :row 2 :return nil))) diff --git a/menu.lisp b/menu.lisp index c3de7f0..f555579 100644 --- a/menu.lisp +++ b/menu.lisp @@ -40,7 +40,7 @@ A state-function for use with the #'state-loop." (defun menu-state-draw (matrix menu-plist) "Render a menu in menu-plist format to the given matrix. A core part of #'menu-state." - (render-menu-strip matrix menu-plist 0 0)) + (render-menu-items matrix menu-plist 0 0)) (defun menu-state-update (menu-plist) @@ -87,26 +87,30 @@ left-to-right, unless negative — in which case, right-to-left." matrix)) -(defun render-menu-strip (matrix items x y &key (max-item-width 12) (height 3)) +(defun render-menu-items (matrix items x y &key (max-item-width 12) (height 3)) "Render several menu items to the matrix, starting at the given x/y coordinates, maximum width for any given item, and the height of all items. The item list should be an plist of the following format: (((LABEL :en “BIRD” :eo “BIRDO”)(SELECTED . T)(SELECTION . 100)) ((LABEL :en “BAR” :eo “BARO”)(SELECTION . -20)) ⋯)" - (let ((x x)) + (let ((row-x’es '())) (mapcar (lambda (item) (let* ((label (…:getf-lang item)) (selection (or (getf item :selection) 0)) (width (…:at-most max-item-width - (+ (length label) 2)))) - (render-menu-item matrix label x y + (+ (length label) 2))) + (row (or (getf item :row) 0)) + (item-x (or (getf row-x’es row) x)) + (item-y (+ y (* row height)))) + (render-menu-item matrix label + item-x item-y :width width :height height :selection selection :selected (getf item :selected)) - (setf x (+ x width 1)))) + (setf (getf row-x’es row) (+ item-x width 1)))) items)) matrix)