diff --git a/Zframework/languages.lua b/Zframework/languages.lua index abb14a05..37402862 100644 --- a/Zframework/languages.lua +++ b/Zframework/languages.lua @@ -66,6 +66,12 @@ local langList={ getVersionFail="检测新版本失败", versionIsNew="游戏已是最新版本", versionIsOld="最新版本$1可以下载了!", + registerSuccessed="注册成功!", + registerFailed="注册失败", + netErrorCode="网络错误码", + noUsername="请填写用户名", + noPassword="请填写密码", + diffPassword="两次密码不一致", errorMsg="Techmino遭受了雷击,需要重新启动.\n我们已收集了一些错误信息,你可以向作者进行反馈.", acts={ @@ -461,8 +467,10 @@ local langList={ login={ title="登录/注册", username="用户名", + email="邮箱", password="密码", password2="确认密码", + back="返回", }, account={ title="账户", @@ -657,6 +665,12 @@ local langList={ getVersionFail="检测新版本失败", versionIsNew="游戏已是最新版本", versionIsOld="最新版本$1可以下载了!", + registerSuccessed="注册成功!", + registerFailed="注册失败", + netErrorCode="网络错误码", + noUsername="请填写用户名", + noPassword="请填写密码", + diffPassword="两次密码不一致", errorMsg="Techmino遭受了雷击,需要重新启动.\n我们已收集了一些错误信息,你可以向作者进行反馈.", acts={ @@ -1054,8 +1068,10 @@ local langList={ login={ title="登录/注册", username="用户名", + email="邮箱", password="密码", password2="确认密码", + back="返回", }, account={ title="账户", @@ -1250,6 +1266,12 @@ local langList={ getVersionFail="get newest version failed", versionIsNew="You are now on the latest version.", versionIsOld="Version $1 is available now!", + registerSuccessed="Register successed!", + registerFailed="Register failed", + netErrorCode="Network error code", + noUsername="Input username", + noPassword="Input password", + diffPassword="Password don't match", errorMsg="An error has occurred and Techmino needs to restart.\nError info has been created, and you can send it to the author.", acts={ @@ -1637,8 +1659,10 @@ local langList={ login={ title="Log in / Sign up", username="Username", + email="E-mail", password="Password", password2="Again Password", + back="Back", }, account={ title="Account", @@ -1836,12 +1860,17 @@ local langList={ noScore="?_____?", highScore="__&:", newRecord="^!!!^", - getNoticeFail="ge7 no7!ce f@i1ed", - getVersionFail="ge7 newe5t ver5i0n f@i1ed", - versionIsNew="Y0u @re now 0n the l@7e57 ver5ion.", - versionIsOld="Versi0n $1 is @v@i1able n0w!", + getNoticeFail="get notice failed", + getVersionFail="get newest version failed", + versionIsNew="You are now on the latest version.", + versionIsOld="Version $1 is available now!", + registerSuccessed="Register successed!", + registerFailed="Register failed", + netErrorCode="Network error code", + noUsername="Input username", + noPassword="Input password", + diffPassword="Password don't match", errorMsg="An e??o? h@s occ^__ed @nd Techmino n__ds to r_st@rt.\n&**o* in#o h@$ b==n cre@ted, @nd y0u c@n $&nd it to the @uth0r.", - acts={ "←:","→:", "R→:","←R:","R↑↓:", @@ -2234,8 +2263,10 @@ local langList={ login={ title="Log in / Sign up", username="@", + email="E-mail", password="*", password2="*", + back="X", }, account={ title="@_@", @@ -2425,9 +2456,15 @@ local langList={ highScore="最佳成绩", newRecord="打破纪录", getNoticeFail="拉取公告失败", - getVersionFail="拉取公告失败", + getVersionFail="检测新版本失败", versionIsNew="游戏已是最新版本", versionIsOld="最新版本$1可以下载了!", + registerSuccessed="注册成功!", + registerFailed="注册失败", + netErrorCode="网络错误码", + noUsername="账号密码都填不来?", + noPassword="账号密码都填不来?", + diffPassword="账号密码都填不来?", errorMsg="Techmino遭受了雷击,需要重新启动.\n我们已收集了一些错误信息,你可以向作者进行反馈.", acts={ @@ -2824,8 +2861,10 @@ local langList={ login={ title="登录/注册", username="用户名", + email="邮箱", password="密码", password2="你觉得应该填啥", + back="返回", }, account={ title="账户", diff --git a/Zframework/widgetList.lua b/Zframework/widgetList.lua index d296bf8c..ad3e5e4e 100644 --- a/Zframework/widgetList.lua +++ b/Zframework/widgetList.lua @@ -668,8 +668,10 @@ local Widgets={ login={ newText({name="title", x=80,y=50,font=70,align="L"}), newTextBox({name="username",x=400,y=200,w=500,h=60}), - newTextBox({name="password",x=400,y=300,w=626,h=60,secret=true}), - newTextBox({name="password2",x=400,y=400,w=626,h=60,secret=true}), + newTextBox({name="email", x=400,y=300,w=626,h=60}), + newTextBox({name="password",x=400,y=400,w=626,h=60,secret=true,regex="[ -~]"}), + newTextBox({name="password2",x=400,y=500,w=626,h=60,secret=true,regex="[ -~]"}), + newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=BACK}), }, account={ newText({name="title", x=80,y=50,font=70,align="L"}), @@ -750,4 +752,16 @@ local Widgets={ newButton({name="back", x=640,y=620,w=200,h=80,font=40,code=BACK}), }, } +local META={ + __index=function(L,k) + for i=1,#L do + if L[i].name==k then + return L[i] + end + end + end +} +for _,v in next,Widgets do + setmetatable(v,META) +end return Widgets \ No newline at end of file diff --git a/main.lua b/main.lua index 68265a58..f43a5e7f 100644 --- a/main.lua +++ b/main.lua @@ -207,7 +207,7 @@ do if S.version~=gameVersion then S.version=gameVersion newVersionLaunch=true - if S.finesseRate<.3*S.piece then + if S.finesseRate<.5*S.piece then S.finesseRate=10*S.finesseRate end FILE.saveData() diff --git a/parts/scenes.lua b/parts/scenes.lua index 0092a896..06398cd2 100644 --- a/parts/scenes.lua +++ b/parts/scenes.lua @@ -2767,6 +2767,38 @@ do--stat end end do--login + function keyDown.login(key) + if key=="return"then + LOG.print("敬请期待!") + LOG.print("Coming Soon!") + -- local user= WIDGET.active.username.value + -- local email=WIDGET.active.email.value + -- local pw= WIDGET.active.password.value + -- local pw2= WIDGET.active.password2.value + -- if #user==0 then + -- LOG.print(text.noUsername)return + -- elseif #pw==0 or #pw2==0 then + -- LOG.print(text.noPassword)return + -- elseif pw~=pw2 then + -- LOG.print(text.diffPassword)return + -- end + -- httpRequest( + -- TICK.httpREQ_register, + -- "api/register", + -- "POST", + -- {["Content-Type"]="application/json"}, + -- json.encode({ + -- user=user, + -- email=email, + -- password=pw, + -- }) + -- ) + elseif key=="escape"then + SCN.back() + else + WIDGET.keyPressed(key) + end + end end do--account end diff --git a/parts/tick.lua b/parts/tick.lua index 8be3b4ae..d5fd8be1 100644 --- a/parts/tick.lua +++ b/parts/tick.lua @@ -86,15 +86,39 @@ function Tick.httpREQ_launch(data) LOG.print(string.gsub(text.versionIsOld,"$1",res.version),"warn") end else - LOG.print("Code error: "..res.code,"warn") + LOG.print(text.netErrorCode..res.code,"warn") end return true elseif err then - LOG.print(text.getNoticeFail..":"..err,"warn") + LOG.print(text.getNoticeFail..": "..err,"warn") return true end data.time=data.time+1 - if data.time==180 then + if data.time==300 then + LOG.print(text.httpTimeout,"message") + return true + end +end +function Tick.httpREQ_register(data) + local res,err=client.poll(data.task) + if res then + if res.code==200 then + res=json.decode(res.body) + if res.status then + LOG.print(text.registerSuccessed) + else + LOG.print(text.registerFailed..": "..res.msg) + end + else + LOG.print(text.netErrorCode..res.code,"warn") + end + return true + elseif err then + LOG.print(text.registerFailed..": "..err,"warn") + return true + end + data.time=data.time+1 + if data.time==360 then LOG.print(text.httpTimeout,"message") return true end