diff --git a/Zframework/widget.lua b/Zframework/widget.lua index cd7b379f..195f3e4d 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -37,7 +37,7 @@ function text:draw() gc.draw(self.text,self.x-self.text:getWidth(),self.y) end end -function WIDGET.newText(D) +function WIDGET.newText(D)--name,x,y[,color][,font=30][,align="M"][,hide] local _={ name= D.name, x= D.x, @@ -64,7 +64,7 @@ function image:draw() gc.setColor(1,1,1,self.alpha) gc.draw(self.img,self.x,self.y,self.ang,self.k) end -function WIDGET.newImage(D) +function WIDGET.newImage(D)--name[,img(name)],x,y[,ang][,k][,hide] local _={ name= D.name, img= D.img or D.name, @@ -143,7 +143,7 @@ end function button:getInfo() return format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font) end -function WIDGET.newButton(D) +function WIDGET.newButton(D)--name,x,y,w[,h][,color][,font],code[,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -218,7 +218,7 @@ end function key:getInfo() return format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font) end -function WIDGET.newKey(D) +function WIDGET.newKey(D)--name,x,y,w[,h][,color][,font],code[,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -302,7 +302,7 @@ end function switch:getInfo() return format("x=%d,y=%d,font=%d",self.x,self.y,self.font) end -function WIDGET.newSwitch(D) +function WIDGET.newSwitch(D)--name,x,y[,font][,disp],code,hide local _={ name= D.name, @@ -328,6 +328,7 @@ local slider={ ATV=0,--Activating time(0~8) TAT=0,--Text activating time(0~180) pos=0,--Position shown + lastTime=0, } local sliderShowFunc={ int=function(S) @@ -339,10 +340,6 @@ local sliderShowFunc={ percent=function(S) return int(S.disp()*100).."%" end, - frame_time=function(S) - S=S.disp() - return S.."F "..int(S*16.67).."ms" - end, } function slider:reset() self.ATV=0 @@ -425,7 +422,7 @@ end function slider:getInfo() return format("x=%d,y=%d,w=%d",self.x,self.y,self.w) end -function WIDGET.newSlider(D) +function WIDGET.newSlider(D)--name,x,y,w[,unit][,smooth][,font][,change],disp,code,hide local _={ name= D.name, @@ -442,15 +439,13 @@ function WIDGET.newSlider(D) }, unit= D.unit or 1, - --smooth=nil, + smooth=nil, font= D.font or 30, change= D.change, disp= D.disp, code= D.code, hide= D.hide, - --show= nil, - - lastTime=0, + show= nil, } if D.smooth~=nil then _.smooth=D.smooth @@ -556,7 +551,7 @@ end function selector:getInfo() return format("x=%d,y=%d,w=%d",self.x+self.w*.5,self.y+30,self.w) end -function WIDGET.newSelector(D) +function WIDGET.newSelector(D)--name,x,y,w[,color],list,disp,code,hide local _={ name= D.name, @@ -645,8 +640,7 @@ end function textBox:getInfo() return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h) end -function WIDGET.newTextBox(D) - if not D.h then D.h=D.w end +function WIDGET.newTextBox(D)--name,x,y,w[,h][,font][,secret][,regex],hide local _={ name= D.name, @@ -654,8 +648,6 @@ function WIDGET.newTextBox(D) y= D.y, w= D.w, h= D.h, - secret= D.secret, - regex= D.regex, resCtr={ D.x+D.w*.2,D.y, @@ -664,6 +656,8 @@ function WIDGET.newTextBox(D) }, font= int(D.h/7-1)*5, + secret= D.secret, + regex= D.regex, hide= D.hide, } for k,v in next,textBox do _[k]=v end diff --git a/parts/scenes/setting_control.lua b/parts/scenes/setting_control.lua index 6596b561..0797e43b 100644 --- a/parts/scenes/setting_control.lua +++ b/parts/scenes/setting_control.lua @@ -1,4 +1,5 @@ local gc=love.graphics +local int=math.floor function sceneInit.setting_control() sceneTemp={ @@ -74,14 +75,18 @@ function Pnt.setting_control() gc.draw(_,x+40,580,nil,40/30) end +local function sliderShow(S) + S=S.disp() + return S.."F "..int(S*16.67).."ms" +end WIDGET.init("setting_control",{ WIDGET.newText({name="title", x=80, y=50,font=70,align="L"}), WIDGET.newText({name="preview", x=520, y=540,font=40,align="R"}), - WIDGET.newSlider({name="das", x=250, y=200,w=910,unit=26,disp=WIDGET.lnk.SETval("das"), show="frame_time",code=WIDGET.lnk.SETsto("das")}), - WIDGET.newSlider({name="arr", x=250, y=290,w=525,unit=15,disp=WIDGET.lnk.SETval("arr"), show="frame_time",code=WIDGET.lnk.SETsto("arr")}), - WIDGET.newSlider({name="sddas", x=250, y=380,w=350,unit=10,disp=WIDGET.lnk.SETval("sddas"), show="frame_time",code=WIDGET.lnk.SETsto("sddas")}), - WIDGET.newSlider({name="sdarr", x=250, y=470,w=140,unit=4, disp=WIDGET.lnk.SETval("sdarr"), show="frame_time",code=WIDGET.lnk.SETsto("sdarr")}), + WIDGET.newSlider({name="das", x=250, y=200,w=910,unit=26,disp=WIDGET.lnk.SETval("das"), show=sliderShow,code=WIDGET.lnk.SETsto("das")}), + WIDGET.newSlider({name="arr", x=250, y=290,w=525,unit=15,disp=WIDGET.lnk.SETval("arr"), show=sliderShow,code=WIDGET.lnk.SETsto("arr")}), + WIDGET.newSlider({name="sddas", x=250, y=380,w=350,unit=10,disp=WIDGET.lnk.SETval("sddas"), show=sliderShow,code=WIDGET.lnk.SETsto("sddas")}), + WIDGET.newSlider({name="sdarr", x=250, y=470,w=140,unit=4, disp=WIDGET.lnk.SETval("sdarr"), show=sliderShow,code=WIDGET.lnk.SETsto("sdarr")}), WIDGET.newSwitch({name="ihs", x=1100, y=290, disp=WIDGET.lnk.SETval("ihs"), code=WIDGET.lnk.SETrev("ihs")}), WIDGET.newSwitch({name="irs", x=1100, y=380, disp=WIDGET.lnk.SETval("irs"), code=WIDGET.lnk.SETrev("irs")}), WIDGET.newSwitch({name="ims", x=1100, y=470, disp=WIDGET.lnk.SETval("ims"), code=WIDGET.lnk.SETrev("ims")}),