添加退出登录按钮
This commit is contained in:
@@ -246,6 +246,7 @@ return{
|
|||||||
ffa="FFA",
|
ffa="FFA",
|
||||||
rooms="Rooms",
|
rooms="Rooms",
|
||||||
chat="Chat",
|
chat="Chat",
|
||||||
|
logout="Log out",
|
||||||
},
|
},
|
||||||
net_rooms={
|
net_rooms={
|
||||||
refreshing="Refreshing Rooms",
|
refreshing="Refreshing Rooms",
|
||||||
|
|||||||
@@ -219,6 +219,7 @@ return{
|
|||||||
ffa="FFA",
|
ffa="FFA",
|
||||||
rooms="Salons",
|
rooms="Salons",
|
||||||
chat="Chat",
|
chat="Chat",
|
||||||
|
-- logout="Log out",
|
||||||
},
|
},
|
||||||
net_rooms={
|
net_rooms={
|
||||||
-- refreshing="Refreshing Rooms",
|
-- refreshing="Refreshing Rooms",
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ return{
|
|||||||
ffa="FFA",
|
ffa="FFA",
|
||||||
rooms="Salas",
|
rooms="Salas",
|
||||||
chat="Chat",
|
chat="Chat",
|
||||||
|
-- logout="Log out",
|
||||||
},
|
},
|
||||||
net_rooms={
|
net_rooms={
|
||||||
-- refreshing="Refreshing Rooms",
|
-- refreshing="Refreshing Rooms",
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ return{
|
|||||||
ffa="FFA",
|
ffa="FFA",
|
||||||
rooms="Salas",
|
rooms="Salas",
|
||||||
chat="Chat",
|
chat="Chat",
|
||||||
|
-- logout="Log out",
|
||||||
},
|
},
|
||||||
net_rooms={
|
net_rooms={
|
||||||
-- refreshing="Refreshing Rooms",
|
-- refreshing="Refreshing Rooms",
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ return{
|
|||||||
ffa="FFA",
|
ffa="FFA",
|
||||||
rooms="房间列表",
|
rooms="房间列表",
|
||||||
chat="聊天室",
|
chat="聊天室",
|
||||||
|
logout="退出登录",
|
||||||
},
|
},
|
||||||
net_rooms={
|
net_rooms={
|
||||||
refreshing="刷新房间列表中",
|
refreshing="刷新房间列表中",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ local data=love.data
|
|||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local WS,TIME=WS,TIME
|
local WS,TIME=WS,TIME
|
||||||
local NET={
|
local NET={
|
||||||
login=false,
|
|
||||||
allow_online=false,
|
allow_online=false,
|
||||||
roomList={},
|
roomList={},
|
||||||
accessToken=false,
|
accessToken=false,
|
||||||
@@ -110,6 +109,9 @@ function NET.wsconn_stream()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Disconnect
|
--Disconnect
|
||||||
|
function NET.wsclose_user()
|
||||||
|
WS.close("user")
|
||||||
|
end
|
||||||
function NET.wsclose_play()
|
function NET.wsclose_play()
|
||||||
WS.close("play")
|
WS.close("play")
|
||||||
end
|
end
|
||||||
@@ -152,7 +154,7 @@ function NET.storeUserInfo(res)
|
|||||||
--Get own name
|
--Get own name
|
||||||
if res.uid==USER.uid then
|
if res.uid==USER.uid then
|
||||||
USER.username=res.username
|
USER.username=res.username
|
||||||
FILE.save(USER,"conf/user")
|
FILE.save(USER,"conf/user","q")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- FILE.save(USERS,"conf/users")
|
-- FILE.save(USERS,"conf/users")
|
||||||
@@ -282,10 +284,11 @@ function NET.updateWS_user()
|
|||||||
local res=_parse(message)
|
local res=_parse(message)
|
||||||
if res then
|
if res then
|
||||||
if res.type=="Connect"then
|
if res.type=="Connect"then
|
||||||
NET.login=true
|
|
||||||
if res.uid then
|
if res.uid then
|
||||||
USER.uid=res.uid
|
USER.uid=res.uid
|
||||||
USER.authToken=res.authToken
|
USER.authToken=res.authToken
|
||||||
|
WIDGET.active.email:clear()
|
||||||
|
WIDGET.active.password:clear()
|
||||||
FILE.save(USER,"conf/user","q")
|
FILE.save(USER,"conf/user","q")
|
||||||
SCN.back()
|
SCN.back()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ function scene.keyDown(key)
|
|||||||
end
|
end
|
||||||
elseif key=="a"then
|
elseif key=="a"then
|
||||||
if testButton(3)then
|
if testButton(3)then
|
||||||
if NET.login then
|
if WS.status("user")=="running"then
|
||||||
if not NET.allow_online then
|
if not NET.allow_online then
|
||||||
TEXT.show(text.needUpdate,640,450,60,"flicker")
|
TEXT.show(text.needUpdate,640,450,60,"flicker")
|
||||||
SFX.play("finesseError")
|
SFX.play("finesseError")
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
local lastLogoutTime
|
||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
|
lastLogoutTime=-1e99
|
||||||
BG.set("space")
|
BG.set("space")
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
@@ -8,9 +11,24 @@ function scene.sceneBack()
|
|||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
-- WIDGET.newButton{name="ffa", x=640, y=200,w=350,h=120,font=40,code=NULL},
|
WIDGET.newButton{name="ffa", x=640, y=200,w=350,h=120,color="black",font=40,code=NULL},
|
||||||
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120, font=40,code=goScene"net_rooms"},
|
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120, font=40,code=goScene"net_rooms"},
|
||||||
-- WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,font=40,code=goScene"net_chat"},
|
WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,color="black",font=40,code=NULL},
|
||||||
|
WIDGET.newButton{name="logout", x=1140, y=70,w=180,h=70,color="dR",code=function()
|
||||||
|
if TIME()-lastLogoutTime<1 then
|
||||||
|
if USER.uid then
|
||||||
|
NET.wsclose_play()
|
||||||
|
NET.wsclose_user()
|
||||||
|
USER.username=false
|
||||||
|
USER.uid=false
|
||||||
|
USER.authToken=false
|
||||||
|
FILE.save(USER,"conf/user","q")
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
lastLogoutTime=TIME()
|
||||||
|
end
|
||||||
|
end},
|
||||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80, font=40,code=backScene},
|
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80, font=40,code=backScene},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user