整理代码,修改颜色名和几乎所有的使用方法(可能有错误,需要后续再整理)

This commit is contained in:
MrZ626
2021-04-21 23:51:34 +08:00
parent 9b3b0e2086
commit 09d0612aeb
62 changed files with 701 additions and 690 deletions

View File

@@ -50,7 +50,7 @@ function BGM.init(list)
Sources[list[i]]:setLooping(true)
Sources[list[i]]:setVolume(0)
else
LOG.print("No BGM file: "..list[i],5,COLOR.orange)
LOG.print("No BGM file: "..list[i],5,COLOR.O)
end
if not skip and i~=count then
coroutine.yield()

View File

@@ -4,51 +4,51 @@ local COLOR={
orange= {1.0, 0.6, 0.0},
yellow= {1.0, 1.0, 0.0},
lime= {0.7, 1.0, 0.0},
grass= {0.5, 1.0, 0.0},
jade= {0.5, 1.0, 0.0},
green= {0.0, 1.0, 0.0},
aqua= {0.0, 1.0, 0.6},
cyan= {0.0, 1.0, 1.0},
sky= {0.0, 0.7, 1.0},
navy= {0.0, 0.7, 1.0},
sea= {0.0, 0.4, 1.0},
blue= {0.2, 0.2, 1.0},
purple= {0.4, 0.0, 1.0},
grape= {0.7, 0.0, 1.0},
violet= {0.4, 0.0, 1.0},
purple= {0.7, 0.0, 1.0},
magenta= {1.0, 0.0, 1.0},
pink= {1.0, 0.0, 0.5},
wine= {1.0, 0.0, 0.5},
lRed= {1.0, 0.5, 0.5},
lFire= {1.0, 0.7, 0.5},
lOrange= {1.0, 0.8, 0.3},
lYellow= {1.0, 1.0, 0.5},
lLime= {0.8, 1.0, 0.4},
lGrass= {0.6, 1.0, 0.4},
lJade= {0.6, 1.0, 0.4},
lGreen= {0.5, 1.0, 0.5},
lAqua= {0.4, 1.0, 0.7},
lCyan= {0.5, 1.0, 1.0},
lSky= {0.5, 0.8, 1.0},
lNavy= {0.5, 0.8, 1.0},
lSea= {0.4, 0.7, 1.0},
lBlue= {0.7, 0.7, 1.0},
lPurple= {0.7, 0.4, 1.0},
lGrape= {0.8, 0.4, 1.0},
lViolet= {0.7, 0.4, 1.0},
lPurple= {0.8, 0.4, 1.0},
lMagenta= {1.0, 0.5, 1.0},
lPink= {1.0, 0.4, 0.7},
lWine= {1.0, 0.4, 0.7},
dRed= {0.6, 0.0, 0.0},
dFire= {0.6, 0.3, 0.0},
dOrange= {0.6, 0.4, 0.0},
dYellow= {0.6, 0.6, 0.0},
dLime= {0.5, 0.6, 0.0},
dGrass= {0.3, 0.6, 0.0},
dJade= {0.3, 0.6, 0.0},
dGreen= {0.0, 0.6, 0.0},
dAqua= {0.0, 0.6, 0.4},
dCyan= {0.0, 0.6, 0.6},
dSky= {0.0, 0.4, 0.6},
dNavy= {0.0, 0.4, 0.6},
dSea= {0.0, 0.2, 0.6},
dBlue= {0.1, 0.1, 0.6},
dPurple= {0.2, 0.0, 0.6},
dGrape= {0.4, 0.0, 0.6},
dViolet= {0.2, 0.0, 0.6},
dPurple= {0.4, 0.0, 0.6},
dMagenta= {0.6, 0.0, 0.6},
dPink= {0.6, 0.0, 0.3},
dWine= {0.6, 0.0, 0.3},
black= {0.0, 0.0, 0.0},
dGray= {0.3, 0.3, 0.3},
@@ -56,56 +56,64 @@ local COLOR={
lGray= {0.8, 0.8, 0.8},
white= {1.0, 1.0, 1.0},
}
local map={
R="red", G="green", B="blue", C="cyan", Y="yellow", M="magenta",
lR="lRed", lG="lGreen",lB="lBlue", lC="lCyan", lY="lYellow", lM="lMagenta",
dR="dRed", dG="dGreen",dB="dBlue", dC="dCyan", dY="dYellow", dM="dMagenta",
W="white",
}for k,v in next,map do COLOR[k]=COLOR[v]end
local list_norm={"red","fire","orange","yellow","i","grass","green","aqua","cyan","sky","sea","blue","purple","grape","magenta","pink"}
local len_list_norm=#list_norm
local rnd=math.random
function COLOR.random_norm()
return COLOR[list_norm[rnd(len_list_norm)]]
for k,v in next,{
R="red",F="fire",O="orange",Y="yellow",L="lime",J="jade",G="green",A="aqua",C="cyan",N="navy",S="sea",B="blue",V="violet",P="purple",M="magenta",W="wine",
lR="lRed",lF="lFire",lO="lOrange",lY="lYellow",lL="lLime",lJ="lJade",lG="lGreen",lA="lAqua",lC="lCyan",lN="lNavy",lS="lSea",lB="lBlue",lV="lViolet",lP="lPurple",lM="lMagenta",lW="lWine",
dR="dRed",dF="dFire",dO="dOrange",dY="dYellow",dL="dLime",dJ="dJade",dG="dGreen",dA="dAqua",dC="dCyan",dN="dNavy",dS="dSea",dB="dBlue",dV="dViolet",dP="dPurple",dM="dMagenta",dW="dWine",
D="black",dH="dGray",H="gray",lH="lGray",Z="white",
--Remain letter: EIKQTUX
}do
COLOR[k]=COLOR[v]
end
local list_bright={"lRed","lFire","lOrange","lYellow","lLime","lGrass","lGreen","lAqua","lCyan","lSky","lSea","lBlue","lPurple","lGrape","lMagenta","lPink"}
local len_list_bright=#list_bright
function COLOR.random_bright()
return COLOR[list_bright[rnd(len_list_bright)]]
do--Random generators
local rnd=math.random
local list_norm={"red","fire","orange","yellow","lime","jade","green","aqua","cyan","navy","sea","blue","violet","purple","magenta","wine"}
local len_list_norm=#list_norm
function COLOR.random_norm()
return COLOR[list_norm[rnd(len_list_norm)]]
end
local list_bright={"lRed","lFire","lOrange","lYellow","lLime","lJade","lGreen","lAqua","lCyan","lNavy","lSea","lBlue","lViolet","lPurple","lMagenta","lWine"}
local len_list_bright=#list_bright
function COLOR.random_bright()
return COLOR[list_bright[rnd(len_list_bright)]]
end
local list_dark={"dRed","dFire","dOrange","dYellow","dLime","dJade","dGreen","dAqua","dCyan","dNavy","dSea","dBlue","dViolet","dPurple","dMagenta","dWine"}
local len_list_dark=#list_dark
function COLOR.random_dark()
return COLOR[list_dark[rnd(len_list_dark)]]
end
end
local list_dark={"dRed","dFire","dOrange","dYellow","dLime","dGrass","dGreen","dAqua","dCyan","dSky","dSea","dBlue","dPurple","dGrape","dMagenta","dPink"}
local len_list_dark=#list_dark
function COLOR.random_dark()
return COLOR[list_dark[rnd(len_list_dark)]]
end
local sin=math.sin
function COLOR.rainbow(phase)
return
sin(phase)*.4+.6,
sin(phase+2.0944)*.4+.6,
sin(phase-2.0944)*.4+.6
end
function COLOR.rainbow_light(phase)
return
sin(phase)*.2+.7,
sin(phase+2.0944)*.2+.7,
sin(phase-2.0944)*.2+.7
end
function COLOR.rainbow_dark(phase)
return
sin(phase)*.2+.4,
sin(phase+2.0944)*.2+.4,
sin(phase-2.0944)*.2+.4
end
function COLOR.rainbow_gray(phase)
return
sin(phase)*.16+.5,
sin(phase+2.0944)*.16+.5,
sin(phase-2.0944)*.16+.5
do--Rainbow generators
local sin=math.sin
function COLOR.rainbow(phase)
return
sin(phase)*.4+.6,
sin(phase+2.0944)*.4+.6,
sin(phase-2.0944)*.4+.6
end
function COLOR.rainbow_light(phase)
return
sin(phase)*.2+.7,
sin(phase+2.0944)*.2+.7,
sin(phase-2.0944)*.2+.7
end
function COLOR.rainbow_dark(phase)
return
sin(phase)*.2+.4,
sin(phase+2.0944)*.2+.4,
sin(phase-2.0944)*.2+.4
end
function COLOR.rainbow_gray(phase)
return
sin(phase)*.16+.5,
sin(phase+2.0944)*.16+.5,
sin(phase-2.0944)*.16+.5
end
end
return COLOR

View File

@@ -21,7 +21,7 @@ function FILE.load(name)
return s
end
end
LOG.print(name.." "..text.loadError,COLOR.red)
LOG.print(name.." "..text.loadError,COLOR.R)
end
end
function FILE.save(data,name,mode)
@@ -50,7 +50,7 @@ function FILE.save(data,name,mode)
F:flush()F:close()
if success then
if not mode:find("q")then
LOG.print(text.saveDone,COLOR.green)
LOG.print(text.saveDone,COLOR.G)
end
else
LOG.print(text.saveError..(mes or"unknown error"),"error")

View File

@@ -215,11 +215,11 @@ local function noDevkeyPressed(key)
elseif key=="f5"then if WIDGET.sel then DBP(WIDGET.sel)end
elseif key=="f6"then for k,v in next,_G do DBP(k,v)end
elseif key=="f7"then if love._openConsole then love._openConsole()end
elseif key=="f8"then devMode=nil LOG.print("DEBUG OFF",COLOR.yellow)
elseif key=="f9"then devMode=1 LOG.print("DEBUG 1",COLOR.yellow)
elseif key=="f10"then devMode=2 LOG.print("DEBUG 2",COLOR.yellow)
elseif key=="f11"then devMode=3 LOG.print("DEBUG 3",COLOR.yellow)
elseif key=="f12"then devMode=4 LOG.print("DEBUG 4",COLOR.yellow)
elseif key=="f8"then devMode=nil LOG.print("DEBUG OFF",COLOR.Y)
elseif key=="f9"then devMode=1 LOG.print("DEBUG 1",COLOR.Y)
elseif key=="f10"then devMode=2 LOG.print("DEBUG 2",COLOR.Y)
elseif key=="f11"then devMode=3 LOG.print("DEBUG 3",COLOR.Y)
elseif key=="f12"then devMode=4 LOG.print("DEBUG 4",COLOR.Y)
elseif key=="\\"then _G["\100\114\97\119\70\87\77"]=NULL
elseif devMode==2 then
if WIDGET.sel then
@@ -249,7 +249,7 @@ function love.keypressed(key)
return
elseif key=="f8"then
devMode=1
LOG.print("DEBUG ON",COLOR.yellow)
LOG.print("DEBUG ON",COLOR.Y)
elseif key=="f11"then
switchFullscreen()
elseif not SCN.swapping then
@@ -281,7 +281,7 @@ function love.joystickremoved(JS)
for i=1,#joysticks do
if joysticks[i]==JS then
rem(joysticks,i)
LOG.print("Joystick removed",COLOR.yellow)
LOG.print("Joystick removed",COLOR.Y)
return
end
end
@@ -454,10 +454,10 @@ local WScolor={
{.5,.8,1,.7},
}
local devColor={
COLOR.white,
COLOR.lMagenta,
COLOR.lGreen,
COLOR.lBlue,
COLOR.Z,
COLOR.lM,
COLOR.lG,
COLOR.lB,
}
love.draw,love.update=nil--remove default draw/update
function love.run()

View File

@@ -4,7 +4,7 @@ return function(name,libName)
if r1 and r2 then
return r2
else
LOG.print("Cannot load "..name..": "..(r2 or r3),"warn",COLOR.red)
LOG.print("Cannot load "..name..": "..(r2 or r3),"warn",COLOR.R)
end
elseif SYSTEM=="Android"then
local fs=love.filesystem
@@ -17,25 +17,25 @@ return function(name,libName)
if success then
libFunc,message=package.loadlib(table.concat({SAVEDIR,libName.Android},"/"),libName.libFunc)
if libFunc then
LOG.print(name.." lib loaded","warn",COLOR.green)
LOG.print(name.." lib loaded","warn",COLOR.G)
break
else
LOG.print("Cannot load "..name..": "..message,"warn",COLOR.red)
LOG.print("Cannot load "..name..": "..message,"warn",COLOR.R)
end
else
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,"warn",COLOR.red)
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,"warn",COLOR.R)
end
else
LOG.print("Read "..name.."-"..platform[i].." failed","warn",COLOR.red)
LOG.print("Read "..name.."-"..platform[i].." failed","warn",COLOR.R)
end
end
if not libFunc then
LOG.print("Cannot load "..name,"warn",COLOR.red)
LOG.print("Cannot load "..name,"warn",COLOR.R)
return
end
return libFunc()
else
LOG.print("No "..name.." for "..SYSTEM,"warn",COLOR.red)
LOG.print("No "..name.." for "..SYSTEM,"warn",COLOR.R)
return
end
return true

