Small logic changes

This commit is contained in:
Amy Grinn 2024-12-18 12:37:19 -05:00
parent 8627f06ebd
commit 89fa09c387
No known key found for this signature in database
GPG key ID: 6B558BED1DCF3192

View file

@ -760,7 +760,7 @@
(y (- (vec2-y center) (* tile-height (floor (/ height 2)))))) (y (- (vec2-y center) (* tile-height (floor (/ height 2))))))
;; Draw menu background ;; Draw menu background
(when (= r r-start) (when (= r r-start)
(let* ((x (- (vec2-x center) (* tile-width (floor (/ width 2))))) (let ((x (- (vec2-x center) (* tile-width (floor (/ width 2)))))
(w (* tile-width width)) (w (* tile-width width))
(h (* tile-height height))) (h (* tile-height height)))
(set-fill-color! context "#000") (set-fill-color! context "#000")
@ -768,28 +768,27 @@
(set-stroke-color! context "blue") (set-stroke-color! context "blue")
(stroke-rect context x y w h))) (stroke-rect context x y w h)))
;; Draw menu text ;; Draw menu text
(let ((r-menu-index (- (+ r (* (current-menu-page) menu:max-items)) (current-menu-page))))
(set-font! context "normal 16px monogram") (set-font! context "normal 16px monogram")
(set-fill-color! context "#fff") (set-fill-color! context "#fff")
(when (= r r-start) (when (= r r-start)
(set-text-align! context "center") (set-text-align! context "center")
(fill-text context (menu-name (current-menu)) (vec2-x center) (+ y text-offset-y))) (fill-text context (menu-name (current-menu)) (vec2-x center) (+ y text-offset-y)))
(let* ((r-index (- (+ r (* (current-menu-page) menu:max-items)) (current-menu-page))))
(set-text-align! context "left") (set-text-align! context "left")
(if (= r-index (current-menu-index)) (when (= r-menu-index (current-menu-index))
(fill-text context "▸" gutter-x (+ y text-offset-y))) (fill-text context "▸" gutter-x (+ y text-offset-y)))
(if (and (>= r -1) (< r-index num-items) (< r r-end)) (when (>= r -1)
(fill-text context (fill-text context
(if (= r -1) (cond
(if (= (current-menu-page) 0) "Back" "...") ((= r-menu-index -1) "Back")
(if (and (= r (1- r-end)) (< r-index (1- num-items))) ((or (= r -1) (and (= r (1- r-end)) (< r-menu-index (1- num-items))))
"..." "...")
(menu-item-name (vector-ref (menu-items (current-menu)) (else
r-index)))) (menu-item-name (vector-ref (menu-items (current-menu)) r-menu-index))))
text-x (+ y text-offset-y)))) text-x (+ y text-offset-y)))
;; Draw next row ;; Draw next row
(set! r (1+ r)) (when (and (< (1+ r) r-end) (< (1+ r-menu-index) num-items))
(if (< r (+ r-start height)) (row (1+ r) (+ y tile-height)))))))
(row r (+ y tile-height))))))
(define (draw-level) (define (draw-level)
(draw-background) (draw-background)