整理代码,返回需要二次确认的小程序统一用一个函数
This commit is contained in:
@@ -15,6 +15,18 @@ local playSFX=SFX.play
|
|||||||
|
|
||||||
|
|
||||||
--System
|
--System
|
||||||
|
do--function tryBackScene()
|
||||||
|
local sureQuitTime=-1e99
|
||||||
|
function tryBack()
|
||||||
|
if TIME()-sureQuitTime<1 then
|
||||||
|
sureQuitTime=-1e99
|
||||||
|
SCN.back()
|
||||||
|
else
|
||||||
|
sureQuitTime=TIME()
|
||||||
|
MES.new('warn',text.sureQuit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
do--function loadFile(name,args), function saveFile(data,name,args)
|
do--function loadFile(name,args), function saveFile(data,name,args)
|
||||||
local t=setmetatable({},{__index=function()return"'$1' loading failed: $2"end})
|
local t=setmetatable({},{__index=function()return"'$1' loading failed: $2"end})
|
||||||
function loadFile(name,args)
|
function loadFile(name,args)
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ function scene.keyDown(key,isRep)
|
|||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
if repeater.focus then
|
if repeater.focus then
|
||||||
repeater.focus=false
|
repeater.focus=false
|
||||||
else
|
elseif tryBack()then
|
||||||
SCN.back()
|
SCN.back()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -185,7 +185,9 @@ function scene.keyDown(key,isRep)
|
|||||||
elseif key=='r'then
|
elseif key=='r'then
|
||||||
reset()
|
reset()
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ function scene.keyDown(key,isRep)
|
|||||||
vy=pow*sin(ang)/2.6
|
vy=pow*sin(ang)/2.6
|
||||||
end
|
end
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function scene.mouseDown(_,_,k)
|
function scene.mouseDown(_,_,k)
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ function scene.keyDown(key,isRep)
|
|||||||
state='move'
|
state='move'
|
||||||
end
|
end
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function scene.mouseDown(_,_,k)
|
function scene.mouseDown(_,_,k)
|
||||||
|
|||||||
@@ -262,11 +262,12 @@ function scene.keyDown(key,isRep)
|
|||||||
elseif key=='z'or key=='x'then
|
elseif key=='z'or key=='x'then
|
||||||
love.mousepressed(ms.getPosition())
|
love.mousepressed(ms.getPosition())
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
if state~=1 or sure>.2 then
|
if state~=1 then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
sure=1
|
sure=1
|
||||||
MES.new('info',"Press again")
|
|
||||||
end
|
end
|
||||||
elseif state==0 then
|
elseif state==0 then
|
||||||
if key=='q'then
|
if key=='q'then
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ end
|
|||||||
function scene.keyDown(key,isRep)
|
function scene.keyDown(key,isRep)
|
||||||
if isRep then return end
|
if isRep then return end
|
||||||
if key=='escape'then
|
if key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
elseif key=='r'then
|
elseif key=='r'then
|
||||||
_reset()
|
_reset()
|
||||||
elseif state==0 then
|
elseif state==0 then
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ end
|
|||||||
function scene.keyDown(key,isRep)
|
function scene.keyDown(key,isRep)
|
||||||
if isRep then return end
|
if isRep then return end
|
||||||
if key=='escape'then
|
if key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
elseif key=='space'then
|
elseif key=='space'then
|
||||||
if state==0 then--main
|
if state==0 then--main
|
||||||
if timer==0 then
|
if timer==0 then
|
||||||
|
|||||||
@@ -109,11 +109,11 @@ local function merge()
|
|||||||
end
|
end
|
||||||
if chosen>=5 then
|
if chosen>=5 then
|
||||||
SFX.play(
|
SFX.play(
|
||||||
chosen>=9 and"ren_mega"or
|
chosen>=9 and'ren_mega'or
|
||||||
chosen>=8 and"spin_3"or
|
chosen>=8 and'spin_3'or
|
||||||
chosen>=7 and"spin_2"or
|
chosen>=7 and'spin_2'or
|
||||||
chosen>=6 and"spin_1"or
|
chosen>=6 and'spin_1'or
|
||||||
"spin_0"
|
'spin_0'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
fallingTimer=fast and 8 or 12
|
fallingTimer=fast and 8 or 12
|
||||||
@@ -157,7 +157,9 @@ function scene.keyDown(key,isRep)
|
|||||||
fast=not fast
|
fast=not fast
|
||||||
end
|
end
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
SCN.back()
|
if tryBack()then
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function scene.mouseMove(x,y)
|
function scene.mouseMove(x,y)
|
||||||
|
|||||||
@@ -116,12 +116,9 @@ function scene.keyDown(key,isRep)
|
|||||||
elseif key=='c'then
|
elseif key=='c'then
|
||||||
enterConsole()
|
enterConsole()
|
||||||
elseif key=='escape'then
|
elseif key=='escape'then
|
||||||
if TIME()-lastQuitTime<1 then
|
if tryBack()then
|
||||||
VOC.play('bye')
|
VOC.play('bye')
|
||||||
SCN.swapTo('quit','slowFade')
|
SCN.swapTo('quit','slowFade')
|
||||||
else
|
|
||||||
lastQuitTime=TIME()
|
|
||||||
MES.new('warn',text.sureQuit)
|
|
||||||
end
|
end
|
||||||
elseif key=='c'then
|
elseif key=='c'then
|
||||||
enterConsole()
|
enterConsole()
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ local inputBox=WIDGET.newInputBox{name='input',x=340,y=660,w=600,h=50,limit=256}
|
|||||||
local playing
|
local playing
|
||||||
local lastUpstreamTime
|
local lastUpstreamTime
|
||||||
local upstreamProgress
|
local upstreamProgress
|
||||||
local lastBackTime=0
|
|
||||||
local noTouch,noKey=false,false
|
local noTouch,noKey=false,false
|
||||||
local touchMoveLastFrame=false
|
local touchMoveLastFrame=false
|
||||||
local newMessageTimer
|
local newMessageTimer
|
||||||
@@ -36,15 +35,12 @@ local function _gotoSetting()
|
|||||||
SCN.go('setting_game')
|
SCN.go('setting_game')
|
||||||
end
|
end
|
||||||
local function _quit()
|
local function _quit()
|
||||||
if TIME()-lastBackTime<1 then
|
if tryBack()then
|
||||||
NET.signal_quit()
|
NET.signal_quit()
|
||||||
if SCN.stack[#SCN.stack-1]=='net_newRoom'then
|
if SCN.stack[#SCN.stack-1]=='net_newRoom'then
|
||||||
SCN.pop()
|
SCN.pop()
|
||||||
end
|
end
|
||||||
SCN.back()
|
SCN.back()
|
||||||
else
|
|
||||||
lastBackTime=TIME()
|
|
||||||
MES.new('info',text.sureQuit)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function _switchChat()
|
local function _switchChat()
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
local lastLogoutTime
|
|
||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
lastLogoutTime=-1e99
|
|
||||||
BG.set()
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
@@ -22,7 +19,7 @@ scene.widgetList={
|
|||||||
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
|
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
|
||||||
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
|
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
|
||||||
code=function()
|
code=function()
|
||||||
if TIME()-lastLogoutTime<1 then
|
if tryBack()then
|
||||||
if USER.uid then
|
if USER.uid then
|
||||||
NET.wsclose_play()
|
NET.wsclose_play()
|
||||||
NET.wsclose_user()
|
NET.wsclose_user()
|
||||||
@@ -31,9 +28,6 @@ scene.widgetList={
|
|||||||
saveFile(USER,'conf/user')
|
saveFile(USER,'conf/user')
|
||||||
SCN.back()
|
SCN.back()
|
||||||
end
|
end
|
||||||
else
|
|
||||||
MES.new('info',text.sureQuit)
|
|
||||||
lastLogoutTime=TIME()
|
|
||||||
end
|
end
|
||||||
end},
|
end},
|
||||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,font=60,fText=CHAR.icon.back,code=backScene},
|
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,font=60,fText=CHAR.icon.back,code=backScene},
|
||||||
|
|||||||
Reference in New Issue
Block a user