From 35e09b3acd471492010cd53807de90e3c2822037 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 10 Dec 2020 12:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=89=E5=85=A8=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E6=98=BE=E7=A4=BA=E7=B3=BB=E7=BB=9F=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 30 +++++++++--------------------- Zframework/screen.lua | 32 +++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 7234db52..a77c7ca7 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -48,7 +48,7 @@ local function updatePowerInfo() if state=="nobattery"then gc.setColor(1,1,1) gc.setLineWidth(2) - gc.line(74,5,100,22) + gc.line(74,SCR.safeX+5,100,22) elseif pow then if charging then gc.setColor(0,1,0) elseif pow>50 then gc.setColor(1,1,1) @@ -310,19 +310,7 @@ function love.lowmemory() collectgarbage() end function love.resize(w,h) - SCR.w,SCR.h,SCR.dpi=w,h,gc.getDPIScale() - SCR.W,SCR.H=SCR.w*SCR.dpi,SCR.h*SCR.dpi - SCR.r=h/w - SCR.rad=(w^2+h^2)^.5 - - if SCR.r>=SCR.h0/SCR.w0 then - SCR.k=w/SCR.w0 - SCR.x,SCR.y=0,(h-w*SCR.h0/SCR.w0)/2 - else - SCR.k=h/SCR.h0 - SCR.x,SCR.y=(w-h*SCR.w0/SCR.h0)/2,0 - end - xOy:setTransformation(w/2,h/2,nil,SCR.k,nil,SCR.w0/2,SCR.h0/2) + SCR.resize(w,h) if BG.resize then BG.resize(w,h)end SHADER.warning:send("w",w*SCR.dpi) @@ -515,7 +503,7 @@ function love.run() --Draw power info. gc.setColor(1,1,1) if SETTING.powerInfo then - gc.draw(infoCanvas,0,0,0,SCR.k) + gc.draw(infoCanvas,SCR.safeX,0,0,SCR.k) end --Draw scene swapping animation @@ -535,16 +523,16 @@ function love.run() gc.setColor(1,1,1) setFont(15) _=SCR.h - gc.print(FPS(),5,_-20) + gc.print(FPS(),SCR.safeX+5,_-20) --Debug info. if devMode then gc.setColor(devColor[devMode]) - gc.print("Memory:"..gcinfo(),5,_-40) - gc.print("Lines:"..FREEROW.getCount(),5,_-60) - gc.print("Cursor:"..int(mx+.5).." "..int(my+.5),5,_-80) - gc.print("Voices:"..VOC.getCount(),5,_-100) - gc.print("Tasks:"..TASK.getCount(),5,_-120) + gc.print("Memory:"..gcinfo(),SCR.safeX+5,_-40) + gc.print("Lines:"..FREEROW.getCount(),SCR.safeX+5,_-60) + gc.print("Cursor:"..int(mx+.5).." "..int(my+.5),SCR.safeX+5,_-80) + gc.print("Voices:"..VOC.getCount(),SCR.safeX+5,_-100) + gc.print("Tasks:"..TASK.getCount(),SCR.safeX+5,_-120) ins(frameTimeList,1,dt)rem(frameTimeList,126) gc.setColor(1,1,1,.3) for i=1,#frameTimeList do diff --git a/Zframework/screen.lua b/Zframework/screen.lua index c27c63c4..4549462e 100644 --- a/Zframework/screen.lua +++ b/Zframework/screen.lua @@ -1,14 +1,32 @@ local SCR={ - w0=1280,h0=720,--Default Screen Size - x=0,y=0,--Up-left Coord on screen - w=0,h=0,--Fullscreen w/h in gc - W=0,H=0,--Fullscreen w/h in shader - rad=0,--Radius - k=1,--Scale size - dpi=1,--DPI from gc.getDPIScale() + w0=1280,h0=720, --Default Screen Size + x=0,y=0, --Up-left Coord on screen + w=0,h=0, --Fullscreen w/h in gc + W=0,H=0, --Fullscreen w/h in shader + safeX=0,safeY=0,--Safe area + safeW=0,safeH=0,--Safe area + rad=0, --Radius + k=1, --Scale size + dpi=1, --DPI from gc.getDPIScale() xOy=love.math.newTransform(),--Screen transformation object } function SCR.setSize(w,h) SCR.w0,SCR.h0=w,h end +function SCR.resize(w,h) + SCR.w,SCR.h,SCR.dpi=w,h,love.graphics.getDPIScale() + SCR.W,SCR.H=SCR.w*SCR.dpi,SCR.h*SCR.dpi + SCR.r=h/w + SCR.rad=(w^2+h^2)^.5 + + if SCR.r>=SCR.h0/SCR.w0 then + SCR.k=w/SCR.w0 + SCR.x,SCR.y=0,(h-w*SCR.h0/SCR.w0)/2 + else + SCR.k=h/SCR.h0 + SCR.x,SCR.y=(w-h*SCR.w0/SCR.h0)/2,0 + end + SCR.safeX,SCR.safeY,SCR.safeW,SCR.safeH=love.window.getSafeArea() + SCR.xOy:setTransformation(w/2,h/2,nil,SCR.k,nil,SCR.w0/2,SCR.h0/2) +end return SCR \ No newline at end of file