整理代码,修复非游戏状态下设置按钮可见性错误

This commit is contained in:
MrZ626
2021-07-05 14:30:29 +08:00
parent 6859d70ca7
commit 82749e9e19
2 changed files with 19 additions and 32 deletions

View File

@@ -20,10 +20,10 @@ scene.widgetList={
WIDGET.newText{name="version", x=950,y=280,color='Z',align='L',fText=VERSION.string},
WIDGET.newButton{name="sprint", x=260,y=480,w=260,font=50,code=function()loadGame('sprint_40l',true)end},
WIDGET.newButton{name="marathon",x=640,y=480,w=260,font=50,code=function()loadGame('marathon_n',true)end},
WIDGET.newButton{name="setting",x=1000,y=400,w=120,fText=TEXTURE.setting,font=50,code=goScene'setting_game'},
WIDGET.newButton{name="lang", x=1000,y=560,w=120,fText=TEXTURE.language,font=40,code=goScene'lang'},
WIDGET.newButton{name="manual", x=1160,y=400,w=120,fText=TEXTURE.sure,font=80,code=goScene'manual'},
WIDGET.newButton{name="quit", x=1160,y=560,w=120,fText=TEXTURE.quit,font=70,code=function()VOC.play('bye')SCN.swapTo('quit','slowFade')end},
WIDGET.newButton{name="setting",x=1000,y=400,w=120,fText=TEXTURE.setting,code=goScene'setting_game'},
WIDGET.newButton{name="lang", x=1000,y=560,w=120,fText=TEXTURE.language,code=goScene'lang'},
WIDGET.newButton{name="manual", x=1160,y=400,w=120,fText=TEXTURE.sure,code=goScene'manual'},
WIDGET.newButton{name="quit", x=1160,y=560,w=120,fText=TEXTURE.quit,code=function()VOC.play('bye')SCN.swapTo('quit','slowFade')end},
}
return scene

View File

@@ -49,6 +49,13 @@ local function _switchChat()
WIDGET.unFocus(true)
end
end
local function hideReadyUI()
return
playing or
NET.roomState.start or
not netPLY.getSelfReady()or
NET.getlock('ready')
end
local scene={}
@@ -142,7 +149,7 @@ function scene.keyDown(key,isRep)
PLAYERS[1]:pressKey(k)
VK.press(k)
end
else
elseif not hideReadyUI()then
if key=="space"then
if netPLY.getSelfJoinMode()==0 then
(kb.isDown("lctrl","rctrl","lalt","ralt")and _setSpectate or _setReady)()
@@ -321,36 +328,16 @@ function scene.draw()
gc_print("M",430,10)
end
end
scene.widgetList={
textBox,
inputBox,
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=_gotoSetting,hideF=function()return playing or netPLY.getSelfReady()or NET.getlock('ready')end},
WIDGET.newKey{name="ready",x=1060,y=510,w=360,h=90,color='lG',font=35,code=_setReady,
hideF=function()
return
playing or
NET.roomState.start or
netPLY.getSelfReady() or
NET.getlock('ready')
end},
WIDGET.newKey{name="spectate",x=1060,y=610,w=360,h=90,color='lO',font=35,code=_setSpectate,
hideF=function()
return
playing or
NET.roomState.start or
netPLY.getSelfReady() or
NET.getlock('ready')
end},
WIDGET.newKey{name="cancel",x=1060,y=560,w=360,h=120,color='lH',font=40,code=_setCancel,
hideF=function()
return
playing or
NET.roomState.start or
not netPLY.getSelfReady() or
NET.getlock('ready')
end},
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=_switchChat},
WIDGET.newKey{name="quit",fText=TEXTURE.quit_small,x=900,y=35,w=60,font=40,code=_quit},
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90, code=_gotoSetting,hideF=hideReadyUI},
WIDGET.newKey{name="ready",x=1060,y=510,w=360,h=90,color='lG',font=35, code=_setReady,hideF=hideReadyUI},
WIDGET.newKey{name="spectate",x=1060,y=610,w=360,h=90,color='lO',font=35, code=_setSpectate,hideF=hideReadyUI},
WIDGET.newKey{name="cancel",x=1060,y=560,w=360,h=120,color='lH',font=40, code=_setCancel,hideF=hideReadyUI},
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35, code=_switchChat},
WIDGET.newKey{name="quit",fText=TEXTURE.quit_small,x=900,y=35,w=60,code=_quit},
}
return scene