修正解除自定义场地绘制高度限制后出现的其他衍生问题
“自定义场地页面”使用元表实现自动补充尺寸(编辑之后需要手动清空多余空行,目前仅一处)
This commit is contained in:
@@ -60,32 +60,21 @@ function DATA.pasteSequence(str)
|
||||
return true
|
||||
end
|
||||
|
||||
function DATA.newBoard(f)--Generate a new board
|
||||
if f then
|
||||
return TABLE.shift(f)
|
||||
else
|
||||
local F={}
|
||||
for i=1,20 do F[i]={0,0,0,0,0,0,0,0,0,0}end
|
||||
return F
|
||||
local fieldMeta={__index=function(self,h)
|
||||
for i=#self+1,h do
|
||||
self[i]={0,0,0,0,0,0,0,0,0,0}
|
||||
end
|
||||
return self[h]
|
||||
end}
|
||||
function DATA.newBoard(f)--Generate a new board
|
||||
return setmetatable(f and TABLE.shift(f)or{},fieldMeta)
|
||||
end
|
||||
function DATA.copyBoard(page)--Copy the [page] board
|
||||
local F=FIELD[page or 1]
|
||||
local str=""
|
||||
local H=0
|
||||
|
||||
for y=20,1,-1 do
|
||||
for x=1,10 do
|
||||
if F[y][x]~=0 then
|
||||
H=y
|
||||
goto BREAK_topFound
|
||||
end
|
||||
end
|
||||
end
|
||||
::BREAK_topFound::
|
||||
|
||||
--Encode field
|
||||
for y=1,H do
|
||||
for y=1,#F do
|
||||
local S=""
|
||||
local L=F[y]
|
||||
for x=1,10 do
|
||||
@@ -144,12 +133,6 @@ function DATA.pasteBoard(str,page)--Paste [str] data to [page] board
|
||||
p=p+1
|
||||
end
|
||||
|
||||
for y=fY,20 do
|
||||
for x=1,10 do
|
||||
F[y][x]=0
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -4,15 +4,12 @@ return{
|
||||
load=function()
|
||||
applyCustomGame()
|
||||
|
||||
for y=1,20 do
|
||||
if notEmptyLine(FIELD[1][y])then
|
||||
--Switch clear sprint mode on
|
||||
GAME.modeEnv.dropPiece=require'parts.eventsets.checkClearBoard'.dropPiece
|
||||
goto BREAK_clearMode
|
||||
end
|
||||
--Switch clear sprint mode on
|
||||
if #FIELD[1]>0 then
|
||||
GAME.modeEnv.dropPiece=require'parts.eventsets.checkClearBoard'.dropPiece
|
||||
else
|
||||
GAME.modeEnv.dropPiece=NULL
|
||||
end
|
||||
GAME.modeEnv.dropPiece=NULL
|
||||
::BREAK_clearMode::
|
||||
PLY.newPlayer(1)
|
||||
local AItype=GAME.modeEnv.opponent:sub(1,2)
|
||||
local AIlevel=tonumber(GAME.modeEnv.opponent:sub(-1))
|
||||
|
||||
@@ -8,7 +8,7 @@ return{
|
||||
dropPiece=function(P)
|
||||
local D=P.modeData
|
||||
local F=FIELD[D.finished+1]
|
||||
for y=1,20 do
|
||||
for y=1,#F do
|
||||
local L=P.field[y]
|
||||
for x=1,10 do
|
||||
local a,b=F[y][x],L and L[x]or 0
|
||||
@@ -42,7 +42,7 @@ return{
|
||||
local mark=TEXTURE.puzzleMark
|
||||
local F=FIELD[P.modeData.finished+1]
|
||||
gc_setColor(1,1,1)
|
||||
for y=1,20 do for x=1,10 do
|
||||
for y=1,#F do for x=1,10 do
|
||||
local T=F[y][x]
|
||||
if T~=0 then
|
||||
gc_draw(mark[T],30*x-30,600-30*y)
|
||||
|
||||
@@ -2,13 +2,6 @@ local gc,kb,sys=love.graphics,love.keyboard,love.system
|
||||
local int=math.floor
|
||||
local CUSTOMENV=CUSTOMENV
|
||||
|
||||
local function _notAir(L)
|
||||
for i=1,10 do
|
||||
if L[i]>0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local sList={
|
||||
visible={"show","easy","slow","medium","fast","none"},
|
||||
freshLimit={0,1,2,4,6,8,10,12,15,30,1e99},
|
||||
@@ -30,22 +23,11 @@ local sList={
|
||||
local scene={}
|
||||
|
||||
local sure
|
||||
local initField
|
||||
local function _freshMiniFieldVisible()
|
||||
initField=false
|
||||
for y=1,20 do
|
||||
if _notAir(FIELD[1][y])then
|
||||
initField=true
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
function scene.sceneInit()
|
||||
sure=0
|
||||
destroyPlayers()
|
||||
BG.set(CUSTOMENV.bg)
|
||||
BGM.play(CUSTOMENV.bgm)
|
||||
_freshMiniFieldVisible()
|
||||
end
|
||||
function scene.sceneBack()
|
||||
BGM.play()
|
||||
@@ -79,7 +61,7 @@ function scene.keyDown(key,isRep)
|
||||
end
|
||||
end
|
||||
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
|
||||
if initField then
|
||||
if #FIELD[1]>0 then
|
||||
FILE.save(CUSTOMENV,'conf/customEnv')
|
||||
loadGame('custom_puzzle',true)
|
||||
end
|
||||
@@ -97,7 +79,6 @@ function scene.keyDown(key,isRep)
|
||||
if sure>.3 then
|
||||
TABLE.cut(FIELD)TABLE.cut(BAG)TABLE.cut(MISSION)
|
||||
FIELD[1]=DATA.newBoard()
|
||||
_freshMiniFieldVisible()
|
||||
TABLE.clear(CUSTOMENV)
|
||||
TABLE.complete(require"parts.customEnv0",CUSTOMENV)
|
||||
for _,W in next,scene.widgetList do W:reset()end
|
||||
@@ -135,7 +116,6 @@ function scene.keyDown(key,isRep)
|
||||
for i=4,#args do
|
||||
if args[i]:find("%S")and not DATA.pasteBoard(args[i],i-3)and i<#args then goto THROW_fail end
|
||||
end
|
||||
_freshMiniFieldVisible()
|
||||
MES.new('check',text.importSuccess)
|
||||
do return end
|
||||
::THROW_fail::MES.new('error',text.dataCorrupted)
|
||||
@@ -162,7 +142,7 @@ function scene.draw()
|
||||
end
|
||||
|
||||
--Field content
|
||||
if initField then
|
||||
if #FIELD[1]>0 then
|
||||
gc.push('transform')
|
||||
gc.translate(330,240)
|
||||
gc.scale(.5)
|
||||
@@ -172,7 +152,7 @@ function scene.draw()
|
||||
local F=FIELD[1]
|
||||
local cross=TEXTURE.puzzleMark[-1]
|
||||
local texture=SKIN.lib[SETTING.skinSet]
|
||||
for y=1,20 do for x=1,10 do
|
||||
for y=1,#F do for x=1,10 do
|
||||
local B=F[y][x]
|
||||
if B>0 then
|
||||
gc.draw(texture[B],30*x-30,600-30*y)
|
||||
@@ -240,7 +220,7 @@ scene.widgetList={
|
||||
WIDGET.newButton{name="copy", x=1070,y=300,w=310,h=70,color='lR',font=25,code=pressKey"cC"},
|
||||
WIDGET.newButton{name="paste", x=1070,y=380,w=310,h=70,color='lB',font=25,code=pressKey"cV"},
|
||||
WIDGET.newButton{name="clear", x=1070,y=460,w=310,h=70,color='lY',font=35,code=pressKey"return"},
|
||||
WIDGET.newButton{name="puzzle", x=1070,y=540,w=310,h=70,color='lM',font=35,code=pressKey"return2",hideF=function()return not initField end},
|
||||
WIDGET.newButton{name="puzzle", x=1070,y=540,w=310,h=70,color='lM',font=35,code=pressKey"return2",hideF=function()return #FIELD[1]==0 end},
|
||||
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=pressKey"escape"},
|
||||
|
||||
--Rule set
|
||||
|
||||
@@ -16,6 +16,12 @@ local penX,penY
|
||||
local demo--If show x
|
||||
local page
|
||||
|
||||
local function isEmpty(L)
|
||||
for i=1,#L do
|
||||
if L[i]~=0 then return end
|
||||
end
|
||||
return true
|
||||
end
|
||||
local penKey={
|
||||
["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,
|
||||
q=9,w=10,e=11,r=12,t=13,y=14,u=15,i=16,
|
||||
@@ -100,13 +106,19 @@ local function _pDraw()
|
||||
C=0
|
||||
end
|
||||
|
||||
local F=FIELD[page]
|
||||
if C then
|
||||
for i=1,l do
|
||||
FIELD[page][penPath[i][2]][penPath[i][1]]=C
|
||||
F[penPath[i][2]][penPath[i][1]]=C
|
||||
end
|
||||
end
|
||||
penPath={}
|
||||
penMode=0
|
||||
|
||||
while #F>0 and isEmpty(F[#F])do
|
||||
rem(F)
|
||||
end
|
||||
print(#F)
|
||||
end
|
||||
|
||||
function scene.sceneInit()
|
||||
@@ -174,7 +186,7 @@ function scene.keyDown(key)
|
||||
end
|
||||
elseif key=="delete"then
|
||||
if sure>.3 then
|
||||
for y=1,20 do for x=1,10 do FIELD[page][y][x]=0 end end
|
||||
FIELD[page]=DATA.newBoard()
|
||||
sure=0
|
||||
SFX.play('finesseError',.7)
|
||||
else
|
||||
@@ -187,19 +199,18 @@ function scene.keyDown(key)
|
||||
SFX.play('blip')
|
||||
elseif key=="l"then
|
||||
local F=FIELD[page]
|
||||
local cleared=false
|
||||
for i=20,1,-1 do
|
||||
for j=1,10 do
|
||||
if F[i][j]<=0 then goto CONTINUE_notFull end
|
||||
end
|
||||
cleared=true
|
||||
SYSFX.newShade(3,200,660-30*i,300,30)
|
||||
SYSFX.newRectRipple(3,200,660-30*i,300,30)
|
||||
rem(F,i)
|
||||
::CONTINUE_notFull::
|
||||
end
|
||||
if #F~=20 then
|
||||
repeat
|
||||
F[#F+1]={0,0,0,0,0,0,0,0,0,0}
|
||||
until#F==20
|
||||
if cleared then
|
||||
SFX.play('clear_3',.8)
|
||||
SFX.play('fall',.8)
|
||||
end
|
||||
@@ -279,7 +290,7 @@ function scene.draw()
|
||||
local cross=TEXTURE.puzzleMark[-1]
|
||||
local F=FIELD[page]
|
||||
local texture=SKIN.lib[SETTING.skinSet]
|
||||
for y=1,20 do for x=1,10 do
|
||||
for y=1,#F do for x=1,10 do
|
||||
local B=F[y][x]
|
||||
if B>0 then
|
||||
gc.draw(texture[B],30*x-30,600-30*y)
|
||||
|
||||
Reference in New Issue
Block a user