local gc=love.graphics local min=math.min local rooms local scrollPos,selected 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.room_list 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 task_enterRoom(task) local time=0 while true do coroutine.yield() local wsconn,connErr=client.poll(task) if wsconn then WSCONN=wsconn SCN.go("net_game") loadGame("sprint_40l") LOG.print(text.wsSuccessed,"warn") return elseif connErr then LOG.print(text.wsFailed..": "..connErr,"warn") return end time=time+1 if time>360 then LOG.print(text.wsFailed..": "..text.httpTimeout,"message") return end end end local function fresh() lastfreshTime=TIME() rooms=nil httpRequest( task_fetchRooms, PATH.api..PATH.rooms, "GET", {["Content-Type"]="application/json"}, json.encode{ email=USER.email, access_token=USER.access_token, } ) end local scene={} function scene.sceneInit() BG.set("bg1") scrollPos=0 selected=1 fresh() end function scene.wheelMoved(_,y) wheelScroll(y) end function scene.keyDown(k) if k=="r"then if TIME()-lastfreshTime>1 then fresh() end elseif k=="escape"then SCN.back() elseif rooms and #rooms>0 then if k=="down"then if selected<#rooms then selected=selected+1 if selected>scrollPos+10 then scrollPos=scrollPos+1 end end elseif k=="up"then if selected>1 then selected=selected-1 if selected