diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index b63c4b2c..394a735b 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -98,6 +98,8 @@ return{ chatHistory="------New messages below------", chatQuit="Press again to exit", + roomsFetchFailed="Failed to fetch rooms", + errorMsg="An error has occurred and Techmino needs to restart.\nError info has been created, and you can send it to the author.", modInstruction="Select mods (modifiers) to use!\nMods will modify the game in different ways\n(and possibly break the game in weird ways).\nSome mods will make your game unranked.", @@ -241,7 +243,7 @@ return{ restart="Retry (R)", quit="Quit (Q)", }, - netgame={ + net_menumenu={ ffa="FFA", rooms="Rooms", chat="Chat", diff --git a/parts/language/lang_fr.lua b/parts/language/lang_fr.lua index 76aa6038..89e2183a 100644 --- a/parts/language/lang_fr.lua +++ b/parts/language/lang_fr.lua @@ -6,9 +6,9 @@ return{ httpTimeout="La connexion au réseau ne s'est pas faite à temps.", marking="Créateur du jeu: MrZ_26\nSi vous pouvez voir ceci, cet enregistrement est illégal\nToute explication est fausse et invalide.", holdR="Hold to restart", - -- newDay="新的一天,新的开始~", - -- playedLong="已经玩很久了!注意休息!", - -- playedTooMuch="今天玩太久啦!打块好玩但也要适可而止哦~", + -- newDay="[Anti-addiction] New day, new beginning!", + -- playedLong="[Anti-addiction] You've been playing quite a bit today. Make sure to take breaks.", + -- playedTooMuch="[Anti-addiction] You've been playing too much today! You can't play any more.", atkModeName={"Aléatoire","Badges","K.O.s faciles","Attaquants"}, royale_remain="$1 Joueurs restants", @@ -89,17 +89,19 @@ return{ -- loginFailed="Login failed", -- accessSuccessed="Successfully authorized!", -- accessFailed="Authorization failed", - -- wsSuccessed="WS连接成功", - -- wsFailed="WS连接失败", - -- wsDisconnected="WS连接断开", - -- wsNoConn="WS未连接", + -- wsSuccessed="WebSocket: connected", + -- wsFailed="WebSocket: connection failed", + -- wsDisconnected="WebSocket: disconnected", + -- wsNoConn="WebSocket: you are not connected", - -- chatJoin="进入房间", - -- chatLeave="离开房间", - -- chatRemain="人数:", - -- chatStart="------消息的开头------", - -- chatHistory="------以上是历史消息------", - -- chatQuit="再按一次退出", + -- chatJoin="joined the room.", + -- chatLeave="left the room.", + -- chatRemain="Online: ", + -- chatStart="------Beginning of log------", + -- chatHistory="------New messages below------", + -- chatQuit="Press again to exit", + + -- roomsFetchFailed="Failed to fetch rooms", errorMsg="Une erreur est survenue et Techmino doit redémarrer.\nDes informations concernant l'erreur ont été créées, et vous pouvez les envoyer au créateur.", @@ -220,7 +222,7 @@ return{ restart="Réessayer (R)", quit="Quitter (Q)", }, - netgame={ + net_menumenu={ -- ffa="FFA", -- rooms="Rooms", -- chat="Chat", @@ -489,55 +491,10 @@ return{ prehold="Préréserve", _pc="PC", - clear1="Clear 1", - clear2="Clear 2", - clear3="Clear 3", - clear4="Clear 4", - spin0="spin 0", - spin1="spin 1", - spin2="spin 2", - spin3="spin 3", - _1="Simple", _2="Double", _3="Triple", _4="Techrash", - z0="Z-spin", - z1="Z-spin 1", - z2="Z-spin 2", - z3="Z-spin 3", - s0="S-spin", - s1="S-spin 1", - s2="S-spin 2", - s3="S-spin 3", - - j0="J-spin", - j1="J-spin 1", - j2="J-spin 2", - j3="J-spin 3", - l0="L-spin", - l1="L-spin 1", - l2="L-spin 2", - l3="L-spin 3", - - t0="T-spin", - t1="T-spin 1", - t2="T-spin 2", - t3="T-spin 3", - o0="O-spin", - o1="O-spin 1", - o2="O-spin 2", - o3="O-spin 3", - - i0="I-spin", - i1="I-spin 1", - i2="I-spin 2", - i3="I-spin 3", - - mini="Mini", - b2b="B2B", - b3b="B3B", - pc="PC", }, mg_15p={ reset="Réinitialiser", diff --git a/parts/language/lang_sp.lua b/parts/language/lang_sp.lua index f0ca20c4..9dc16747 100644 --- a/parts/language/lang_sp.lua +++ b/parts/language/lang_sp.lua @@ -6,9 +6,9 @@ return{ httpTimeout="¡Tiempo de espera de conexión agotado!", marking="Autor:MrZ_26\nEsta grabación es ilegal si ves esto\nNo se aceptan excusas", holdR="Mantén presionado para reiniciar", - -- newDay="新的一天,新的开始~", - -- playedLong="已经玩很久了!注意休息!", - -- playedTooMuch="今天玩太久啦!打块好玩但也要适可而止哦~", + -- newDay="[Anti-addiction] New day, new beginning!", + -- playedLong="[Anti-addiction] You've been playing quite a bit today. Make sure to take breaks.", + -- playedTooMuch="[Anti-addiction] You've been playing too much today! You can't play any more.", atkModeName={"Al azar","Medallas","KOs","Atacantes"}, royale_remain="$1 Jugadores Restantes", @@ -90,17 +90,19 @@ return{ -- loginFailed="Login failed", -- accessSuccessed="Successfully authorized!", -- accessFailed="Authorization failed", - -- wsSuccessed="WS连接成功", - -- wsFailed="WS连接失败", - -- wsDisconnected="WS连接断开", - -- wsNoConn="WS未连接", + -- wsSuccessed="WebSocket: connected", + -- wsFailed="WebSocket: connection failed", + -- wsDisconnected="WebSocket: disconnected", + -- wsNoConn="WebSocket: you are not connected", - -- chatJoin="进入房间", - -- chatLeave="离开房间", - -- chatRemain="人数:", - -- chatStart="------消息的开头------", - -- chatHistory="------以上是历史消息------", - -- chatQuit="再按一次退出", + -- chatJoin="joined the room.", + -- chatLeave="left the room.", + -- chatRemain="Online: ", + -- chatStart="------Beginning of log------", + -- chatHistory="------New messages below------", + -- chatQuit="Press again to exit", + + -- roomsFetchFailed="Failed to fetch rooms", errorMsg="Ha ocurrido un error y Techmino necesita reiniciarse.\nSe creó un registro de error, puedes enviarlo al autor.", @@ -224,7 +226,7 @@ return{ restart="Reiniciar (R)", quit= "Finalizar (Q)", }, - netgame={ + net_menumenu={ -- ffa="FFA", -- rooms="Rooms", -- chat="Chat", @@ -311,7 +313,6 @@ return{ }, setting_skin={ title="Ajustes de Texturas", - spin1="R",spin2="R",spin3="R",spin4="R",spin5="R",spin6="R",spin7="R", skinR="Color por def.", faceR="Direc. por def.", }, @@ -492,57 +493,11 @@ return{ -- hold="Hold", -- prerotate="Prerotate", -- prehold="Prehold", - -- _pc="PC", - -- clear1="clear 1", - -- clear2="clear 2", - -- clear3="clear 3", - -- clear4="clear 4", - -- spin0="spin 0", - -- spin1="spin 1", - -- spin2="spin 2", - -- spin3="spin 3", - - -- _1="Single", - -- _2="Double", - -- _3="Triple", - -- _4="Techrash", - -- z0="Z-spin", - -- z1="Z-spin 1", - -- z2="Z-spin 2", - -- z3="Z-spin 3", - -- s0="S-spin", - -- s1="S-spin 1", - -- s2="S-spin 2", - -- s3="S-spin 3", - - -- j0="J-spin", - -- j1="J-spin 1", - -- j2="J-spin 2", - -- j3="J-spin 3", - -- l0="L-spin", - -- l1="L-spin 1", - -- l2="L-spin 2", - -- l3="L-spin 3", - - -- t0="T-spin", - -- t1="T-spin 1", - -- t2="T-spin 2", - -- t3="T-spin 3", - -- o0="O-spin", - -- o1="O-spin 1", - -- o2="O-spin 2", - -- o3="O-spin 3", - - -- i0="I-spin", - -- i1="I-spin 1", - -- i2="I-spin 2", - -- i3="I-spin 3", - - -- mini="Mini", - -- b2b="B2B", - -- b3b="B3B", - -- pc="PC", + _1="Single", + _2="Doble", + _3="Triple", + _4="Techrash", }, mg_15p={ reset="Mezclar", diff --git a/parts/language/lang_zh.lua b/parts/language/lang_zh.lua index bcce2bf6..b27c51f4 100644 --- a/parts/language/lang_zh.lua +++ b/parts/language/lang_zh.lua @@ -99,6 +99,8 @@ return{ chatHistory="------以上是历史消息------", chatQuit="再按一次退出", + roomsFetchFailed="拉取房间列表失败", + errorMsg="Techmino遭受了雷击,需要重新启动.\n我们已收集了一些错误信息,你可以向作者进行反馈.", modInstruction="选择你要使用的Mod!\n不同Mod会用不同的方式改变初始游戏规则(可能导致不能正常游玩)\n来开发新玩法或者挑战自我吧!\n提醒:开启一些Mod会让成绩无效,你也可以用键盘开关Mod,按住shift反向", @@ -244,7 +246,7 @@ return{ restart="重新开始(R)", quit= "退出(Q)", }, - netgame={ + net_menumenu={ ffa="FFA", rooms="房间列表", chat="聊天室", diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index 90cdddac..c0245efd 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -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 diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index e0c494ca..27243514 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -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 diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 69e9b286..adcd1cf9 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -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 diff --git a/parts/scenes/netgame.lua b/parts/scenes/net_menu.lua similarity index 90% rename from parts/scenes/netgame.lua rename to parts/scenes/net_menu.lua index f87e75b3..21f9ccc8 100644 --- a/parts/scenes/netgame.lua +++ b/parts/scenes/net_menu.lua @@ -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}, } diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua new file mode 100644 index 00000000..9f709510 --- /dev/null +++ b/parts/scenes/net_rooms.lua @@ -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 \ No newline at end of file diff --git a/parts/scenes/register.lua b/parts/scenes/register.lua index a00fcbd5..dec6e363 100644 --- a/parts/scenes/register.lua +++ b/parts/scenes/register.lua @@ -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 diff --git a/parts/tick.lua b/parts/tick.lua index 9c55b500..8acba2a7 100644 --- a/parts/tick.lua +++ b/parts/tick.lua @@ -11,7 +11,7 @@ function Tick.httpREQ_getAccessToken(task) LOG.print(text.accessSuccessed) USER.access_token=res.access_token FILE.save(USER,"conf/user") - SCN.swapTo("netgame") + SCN.swapTo("net_menumenu") else LOG.print(text.netErrorCode..response.code..": "..res.message,"warn") end @@ -33,7 +33,7 @@ function Tick.httpREQ_getAccessToken(task) end time=time+1 if time>360 then - LOG.print(text.httpTimeout,"message") + LOG.print(text.loginFailed..": "..text.httpTimeout,"message") return end end @@ -76,7 +76,7 @@ function Tick.wsCONN_connect(task) end time=time+1 if time>360 then - LOG.print(text.httpTimeout,"message") + LOG.print(text.wsFailed..": "..text.httpTimeout,"message") return end end