SKIN模块升级,其他多媒体模块微调

This commit is contained in:
MrZ626
2020-12-10 15:29:48 +08:00
parent ddbe1d9c97
commit 681802d030
5 changed files with 140 additions and 124 deletions

View File

@@ -89,6 +89,7 @@ function BGM.init(list)
BGM.nowPlay,BGM.playing=nil
end
end
BGM.loadOne=coroutine.wrap(load)
function BGM.loadAll()load(true)end
end

View File

@@ -1,4 +1,6 @@
local IMG={}
local IMG={
getCount=function()return 0 end,
}
function IMG.init(list)
IMG.init=nil
local count=0
@@ -16,6 +18,7 @@ function IMG.init(list)
end
IMG.loadOne=nil
end
IMG.loadOne=coroutine.wrap(load)
function IMG.loadAll()load(true)end
end

View File

@@ -51,7 +51,7 @@ AIFUNC= require"parts/ai"
MODES= require"parts/modes"
TICK= require"parts/tick"
--Initialize image lib
--Initialize image libs
IMG.init{
batteryImage="/mess/power.png",
title="mess/title.png",
@@ -75,7 +75,30 @@ IMG.init{
electric="mess/electric.png",
hbm="mess/hbm.png",
}
SKIN.init{
"normal(mrz)",
"smooth(mrz)",
"contrast(mrz)",
"glow(mrz)",
"plastic(mrz)",
"jelly(miya)",
"steel(kulumi)",
"pure(mrz)",
"ball(shaw)",
"paper(mrz)",
"gem(notypey)",
"classic(_)",
"brick(notypey)",
"brick_light(notypey)",
"cartoon_cup(earety)",
"crack(earety)",
"retro(notypey)",
"retro_grey(notypey)",
"text_bone(mrz)",
"colored_bone(mrz)",
"white_bone(mrz)",
"WTF",
}
--Initialize sound libs
SFX.init{
--Stereo sfxs(cannot set position)

View File

@@ -128,7 +128,7 @@ function scene.update()
elseif S.phase==5 then
getFont(15+5*S.cur)
elseif S.phase==6 then
SKIN.loadOne(S.cur)
SKIN.loadOne()
elseif S.phase==7 then
local m=MODES[S.cur]--Mode template
local M=require("parts/modes/"..m.name)--Mode file

View File

@@ -1,127 +1,116 @@
local gc=love.graphics
local int=math.floor
local function C(x,y)
local _=gc.newCanvas(x,y)
gc.setCanvas(_)
return _
end
local list={
"normal(mrz)",
"smooth(mrz)",
"contrast(mrz)",
"glow(mrz)",
"plastic(mrz)",
"jelly(miya)",
"steel(kulumi)",
"pure(mrz)",
"ball(shaw)",
"paper(mrz)",
"gem(notypey)",
"classic(_)",
"brick(notypey)",
"brick_light(notypey)",
"cartoon_cup(earety)",
"crack(earety)",
"retro(notypey)",
"retro_grey(notypey)",
"text_bone(mrz)",
"colored_bone(mrz)",
"white_bone(mrz)",
"WTF",
local SKIN={
getCount=function()return 0 end,
prevSet=NULL,
nextSet=NULL,
prev=NULL,
next=NULL,
rotate=NULL,
change=NULL,
}
local count=#list
local SKIN={}
SKIN.lib={}
SKIN.libMini={}
SKIN.libColor={
COLOR.red,
COLOR.fire,
COLOR.orange,
COLOR.yellow,
COLOR.lame,
COLOR.grass,
COLOR.green,
COLOR.water,
COLOR.cyan,
COLOR.sky,
COLOR.sea,
COLOR.blue,
COLOR.purple,
COLOR.grape,
COLOR.magenta,
COLOR.pink,
COLOR.dGrey,
COLOR.black,
COLOR.lYellow,
COLOR.grey,
COLOR.lGrey,
COLOR.dPurple,
COLOR.dRed,
COLOR.dGreen,
}
function SKIN.getCount()
return count
end
function SKIN.loadOne(_)
gc.push()
gc.origin()
gc.setDefaultFilter("nearest","nearest")
gc.setColor(1,1,1)
SKIN.lib[_],SKIN.libMini[_]={},{}
local N="media/image/skin/"..list[_]..".png"
local I
if love.filesystem.getInfo(N)then
I=gc.newImage(N)
else
I=gc.newImage("media/image/skin/"..list[1]..".png")
LOG.print("No skin file: "..list[_],"warn")
function SKIN.init(list)
local gc=love.graphics
local int=math.floor
local function C(x,y)
local _=gc.newCanvas(x,y)
gc.setCanvas(_)
return _
end
for i=0,2 do
for j=1,8 do
SKIN.lib[_][8*i+j]=C(30,30)
gc.draw(I,30-30*j,-30*i)
local count=#list function SKIN.getCount()return count end
SKIN.lib={}
SKIN.libMini={}
SKIN.libColor={
COLOR.red,
COLOR.fire,
COLOR.orange,
COLOR.yellow,
COLOR.lame,
COLOR.grass,
COLOR.green,
COLOR.water,
COLOR.cyan,
COLOR.sky,
COLOR.sea,
COLOR.blue,
COLOR.purple,
COLOR.grape,
COLOR.magenta,
COLOR.pink,
COLOR.dGrey,
COLOR.black,
COLOR.lYellow,
COLOR.grey,
COLOR.lGrey,
COLOR.dPurple,
COLOR.dRed,
COLOR.dGreen,
}
SKIN.libMini[_][8*i+j]=C(6,6)
gc.draw(I,6-6*j,-6*i,nil,.2)
local function load(skip)
for i=1,count do
gc.push()
gc.origin()
gc.setDefaultFilter("nearest","nearest")
gc.setColor(1,1,1)
SKIN.lib[i],SKIN.libMini[i]={},{}
local N="media/image/skin/"..list[i]..".png"
local I
if love.filesystem.getInfo(N)then
I=gc.newImage(N)
else
I=gc.newImage("media/image/skin/"..list[1]..".png")
LOG.print("No skin file: "..list[i],"warn")
end
for y=0,2 do
for x=1,8 do
SKIN.lib[i][8*y+x]=C(30,30)
gc.draw(I,30-30*x,-30*y)
SKIN.libMini[i][8*y+x]=C(6,6)
gc.draw(I,6-6*x,-6*y,nil,.2)
end
end
I:release()
gc.setCanvas()
gc.pop()
if not skip and i~=count then
coroutine.yield()
end
end
SKIN.loadOne=nil
function SKIN.prevSet()--Prev skin_set
local _=(SETTING.skinSet-2)%count+1
SETTING.skinSet=_
SKIN.change(_)
_=list[_]
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
end
function SKIN.nextSet()--Next skin_set
local _=SETTING.skinSet%count+1
SETTING.skinSet=_
SKIN.change(_)
_=list[_]
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
end
function SKIN.prev(i)--Prev skin for [i]
local _=SETTING.skin
_[i]=(_[i]-2)%16+1
end
function SKIN.next(i)--Next skin for [i]
local _=SETTING.skin
_[i]=_[i]%16+1
end
function SKIN.rotate(i)--Change direction of [i]
SETTING.face[i]=(SETTING.face[i]+1)%4
SFX.play("rotate")
end
function SKIN.change(i)--Change to skin_set[i]
SKIN.curText=SKIN.lib[i]
SKIN.curTextMini=SKIN.libMini[i]
end
end
I:release()
gc.setCanvas()
gc.pop()
end
function SKIN.loadAll()
for i=1,count do
SKIN.loadOne(i)
end
end
function SKIN.prevSet()--Prev skin_set
local _=(SETTING.skinSet-2)%count+1
SETTING.skinSet=_
SKIN.change(_)
_=list[_]
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
end
function SKIN.nextSet()--Next skin_set
local _=SETTING.skinSet%count+1
SETTING.skinSet=_
SKIN.change(_)
_=list[_]
TEXT.show(_,1100,100,int(300/#_)+5,"fly")
end
function SKIN.prev(i)--Prev skin for [i]
local _=SETTING.skin
_[i]=(_[i]-2)%16+1
end
function SKIN.next(i)--Next skin for [i]
local _=SETTING.skin
_[i]=_[i]%16+1
end
function SKIN.rotate(i)--Change direction of [i]
SETTING.face[i]=(SETTING.face[i]+1)%4
SFX.play("rotate")
end
function SKIN.change(i)--Change to skin_set[i]
SKIN.curText=SKIN.lib[i]
SKIN.curTextMini=SKIN.libMini[i]
SKIN.loadOne=coroutine.wrap(load)
function SKIN.loadAll()load(true)end
end
return SKIN