联网游戏按钮代码移至场景内

This commit is contained in:
MrZ626
2020-12-05 23:14:09 +08:00
parent ebe3424b01
commit 0faadc979e
2 changed files with 29 additions and 30 deletions

View File

@@ -807,35 +807,6 @@ function WIDGET.lnk_STPeq(k,v) return function() return sceneTemp[k]==v end e
function WIDGET.lnk_pressKey(k) return function() love.keypressed(k) end end
function WIDGET.lnk_goScene(t,s) return function() SCN.go(t,s) end end
function WIDGET.lnk_swapScene(t,s) return function() SCN.swapTo(t,s) end end
function WIDGET.lnk_goNetgame()
if LOGIN then
if ACCOUNT.access_token then
httpRequest(
TICK.httpREQ_checkAccessToken,
PATH.api..PATH.access,
"GET",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
access_token=ACCOUNT.access_token,
}
)
else
httpRequest(
TICK.httpREQ_getAccessToken,
PATH.api..PATH.access,
"POST",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
}
)
end
else
SCN.go("login")
end
end
local indexMeta={
__index=function(L,k)

View File

@@ -37,7 +37,35 @@ end
scene.widgetList={
WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")},
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=WIDGET.lnk_goNetgame},
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=function()
if LOGIN then
if ACCOUNT.access_token then
httpRequest(
TICK.httpREQ_checkAccessToken,
PATH.api..PATH.access,
"GET",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
access_token=ACCOUNT.access_token,
}
)
else
httpRequest(
TICK.httpREQ_getAccessToken,
PATH.api..PATH.access,
"POST",
{["Content-Type"]="application/json"},
json.encode{
email=ACCOUNT.email,
auth_token=ACCOUNT.auth_token,
}
)
end
else
SCN.go("login")
end
end},
WIDGET.newButton{name="custom", x=590,y=220,w=200,h=140,color="lBlue", font=40,code=WIDGET.lnk_goScene("customGame")},
WIDGET.newButton{name="setting",x=150,y=380,w=200,h=140,color="lOrange",font=40,code=WIDGET.lnk_goScene("setting_game")},
WIDGET.newButton{name="stat", x=370,y=380,w=200,h=140,color="lGreen", font=40,code=WIDGET.lnk_goScene("stat")},