diff --git a/assets/fmod20221/cdef.lua b/assets/fmod20221/cdef.lua index 4c01efcd..fd7b80ee 100644 --- a/assets/fmod20221/cdef.lua +++ b/assets/fmod20221/cdef.lua @@ -1,4 +1,4 @@ -require("ffi").cdef[[ +require'ffi'.cdef[[ typedef int FMOD_BOOL; typedef struct FMOD_SYSTEM FMOD_SYSTEM; typedef struct FMOD_SOUND FMOD_SOUND; diff --git a/assets/fmod20221/constants.lua b/assets/fmod20221/constants.lua index bdbe6015..e190358c 100644 --- a/assets/fmod20221/constants.lua +++ b/assets/fmod20221/constants.lua @@ -1,9 +1,9 @@ -local bit=require("bit") -local ffi=require("ffi") +local bit=require'bit' +local ffi=require'ffi' local require=simpRequire(((...):gsub("[^%.]*$", ""))) ---@class FMOD.Master -local M=require("master") +local M=require'master' M.FMOD_VERSION=0x00020221 M.FMOD_DEBUG_LEVEL_NONE=0x00000000 diff --git a/assets/fmod20221/enums.lua b/assets/fmod20221/enums.lua index da16e1db..cbd84e9b 100644 --- a/assets/fmod20221/enums.lua +++ b/assets/fmod20221/enums.lua @@ -1,7 +1,7 @@ local require=simpRequire(((...):gsub("[^%.]*$", ""))) ---@class FMOD.Master -local M=require("master") +local M=require'master' local C=M.C M.FMOD_THREAD_TYPE_MIXER=C.FMOD_THREAD_TYPE_MIXER diff --git a/assets/fmod20221/errors.lua b/assets/fmod20221/errors.lua index 60e80395..e29cf27f 100644 --- a/assets/fmod20221/errors.lua +++ b/assets/fmod20221/errors.lua @@ -1,7 +1,7 @@ local require=simpRequire(((...):gsub("[^%.]*$", ""))) ---@class FMOD.Master -local M=require("master") +local M=require'master' M.errorString=setmetatable({ [M.FMOD_OK]="No errors.", diff --git a/assets/fmod20221/init.lua b/assets/fmod20221/init.lua index 0692cae2..f20273cf 100644 --- a/assets/fmod20221/init.lua +++ b/assets/fmod20221/init.lua @@ -1,28 +1,29 @@ -local ffi=require("ffi") +local ffi=require'ffi' local require=simpRequire(((...):gsub(".init$","")..".")) -require("cdef") +require'cdef' ---@class FMOD.Master -local M=require("master") - --- search for fmod shared libraries in package.cpath -local fmodPath=package.searchpath("fmod",package.cpath) -local fmodstudioPath=package.searchpath("fmodstudio",package.cpath) - -if fmodPath and fmodstudioPath then - -- pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi - -- package.loadlib(fmodPath,"") - M.C=ffi.load(fmodPath) - M.C2=ffi.load(fmodstudioPath) - require("enums") - require("constants") - require("wrap") - require("errors") -else - MSG.new('error',"FMOD shared libraries not found!") -end - +local M=require'master' + +-- (Old method) search for fmod shared libraries in package.cpath +-- local fmodPath=package.searchpath('fmod',package.cpath) +-- local fmodstudioPath=package.searchpath('fmodstudio',package.cpath) +-- -- pretend to load libfmod through Lua (it's going to fail but not raise any errors) so that its location is known when loading libfmodstudio through ffi +-- -- package.loadlib(fmodPath,"") +-- M.C=ffi.load(fmodPath) +-- M.C2=ffi.load(fmodstudioPath) + +M.C=ffi.load('fmod') +if not M.C then MSG.new('error',"FMOD library not found") end + +M.C2=ffi.load('fmodstudio') +if not M.C2 then MSG.new('error',"FMODstudio library not found") end + +require'enums' +require'constants' +require'wrap' +require'errors' -------------------------------------------------------------- diff --git a/assets/fmod20221/wrap.lua b/assets/fmod20221/wrap.lua index 69adb546..5e80486b 100644 --- a/assets/fmod20221/wrap.lua +++ b/assets/fmod20221/wrap.lua @@ -1,4 +1,4 @@ -local ffi=require("ffi") +local ffi=require'ffi' local require=simpRequire(((...):gsub("[^%.]*$", ""))) ---@alias FMOD.GUID FMOD.GUID @@ -7,7 +7,7 @@ local require=simpRequire(((...):gsub("[^%.]*$", ""))) ---@alias FMOD.Enum FMOD.Enum ---@class FMOD.Master -local M=require("master") +local M=require'master' local C=M.C local C2=M.C2 diff --git a/assets/gamefunc.lua b/assets/gamefunc.lua index f72e2086..bd2f1a9c 100644 --- a/assets/gamefunc.lua +++ b/assets/gamefunc.lua @@ -46,6 +46,7 @@ function playSample(...) volume=vol, param={'release',rel*1.0594630943592953^(note-33)}, }) + if not event then return end TASK.new(function() DEBUG.yieldT(len/1000) event:stop(FMOD.FMOD_STUDIO_STOP_ALLOWFADEOUT) diff --git a/assets/scene/dictionary.lua b/assets/scene/dictionary.lua index 7c7c843e..cba5c93a 100644 --- a/assets/scene/dictionary.lua +++ b/assets/scene/dictionary.lua @@ -31,7 +31,7 @@ local contents={ } -- Base dict data, not formatted local baseDict do - baseDict=require('assets/dict_base') + baseDict=require'assets/dict_base' local dictObjMeta={__index=function(obj,k) if k=='titleText' then obj.titleText=GC.newText(FONT.get(obj.titleSize,'bold'),obj.titleFull) diff --git a/assets/songbook.lua b/assets/songbook.lua index 7b9b23ad..09f25c2a 100644 --- a/assets/songbook.lua +++ b/assets/songbook.lua @@ -1,3 +1,11 @@ +---@class Techmino.MusicMeta +---@field message string +---@field author string +---@field title string +---@field inside? boolean +---@field redirect? string|table +---@field notFound? boolean + ---@enum (key) Techmino.MusicName local songbook={ ['8-bit happiness'] ={}, @@ -116,4 +124,5 @@ setmetatable(songbook,{__call=function(t,name) } end}) +---@cast songbook table return songbook diff --git a/conf.lua b/conf.lua index 056ee3f9..d6c4feed 100644 --- a/conf.lua +++ b/conf.lua @@ -51,7 +51,7 @@ function love.conf(t) W.width,W.height=1440,900 W.minwidth,W.minheight=288,180 end - W.title=require"version".appName.." "..require"version".appVer + W.title=require'version'.appName..' '..require'version'.appVer if fs.getInfo('assets/image/icon.png') then W.icon='assets/image/icon.png' diff --git a/main.lua b/main.lua index 37de8678..c6488798 100644 --- a/main.lua +++ b/main.lua @@ -25,7 +25,7 @@ ------------------------------------------------------------- -- Load Zenitha -require("Zenitha") +require'Zenitha' DEBUG.checkLoadTime("Load Zenitha") -- DEBUG.runVarMonitor() -- DEBUG.setCollectGarvageVisible() @@ -37,7 +37,7 @@ STRING.install() math.randomseed(os.time()*626) love.setDeprecationOutput(false) love.keyboard.setTextInput(false) -VERSION=require"version" +VERSION=require'version' -------------------------------------------------------------- -- Create directories @@ -420,10 +420,15 @@ TASK.new(function() -- Don't initialize studio at first frame, may cause some we FMODLoadFunc() FMOD.setMainVolume(SETTINGS.system.mainVol,true) for name,data in next,SONGBOOK do - data.intensity=FMOD.music.getParamDesc(name,'intensity')~=nil - data.section=FMOD.music.getParamDesc(name,'section')~=nil - if not FMOD.music.getParamDesc(name,'fade') then - MSG.new('warn',"Missing fade parameter in music '"..name.."'") + if FMOD.music.getDesc(name) then + data.intensity=FMOD.music.getParamDesc(name,'intensity')~=nil + data.section=FMOD.music.getParamDesc(name,'section')~=nil + if not FMOD.music.getParamDesc(name,'fade') then + MSG.new('warn',"Missing 'fade' parameter in music '"..name.."'") + end + else + data.notFound=true + MSG.new('warn',"Music '"..name.."' not found in FMOD") end end end)