From 10d65c458199edaedbd80b22a467f278f8f3bfb7 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 18 Oct 2020 23:05:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=AE=E7=9B=98=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/languages.lua | 5 - Zframework/widget.lua | 425 ++++++++++++++++---------------------- Zframework/widgetList.lua | 5 +- parts/scenes.lua | 3 - 4 files changed, 176 insertions(+), 262 deletions(-) diff --git a/Zframework/languages.lua b/Zframework/languages.lua index 70902261..b1ac27b3 100644 --- a/Zframework/languages.lua +++ b/Zframework/languages.lua @@ -441,7 +441,6 @@ local langList={ dict={ title="小Z方块词典", link="打开链接", - keyboard="键盘", back="返回", }, staff={ @@ -1029,7 +1028,6 @@ local langList={ dict={ title="小Z方块词典", link="打开链接", - keyboard="键盘", back="返回", }, staff={ @@ -1607,7 +1605,6 @@ local langList={ dict={ title="TetroDictionary", link="Open URL", - keyboard="Keyboard", back="Back", }, staff={ @@ -2199,7 +2196,6 @@ local langList={ dict={ title="TetroDictionary", link="~~e>>", - keyboard="□□□", back="X", }, staff={ @@ -2784,7 +2780,6 @@ local langList={ dict={ title="小Z方块词典", link="看链接", - keyboard="键盘", back="返回", }, staff={ diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 20c108b0..d835b504 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -7,6 +7,13 @@ local color=color local setFont=setFont local Timer=love.timer.getTime +local WIDGET={} +local widgetMetatable={ + __tostring=function(self) + return self:getInfo() + end, +} + local text={ type="text", } @@ -25,6 +32,20 @@ function text:draw() gc.draw(self.text,self.x-self.text:getWidth(),self.y) end end +function WIDGET.newText(D) + local _={ + name= D.name, + x= D.x, + y= D.y, + color= D.color and(color[D.color]or D.color)or color.white, + font= D.font or 30, + align= D.align or"M", + hide= D.hide, + } + for k,v in next,text do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local image={ type="image", @@ -38,6 +59,24 @@ function image:draw() gc.setColor(1,1,1,self.alpha) gc.draw(self.img,self.x,self.y,self.ang,self.kx,self.ky,self.ox,self.oy) end +function WIDGET.newImage(D) + local _={ + name= D.name, + img= D.img, + alpha= D.alpha or 1, + x= D.x, + y= D.y, + ang= D.ang, + kx= D.kx, + ky= D.ky, + ox= D.ox, + oy= D.oy, + hide= D.hide, + } + for k,v in next,image do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local button={ type="button", @@ -104,6 +143,33 @@ 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) + if not D.h then D.h=D.w end + local _={ + name= D.name, + + x= D.x-D.w*.5, + y= D.y-D.h*.5, + w= D.w, + h= D.h, + + resCtr={ + D.x,D.y, + D.x-D.w*.35,D.y-D.h*.35, + D.x-D.w*.35,D.y+D.h*.35, + D.x+D.w*.35,D.y-D.h*.35, + D.x+D.w*.35,D.y+D.h*.35, + }, + + color= D.color and(color[D.color]or D.color)or color.white, + font= D.font or 30, + code= D.code, + hide= D.hide, + } + for k,v in next,button do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local key={ type="key", @@ -113,7 +179,6 @@ function key:reset() self.ATV=0 end function key:isAbove(x,y) - local ATV=self.ATV return x>self.x and y>self.y and @@ -154,6 +219,33 @@ 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) + if not D.h then D.h=D.w end + local _={ + name= D.name, + + x= D.x-D.w*.5, + y= D.y-D.h*.5, + w= D.w, + h= D.h, + + resCtr={ + D.x,D.y, + D.x-D.w*.35,D.y-D.h*.35, + D.x-D.w*.35,D.y+D.h*.35, + D.x+D.w*.35,D.y-D.h*.35, + D.x+D.w*.35,D.y+D.h*.35, + }, + + color= D.color and(color[D.color]or D.color)or color.white, + font= D.font or 30, + code= D.code, + hide= D.hide, + } + for k,v in next,key do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local switch={ type="switch", @@ -211,6 +303,26 @@ end function switch:getInfo() return format("x=%d,y=%d,font=%d",self.x,self.y,self.font) end +function WIDGET.newSwitch(D) + local _={ + name= D.name, + + x= D.x, + y= D.y, + + resCtr={ + D.x+25,D.y, + }, + + font= D.font or 30, + disp= D.disp, + code= D.code, + hide= D.hide, + } + for k,v in next,switch do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local slider={ type="slider", @@ -315,6 +427,55 @@ end function slider:getInfo() return format("x=%d,y=%d,w=%d",self.x,self.y,self.w) end +function WIDGET.newSlider(D) + local _={ + name= D.name, + + x= D.x, + y= D.y, + w= D.w, + + resCtr={ + D.x,D.y, + D.x+D.w*.25,D.y, + D.x+D.w*.5,D.y, + D.x+D.w*.75,D.y, + D.x+D.w,D.y, + }, + + unit= D.unit or 1, + --smooth=nil, + font= D.font or 30, + change= D.change, + disp= D.disp, + code= D.code, + hide= D.hide, + --show= nil, + + lastTime=0, + } + if D.smooth~=nil then + _.smooth=D.smooth + else + _.smooth=_.unit<=1 + end + if D.show then + if type(D.show)=="function"then + _.show=D.show + else + _.show=sliderShowFunc[D.show] + end + elseif D.show~=false then + if _.unit<=1 then + _.show=sliderShowFunc.percent + else + _.show=sliderShowFunc.int + end + end + for k,v in next,slider do _[k]=v end + setmetatable(_,widgetMetatable) + return _ +end local selector={ type="selector", @@ -384,6 +545,7 @@ function selector:draw() end end + --Text setFont(28) t=self.text if t then @@ -397,243 +559,6 @@ end function selector:getInfo() return format("x=%d,y=%d,w=%d",self.x+self.w*.5,self.y+30,self.w) end - -local keyboardNames={--15*5 keys - "ESC","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","","Del", - "1","2","3","4","5","6","7","8","9","0","-","=","","self.x and - xself.y and - y0 then clearResult()