View File

@@ -39,23 +39,23 @@ function LOG.print(text,T,C)--text,type/time,color
local time
local his
if T=="warn"then
C=C or COLOR.yellow
C=C or COLOR.Y
his=true
time=180
elseif T=="error"then
C=C or COLOR.red
C=C or COLOR.R
his=true
time=210
elseif T=="message"then
C=C or COLOR.sky
C=C or COLOR.N
his=true
elseif type(T)=="number"then
C=C or COLOR.white
C=C or COLOR.Z
time=T
elseif type(T)=="table"then
C=T
elseif not C then
C=COLOR.white
C=COLOR.Z
end
if his then
ins(debugMesHistory,SCN.cur..": "..tostring(text))
@@ -65,6 +65,6 @@ end
function LOG.copy()
local str=table.concat(debugMesHistory,"\n")
love.system.setClipboardText(str)
LOG.print("Log copied",COLOR.blue)
LOG.print("Log copied",COLOR.B)
end
return LOG

View File

@@ -17,7 +17,7 @@ function SFX.init(list)
if love.filesystem.getInfo(N)then
Sources[list[i]]={love.audio.newSource(N,"static")}
else
LOG.print("No SFX file: "..N,5,COLOR.orange)
LOG.print("No SFX file: "..N,5,COLOR.O)
end
if not skip and i~=count then
coroutine.yield()

