Optimizing conditionals
This commit is contained in:
parent
6aed092c24
commit
0e5fc5a73b
1 changed files with 14 additions and 15 deletions
29
game.scm
29
game.scm
|
@ -748,14 +748,14 @@
|
|||
(let row ((r r-start)
|
||||
(y (- (vec2-y center) (* tile-height (floor (/ height 2))))))
|
||||
;; Draw menu background
|
||||
(if (= r r-start)
|
||||
(let* ((x (- (vec2-x center) (* tile-width (floor (/ width 2)))))
|
||||
(w (* tile-width width))
|
||||
(h (* tile-height height)))
|
||||
(set-fill-color! context "#000")
|
||||
(fill-rect context x y w h)
|
||||
(set-stroke-color! context "blue")
|
||||
(stroke-rect context x y w h)))
|
||||
(when (= r r-start)
|
||||
(let* ((x (- (vec2-x center) (* tile-width (floor (/ width 2)))))
|
||||
(w (* tile-width width))
|
||||
(h (* tile-height height)))
|
||||
(set-fill-color! context "#000")
|
||||
(fill-rect context x y w h)
|
||||
(set-stroke-color! context "blue")
|
||||
(stroke-rect context x y w h)))
|
||||
;; Draw menu text
|
||||
(set-text-align! context "center")
|
||||
(set-font! context "normal 16px monogram")
|
||||
|
@ -764,13 +764,12 @@
|
|||
(if (= r r-start)
|
||||
(fill-text context (menu-name (current-menu)) (vec2-x center) (+ y text-offset-y))
|
||||
(if (and (>= r -1) (< r-index num-items) (< r r-end))
|
||||
(let* ((item (cond
|
||||
((= r -1)
|
||||
(if (= (current-menu-page) 0) "Back" "..."))
|
||||
((and (= r (1- r-end)) (< r-index (1- num-items)))
|
||||
"...")
|
||||
(else
|
||||
(menu-item-name (vector-ref (menu-items (current-menu)) r-index)))))
|
||||
(let* ((item (if (= r -1)
|
||||
(if (= (current-menu-page) 0)
|
||||
"Back" "...")
|
||||
(if (and (= r (1- r-end)) (< r-index (1- num-items)))
|
||||
"..."
|
||||
(menu-item-name (vector-ref (menu-items (current-menu)) r-index)))))
|
||||
(text (string-append (if (= r-index (current-menu-index)) "▸ " " ") item)))
|
||||
(fill-text context text (vec2-x center) (+ y text-offset-y))))))
|
||||
;; Draw next row
|
||||
|
|
Loading…
Add table
Reference in a new issue