From 4abbd79b7769cc4a7d4be61ba1b77d197b664c71 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Thu, 26 Sep 2024 00:56:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8Apower=20manager=E6=94=BE=E5=88=B0main.?= =?UTF-8?q?lua=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/gamefunc.lua | 22 ---------------------- main.lua | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/assets/gamefunc.lua b/assets/gamefunc.lua index bf52dfd0..8e432457 100644 --- a/assets/gamefunc.lua +++ b/assets/gamefunc.lua @@ -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 diff --git a/main.lua b/main.lua index fcb22e50..737db54a 100644 --- a/main.lua +++ b/main.lua @@ -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") @@ -704,7 +728,6 @@ else end end -TASK.new(task_powerManager) DEBUG.checkLoadTime("Load shaders/BGs/SCNs/skins/FMOD/Managers")