make music toggle button graphic instead of text
This commit is contained in:
42
menu.sex
42
menu.sex
@@ -8,6 +8,8 @@
|
||||
(pub record menu-state
|
||||
((app-state (* app-state))
|
||||
(bg Texture2D)
|
||||
(mus-on Texture2D)
|
||||
(mus-off Texture2D)
|
||||
(btn-to-game int)
|
||||
(btn-toggle-music int)
|
||||
(btn-exit int)))
|
||||
@@ -18,8 +20,7 @@
|
||||
(define BTN-WIDTH 320.0)
|
||||
(define BTN-HEIGHT 72.0)
|
||||
|
||||
(define MUSIC-BTN-WIDTH 240.0)
|
||||
(define MUSIC-BTN-HEIGHT 60.0)
|
||||
(define MUSIC-BTN-SIZE 64.0)
|
||||
(define MUSIC-BTN-MARGIN 40.0)
|
||||
|
||||
(pub fn mk-menu ((app-state (* app-state))) page
|
||||
@@ -32,9 +33,17 @@
|
||||
(var img Image (LoadImage "res/img/menu.png"))
|
||||
(ImageResize (& img) WIN-WIDTH WIN-HEIGHT)
|
||||
(= (. state bg) (LoadTextureFromImage img))
|
||||
(= (. state mus-on) (LoadTexture "res/img/mus.png"))
|
||||
(= (. state mus-off) (LoadTexture "res/img/mus_off.png"))
|
||||
(return (page/menu state)))
|
||||
|
||||
(pub fn rm-menu ((state (* menu-state))) void
|
||||
(if (IsTextureValid (. state bg))
|
||||
(UnloadTexture (. state bg)))
|
||||
(if (IsTextureValid (. state mus-on))
|
||||
(UnloadTexture (. state mus-on)))
|
||||
(if (IsTextureValid (. state mus-off))
|
||||
(UnloadTexture (. state mus-off)))
|
||||
(free state)
|
||||
(return))
|
||||
|
||||
@@ -55,15 +64,32 @@
|
||||
BTN-WIDTH
|
||||
BTN-HEIGHT) "Quit"))
|
||||
|
||||
(var music-label (* const char) "Music: On")
|
||||
(if (! (audio-music-enabled))
|
||||
(= music-label "Music: Off"))
|
||||
(var music-x float (- WIN-WIDTH (+ MUSIC-BTN-MARGIN MUSIC-BTN-SIZE)))
|
||||
(= (. state btn-toggle-music)
|
||||
(GuiButton #(Rectangle :
|
||||
(- WIN-WIDTH (+ MUSIC-BTN-MARGIN MUSIC-BTN-WIDTH))
|
||||
music-x
|
||||
MUSIC-BTN-MARGIN
|
||||
MUSIC-BTN-WIDTH
|
||||
MUSIC-BTN-HEIGHT) music-label))
|
||||
MUSIC-BTN-SIZE
|
||||
MUSIC-BTN-SIZE) ""))
|
||||
|
||||
(var music-icon Texture2D (. state mus-on))
|
||||
(if (! (audio-music-enabled))
|
||||
(= music-icon (. state mus-off)))
|
||||
(if (IsTextureValid music-icon)
|
||||
(DrawTexturePro music-icon
|
||||
#(Rectangle :
|
||||
0.0f
|
||||
0.0f
|
||||
(cast (. music-icon width) float)
|
||||
(cast (. music-icon height) float))
|
||||
#(Rectangle :
|
||||
music-x
|
||||
MUSIC-BTN-MARGIN
|
||||
MUSIC-BTN-SIZE
|
||||
MUSIC-BTN-SIZE)
|
||||
#(Vector2 : 0.0f 0.0f)
|
||||
0.0f
|
||||
WHITE))
|
||||
|
||||
(EndDrawing))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user