setFont改为font模块,字体文件放到parts/fonts内,调整打包ci对应处
This commit is contained in:
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -54,7 +54,7 @@ jobs:
|
||||
7z x .\resource_hacker.zip
|
||||
- name: Pack Techmino
|
||||
run: |
|
||||
7z a -tzip .\Techmino.love .\document .\font .\media .\parts .\Zframework .\conf.lua .\main.lua .\version.lua
|
||||
7z a -tzip .\Techmino.love .\document .\media .\parts .\Zframework .\conf.lua .\main.lua .\version.lua
|
||||
cmd /c copy /b .\love-11.3-win64\love.exe + .\Techmino.love .\love-11.3-win64\Techmino.exe
|
||||
del .\love-11.3-win64\love.exe
|
||||
del .\love-11.3-win64\lovec.exe
|
||||
@@ -124,7 +124,7 @@ jobs:
|
||||
cp ./squashfs-root/icon.png ./squashfs-root/.DirIcon
|
||||
chmod 777 ./squashfs-root/love
|
||||
mkdir -p ./squashfs-root/usr/share/Techmino
|
||||
mv ./document ./font ./media ./parts ./Zframework ./conf.lua ./main.lua ./version.lua ./squashfs-root/usr/share/Techmino
|
||||
mv ./document ./media ./parts ./Zframework ./conf.lua ./main.lua ./version.lua ./squashfs-root/usr/share/Techmino
|
||||
mv ./ColdClear/CCloader.so ./squashfs-root/usr/share/Techmino
|
||||
mv ./ColdClear/libcold_clear.so ./squashfs-root/usr/lib
|
||||
chmod 777 ./appimagetool-x86_64.AppImage
|
||||
@@ -198,7 +198,7 @@ jobs:
|
||||
mkdir -p ./libAndroid/armeabi-v7a
|
||||
mv ./ColdClear/android_aarch64/libs/arm64-v8a/libCCloader.so ./libAndroid/arm64-v8a
|
||||
mv ./ColdClear/android_armv7/libs/armeabi-v7a/libCCloader.so ./libAndroid/armeabi-v7a
|
||||
7z a -tzip ./love-android/app/src/main/assets/game.love ./document ./font ./media ./parts ./Zframework ./libAndroid ./conf.lua ./main.lua ./version.lua
|
||||
7z a -tzip ./love-android/app/src/main/assets/game.love ./document ./media ./parts ./Zframework ./libAndroid ./conf.lua ./main.lua ./version.lua
|
||||
echo "${{ secrets.SIGNING_KEY }}" | base64 -d > ./love-android/app/android.keystore
|
||||
python3 ./.github/workflows/updateVersion.py -T AndroidSnapshot -C $(lua ./.github/workflows/getVersion.lua -code) -N ${{ env.Version }} -S ${{ secrets.KEY_STORE_PASSWORD }} -A ${{ secrets.ALIAS }} -K ${{ secrets.KEY_PASSWORD }}
|
||||
chmod 777 ./love-android/gradlew
|
||||
@@ -238,7 +238,7 @@ jobs:
|
||||
python3 ./.github/workflows/updateVersion.py -T Version -H ${{ env.CommitID }}
|
||||
- name: Pack love
|
||||
run: |
|
||||
7z a -tzip ./Techmino.love ./document ./font ./media ./parts ./Zframework ./conf.lua ./main.lua ./version.lua
|
||||
7z a -tzip ./Techmino.love ./document ./media ./parts ./Zframework ./conf.lua ./main.lua ./version.lua
|
||||
- name: Download template
|
||||
run: |
|
||||
curl -OL https://github.com/26F-Studio/Techmino/releases/download/v0.15.1/Techmino.app.zip
|
||||
|
||||
55
Zframework/font.lua
Normal file
55
Zframework/font.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
local gc=love.graphics
|
||||
local fontCache={}
|
||||
local currentFontSize
|
||||
|
||||
local FONT={}
|
||||
function FONT.set(s)
|
||||
if s~=currentFontSize then
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
gc.setFont(fontCache[s])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
function FONT.get(s)print(1)
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
return fontCache[s]
|
||||
end
|
||||
function FONT.reset()
|
||||
for s in next,fontCache do
|
||||
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
end
|
||||
|
||||
function FONT.init(mainFont,secFont)
|
||||
mainFont=love.filesystem.newFile(mainFont)
|
||||
secFont=love.filesystem.newFile(secFont)
|
||||
function FONT.set(s)
|
||||
if s~=currentFontSize then
|
||||
if not fontCache[s]then
|
||||
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])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
function FONT.get(s)
|
||||
if not fontCache[s]then
|
||||
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
|
||||
return fontCache[s]
|
||||
end
|
||||
function FONT.reset()
|
||||
for s in next,fontCache do
|
||||
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
|
||||
end
|
||||
FONT.reset()
|
||||
end
|
||||
return FONT
|
||||
@@ -95,7 +95,7 @@ do--function GC.DO(L)
|
||||
setLJ="setLineJoin",
|
||||
|
||||
print="print",
|
||||
setFT=function(...)setFont(...)end,
|
||||
setFT=function(...)FONT.set(...)end,
|
||||
mText=GC.str,
|
||||
mDraw=GC.draw,
|
||||
mOutDraw=GC.outDraw,
|
||||
|
||||
@@ -44,11 +44,11 @@ SCN= require'Zframework.scene'
|
||||
LIGHT= require'Zframework.light'
|
||||
|
||||
--Love-based modules (complex)
|
||||
GC=require'Zframework.gcExtend'
|
||||
GC= require'Zframework.gcExtend'
|
||||
mStr=GC.str
|
||||
mText=GC.simpX
|
||||
mDraw=GC.draw
|
||||
require'Zframework.setFont'
|
||||
FONT= require'Zframework.font'
|
||||
TEXT= require'Zframework.text'
|
||||
SYSFX= require'Zframework.sysFX'
|
||||
MES= require'Zframework.message'
|
||||
@@ -68,7 +68,7 @@ local gc_replaceTransform,gc_present=gc.replaceTransform,gc.present
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_draw,gc_line,gc_print=gc.draw,gc.line,gc.print
|
||||
|
||||
local setFont,mStr=setFont,mStr
|
||||
local mStr=mStr
|
||||
|
||||
local int,rnd,abs=math.floor,math.random,math.abs
|
||||
local min,sin=math.min,math.sin
|
||||
@@ -114,7 +114,7 @@ local function updatePowerInfo()
|
||||
end
|
||||
gc.rectangle('fill',76,6,pow*.22,14)
|
||||
if pow<100 then
|
||||
setFont(15)
|
||||
FONT.set(15)
|
||||
gc.setColor(COLOR.D)
|
||||
gc_print(pow,77,1)
|
||||
gc_print(pow,77,3)
|
||||
@@ -126,7 +126,7 @@ local function updatePowerInfo()
|
||||
end
|
||||
gc_draw(batteryImg,73,3)
|
||||
end
|
||||
setFont(25)
|
||||
FONT.set(25)
|
||||
gc_print(os.date("%H:%M"),3,-5)
|
||||
gc_pop()
|
||||
gc.setCanvas()
|
||||
@@ -388,7 +388,7 @@ function love.resize(w,h)
|
||||
if BG.resize then BG.resize(w,h)end
|
||||
if SCN.resize then SCN.resize(w,h)end
|
||||
WIDGET.resize(w,h)
|
||||
resetFont()
|
||||
FONT.reset()
|
||||
|
||||
SHADER.warning:send('w',w*SCR.dpi)
|
||||
end
|
||||
@@ -475,9 +475,9 @@ function love.errorhandler(msg)
|
||||
gc_clear(.3,.5,.9)
|
||||
gc_push('transform')
|
||||
gc_replaceTransform(SCR.xOy)
|
||||
setFont(100)gc_print(":(",100,0,0,1.2)
|
||||
setFont(40)gc.printf(errorMsg,100,160,SCR.w0-100)
|
||||
setFont(20)
|
||||
FONT.set(100)gc_print(":(",100,0,0,1.2)
|
||||
FONT.set(40)gc.printf(errorMsg,100,160,SCR.w0-100)
|
||||
FONT.set(20)
|
||||
gc_print(SYSTEM.."-"..VERSION.string.." scene:"..(SCN and SCN.cur or"NULL"),100,660)
|
||||
gc.printf(err[1],100,360,1260-100)
|
||||
gc_print("TRACEBACK",100,450)
|
||||
@@ -517,16 +517,17 @@ end
|
||||
local ws_deadImg=GC.DO{20,20,
|
||||
{'setFT',20},
|
||||
{'setCL',1,.3,.3},
|
||||
{'print',"X",3,-4},
|
||||
{'print',"X",3,-1},
|
||||
}
|
||||
local ws_connectingImg=GC.DO{20,20,
|
||||
{'setFT',20},
|
||||
{'setLW',3},
|
||||
{'dArc',11.5,10,6.26,1,5.28},
|
||||
{'print',"C",3,-1},
|
||||
}
|
||||
local ws_runningImg=GC.DO{20,20,
|
||||
{'setFT',20},
|
||||
{'setCL',.5,1,0},
|
||||
{'print',"R",3,-4},
|
||||
{'print',"R",3,-1},
|
||||
}
|
||||
local cursorImg=GC.DO{16,16,
|
||||
{'fCirc',8,8,4},
|
||||
@@ -642,11 +643,11 @@ function love.run()
|
||||
gc_replaceTransform(SCR.xOy_d)
|
||||
--Draw Version string
|
||||
gc_setColor(.8,.8,.8,.4)
|
||||
setFont(20)
|
||||
FONT.set(20)
|
||||
mStr(VERSION.string,0,-30)
|
||||
gc_replaceTransform(SCR.xOy_dl)
|
||||
--Draw FPS
|
||||
setFont(15)
|
||||
FONT.set(15)
|
||||
gc_setColor(1,1,1)
|
||||
gc_print(FPS(),safeX+5,-20)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ function MES.new(icon,str,time)
|
||||
backColor=backColors[icon]or backColor
|
||||
icon=mesIcon[icon]
|
||||
end
|
||||
local t=gc.newText(getFont(30),str)
|
||||
local t=gc.newText(FONT.get(30),str)
|
||||
local w=math.max(t:getWidth()+(icon and 45 or 5),200)+20
|
||||
local h=math.max(t:getHeight(),46)+3
|
||||
local L={w,h,
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
local gc=love.graphics
|
||||
local newFont=gc.setNewFont
|
||||
local setNewFont=gc.setFont
|
||||
local fontCache,currentFontSize={}
|
||||
if
|
||||
love.filesystem.getInfo('font/barlowCond.ttf')and
|
||||
love.filesystem.getInfo('font/puhui.ttf')
|
||||
then
|
||||
local fontData=love.filesystem.newFile('font/barlowCond.ttf')
|
||||
local fallback=love.filesystem.newFile('font/puhui.ttf')
|
||||
function setFont(s)
|
||||
if s~=currentFontSize then
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
|
||||
end
|
||||
setNewFont(fontCache[s])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
function getFont(s)
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
|
||||
end
|
||||
return fontCache[s]
|
||||
end
|
||||
function resetFont()
|
||||
for s in next,fontCache do
|
||||
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
|
||||
end
|
||||
end
|
||||
else
|
||||
function setFont(s)
|
||||
if s~=currentFontSize then
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
setNewFont(fontCache[s])
|
||||
currentFontSize=s
|
||||
end
|
||||
end
|
||||
function getFont(s)
|
||||
if not fontCache[s]then
|
||||
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
return fontCache[s]
|
||||
end
|
||||
function resetFont()
|
||||
for s in next,fontCache do
|
||||
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,7 +4,7 @@ local gc_translate,gc_scale,gc_rotate,gc_shear=gc.translate,gc.scale,gc.rotate,g
|
||||
|
||||
local int,rnd=math.floor,math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
local setFont,mStr=setFont,mStr
|
||||
local mStr=mStr
|
||||
|
||||
local texts={}
|
||||
|
||||
@@ -122,7 +122,7 @@ function TEXT.draw(list)
|
||||
local t=list[i]
|
||||
local p=t.c
|
||||
gc_setColor(1,1,1,p<.2 and p*5 or p<.8 and 1 or 5-p*5)
|
||||
setFont(t.font)
|
||||
FONT.set(t.font)
|
||||
t:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,9 +15,9 @@ local next=next
|
||||
local int,ceil,abs=math.floor,math.ceil,math.abs
|
||||
local max,min=math.max,math.min
|
||||
local sub,ins,rem=string.sub,table.insert,table.remove
|
||||
local getFont,setFont,mStr=getFont,setFont,mStr
|
||||
local mDraw,mDraw_X,mDraw_Y=GC.draw,GC.simpX,GC.simpY
|
||||
local xOy=SCR.xOy
|
||||
local mStr=mStr
|
||||
|
||||
local downArrowIcon=GC.DO{40,25,{'fPoly',0,0,20,25,40,0}}
|
||||
local upArrowIcon=GC.DO{40,25,{'fPoly',0,25,20,0,40,25}}
|
||||
@@ -28,7 +28,7 @@ local clearIcon=GC.DO{40,40,
|
||||
}
|
||||
local sureIcon=GC.DO{40,40,
|
||||
{'setFT',35},
|
||||
{'mText',"?",20,-6},
|
||||
{'mText',"?",20,0},
|
||||
}
|
||||
local smallerThen=GC.DO{20,20,
|
||||
{'setLW',5},
|
||||
@@ -137,7 +137,7 @@ function button:reset()
|
||||
end
|
||||
function button:setObject(obj)
|
||||
if type(obj)=='string'or type(obj)=='number'then
|
||||
self.obj=gc.newText(getFont(self.font),obj)
|
||||
self.obj=gc.newText(FONT.get(self.font),obj)
|
||||
elseif obj then
|
||||
self.obj=obj
|
||||
end
|
||||
@@ -264,7 +264,7 @@ function key:reset()
|
||||
end
|
||||
function key:setObject(obj)
|
||||
if type(obj)=='string'or type(obj)=='number'then
|
||||
self.obj=gc.newText(getFont(self.font),obj)
|
||||
self.obj=gc.newText(FONT.get(self.font),obj)
|
||||
elseif obj then
|
||||
self.obj=obj
|
||||
end
|
||||
@@ -535,7 +535,7 @@ function slider:draw()
|
||||
|
||||
--Float text
|
||||
if self.TAT>0 and self.show then
|
||||
setFont(25)
|
||||
FONT.set(25)
|
||||
gc_setColor(.97,.97,.97,self.TAT/180)
|
||||
mStr(self:show(),cx,by-30)
|
||||
end
|
||||
@@ -711,7 +711,7 @@ function selector:draw()
|
||||
gc_setColor(self.color)
|
||||
GC.simpX(self.obj,x+w*.5,y+17-21)
|
||||
gc_setColor(1,1,1)
|
||||
setFont(30)
|
||||
FONT.set(30)
|
||||
mStr(self.selText,x+w*.5,y+43-21)
|
||||
end
|
||||
function selector:getInfo()
|
||||
@@ -850,7 +850,7 @@ function inputBox:draw()
|
||||
gc_rectangle('line',x,y,w,h,3)
|
||||
|
||||
--Drawable
|
||||
setFont(self.font)
|
||||
FONT.set(self.font)
|
||||
if self.obj then
|
||||
mDraw_Y(self.obj,x-12-self.obj:getWidth(),y+h*.5)
|
||||
end
|
||||
@@ -860,7 +860,7 @@ function inputBox:draw()
|
||||
end
|
||||
else
|
||||
gc_printf(self.value,x+10,y,self.w)
|
||||
setFont(self.font-10)
|
||||
FONT.set(self.font-10)
|
||||
if WIDGET.sel==self then
|
||||
gc_print(EDITING,x+10,y+12-self.font*1.4)
|
||||
end
|
||||
@@ -1007,7 +1007,7 @@ function textBox:draw()
|
||||
gc_rectangle('line',x,y,w,h,3)
|
||||
|
||||
--Texts
|
||||
setFont(self.font)
|
||||
FONT.set(self.font)
|
||||
gc_push('transform')
|
||||
gc_translate(x,y)
|
||||
|
||||
@@ -1282,7 +1282,7 @@ function WIDGET.setLang(widgetText)
|
||||
W.color=COLOR.dV
|
||||
end
|
||||
if type(t)=='string'and W.font then
|
||||
t=gc.newText(getFont(W.font),t)
|
||||
t=gc.newText(FONT.get(W.font),t)
|
||||
end
|
||||
W.obj=t
|
||||
end
|
||||
|
||||
3
main.lua
3
main.lua
@@ -45,6 +45,9 @@ end
|
||||
|
||||
--Load modules
|
||||
require'Zframework'
|
||||
FONT.init('parts/fonts/barlowCond.ttf','parts/fonts/puhui.ttf')
|
||||
setFont=FONT.set
|
||||
getFont=FONT.get
|
||||
SCR.setSize(1280,720)--Initialize Screen size
|
||||
BGM.setChange(function(name)MES.new('music',text.nowPlaying..name,5)end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user