diff --git a/assets/fmod20221/init.lua b/assets/fmod20221/init.lua index 681f1ff3..dd4de697 100644 --- a/assets/fmod20221/init.lua +++ b/assets/fmod20221/init.lua @@ -295,7 +295,7 @@ setmetatable(M.music,{__call=function(_,...) return M.music.play(...) end}) -------------------------- ---@class FMOD._Effect ----@overload fun(name:string, args?:{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? +---@overload fun(name:string, args?:number|{instant?:boolean, volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table}):FMOD.Studio.EventInstance? M.effect={} ---@param v number @@ -321,7 +321,7 @@ local unhintedSFX={} --- ---param:{'paramName', 0, true?} ---@param name string ----@param args? {volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table} +---@param args? number|{volume?:number, pitch?:number, tune?:number, fine?:number, pos?:number[], param?:table} ---@return FMOD.Studio.EventInstance? function M.effect.play(name,args) if not studio then return end @@ -339,7 +339,9 @@ function M.effect.play(name,args) return end - if args then + if type(args)=='number' then + event:setVolume(args) + elseif args then assert(type(args)=='table',"args must be table") if args.volume then event:setVolume(args.volume) end if args.pitch then diff --git a/assets/gamefunc.lua b/assets/gamefunc.lua index db4073fc..d33609bf 100644 --- a/assets/gamefunc.lua +++ b/assets/gamefunc.lua @@ -55,30 +55,53 @@ function playSample(...) end end end + gameSoundFunc={} gameSoundFunc.__index=gameSoundFunc gameSoundFunc.__metatable=true -for _,n in next,{ - 'move','move_down','move_failed', - 'touch','lock','tuck', - 'rotate','rotate_init', - 'rotate_locked','rotate_corners', - 'rotate_failed','rotate_special', - 'hold','hold_init', - 'drop_old', - 'clear_all','clear_half', - 'frenzy','discharge', - 'suffocate','desuffocate', - 'beep_rise','beep_drop','beep_notice', - 'finish_win','finish_suffocate','finish_lockout','finish_topout', - 'finish_timeout','finish_rule','finish_exhaust','finish_taskfail','finish_other', - 'win','fail', -} do - gameSoundFunc[n]=function() FMOD.effect(n) end -end -function gameSoundFunc.drop(vol) - FMOD.effect('drop',{volume=vol}) +function gameSoundFunc.__newindex(self,k,v) + if v==NULL then + rawset(self,k,function(vol) FMOD.effect(k,vol) end) + else + rawset(self,k,v) + end end + +gameSoundFunc.move =NULL +gameSoundFunc.move_down =NULL +gameSoundFunc.move_failed =NULL +gameSoundFunc.touch =NULL +gameSoundFunc.lock =NULL +gameSoundFunc.tuck =NULL +gameSoundFunc.rotate =NULL +gameSoundFunc.rotate_init =NULL +gameSoundFunc.rotate_locked =NULL +gameSoundFunc.rotate_corners =NULL +gameSoundFunc.rotate_failed =NULL +gameSoundFunc.rotate_special =NULL +gameSoundFunc.hold =NULL +gameSoundFunc.hold_init =NULL +gameSoundFunc.drop =NULL +gameSoundFunc.drop_old =NULL +gameSoundFunc.clear_all =NULL +gameSoundFunc.clear_half =NULL +gameSoundFunc.frenzy =NULL +gameSoundFunc.discharge =NULL +gameSoundFunc.suffocate =NULL +gameSoundFunc.desuffocate =NULL +gameSoundFunc.beep_rise =NULL +gameSoundFunc.beep_drop =NULL +gameSoundFunc.beep_notice =NULL +gameSoundFunc.finish_win =NULL +gameSoundFunc.finish_suffocate =NULL +gameSoundFunc.finish_lockout =NULL +gameSoundFunc.finish_topout =NULL +gameSoundFunc.finish_timeout =NULL +gameSoundFunc.finish_rule =NULL +gameSoundFunc.finish_exhaust =NULL +gameSoundFunc.finish_taskfail =NULL +gameSoundFunc.finish_other =NULL + function gameSoundFunc.countDown(num) if num==0 then -- 6, 3+6+6 playSample('sine',{'A3',.8}) diff --git a/assets/scene/tutorial_shape.lua b/assets/scene/tutorial_shape.lua index 056d3d46..66194b74 100644 --- a/assets/scene/tutorial_shape.lua +++ b/assets/scene/tutorial_shape.lua @@ -152,7 +152,7 @@ end local function answer(ansID) if noControl then if ansID==curPiece.id then - gameSoundFunc.move_failed() + FMOD.effect('move_failed') end return end @@ -171,7 +171,7 @@ local function answer(ansID) noControl=0.26 end else - FMOD.effect('finish_rule') + FMOD.effect('move_failed') end end @@ -201,7 +201,7 @@ function scene.update(dt) local lines=AI.util.clearLine(matrix) if lines>0 then gameSoundFunc.clear(lines) end if #matrix==0 then - gameSoundFunc.clear_all() + FMOD.effect('clear_all') end -- newPiece() noControl=nil diff --git a/assets/scene/zeta_input_method.lua b/assets/scene/zeta_input_method.lua index 488b4d4b..78068f52 100644 --- a/assets/scene/zeta_input_method.lua +++ b/assets/scene/zeta_input_method.lua @@ -149,7 +149,7 @@ function scene.load() charQueue={} if not database then - local data=STRING.split(FILE.load("assets/stroke_data.txt"),"\n") + local data=STRING.split(FILE.load('datatable/stroke_data.txt'),'\n') database={{},{},{},{},{},list={}} for i=1,#data do local char diff --git a/assets/scene_app/dropper.lua b/assets/scene_app/dropper.lua index ff40514d..2b180292 100644 --- a/assets/scene_app/dropper.lua +++ b/assets/scene_app/dropper.lua @@ -96,7 +96,7 @@ function scene.update(dt) else move.y=SCR.h0-2*brickHeight comboSound(math.floor(floor/2)+1) - FMOD.effect(move.x==base.x and 'clear_3' or 'clear_2',{volume=.6}) + FMOD.effect(move.x==base.x and 'clear_3' or 'clear_2',.6) state='shorten' end end diff --git a/assets/scene_app/dtw.lua b/assets/scene_app/dtw.lua index b5fd868c..e2b5046e 100644 --- a/assets/scene_app/dtw.lua +++ b/assets/scene_app/dtw.lua @@ -251,7 +251,7 @@ local function touch(n) state=2 FMOD.effect('finish_win') else - FMOD.effect('beep_notice',{volume=.5}) + FMOD.effect('beep_notice',.5) end end height=height+B.ch diff --git a/assets/scene_app/link.lua b/assets/scene_app/link.lua index b44b6937..80c1966e 100644 --- a/assets/scene_app/link.lua +++ b/assets/scene_app/link.lua @@ -197,7 +197,7 @@ local function tap(x,y) -- Check win if field.remain==0 then - FMOD.effect('frenzy',{volume=.8}) + FMOD.effect('frenzy',.8) if noComboBreak then TEXT:add{text="FULL COMBO",x=800,y=500,fontSize=50,k=2,style='beat',styleArg=.626} comboTime=comboTime+3 @@ -244,12 +244,12 @@ local function tap(x,y) selX,selY=false,false else selX,selY=x,y - FMOD.effect('move',{volume=.9}) + FMOD.effect('move',.9) end else if field[y][x] and (x~=selX or y~=selY) then selX,selY=x,y - FMOD.effect('move',{volume=.8}) + FMOD.effect('move',.8) end end end diff --git a/assets/scene_app/memorize.lua b/assets/scene_app/memorize.lua index 2be62838..d12a070c 100644 --- a/assets/scene_app/memorize.lua +++ b/assets/scene_app/memorize.lua @@ -73,7 +73,7 @@ function scene.update(dt) if inputTime<=0 then inputTime=0 state=1 - FMOD.effect('finish_timeout',{volume=.6}) + FMOD.effect('finish_timeout',.6) end end end diff --git a/assets/scene_app/polyforge.lua b/assets/scene_app/polyforge.lua index b9da7129..5ad6aebd 100644 --- a/assets/scene_app/polyforge.lua +++ b/assets/scene_app/polyforge.lua @@ -64,7 +64,7 @@ function scene.keyDown(key,isRep) end else hit[c]=2 - FMOD.effect('finish_suffocate',{volume=.6}) + FMOD.effect('finish_suffocate',.6) needReset=true state=1 end diff --git a/datatable/se_names.lua b/datatable/se_names.lua new file mode 100644 index 00000000..ab85c078 --- /dev/null +++ b/datatable/se_names.lua @@ -0,0 +1,44 @@ +---@enum Techmino.SE +return { + -- In-game + 'spawn_z','spawn_s','spawn_l','spawn_j','spawn_t','spawn_o','spawn_i', + 'move','move_down','move_failed', + 'touch','lock','tuck', + 'rotate','rotate_init', + 'rotate_locked','rotate_corners', + 'rotate_failed','rotate_special', + 'spin_0','spin_1','spin_2','spin_3','spin_4','spin_mega', + 'hold','hold_init', + 'drop','drop_old','drop_1','drop_2','drop_3','drop_4','drop_5','drop_6', + 'clear_1','clear_2','clear_3','clear_4','clear_5','clear_6','clear_8','clear_10', + 'clear_12','clear_14','clear_16','clear_18','clear_19','clear_20','clear_21','clear_22','clear_24','clear_26', + 'clear_all','clear_half', + 'frenzy','discharge', + 'charge_1','charge_2','charge_3','charge_4','charge_5', + 'charge_6','charge_7','charge_8','charge_9','charge_10', + 'charge_11', + 'suffocate','desuffocate', + 'beep_rise','beep_drop','beep_notice', + 'finish_win','finish_suffocate','finish_lockout','finish_topout', + 'finish_timeout','finish_rule','finish_exhaust','finish_taskfail','finish_other', + + -- Game UI + 'pause_pause','pause_unpause','pause_restart','pause_setting','pause_quit', + 'music_highcut','music_pause', + 'notice_up','notice_down','unlock_secret', + 'simulation_select','map_select','map_enter', + 'map_pass_1','map_pass_2','map_pass_3','map_pass_4','map_pass_5', + 'map_unlock','map_unlock_bg', + 'dict_open','dict_close','dict_copy','dict_link', + + -- Widgets + 'button_back','button_norm','button_soft', + 'selector', + 'check_on','check_off', + 'listbox_select','listbox_click', + 'slider_drag','slider_fill_drag', + 'inputbox_input','inputbox_bksp','inputbox_clear', + + -- Other + 'triangle_wave','sine_wave','square_wave', +} diff --git a/assets/stroke_data.txt b/datatable/stroke_data.txt similarity index 100% rename from assets/stroke_data.txt rename to datatable/stroke_data.txt diff --git a/main.lua b/main.lua index 8f12e6f7..a0fae8c8 100644 --- a/main.lua +++ b/main.lua @@ -408,6 +408,18 @@ function FMODLoadFunc() -- Will be called again when applying advanced options -- print("--------------------------") -- print("Musics") -- for k,v in next,L do print(k,v)end + + -- Music check + local regMore={} + for name in next,SONGBOOK do + if not L[name] then + table.insert(regMore,name) + end + end + if #regMore>0 then + MSG.new('warn',"Music not found in Bank:") + for i=1,#regMore do MSG.new('info',regMore[i]) end + end return L end)()) FMOD.registerEffect((function() @@ -421,18 +433,37 @@ function FMODLoadFunc() -- Will be called again when applying advanced options return {} end local L={} + local nameList={} local l,c=bankEffect:getEventList() for i=1,c do local path=l[i-1]:getPath() if path then local name=path:match('/([^/]+)$'):lower() L[name]=path + if path:find('event:') then + table.insert(nameList,name) + end -- print(name,path) end end -- print("--------------------------") -- print("Effects") -- for k,v in next,L do print(k,v)end + + -- SE check + local regList=require'datatable.se_names' + local existMore,regMore=TABLE.copy(nameList),TABLE.copy(regList) + TABLE.subtract(existMore,regList) + TABLE.subtract(regMore,nameList) + if #existMore>0 then + MSG.new('warn',"SE not registered:") + for i=1,#existMore do MSG.new('info',existMore[i]) end + end + if #regMore>0 then + MSG.new('warn',"SE not found in Bank:") + for i=1,#regMore do MSG.new('info',regMore[i]) end + end + return L end)()) end