2020-12-14 17:46:49 +01:00
|
|
|
(use-modules (tsukundere)
|
|
|
|
(sdl2)
|
|
|
|
(sdl2 ttf)
|
|
|
|
(ice-9 match)
|
2021-01-05 19:09:34 +01:00
|
|
|
(tsukundere menu button))
|
2020-12-14 17:46:49 +01:00
|
|
|
|
|
|
|
(define (load)
|
|
|
|
(let* ((scene
|
|
|
|
(make-scene '(background
|
|
|
|
text
|
|
|
|
menu)))
|
|
|
|
(paper (load-image "paper.png"))
|
|
|
|
(texture (load-image "unchecked_box.png"))
|
|
|
|
(selected (load-image "checked_box.png"))
|
|
|
|
(radio (load-image "unselected_radio_button.png"))
|
|
|
|
(radio-selected (load-image "selected_radio_button.png"))
|
|
|
|
(simple (load-image "round_button_normal.png"))
|
|
|
|
(simple-hover (load-image "round_button_hover.png"))
|
|
|
|
(simple-pressed (load-image "round_button_mouse_down.png"))
|
|
|
|
(font (load-font "JuliaMono.ttf" 18))
|
2020-12-15 01:14:27 +01:00
|
|
|
(colors
|
|
|
|
`((none . ,(make-color 80 225 100 255))
|
|
|
|
(hover . ,(make-color 255 0 0 255))
|
|
|
|
(pressed . ,(make-color 0 0 255 255))))
|
|
|
|
(textures
|
|
|
|
`((none . ,texture)
|
|
|
|
(pressed . ,selected)))
|
2020-12-14 17:46:49 +01:00
|
|
|
(textures-radio
|
|
|
|
`((none . ,radio)
|
|
|
|
(pressed . ,radio-selected)))
|
|
|
|
(textures-button
|
|
|
|
`((none . ,simple)
|
|
|
|
(hover . ,simple-hover)
|
|
|
|
(pressed . ,simple-pressed)))
|
|
|
|
(checkbox-button
|
|
|
|
(make-button (s32vector 0 0) "" 0 font textures
|
|
|
|
#:text-colors colors
|
2020-12-15 01:14:27 +01:00
|
|
|
#:text-pos (s32vector 30 5)
|
|
|
|
#:text-alignment '(left . top)
|
2020-12-14 17:46:49 +01:00
|
|
|
#:callback checkbox-button-callback))
|
|
|
|
(radio-button
|
|
|
|
(make-button (s32vector 0 0) "" 0 font textures-radio
|
|
|
|
#:text-colors colors
|
2020-12-15 01:14:27 +01:00
|
|
|
#:text-alignment '(left . top)
|
|
|
|
#:text-pos (s32vector 30 0)
|
2020-12-14 17:46:49 +01:00
|
|
|
#:callback radio-button-callback))
|
|
|
|
(simple-button
|
|
|
|
(make-button (s32vector 0 0) "" 0 font textures-button
|
|
|
|
#:text-colors colors
|
2020-12-15 01:14:27 +01:00
|
|
|
;; Put text at the center of the button
|
|
|
|
#:text-pos (s32vector 0 0)
|
|
|
|
#:anchor 'center
|
|
|
|
#:text-alignment '(center . center)
|
2021-01-05 19:09:34 +01:00
|
|
|
#:callback simple-button-callback))
|
|
|
|
(nixo (make-speaker "nixo")))
|
2020-12-14 17:46:49 +01:00
|
|
|
(init-script!
|
|
|
|
(lambda ()
|
2021-01-05 19:09:34 +01:00
|
|
|
(script
|
|
|
|
(begin
|
|
|
|
(background paper)
|
|
|
|
(nixo "This is not an exam!"))
|
|
|
|
(nixo "Chose one and press enter!")
|
|
|
|
(nixo
|
|
|
|
(format #f "You choose: ~a\n"
|
|
|
|
(menu
|
|
|
|
'("Select me!" "Or me!" "No, select me!")
|
|
|
|
#:prototype radio-button)))
|
|
|
|
(nixo "Chose as many as you want!")
|
|
|
|
(nixo
|
|
|
|
(format #f "You selected: ~a\n"
|
|
|
|
(menu '(("A") ("B") ("C"))
|
|
|
|
#:prototype checkbox-button
|
|
|
|
#:seed '() #:pressed cons)))
|
|
|
|
(nixo "Click it!")
|
|
|
|
(nixo
|
|
|
|
(format #f "You selected the element number: ~a\n"
|
|
|
|
(menu
|
|
|
|
'("Yes" "Maybe" "No way"))))
|
|
|
|
(nixo "Click it again!")
|
|
|
|
(nixo
|
|
|
|
(format #f "You selected the element: ~a\n"
|
|
|
|
(menu
|
|
|
|
'(("Yes") ("Maybe") ("No way")))))
|
|
|
|
(nixo "Once more!")
|
|
|
|
(nixo
|
|
|
|
(format #f "You selected the element: ~a\n"
|
|
|
|
(menu
|
|
|
|
'(("Yes" . yep) ("Maybe" . maybe) ("No way" . nope)))))
|
|
|
|
*unspecified*))
|
2020-12-14 17:46:49 +01:00
|
|
|
scene)
|
2021-01-05 19:09:34 +01:00
|
|
|
(init-menu! #s32(100 100) #s32(0 50) #f simple-button #:scene scene)
|
|
|
|
(init-text! 10 300 280 font font #:scene scene)))
|
2020-12-14 17:46:49 +01:00
|
|
|
|
|
|
|
(run-game
|
|
|
|
#:game-name ".tsukundere-example-buttons"
|
|
|
|
#:window-width 400
|
|
|
|
#:window-height 400
|
|
|
|
#:init! load)
|