commit 86584d54bb6a87a6a4d6e9fa3c8e71d96feef5ea Author: nixo Date: Mon Dec 14 17:46:49 2020 +0100 init example diff --git a/JuliaMono.ttf b/JuliaMono.ttf new file mode 100644 index 0000000..7a32371 Binary files /dev/null and b/JuliaMono.ttf differ diff --git a/checked_box.png b/checked_box.png new file mode 100644 index 0000000..5de14e0 Binary files /dev/null and b/checked_box.png differ diff --git a/paper.png b/paper.png new file mode 100644 index 0000000..c44d1d8 Binary files /dev/null and b/paper.png differ diff --git a/round_button_hover.png b/round_button_hover.png new file mode 100644 index 0000000..fcacc36 Binary files /dev/null and b/round_button_hover.png differ diff --git a/round_button_mouse_down.png b/round_button_mouse_down.png new file mode 100644 index 0000000..a15a6ad Binary files /dev/null and b/round_button_mouse_down.png differ diff --git a/round_button_normal.png b/round_button_normal.png new file mode 100644 index 0000000..431e29b Binary files /dev/null and b/round_button_normal.png differ diff --git a/run.scm b/run.scm new file mode 100644 index 0000000..73a3aa9 --- /dev/null +++ b/run.scm @@ -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))) diff --git a/selected_radio_button.png b/selected_radio_button.png new file mode 100644 index 0000000..5592e90 Binary files /dev/null and b/selected_radio_button.png differ diff --git a/unchecked_box.png b/unchecked_box.png new file mode 100644 index 0000000..58abbfc Binary files /dev/null and b/unchecked_box.png differ diff --git a/unselected_radio_button.png b/unselected_radio_button.png new file mode 100644 index 0000000..0ad94b0 Binary files /dev/null and b/unselected_radio_button.png differ