From e83f7002a2f4510c3562628366e5861a1c57116b Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Wed, 28 Feb 2024 23:38:47 -0800 Subject: [PATCH] music menu (untested) --- vacation.p8 | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/vacation.p8 b/vacation.p8 index 7180a1d..40a5593 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -149,20 +149,38 @@ function _init() awakener_hold_frames = 0 -- debug mode: skip splahes mainview = ao_splash.new() + menuitem(1, "⬅️ music: on ➡️", cycle_music) + musicmode = 0 --arm_awakener() --mainview=newtitle() end +mlbl={"on", "text", "game", "off"} + +function cycle_music(b) + if b & 1 ~= 0 then + -- left + musicmode -= 1 + if (musicmode < 0) musicmode = 3 + elseif b & 34 ~= 0 then + musicmode += 1 + if (musicmode > 3) musicmode = 0 + end + if (mainview and mainview.onmchg) mainview:onmchg(musicmode) + menuitem(nil, "⬅️ music: "..mlbl[musicmode+1].." ➡️") + return true -- stay open +end + function arm_awakener() awakener_hold_frames=0 awakener_armed=true - menuitem(1, "awaken now", awaken_now) + menuitem(2, "awaken now", awaken_now) end function awaken_now() exit_dither = ditherer.new{di=1} awakener_armed = false - menuitem(1) + menuitem(2) end function _update60() @@ -702,7 +720,16 @@ function zonk_mode:av() if (type(self.file) == "string") self.file = split(self.file, "\n") if (not self.file) self:nf() assert(self.file) - if (self.bgm) music(self.bgm,1000,7) + if (self.bgm and (musicmode & 2 == 0)) music(self.bgm,1000,7) +end + +function zonk_mode:onmchg() + if (musicmode & 2 == 0 and not self.xbgm) then + music(self.nextbgm or self.bgm or -1, 500, 7) + self.nextbgm = nil + else + music(-1, 250) + end end function zonk_mode:nf() @@ -832,7 +859,7 @@ function zonk_mode:u() self.brth:u() self.txt_frame:u() if (self.d and self.d:u()) seq:next() - if not self.d and self.nextbgm and not self.xbgm and stat(56) <= 0 then + if not self.d and self.nextbgm and not self.xbgm and (musicmode & 2 == 0) and stat(56) <= 0 then music(self.nextbgm, 500, 7) self.nextbgm = nil end @@ -1126,6 +1153,9 @@ function title_screen:av() self.a:av() font_monogram() end +function title_screen:onmchg() + self.a:onmchg() +end function title_screen:draw() self.a:draw() @@ -1493,10 +1523,14 @@ mknew(arcade_level, function(x) end) function arcade_level:av() - music(0,1000,7) + if (musicmode & 1 ==0) music(0,1000,7) font_compact() end +function ggwp:onmchg() + music((musicmode & 0x1 == 0) and 0 or -1, 500, 7) +end + function arcade_level:u() if self.phin.entered then if self.wordtimer <= 0 and self.wordremain > 0 then @@ -1637,6 +1671,7 @@ mknew(ggwp) function ggwp:av() font_monogram() + if (musicmode & 1 == 0) music(0,500,7) local score_pct = 100 if seq.max_score ~= 0 then score_pct = seq.score/seq.max_score*100\1 @@ -1676,6 +1711,10 @@ accomplishment already. will you end end +function ggwp:onmchg() + music((musicmode & 0x1 == 0) and 0 or -1, 500, 7) +end + function ggwp:u() if (hz(2) ~= self.lasthz) self.col = irnd(8)+8 self.lasthz = hz(2)