Optimizing conditionals
This commit is contained in:
parent
6aed092c24
commit
0e5fc5a73b
1 changed files with 14 additions and 15 deletions
13
game.scm
13
game.scm
|
@ -748,7 +748,7 @@
|
||||||
(let row ((r r-start)
|
(let row ((r r-start)
|
||||||
(y (- (vec2-y center) (* tile-height (floor (/ height 2))))))
|
(y (- (vec2-y center) (* tile-height (floor (/ height 2))))))
|
||||||
;; Draw menu background
|
;; Draw menu background
|
||||||
(if (= 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)))
|
||||||
|
@ -764,12 +764,11 @@
|
||||||
(if (= r r-start)
|
(if (= r r-start)
|
||||||
(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))
|
||||||
(if (and (>= r -1) (< r-index num-items) (< r r-end))
|
(if (and (>= r -1) (< r-index num-items) (< r r-end))
|
||||||
(let* ((item (cond
|
(let* ((item (if (= r -1)
|
||||||
((= r -1)
|
(if (= (current-menu-page) 0)
|
||||||
(if (= (current-menu-page) 0) "Back" "..."))
|
"Back" "...")
|
||||||
((and (= r (1- r-end)) (< r-index (1- num-items)))
|
(if (and (= r (1- r-end)) (< r-index (1- num-items)))
|
||||||
"...")
|
"..."
|
||||||
(else
|
|
||||||
(menu-item-name (vector-ref (menu-items (current-menu)) r-index)))))
|
(menu-item-name (vector-ref (menu-items (current-menu)) r-index)))))
|
||||||
(text (string-append (if (= r-index (current-menu-index)) "▸ " " ") item)))
|
(text (string-append (if (= r-index (current-menu-index)) "▸ " " ") item)))
|
||||||
(fill-text context text (vec2-x center) (+ y text-offset-y))))))
|
(fill-text context text (vec2-x center) (+ y text-offset-y))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue