From 1d2a4437e385c77a7b40390302e6f1ab8eaaf2d8 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 23 Nov 2020 22:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=92=8C=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/language/lang_en.lua | 11 ++++++--- parts/language/lang_fr.lua | 11 ++++++--- parts/language/lang_sp.lua | 11 ++++++--- parts/language/lang_symbol.lua | 10 ++++++-- parts/language/lang_yygq.lua | 3 +-- parts/language/lang_zh.lua | 11 ++++++--- parts/scenes/login.lua | 21 ++++------------- parts/scenes/main.lua | 2 +- parts/scenes/register.lua | 43 ++++++++++++++++++++++++++++++++++ 9 files changed, 89 insertions(+), 34 deletions(-) create mode 100644 parts/scenes/register.lua diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index 8272b2c3..9b829d3d 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -80,7 +80,6 @@ return{ jsonError="Json error", noUsername="Please enter your username", - wrongCode="Please enter invitation code", wrongEmail="Wrong email address", noPassword="Please enter your password", diffPassword="Passwords don't match", @@ -465,10 +464,16 @@ return{ down="↓", }, login={ - title="Log in / Sign up", + title="Log in", + register="Sign up", + username="Username", + password="Password", + }, + register={ + title="Sign up", + login="Log in", username="Username", email="Email address", - code="Invitation Code", password="Password", password2="Reenter password", }, diff --git a/parts/language/lang_fr.lua b/parts/language/lang_fr.lua index b09f78c6..f0b4db08 100644 --- a/parts/language/lang_fr.lua +++ b/parts/language/lang_fr.lua @@ -83,7 +83,6 @@ return{ jsonError="Erreur json", noUsername="Entrez votre nom d'utilisateur", - wrongCode="Veuillez entrer un code d'invitation", wrongEmail="Mauvaise adresse email", noPassword="Entrez votre mot de passe", diffPassword="Les mots de passe ne se correspondent pas", @@ -463,10 +462,16 @@ return{ down="↓", }, login={ - title="Connexion / Enregistrement", + title="Connexion", + register="Enregistrement", + username="Nom d'utilisateur", + password="Mot de passe", + }, + register={ + title="Enregistrement", + login="Connexion", username="Nom d'utilisateur", email="E-mail", - code="Code d'invitation", password="Mot de passe", password2="Confirmer le mot de passe", }, diff --git a/parts/language/lang_sp.lua b/parts/language/lang_sp.lua index ab4e0ef1..e628f9c5 100644 --- a/parts/language/lang_sp.lua +++ b/parts/language/lang_sp.lua @@ -83,7 +83,6 @@ return{ noUsername="Por favor ingresa un nombre de usuario", - -- wrongCode="Please enter invitation code", -- wrongEmail="Wrong email address", noPassword="Por favor ingresa una contraseña", diffPassword="Las contraseñas no coinciden", @@ -467,10 +466,16 @@ return{ down="↓", }, login={ - title="Entrar/Registrarse", + title="Entrar", + register="Registrarse", + username="Nombre de Usuario", + password="Contraseña", + }, + register={ + title="Registrarse", + login="Entrar", username="Nombre de Usuario", email="Correo Elec.", - code="Código de Invit.", password="Contraseña", password2="Repetir Contr.", }, diff --git a/parts/language/lang_symbol.lua b/parts/language/lang_symbol.lua index 4a640e52..cb907988 100644 --- a/parts/language/lang_symbol.lua +++ b/parts/language/lang_symbol.lua @@ -399,10 +399,16 @@ return{ down="↓", }, login={ - title="Log in / Sign up", + title="Log in", + register="Sign up", + username="#", + password="*", + }, + register={ + title="Sign up", + login="Log in", username="#", email="@", - code="%", password="*", password2="*", }, diff --git a/parts/language/lang_yygq.lua b/parts/language/lang_yygq.lua index 37d4bdd9..3aca2e0c 100644 --- a/parts/language/lang_yygq.lua +++ b/parts/language/lang_yygq.lua @@ -34,7 +34,6 @@ return{ finesse_fc="全连", noUsername="别闹。", - wrongCode="有人邀请你注册了?", wrongEmail="别乱输。", noPassword="注册会不会?", diffPassword="字不认识?", @@ -114,7 +113,7 @@ return{ his="黑历史", qq="QQ对线", }, - login={ + register={ password2="你觉得应该填啥", }, sound={ diff --git a/parts/language/lang_zh.lua b/parts/language/lang_zh.lua index bfe762fa..f6070da8 100644 --- a/parts/language/lang_zh.lua +++ b/parts/language/lang_zh.lua @@ -81,7 +81,6 @@ return{ jsonError="json错误", noUsername="请填写用户名", - wrongCode="请填写邀请码", wrongEmail="邮箱格式错误", noPassword="请填写密码", diffPassword="两次密码不一致", @@ -489,10 +488,16 @@ return{ save="用户档案管理", }, login={ - title="登录/注册", + title="登录", + register="注册", + username="用户名", + password="密码", + }, + register={ + title="注册", + login="登录", username="用户名", email="邮箱", - code="邀请码", password="密码", password2="确认密码", }, diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index 7b867a7e..1ffe47f7 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -1,26 +1,15 @@ function keyDown.login(key) if key=="return"then local username= WIDGET.active.username.value - local email= WIDGET.active.email.value - local code= WIDGET.active.code.value local password= WIDGET.active.password.value - local password2=WIDGET.active.password2.value if #username==0 then LOG.print(text.noUsername)return - elseif not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$")then - LOG.print(text.wrongEmail)return - elseif #code~=12 then - LOG.print(text.wrongCode)return - elseif #password==0 or #password2==0 then + elseif #password==0 then LOG.print(text.noPassword)return - elseif password~=password2 then - LOG.print(text.diffPassword)return end local data=urlencode.encode{ username=username, - email=email, password=password, - code=code, } httpRequest( TICK.httpREQ_register, @@ -38,10 +27,8 @@ end WIDGET.init("login",{ WIDGET.newText{name="title", x=80, y=50,font=70,align="L"}, - WIDGET.newTextBox{name="username", x=380, y=160,w=500,h=60,regex="[0-9A-Za-z_]"}, - WIDGET.newTextBox{name="email", x=380, y=260,w=626,h=60,regex="[0-9A-Za-z@._-]"}, - WIDGET.newTextBox{name="code", x=380, y=360,w=626,h=60,regex="[0-9A-Za-z]"}, - WIDGET.newTextBox{name="password", x=380, y=460,w=626,h=60,secret=true,regex="[ -~]"}, - WIDGET.newTextBox{name="password2", x=380, y=560,w=626,h=60,secret=true,regex="[ -~]"}, + WIDGET.newButton{name="register", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("register","swipeR")end}, + WIDGET.newTextBox{name="username", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]"}, + WIDGET.newTextBox{name="password", x=380, y=300,w=626,h=60,secret=true,regex="[ -~]"}, WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}, }) \ No newline at end of file diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 15174934..263ad26a 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -35,7 +35,7 @@ end WIDGET.init("main",{ WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")}, - WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=WIDGET.lnk_goScene(LOGIN and"netgame"or"login")}, + WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=WIDGET.lnk_goScene(LOGIN and"netgame"or"register")}, WIDGET.newButton{name="custom", x=590,y=220,w=200,h=140,color="lBlue", font=40,code=WIDGET.lnk_goScene("customGame")}, WIDGET.newButton{name="setting",x=150,y=380,w=200,h=140,color="lOrange",font=40,code=WIDGET.lnk_goScene("setting_game")}, WIDGET.newButton{name="stat", x=370,y=380,w=200,h=140,color="lGreen", font=40,code=WIDGET.lnk_goScene("stat")}, diff --git a/parts/scenes/register.lua b/parts/scenes/register.lua new file mode 100644 index 00000000..9c3ee346 --- /dev/null +++ b/parts/scenes/register.lua @@ -0,0 +1,43 @@ +function keyDown.register(key) + if key=="return"then + local username= WIDGET.active.username.value + local email= WIDGET.active.email.value + local password= WIDGET.active.password.value + local password2=WIDGET.active.password2.value + if #username==0 then + LOG.print(text.noUsername)return + elseif not email:match("^[a-zA-Z0-9_]+@[a-zA-Z0-9_-]+%.[a-zA-Z0-9_]+$")then + LOG.print(text.wrongEmail)return + elseif #password==0 or #password2==0 then + LOG.print(text.noPassword)return + elseif password~=password2 then + LOG.print(text.diffPassword)return + end + local data=urlencode.encode{ + username=username, + email=email, + password=password, + } + httpRequest( + TICK.httpREQ_register, + "api/account/register", + "POST", + {["Content-Type"]="application/x-www-form-urlencoded"}, + data + ) + elseif key=="escape"then + SCN.back() + else + WIDGET.keyPressed(key) + end +end + +WIDGET.init("register",{ + WIDGET.newText{name="title", x=80, y=50,font=70,align="L"}, + WIDGET.newButton{name="login", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("login","swipeL")end}, + WIDGET.newTextBox{name="username", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]"}, + WIDGET.newTextBox{name="email", x=380, y=300,w=626,h=60,regex="[0-9A-Za-z@._-]"}, + WIDGET.newTextBox{name="password", x=380, y=400,w=626,h=60,secret=true,regex="[ -~]"}, + WIDGET.newTextBox{name="password2", x=380, y=500,w=626,h=60,secret=true,regex="[ -~]"}, + WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}, +}) \ No newline at end of file