Zframework finished

This commit is contained in:
MrZ_26
2020-07-08 20:26:28 +08:00
parent cdd5194108
commit a3302ab2bc
47 changed files with 308 additions and 275 deletions

303
Zframework/bg.lua Normal file
View File

@@ -0,0 +1,303 @@
local gc=love.graphics
local int,ceil,rnd,abs=math.floor,math.ceil,math.random,math.abs
local max,min,sin,cos=math.max,math.min,math.sin,math.cos
local BG
local scr=scr
local BGvars={_G=_G,SHADER=SHADER}
local back={}
back.none={
draw=function()
gc.clear(.15,.15,.15)
end,
}
back.grey={
draw=function()
gc.clear(.3,.3,.3)
end,
}
back.glow={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
local t=(sin(t*.5)+sin(t*.7)+sin(t*.9+1)+sin(t*1.5)+sin(t*2+10))*.08
gc.clear(t,t,t)
end,
}--light-dark
back.rgb={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
gc.clear(
sin(t*1.2)*.15+.2,
sin(t*1.5)*.15+.2,
sin(t*1.9)*.15+.2
)
end,
}--Changing pure color
back.strap={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.strap:send("t",t*.626)
gc.setColor(.4,.626,.626)
gc.setShader(SHADER.strap)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--Horizonal ranbow
back.flink={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
local t=.13-t%3%1.7
if t<.2 then gc.clear(t,t,t)
else gc.clear(0,0,0)
end
end,
}--flash after random time
back.aura={
init=function()
t=rnd()*3600
BG.resize(scr.w,scr.h)
end,
resize=function(w,h)
SHADER.aura:send("w",w*scr.dpi)
SHADER.aura:send("h",h*scr.dpi)
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.aura:send("t",t)
gc.setShader(SHADER.aura)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--cool liquid background
back.game1={
init=function()
t=0
BG.resize(scr.w,scr.h)
end,
resize=function(w,h)
SHADER.rainbow:send("w",w*scr.dpi)
SHADER.rainbow:send("h",h*scr.dpi)
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.rainbow:send("t",t)
gc.setColor(.6,.6,.6)
gc.setShader(SHADER.rainbow)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--Rolling rainbow
back.game2={
init=function()
t=0
BG.resize(scr.w,scr.h)
end,
resize=function(w,h)
SHADER.rainbow:send("w",w*scr.dpi)
SHADER.rainbow:send("h",h*scr.dpi)
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.rainbow:send("t",t)
gc.setColor(.7,.4,.4)
gc.setShader(SHADER.rainbow)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--Red rolling rainbow
back.game3={
init=function()
t=0
BG.resize(scr.w,scr.h)
end,
resize=function(w,h)
SHADER.rainbow:send("w",w*scr.dpi)
SHADER.rainbow:send("h",h*scr.dpi)
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.rainbow:send("t",t)
gc.setColor(.5,.5,.8)
gc.setShader(SHADER.rainbow)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--Blue rolling rainbow
back.game4={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
SHADER.strap:send("t",t*1.26)
gc.setColor(.5,.626,.74)
gc.setShader(SHADER.strap)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end,
}--Blue strap
back.game5={
init=function()
t=0
end,
update=function(dt)
t=t+dt
end,
draw=function()
local t=2.5-t%20%6%2.5
if t<.3 then gc.clear(t,t,t)
else gc.clear(0,0,0)
end
end,
}--Lightning
local blocks=require("parts/mino")
local scs=require("parts/spinCenters")
back.game6={
init=function()
t=0
colorLib=_G.SKIN.libColor
colorSet=_G.setting.skin
miniBlock=_G.miniBlock
end,
update=function(dt)
t=t+dt
end,
draw=function()
local t=1.2-t%10%3%1.2
if t<.3 then gc.clear(t,t,t)
else gc.clear(0,0,0)
end
local R=7-int(t*.5)%7
local _=colorLib[colorSet[R]]
gc.setColor(_[1],_[2],_[3],.1)
gc.draw(miniBlock[R],640,360,t%3.1416*6,400,400,scs[R][0][2]-.5,#blocks[R][0]-scs[R][0][1]+.5)
end,
}--Fast lightning + spining tetromino
local matrixT={}for i=1,50 do matrixT[i]={}for j=1,50 do matrixT[i][j]=love.math.noise(i,j)+2 end end
back.matrix={
init=function()
t=rnd()*3600
end,
update=function(dt)
t=t+dt
end,
draw=function()
gc.scale(scr.k)
gc.clear(.15,.15,.15)
local Y=ceil(scr.h*scr.dpi/80)
for x=1,ceil(scr.w*scr.dpi/80)do
for y=1,Y do
gc.setColor(1,1,1,sin(x+matrixT[x][y]*t)*.1+.1)
gc.rectangle("fill",80*x,80*y,-80,-80)
end
end
gc.scale(1/scr.k)
end,
}
back.space={
init=function()
stars={}
W,H=scr.w+20,scr.h+20
BG.resize(scr.w,scr.h)
end,
resize=function(w,h)
local S=stars
for i=1,1260,5 do
local s=rnd(26,40)*.1
S[i]=s*scr.k --size
S[i+1]=rnd(W)-10 --x
S[i+2]=rnd(H)-10 --y
S[i+3]=(rnd()-.5)*.01*s --vx
S[i+4]=(rnd()-.5)*.01*s --vy
end--800 var
end,
update=function(dt)
local S=stars
for i=1,1260,5 do
S[i+1]=(S[i+1]+S[i+3])%W
S[i+2]=(S[i+2]+S[i+4])%H
end--star moving
end,
draw=function()
gc.clear(.2,.2,.2)
if not stars[1]then return end
gc.translate(-10,-10)
gc.setColor(.8,.8,.8)
for i=1,1260,5 do
local s=stars
local x,y=s[i+1],s[i+2]
s=s[i]
gc.rectangle("fill",x,y,s,s)
end
gc.translate(10,10)
end,
discard=function()
stars={}
end,
}
for _,bg in next,back do
if not bg.init then bg.init= NULL end setfenv(bg.init ,BGvars)
if not bg.resize then bg.resize= NULL end setfenv(bg.resize ,BGvars)
if not bg.update then bg.update= NULL end setfenv(bg.update ,BGvars)
if not bg.discard then bg.discard=NULL end setfenv(bg.discard ,BGvars)
if not bg.draw then bg.draw= NULL end setfenv(bg.draw ,BGvars)
end--make BG vars invisible
BG={
cur="none",
resize=NULL,
update=NULL,
draw=back.none.draw,
}
function BG.set(bg)
if bg==BG.cur or not setting.bg then return end
if BG.discard then
BG.discard()
collectgarbage()
end
BG.cur=bg
bg=back[bg]
BG.init=bg.init or NULL
BG.resize=bg.resize or NULL
BG.update=bg.update or NULL
BG.discard=bg.discard or NULL
BG.draw=bg.draw or NULL
BG.init()
end
return BG

89
Zframework/bgm.lua Normal file
View File

@@ -0,0 +1,89 @@
local min=math.min
local rem=table.remove
local function fadeOut(id)
local src=BGM.list[id]
local v=src:getVolume()-.025*setting.bgm*.1
src:setVolume(v>0 and v or 0)
if v<=0 then
src:stop()
return true
end
end
local function fadeIn(id)
local src=BGM.list[id]
local v=min(src:getVolume()+.025*setting.bgm*.1,setting.bgm*.1)
src:setVolume(v)
if v>=setting.bgm*.1 then return true end
end
local BGM={
--nowPlay=[str:playing ID]
--suspend=[str:pausing ID]
--playing=[src:playing SRC]
}
BGM.list={
"blank","way","race","newera","push","reason","infinite",
"secret7th","secret8th",
"shining terminal","oxygen","distortion","far",
"rockblock","cruelty","final","8-bit happiness","end",
"how feeling",
}
BGM.len=#BGM.list
function BGM.loadOne(N)
N=BGM.list[N]
local file="/BGM/"..N..".ogg"
if love.filesystem.getInfo(file)then
BGM.list[N]=love.audio.newSource(file,"stream")
BGM.list[N]:setLooping(true)
BGM.list[N]:setVolume(0)
end
end
function BGM.loadAll()
for i=1,#BGM.list do
BGM.loadOne(i)
end
end
function BGM.play(s)
if setting.bgm==0 then
BGM.playing=BGM.list[s]
BGM.suspend,BGM.nowPlay=s
return
elseif not s or not BGM.list[s]then
return
end
if BGM.nowPlay~=s then
if BGM.nowPlay then TASK.new(fadeOut,BGM.nowPlay)end
TASK.changeCode(fadeIn,fadeOut)
TASK.removeTask_data(s)
BGM.nowPlay,BGM.suspend=s
TASK.new(fadeIn,s)
BGM.playing=BGM.list[s]
BGM.playing:play()
end
end
function BGM.freshVolume()
if BGM.playing then
local v=setting.bgm*.1
if v>0 then
BGM.playing:setVolume(v)
if BGM.suspend then
BGM.playing:play()
BGM.nowPlay,BGM.suspend=BGM.suspend
end
else
BGM.playing:setVolume(0)
BGM.playing:pause()
BGM.suspend,BGM.nowPlay=BGM.nowPlay
end
end
end
function BGM.stop()
if BGM.nowPlay then
TASK.new(fadeOut,BGM.nowPlay)
end
TASK.changeCode(fadeIn,fadeOut)
BGM.playing,BGM.nowPlay=nil
end
return BGM

38
Zframework/color.lua Normal file
View File

@@ -0,0 +1,38 @@
return{
red={1,0,0},
green={0,1,0},
blue={.2,.2,1},
yellow={1,1,0},
magenta={1,0,1},
cyan={0,1,1},
grey={.6,.6,.6},
lightRed={1,.5,.5},
lightGreen={.5,1,.5},
lightBlue={.6,.6,1},
lightYellow={1,1,.5},
lightMagenta={1,.5,1},
lightCyan={.5,1,1},
lightGrey={.8,.8,.8},
darkRed={.6,0,0},
darkGreen={0,.6,0},
darkBlue={0,0,.6},
darkYellow={.6,.6,0},
darkMagenta={.6,0,.6},
darkCyan={0,.6,.6},
darkGrey={.3,.3,.3},
black={0,0,0},
orange={1,.6,0},
pink={1,0,.6},
grass={.6,1,0},
water={0,1,.6},
bronze={.7,.4,0},
white={1,1,1},
lightOrange={1,.7,.3},
darkOrange={.6,.4,0},
purple={.5,0,1},
lightPurple={.8,.4,1},
darkPurple={.3,0,.6},
}

219
Zframework/file.lua Normal file
View File

@@ -0,0 +1,219 @@
local fs=love.filesystem
local int,max,min=math.floor,math.max,math.min
local sub,find=string.sub,string.find
local toN,toS=tonumber,tostring
local concat=table.concat
local function splitS(s,sep)
local t,n={},1
repeat
local p=find(s,sep)or #s+1
t[n]=sub(s,1,p-1)
n=n+1
s=sub(s,p+#sep)
until #s==0
return t
end
local tabs={
[0]="",
"\t",
"\t\t",
"\t\t\t",
"\t\t\t\t",
"\t\t\t\t\t",
}
local function dumpTable(L,t)
local s
if t then
s="{\n"
else
s="return{\n"
t=1
end
local count=1
for k,v in next,L do
local T=type(k)
if T=="number"then
if k==count then
k="";count=count+1
else
k="["..k.."]="
end
elseif T=="string"then k=k.."="
elseif T=="boolean"then k="["..k.."]="
else assert(false,"Error key type!")
end
T=type(v)
if T=="number"then v=tostring(v)
elseif T=="string"then v="\""..v.."\""
elseif T=="table"then v=dumpTable(v,t+1)
elseif T=="boolean"then v=tostring(v)
else assert(false,"Error data type!")
end
s=s..tabs[t]..k..v..",\n"
end
return s..tabs[t-1].."}"
end
local function addToTable(G,base)--refresh default base with G-values
for k,v in next,G do
if type(v)==type(base[k])then
if type(v)=="table"then
addToTable(v,base[k])
else
base[k]=v
end
end
end
end
local files={
data= fs.newFile("data.dat"),
setting=fs.newFile("settings.dat"),
VK= fs.newFile("virtualkey.dat"),
keyMap= fs.newFile("key.dat"),
unlock= fs.newFile("unlock.dat"),
}
local File={}
function File.loadRecord(N)
local F=fs.newFile(N..".dat")
if F:open("r")then
local s=loadstring(F:read())
F:close()
if s then
setfenv(s,{})
return s()
else
return{}
end
end
end
function File.saveRecord(N,L)
local F=fs.newFile(N..".dat")
F:open("w")
local _,mes=F:write(dumpTable(L))
F:flush()F:close()
if not _ then
TEXT.show(text.recSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
function File.delRecord(N)
fs.remove(N..".dat")
end
function File.loadUnlock()
local F=files.unlock
if F:open("r")then
local s=F:read()
if s:sub(1,6)~="return"then s="return{"..s.."}"end
s=loadstring(s)
F:close()
if s then
setfenv(s,{})
modeRanks=s()
end
end
end
function File.saveUnlock()
local F=files.unlock
F:open("w")
local _,mes=F:write(dumpTable(modeRanks))
F:flush()F:close()
if not _ then
TEXT.show(text.unlockSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
function File.loadData()
local F=files.data
if F:open("r")then
local s=F:read()
if s:sub(1,6)~="return"then
s="return{"..s:gsub("\n",",").."}"
end
s=loadstring(s)
F:close()
if s then
setfenv(s,{})
local S=s()
addToTable(S,stat)
end
end
end
function File.saveData()
local F=files.data
F:open("w")
local _,mes=F:write(dumpTable(stat))
F:flush()F:close()
if not _ then
TEXT.show(text.statSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
function File.loadSetting()
local F=files.setting
if F:open("r")then
local s=F:read()
if s:sub(1,6)~="return"then
s="return{"..s:gsub("\n",",").."}"
end
s=loadstring(s)
F:close()
if s then
setfenv(s,{})
addToTable(s(),setting)
end
end
end
function File.saveSetting()
local F=files.setting
F:open("w")
local _,mes=F:write(dumpTable(setting))
F:flush()F:close()
if _ then TEXT.show(text.settingSaved,1140,650,40,"sudden",.5)
else TEXT.show(text.settingSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
function File.loadKeyMap()
local F=files.keyMap
if F:open("r")then
local s=loadstring(F:read())
F:close()
if s then
setfenv(s,{})
addToTable(s(),keyMap)
end
end
end
function File.saveKeyMap()
local F=files.keyMap
F:open("w")
local _,mes=F:write(dumpTable(keyMap))
F:flush()F:close()
if _ then TEXT.show(text.keyMapSaved,1140,650,26,"sudden",.5)
else TEXT.show(text.keyMapSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
function File.loadVK()
local F=files.VK
if F:open("r")then
local s=loadstring(F:read())
F:close()
if s then
setfenv(s,{})
addToTable(s(),VK_org)
end
end
end
function File.saveVK()
local F=files.VK
F:open("w")
local _,mes=F:write(dumpTable(VK_org))
F:flush()F:close()
if _ then TEXT.show(text.VKSaved,1140,650,26,"sudden",.5)
else TEXT.show(text.VKSavingError..(mes or"unknown error"),1140,650,20,"sudden",.5)
end
end
return File

40
Zframework/img.lua Normal file
View File

@@ -0,0 +1,40 @@
local IMG={
batteryImage="/mess/power.png",
titleImage="mess/title.png",
coloredTitleImage="mess/title_colored.png",
dialCircle="mess/dialCircle.png",
dialNeedle="mess/dialNeedle.png",
badgeIcon="mess/badge.png",
spinCenter="mess/spinCenter.png",
ctrlSpeedLimit="mess/ctrlSpeedLimit.png",
speedLimit="mess/speedLimit.png",
pay1="mess/pay1.png",
pay2="mess/pay2.png",
miyaCH="miya/ch.png",
miyaF1="miya/f1.png",
miyaF2="miya/f2.png",
miyaF3="miya/f3.png",
miyaF4="miya/f4.png",
electric="mess/electric.png",
}
local list={}
local count=0
for k,v in next,IMG do
count=count+1
list[count]=k
end
function IMG.getCount()
return count
end
function IMG.loadOne(_)
local N=list[_]
IMG[N]=love.graphics.newImage("/image/"..IMG[N])
end
function IMG.loadAll()
for i=1,count do
IMG.loadOne(i)
end
end
return IMG

1081
Zframework/init.lua Normal file

File diff suppressed because it is too large Load Diff

1762
Zframework/languages.lua Normal file

File diff suppressed because it is too large Load Diff

89
Zframework/light.lua Normal file
View File

@@ -0,0 +1,89 @@
--LIGHT MODULE(Optimized by MrZ,Original on github/love2d community/simple-love-lights)
--Heavily based on mattdesl's libGDX implementation:
--https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows
local gc=love.graphics
local C=gc.clear
local shadowMapShader=gc.newShader("shader/shadowMap.glsl")--Shader for caculating the 1D shadow map.
local lightRenderShader=gc.newShader("shader/lightRender.glsl")--Shader for rendering blurred lights and shadows.
local Lights={}--Lightsource objects
local function move(L,x,y)
L.x,L.y=x,y
end
local function setPow(L,pow)
L.size=pow
end
local function destroy(L)
L.blackCanvas:release()
L.shadowCanvas:release()
L.renderCanvas:release()
end
local function draw(L)
--Initialization
local r,g,b,a=love.graphics.getColor()
gc.setCanvas(L.blackCanvas)C()
gc.setCanvas(L.shadowCanvas)C()
gc.setCanvas(L.renderCanvas)C()
lightRenderShader:send("xresolution",L.size);
shadowMapShader:send("yresolution",L.size);
--get up-left of light
local X=L.x-L.size*.5
local Y=L.y-L.size*.5
--Render solid
gc.translate(-X,-Y)
L.blackCanvas:renderTo(L.blackFn)
gc.translate(X,Y)
--Render shade canvas by solid
gc.setShader(shadowMapShader)
gc.setCanvas(L.shadowCanvas)
gc.draw(L.blackCanvas)
--Render light canvas by shade
gc.setShader(lightRenderShader)
gc.setCanvas(L.renderCanvas)
gc.draw(L.shadowCanvas,0,0,0,1,L.size)
--Ready to final render
gc.setShader()gc.setCanvas()gc.setBlendMode("add")
--Render to screes
gc.setColor(r,g,b,a)
gc.draw(L.renderCanvas,X,Y+L.size,0,1,-1)
--Reset
gc.setBlendMode("alpha")
end
local LIGHT={}
function LIGHT.draw()
for i=1,#Lights do
Lights[i]:draw()
end
end
function LIGHT.clear(L)
for i=#Lights,1,-1 do
Lights[i]:destroy()
Lights[i]=nil
end
end
function LIGHT.add(x,y,R,F)
local id=#Lights+1
Lights[id]={
--Methods
id=id,
x=x,y=y,size=R,
blackCanvas=gc.newCanvas(R,R),--solid canvas
shadowCanvas=gc.newCanvas(R,1),--1D vis-depth canvas
renderCanvas=gc.newCanvas(R,R),--light canvas
blackFn=F,--solid draw funcion
move=move,
setPow=setPow,
draw=draw,
destroy=destroy,
}
end
return LIGHT

760
Zframework/paint.lua Normal file
View File

@@ -0,0 +1,760 @@
local gc=love.graphics
local setFont=setFont
local int,ceil,rnd,abs=math.floor,math.ceil,math.random,math.abs
local max,min,sin,cos=math.max,math.min,math.sin,math.cos
local format=string.format
local Timer=love.timer.getTime
local mStr=mStr
local scr=scr
local scs=require("parts/spinCenters")
local modeRankColor={
color.bronze, --Rank1
color.lightGrey, --Rank2
color.lightYellow, --Rank3
color.lightPurple, --Rank4
color.lightCyan, --Rank5
color.purple, --Special
}
local rankString={
"D","C","B","A","S",
}
local miniTitle_rect={
{2,0,5,1},{4,1,1,6},
{9,0,4,1},{9,3,4,1},{9,6,4,1},{8,0,1,7},
{15,0,3,1},{15,6,3,1},{14,0,1,7},
{19,0,1,7},{23,0,1,7},{20,3,3,1},
{0,8,1,6},{6,8,1,6},{1,9,1,1},{2,10,1,1},{3,11,1,1},{4,10,1,1},{5,9,1,1},
{8,8,5,1},{8,13,5,1},{10,9,1,4},
{14,8,1,6},{19,8,1,6},{15,9,1,1},{16,10,1,1},{17,11,1,1},{18,12,1,1},
{21,8,5,1},{21,13,5,1},{21,9,1,4},{25,9,1,4},
}
local function stencil_miniTitle()
for i=1,#miniTitle_rect do
local a,b,c,d=unpack(miniTitle_rect[i])
gc.rectangle("fill",250+a*30,150+b*30,c*30,d*30)
end
end
FX_attack={}--Attack beam
FX_badge={}--Badge thrown
local function drawAtkPointer(x,y)
local t=sin(Timer()*20)
gc.setColor(.2,.7+t*.2,1,.6+t*.4)
gc.circle("fill",x,y,25,6)
local a=Timer()*3%1*.8
gc.setColor(0,.6,1,.8-a)
gc.circle("line",x,y,30*(1+a),6)
end
local function VirtualkeyPreview()
if setting.VKSwitch then
for i=1,#VK_org do
local B=VK_org[i]
if B.ava then
local c=sceneTemp.sel==i and .6 or 1
gc.setColor(c,1,c,setting.VKAlpha*.1)
gc.setLineWidth(B.r*.07)
gc.circle("line",B.x,B.y,B.r,10)
if setting.VKIcon then gc.draw(VKIcon[i],B.x,B.y,nil,B.r*.025,nil,18,18)end
end
end
end
end
local function drawVirtualkey()
local V=virtualkey
local a=setting.VKAlpha*.1
local _
if setting.VKIcon then
for i=1,#V do
if V[i].ava then
local B=V[i]
gc.setColor(1,1,1,a)
gc.setLineWidth(B.r*.07)
gc.circle("line",B.x,B.y,B.r,10)--Button outline
_=V[i].pressTime
gc.draw(VKIcon[i],B.x,B.y,nil,B.r*.026+_*.08,nil,18,18)--icon
if _>0 then
gc.setColor(1,1,1,a*_*.08)
gc.circle("fill",B.x,B.y,B.r*.94,10)--Glow
gc.circle("line",B.x,B.y,B.r*(1.4-_*.04),10)--Ripple
end
end
end
else
for i=1,#V do
if V[i].ava then
local B=V[i]
gc.setColor(1,1,1,a)
gc.setLineWidth(B.r*.07)
gc.circle("line",B.x,B.y,B.r,10)
_=V[i].pressTime
if _>0 then
gc.setColor(1,1,1,a*_*.08)
gc.circle("fill",B.x,B.y,B.r*.94,10)
gc.circle("line",B.x,B.y,B.r*(1.4-_*.04),10)
end
end
end
end
end
local Pnt={}
function Pnt.load()
local S=sceneTemp
gc.setLineWidth(4)
gc.setColor(1,1,1,.5)
gc.rectangle("fill",300,330,S.cur/S.tar*680,60,5)
gc.setColor(1,1,1)
gc.rectangle("line",300,330,680,60,5)
setFont(35)
gc.print(text.load[S.phase],340,335)
if S.phase~=0 then
gc.printf(S.cur.."/"..S.tar,795,335,150,"right")
end
setFont(25)
mStr(S.tip,640,400)
end
function Pnt.intro()
local T=sceneTemp
gc.stencil(stencil_miniTitle,"replace",1)
gc.setStencilTest("equal",1)
gc.setColor(1,1,1,min(T,80)*.005)
gc.push("transform")
gc.translate(250,150)
gc.scale(30)
gc.rectangle("fill",0,0,26,14)
gc.pop()
gc.setColor(1,1,1,.06)
for i=41,5,-2 do
gc.setLineWidth(i)
gc.line(200+(T-80)*25,130,(T-80)*25,590)
end
gc.setStencilTest()
if T>=80 then
gc.setColor(1,1,1,.5+sin((T-95)/30*3.142)*.5)
mText(drawableText.anykey,640,615+sin(Timer()*3)*5)
end
end
function Pnt.main()
gc.setColor(1,1,1)
gc.draw(IMG.coloredTitleImage,60,30,nil,1.3)
setFont(30)
gc.print(gameVersion,70,125)
gc.print(system,610,100)
players[1]:draw()
end
function Pnt.mode()
local _
local cam=mapCam
gc.push("transform")
gc.translate(640,360)
gc.scale(cam.zoomK)
gc.translate(-cam.x1,-cam.y1)
gc.scale(cam.k1)
local MM=Modes
local R=modeRanks
local sel=cam.sel
setFont(30)
for _=1,#MM do
local M=MM[_]
if R[_]then
gc.setLineWidth(8)
gc.setColor(1,1,1,.2)
for _=1,#M.unlock do
local m=M.unlock[_]
m=MM[m]
gc.line(M.x,M.y,m.x,m.y)
end
local S=M.size
local d=((M.x-(cam.x1+(sel and -180 or 0))/cam.k1)^2+(M.y-cam.y1/cam.k1)^2)^.55
if d<500 then S=S*(1.25-d*0.0005) end
local c=modeRankColor[modeRanks[M.id]]
if c then
gc.setColor(c)
else
c=.5+sin(Timer()*6.26-_)*.2
S=S*(.9+c*.4)
gc.setColor(c,c,c)
end
if M.shape==1 then--Rectangle
gc.rectangle("fill",M.x-S,M.y-S,2*S,2*S)
if sel==_ then
gc.setColor(1,1,1)
gc.setLineWidth(10)
gc.rectangle("line",M.x-S+5,M.y-S+5,2*S-10,2*S-10)
end
elseif M.shape==2 then--diamond
gc.circle("fill",M.x,M.y,S+5,4)
if sel==_ then
gc.setColor(1,1,1)
gc.setLineWidth(10)
gc.circle("line",M.x,M.y,S+5,4)
end
elseif M.shape==3 then--Octagon
gc.circle("fill",M.x,M.y,S,8)
if sel==_ then
gc.setColor(1,1,1)
gc.setLineWidth(10)
gc.circle("line",M.x,M.y,S,8)
end
end
_=drawableText[rankString[modeRanks[M.id]]]
if _ then
local dx,dy=6.26*sin(Timer()*0.626+M.id),6.6*sin(Timer()+M.id)
gc.setColor(0,0,0,.26)
mDraw(_,M.x+dx*1.5,M.y+dy*1.5)
end
--[[
if M.icon then
local i=M.icon
local l=i:getWidth()*.5
local k=S/l*.8
gc.setColor(0,0,0,2)
gc.draw(i,M.x-1,M.y-1,nil,k,nil,l,l)
gc.draw(i,M.x-1,M.y+1,nil,k,nil,l,l)
gc.draw(i,M.x+1,M.y-1,nil,k,nil,l,l)
gc.draw(i,M.x+1,M.y+1,nil,k,nil,l,l)
gc.setColor(1,1,1)
gc.draw(i,M.x,M.y,nil,k,nil,l,l)
end
]]
end
end
gc.pop()
if sel then
local M=MM[sel]
local lang=setting.lang
gc.setColor(.7,.7,.7,.5)
gc.rectangle("fill",920,0,360,720)--Info board
gc.setColor(M.color)
setFont(40)mStr(text.modes[sel][1],1100,5)
setFont(30)mStr(text.modes[sel][2],1100,50)
gc.setColor(1,1,1)
setFont(28)gc.printf(text.modes[sel][3],920,110,360,"center")
if M.slowMark then
gc.draw(IMG.ctrlSpeedLimit,1230,50,nil,.4)
end
if M.score then
mText(drawableText.highScore,1100,240)
gc.setColor(.4,.4,.4,.8)
gc.rectangle("fill",940,290,320,280)--Highscore board
local L=M.records
gc.setColor(1,1,1)
if L[1]then
for i=1,#L do
local t=M.scoreDisp(L[i])
local s=#t
local dy
if s<15 then dy=0
elseif s<25 then dy=2
else dy=4
end
setFont(int(26-s*.4))
gc.print(t,955,275+dy+25*i)
setFont(10)
_=L[i].date
if _ then gc.print(_,1155,284+25*i)end
end
else
mText(drawableText.noScore,1100,370)
end
end
end
if cam.keyCtrl then
gc.setColor(1,1,1)
gc.draw(mapCross,460-20,360-20)
end
end
function Pnt.music()
gc.setColor(1,1,1,.3+sin(Timer()*5)*.2)
gc.rectangle("fill",45,98+30*sceneTemp,250,30)
gc.setColor(.7,.7,.7)
gc.draw(drawableText.musicRoom,20,20)
gc.setColor(1,1,1)
gc.draw(drawableText.musicRoom,22,23)
gc.draw(drawableText.nowPlaying,490,390)
setFont(30)
for i=1,BGM.len do
gc.print(BGM.list[i],50,90+30*i)
end
gc.draw(IMG.titleImage,640,310,nil,1.5,nil,206,35)
if BGM.nowPlay then
setFont(45)
gc.setColor(sin(Timer()*.5)*.2+.8,sin(Timer()*.7)*.2+.8,sin(Timer())*.2+.8)
mStr(BGM.nowPlay,630,460)
local t=-Timer()%2.3/2
if t<1 then
gc.setColor(1,1,1,t)
gc.draw(IMG.coloredTitleImage,640,310,nil,1.5+.1-.1*t,1.5+.3-.3*t,206,35)
end
end
end
function Pnt.custom()
gc.setColor(1,1,1,.3+sin(Timer()*8)*.2)
gc.rectangle("fill",25,95+40*sceneTemp,480,40)
gc.setColor(.7,.7,.7)gc.draw(drawableText.custom,20,20)
gc.setColor(1,1,1)gc.draw(drawableText.custom,22,23)
setFont(35)
for i=1,#customID do
local k=customID[i]
local y=90+40*i
gc.printf(text.customOption[k],15,y,320,"right")
if text.customVal[k]then
gc.print(text.customVal[k][customSel[i]],335,y)
else
gc.print(customRange[k][customSel[i]],335,y)
end
end
end
function Pnt.draw()
local sx,sy=sceneTemp.x,sceneTemp.y
gc.translate(200,60)
gc.setColor(1,1,1,.2)
gc.setLineWidth(1)
for x=1,9 do gc.line(30*x,0,30*x,600)end
for y=0,19 do gc.line(0,30*y,300,30*y)end
gc.setColor(1,1,1)
gc.setLineWidth(3)
gc.rectangle("line",-2,-2,304,604)
gc.setLineWidth(2)
local cross=puzzleMark[-1]
for y=1,20 do for x=1,10 do
local B=preField[y][x]
if B>0 then
gc.draw(blockSkin[B],30*x-30,600-30*y)
elseif B==-1 and not sceneTemp.demo then
gc.draw(cross,30*x-30,600-30*y)
end
end end
if sx and sy then
gc.setLineWidth(2)
gc.rectangle("line",30*sx-30,600-30*sy,30,30)
end
gc.translate(-200,-60)
local pen=sceneTemp.pen
if pen>0 then
gc.setLineWidth(13)
gc.setColor(SKIN.libColor[pen])
gc.rectangle("line",565,460,70,70)
elseif pen==-1 then
gc.setLineWidth(5)
gc.setColor(.9,.9,.9)
gc.line(575,470,625,520)
gc.line(575,520,625,470)
end
if sceneTemp.sure>0 then
gc.setColor(1,1,1,sceneTemp.sure*.02)
gc.draw(drawableText.question,1040,430)
end
setFont(40)
local _
for i=1,7 do
_=setting.skin[i]
gc.setColor(SKIN.libColor[_])
mStr(text.block[i],500+65*_,65)
end
end
function Pnt.play()
for p=1,#players do
players[p]:draw()
end
gc.setLineWidth(5)
for i=1,#FX_attack do
local A=FX_attack[i]
gc.push("transform")
local a=(A.t<10 and A.t*.05 or A.t>50 and 6-A.t*.1 or 1)*A.a
gc.setColor(A.r,A.g,A.b,a*.5)
gc.circle("line",0,0,A.rad,A.corner)
local L=A.drag
local len=#L
for i=1,len,2 do
gc.setColor(A.r,A.g,A.b,.4*a*i/len)
gc.translate(L[i],L[i+1])
gc.rotate(A.t*.1)
gc.circle("fill",0,0,A.rad,A.corner)
gc.rotate(-A.t*.1)
gc.translate(-L[i],-L[i+1])
end
gc.setColor(A.r,A.g,A.b,a)
gc.translate(A.x,A.y)
gc.rotate(A.t*.1)
gc.circle("fill",0,0,A.rad,A.corner)
gc.pop()
end--FX animation
gc.setColor(1,1,1)
if setting.VKSwitch then drawVirtualkey()end
if modeEnv.royaleMode then
for i=1,#FX_badge do
local b=FX_badge[i]
gc.setColor(1,1,1,b.t<10 and b.t*.1 or b.t<50 and 1 or(60-b.t)*.1)
if b.t<10 then
gc.draw(IMG.badgeIcon,b[1]-14,b[2]-14)
elseif b.t<50 then
local t=((b.t-10)*.025)t=(3-2*t)*t*t
gc.draw(IMG.badgeIcon,b[1]*(1-t)+b[3]*t-14,b[2]*(1-t)+b[4]*t-14)
else
gc.draw(IMG.badgeIcon,b[3]-14,b[4]-14)
end
end
local P=players[1]
gc.setLineWidth(5)
gc.setColor(.8,1,0,.2)
for i=1,#P.atker do
local p=P.atker[i]
gc.line(p.centerX,p.centerY,P.x+300*P.size,P.y+670*P.size)
end
if P.atkMode~=4 then
if P.atking then drawAtkPointer(P.atking.centerX,P.atking.centerY)end
else
for i=1,#P.atker do
local p=P.atker[i]
drawAtkPointer(p.centerX,p.centerY)
end
end
end
gc.push("transform")
gc.origin()
if restartCount>0 then
gc.setColor(0,0,0,restartCount*.05)
gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi)
end
if game.warnLVL>0 then
gc.setColor(0,0,0,0)
SHADER.warning:send("level",game.warnLVL)
gc.setShader(SHADER.warning)
gc.rectangle("fill",0,0,scr.w,scr.h)
gc.setShader()
end
gc.pop()
end
local hexList={1,0,.5,1.732*.5,-.5,1.732*.5}for i=1,6 do hexList[i]=hexList[i]*150 end
local textPos={90,131,-90,131,-200,-25,-90,-181,90,-181,200,-25}
local dataPos={90,143,-90,143,-200,-13,-90,-169,90,-169,200,-13}
function Pnt.pause()
local S=sceneTemp
local T=S.timer*.02
if T<1 or game.result then Pnt.play()end
--Dark BG
local _=T
if game.result then _=_*.7 end
gc.setColor(.15,.15,.15,_)
gc.push("transform")
gc.origin()
gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi)
gc.pop()
--Pause Info
setFont(25)
if game.pauseCount>0 then
gc.setColor(1,.4,.4,T)
gc.print(text.pauseCount..":["..game.pauseCount.."] "..format("%.2f",game.pauseTime).."s",70,100)
end
gc.setColor(1,1,1,T)
--Mode Info
_=drawableText.modeName
gc.draw(_,40,180)
gc.draw(drawableText.levelName,60+_:getWidth(),180)
--Result Text
setFont(35)
mText(game.result and drawableText[game.result]or drawableText.pause,640,50-10*(5-sceneTemp.timer*.1)^1.5)
--Infos
if frame>180 then
_=S.list
setFont(26)
for i=1,10 do
gc.print(text.pauseStat[i],40,210+40*i)
gc.printf(_[i],245,210+40*i,250,"right")
end
end
--Radar Chart
if T>.5 and frame>180 then
T=T*2-1
gc.setLineWidth(2)
gc.push("transform")
gc.translate(1026,400)
--axes
gc.setColor(1,1,1,T)
for i=1,3 do
local x,y=hexList[2*i-1],hexList[2*i]
gc.line(-x,-y,x,y)
end
local C
_=Timer()%6.2832
if _>3.1416 then
gc.setColor(1,1,1,-T*sin(_))
setFont(35)
C,_=text.radar,textPos
else
gc.setColor(1,1,1,T*sin(_))
setFont(18)
C,_=S.radar,dataPos
end
for i=1,6 do
mStr(C[i],_[2*i-1],_[2*i])
end
gc.scale((3-2*T)*T)
gc.setColor(1,1,1,T*(.5+.3*sin(Timer()*6.26)))gc.polygon("line",S.standard)
_=S.color
gc.setColor(_[1],_[2],_[3],T)
_=S.val
for i=1,9,2 do
gc.polygon("fill",0,0,_[i],_[i+1],_[i+2],_[i+3])
end
gc.polygon("fill",0,0,_[11],_[12],_[1],_[2])
gc.setColor(1,1,1,T)gc.polygon("line",S.val)
gc.pop()
end
end
function Pnt.setting_game()
gc.setColor(1,1,1)
mText(drawableText.setting_game,640,15)
gc.draw(blockSkin[int(Timer()*2)%11+1],720,540,Timer()%6.28319,2,nil,15,15)
end
function Pnt.setting_video()
gc.setColor(1,1,1)
mText(drawableText.setting_video,640,15)
end
function Pnt.setting_sound()
gc.setColor(1,1,1,.8)
mText(drawableText.setting_sound,640,15)
local t=Timer()
local _=sceneTemp.jump
local x,y=800,340+10*sin(t*.5)+(_-10)*_*.3
gc.translate(x,y)
gc.draw(IMG.miyaCH,0,0)
gc.setColor(1,1,1,.7)
gc.draw(IMG.miyaF1,4,47+4*sin(t*.9))
gc.draw(IMG.miyaF2,42,107+5*sin(t))
gc.draw(IMG.miyaF3,93,126+3*sin(t*.7))
gc.draw(IMG.miyaF4,129,98+3*sin(t*.7))
gc.translate(-x,-y)
end
local function timeConv(t)
return t.."F "..int(t*16.67).."ms"
end
function Pnt.setting_control()
--Testing grid line
gc.setLineWidth(4)
gc.setColor(1,1,1,.4)
gc.line(550,540,950,540)
gc.line(550,580,950,580)
gc.line(550,620,950,620)
for x=590,910,40 do
gc.line(x,530,x,630)
end
gc.setColor(1,1,1)
gc.line(550,530,550,630)
gc.line(950,530,950,630)
--Texts
gc.draw(drawableText.setting_control,80,50)
setFont(50)
gc.printf(text.preview,320,540,200,"right")
--Floating number
setFont(30)
local _=setting
mStr(timeConv(_.das),226+35*_.das,145)
mStr(timeConv(_.arr),226+35*_.arr,235)
mStr(timeConv(_.sddas),226+35*_.sddas,325)
mStr(timeConv(_.sdarr),226+35*_.sdarr,415)
--Testing O mino
_=blockSkin[setting.skin[6]]
local x=550+40*sceneTemp.pos
gc.draw(_,x,540,nil,40/30)
gc.draw(_,x,580,nil,40/30)
gc.draw(_,x+40,540,nil,40/30)
gc.draw(_,x+40,580,nil,40/30)
end
function Pnt.setting_key()
local s=sceneTemp
local a=.3+sin(Timer()*15)*.1
if s.kS then gc.setColor(1,.3,.3,a)else gc.setColor(1,.7,.7,a)end
gc.rectangle("fill",
s.kb<11 and 240 or 840,
45*s.kb+20-450*int(s.kb/11),
200,45
)
if s.jS then gc.setColor(.3,.3,.1,a)else gc.setColor(.7,.7,1,a)end
gc.rectangle("fill",
s.js<11 and 440 or 1040,
45*s.js+20-450*int(s.js/11),
200,45
)
--Selection rect
gc.setColor(1,.3,.3)
mText(drawableText.keyboard,340,30)
mText(drawableText.keyboard,940,30)
gc.setColor(.3,.3,1)
mText(drawableText.joystick,540,30)
mText(drawableText.joystick,1140,30)
gc.setColor(1,1,1)
setFont(26)
local b1,b2=keyMap[s.board],keyMap[s.board+2]
for N=1,20 do
if N<11 then
gc.printf(text.acts[N],47,45*N+22,180,"right")
mStr(b1[N],340,45*N+22)
mStr(b2[N],540,45*N+22)
else
gc.printf(text.acts[N],647,45*N-428,180,"right")
mStr(b1[N],940,45*N-428)
mStr(b2[N],1040,45*N-428)
end
end
gc.setLineWidth(2)
for x=40,1240,200 do
gc.line(x,65,x,515)
end
for y=65,515,45 do
gc.line(40,y,1240,y)
end
setFont(35)
gc.print(text.page..s.board,280,590)
gc.draw(drawableText.ctrlSetHelp,50,650)
end
function Pnt.setting_skin()
gc.setColor(1,1,1)
for N=1,7 do
local face=setting.face[N]
local B=blocks[N][face]
local x,y=-25+140*N-scs[N][face][2]*30,325+scs[N][face][1]*30
local col=#B[1]
for i=1,#B do for j=1,col do
if B[i][j]then
gc.draw(blockSkin[setting.skin[N]],x+30*j,y-30*i)
end
end end
gc.circle("fill",-10+140*N,340,sin(Timer()*10)+5)
end
for i=1,6 do
gc.draw(blockSkin[11+i],1110,100+60*i,nil,2)
end
gc.draw(drawableText.setting_skin,80,50)
end
function Pnt.setting_touch()
gc.setColor(1,1,1)
gc.setLineWidth(7)gc.rectangle("line",340,15,600,690)
gc.setLineWidth(3)gc.rectangle("line",490,85,300,600)
VirtualkeyPreview()
local d=snapLevelValue[sceneTemp.snap]
if d>=10 then
gc.setLineWidth(3)
gc.setColor(1,1,1,sin(Timer()*4)*.1+.1)
for i=1,1280/d-1 do
gc.line(d*i,0,d*i,720)
end
for i=1,720/d-1 do
gc.line(0,d*i,1280,d*i)
end
end
end
function Pnt.setting_trackSetting()
gc.setColor(1,1,1)
mText(drawableText.VKTchW,140+50*setting.VKTchW,260)
mText(drawableText.VKOrgW,140+50*setting.VKTchW+50*setting.VKCurW,320)
mText(drawableText.VKCurW,640+50*setting.VKCurW,380)
end
function Pnt.help()
setFont(20)
gc.setColor(1,1,1)
for i=1,#text.help do
gc.printf(text.help[i],150,35*i+40,1000,"center")
end
setFont(19)
gc.print(text.used,30,330)
gc.draw(IMG.titleImage,280,610,.1,1+.05*sin(Timer()*2.6),nil,206,35)
gc.setLineWidth(3)
gc.rectangle("line",18,18,263,263)
gc.rectangle("line",1012,18,250,250)
gc.draw(IMG.pay1,20,20)
gc.draw(IMG.pay2,1014,20)
setFont(20)
mStr(text.group,640,490)
gc.setColor(1,1,1,sin(Timer()*20)*.3+.6)
setFont(30)
mStr(text.support,150+sin(Timer()*4)*20,283)
mStr(text.support,1138-sin(Timer()*4)*20,270)
end
function Pnt.staff()
local L=text.staff
local t=sceneTemp.time
if t>0 then
setFont(40)
for i=1,#L do
mStr(L[i],640,800+80*i-t*40)
end
mDraw(IMG.coloredTitleImage,640,800-t*40,nil,2)
mDraw(IMG.coloredTitleImage,640,2160-t*40,nil,2)
else
setFont(60)
mStr("Don't tell this to anyone.",640,-100-t*40)
end
end
function Pnt.stat()
local chart=sceneTemp.chart
setFont(24)
local _,__=SKIN.libColor,setting.skin
local A,B=chart.A1,chart.A2
for x=1,7 do
gc.setColor(_[__[x]])
mStr(text.block[x],80*x,40)
mStr(text.block[x],80*x,280)
for y=1,4 do
mStr(A[x][y],80*x,40+40*y)
mStr(B[x][y],80*x,280+40*y)
end
mStr(chart.Y1[x],80*x,240)
mStr(chart.Y2[x],80*x,480)
end
gc.setColor(1,1,1)
A,B=chart.X1,chart.X2
mStr(text.stat.spin,650,45)
mStr(text.stat.clear,650,285)
for y=1,4 do
mStr(A[y],650,40+40*y)
mStr(B[y],650,280+40*y)
end
setFont(22)
for i=1,11 do
gc.print(sceneTemp.item[i],740,40*i+10)
end
gc.setLineWidth(4)
for x=1,8 do
x=80*x-40
gc.line(x,80,x,240)
gc.line(x,320,x,480)
end
for y=2,6 do
gc.line(40,40*y,600,40*y)
gc.line(40,240+40*y,600,240+40*y)
end
gc.draw(IMG.titleImage,260,615,.2+.04*sin(Timer()*3),nil,nil,206,35)
end
function Pnt.history()
gc.setColor(.2,.2,.2,.7)
gc.rectangle("fill",30,45,1000,632)
gc.setColor(1,1,1)
gc.setLineWidth(4)
gc.rectangle("line",30,45,1000,632)
setFont(20)
local _=sceneTemp
gc.print(_[1][_[2]],40,50)
end
return Pnt

341
Zframework/scene.lua Normal file
View File

@@ -0,0 +1,341 @@
local gc=love.graphics
local int,log=math.floor,math.log
local sin,cos=math.sin,math.cos
local max,format=math.max,string.format
local scr=scr
local SCN={
cur="load",--Current scene
swapping=false,--ifSwapping
swap={
tar=nil, --Swapping target
style=nil, --Swapping style
mid=nil, --Loading point
time=nil, --Full swap time
draw=nil, --Swap draw func
},
seq={"quit","slowFade"},--Back sequence
}--scene datas,returned
local sceneInit={}
sceneInit.quit=love.event.quit
function sceneInit.load()
sceneTemp={
phase=1,--Loading stage
cur=1,--Counter
tar=#VOC.name,--Loading bar lenth(current)
tip=require("parts/getTip"),
list={
#VOC.name,
#BGM.list,
#SFX.list,
IMG.getCount(),
#Modes,
1,
},
skip=false,--if skipping
}
end
function sceneInit.intro()
BG.set("space")
sceneTemp=0--animation timer
BGM.play("blank")
end
function sceneInit.main()
BG.set("space")
BGM.play("blank")
destroyPlayers()
modeEnv={}
if not players[1]then
PLY.newDemoPlayer(1,900,35,1.1)
end--create demo player
end
function sceneInit.music()
if BGM.nowPlay then
for i=1,BGM.len do
if BGM.list[i]==BGM.nowPlay then
sceneTemp=i--music select
return
end
end
else
sceneTemp=1
end
end
function sceneInit.mode(org)
BG.set("space")
BGM.play("blank")
destroyPlayers()
local cam=mapCam
cam.zoomK=org=="main"and 5 or 1
if cam.sel then
local M=Modes[cam.sel]
cam.x,cam.y=M.x*cam.k+180,M.y*cam.k
cam.x1,cam.y1=cam.x,cam.y
end
end
function sceneInit.custom()
sceneTemp=1--option select
destroyPlayers()
BG.set(customRange.bg[customSel[12]])
BGM.play(customRange.bgm[customSel[13]])
end
function sceneInit.draw()
BG.set("space")
sceneTemp={
sure=0,
pen=1,
x=1,y=1,
demo=false,
}
end
function sceneInit.play()
love.keyboard.setKeyRepeat(false)
restartCount=0
if needResetGameData then
resetGameData()
needResetGameData=nil
end
BG.set(modeEnv.bg)
end
function sceneInit.pause(org)
if
org=="setting_game"or
org=="setting_video"or
org=="setting_sound"
then
TEXT.show(text.needRestart,640,440,50,"fly",.6)
end
local S=players[1].stat
sceneTemp={
timer=org=="play"and 0 or 50,
list={
toTime(S.time),
S.key.."/"..S.rotate.."/"..S.hold,
format("%d %.2fPPS",S.piece,S.piece/S.time),
format("%d(%d) %.2fLPM",S.row,S.dig,S.row/S.time*60),
format("%d(%d)",S.atk,S.digatk),
format("%d(%d-%d)",S.pend,S.recv,S.recv-S.pend),
format("%d/%d/%d/%d",S.clear_S[1],S.clear_S[2],S.clear_S[3],S.clear_S[4]),
format("(%d)/%d/%d/%d",S.spin_S[1],S.spin_S[2],S.spin_S[3],S.spin_S[4]),
format("%d(+%d)/%d(%d)",S.b2b,S.b3b,S.pc,S.hpc),
format("%d[%.2f%%]",S.extraPiece,100*max(1-S.extraRate/S.piece,0)),
},
--from right-down, 60 degree each
radar={
(S.off+S.dig)/S.time*60,--DefPM
(S.off)/S.time*60, --OffPM
S.atk/S.time*60, --AtkPM
S.send/S.time*60, --SendPM
S.piece/S.time*24, --LinePM
S.dig/S.time*60, --DigPM
},
val={1/80,1/40,1/60,1/60,1/100,1/40},
timing=org=="play",
}
local _=sceneTemp
local A,B=_.radar,_.val
for i=1,6 do
B[i]=B[i]*A[i]if B[i]>1.26 then B[i]=1.26+(B[i]-1.26)*.26 end
end--normalize vals
for i=1,6 do
A[i]=format("%.2f",A[i])..text.radarData[i]
end
local f=1
for i=1,6 do
if B[i]>.5 then f=2 end
if B[i]>1 then f=3 break end
end
if f==1 then _.color,f={.4,.9,.5},1.25 --Vegetable
elseif f==2 then _.color,f={.4,.7,.9},1 --Normal
elseif f==3 then _.color,f={1,.3,.3},.626 --Diao
end
A={
120*.5*f, 120*3^.5*.5*f,
120*-.5*f, 120*3^.5*.5*f,
120*-1*f, 120*0*f,
120*-.5*f, 120*-3^.5*.5*f,
120*.5*f, 120*-3^.5*.5*f,
120*1*f, 120*0*f,
}
_.scale=f
_.standard=A
for i=6,1,-1 do
B[2*i-1],B[2*i]=B[i]*A[2*i-1],B[i]*A[2*i]
end
_.val=B
end
function sceneInit.setting_game()
BG.set("space")
end
function sceneInit.setting_video()
BG.set("space")
end
function sceneInit.setting_sound()
sceneTemp={last=0,jump=0}--last sound time,animation count(10 to 0)
BG.set("space")
end
function sceneInit.setting_control()
sceneTemp={
das=setting.das,
arr=setting.arr,
pos=0,
dir=1,
wait=30,
}
BG.set("strap")
end
function sceneInit.setting_key()
sceneTemp={
board=1,
kb=1,js=1,
kS=false,jS=false,
}
end
function sceneInit.setting_touch()
BG.set("game2")
sceneTemp={
default=1,
snap=1,
sel=nil,
}
end
function sceneInit.setting_touchSwitch()
BG.set("matrix")
end
function sceneInit.help()
sceneTemp={
pw=0,
}
BG.set("space")
end
function sceneInit.staff()
sceneTemp={
time=0,
v=1,
ct=0,
}
BG.set("space")
end
function sceneInit.stat()
local S=stat
sceneTemp={
chart={
A1=S.spin,A2=S.clear,
X1=S.spin_S,X2=S.clear_S,
Y1=S.spin_B,Y2=S.clear_B,
},
item={
S.run,
S.game,
toTime(S.time),
S.key.." "..S.rotate.." "..S.hold,
S.piece.." "..S.row.." "..int(S.atk),
S.recv.." "..S.off.." "..S.pend,
S.dig.." "..int(S.digatk),
format("%.2f %.2f",S.atk/S.row,S.digatk/S.dig),
format("%d/%.3f%%",S.extraPiece,100*max(1-S.extraRate/S.piece,0)),
S.b2b.." "..S.b3b,
S.pc.." "..S.hpc,
}
}
for i=1,11 do
sceneTemp.item[i]=text.stat[i].."\t"..sceneTemp.item[i]
end
end
function sceneInit.history()
BG.set("strap")
sceneTemp={require("parts/updateLog"),1}--scroll pos
end
function sceneInit.quit()
love.timer.sleep(.3)
love.event.quit()
end
local swap={
none={1,0,NULL},
flash={8,1,function()gc.clear(1,1,1)end},
fade={30,15,function(t)
local t=t>15 and 2-t/15 or t/15
gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi)
end},
fade_togame={120,20,function(t)
local t=t>20 and (120-t)/100 or t/20
gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi)
end},
slowFade={180,90,function(t)
local t=t>90 and 2-t/90 or t/90
gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi)
end},
}--Scene swapping animations
local backFunc={
load=love.event.quit,
pause=function()
love.keyboard.setKeyRepeat(true)
mergeStat(stat,players[1].stat)
TASK.clear("play")
end,
setting_game= function()FILE.saveSetting()end,
setting_video= function()FILE.saveSetting()end,
setting_sound= function()FILE.saveSetting()end,
setting_touch= function()FILE.saveVK()end,
setting_key= function()FILE.saveKeyMap()end,
setting_lang= function()FILE.saveSetting()end,
}
function SCN.swapUpdate()
local S=SCN.swap
S.time=S.time-1
if S.time==S.mid then
SCN.init(S.tar,SCN.cur)
SCN.cur=S.tar
WIDGET.set(Widgets[S.tar])
collectgarbage()
--Scene swapped this moment
end
if S.time==0 then
SCN.swapping=false
end
end
function SCN.init(s,org)
if sceneInit[s]then sceneInit[s](org)end
end
function SCN.push(tar,style)
if not SCN.swapping then
local m=#SCN.seq
SCN.seq[m+1]=tar or SCN.cur
SCN.seq[m+2]=style or"fade"
end
end
function SCN.pop()
local _=SCN.seq
_[#_-1]=nil
end
function SCN.swapTo(tar,style)
local S=SCN.swap
if not SCN.swapping and tar~=SCN.cur then
SCN.swapping=true
if not style then style="fade"end
S.tar=tar
S.style=style
local swap=swap[style]
S.time=swap[1]
S.mid=swap[2]
S.draw=swap[3]
end
end
function SCN.back()
if backFunc[SCN.cur] then backFunc[SCN.cur]()end
--func when scene end
local m=#SCN.seq
if m>0 then
SCN.swapTo(SCN.seq[m-1],SCN.seq[m])
SCN.seq[m],SCN.seq[m-1]=nil
--Poll&Back to preScene
end
end
return SCN

71
Zframework/sfx.lua Normal file
View File

@@ -0,0 +1,71 @@
local rem=table.remove
local SFX={}
SFX.list={
"welcome_sfx",
"click","enter",
"finesseError","finesseError_long",
--Stereo sfxs(cannot set position)
"virtualKey",
"button","swipe",
"ready","start","win","fail","collect",
"move","rotate","rotatekick","hold",
"prerotate","prehold",
"lock","drop","fall",
"reach",
"ren_1","ren_2","ren_3","ren_4","ren_5","ren_6","ren_7","ren_8","ren_9","ren_10","ren_11","ren_mega",
"clear_1","clear_2","clear_3","clear_4",
"spin_0","spin_1","spin_2","spin_3",
"emit","blip_1","blip_2",
"clear",
"error",
--Mono sfxs
}
function SFX.loadOne(_)
_,SFX.list[_]=SFX.list[_]
SFX.list[_]={love.audio.newSource("/SFX/".._..".ogg","static")}
end
function SFX.loadAll()
for i=1,#SFX.list do
SFX.loadOne(i)
end
end
function SFX.fieldPlay(s,v,P)
SFX.play(s,v,(P.curX+P.sc[2]-6.5)*.15)
end
function SFX.play(s,v,pos)
if setting.sfx==0 then return end
local S=SFX.list[s]--source list
local n=1
while S[n]:isPlaying()do
n=n+1
if not S[n]then
S[n]=S[1]:clone()
S[n]:seek(0)
break
end
end
S=S[n]--AU_SRC
if S:getChannelCount()==1 then
if pos then
pos=pos*setting.stereo*.1
S:setPosition(pos,1-pos^2,0)
else
S:setPosition(0,0,0)
end
end
S:setVolume((v or 1)*setting.sfx*.1)
S:play()
end
function SFX.reset()
for _,L in next,sfx do
for i=#v,2,-1 do
if not L[i]:isPlaying()then
rem(L,i)
end
end
end
end
return SFX

12
Zframework/shader.lua Normal file
View File

@@ -0,0 +1,12 @@
local function N(file)
return love.graphics.newShader("shader/"..file..".glsl")
end
return{
-- glow=gc.newShader("shader/glow.cs"),
alpha=N("alpha"),
warning=N("warning"),
rainbow=N("rainbow"),
strap=N("strap"),
aura=N("aura"),
}

42
Zframework/sysFX.lua Normal file
View File

@@ -0,0 +1,42 @@
local gc=love.graphics
local setColor=gc.setColor
local setWidth=gc.setLineWidth
local rect=gc.rectangle
local fx={}
local FXdraw={}
function FXdraw.ripple(S)
setWidth(6)
setColor(1,1,1,1-S.t)
local r=(10*S.t)^1.2
rect("line",S[1]-r,S[2]-r,S[3]+2*r,S[4]+2*r)
end
function FXdraw.shade(S)
setColor(S[1],S[2],S[3],1-S.t)
rect("fill",S[4],S[5],S[6],S[7],2)
end
local sysFX={}
function sysFX.update(dt)
for i=#fx,1,-1 do
local S=fx[i]
S.t=S.t+dt*S.rate
if S.t>=1 then
for i=i,#fx do
fx[i]=fx[i+1]
end
end
end
end
function sysFX.draw()
for i=1,#fx do
fx[i]:draw()
end
end
--0=ripple,x,y,w,h
--1=shade,r,g,b,x,y,w,h
function sysFX.new(type,duration,...)
fx[#fx+1]={draw=FXdraw[type],t=0,rate=1/duration,...}
end
return sysFX

65
Zframework/task.lua Normal file
View File

@@ -0,0 +1,65 @@
local rem=table.remove
local tasks={}
local TASK={}
function TASK.getCount()
return #tasks
end
function TASK.update()
for i=#tasks,1,-1 do
local T=tasks[i]
if T.code(T.data)then
rem(tasks,i)
end
end
end
function TASK.new(code,data)
tasks[#tasks+1]={
code=code,
data=data,
}
end
function TASK.changeCode(c1,c2)
for i=#tasks,1,-1 do
if tasks[i].code==c1 then
tasks[i].code=c2
end
end
end
function TASK.removeTask_code(code)
for i=#tasks,1,-1 do
if tasks[i].code==code then
rem(tasks,i)
end
end
end
function TASK.removeTask_data(data)
for i=#tasks,1,-1 do
if tasks[i].data==data then
rem(tasks,i)
end
end
end
function TASK.clear(opt)
if opt=="all"then
local i=#tasks
while i>0 do
tasks[i]=nil
i=i-1
end
elseif opt=="play"then
for i=#tasks,1,-1 do
if tasks[i].P then
rem(tasks,i)
end
end
else--Player table
for i=#tasks,1,-1 do
if tasks[i].P==opt then
rem(tasks,i)
end
end
end
end
return TASK

126
Zframework/text.lua Normal file
View File

@@ -0,0 +1,126 @@
local gc=love.graphics
local rnd=math.random
local mStr=mStr
local rem=table.remove
local texts={}
local textFX={}
function textFX.appear(t)
mStr(t.text,t.x,t.y-t.font*.7)
end
function textFX.sudden(t)
gc.setColor(1,1,1,1-t.c)
mStr(t.text,t.x,t.y-t.font*.7)
end
function textFX.fly(t)
mStr(t.text,t.x+(t.c-.5)^3*300,t.y-t.font*.7)
end
function textFX.stretch(t)
gc.push("transform")
gc.translate(t.x,t.y)
if t.c<.3 then gc.scale((.3-t.c)*1.6+1,1)end
mStr(t.text,0,-t.font*.7)
gc.pop()
end
function textFX.drive(t)
gc.push("transform")
gc.translate(t.x,t.y)
if t.c<.3 then gc.shear((.3-t.c)*2,0)end
mStr(t.text,0,-t.font*.7)
gc.pop()
end
function textFX.spin(t)
gc.push("transform")
gc.translate(t.x,t.y)
if t.c<.3 then
gc.rotate((.3-t.c)^2*4)
elseif t.c>.8 then
gc.rotate((t.c-.8)^2*-4)
end
mStr(t.text,0,-t.font*.7)
gc.pop()
end
function textFX.flicker(t)
local _,_,_,T=gc.getColor()
gc.setColor(1,1,1,T*(rnd()+.5))
mStr(t.text,t.x,t.y-t.font*.7)
end
function textFX.zoomout(t)
gc.push("transform")
local k=t.c^.5*.1+1
gc.translate(t.x,t.y)
gc.scale(k,k)
mStr(t.text,0,-t.font*.7)
gc.pop()
end
function textFX.beat(t)
gc.push("transform")
gc.translate(t.x,t.y)
if t.c<.3 then
local k=1.3-t.c^2/.3
gc.scale(k,k)
end
mStr(t.text,0,-t.font*.7)
gc.pop()
end
function textFX.mark(t)
local _,_,_,T=gc.getColor()
gc.setColor(1,1,1,T*.08)
mStr(t.text,t.x,t.y-t.font*.7)
end
local TEXT={}
function TEXT.clear()
texts={}
end
function TEXT.getText(text,x,y,font,style,spd,stop)
return{
c=0,
text=text,
x=x or 0,
y=y or 0,
font=font or 40,
spd=(spd or 1)/60,
stop=stop,
draw=textFX[style]or assert(false,"unavailable type:"..style),
}
end--another version of TEXT()
function TEXT.show(text,x,y,font,style,spd,stop)
texts[#texts+1]={
c=0, --timer
text=text, --string
x=x or 0, --x
y=y or 0, --y
font=font or 40, --font
spd=(spd or 1)/60, --timing speed(1=last 1 sec)
stop=stop, --stop time(sustained text)
draw=textFX[style]or assert(false,"unavailable type:"..style), --draw method
}
end
function TEXT.update(list)
if not list then list=texts end
for i=#list,1,-1 do
local t=list[i]
t.c=t.c+t.spd
if t.stop then
if t.c>t.stop then
t.c=t.stop
end
end
if t.c>1 then
rem(list,i)
end
end
end
function TEXT.draw(list)
if not list then list=texts end
for i=1,#list do
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)
t:draw()
end
end
return TEXT

328
Zframework/timer.lua Normal file
View File

@@ -0,0 +1,328 @@
local gc=love.graphics
local kb=love.keyboard
local Timer=love.timer.getTime
local int,abs,rnd,max,min,sin,ln=math.floor,math.abs,math.random,math.max,math.min,math.sin,math.log
local ins,rem=table.insert,table.remove
local Tmr={}
function Tmr.load()
local t=Timer()
local S=sceneTemp
repeat
if S.phase==1 then
VOC.loadOne(S.cur)
elseif S.phase==2 then
BGM.loadOne(S.cur)
elseif S.phase==3 then
SFX.loadOne(S.cur)
elseif S.phase==4 then
IMG.loadOne(S.cur)
elseif S.phase==5 then
local m=Modes[S.cur]
Modes[S.cur]=require("modes/"..m[1])
local M=Modes[S.cur]
M.saveFileName,M.id=m[1],m.id
M.x,M.y,M.size,M.shape=m.x,m.y,m.size,m.shape
M.unlock=m.unlock
M.records=FILE.loadRecord(m[1])or M.score and{}
-- M.icon=gc.newImage("image/modeIcon/"..m.icon..".png")
-- M.icon=gc.newImage("image/modeIcon/custom.png")
elseif S.phase==6 then
--------------------------Loading other little things here
SKIN.load()
stat.run=stat.run+1
--------------------------
SFX.play("welcome_sfx")
VOC.play("welcome")
else
S.cur=S.cur+1
S.tar=S.cur
if S.cur>62.6 then
SCN.swapTo("intro","none")
end
return
end
S.cur=S.cur+1
if S.cur>S.tar then
S.phase=S.phase+1
S.cur=1
S.tar=S.list[S.phase]
if not S.tar then
S.phase=0
S.tar=1
end
end
until not S.skip and Timer()-t>.01
end
function Tmr.intro()
sceneTemp=sceneTemp+1
if sceneTemp==200 then sceneTemp=80 end
end
function Tmr.main(dt)
players[1]:update(dt)
end
local function dumpTable(L)
local s="{\n"
for k,v in next,L do
local T
T=type(k)
if T=="number"then k="["..k.."]="
elseif T=="string"then k=k.."="
else assert(false,"Error data type!")
end
T=type(v)
if T=="number"then v=tostring(v)
elseif T=="string"then v="\""..v.."\""
elseif T=="table"then v=dumpTable(v)
else assert(false,"Error data type!")
end
s=s..k..v..",\n"
end
return s.."}"
end
function Tmr.mode(dt)
local cam=mapCam
local x,y,k=cam.x,cam.y,cam.k
local F
if not SCN.swapping then
if kb.isDown("up", "w")then y=y-10*k;F=true end
if kb.isDown("down","s")then y=y+10*k;F=true end
if kb.isDown("left","a")then x=x-10*k;F=true end
if kb.isDown("right","d")then x=x+10*k;F=true end
local js1=joysticks[1]
if js1 then
local k=js1:getAxis(1)
if k~="c"then
if k=="u"or k=="ul"or k=="ur"then y=y-10*k;F=true end
if k=="d"or k=="dl"or k=="dl"then y=y+10*k;F=true end
if k=="l"or k=="ul"or k=="dl"then x=x-10*k;F=true end
if k=="r"or k=="ur"or k=="dr"then x=x+10*k;F=true end
end
end
end
if F or cam.keyCtrl and(x-cam.x1)^2+(y-cam.y1)^2>2.6 then
if F then
cam.keyCtrl=true
end
local x,y=(cam.x1-180)/cam.k1,cam.y1/cam.k1
local MM,R=Modes,modeRanks
for _=1,#MM do
if R[_]then
local __
local M=MM[_]
local s=M.size
if M.shape==1 then
if x>M.x-s and x<M.x+s and y>M.y-s and y<M.y+s then __=_ end
elseif M.shape==2 then
if abs(x-M.x)+abs(y-M.y)<s then __=_ end
elseif M.shape==3 then
if(x-M.x)^2+(y-M.y)^2<s^2 then __=_ end
end
if __ and cam.sel~=__ then
cam.sel=__
SFX.play("click")
end
end
end
end
if x>1850*k then x=1850*k
elseif x<-1000*k then x=-1000*k
end
if y>500*k then y=500*k
elseif y<-1900*k then y=-1900*k
end
cam.x,cam.y=x,y
--keyboard controlling
cam.x1=cam.x1*.85+x*.15
cam.y1=cam.y1*.85+y*.15
cam.k1=cam.k1*.85+k*.15
local _=SCN.swap.tar
cam.zoomMethod=_=="play"and 1 or _=="mode"and 2
if cam.zoomMethod==1 then
if cam.sel then
local M=Modes[cam.sel]
cam.x=cam.x*.8+M.x*cam.k*.2
cam.y=cam.y*.8+M.y*cam.k*.2
end
_=cam.zoomK
if _<.8 then _=_*1.05 end
if _<1.1 then _=_*1.05 end
cam.zoomK=_*1.05
elseif cam.zoomMethod==2 then
cam.zoomK=cam.zoomK^.9
end
end
function Tmr.draw()
if sceneTemp.sure>0 then sceneTemp.sure=sceneTemp.sure-1 end
end
function Tmr.play(dt)
frame=frame+1
stat.time=stat.time+dt
local P1=players[1]
for i=#FX_attack,1,-1 do
local b=FX_attack[i]
b.t=b.t+1
if b.t>50 then
b.rad=b.rad*1.05+.1
b.x,b.y=b.x2,b.y2
elseif b.t>10 then
local t=((b.t-10)*.025)t=(3-2*t)*t*t
b.x,b.y=b.x1*(1-t)+b.x2*t,b.y1*(1-t)+b.y2*t
end
if b.t<60 then
local L=FX_attack[i].drag
if #L==4*setting.atkFX then
rem(L,1)rem(L,1)
end
ins(L,b.x)ins(L,b.y)
else
for i=i,#FX_attack do
FX_attack[i]=FX_attack[i+1]
end
end
end
for i=#FX_badge,1,-1 do
local b=FX_badge[i]
b.t=b.t+1
if b.t==60 then
rem(FX_badge,i)
end
end
local _
for i=1,#virtualkey do
_=virtualkey[i]
if _.pressTime>0 then
_.pressTime=_.pressTime-1
end
end
if frame<180 then
if frame==179 then
gameStart()
elseif frame==60 or frame==120 then
SFX.play("ready")
end
for p=1,#players do
local P=players[p]
if P.movDir~=0 then
if P.moving<P.gameEnv.das then
P.moving=P.moving+1
end
else
P.moving=0
end
end
if restartCount>0 then restartCount=restartCount-1 end
return
elseif P1.keyPressing[10]then
restartCount=restartCount+1
if restartCount>20 then
TASK.clear("play")
mergeStat(stat,P1.stat)
resetGameData()
return
end
elseif restartCount>0 then
restartCount=restartCount>2 and restartCount-2 or 0
end--Counting,include pre-das,directy RETURN,or restart counting
for p=1,#players do
local P=players[p]
P:update(dt)
end
if frame%120==0 then
if modeEnv.royaleMode then freshMostDangerous()end
if marking and rnd()<.2 then
TEXT.show(text.marking,rnd(162,scr.w-162),rnd(126,scr.h-200),40,"mark",.626)
end--mark 2s each 10s
end
if P1.alive then
if frame%26==0 and setting.warn then
local F=P1.field
local M=#F
local height=0
for x=3,8 do
for y=M,1,-1 do
if F[y][x]>0 then
if y>height then
height=y
end
break
end
end
end
game.warnLVL0=ln(height-15+P1.atkBuffer.sum*.8)
end
local M=game.warnLVL
if M<game.warnLVL0 then
M=M*.95+game.warnLVL0*.05
elseif M>0 then
M=max(M-.026,0)
end
game.warnLVL=M
elseif game.warnLVL>0 then
game.warnLVL=max(game.warnLVL-.026,0)
end
end
function Tmr.pause(dt)
if not game.result then
game.pauseTime=game.pauseTime+dt
end
if sceneTemp.timer<50 then
sceneTemp.timer=sceneTemp.timer+1
end
end
function Tmr.setting_sound()
local t=sceneTemp.jump
if t>0 then
sceneTemp.jump=t-1
end
end
function Tmr.setting_control()
local T=sceneTemp
if T.wait>0 then
T.wait=T.wait-1
if T.wait==0 then
T.pos=T.pos+T.dir
else
return
end
end
if T.das>0 then
T.das=T.das-1
if T.das==0 then
T.pos=T.pos+T.dir
end
else
T.arr=T.arr-1
if T.arr==0 then
T.pos=T.pos+T.dir
T.arr=setting.arr
elseif T.arr==-1 then
T.pos=T.dir>0 and 8 or 0
T.arr=setting.arr
end
if T.pos%8==0 then
T.dir=-T.dir
T.wait=26
T.das=setting.das
end
end
end
function Tmr.staff(dt)
local S=sceneTemp
if kb.isDown("space","return")and S.v<6.26 then
S.v=S.v+.26
elseif S.v>1 then
S.v=S.v-.26
end
S.time=S.time+S.v*dt
if S.time>45 then
S.time=45
elseif S.time<-10 then
S.time=-10
end
end
return Tmr

42
Zframework/toolfunc.lua Normal file
View File

@@ -0,0 +1,42 @@
local gc=love.graphics
local int=math.floor
local format=string.format
local fontData=love.filesystem.newFile("font.ttf")
local newFont=gc.setNewFont
local setNewFont=gc.setFont
local fontCache,currentFontSize={}
function setFont(s)
local f=fontCache[s]
if s~=currentFontSize then
if f then
setNewFont(f)
else
f=newFont(fontData,s)
fontCache[s]=f
setNewFont(f)
end
currentFontSize=s
end
return f
end
function toTime(s)
if s<60 then
return format("%.3fs",s)
elseif s<3600 then
return format("%d:%.2f",int(s/60),s%60)
else
local h=int(s/3600)
return format("%d:%d:%.2f",h,int(s/60%60),s%60)
end
end
function mStr(s,x,y)
gc.printf(s,x-400,y,800,"center")
end
function mText(s,x,y)
gc.draw(s,x-s:getWidth()*.5,y)
end
function mDraw(s,x,y,a,k)
gc.draw(s,x,y,a,k,nil,s:getWidth()*.5,s:getHeight()*.5)
end

8
Zframework/vib.lua Normal file
View File

@@ -0,0 +1,8 @@
local level={0,0,.015,.02,.03,.04,.05,.06,.07,.08}
local _=love.system.vibrate
return function(t)
local L=setting.vib
if L>0 then
_(level[L+t])
end
end

134
Zframework/voice.lua Normal file
View File

@@ -0,0 +1,134 @@
local rnd=math.random
local rem=table.remove
local voiceQueue={free=0}
local bank={}--{{SRC1s},{SRC2s},...}
local VOC={}
VOC.name={
"zspin","sspin","lspin","jspin","tspin","ospin","ispin",
"single","double","triple","techrash",
"mini","b2b","b3b","pc",
"win","lose",
"bye",
"nya",
"happy",
"doubt",
"sad",
"egg",
"welcome"
}
VOC.list={
zspin={"zspin_1","zspin_2","zspin_3"},
sspin={"sspin_1","sspin_2","sspin_3","sspin_4","sspin_5","sspin_6"},
lspin={"lspin_1","lspin_2"},
jspin={"jspin_1","jspin_2","jspin_3","jspin_4"},
tspin={"tspin_1","tspin_2","tspin_3","tspin_4","tspin_5","tspin_6"},
ospin={"ospin_1","ospin_2","ospin_3"},
ispin={"ispin_1","ispin_2","ispin_3"},
single={"single_1","single_2","single_3","single_4","single_5","single_6","single_7"},
double={"double_1","double_2","double_3","double_4","double_5"},
triple={"triple_1","triple_2","triple_3","triple_4","triple_5","triple_6","triple_7"},
techrash={"techrash_1","techrash_2","techrash_3","techrash_4"},
mini={"mini_1","mini_2","mini_3"},
b2b={"b2b_1","b2b_2","b2b_3"},
b3b={"b3b_1","b3b_2"},
pc={"clear_1","clear_2"},
win={"win_1","win_2","win_3","win_4","win_5","win_6","win_6","win_7"},
lose={"lose_1","lose_2","lose_3"},
bye={"bye_1","bye_2"},
nya={"nya_1","nya_2","nya_3","nya_4"},
happy={"nya_happy_1","nya_happy_2","nya_happy_3","nya_happy_4"},
doubt={"nya_doubt_1","nya_doubt_2"},
sad={"nya_sad_1"},
egg={"egg_1","egg_2"},
welcome={"welcome_voc"},
}
local function getVoice(str)
local L=bank[str]
local n=1
while L[n]:isPlaying()do
n=n+1
if not L[n]then
L[n]=L[1]:clone()
L[n]:seek(0)
break
end
end
return L[n]
--load voice with string
end
function VOC.loadOne(_)
local N=VOC.name[_]
for i=1,#VOC.list[N]do
local V=VOC.list[N][i]
bank[V]={love.audio.newSource("VOICE/"..V..".ogg","static")}
end
end
function VOC.loadAll()
for i=1,#VOC.list do
VOC.loadOne(i)
end
end
function VOC.getFreeChannel()
local i=#voiceQueue
for i=1,i do
if #voiceQueue[i]==0 then return i end
end
voiceQueue[i+1]={s=0}
return i+1
end
function VOC.getCount()
return #voiceQueue
end
function VOC.update()
for i=#voiceQueue,1,-1 do
local Q=voiceQueue[i]
if Q.s==0 then--Free channel, auto delete when >3
if i>3 then
rem(voiceQueue,i)
end
elseif Q.s==1 then--Waiting load source
Q[1]=getVoice(Q[1])
Q[1]:setVolume(setting.voc*.1)
Q[1]:play()
Q.s=Q[2]and 2 or 4
elseif Q.s==2 then--playing 1,ready 2
if Q[1]:getDuration()-Q[1]:tell()<.08 then
Q[2]=getVoice(Q[2])
Q[2]:setVolume(setting.voc*.1)
Q[2]:play()
Q.s=3
end
elseif Q.s==3 then--playing 12 same time
if not Q[1]:isPlaying()then
for i=1,#Q do
Q[i]=Q[i+1]
end
Q.s=Q[2]and 2 or 4
end
elseif Q.s==4 then--playing last
if not Q[1].isPlaying(Q[1])then
Q[1]=nil
Q.s=0
end
end
end
end
function VOC.play(s,chn)
if setting.voc>0 then
if chn then
local L=voiceQueue[chn]
local _=VOC.list[s]
if not _ then print("no VOC called:"..s)return end
L[#L+1]=_[rnd(#_)]
L.s=1
--add to queue[chn]
else
voiceQueue[VOC.getFreeChannel()]={s=1,VOC.list[s][rnd(#VOC.list[s])]}
--create new channel & play
end
end
end
return VOC

309
Zframework/widget.lua Normal file
View File

@@ -0,0 +1,309 @@
local gc=love.graphics
local kb=love.keyboard
local int=math.floor
local format=string.format
local next=next
local EMPTY={}
local button={
type="button",
ATV=0,--activating time(0~8)
}
function button:reset()
self.ATV=0
end
function button:isAbove(x,y)
return x>self.x-self.ATV and x<self.x+self.w+2*self.ATV and y>self.y-self.ATV and y<self.y+self.h+2*self.ATV
end
function button:FX()
sysFX.new("ripple",.16,self.x-self.ATV,self.y-self.ATV,self.w+2*self.ATV,self.h+2*self.ATV)
end
function button:update()
if WIDGET.sel==self then
if self.ATV<8 then self.ATV=self.ATV+1 end
else
if self.ATV>0 then self.ATV=self.ATV-1 end
end
end
function button:draw()
local x,y,w,h=self.x,self.y,self.w,self.h
local r,g,b=unpack(self.color)
gc.setColor(.2+r*.8,.2+g*.8,.2+b*.8,.7)
gc.rectangle("fill",x-self.ATV,y-self.ATV,w+2*self.ATV,h+2*self.ATV)
if self.ATV>0 then
gc.setLineWidth(4)
gc.setColor(1,1,1,self.ATV*.125)
gc.rectangle("line",x-self.ATV+2,y-self.ATV+2,w+2*self.ATV-4,h+2*self.ATV-4)
end
local t=self.text
if t then
if type(t)=="function"then t=t()end
setFont(self.font)
local y0=y+h*.5-self.font*.7
gc.setColor(1,1,1,.3)
gc.printf(t,x-2,y0-2,w,"center")
gc.printf(t,x-2,y0+2,w,"center")
gc.printf(t,x+2,y0-2,w,"center")
gc.printf(t,x+2,y0+2,w,"center")
gc.setColor(r*.5,g*.5,b*.5)
gc.printf(t,x,y0,w,"center")
end
end
function button:getInfo()
print(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
local switch={
type="switch",
ATV=0,--activating time(0~8)
CHK=0,--check alpha(0~6)
}
function switch:reset()
self.ATV=0
self.CHK=0
end
function switch:isAbove(x,y)
return x>self.x and x<self.x+50 and y>self.y-25 and y<self.y+25
end
function switch:update()
local _=self.ATV
if WIDGET.sel==self then if _<8 then self.ATV=_+1 end
else if _>0 then self.ATV=_-1 end
end
_=self.CHK
if self:disp()then if _<6 then self.CHK=_+1 end
else if _>0 then self.CHK=_-1 end
end
end
function switch:draw()
local x,y=self.x,self.y-25
if self.ATV>0 then
gc.setColor(1,1,1,self.ATV*.08)
gc.rectangle("fill",x,y,50,50)
end
if self.CHK>0 then
gc.setColor(.9,1,.9,self.CHK/6)
gc.setLineWidth(6)
gc.line(x+5,y+25,x+18,y+38,x+45,y+11)
end
--checked
gc.setLineWidth(4)
gc.setColor(1,1,1,.6+self.ATV*.05)
gc.rectangle("line",x,y,50,50)
--frame
local t=self.text
if t then
gc.setColor(1,1,1)
setFont(self.font)
gc.printf(t,x-412,y+20-self.font*.7,400,"right")
end
end
function switch:getInfo()
print(format("x=%d,y=%d,font=%d",self.x,self.y,self.font))
end
local slider={
type="slider",
ATV=0,--activating time(0~8)
pos=0,--position shown
}
function slider:reset()
self.ATV=0
self.pos=0
end
function slider:isAbove(x,y)
return x>self.x-10 and x<self.x+self.w+10 and y>self.y-20 and y<self.y+20
end
function slider:update()
if WIDGET.sel==self then
if self.ATV<6 then self.ATV=self.ATV+1 end
else
if self.ATV>0 then self.ATV=self.ATV-1 end
end
if not(self.hide and self.hide())then
self.pos=self.pos*.7+self.disp()*.3
end
end
function slider:draw()
local x,y=self.x,self.y
gc.setColor(1,1,1,.5+self.ATV*.06)
gc.setLineWidth(2)
local x1,x2=x,x+self.w
for p=0,self.unit do
local x=x1+(x2-x1)*p/self.unit
gc.line(x,y+7,x,y-7)
end
--units
gc.setLineWidth(4)
gc.line(x1,y,x2,y)
--axis
local t=self.text
if t then
gc.setColor(1,1,1)
setFont(self.font)
gc.printf(t,x-312,y-self.font*.7,300,"right")
end
--text
local x,y,w,h=x1+(x2-x1)*self.pos/self.unit-10-self.ATV*.5,y-16-self.ATV,20+self.ATV,32+2*self.ATV
gc.setColor(.8,.8,.8)
gc.rectangle("fill",x,y,w,h)
if self.ATV>0 then
gc.setLineWidth(2)
gc.setColor(1,1,1,self.ATV*.16)
gc.rectangle("line",x+1,y+1,w-2,h-2)
end
--block
end
function slider:getInfo()
print(format("x=%d,y=%d,w=%d",self.x,self.y,self.w))
end
local WIDGET={}
WIDGET.active=EMPTY--table, contains all active widgets
WIDGET.sel=nil--selected widget
function WIDGET.set(L)
WIDGET.sel=nil
WIDGET.active=L or EMPTY
if L then
for _,W in next,L do
W:reset()
end--Reset all widgets
end
end
WIDGET.new={}
function WIDGET.new.button(x,y,w,h,color,font,code,hide,N)
local _={
x=x-w*.5,y=y-h*.5,
w=w,h=h,
color=color,
font=font,
code=code,
hide=hide,
next=N,
}for k,v in next,button do _[k]=v end return _
end
function WIDGET.new.switch(x,y,font,disp,code,hide,N)
local _={
x=x,y=y,font=font,
disp=disp,
code=code,
hide=hide,
next=N,
}for k,v in next,switch do _[k]=v end return _
end
function WIDGET.new.slider(x,y,w,unit,font,change,disp,code,hide,N)
local _={
x=x,y=y,
w=w,unit=unit,
font=font,
change=change,
disp=disp,
code=code,
hide=hide,
next=N,
}for k,v in next,slider do _[k]=v end return _
end
function WIDGET.moveCursor(x,y)
WIDGET.sel=nil
for _,W in next,WIDGET.active do
if not(W.hide and W.hide())and W:isAbove(x,y)then
WIDGET.sel=W
return
end
end
end
function WIDGET.press(x,y)
local W=WIDGET.sel
if not W then return end
if W.type=="button"then
W.code()
W:FX()
SFX.play("button")
VOC.play("nya")
elseif W.type=="switch"then
W.code()
SFX.play("move",.6)
elseif W.type=="slider"then
if not x then return end
local p,P=W.disp(),x<W.x and 0 or x>W.x+W.w and W.unit or int((x-W.x)*W.unit/W.w+.5)
if p==P then return end
W.code(P)
if W.change then W.change()end
end
if W.hide and W.hide()then WIDGET.sel=nil end
end
function WIDGET.drag(x,y,dx,dy)
local W=WIDGET.sel
if not W then return end
if W.type=="slider"then
local p,P=W.disp(),x<W.x and 0 or x>W.x+W.w and W.unit or int((x-W.x)*W.unit/W.w+.5)
if p==P then return end
W.code(P)
if W.change then W.change()end
elseif not W:isAbove(x,y)then
WIDGET.sel=nil
end
end
function WIDGET.keyPressed(i)
if i=="tab"then
if WIDGET.sel then
WIDGET.sel=kb.isDown("lshift")and WIDGET.sel.prev or WIDGET.sel.next or WIDGET.sel
else
WIDGET.sel=select(2,next(WIDGET.active))
end
elseif i=="space"or i=="return"then
if WIDGET.sel then
WIDGET.press(WIDGET.sel)
end
elseif i=="left"or i=="right"then
local W=WIDGET.sel
if W then
if W.type=="slider"then
local p=W.disp()
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
if p==P or not P then return end
W.code(P)
if W.change then W.change()end
end
end
end
end
function WIDGET.gamepadPressed(i)
if i=="dpup"or i=="dpdown"then
if WIDGET.sel then
WIDGET.sel=i=="dpup"and WIDGET.sel.prev or WIDGET.sel.next or WIDGET.sel
else
WIDGET.sel=select(2,next(WIDGET.active))
end
elseif i=="start"then
if WIDGET.sel then
WIDGET.press(WIDGET.sel)
end
elseif i=="dpleft"or i=="dpright"then
if WIDGET.sel then
local W=WIDGET.sel
if W.type=="slider"then
local p=W.disp()
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
if p==P or not P then return end
W.code(P)
if W.change then W.change()end
end
end
end
end
function WIDGET.update()
for _,W in next,WIDGET.active do W:update()end
end
function WIDGET.draw()
for _,W in next,WIDGET.active do
if not(W.hide and W.hide())then
W:draw()
end
end
end
return WIDGET

404
Zframework/widgetList.lua Normal file
View File

@@ -0,0 +1,404 @@
local mobileHide=(system=="Android"or system=="iOS")and function()return true end
local function BACK()SCN.back()end
local virtualkeySet={
{
{1, 80, 720-200, 80},--moveLeft
{2, 320, 720-200, 80},--moveRight
{3, 1280-80, 720-200, 80},--rotRight
{4, 1280-200, 720-80, 80},--rotLeft
{5, 1280-200, 720-320, 80},--rot180
{6, 200, 720-320, 80},--hardDrop
{7, 200, 720-80, 80},--softDrop
{8, 1280-320, 720-200, 80},--hold
{9, 1280-80, 280, 80},--func
{10,80, 280, 80},--restart
},--Farter's set,thanks
{
{1, 1280-320, 720-200, 80},--moveLeft
{2, 1280-80, 720-200, 80},--moveRight
{3, 200, 720-80, 80},--rotRight
{4, 80, 720-200, 80},--rotLeft
{5, 200, 720-320, 80},--rot180
{6, 1280-200, 720-320, 80},--hardDrop
{7, 1280-200, 720-80, 80},--softDrop
{8, 320, 720-200, 80},--hold
{9, 80, 280, 80},--func
{10,1280-80, 280, 80},--restart
},--Mirrored farter's set,sknaht
{
{1, 80, 720-80, 80},--moveLeft
{2, 240, 720-80, 80},--moveRight
{3, 1280-240, 720-80, 80},--rotRight
{4, 1280-400, 720-80, 80},--rotLeft
{5, 1280-240, 720-240, 80},--rot180
{6, 1280-80, 720-80, 80},--hardDrop
{7, 1280-80, 720-240, 80},--softDrop
{8, 1280-80, 720-400, 80},--hold
{9, 80, 360, 80},--func
{10,80, 80, 80},--restart
},--Author's set,not recommend
{
{1, 1280-400, 720-80, 80},--moveLeft
{2, 1280-80, 720-80, 80},--moveRight
{3, 240, 720-80, 80},--rotRight
{4, 80, 720-80, 80},--rotLeft
{5, 240, 720-240, 80},--rot180
{6, 1280-240, 720-240, 80},--hardDrop
{7, 1280-240, 720-80, 80},--softDrop
{8, 1280-80, 720-240, 80},--hold
{9, 80, 720-240, 80},--func
{10,80, 320, 80},--restart
},--Keyboard set
{
{10,70, 50,30},--restart
{9, 130, 50,30},--func
{4, 190, 50,30},--rotLeft
{3, 250, 50,30},--rotRight
{5, 310, 50,30},--rot180
{1, 370, 50,30},--moveLeft
{2, 430, 50,30},--moveRight
{8, 490, 50,30},--hold
{7, 550, 50,30},--softDrop1
{6, 610, 50,30},--hardDrop
{11,670, 50,30},--insLeft
{12,730, 50,30},--insRight
{13,790, 50,30},--insDown
{14,850, 50,30},--down1
{15,910, 50,30},--down4
{16,970, 50,30},--down10
{17,1030, 50,30},--dropLeft
{18,1090, 50,30},--dropRight
{19,1150, 50,30},--addLeft
{20,1210, 50,30},--addRight
},--PC key feedback(top&in a row)
}
--lambda Funcs for widgets,delete at file end
local function SETval(k) return function()return setting[k] end end
local function SETsto(k) return function(i)setting[k]=i end end
local function SETrev(k) return function()setting[k]=not setting[k] end end
local function pressKey(k) return function()love.keypressed(k) end end
local function setPen(i) return function()sceneTemp.pen=i end end
local function prevSkin(n) return function()SKIN.prev(n) end end
local function nextSkin(n) return function()SKIN.next(n) end end
local function nextDir(n) return function()SKIN.rotate(n) end end
local function VKAdisp(n) return function()return VK_org[n].ava end end
local function VKAcode(n) return function()VK_org[n].ava=not VK_org[n].ava end end
local function setLang(n) return function()LANG.set(n)setting.lang=n end end
local newButton,newSwitch,newSlider=WIDGET.new.button,WIDGET.new.switch,WIDGET.new.slider
local C=color
local Widgets={
load={},intro={},quit={},
main={
play= newButton(150,280,200,160,C.lightRed, 55,function()SCN.push()SCN.swapTo("mode")end, nil,"setting"),
setting=newButton(370,280,200,160,C.lightBlue, 45,function()SCN.push()SCN.swapTo("setting_game")end, nil,"music"),
music= newButton(590,280,200,160,C.lightPurple, 32,function()SCN.push()SCN.swapTo("music")end, nil,"help"),
help= newButton(150,460,200,160,C.lightYellow, 50,function()SCN.push()SCN.swapTo("help")end, nil,"stat"),
stat= newButton(370,460,200,160,C.lightCyan, 43,function()SCN.push()SCN.swapTo("stat")end, nil,"qplay"),
qplay= newButton(590,460,200,160,C.lightOrange, 43,function()SCN.push()loadGame(stat.lastPlay)end, nil,"lang"),
lang= newButton(150,610,160,100,C.lightGreen, 45,function()SCN.push()SCN.swapTo("setting_lang")end, nil,"quit"),
quit= newButton(590,610,160,100,C.lightGrey, 45,function()VOC.play("bye")SCN.swapTo("quit","slowFade")end,nil,"play"),
},
mode={
draw= newButton(1100, 440,240,90,C.lightYellow, 40,function()SCN.push()SCN.swapTo("draw")end,function()return mapCam.sel~=71 and mapCam.sel~=72 end),
custom= newButton(1100, 540,240,90,C.lightGreen, 40,function()SCN.push()SCN.swapTo("custom")end,function()return mapCam.sel~=71 and mapCam.sel~=72 end),
start= newButton(1040, 655,180,80,C.lightGrey, 40,function()if mapCam.sel then SCN.push()loadGame(mapCam.sel)end end,function()return not mapCam.sel end),
back= newButton(1200, 655,120,80,C.white, 40,BACK),
--function()SCN.push()SCN.swapTo("custom")end
},
music={
bgm= newSlider(760, 80,400,10,35,function()BGM.freshVolume()end,SETval("bgm"),SETsto("bgm")),
up= newButton(1100, 200,120,120,C.white,55,pressKey("up")),
play= newButton(1100, 340,120,120,C.white,35,pressKey("space"),function()return setting.bgm==0 end),
down= newButton(1100, 480,120,120,C.white,55,pressKey("down")),
back= newButton(640, 630,230,90, C.white,40,BACK),
},
custom={
up= newButton(1000, 360,100,100,C.white, 45,function()sceneTemp=(sceneTemp-2)%#customID+1 end),
down= newButton(1000, 600,100,100,C.white, 45,function()sceneTemp=sceneTemp%#customID+1 end),
left= newButton(880, 480,100,100,C.white, 45,pressKey("left")),
right= newButton(1120, 480,100,100,C.white, 45,pressKey("right")),
set1= newButton(640, 160,240,75, C.lightYellow, 35,pressKey("1")),
set2= newButton(640, 250,240,75, C.lightYellow, 35,pressKey("2")),
set3= newButton(640, 340,240,75, C.lightYellow, 35,pressKey("3")),
set4= newButton(640, 430,240,75, C.lightYellow, 35,pressKey("4")),
set5= newButton(640, 520,240,75, C.lightYellow, 35,pressKey("5")),
back= newButton(640, 630,180,60, C.white, 35,BACK),
},
draw={
b1= newButton(500+65*1, 150,58,58,C.red, 30,setPen(1)),--B1
b2= newButton(500+65*2, 150,58,58,C.orange, 30,setPen(2)),--B2
b3= newButton(500+65*3, 150,58,58,C.yellow, 30,setPen(3)),--B3
b4= newButton(500+65*4, 150,58,58,C.grass, 30,setPen(4)),--B4
b5= newButton(500+65*5, 150,58,58,C.green, 30,setPen(5)),--B5
b6= newButton(500+65*6, 150,58,58,C.water, 30,setPen(6)),--B6
b7= newButton(500+65*7, 150,58,58,C.cyan, 30,setPen(7)),--B7
b8= newButton(500+65*8, 150,58,58,C.blue, 30,setPen(8)),--B8
b9= newButton(500+65*9, 150,58,58,C.purple, 30,setPen(9)),--B9
b10= newButton(500+65*10,150,58,58,C.magenta, 30,setPen(10)),--B10
b11= newButton(500+65*11,150,58,58,C.pink, 30,setPen(11)),--B11
b12= newButton(500+65*1, 230,58,58,C.darkGrey, 30,setPen(12)),--Bone
b13= newButton(500+65*2, 230,58,58,C.grey, 30,setPen(13)),--GB1
b14= newButton(500+65*3, 230,58,58,C.lightGrey, 30,setPen(14)),--GB2
b15= newButton(500+65*4, 230,58,58,C.darkPurple, 30,setPen(15)),--GB3
b16= newButton(500+65*5, 230,58,58,C.darkRed, 30,setPen(16)),--GB4
b17= newButton(500+65*6, 230,58,58,C.darkGreen, 30,setPen(17)),--GB5
any= newButton(600, 360,120,120,C.lightGrey, 40,setPen(0)),
space= newButton(730, 360,120,120,C.grey, 65,setPen(-1)),
clear= newButton(1200, 500,120,120,C.white, 40,pressKey("delete")),
demo= newSwitch(755, 640,30,function()return sceneTemp.demo end,function()sceneTemp.demo=not sceneTemp.demo end),
copy= newButton(920, 640,120,120,C.lightRed, 35,copyBoard),
paste= newButton(1060, 640,120,120,C.lightBlue, 35,pasteBoard),
back= newButton(1200, 640,120,120,C.white, 35,BACK),
},
play={
pause= newButton(1235,45,80,80,C.white,25,pauseGame),
},
pause={
resume= newButton(640,290,240,100,C.white,30,resumeGame),
restart=newButton(640,445,240,100,C.white,33,function()
TASK.clear("play")
mergeStat(stat,players[1].stat)
resetGameData()
SCN.swapTo("play","none")
end),
setting=newButton(1120,70,240,90,C.lightBlue,35,function()
SCN.push()SCN.swapTo("setting_sound")
end),
quit= newButton(640,600,240,100,C.white,35,BACK),
},
setting_game={
graphic=newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_video")end, nil,"sound"),
sound= newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_sound")end, nil,"ctrl"),
ctrl= newButton(290,220,320,80,C.lightYellow,35,function()SCN.push()SCN.swapTo("setting_control")end, nil,"key"),
key= newButton(640,220,320,80,C.lightGreen,35,function()SCN.push()SCN.swapTo("setting_key")end, nil,"touch"),
touch= newButton(990,220,320,80,C.lightBlue,35,function()SCN.push()SCN.swapTo("setting_touch")end, nil,"reTime"),
reTime= newSlider(350,340,300,10,30,nil, SETval("reTime"), SETsto("reTime"), nil,"maxNext"),
maxNext=newSlider(350,440,300,6,30,nil, SETval("maxNext"), SETsto("maxNext"), nil,"autoPause"),
autoPause=newSwitch(350,540,20, SETval("autoPause"), SETrev("autoPause"), nil,"layout"),
layout= newButton(590,540,140,70,C.white,35,function()
SCN.push()
SCN.swapTo("setting_skin")
end,nil,"quickR"),
quickR= newSwitch(1050,340,35, SETval("quickR"), SETrev("quickR"), nil,"swap"),
swap= newSwitch(1050,440,19, SETval("swap"), SETrev("swap"), nil,"fine"),
fine= newSwitch(1050,540,20, SETval("fine"), SETrev("fine"), nil,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK, nil,"graphic"),
},
setting_video={
sound= newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_sound")end, nil,"game"),
game= newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_game")end, nil,"ghost"),
ghost= newSwitch(250,180,35, SETval("ghost"), SETrev("ghost"), nil,"smooth"),
smooth= newSwitch(250,260,25, SETval("smooth"), SETrev("smooth"), nil,"center"),
center= newSwitch(500,180,35, SETval("center"), SETrev("center"), nil,"grid"),
grid= newSwitch(500,260,30, SETval("grid"), SETrev("grid"), nil,"bagLine"),
bagLine=newSwitch(730,180,30, SETval("bagLine"), SETrev("bagLine"), nil,"lockFX"),
lockFX= newSlider(350,340,373,3,32,nil, SETval("lockFX"), SETsto("lockFX"), nil,"dropFX"),
dropFX= newSlider(350,400,373,5,32,nil, SETval("dropFX"), SETsto("dropFX"), nil,"clearFX"),
clearFX=newSlider(350,460,373,3,32,nil, SETval("clearFX"), SETsto("clearFX"), nil,"shakeFX"),
shakeFX=newSlider(350,520,373,5,32,nil, SETval("shakeFX"), SETsto("shakeFX"), nil,"atkFX"),
atkFX= newSlider(350,580,373,5,32,nil, SETval("atkFX"), SETsto("atkFX"), nil,"frame"),
frame= newSlider(350,640,373,10,30,nil,function()return setting.frameMul>35 and setting.frameMul/10 or setting.frameMul/5-4 end,function(i)setting.frameMul=i<5 and 5*i+20 or 10*i end,nil,"text"),
text= newSwitch(1050,180,35,SETval("text"),SETrev("text"),nil,"warn"),
warn= newSwitch(1050,260,35,SETval("warn"),SETrev("warn"),nil,"fullscreen"),
fullscreen=newSwitch(1050,340,35,SETval("fullscreen"),function()
setting.fullscreen=not setting.fullscreen
love.window.setFullscreen(setting.fullscreen)
love.resize(love.graphics.getWidth(),love.graphics.getHeight())
end,nil,"bg"),
bg= newSwitch(1050,420,35,SETval("bg"),function()
BG.set("none")
setting.bg=not setting.bg
BG.set("space")
end,nil,"power"),
power= newSwitch(1050,500,35,SETval("powerInfo"),function()
setting.powerInfo=not setting.powerInfo
end,nil,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK,nil,"sound"),
},
setting_sound={
game= newButton(200,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_game")end, nil,"graphic"),
graphic=newButton(1080,80,240,80,C.lightCyan,35,function()SCN.swapTo("setting_video")end, nil,"sfx"),
sfx= newSlider(180,250,400,10,35,function()SFX.play("blip_1")end, SETval("sfx"), SETsto("sfx"), nil,"bgm"),
bgm= newSlider(750,250,400,10,35,function()BGM.freshVolume()end, SETval("bgm"), SETsto("bgm"), nil,"vib"),
vib= newSlider(180,440,400,5 ,28,function()VIB(2)end, SETval("vib"), SETsto("vib"), nil,"voc"),
voc= newSlider(750,440,400,10,32,function()VOC.play("nya")end, SETval("voc"), SETsto("voc"), nil,"stereo"),
stereo= newSlider(180,630,400,10,35,function()SFX.play("move",1,-1)SFX.play("lock",1,1)end, SETval("stereo"), SETsto("stereo"),function()return setting.sfx==0 end,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK,nil,"game"),
},
setting_control={
das= newSlider(226,200,910, 26, 30,nil,SETval("das"), SETsto("das"), nil,"arr"),
arr= newSlider(226,290,525, 15, 30,nil,SETval("arr"), SETsto("arr"), nil,"sddas"),
sddas= newSlider(226,380,350, 10, 30,nil,SETval("sddas"), SETsto("sddas"),nil,"sdarr"),
sdarr= newSlider(226,470,140, 4, 30,nil,SETval("sdarr"), SETsto("sdarr"),nil,"ihs"),
ihs= newSwitch(1100,290,30, SETval("ihs"), SETrev("ihs"),nil,"irs"),
irs= newSwitch(1100,380,30, SETval("irs"), SETrev("irs"),nil,"ihs"),
ims= newSwitch(1100,470,30, SETval("ims"), SETrev("ims"),nil,"reset"),
reset= newButton(160,580,200, 100,C.lightRed,40,function()
local _=setting
_.das,_.arr=10,2
_.sddas,_.sdarr=0,2
_.ihs,_.irs,_.ims=false,false,false
end,nil,"back"),
back= newButton(1140,650,200,80,C.white,40,BACK,nil,"das"),
},
setting_key={
back=newButton(1140,650,200,80,C.white,45,BACK),
},
setting_skin={
prev= newButton(700,100,140,100,C.white,50,function()SKIN.prevSet()end),
next= newButton(860,100,140,100,C.white,50,function()SKIN.nextSet()end),
prev1= newButton(130,230,90,65,C.white,30,prevSkin(1)),
prev2= newButton(270,230,90,65,C.white,30,prevSkin(2)),
prev3= newButton(410,230,90,65,C.white,30,prevSkin(3)),
prev4= newButton(550,230,90,65,C.white,30,prevSkin(4)),
prev5= newButton(690,230,90,65,C.white,30,prevSkin(5)),
prev6= newButton(830,230,90,65,C.white,30,prevSkin(6)),
prev7= newButton(970,230,90,65,C.white,30,prevSkin(7)),
next1= newButton(130,450,90,65,C.white,30,nextSkin(1)),
next2= newButton(270,450,90,65,C.white,30,nextSkin(2)),
next3= newButton(410,450,90,65,C.white,30,nextSkin(3)),
next4= newButton(550,450,90,65,C.white,30,nextSkin(4)),
next5= newButton(690,450,90,65,C.white,30,nextSkin(5)),
next6= newButton(830,450,90,65,C.white,30,nextSkin(6)),
next7= newButton(970,450,90,65,C.white,30,nextSkin(7)),
spin1= newButton(130,540,90,65,C.white,30,nextDir(1)),
spin2= newButton(270,540,90,65,C.white,30,nextDir(2)),
spin3= newButton(410,540,90,65,C.white,30,nextDir(3)),
spin4= newButton(550,540,90,65,C.white,30,nextDir(4)),
spin5= newButton(690,540,90,65,C.white,30,nextDir(5)),
--spin6=newButton(825,540,90,65,C.white,30,nextDir(6)),--cannot rotate O
spin7= newButton(970,540,90,65,C.white,30,nextDir(7)),
skinR= newButton(200,640,220,80,C.lightPurple,35,function()
setting.skin={1,5,8,2,10,3,7,1,5,5,1,8,2,10,3,7,10,7,8,2,8,2,1,5,3}
SFX.play("rotate")
end),
faceR= newButton(480,640,220,80,C.lightRed,35,function()
for i=1,25 do
setting.face[i]=0
end
SFX.play("hold")
end),
back= newButton(1140,650,200,80,C.white,40,BACK),
},
setting_touch={
default=newButton(520,80,170,80,C.white,35,function()
local D=virtualkeySet[sceneTemp.default]
for i=1,#VK_org do
VK_org[i].ava=false
end
for n=1,#D do
local T=D[n]
if T[1]then
local B=VK_org[n]
B.ava=true
B.x,B.y,B.r=T[2],T[3],T[4]
end
end--Replace keys
sceneTemp.default=sceneTemp.default%5+1
sceneTemp.sel=nil
end),
snap= newButton(760,80,170,80,C.white,35,function()
sceneTemp.snap=sceneTemp.snap%6+1
end),
option= newButton(520,180,170,80,C.white,40,function()
SCN.push()
SCN.swapTo("setting_touchSwitch")
end),
back= newButton(760,180,170,80,C.white,40,BACK),
size= newSlider(450,265,460,14,40,nil,function()
return VK_org[sceneTemp.sel].r/10-1
end,
function(v)
if sceneTemp.sel then
VK_org[sceneTemp.sel].r=10+v*10
end
end,
function()return not sceneTemp.sel end),
},
setting_touchSwitch={
b1= newSwitch(280,80, 35,VKAdisp(1),VKAcode(1)),
b2= newSwitch(280,140, 35,VKAdisp(2),VKAcode(2)),
b3= newSwitch(280,200, 35,VKAdisp(3),VKAcode(3)),
b4= newSwitch(280,260, 35,VKAdisp(4),VKAcode(4)),
b5= newSwitch(280,320, 35,VKAdisp(5),VKAcode(5)),
b6= newSwitch(280,380, 35,VKAdisp(6),VKAcode(6)),
b7= newSwitch(280,440, 35,VKAdisp(7),VKAcode(7)),
b8= newSwitch(280,500, 35,VKAdisp(8),VKAcode(8)),
b9= newSwitch(280,560, 35,VKAdisp(9),VKAcode(9)),
b10= newSwitch(280,620, 35,VKAdisp(10),VKAcode(10)),
b11= newSwitch(620,80, 35,VKAdisp(11),VKAcode(11)),
b12= newSwitch(620,140, 35,VKAdisp(12),VKAcode(12)),
b13= newSwitch(620,200, 35,VKAdisp(13),VKAcode(13)),
b14= newSwitch(620,260, 35,VKAdisp(14),VKAcode(14)),
b15= newSwitch(620,320, 35,VKAdisp(15),VKAcode(15)),
b16= newSwitch(620,380, 35,VKAdisp(16),VKAcode(16)),
b17= newSwitch(620,440, 35,VKAdisp(17),VKAcode(17)),
b18= newSwitch(620,500, 35,VKAdisp(18),VKAcode(18)),
b19= newSwitch(620,560, 35,VKAdisp(19),VKAcode(19)),
b20= newSwitch(620,620, 35,VKAdisp(20),VKAcode(20)),
norm= newButton(840,100, 240,80,C.white,35,function()for i=1,20 do VK_org[i].ava=i<11 end end),
pro= newButton(1120,100, 240,80,C.white,35,function()for i=1,20 do VK_org[i].ava=true end end),
hide= newSwitch(1170,200, 40,SETval("VKSwitch"),SETrev("VKSwitch")),
track= newSwitch(1170,300, 35,SETval("VKTrack"),SETrev("VKTrack")),
sfx= newSlider(800,380,180,4,40,function()SFX.play("virtualKey",setting.VKSFX*.25)end,SETval("VKSFX"),SETsto("VKSFX")),
vib= newSlider(800,460,180,2,40,function()VIB(setting.VKVIB)end,SETval("VKVIB"),SETsto("VKVIB")),
icon= newSwitch(850,300, 40,SETval("VKIcon"),SETrev("VKIcon")),
tkset= newButton(1120,420,240,80,C.white,32,function()
SCN.push()
SCN.swapTo("setting_trackSetting")
end,function()return not setting.VKTrack end),
alpha= newSlider(840,540,400,10,40,nil,SETval("VKAlpha"),SETsto("VKAlpha")),
back= newButton(1120,620,200,80,C.white,45,BACK),
},
setting_trackSetting={
VKDodge=newSwitch(400,200, 35,SETval("VKDodge"),SETrev("VKDodge")),
VKTchW= newSlider(140,310,1000,10,35,nil,SETval("VKTchW"),function(i)setting.VKTchW=i;setting.VKCurW=math.max(setting.VKCurW,i)end),
VKCurW= newSlider(140,370,1000,10,35,nil,SETval("VKCurW"),function(i)setting.VKCurW=i;setting.VKTchW=math.min(setting.VKTchW,i)end),
back= newButton(1080,600,240,80,C.white,45,BACK),
},
setting_lang={
chi= newButton(160,100,200,120,C.white,45,setLang(1),nil,"chi2"),
chi2= newButton(380,100,200,120,C.white,45,setLang(2),nil,"eng"),
eng= newButton(600,100,200,120,C.white,45,setLang(3),nil,"str"),
str= newButton(820,100,200,120,C.white,45,setLang(4),nil,"back"),
back= newButton(640,600,200,80,C.white,40,BACK,nil,"chi"),
},
help={
staff= newButton(980,500,150,80,C.white,32,function()SCN.push()SCN.swapTo("staff")end,nil,"his"),
his= newButton(1160,500,150,80,C.white,32,function()SCN.push()SCN.swapTo("history")end,nil,"qq"),
qq= newButton(980,600,150,80,C.white,32,function()love.system.openURL("tencent://message/?uin=1046101471&Site=&Menu=yes")end,mobileHide,"back"),
back= newButton(640,600,200,80,C.white,40,BACK,nil,"staff"),
},
staff={
back= newButton(1160,630,150,80,C.white,40,BACK),
},
history={
prev= newButton(1155,170,180,180,C.white,65,pressKey("up"),function()return sceneTemp[2]==1 end),
next= newButton(1155,400,180,180,C.white,65,pressKey("down"),function()return sceneTemp[2]==#sceneTemp[1]end),
back= newButton(1155,600,180,90,C.white,40,BACK),
},
stat={
path= newButton(980,620,250,80,C.white,25,function()love.system.openURL(love.filesystem.getSaveDirectory())end,mobileHide,"back"),
back= newButton(640,620,200,80,C.white,40,BACK,nil,"path"),
},
}
mobileHide,SETval,SETsto,SETrev=nil
pressKey,setPen,prevSkin,nextSkin=nil
nextDir,VKAdisp,VKAcode,setLang=nil
newButton,newSwitch,newSlider=nil
for _,L in next,Widgets do
for _,W in next,L do
if W.next then
W.next,L[W.next].prev=L[W.next],W
end
end
end
return Widgets