From 3714fea9947e22c7b2e144dde459e2e984bf0311 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 16 Sep 2021 02:29:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=91=E6=9D=A1=E5=92=8C=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=E6=8E=A7=E4=BB=B6=E6=94=AF=E6=8C=81lim=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E9=99=90=E5=88=B6=E6=96=87=E6=9C=AC=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/widget.lua | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 33566dfb..baa4dc3b 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -177,7 +177,7 @@ function button:draw() gc_rectangle('line',x-ATV+2,y-ATV+2,w+2*ATV-4,h+2*ATV-4,3) end - --Object + --Drawable local obj=self.obj local y0=y+h*.5-ATV*.5 gc_setColor(1,1,1,.2+ATV*.05) @@ -319,7 +319,7 @@ function key:draw() gc_rectangle('fill',x,y,w,h,3) end - --Object + --Drawable gc_setColor(r,g,b) if align=='M'then mDraw(self.obj,x+w*.5,y+h*.5) @@ -404,28 +404,29 @@ function switch:update() end end function switch:draw() - local x,y=self.x,self.y-25 + local x,y=self.x,self.y local ATV=self.ATV --Frame gc_setLineWidth(2) gc_setColor(1,1,1,.6+ATV*.1) - gc_rectangle('line',x,y,50,50,3) + gc_rectangle('line',x,y-25,50,50,3) --Checked if ATV>0 then gc_setColor(1,1,1,ATV*.06) - gc_rectangle('fill',x,y,50,50,3) + gc_rectangle('fill',x,y-25,50,50,3) end if self.CHK>0 then gc_setColor(.9,1,.9,self.CHK/6) gc_setLineWidth(5) - gc_line(x+5,y+25,x+18,y+38,x+45,y+11) + gc_line(x+5,y,x+18,y+13,x+45,y-14) end --Drawable + local obj=self.obj gc_setColor(self.color) - mDraw_Y(self.obj,x-12-ATV-self.obj:getWidth(),y+25) + gc_draw(obj,x-12-ATV,y,nil,min(self.lim/obj:getWidth(),1),1,obj:getWidth(),obj:getHeight()*.5) end function switch:getInfo() return("x=%d,y=%d,font=%d"):format(self.x,self.y,self.font) @@ -436,12 +437,13 @@ function switch:press() SFX.play('move') end end -function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,disp],code[,hideF][,hide] +function WIDGET.newSwitch(D)--name,x,y[,lim][,fText][,color][,font=30][,sound=true][,disp],code[,hideF][,hide] local _={ name= D.name or"_", x= D.x, y= D.y, + lim= D.lim or 1e99, resCtr={ D.x+25,D.y, @@ -552,9 +554,10 @@ function slider:draw() end --Drawable - if self.obj then + local obj=self.obj + if obj then gc_setColor(self.color) - mDraw_Y(self.obj,x-12-ATV-self.obj:getWidth(),y) + gc_draw(obj,x-12-ATV,y,nil,min(self.lim/obj:getWidth(),1),1,obj:getWidth(),obj:getHeight()*.5) end end function slider:getInfo() @@ -597,13 +600,14 @@ end function slider:arrowKey(k) self:scroll((k=="left"or k=="up")and -1 or 1) end -function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font=30][,change],disp[,show],code,hide +function WIDGET.newSlider(D)--name,x,y,w[,lim][,fText][,color][,unit][,smooth][,font=30][,change],disp[,show],code,hide local _={ name= D.name or"_", x= D.x, y= D.y, w= D.w, + lim= D.lim or 1e99, resCtr={ D.x,D.y, @@ -721,10 +725,10 @@ function selector:draw() --Drawable gc_setColor(self.color) - GC.simpX(self.obj,x+w*.5,y+17-21) + gc_draw(self.obj,x+w*.5,y-4,nil,min((w-20)/self.obj:getWidth(),1),1,self.obj:getWidth()*.5,0) gc_setColor(1,1,1) FONT.set(30) - mStr(self.selText,x+w*.5,y+43-21) + mStr(self.selText,x+w*.5,y+22) end function selector:getInfo() return("x=%d,y=%d,w=%d"):format(self.x+self.w*.5,self.y+30,self.w)