调整字体相关的一些东西
整理代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local gc=love.graphics
|
||||
local set=gc.setFont
|
||||
local fontCache={}
|
||||
local currentFontSize
|
||||
|
||||
@@ -8,7 +9,7 @@ function FONT.set(s)
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
gc.setFont(fontCache[s])
|
||||
set(fontCache[s])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
@@ -33,7 +34,7 @@ function FONT.init(mainFont,secFont)
|
||||
fontCache[s]=gc.setNewFont(mainFont,s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
fontCache[s]:setFallbacks(gc.setNewFont(secFont,s,'light',gc.getDPIScale()*SCR.k*2))
|
||||
end
|
||||
gc.setFont(fontCache[s])
|
||||
set(fontCache[s])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -91,7 +91,7 @@ local batteryImg=GC.DO{31,20,
|
||||
{'fRect',26,1,2,18},
|
||||
{'fRect',29,3,2,14},
|
||||
}
|
||||
local infoCanvas=gc.newCanvas(108,27)
|
||||
local infoCanvas=gc.newCanvas(93,27)
|
||||
local function updatePowerInfo()
|
||||
local state,pow=love.system.getPowerInfo()
|
||||
gc.setCanvas(infoCanvas)
|
||||
@@ -104,7 +104,7 @@ local function updatePowerInfo()
|
||||
if state=='nobattery'then
|
||||
gc_setColor(1,1,1)
|
||||
gc_setLineWidth(2)
|
||||
gc_line(74,SCR.safeX+5,100,22)
|
||||
gc_line(59,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)
|
||||
@@ -112,22 +112,22 @@ local function updatePowerInfo()
|
||||
elseif pow==26 then gc_setColor(.5,0,1)
|
||||
else gc_setColor(1,0,0)
|
||||
end
|
||||
gc.rectangle('fill',76,6,pow*.22,14)
|
||||
gc.rectangle('fill',61,6,pow*.22,14)
|
||||
if pow<100 then
|
||||
FONT.set(15)
|
||||
gc.setColor(COLOR.D)
|
||||
gc_print(pow,77,1)
|
||||
gc_print(pow,77,3)
|
||||
gc_print(pow,79,1)
|
||||
gc_print(pow,79,3)
|
||||
gc_print(pow,62.5,2.5)
|
||||
gc_print(pow,62.5,4.5)
|
||||
gc_print(pow,64.5,2.5)
|
||||
gc_print(pow,64.5,4.5)
|
||||
gc_setColor(COLOR.Z)
|
||||
gc_print(pow,78,2)
|
||||
gc_print(pow,63.5,3.5)
|
||||
end
|
||||
end
|
||||
gc_draw(batteryImg,73,3)
|
||||
gc_draw(batteryImg,58,3)
|
||||
end
|
||||
FONT.set(25)
|
||||
gc_print(os.date("%H:%M"),3,-5)
|
||||
gc_print(os.date("%H:%M"),5,-2)
|
||||
gc_pop()
|
||||
gc.setCanvas()
|
||||
end
|
||||
|
||||
@@ -17,6 +17,7 @@ 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=mStr
|
||||
|
||||
local downArrowIcon=GC.DO{40,25,{'fPoly',0,0,20,25,40,0}}
|
||||
@@ -850,19 +851,21 @@ function inputBox:draw()
|
||||
gc_rectangle('line',x,y,w,h,3)
|
||||
|
||||
--Drawable
|
||||
FONT.set(self.font)
|
||||
local f=self.font
|
||||
FONT.set(f)
|
||||
if self.obj then
|
||||
mDraw_Y(self.obj,x-12-self.obj:getWidth(),y+h*.5)
|
||||
end
|
||||
if self.secret then
|
||||
y=y+h*.5-f*.2
|
||||
for i=1,#self.value do
|
||||
gc_print("*",x-5+self.font*.5*i,y+h*.5-self.font*.7)
|
||||
gc_rectangle("fill",x+f*.6*i,y,f*.4,f*.4)
|
||||
end
|
||||
else
|
||||
gc_printf(self.value,x+10,y,self.w)
|
||||
FONT.set(self.font-10)
|
||||
FONT.set(f-10)
|
||||
if WIDGET.sel==self then
|
||||
gc_print(EDITING,x+10,y+12-self.font*1.4)
|
||||
gc_print(EDITING,x+10,y+12-f*1.4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user