两种按钮上的文本也会挤压绘制了

优化控件绘制性能
修正两个背景设置按钮位置错误
调整之前忘了同步的语言
This commit is contained in:
MrZ626
2021-11-28 04:56:55 +08:00
parent fe004a72f0
commit e6bc567b12
6 changed files with 43 additions and 39 deletions

View File

@@ -16,7 +16,6 @@ local next=next
local int,ceil=math.floor,math.ceil
local max,min=math.max,math.min
local sub,ins,rem=string.sub,table.insert,table.remove
local mDraw,mDraw_X,mDraw_Y=GC.draw,GC.simpX,GC.simpY
local xOy=SCR.xOy
local FONT=FONT
local mStr=GC.mStr
@@ -74,7 +73,7 @@ function text:draw()
local c=self.color
gc_setColor(c[1],c[2],c[3],self.alpha)
if self.align=='M'then
mDraw_X(self.obj,self.x,self.y)
gc_draw(self.obj,self.x-self.obj:getWidth()*.5,self.y)
elseif self.align=='L'then
gc_draw(self.obj,self.x,self.y)
elseif self.align=='R'then
@@ -181,32 +180,34 @@ function button:draw()
--Drawable
local obj=self.obj
local ox,oy=obj:getWidth()*.5,obj:getHeight()*.5
local y0=y+h*.5-ATV*.5
gc_setColor(1,1,1,.2+ATV*.05)
if self.align=='M'then
local x0=x+w*.5
mDraw(obj,x0-1,y0-1)
mDraw(obj,x0-1,y0+1)
mDraw(obj,x0+1,y0-1)
mDraw(obj,x0+1,y0+1)
local kx=obj:type()=='Text'and min(w/ox/2,1)or 1
gc_draw(obj,x0-1,y0-1,nil,kx,1,ox,oy)
gc_draw(obj,x0-1,y0+1,nil,kx,1,ox,oy)
gc_draw(obj,x0+1,y0-1,nil,kx,1,ox,oy)
gc_draw(obj,x0+1,y0+1,nil,kx,1,ox,oy)
gc_setColor(r*.55,g*.55,b*.55)
mDraw(obj,x0,y0)
gc_draw(obj,x0,y0,nil,kx,1,ox,oy)
elseif self.align=='L'then
local edge=self.edge
mDraw_Y(obj,x+edge-1,y0-1)
mDraw_Y(obj,x+edge-1,y0+1)
mDraw_Y(obj,x+edge+1,y0-1)
mDraw_Y(obj,x+edge+1,y0+1)
gc_draw(obj,x+edge-1,y0-1-oy)
gc_draw(obj,x+edge-1,y0+1-oy)
gc_draw(obj,x+edge+1,y0-1-oy)
gc_draw(obj,x+edge+1,y0+1-oy)
gc_setColor(r*.55,g*.55,b*.55)
mDraw_Y(obj,x+edge,y0)
gc_draw(obj,x+edge,y0-oy)
elseif self.align=='R'then
local x0=x+w-self.edge-obj:getWidth()
mDraw_Y(obj,x0-1,y0-1)
mDraw_Y(obj,x0-1,y0+1)
mDraw_Y(obj,x0+1,y0-1)
mDraw_Y(obj,x0+1,y0+1)
local x0=x+w-self.edge-ox*2
gc_draw(obj,x0-1,y0-1-oy)
gc_draw(obj,x0-1,y0+1-oy)
gc_draw(obj,x0+1,y0-1-oy)
gc_draw(obj,x0+1,y0+1-oy)
gc_setColor(r*.55,g*.55,b*.55)
mDraw_Y(obj,x0,y0)
gc_draw(obj,x0,y0-oy)
end
end
function button:getInfo()
@@ -311,11 +312,11 @@ function key:draw()
if self.fShade then
gc_setColor(r,g,b,ATV*.25)
if align=='M'then
mDraw(self.fShade,x+w*.5,y+h*.5)
gc_draw(self.fShade,x+w*.5-self.fShade:getWidth()*.5,y+h*.5-self.fShade:getHeight()*.5)
elseif align=='L'then
mDraw_Y(self.fShade,x+self.edge,y+h*.5)
gc_draw(self.fShade,x+self.edge,y+h*.5-self.fShade:getHeight()*.5)
elseif align=='R'then
mDraw_Y(self.fShade,x+w-self.edge-self.fShade:getWidth(),y+h*.5)
gc_draw(self.fShade,x+w-self.edge-self.fShade:getWidth(),y+h*.5-self.fShade:getHeight()*.5)
end
else
gc_setColor(1,1,1,ATV*.05)
@@ -323,13 +324,16 @@ function key:draw()
end
--Drawable
local obj=self.obj
local ox,oy=obj:getWidth()*.5,obj:getHeight()*.5
gc_setColor(r,g,b)
if align=='M'then
mDraw(self.obj,x+w*.5,y+h*.5)
local kx=obj:type()=='Text'and min(w/ox/2,1)or 1
gc_draw(obj,x+w*.5,y+h*.5,nil,kx,1,ox,oy)
elseif align=='L'then
mDraw_Y(self.obj,x+self.edge,y+h*.5)
gc_draw(obj,x+self.edge,y-oy+h*.5)
elseif align=='R'then
mDraw_Y(self.obj,x+w-self.edge-self.obj:getWidth(),y+h*.5)
gc_draw(obj,x+w-self.edge-ox*2,y-oy+h*.5)
end
end
function key:getInfo()
@@ -870,7 +874,7 @@ function inputBox:draw()
local f=self.font
FONT.set(f,self.fType)
if self.obj then
mDraw_Y(self.obj,x-12-self.obj:getWidth(),y+h*.5)
gc_draw(self.obj,x-12-self.obj:getWidth(),y+h*.5-self.obj:getHeight()*.5)
end
if self.secret then
y=y+h*.5-f*.2

