Use make-menu/run-menu directly for special menus.

master
Leo Prikler 2021-01-12 00:40:55 +01:00 committed by nixo
parent f2389ceeb2
commit 5cbb11439d
1 changed files with 32 additions and 17 deletions

49
run.scm
View File

@ -2,7 +2,9 @@
(sdl2)
(sdl2 ttf)
(ice-9 match)
(tsukundere menu button))
(srfi srfi-26)
(tsukundere menu button)
(tsukundere menu)) ; make-menu run-menu
(define (load)
(let* ((scene
@ -40,6 +42,11 @@
#:text-pos (s32vector 30 -7)
#:text-alignment '(left . top)
#:callback checkbox-button-callback))
(checkbox-menu
(make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50)
#:button-prototype checkbox-button
#:accumulator
(cute menu-fold <> '() cons)))
(radio-button
(make-button (s32vector 0 0) "" 0 font textures-radio
#:text-colors colors
@ -48,6 +55,10 @@
#:text-alignment '(left . top)
#:text-pos (s32vector 30 0)
#:callback radio-button-callback))
(radio-menu
(make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50)
#:button-prototype radio-button))
(simple-button
(make-button (s32vector 0 0) "" 0 font textures-button
#:text-colors colors
@ -56,6 +67,9 @@
#:anchor 'center
#:text-alignment '(center . center)
#:callback simple-button-callback))
(simple-menu
(make-menu '() #:pos #s32(100 100) #:spacing #s32(0 50)
#:button-prototype simple-button))
(nixo (make-speaker "nixo")))
(init-script!
(lambda ()
@ -66,27 +80,27 @@
(nixo "Choose one and press enter!")
(nixo
(format #f "You chose: ~a\n"
(menu
(("Select me!")
("Or me!")
("No, select me!"))
#:prototype ,radio-button)))
(run-menu
(make-menu '(("Select me!")
("Or me!")
("No, select me!"))
#:prototype radio-menu))))
(nixo "Choose as many as you want!")
(nixo
(format #f "You chose ~a\n"
(menu (("A" 0)
("B" 1)
("C" 2))
#:prototype ,checkbox-button
#:seed () #:pressed ,cons)))
(run-menu
(make-menu '(("A" 0)
("B" 1)
("C" 2))
#:prototype checkbox-menu))))
(nixo "Choose as many as you want!")
(nixo
(format #f "You chose ~a\n"
(menu (("A" 0 (pressed))
("B" 1 (selected))
("C" 2 (pressed)))
#:prototype ,checkbox-button
#:seed () #:pressed ,cons)))
(run-menu
(make-menu '(("A" 0 (pressed))
("B" 1 (selected))
("C" 2 (pressed)))
#:prototype checkbox-menu))))
(nixo "Click it!")
(nixo
(format #f "You chose the element number: ~a\n"
@ -101,7 +115,8 @@
(menu (("Yes" yep) ("Maybe" maybe) ("No way" nope)))))
*unspecified*))
scene)
(init-menu! #s32(100 100) #s32(0 50) simple-button #:scene scene)
(scene-add-object! scene 'menu simple-menu) ; roughly equivalent to init-menu! below
;; (init-menu! #s32(100 100) #s32(0 50) simple-button #:scene scene)
(init-text! 10 300 280 font font #:scene scene)))
(run-game