music menu (untested)

This commit is contained in:
Kistaro Windrider 2024-02-28 23:38:47 -08:00
parent c35c9f0c3e
commit e83f7002a2
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -149,20 +149,38 @@ function _init()
awakener_hold_frames = 0 awakener_hold_frames = 0
-- debug mode: skip splahes -- debug mode: skip splahes
mainview = ao_splash.new() mainview = ao_splash.new()
menuitem(1, "⬅️ music: on ➡️", cycle_music)
musicmode = 0
--arm_awakener() --arm_awakener()
--mainview=newtitle() --mainview=newtitle()
end 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() function arm_awakener()
awakener_hold_frames=0 awakener_hold_frames=0
awakener_armed=true awakener_armed=true
menuitem(1, "awaken now", awaken_now) menuitem(2, "awaken now", awaken_now)
end end
function awaken_now() function awaken_now()
exit_dither = ditherer.new{di=1} exit_dither = ditherer.new{di=1}
awakener_armed = false awakener_armed = false
menuitem(1) menuitem(2)
end end
function _update60() function _update60()
@ -702,7 +720,16 @@ function zonk_mode:av()
if (type(self.file) == "string") self.file = split(self.file, "\n") if (type(self.file) == "string") self.file = split(self.file, "\n")
if (not self.file) self:nf() if (not self.file) self:nf()
assert(self.file) 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 end
function zonk_mode:nf() function zonk_mode:nf()
@ -832,7 +859,7 @@ function zonk_mode:u()
self.brth:u() self.brth:u()
self.txt_frame:u() self.txt_frame:u()
if (self.d and self.d:u()) seq:next() 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) music(self.nextbgm, 500, 7)
self.nextbgm = nil self.nextbgm = nil
end end
@ -1126,6 +1153,9 @@ function title_screen:av()
self.a:av() self.a:av()
font_monogram() font_monogram()
end end
function title_screen:onmchg()
self.a:onmchg()
end
function title_screen:draw() function title_screen:draw()
self.a:draw() self.a:draw()
@ -1493,10 +1523,14 @@ mknew(arcade_level, function(x)
end) end)
function arcade_level:av() function arcade_level:av()
music(0,1000,7) if (musicmode & 1 ==0) music(0,1000,7)
font_compact() font_compact()
end end
function ggwp:onmchg()
music((musicmode & 0x1 == 0) and 0 or -1, 500, 7)
end
function arcade_level:u() function arcade_level:u()
if self.phin.entered then if self.phin.entered then
if self.wordtimer <= 0 and self.wordremain > 0 then if self.wordtimer <= 0 and self.wordremain > 0 then
@ -1637,6 +1671,7 @@ mknew(ggwp)
function ggwp:av() function ggwp:av()
font_monogram() font_monogram()
if (musicmode & 1 == 0) music(0,500,7)
local score_pct = 100 local score_pct = 100
if seq.max_score ~= 0 then if seq.max_score ~= 0 then
score_pct = seq.score/seq.max_score*100\1 score_pct = seq.score/seq.max_score*100\1
@ -1676,6 +1711,10 @@ accomplishment already. will you
end end
end end
function ggwp:onmchg()
music((musicmode & 0x1 == 0) and 0 or -1, 500, 7)
end
function ggwp:u() function ggwp:u()
if (hz(2) ~= self.lasthz) self.col = irnd(8)+8 if (hz(2) ~= self.lasthz) self.col = irnd(8)+8
self.lasthz = hz(2) self.lasthz = hz(2)