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
|
(pub record menu-state
|
||||||
((app-state (* app-state))
|
((app-state (* app-state))
|
||||||
(bg Texture2D)
|
(bg Texture2D)
|
||||||
|
(mus-on Texture2D)
|
||||||
|
(mus-off Texture2D)
|
||||||
(btn-to-game int)
|
(btn-to-game int)
|
||||||
(btn-toggle-music int)
|
(btn-toggle-music int)
|
||||||
(btn-exit int)))
|
(btn-exit int)))
|
||||||
@@ -18,8 +20,7 @@
|
|||||||
(define BTN-WIDTH 320.0)
|
(define BTN-WIDTH 320.0)
|
||||||
(define BTN-HEIGHT 72.0)
|
(define BTN-HEIGHT 72.0)
|
||||||
|
|
||||||
(define MUSIC-BTN-WIDTH 240.0)
|
(define MUSIC-BTN-SIZE 64.0)
|
||||||
(define MUSIC-BTN-HEIGHT 60.0)
|
|
||||||
(define MUSIC-BTN-MARGIN 40.0)
|
(define MUSIC-BTN-MARGIN 40.0)
|
||||||
|
|
||||||
(pub fn mk-menu ((app-state (* app-state))) page
|
(pub fn mk-menu ((app-state (* app-state))) page
|
||||||
@@ -32,9 +33,17 @@
|
|||||||
(var img Image (LoadImage "res/img/menu.png"))
|
(var img Image (LoadImage "res/img/menu.png"))
|
||||||
(ImageResize (& img) WIN-WIDTH WIN-HEIGHT)
|
(ImageResize (& img) WIN-WIDTH WIN-HEIGHT)
|
||||||
(= (. state bg) (LoadTextureFromImage img))
|
(= (. 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)))
|
(return (page/menu state)))
|
||||||
|
|
||||||
(pub fn rm-menu ((state (* menu-state))) void
|
(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)
|
(free state)
|
||||||
(return))
|
(return))
|
||||||
|
|
||||||
@@ -55,15 +64,32 @@
|
|||||||
BTN-WIDTH
|
BTN-WIDTH
|
||||||
BTN-HEIGHT) "Quit"))
|
BTN-HEIGHT) "Quit"))
|
||||||
|
|
||||||
(var music-label (* const char) "Music: On")
|
(var music-x float (- WIN-WIDTH (+ MUSIC-BTN-MARGIN MUSIC-BTN-SIZE)))
|
||||||
(if (! (audio-music-enabled))
|
|
||||||
(= music-label "Music: Off"))
|
|
||||||
(= (. state btn-toggle-music)
|
(= (. state btn-toggle-music)
|
||||||
(GuiButton #(Rectangle :
|
(GuiButton #(Rectangle :
|
||||||
(- WIN-WIDTH (+ MUSIC-BTN-MARGIN MUSIC-BTN-WIDTH))
|
music-x
|
||||||
MUSIC-BTN-MARGIN
|
MUSIC-BTN-MARGIN
|
||||||
MUSIC-BTN-WIDTH
|
MUSIC-BTN-SIZE
|
||||||
MUSIC-BTN-HEIGHT) music-label))
|
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))
|
(EndDrawing))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user