Add music manager
This commit is contained in:
parent
da41929613
commit
3b9c61329b
@ -33,6 +33,15 @@ end
|
|||||||
function completion_tracker:advance_completion_level(clevel)
|
function completion_tracker:advance_completion_level(clevel)
|
||||||
dset(0,max(dget(0), clevel))
|
dset(0,max(dget(0), clevel))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function completion_tracker:get_music_preference()
|
||||||
|
return dget(59)==0
|
||||||
|
end
|
||||||
|
function completion_tracker:set_music_preference()
|
||||||
|
if (dget(59)==0) dset(59,1) return
|
||||||
|
dset(59,0)
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: Bitfield instead
|
-- TODO: Bitfield instead
|
||||||
function completion_tracker:mark_seen(text_id)
|
function completion_tracker:mark_seen(text_id)
|
||||||
local ix,bit=self:_unpack_text_id(text_id)
|
local ix,bit=self:_unpack_text_id(text_id)
|
||||||
|
1
main.lua
1
main.lua
@ -2,7 +2,6 @@ main={}
|
|||||||
add(modules,main)
|
add(modules,main)
|
||||||
|
|
||||||
function main:init()
|
function main:init()
|
||||||
music(0)
|
|
||||||
extcmd("rec")
|
extcmd("rec")
|
||||||
self.state_manager=state_manager:new() -- instantiate one global
|
self.state_manager=state_manager:new() -- instantiate one global
|
||||||
self.state_manager:push(state_menu:new())
|
self.state_manager:push(state_menu:new())
|
||||||
|
1
main.p8
1
main.p8
@ -14,6 +14,7 @@ __lua__
|
|||||||
#include layout.lua
|
#include layout.lua
|
||||||
#include layout_hint.lua
|
#include layout_hint.lua
|
||||||
#include liturgy.lua
|
#include liturgy.lua
|
||||||
|
#include music_manager.lua
|
||||||
#include ruleset.lua
|
#include ruleset.lua
|
||||||
#include palette.lua
|
#include palette.lua
|
||||||
#include progression.lua
|
#include progression.lua
|
||||||
|
10
music_manager.lua
Normal file
10
music_manager.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
music_manager={}
|
||||||
|
add(modules,music_manager)
|
||||||
|
function music_manager:init()
|
||||||
|
end
|
||||||
|
function music_manager:update()
|
||||||
|
local is_playing = stat(54) != -1
|
||||||
|
local should_be_playing = completion_tracker:get_music_preference()
|
||||||
|
if (is_playing and not should_be_playing) music(-1,500)
|
||||||
|
if (not is_playing and should_be_playing) music(0)
|
||||||
|
end
|
@ -10,8 +10,12 @@ function state_menu:init()
|
|||||||
main.state_manager:push(state_archaeology:new())
|
main.state_manager:push(state_archaeology:new())
|
||||||
end),
|
end),
|
||||||
menu_option:new(),
|
menu_option:new(),
|
||||||
menu_option:new(function() return "music" end,function()
|
menu_option:new(function()
|
||||||
-- todo: music manager
|
local pref=completion_tracker:get_music_preference()
|
||||||
|
if (pref) return "stop music"
|
||||||
|
return "start music"
|
||||||
|
end,function()
|
||||||
|
completion_tracker:set_music_preference(not completion_tracker:get_music_preference())
|
||||||
end),
|
end),
|
||||||
menu_option:new(function() return "reset data" end,function()
|
menu_option:new(function() return "reset data" end,function()
|
||||||
main.state_manager:push(state_reset_menu:new(self))
|
main.state_manager:push(state_reset_menu:new(self))
|
||||||
|
Loading…
Reference in New Issue
Block a user