View File

@@ -2,8 +2,8 @@ local THEME={
cur=false,--Current theme
}
local themeColor={
xmas={COLOR.red,COLOR.white,COLOR.green},
sprfes={COLOR.red,COLOR.orange,COLOR.yellow},
xmas={COLOR.R,COLOR.Z,COLOR.G},
sprfes={COLOR.R,COLOR.O,COLOR.Y},
}
function THEME.calculate(Y,M,D)
@@ -48,15 +48,15 @@ function THEME.set(theme)
elseif theme=="xmas"then
BG.setDefault("snow")
BGM.setDefault("xmas")
LOG.print("==============",COLOR.red)
LOG.print("Merry Christmas!",COLOR.white)
LOG.print("==============",COLOR.red)
LOG.print("==============",COLOR.R)
LOG.print("Merry Christmas!",COLOR.Z)
LOG.print("==============",COLOR.R)
elseif theme=="sprfes"then
BG.setDefault("firework")
BGM.setDefault("spring festival")
LOG.print(" ★☆☆★",COLOR.red)
LOG.print("新年快乐!",COLOR.white)
LOG.print(" ★☆☆★",COLOR.red)
LOG.print(" ★☆☆★",COLOR.R)
LOG.print("新年快乐!",COLOR.Z)
LOG.print(" ★☆☆★",COLOR.R)
elseif theme=="zday1"then
BG.setDefault("lanterns")
BGM.setDefault("empty")