View File

@@ -392,9 +392,9 @@ return{
clean="Quick Draw",
fullscreen="Fullscreen",
bg_on="Normal Backgrounds",
bg_off="No Background",
bg_custom="Apply Custom BG",
bg_on="Normal B.G.",
bg_off="No B.G.",
bg_custom="Use Custom B.G.",
blockSatur="Block Saturation",
fieldSatur="Field Saturation",

View File

@@ -358,9 +358,9 @@ return{
clean="Fast Draw",
fullscreen="Pant. Completa",
-- bg_on="Normal Backgrounds",
-- bg_off="No Background",
-- bg_custom="Apply Custom BG",
-- bg_on="Normal B.G.",
-- bg_on="No B.G.",
-- bg_custom="Use Custom B.G.",
blockSatur="Saturac. de los Bloques",
fieldSatur="Saturac. del Tablero",

View File

@@ -356,9 +356,9 @@ return{
-- clean="Fast Draw",
fullscreen="Plein écran",
-- bg_on="Normal Backgrounds",
-- bg_off="No Background",
-- bg_custom="Apply Custom BG",
-- bg_on="Normal B.G.",
-- bg_on="No B.G.",
-- bg_custom="Use Custom B.G.",
-- blockSatur="Block Saturation",
-- fieldSatur="Field Saturation",

View File

@@ -380,9 +380,9 @@ return{
-- clean="Fast Draw",
fullscreen="Tela cheia",
-- bg_on="Normal Backgrounds",
-- bg_off="No Background",
-- bg_custom="Apply Custom BG",
-- bg_on="Normal B.G.",
-- bg_on="No B.G.",
-- bg_custom="Use Custom B.G.",
-- blockSatur="Block Saturation",
-- fieldSatur="Field Saturation",

View File

@@ -80,8 +80,8 @@ scene.widgetList={
WIDGET.newSwitch{name='clean', x=950,y=1160,lim=360,disp=SETval('cleanCanvas'), code=SETrev('cleanCanvas')},
WIDGET.newSwitch{name='fullscreen', x=950,y=1250,lim=360,disp=SETval('fullscreen'), code=function()SETTING.fullscreen=not SETTING.fullscreen applyFullscreen()end},
WIDGET.newKey{name='bg_on', x=900,y=1340,w=200,h=80,code=function()SETTING.bg='on'applyBG()end},
WIDGET.newKey{name='bg_off', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='off'applyBG()end},
WIDGET.newKey{name='bg_on', x=680,y=1340,w=200,h=80,code=function()SETTING.bg='on'applyBG()end},
WIDGET.newKey{name='bg_off', x=900,y=1340,w=200,h=80,code=function()SETTING.bg='off'applyBG()end},
WIDGET.newKey{name='bg_custom', x=1120,y=1340,w=200,h=80,
code=function()
if love.filesystem.getInfo('conf/customBG')then