init example
After Width: | Height: | Size: 713 B |
After Width: | Height: | Size: 820 B |
After Width: | Height: | Size: 789 B |
After Width: | Height: | Size: 734 B |
|
@ -0,0 +1,105 @@
|
||||||
|
(use-modules (tsukundere)
|
||||||
|
(sdl2)
|
||||||
|
(sdl2 ttf)
|
||||||
|
(ice-9 match)
|
||||||
|
(tsukundere button)
|
||||||
|
(tsukundere game)
|
||||||
|
(tsukundere scene)
|
||||||
|
(tsukundere geometry)
|
||||||
|
(tsukundere script utils))
|
||||||
|
|
||||||
|
(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 0 255 0 255))
|
||||||
|
(hover . ,(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)
|
||||||
|
(hover . ,simple-hover)
|
||||||
|
(pressed . ,simple-pressed)))
|
||||||
|
(checkbox-button
|
||||||
|
(make-button (s32vector 0 0) "" 0 font textures
|
||||||
|
#:text-colors colors
|
||||||
|
#:callback checkbox-button-callback))
|
||||||
|
(radio-button
|
||||||
|
(make-button (s32vector 0 0) "" 0 font textures-radio
|
||||||
|
#:text-colors colors
|
||||||
|
#:callback radio-button-callback))
|
||||||
|
(simple-button
|
||||||
|
(make-button (s32vector 0 0) "" 0 font textures-button
|
||||||
|
#:text-colors colors
|
||||||
|
#:callback simple-button-callback)))
|
||||||
|
(init-script!
|
||||||
|
(lambda ()
|
||||||
|
(background paper)
|
||||||
|
(say "nixo" "This is not an exam!")
|
||||||
|
(pause)
|
||||||
|
(say "nixo" "Chose one and press enter!")
|
||||||
|
(say "nixo"
|
||||||
|
(format #f "You choose: ~a\n"
|
||||||
|
(menu
|
||||||
|
'("Select me!" "Or me!" "No, select me!")
|
||||||
|
#:template radio-button)))
|
||||||
|
(pause)
|
||||||
|
(say "nixo" "Chose as many as you want!")
|
||||||
|
(say "nixo"
|
||||||
|
(format #f "You selected: ~a\n"
|
||||||
|
(menu '(("A") ("B") ("C"))
|
||||||
|
#:template checkbox-button)))
|
||||||
|
(pause)
|
||||||
|
(say "nixo" "Click it!")
|
||||||
|
(say "nixo"
|
||||||
|
(format #f "You selected the element number: ~a\n"
|
||||||
|
(menu
|
||||||
|
'("Yes" "Maybe" "No way"))))
|
||||||
|
(say "nixo"
|
||||||
|
(format #f "You selected the element: ~a\n"
|
||||||
|
(menu
|
||||||
|
'(("Yes") ("Maybe") ("No way")))))
|
||||||
|
(say "nixo"
|
||||||
|
(format #f "You selected the element: ~a\n"
|
||||||
|
(menu
|
||||||
|
'((yep "Yes") (maybe "Maybe") (nope "No way")))))
|
||||||
|
(pause)
|
||||||
|
;; (format #f "You selected the element with value: ~a\n"
|
||||||
|
;; (menu
|
||||||
|
;; '(("Yes" I am happy now)
|
||||||
|
;; ("Maybe" you have more time to decide)
|
||||||
|
;; ("No way" that makes me sad))))
|
||||||
|
)
|
||||||
|
scene)
|
||||||
|
(init-menu! 100 100 (s32vector 0 50) font textures
|
||||||
|
(s32vector 50 18)
|
||||||
|
#:colors colors
|
||||||
|
#:template simple-button)
|
||||||
|
(init-text! 10 300 280 font font)))
|
||||||
|
|
||||||
|
(run-game
|
||||||
|
#:game-name ".tsukundere-example-buttons"
|
||||||
|
#:window-width 400
|
||||||
|
#:window-height 400
|
||||||
|
#:init! load)
|
||||||
|
|
||||||
|
(use-modules (ice-9 match))
|
||||||
|
(let ((option "OK"))
|
||||||
|
(match option
|
||||||
|
(selected selected)
|
||||||
|
((value selected) selected)
|
||||||
|
((selected . value) selected)))
|
After Width: | Height: | Size: 729 B |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 541 B |