Skip to content

Commit

Permalink
把power manager放到main.lua里
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed Sep 25, 2024
1 parent 119f3e5 commit 4abbd79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
22 changes: 0 additions & 22 deletions assets/gamefunc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,6 @@ function showSaveIcon(str)
TEXT:add{text=str,x=SCR.w0-15,y=SCR.h0+5,align='bottomright',a=.0626,duration=.62,fontSize=70}
end

local warnThres={-1,2.6,6.26,14.2,26}
local warnCheck=5
function task_powerManager()
while true do
local state,pow=love.system.getPowerInfo()
if not pow then return end
if state=='charging' or state=='charged' then
while warnCheck<5 and pow>warnThres[warnCheck] do
warnCheck=warnCheck+1
end
else
if pow<=warnThres[warnCheck] then
repeat
warnCheck=warnCheck-1
until warnCheck==1 or pow>warnThres[warnCheck]
MSG.new(({'check','error','warn','info'})[warnCheck],Text.batteryWarn[warnCheck])
end
end
TASK.yieldT(6.26)
end
end

function backText()
return CHAR.icon.back_chevron..' '..Text.button_back
end
Expand Down
25 changes: 24 additions & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,30 @@ SCN.addSwapStyle('fastFadeHeader',{
SCN.scenes._console.widgetList.output.fontType='codepixel'
SCN.scenes._console.widgetList.input.fontType='codepixel'

do -- Power Manager
local warnThres={-1,2.6,6.26,14.2,26}
local warnCheck=5
TASK.new(function()
while true do
local state,pow=love.system.getPowerInfo()
if not pow then return end
if state=='charging' or state=='charged' then
while warnCheck<5 and pow>warnThres[warnCheck] do
warnCheck=warnCheck+1
end
else
if pow<=warnThres[warnCheck] then
repeat
warnCheck=warnCheck-1
until warnCheck==1 or pow>warnThres[warnCheck]
MSG.new(({'check','error','warn','info'})[warnCheck],Text.batteryWarn[warnCheck])
end
end
TASK.yieldT(6.26)
end
end)
end

FMODLoadFunc()
if tostring(FMOD.studio):find('NULL') then
MSG.new('error',"FMOD initialization failed")
Expand Down Expand Up @@ -704,7 +728,6 @@ else
end
end

TASK.new(task_powerManager)

DEBUG.checkLoadTime("Load shaders/BGs/SCNs/skins/FMOD/Managers")

Expand Down

0 comments on commit 4abbd79

Please sign in to comment.