(use-modules (tsukundere) (sdl2) (sdl2 ttf) (ice-9 match) (tsukundere menu button)) (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)) (colors `((none . ,(make-color 80 225 100 255)) (selected . ,(make-color 255 0 0 255)) (pressed . ,(make-color 0 0 255 255)))) (textures `((none . ,texture) (pressed . ,selected))) (textures-radio `((none . ,radio) (pressed . ,radio-selected))) (textures-button `((none . ,simple) (selected . ,simple-hover) (pressed . ,simple-pressed))) (checkbox-button (make-button (s32vector 0 0) "" 0 font textures #:text-colors colors #:text-pos (s32vector 30 5) #:text-alignment '(left . top) #:callback checkbox-button-callback)) (radio-button (make-button (s32vector 0 0) "" 0 font textures-radio #:text-colors colors #:text-alignment '(left . top) #:text-pos (s32vector 30 0) #:callback radio-button-callback)) (simple-button (make-button (s32vector 0 0) "" 0 font textures-button #:text-colors colors ;; Put text at the center of the button #:text-pos (s32vector 0 0) #:anchor 'center #:text-alignment '(center . center) #:callback simple-button-callback)) (nixo (make-speaker "nixo"))) (init-script! (lambda () (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*)) scene) (init-menu! #s32(100 100) #s32(0 50) simple-button #:scene scene) (init-text! 10 300 280 font font #:scene scene))) (run-game #:game-name ".tsukundere-example-buttons" #:window-width 400 #:window-height 400 #:init! load)