From ed47dcb90c4668e8ca415b1de4189fcd3351e3aa Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 23 Dec 2021 21:03:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=96=B0=E5=A2=9EonResize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index dc5f9d93..01caf78d 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -107,17 +107,16 @@ local function updatePowerInfo() gc_clear(0,0,0,.25) if state~='unknown'then gc_setLineWidth(4) - local charging=state=='charging' if state=='nobattery'then gc_setColor(1,1,1) gc_setLineWidth(2) - gc_line(74,SCR.safeX+5,100,22) + gc_line(74,5,100,22) elseif pow then - if charging then gc_setColor(0,1,0) - elseif pow>50 then gc_setColor(1,1,1) - elseif pow>26 then gc_setColor(1,1,0) - elseif pow==26 then gc_setColor(.5,0,1) - else gc_setColor(1,0,0) + if state=='charging'then gc_setColor(0,1,0) + elseif pow>50 then gc_setColor(1,1,1) + elseif pow>26 then gc_setColor(1,1,0) + elseif pow==26 then gc_setColor(.5,0,1) + else gc_setColor(1,0,0) end gc.rectangle('fill',76,6,pow*.22,14) if pow<100 then @@ -492,6 +491,8 @@ function love.lowmemory() MES.new('check',"[auto GC] low MEM 设备内存过低") end end + +local onResize=NULL function love.resize(w,h) if SCR.w==w and SCR.h==h then return end SCR.resize(w,h) @@ -499,8 +500,7 @@ function love.resize(w,h) if SCN.resize then SCN.resize(w,h)end WIDGET.resize(w,h) FONT.reset() - - SHADER.warning:send('w',w*SCR.dpi) + onResize(w,h) end local onFocus=NULL @@ -858,6 +858,8 @@ end function Z.setOnFocus(func)onFocus=assert(type(func)=='function'and func,"Z.setOnFocus(func): func must be a function")end +function Z.setOnResize(func)onResize=assert(type(func)=='function'and func,"Z.setOnResize(func): func must be a function")end + function Z.setOnQuit(func)onQuit=assert(type(func)=='function'and func,"Z.setOnQuit(func): func must be a function")end return Z