调整mod系统交互逻辑

This commit is contained in:
MrZ626
2020-11-22 19:58:08 +08:00
parent fb5ea1643a
commit 3b717d4705
5 changed files with 31 additions and 24 deletions

View File

@@ -433,13 +433,6 @@ function loadGame(M,ifQuickPlay)
STAT.lastPlay=M
GAME.curMode=MODES[M]
GAME.modeEnv=GAME.curMode.env
GAME.unranked=false
for _,mod in next,MODOPT do
if mod.sel>0 and mod.unranked then
GAME.unranked=true
end
end
print(GAME.unranked)
drawableText.modeName:set(text.modes[M][1])
drawableText.levelName:set(text.modes[M][2])
GAME.init=true
@@ -510,4 +503,12 @@ function gameStart()
P.timing=true
P:popNext()
end
end
function scoreValid()
for _,v in next,GAME.mod do
if v.unranked then
return false
end
end
return true
end

View File

@@ -221,7 +221,7 @@ GAME={--Global game data
rec={}, --Recording list, key,time,key,time...
recording=false, --If recording
replaying=false, --If replaying
unranked=nil, --unranked if specific mod is on
mod={}, --List of loaded mods
rank=nil, --Rank reached
prevBG=nil, --Previous background, for restore BG when quit setting page

View File

@@ -215,10 +215,8 @@ local function loadGameEnv(P)--Load gameEnv
end
end
if not ENV.noMod then
for _,M in next,MODOPT do
if M.sel>0 then
M.func(P,M)
end
for _,M in next,GAME.mod do
M.func(P,M)
end
end
end

View File

@@ -1345,7 +1345,7 @@ local function gameOver()--Save record
if R>0 then
GAME.rank=R
end
if not GAME.unranked then
if scoreValid()then
local r=RANKS[M.name]--Old rank
local needSave
if R>r then

View File

@@ -1,31 +1,37 @@
local gc=love.graphics
local ins,rem=table.insert,table.remove
local function checkunranked()
for _,M in next,MODOPT do
if M.sel>0 and M.unranked then
return true
local function remMod(M)
for i=1,#GAME.mod do
if GAME.mod[i]==M then
rem(GAME.mod,i)
return
end
end
end
local function toggleMod(M)
if M.sel==0 then
ins(GAME.mod,M)
end
if M.list then
M.sel=(M.sel+1)%(#M.list+1)
else
M.sel=1-M.sel
end
if M.sel>0 and M.conflict then
if M.sel==0 then
remMod(M)
elseif M.conflict then
for _,v in next,M.conflict do
MODOPT[v].sel=0
remMod(MODOPT[v])
end
end
sceneTemp.unranked=checkunranked()
SFX.play("move")
end
function sceneInit.mod()
sceneTemp={
sel=nil,--selected mod name
unranked=checkunranked(),--if unranked
}
BG.set("tunnel")
end
@@ -33,7 +39,7 @@ end
function mouseMove.mod(x,y)
sceneTemp.sel=nil
for N,M in next,MODOPT do
if(x-M.x)^2+(y-M.y)^2<1600 then
if(x-M.x)^2+(y-M.y)^2<2000 then
sceneTemp.sel=N
break
end
@@ -41,7 +47,7 @@ function mouseMove.mod(x,y)
end
function mouseDown.mod(x,y)
for _,M in next,MODOPT do
if(x-M.x)^2+(y-M.y)^2<1600 then
if(x-M.x)^2+(y-M.y)^2<2000 then
toggleMod(M)
break
end
@@ -59,8 +65,10 @@ function keyDown.mod(key)
for _,M in next,MODOPT do
M.sel=0
end
while GAME.mod[1]do
rem(GAME.mod)
end
SFX.play("hold")
sceneTemp.unranked=false
elseif #key==1 then
for N,M in next,MODOPT do
if key==M.key then
@@ -124,7 +132,7 @@ end
WIDGET.init("mod",{
WIDGET.newText({name="title",x=80,y=50,font=70,align="L"}),
WIDGET.newText({name="unranked",x=1200,y=60,color="lRed",font=50,align="R",hide=function()return not sceneTemp.unranked end}),
WIDGET.newText({name="unranked",x=1200,y=60,color="lRed",font=50,align="R",hide=function()return scoreValid()end}),
WIDGET.newButton({name="reset",x=1140,y=540,w=170,h=80,font=25,code=WIDGET.lnk_pressKey("tab")}),
WIDGET.newButton({name="back",x=1140,y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}),
})