View File

@@ -45,7 +45,7 @@ function VOC.init(list)
if n==1 then
if not loadVoiceFile(list[i],list[i])then
LOG.print("No VOICE file: "..list[i],5,COLOR.orange)
LOG.print("No VOICE file: "..list[i],5,COLOR.O)
end
end
if not Source[list[i]][1]then Source[list[i]]=nil end

View File

@@ -5,6 +5,7 @@ local int,abs=math.floor,math.abs
local max,min=math.max,math.min
local sub,format=string.sub,string.format
local ins=table.insert
local COLOR=COLOR
local setFont,mStr=setFont,mStr
local mDraw_Y=MDRAW.simpY
@@ -56,7 +57,7 @@ function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align="M"][,hide
y= D.y,
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
font= D.font or 30,
align= D.align or"M",
hideCon=D.hide,
@@ -199,7 +200,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font][,align="M"[,
},
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
font= D.font or 30,
align= D.align or"M",
edge= D.edge or 0,
@@ -283,7 +284,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font][,align="M"[,edg
},
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
font= D.font or 30,
align= D.align or"M",
edge= D.edge or 0,
@@ -364,7 +365,7 @@ function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font][,disp],code,hide
},
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
font= D.font or 30,
disp= D.disp,
code= D.code,
@@ -518,7 +519,7 @@ function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font][
},
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
unit= D.unit or 1,
smooth= false,
font= D.font or 30,
@@ -684,7 +685,7 @@ function WIDGET.newSelector(D)--name,x,y,w[,fText][,color],list,disp,code,hide
},
fText= D.fText,
color= D.color and(COLOR[D.color]or D.color)or COLOR.white,
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
font= 30,
list= D.list,
disp= D.disp,
@@ -1003,7 +1004,7 @@ function WIDGET.setLang(widgetText)
local t=W.fText or widgetText[S][W.name]
if not t and not allowNoText[W.type]then
t=W.name or"##"
W.color=COLOR.dPurple
W.color=COLOR.dV
end
if type(t)=="string"and W.font then
t=gc.newText(getFont(W.font),t)