更新整理法文和西文部分注释,网络错误提示信息更具体,netgame_xx系列改名,房间列表场景初步

This commit is contained in:
MrZ626
2020-12-22 14:36:27 +08:00
parent 8fffeaca94
commit f611199fab
11 changed files with 145 additions and 136 deletions

View File

@@ -29,7 +29,7 @@ local function tick_httpREQ_launch(task)
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
LOG.print(text.getNoticeFail..": "..text.httpTimeout,"message")
return
end
end
@@ -60,7 +60,7 @@ local function tick_httpREQ_autoLogin(task)
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
LOG.print(text.loginFailed..": "..text.httpTimeout,"message")
return
end
end

View File

@@ -34,7 +34,7 @@ local function tick_httpREQ_newLogin(task)
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
LOG.print(text.loginFailed..": "..text.httpTimeout,"message")
return
end
end

View File

@@ -8,7 +8,7 @@ local function tick_httpREQ_checkAccessToken(task)
if response then
if response.code==200 then
LOG.print(text.accessSuccessed)
SCN.go("netgame")
SCN.go("net_menumenu")
elseif response.code==403 or response.code==401 then
httpRequest(
TICK.httpREQ_getAccessToken,
@@ -33,7 +33,7 @@ local function tick_httpREQ_checkAccessToken(task)
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
LOG.print(text.loginFailed..": "..text.httpTimeout,"message")
return
end
end

View File

@@ -6,7 +6,7 @@ end
scene.widgetList={
WIDGET.newButton{name="ffa", x=640, y=200,w=350,h=120,font=40,code=NULL},
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120,font=40,code=NULL},
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120,font=40,code=WIDGET.lnk_goScene("net_menurooms")},
WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,font=40,code=WIDGET.lnk_goScene("chat")},
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK},
}

View File

@@ -0,0 +1,93 @@
local gc=love.graphics
local max,min=math.max,math.min
local rooms
local scrollPos,curPos
local lastfreshTime
local function task_fetchRooms(task)
local time=0
while true do
coroutine.yield()
local response,request_error=client.poll(task)
if response then
local res=json.decode(response.body)
if res then
if response.code==200 then
rooms=res.rooms
curPos=1
else
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
end
end
return
elseif request_error then
LOG.print(text.roomsFetchFailed..": "..request_error,"warn")
return
end
time=time+1
if time>210 then
LOG.print(text.roomsFetchFailed..": "..text.httpTimeout,"warn")
return
end
end
end
local function fresh()
lastfreshTime=TIME()
rooms=nil
httpRequest(
task_fetchRooms,
PATH.api..PATH.access,
"GET"
)
end
local scene={}
function scene.sceneInit()
BG.set("bg1")
scrollPos=0
curPos=0
fresh()
end
function scene.wheelMoved(_,y)
wheelScroll(y)
end
function scene.keyDown(k)
if rooms then
if k=="down"then
curPos=min(curPos+1,#rooms)
elseif k=="up"then
curPos=max(curPos-1,1)
elseif k=="r"then
fresh()
end
end
end
function scene.update()
if TIME()-lastfreshTime>5 then
fresh()
end
end
function scene.draw()
if rooms then
setFont(40)
for i=scrollPos,min(scrollPos+9,#rooms)do
local R=rooms[i+1]
gc.setColor(.7,.7,1)
gc.print(i,50,100+50*i)
gc.setColor(1,1,.7)
gc.print(R.name,130,100+50*i)
end
gc.print("",20,50+50*curPos)
end
end
scene.widgetList={
WIDGET.newButton{name="back",x=1140,y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK},
}
return scene

View File

@@ -19,7 +19,7 @@ local function tick_httpREQ_register(task)
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
LOG.print(text.loginFailed..": "..text.httpTimeout,"message")
return
end
end