Skip to content

Commit 0e8baf1

Browse files
committed
整理代码 框架跟进
1 parent 09ea26a commit 0e8baf1

File tree

6 files changed

+26
-16
lines changed

6 files changed

+26
-16
lines changed

Zenitha

assets/game/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ do -- function layoutFuncs.default():
129129
end
130130
end
131131

132+
---@async
132133
local function task_switchToResult()
133134
if SCN.cur=='game_in' then
134135
SCN.swapTo('result_in','none')

assets/gamefunc.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ function CanPause()
252252
return GAME.playing and not GAME.mode.name:find('/test')
253253
end
254254

255+
---@async
255256
local function task_interiorAutoBack()
256257
local time=love.timer.getTime()
257258
local startScene=SCN.cur
@@ -268,7 +269,8 @@ function autoBack_interior(disable)
268269
end
269270
end
270271

271-
local function _saveSettings()
272+
---@async
273+
local function task_saveSettings()
272274
TASK.yieldT(.626)
273275
FILE.save({
274276
system=SETTINGS._system,
@@ -281,8 +283,8 @@ local function _saveSettings()
281283
end
282284
end
283285
function SaveSettings()
284-
TASK.removeTask_code(_saveSettings)
285-
TASK.new(_saveSettings)
286+
TASK.removeTask_code(task_saveSettings)
287+
TASK.new(task_saveSettings)
286288
end
287289
function SaveKey()
288290
FILE.save({
@@ -309,6 +311,7 @@ function CallDict(entry)
309311
SCN.go('dictionary','none',entry)
310312
end
311313

314+
---@async
312315
function task_unloadGame()
313316
coroutine.yield()
314317
TASK.yieldUntilNextScene()

assets/progress.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ local PROGRESS={}
123123
--------------------------------------------------------------
124124
-- Save & Load
125125

126-
---@param step nil
126+
---@async
127+
---@param step nil | 'yield' | 'save'
127128
function PROGRESS.save(step)
128129
if step==nil then
129130
-- Wait 1 frame before saving
@@ -289,14 +290,17 @@ function PROGRESS.applyEnv(env)
289290
02*cos(rc+w*2.),02*sin(rc+w*2.)
290291
end
291292
updateCursor(.55)
293+
local _wid1,_wid2
294+
local function cursor_anim(t) updateCursor(MATH.lerp(_wid1,_wid2,t)) end
295+
local function cursor_anim2(t) msColor[4]=1-t end
292296
function ZENITHA.globalEvent.mouseDown(x,y,k)
293297
msColor[1],msColor[2],msColor[3]=unpack(k==1 and COLOR.lP or k==2 and COLOR.lS or COLOR.lR)
294298
msColor[4]=1
295299

296300
TWEEN.tag_kill('cursor_anim')
297-
local _wid=msWidth
298-
TWEEN.new(function(t) updateCursor(MATH.lerp(_wid,.4,t)) end):setTag('cursor_anim'):setDuration(.0626):run()
299301
TWEEN.tag_kill('cursor_anim2')
302+
_wid1,_wid2=msWidth,.4
303+
TWEEN.new(cursor_anim):setTag('cursor_anim'):setDuration(.0626):run()
300304

301305
if k==1 then SYSFX.ripple(.26,x,y,26,.8,.62,1)
302306
elseif k==2 then SYSFX.ripple(.26,x,y,26,.62,.8,1)
@@ -309,11 +313,10 @@ function PROGRESS.applyEnv(env)
309313
function ZENITHA.globalEvent.mouseUp(x,y,k)
310314
if not love.mouse.isDown(1,2,3) then
311315
TWEEN.tag_kill('cursor_anim')
312-
local _wid=msWidth
313-
TWEEN.new(function(t) updateCursor(MATH.lerp(_wid,.55,t)) end):setTag('cursor_anim'):setDuration(.0626):run()
314-
TWEEN.new(function(t) msColor[4]=1-t end):setEase('Linear'):setTag('cursor_anim2'):setDuration(1):run()
316+
_wid1,_wid2=msWidth,.55
317+
TWEEN.new(cursor_anim):setTag('cursor_anim'):setDuration(.0626):run()
318+
TWEEN.new(cursor_anim2):setEase('Linear'):setTag('cursor_anim2'):setDuration(1):run()
315319
end
316-
317320
SFX.play('mouse_up')
318321
end
319322

assets/scene/musicroom.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ local function searchMusic(str)
133133
musicListBox:select(bestID)
134134
end
135135
end
136-
local function timeBomb()
136+
137+
---@async
138+
local function task_timeBomb()
137139
TASK.yieldT(26)
138140
if TASK.getLock('musicroom_glitchFX') then
139141
FMOD.effect.keyOff('music_glitch')
@@ -189,7 +191,7 @@ function scene.keyDown(key,isRep)
189191
elseif key=='f3' then
190192
if TASK.lock('musicroom_glitchFX') then
191193
FMOD.effect('music_glitch')
192-
TASK.new(timeBomb)
194+
TASK.new(task_timeBomb)
193195
end
194196
end
195197
end

assets/settings.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ local settingTriggers={ -- Changing values in SETTINGS.system will trigger these
9090
locale= function(v) Text=LANG.set(v) end,
9191
}
9292

93-
local function updateDiscordRPC(v)
93+
---@async
94+
local function task_updateDiscordRPC(v)
9495
TASK.yieldT(2.6)
9596
DiscordRPC.setEnable(v)
9697
end
9798
function settingTriggers.discordConnect(v)
98-
TASK.removeTask_code(updateDiscordRPC)
99-
TASK.new(updateDiscordRPC,v)
99+
TASK.removeTask_code(task_updateDiscordRPC)
100+
TASK.new(task_updateDiscordRPC,v)
100101
end
101102

102103
settings.system=setmetatable({},{

0 commit comments

Comments
 (0)