refactor GAME.mod (#1006)

Co-authored-by: MrZ_26 <1046101471@qq.com>
This commit is contained in:
Imple Lee
2023-10-08 18:56:44 +08:00
committed by GitHub
parent 323f8a72aa
commit 4e41024ba8
9 changed files with 105 additions and 84 deletions

View File

@@ -32,6 +32,7 @@ local listBox=WIDGET.newListBox{name='list',x=50,y=50,w=1200,h=520,lineH=40,draw
end}
local scene={}
local mods={}
local function _playRep(fileName)
local rep=DATA.parseReplay(fileName,true)
@@ -40,11 +41,12 @@ local function _playRep(fileName)
elseif MODES[rep.mode] then
GAME.seed=rep.seed
GAME.setting=rep.setting
TABLE.cut(GAME.mod)
for i=1,#MODOPT do MODOPT[i].sel=0 end
if #mods==0 then
mods=GAME.mod
end
GAME.mod=TABLE.new(0,#MODOPT)
for _,m in next,rep.mod do
MODOPT[m[1]+1].sel=m[2]
table.insert(GAME.mod,MODOPT[m[1]+1])
GAME.mod[m[1]+1]=m[2]
end
GAME.rep={}
DATA.pumpRecording(rep.data,GAME.rep)
@@ -74,8 +76,9 @@ function scene.enter()
_updateButtonVisibility()
end
function scene.leave()
for i=1,#MODOPT do MODOPT[i].sel=0 end
TABLE.cut(GAME.mod)
if #mods>0 then
GAME.mod,mods=mods,{}
end
end
function scene.keyDown(key)