调整mod系统交互逻辑
This commit is contained in:
@@ -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}),
|
||||
})
|
||||
Reference in New Issue
Block a user