local gc=love.graphics local gc_push,gc_pop,gc_scale,gc_translate=gc.push,gc.pop,gc.scale,gc.translate local gc_draw,gc_print,gc_line,gc_rectangle,gc_circle=gc.draw,gc.print,gc.line,gc.rectangle,gc.circle local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth local TIME=love.timer.getTime local int,ceil,rnd=math.floor,math.ceil,math.random local max,min,sin=math.max,math.min,math.sin local SCR=SCR local setFont,mStr=setFont,mStr local frameColorList={ [0]=COLOR.white, COLOR.lGreen, COLOR.lBlue, COLOR.lPurple, COLOR.lOrange, } --local function drawCell(y,x,id)gc_draw(SKIN.curText[id],30*x-30,-30*y)end local function drawGrid(P) local d=P.fieldBeneath+P.fieldUp gc_setLineWidth(1) gc_setColor(1,1,1,P.gameEnv.grid) for x=1,9 do gc_line(30*x,-10,30*x,600) end gc_push("transform") gc_translate(0,d-30*int(d/30)) for y=0,19 do gc_line(0,30*y,300,30*y) end gc_pop() end local function boardTransform(mode) if mode then if mode=="U-D"then gc_translate(0,590) gc_scale(1,-1) elseif mode=="L-R"then gc_translate(300,0) gc_scale(-1,1) elseif mode=="180"then gc_translate(300,590) gc_scale(-1,-1) end end end local function drawField(P) local V,F=P.visTime,P.field local start=int((P.fieldBeneath+P.fieldUp)/30+1) local edge=P.gameEnv.upEdge local rep=GAME.replaying local texture=SKIN.curText if P.falling==-1 then--Blocks only local t=TIME()*4 for j=start,min(start+21,#F)do for i=1,10 do if F[j][i]>0 then if V[j][i]>0 then gc_setColor(1,1,1,V[j][i]*.05) gc_draw(texture[F[j][i]],30*i-30,-30*j)-- drawCell(j,i,F[j][i]) if edge and(not F[j+1]or F[j+1][i]<=0)then local r,g,b=unpack(SKIN.libColor[F[j][i]]) gc_setColor((r+2)/3,(g+2)/3,(b+2)/3,V[j][i]*.05) gc_rectangle("fill",30*i-30,-30*j,30,-4) end elseif rep then gc_setColor(1,1,1,.3+.08*sin(.5*(j-i)+t)) gc_rectangle("fill",30*i-30,-30*j,30,30) end end end end else--With falling animation local ENV=P.gameEnv local stepY=ENV.smooth and(P.falling/(ENV.fall+1))^2.5*30 or 30 local A=P.falling/ENV.fall local h=1 gc_push("transform") for j=start,min(start+21,#F)do while j==P.clearingRow[h]do h=h+1 gc_translate(0,-stepY) gc_setColor(1,1,1,A) gc_rectangle("fill",0,30-30*j,300,stepY) end for i=1,10 do if F[j][i]>0 then if V[j][i]>0 then gc_setColor(1,1,1,V[j][i]*.05) gc_draw(texture[F[j][i]],30*i-30,-30*j)-- drawCell(j,i,F[j][i]) if edge and(not F[j+1]or F[j+1][i]<=0)then local r,g,b=unpack(SKIN.libColor[F[j][i]]) gc_setColor((r+2)/3,(g+2)/3,(b+2)/3,V[j][i]*.05) gc_rectangle("fill",30*i-30,-30*j,30,-4) end elseif rep then gc_setColor(1,1,1,.2) gc_rectangle("fill",30*i-30,-30*j,30,30) end end end end gc_pop() end end local function drawFXs(P) --LockFX for i=1,#P.lockFX do local S=P.lockFX[i] if S[3]<.5 then gc_setColor(1,1,1,2*S[3]) gc_rectangle("fill",S[1],S[2],60*S[3],30) else gc_setColor(1,1,1,2-2*S[3]) gc_rectangle("fill",S[1]+30,S[2],60*S[3]-60,30) end end --DropFX for i=1,#P.dropFX do local S=P.dropFX[i] gc_setColor(1,1,1,.6-S[5]*.6) local w=30*S[3]*(1-S[5]*.5) gc_rectangle("fill",30*S[1]-30+15*S[3]-w*.5,-30*S[2],w,30*S[4]) end --MoveFX local texture=SKIN.curText for i=1,#P.moveFX do local S=P.moveFX[i] gc_setColor(1,1,1,.6-S[4]*.6) gc_draw(texture[S[1]],30*S[2]-30,-30*S[3])-- drawCell(S[3],S[2],S[1]) end --ClearFX for i=1,#P.clearFX do local S=P.clearFX[i] local t=S[2] local x=t<.3 and 1-(3.3333*t-1)^2 or 1 local y=t<.2 and 5*t or 1-1.25*(t-.2) gc_setColor(1,1,1,y) gc_rectangle("fill",150-x*150,15-S[1]*30-y*15,300*x,y*30) end end local function drawGhost(P,clr) gc_setColor(1,1,1,P.gameEnv.ghost) local texture=SKIN.curText local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then gc_draw(texture[clr],30*(j+P.curX-1)-30,-30*(i+P.ghoY-1))-- drawCell(i+P.ghoY-1,j+P.curX-1,clr) end end end end local function drawBlockOutline(P,texture,trans) SHADER.alpha:send("a",trans) gc.setShader(SHADER.alpha) local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then local x=30*(j+P.curX)-60-3 local y=30-30*(i+P.curY)-3 gc_draw(texture,x,y) gc_draw(texture,x+6,y+6) gc_draw(texture,x+6,y) gc_draw(texture,x,y+6) end end end gc.setShader() end local function drawBlock(P,clr) gc_setColor(1,1,1) local texture=SKIN.curText local CB=P.cur.bk for i=1,#CB do for j=1,#CB[1]do if CB[i][j]then gc_draw(texture[clr],30*(j+P.curX-1)-30,-30*(i+P.curY-1))-- drawCell(i+P.curY-1,j+P.curX-1,clr) end end end end local function drawNextPreview(P,B) gc_setColor(1,1,1,.8) local x=int(6-#B[1]*.5) local y=21+ceil(P.fieldBeneath/30) for i=1,#B do for j=1,#B[1]do if B[i][j]then gc_draw(puzzleMark[-1],30*(x+j-2),30*(1-y-i)) end end end end local attackColor={ {COLOR.dGrey,COLOR.white}, {COLOR.grey,COLOR.white}, {COLOR.lPurple,COLOR.white}, {COLOR.lRed,COLOR.white}, {COLOR.dGreen,COLOR.cyan}, } local function drawBuffer(P) local h=0 for i=1,#P.atkBuffer do local A=P.atkBuffer[i] local bar=A.amount*30 if h+bar>600 then bar=600-h end if not A.sent then --Appear if A.time<20 then bar=bar*(20*A.time)^.5*.05 end if A.countdown>0 then --Timing gc_setColor(attackColor[A.lv][1]) gc_rectangle("fill",303,599-h,11,-bar) gc_setColor(attackColor[A.lv][2]) gc_rectangle("fill",303,599-h-bar,11,bar*(1-A.countdown/A.cd0)) else --Warning local a=math.sin((TIME()-i)*30)*.5+.5 local c1,c2=attackColor[A.lv][1],attackColor[A.lv][2] gc_setColor(c1[1]*a+c2[1]*(1-a),c1[2]*a+c2[2]*(1-a),c1[3]*a+c2[3]*(1-a)) gc_rectangle("fill",303,599-h,11,-bar) end else gc_setColor(attackColor[A.lv][1]) bar=bar*(20-A.time)*.05 gc_rectangle("fill",303,599-h,11,-bar) --Disappear end h=h+bar end end local function drawB2Bbar(P) local a,b=P.b2b,P.b2b1 if a>b then a,b=b,a end gc_setColor(.8,1,.2) gc_rectangle("fill",-14,599,11,-b*.6) gc_setColor(P.b2b<40 and COLOR.white or P.b2b<=800 and COLOR.lRed or COLOR.lBlue) gc_rectangle("fill",-14,599,11,-a*.6) if TIME()%.5<.3 then gc_setColor(1,1,1) gc_rectangle("fill",-15,b<40 and 568.5 or 118.5,13,3) end --LockDelay indicator if P.gameEnv.easyFresh then gc_setColor(1,1,1) else gc_setColor(1,.26,.26) end if P.lockDelay>=0 then gc_rectangle("fill",0,602,300*P.lockDelay/P.gameEnv.lock,6)--Lock delay indicator end local x=3 for _=1,min(P.freshTime,15)do gc_rectangle("fill",x,615,14,5) x=x+20 end end local function drawFinesseCombo_norm(P) if P.finesseCombo>2 then local S=P.stat local _=P.finesseComboTime local str=P.finesseCombo.."x" if S.finesseRate==5*S.piece then gc_setColor(.9,.9,.3,_*.2) gc_print(str,20,570) gc_setColor(.9,.9,.3,1.2-_*.1) elseif S.maxFinesseCombo==S.piece then gc_setColor(.7,.7,1,_*.2) gc_print(str,20,570) gc_setColor(.7,.7,1,1.2-_*.1) else gc_setColor(1,1,1,_*.2) gc_print(str,20,570) gc_setColor(1,1,1,1.2-_*.1) end if _>0 then gc_push("transform") gc_translate(20,600) gc_scale(1+_*.08) gc_print(str,0,-30) gc_pop() else gc_print(str,20,570) end end end local function drawFinesseCombo_remote(P) if P.finesseCombo>2 then local S=P.stat local str=P.finesseCombo.."x" if S.finesseRate==5*S.piece then gc_setColor(.9,.9,.3) elseif S.maxFinesseCombo==S.piece then gc_setColor(.7,.7,1) else gc_setColor(1,1,1) end gc_print(str,20,570) end end local function drawLife(life) if life>3 then gc_setColor(1,1,1) gc_draw(IMG.lifeIcon,475,595,nil,.8) setFont(20) gc_print("x",503,595) gc_print(life,517,595) elseif life>0 then gc_setColor(1,1,1) for i=1,life do gc_draw(IMG.lifeIcon,450+25*i,595,nil,.8) end end end local function drawMission(P) if not P.curMission then return end local missionEnum=missionEnum local L=P.gameEnv.mission local cur=P.curMission --Draw current mission setFont(35) if P.gameEnv.missionkill then gc_setColor(1,.7+.2*sin(TIME()*6.26),.4) else gc_setColor(1,1,1) end gc_print(missionEnum[L[cur]],85,110) --Draw next mission setFont(20) for i=1,3 do local m=L[cur+i] if m then m=missionEnum[m] gc_print(m,87-28*i,117) else break end end end local function drawStartCounter(P) gc_setColor(1,1,1) if GAME.frame<180 then if GAME.frame==0 then setFont(70) mStr(P.ready and text.beReady or text.notReady,305,220) else local count=179-GAME.frame gc_push("transform") gc_translate(305,220) setFont(95) if count%60>45 then gc_scale(1+(count%60-45)^2*.01,1)end mStr(int(count/60+1),0,0) gc_pop() end end end local draw={} function draw.drawNext_norm(P) local ENV=P.gameEnv local texture=SKIN.curText gc_push("transform") gc_translate(316,36) local N=ENV.nextCount*72 gc_setColor(0,0,0,.4)gc_rectangle("fill",0,0,124,N+8) gc_setColor(1,1,1)gc_rectangle("line",0,0,124,N+8) mText(drawableText.next,62,-51) N=1 gc_push("transform") gc_translate(62,40) while N<=ENV.nextCount and P.nextQueue[N]do local bk,clr=P.nextQueue[N].bk,P.nextQueue[N].color local k=#bk>2 and 2.2/#bk or 1 gc_scale(k) for i=1,#bk do for j=1,#bk[1] do if bk[i][j]then gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5))-- drawCell(i-#bk*.5,j-#bk[1]*.5,clr) end end end gc_scale(1/k) N=N+1 gc_translate(0,72) end gc_pop() if ENV.bagLine then local len=ENV.bagLen local phase=-P.pieceCount%len gc_setColor(.8,.5,.5) for i=phase,N-1,len do local y=72*i+3 gc_line(2+P.fieldOff.x,y,120,y) end end gc_pop() end function draw.drawNext_hidden(P) local ENV=P.gameEnv local texture=SKIN.curText gc_push("transform") gc_translate(316,36) local N=ENV.nextCount*72 gc_setColor(.5,0,0,.4)gc_rectangle("fill",0,0,124,N+8) gc_setColor(1,1,1)gc_rectangle("line",0,0,124,N+8) mText(drawableText.next,62,-51) N=min(ENV.nextStartPos,P.pieceCount+1) gc_push("transform") gc_translate(62,40) while N<=ENV.nextCount and P.nextQueue[N]do local bk,clr=P.nextQueue[N].bk,P.nextQueue[N].color local k=#bk>2 and 2.2/#bk or 1 gc_scale(k) for i=1,#bk do for j=1,#bk[1] do if bk[i][j]then gc_draw(texture[clr],30*(j-#bk[1]*.5)-30,-30*(i-#bk*.5))-- drawCell(i-#bk*.5,j-#bk[1]*.5,clr) end end end gc_scale(1/k) N=N+1 gc_translate(0,72) end gc_pop() if ENV.bagLine then local len=ENV.bagLen local phase=-P.pieceCount%len gc_setColor(.8,.5,.5) for i=phase,N-1,len do local y=72*i+3 gc_line(2+P.fieldOff.x,y,120,y) end end gc_pop() end function draw.drawHold_norm(P) local texture=SKIN.curText gc_push("transform") gc_translate(-140,116) gc_setColor(0,0,0,.4)gc_rectangle("fill",0,-80,124,80) gc_setColor(1,1,1)gc_rectangle("line",0,-80,124,80) if P.holdTime==0 then gc_setColor(.6,.4,.4)end mText(drawableText.hold,62,-131) local B=P.holdQueue[1] if B then local bk,clr=B.bk,B.color for i=1,#bk do for j=1,#bk[1]do if bk[i][j]then gc_draw(texture[clr],30*(j+2.06-#bk[1]*.5)-30,-30*(i+3.76-2.4*1-#bk*.5))-- drawCell(i+1.36-#B*.5,j+2.06-#B[1]*.5,clr) end end end end gc_pop() end function draw.drawHold_multi(P) local ENV=P.gameEnv local N=ENV.holdCount*72 local texture=SKIN.curText gc_push("transform") gc_translate(-140,116) gc_setColor(0,0,0,.4)gc_rectangle("fill",0,-80,124,N+8) gc_setColor(1,1,1)gc_rectangle("line",0,-80,124,N+8) if P.holdTime==0 then gc_setColor(.6,.4,.4)end mText(drawableText.hold,62,-131) gc_setColor(1,1,1) if #P.holdQueue