减少密码哈希迭代次数防止把手机卡烂

原来的登录和注册界面改为密码登录和邮箱登录
邮箱登录界面不再分状态,设置密码独立出一个界面
自动登录不再检测本地用过密码登录,第一次邮箱登录不设置密码但存了token也可以
整理代码
This commit is contained in:
MrZ_26
2022-10-23 04:36:19 +08:00
parent f9bbb8fce6
commit d12f8a27e7
23 changed files with 313 additions and 220 deletions

View File

@@ -372,6 +372,7 @@ return{
league="Tech League", league="Tech League",
ffa="FFA", ffa="FFA",
rooms="Rooms", rooms="Rooms",
resetPW="Reset password",
logout="Log out", logout="Log out",
}, },
net_league={ net_league={
@@ -698,21 +699,26 @@ return{
music="BGMs", music="BGMs",
label="label", label="label",
}, },
login={ login_pw={
title="Sign In", title="Sign In",
register="Sign Up", login_mail="Login with E-mail/Sign Up",
email="Email Address", email="Email Address",
password="Password", password="Password",
showEmail="Show Email", showEmail="Show Email",
login="Log In", login="Log In",
}, },
register={ login_mail={
title="Sign Up", title="Sign In/Sign Up",
login="Sign In", login_pw="Password Sign In",
email="Email Address", email="Email Address",
send="Send code", send="Send code",
code="Verification Code", code="Verification Code",
verify="Verify", verify="Verify",
},
reset_password={
title="Reset Password",
send="Send code",
code="Verification Code",
password="Password", password="Password",
password2="Re-enter Password", password2="Re-enter Password",
setPW="Set Password", setPW="Set Password",

View File

@@ -372,6 +372,7 @@ return{
league="Liga Tech", league="Liga Tech",
ffa="FFA", ffa="FFA",
rooms="Salas", rooms="Salas",
-- resetPW="Reset password",
logout="Desconec.", logout="Desconec.",
}, },
net_league={ net_league={
@@ -690,21 +691,26 @@ return{
music="BGMs", music="BGMs",
label="Etiq.", label="Etiq.",
}, },
login={ login_pw={
title="Entrar", title="Entrar",
register="Registrarse", -- login_mail="Login with E-mail/Sign Up",
email="Correo Elec.", email="Correo Elec.",
password="Contraseña", password="Contraseña",
showEmail="Mostrar Correo", showEmail="Mostrar Correo",
login="Entrar", login="Entrar",
}, },
register={ login_mail={
title="Registrarse", title="Entrar/Registrarse",
login="Entrar", -- login_pw="Password Sign In",
email="Correo Elec.", email="Correo Elec.",
-- send="Send code", -- send="Send code",
-- code="Verification Code", -- code="Verification Code",
-- verify="Verify", -- verify="Verify",
},
reset_password={
-- title="Reset Password",
-- send="Send code",
-- code="Verification Code",
password="Contraseña", password="Contraseña",
password2="Repetir Contr.", password2="Repetir Contr.",
-- setPW="Set Password", -- setPW="Set Password",

View File

@@ -335,6 +335,7 @@ return{
-- league="Tech League", -- league="Tech League",
ffa="FFA", ffa="FFA",
rooms="Salons", rooms="Salons",
-- resetPW="Reset password",
-- logout="Log out", -- logout="Log out",
}, },
net_league={ net_league={
@@ -652,21 +653,26 @@ return{
music="Musique", music="Musique",
-- label="label", -- label="label",
}, },
login={ login_pw={
title="Connexion", title="Connexion",
register="Enregistrement", -- login_mail="Login with E-mail/Sign Up",
email="E-mail", email="E-mail",
password="Mot de passe", password="Mot de passe",
-- showEmail="Show Email", -- showEmail="Show Email",
login="Connexion", login="Connexion",
}, },
register={ login_mail={
title="Enregistrement", title="Connexion/Enregistrement",
login="Connexion", -- login_pw="Password Sign In",
email="E-mail", email="E-mail",
-- send="Send code", -- send="Send code",
-- code="Verification Code", -- code="Verification Code",
-- verify="Verify", -- verify="Verify",
},
reset_password={
-- title="Reset Password",
-- send="Send code",
-- code="Verification Code",
password="Mot de passe", password="Mot de passe",
password2="Confirmer le mot de passe", password2="Confirmer le mot de passe",
-- setPW="Set Password", -- setPW="Set Password",

View File

@@ -373,6 +373,7 @@ return{
league="Tech League", league="Tech League",
ffa="FFA", ffa="FFA",
rooms="Ruang-ruang", rooms="Ruang-ruang",
-- resetPW="Reset password",
logout="Log out", logout="Log out",
}, },
net_league={ net_league={
@@ -699,21 +700,26 @@ return{
music="Musik", music="Musik",
label="label", label="label",
}, },
login={ login_pw={
title="Masuk", title="Masuk",
register="Daftar", -- login_mail="Login with E-mail/Sign Up",
email="Alamat Email", email="Alamat Email",
password="Password", password="Password",
showEmail="Tunjukkan Email", showEmail="Tunjukkan Email",
login="Masuk", login="Masuk",
}, },
register={ login_mail={
title="Daftar", title="Masuk/Daftar",
login="Masuk", -- login_pw="Password Sign In",
email="Alamat Email", email="Alamat Email",
-- send="Send code", -- send="Send code",
-- code="Verification Code", -- code="Verification Code",
-- verify="Verify", -- verify="Verify",
},
reset_password={
-- title="Reset Password",
-- send="Send code",
-- code="Verification Code",
password="Password", password="Password",
password2="Ulangi Password", password2="Ulangi Password",
-- setPW="Set Password", -- setPW="Set Password",

View File

@@ -374,6 +374,7 @@ return{
league="テクリーグ", league="テクリーグ",
ffa="自由乱闘戦", ffa="自由乱闘戦",
rooms="ルーム・プライベート戦", rooms="ルーム・プライベート戦",
-- resetPW="Reset password",
logout="ログアウト", logout="ログアウト",
}, },
net_league={ net_league={
@@ -700,21 +701,26 @@ return{
music="", music="",
label="ラベル", label="ラベル",
}, },
login={ login_pw={
title="サインイン", title="サインイン",
register="サインアップ", -- login_mail="Login with E-mail/Sign Up",
email="Eメールアドレス", email="Eメールアドレス",
password="パスワード", password="パスワード",
-- showEmail="Show Email", -- showEmail="Show Email",
login="ログイン", login="ログイン",
}, },
register={ login_mail={
title="サインアップ", title="サインイン/サインアップ",
login="サインイン", -- login_pw="Password Sign In",
email="Eメールアドレス", email="Eメールアドレス",
-- send="Send code", -- send="Send code",
-- code="Verification Code", -- code="Verification Code",
-- verify="Verify", -- verify="Verify",
},
reset_password={
-- title="Reset Password",
-- send="Send code",
-- code="Verification Code",
password="パスワード", password="パスワード",
password2="パスワード(確認)", password2="パスワード(確認)",
-- setPW="Set Password", -- setPW="Set Password",

View File

@@ -361,6 +361,7 @@ return{
-- league="Tech League", -- league="Tech League",
ffa="FFA", ffa="FFA",
rooms="Salas", rooms="Salas",
-- resetPW="Reset password",
-- logout="Log out", -- logout="Log out",
}, },
net_league={ net_league={
@@ -688,21 +689,26 @@ return{
-- music="BGMs", -- music="BGMs",
-- label="label", -- label="label",
}, },
login={ login_pw={
title="Log in", title="Log in",
register="Registrar", -- login_mail="Login with E-mail/Sign Up",
email="Endereço De Email", email="Endereço De Email",
password="Senha", password="Senha",
-- showEmail="Show Email", -- showEmail="Show Email",
login="Log in", login="Log in",
}, },
register={ login_mail={
title="Registrar", title="Log in/Registrar",
login="Log in", -- login_pw="Password Sign In",
email="Endereço De Email", email="Endereço De Email",
-- send="Send code", -- send="Send code",
-- code="Verification Code", -- code="Verification Code",
-- verify="Verify", -- verify="Verify",
},
reset_password={
-- title="Reset Password",
-- send="Send code",
-- code="Verification Code",
password="Senha", password="Senha",
password2="Entre Senha Novamente", password2="Entre Senha Novamente",
-- setPW="Set Password", -- setPW="Set Password",

View File

@@ -166,6 +166,7 @@ return{
league="TL", league="TL",
ffa="FFA", ffa="FFA",
rooms="< >", rooms="< >",
resetPW="R ***",
logout="@_@x", logout="@_@x",
}, },
net_league={ net_league={
@@ -483,21 +484,26 @@ return{
music="~~~", music="~~~",
label="...", label="...",
}, },
login={ login_pw={
title="Log in", title="Log in",
register="Sign up", -- login_mail="Login with E-mail/Sign Up",
email="@", email="@",
password="*", password="*",
showEmail="?", showEmail="?",
login="Log in", login="",
}, },
register={ login_mail={
title="Sign up", title="Log in/Sign up",
login="Log in", login_pw="*** →",
email="@", email="@",
send="", send="",
code="", code="",
verify="!", verify="!",
},
reset_password={
title="R ***",
send="",
code="",
password="*", password="*",
password2="*", password2="*",
setPW="##", setPW="##",

View File

@@ -373,6 +373,7 @@ return{
league="Tech League", league="Tech League",
ffa="FFA", ffa="FFA",
rooms="房间列表", rooms="房间列表",
resetPW="重置密码",
logout="退出登录", logout="退出登录",
}, },
net_league={ net_league={
@@ -698,23 +699,28 @@ return{
path="打开存储目录", path="打开存储目录",
save="用户档案管理", save="用户档案管理",
}, },
login={ login_pw={
title="登录", title="登录",
register="注册", login_mail="邮箱登录/注册",
email="邮箱", email="邮箱",
password="密码", password="密码",
showEmail="显示邮箱", showEmail="显示邮箱",
login="登录", login="登录",
}, },
register={ login_mail={
title="注册", title="登录/注册",
login="登录", login_pw="密码登录",
email="邮箱:", email="邮箱",
send="发送验证码", send="发送验证码",
code="验证码", code="验证码",
verify="验证邮箱", verify="验证邮箱",
password="密码:", },
password2="确认密码:", reset_password={
title="重置密码",
send="发送验证码",
code="验证码",
password="密码",
password2="确认密码",
setPW="设置密码", setPW="设置密码",
}, },
account={ account={

View File

@@ -374,6 +374,7 @@ return{
league="M.TechLeague();", league="M.TechLeague();",
ffa="M.FFA", ffa="M.FFA",
rooms="M.Rooms();", rooms="M.Rooms();",
resetPW="M.ResetPW",
logout="M.Logout();", logout="M.Logout();",
}, },
net_league={ net_league={
@@ -699,21 +700,26 @@ return{
path="OpenPath();", path="OpenPath();",
save="DataManagement();", save="DataManagement();",
}, },
login={ login_pw={
title="LogIn.UI", title="LogIn.UI",
register="Register();", login_mail="Login_mail_sign_up()",
email="Email=", email="Email=",
password="Password=", password="Password=",
showEmail="ShowEmail", showEmail="ShowEmail",
login="Login();", login="Login();",
}, },
register={ login_mail={
title="Register.UI", title="LogIn_Register.UI",
login="Login();", login_pw="Login_pw();",
email="Email=", email="Email=",
send="Send();", send="Send();",
code="V-code=", code="V-code=",
verify="Verify();", verify="Verify();",
},
reset_password={
title="Reset_Password.UI",
send="Send();",
code="V-code=",
password="Password=", password="Password=",
password2="RePassword=", password2="RePassword=",
setPW="SetPassword();", setPW="SetPassword();",

View File

@@ -373,6 +373,7 @@ return{
league="Tech League", league="Tech League",
ffa="FFA", ffa="FFA",
rooms="房間列表", rooms="房間列表",
resetPW="重設密碼",
logout="登出", logout="登出",
}, },
net_league={ net_league={
@@ -698,21 +699,26 @@ return{
path="打開存儲目錄", path="打開存儲目錄",
save="用戶資料管理", save="用戶資料管理",
}, },
login={ login_pw={
title="登錄", title="登錄",
register="註冊", login_mail="電郵登錄/注册",
email="電郵", email="電郵",
password="密碼", password="密碼",
showEmail="顯示郵箱", showEmail="顯示郵箱",
login="登錄", login="登錄",
}, },
register={ login_mail={
title="註冊", title="登錄/註冊",
login="登錄", login_pw="密碼登錄",
email="電郵", email="電郵",
send="發送驗證碼", send="發送驗證碼",
code="驗證碼", code="驗證碼",
verify="驗證郵箱", verify="驗證郵箱",
},
reset_password={
title="重設密碼",
send="發送驗證碼",
code="驗證碼",
password="密碼", password="密碼",
password2="確認密碼", password2="確認密碼",
setPW="設置密碼", setPW="設置密碼",

View File

@@ -132,19 +132,14 @@ function NET.getCode(email)
body={email=email}, body={email=email},
},12.6) },12.6)
if res then if res and res.code==200 then
if res.code==200 then MES.new('info',text.checkEmail,5)
USER.email=email
saveUser()
SCN.fileDropped(2)
MES.new('info',text.checkEmail,5)
end
end end
WAIT.interrupt() WAIT.interrupt()
end) end)
end end
function NET.codeLogin(code) function NET.codeLogin(email,code)
if not TASK.lock('codeLogin') then return end if not TASK.lock('codeLogin') then return end
TASK.new(function() TASK.new(function()
WAIT{ WAIT{
@@ -159,7 +154,7 @@ function NET.codeLogin(code)
pool='codeLogin', pool='codeLogin',
path='/techmino/api/v1/auth/login/email', path='/techmino/api/v1/auth/login/email',
body={ body={
email=USER.email, email=email,
code=code, code=code,
}, },
},6.26) },6.26)
@@ -176,7 +171,7 @@ function NET.codeLogin(code)
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
saveUser() saveUser()
SCN.pop()SCN.push('net_menu') SCN.pop()SCN.push('net_menu')
SCN.fileDropped(3) SCN.go('reset_password','fade')
end end
end end
@@ -194,7 +189,24 @@ function NET.setPW(code,pw)
timeout=6.26, timeout=6.26,
} }
pw=HASH.pbkdf2(HASH.sha3_256,pw,'salt',26000) local salt do
local res=getMsg({
pool='pwLogin',
path='/techmino/api/v1/auth/seed/email',
body={
email=USER.email,
},
},6.26)
if res and res.code==200 then
salt=res.data
else
WAIT.interrupt()
return
end
end
pw=HASH.pbkdf2(HASH.sha3_256,pw,salt,260)
local res=getMsg({ local res=getMsg({
pool='setPW', pool='setPW',
@@ -219,7 +231,6 @@ function NET.setPW(code,pw)
end) end)
end end
function NET.autoLogin() function NET.autoLogin()
if not USER.password then SCN.go('login') return end
if not TASK.lock('autoLogin') then return end if not TASK.lock('autoLogin') then return end
TASK.new(function() TASK.new(function()
WAIT{ WAIT{
@@ -297,7 +308,7 @@ function NET.autoLogin()
end end
end end
SCN.go('login') SCN.go('login_pw')
WAIT.interrupt() WAIT.interrupt()
end) end)
end end
@@ -313,26 +324,45 @@ function NET.pwLogin(email,pw)
} }
TEST.yieldT(.26) TEST.yieldT(.26)
pw=HASH.pbkdf2(HASH.sha3_256,pw,"salt",26000) local salt do
local res=getMsg({
pool='pwLogin',
path='/techmino/api/v1/auth/seed/email',
body={
email=email,
},
},6.26)
local res=getMsg({ if res and res.code==200 then
pool='pwLogin', salt=res.data
path='/techmino/api/v1/auth/login/email', else
body={ WAIT.interrupt()
email=email, return
password=pw, end
}, end
},6.26)
if res then pw=HASH.pbkdf2(HASH.sha3_256,pw,salt,260)
if res.code==200 then
USER.email=email do
USER.password=pw local res=getMsg({
USER.rToken=res.data.refreshToken pool='pwLogin',
USER.aToken=res.data.accessToken path='/techmino/api/v1/auth/login/email',
saveUser() body={
NET.ws_connect() email=email,
SCN.go('net_menu') password=pw,
},
},6.26)
if res then
if res.code==200 then
USER.email=email
USER.password=pw
USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken
saveUser()
NET.ws_connect()
SCN.go('net_menu')
end
end end
end end

View File

@@ -17,6 +17,8 @@ local history,hisPtr={"?"}
local sumode=false local sumode=false
local the_secret=(0xe^2*10)..(2*0xb) local the_secret=(0xe^2*10)..(2*0xb)
local scene={}
local commands={} do local commands={} do
--[[ --[[
format of elements in table 'commands': format of elements in table 'commands':
@@ -708,7 +710,7 @@ local commands={} do
outputBox.h=500 outputBox.h=500
local button=WIDGET.newButton{name='bye',x=640,y=615,w=426,h=100,code=function() local button=WIDGET.newButton{name='bye',x=640,y=615,w=426,h=100,code=function()
TASK.new(function() TASK.new(function()
WIDGET.active.bye.hide=true scene.widgetList.bye.hide=true
for _=1,30 do coroutine.yield() end for _=1,30 do coroutine.yield() end
log{C.R,"Deleting all data in 10..."}SFX.play('ready')SFX.play('clear_1')TEST.yieldN(60) log{C.R,"Deleting all data in 10..."}SFX.play('ready')SFX.play('clear_1')TEST.yieldN(60)
log{C.R,"Deleting all data in 9..."}SFX.play('ready')SFX.play('clear_1')TEST.yieldN(60) log{C.R,"Deleting all data in 9..."}SFX.play('ready')SFX.play('clear_1')TEST.yieldN(60)
@@ -726,7 +728,7 @@ local commands={} do
end) end)
end} end}
button:setObject("Techmino is fun. Bye.") button:setObject("Techmino is fun. Bye.")
ins(WIDGET.active,button) ins(scene.widgetList,button)
else else
log"Are you sure you want to reset everything?" log"Are you sure you want to reset everything?"
log"This will delete EVERYTHING in your saved game data, including but not limited to:" log"This will delete EVERYTHING in your saved game data, including but not limited to:"
@@ -1012,8 +1014,6 @@ userG.the_key=first_key
local scene={}
function scene.sceneInit() function scene.sceneInit()
WIDGET.focus(inputBox) WIDGET.focus(inputBox)
BG.set('none') BG.set('none')

View File

@@ -72,7 +72,7 @@ function scene.keyDown(key)
local l={1,2,3,4,5,6,7} local l={1,2,3,4,5,6,7}
repeat scene.keyDown(rem(l,math.random(#l))) until not l[1] repeat scene.keyDown(rem(l,math.random(#l))) until not l[1]
elseif key=='tab' then elseif key=='tab' then
WIDGET.active.sequence:scroll(kb.isDown('lshift','rshift') and -1 or 1) scene.widgetList.sequence:scroll(kb.isDown('lshift','rshift') and -1 or 1)
elseif key=='c' and kb.isDown('lctrl','rctrl') or key=='cC' then elseif key=='c' and kb.isDown('lctrl','rctrl') or key=='cC' then
if #BAG>0 then if #BAG>0 then
sys.setClipboardText("Techmino SEQ:"..DATA.copySequence()) sys.setClipboardText("Techmino SEQ:"..DATA.copySequence())

View File

@@ -18,24 +18,24 @@ local repRateStrings={[0]="pause",[.125]="0.125x",[.5]="0.5x",[1]="1x",[2]="2x",
local scene={} local scene={}
local function _updateMenuButtons() local function _updateMenuButtons()
WIDGET.active.restart.hide=replaying scene.widgetList.restart.hide=replaying
local pos=(GAME.tasUsed or replaying) and 'right' or SETTING.menuPos local pos=(GAME.tasUsed or replaying) and 'right' or SETTING.menuPos
modeTextWidK=math.min(280/TEXTOBJ.modeName:getWidth(),1) modeTextWidK=math.min(280/TEXTOBJ.modeName:getWidth(),1)
if GAME.replaying then if GAME.replaying then
WIDGET.active.pause.x=1195 scene.widgetList.pause.x=1195
modeTextPos=1185-TEXTOBJ.modeName:getWidth()*modeTextWidK modeTextPos=1185-TEXTOBJ.modeName:getWidth()*modeTextWidK
elseif pos=='right' then elseif pos=='right' then
WIDGET.active.restart.x=1125 scene.widgetList.restart.x=1125
WIDGET.active.pause.x=1195 scene.widgetList.pause.x=1195
modeTextPos=1115-TEXTOBJ.modeName:getWidth()*modeTextWidK modeTextPos=1115-TEXTOBJ.modeName:getWidth()*modeTextWidK
elseif pos=='middle' then elseif pos=='middle' then
WIDGET.active.restart.x=360 scene.widgetList.restart.x=360
WIDGET.active.pause.x=860 scene.widgetList.pause.x=860
modeTextPos=940 modeTextPos=940
elseif pos=='left' then elseif pos=='left' then
WIDGET.active.restart.x=120 scene.widgetList.restart.x=120
WIDGET.active.pause.x=190 scene.widgetList.pause.x=190
modeTextPos=1200-TEXTOBJ.modeName:getWidth()*modeTextWidK modeTextPos=1200-TEXTOBJ.modeName:getWidth()*modeTextWidK
end end
end end

View File

@@ -2,7 +2,7 @@ local scene={}
function scene.sceneInit() function scene.sceneInit()
BG.set('cubes') BG.set('cubes')
WIDGET.active.texts:setTexts(require"parts.updateLog":split("\n")) scene.widgetList.texts:setTexts(require"parts.updateLog":split("\n"))
end end
function scene.wheelMoved(_,y) function scene.wheelMoved(_,y)
@@ -10,13 +10,13 @@ function scene.wheelMoved(_,y)
end end
function scene.keyDown(key) function scene.keyDown(key)
if key=='up' then if key=='up' then
WIDGET.active.texts:scroll(-5) scene.widgetList.texts:scroll(-5)
elseif key=='down' then elseif key=='down' then
WIDGET.active.texts:scroll(5) scene.widgetList.texts:scroll(5)
elseif key=='pageup' then elseif key=='pageup' then
WIDGET.active.texts:scroll(-20) scene.widgetList.texts:scroll(-20)
elseif key=='pagedown' then elseif key=='pagedown' then
WIDGET.active.texts:scroll(20) scene.widgetList.texts:scroll(20)
elseif key=='escape' then elseif key=='escape' then
SCN.back() SCN.back()
end end

View File

@@ -3,9 +3,9 @@ function scene.sceneInit()
BG.set('cubes') BG.set('cubes')
local fileData=love.filesystem.read("legals.md") local fileData=love.filesystem.read("legals.md")
if fileData then if fileData then
WIDGET.active.texts:setTexts(fileData:split('\n')) scene.widgetList.texts:setTexts(fileData:split('\n'))
else else
WIDGET.active.texts:setTexts{"[legals.md not found]"} scene.widgetList.texts:setTexts{"[legals.md not found]"}
end end
end end
@@ -14,13 +14,13 @@ function scene.wheelMoved(_,y)
end end
function scene.keyDown(key) function scene.keyDown(key)
if key=='up' then if key=='up' then
WIDGET.active.texts:scroll(-5) scene.widgetList.texts:scroll(-5)
elseif key=='down' then elseif key=='down' then
WIDGET.active.texts:scroll(5) scene.widgetList.texts:scroll(5)
elseif key=='pageup' then elseif key=='pageup' then
WIDGET.active.texts:scroll(-20) scene.widgetList.texts:scroll(-20)
elseif key=='pagedown' then elseif key=='pagedown' then
WIDGET.active.texts:scroll(20) scene.widgetList.texts:scroll(20)
elseif key=='escape' then elseif key=='escape' then
SCN.back() SCN.back()
end end

View File

@@ -0,0 +1,54 @@
local scene={}
local function _getCode()
local email=scene.widgetList.email:getText()
if not STRING.simpEmailCheck(email) then
MES.new('error',text.wrongEmail)
else
USER.email=email
NET.getCode(email)
end
end
local function _codeLogin()
local code=scene.widgetList.code:getText():upper()
if #code~=8 then
MES.new('error',text.wrongCode)
else
NET.codeLogin(USER.email,code)
end
end
function scene.sceneInit()
scene.widgetList.email:setText(USER.email or "")
scene.widgetList.code:clear()
end
function scene.keyDown(key,rep)
if key=='escape' and not rep then
SCN.back()
elseif key=='return' then
if #scene.widgetList.code:getText():upper()==0 then
_getCode()
else
_codeLogin()
end
else
return true
end
end
scene.widgetList={
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
WIDGET.newButton{name='login_pw', x=1080,y=100,w=260,h=80,color='lY',code=function() SCN.swapTo('login_pw','swipeR') end},
WIDGET.newInputBox{name='email', x=380, y=200,w=626,h=60,limit=128},
WIDGET.newKey{name='send', x=640, y=330,w=300,h=80,font=40,code=_getCode},
WIDGET.newInputBox{name='code', x=380, y=400,w=626 ,h=60,limit=8},
WIDGET.newKey{name='verify', x=640, y=530,w=300,h=80,font=40,code=_codeLogin},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
}
return scene

View File

@@ -28,13 +28,13 @@ function scene.keyDown(key,rep)
end end
scene.widgetList={ scene.widgetList={
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'}, WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
WIDGET.newButton{name='register', x=1140,y=100,w=170,h=80,color='lY',code=function() SCN.swapTo('register','swipeR') end}, WIDGET.newButton{name='login_mail',x=1080,y=100,w=260,h=80,color='lY',code=function() SCN.swapTo('login_mail','swipeL') end},
emailBox, emailBox,
passwordBox, passwordBox,
WIDGET.newSwitch{name='showEmail',x=550, y=420,disp=function() return showEmail end,code=function() showEmail=not showEmail emailBox.secret=not showEmail end}, WIDGET.newSwitch{name='showEmail', x=550, y=420,disp=function() return showEmail end,code=function() showEmail=not showEmail emailBox.secret=not showEmail end},
WIDGET.newKey{name='login', x=1140,y=540,w=170,h=80,font=40,code=pressKey'return'}, WIDGET.newKey{name='login', x=1140,y=540,w=170,h=80,font=40,code=pressKey'return'},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
} }
return scene return scene

View File

@@ -4,9 +4,9 @@ function scene.sceneInit()
BG.set('cubes') BG.set('cubes')
local fileData=FILE.load('parts/language/manual_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or 'en')..'.txt','-string') local fileData=FILE.load('parts/language/manual_'..(SETTING.locale:find'zh' and 'zh' or SETTING.locale:find'ja' and 'ja' or 'en')..'.txt','-string')
if fileData then if fileData then
WIDGET.active.texts:setTexts(fileData:split('\n')) scene.widgetList.texts:setTexts(fileData:split('\n'))
else else
WIDGET.active.texts:setTexts{"[manual file not found]"} scene.widgetList.texts:setTexts{"[manual file not found]"}
end end
end end
@@ -16,13 +16,13 @@ function scene.wheelMoved(_,y)
end end
function scene.keyDown(key) function scene.keyDown(key)
if key=='up' then if key=='up' then
WIDGET.active.texts:scroll(-5) scene.widgetList.texts:scroll(-5)
elseif key=='down' then elseif key=='down' then
WIDGET.active.texts:scroll(5) scene.widgetList.texts:scroll(5)
elseif key=='pageup' then elseif key=='pageup' then
WIDGET.active.texts:scroll(-20) scene.widgetList.texts:scroll(-20)
elseif key=='pagedown' then elseif key=='pagedown' then
WIDGET.active.texts:scroll(20) scene.widgetList.texts:scroll(20)
elseif key=='escape' then elseif key=='escape' then
SCN.back() SCN.back()
end end

View File

@@ -17,6 +17,9 @@ scene.widgetList={
WIDGET.newButton{name='league',x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'}, WIDGET.newButton{name='league',x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'},
WIDGET.newButton{name='ffa', x=640, y=360,w=350,h=120,font=40,color='D',code=function() MES.new('warn',text.notFinished)--[[NET.enterRoom({name='ffa'})]] end}, WIDGET.newButton{name='ffa', x=640, y=360,w=350,h=120,font=40,color='D',code=function() MES.new('warn',text.notFinished)--[[NET.enterRoom({name='ffa'})]] end},
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'}, WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
WIDGET.newButton{name='resetPW',x=680, y=40,w=180,h=60,color='dG',code=function()
SCN.go('reset_password','none')
end},
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR', WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
code=function() code=function()
if tryBack() then if tryBack() then

View File

@@ -1,98 +0,0 @@
local scene={}
local state
local code
local function _getCode()
local email=WIDGET.active.email:getText()
if not STRING.simpEmailCheck(email) then
MES.new('error',text.wrongEmail)
else
NET.getCode(email)
end
end
local function _codeLogin()
code=WIDGET.active.code:getText():upper()
if #code~=8 then
MES.new('error',text.wrongCode)
else
NET.codeLogin(code)
end
end
local function _setPW()
local password= WIDGET.active.password:getText()
local password2=WIDGET.active.password2:getText()
if #password==0 or #password2==0 then
MES.new('error',text.noPassword)
elseif password~=password2 then
MES.new('error',text.diffPassword)
else
NET.setPW(code,password)
end
end
function scene.sceneInit()
state=SCN.args[1] or 1
scene.fileDropped(state)
end
function scene.keyDown(key,rep)
if key=='escape' and not rep then
if state==2 then
scene.fileDropped(state-1)
else
SCN.back()
end
elseif key=='return' then
if state==1 then
_getCode()
elseif state==2 then
_codeLogin()
elseif state==3 then
_setPW()
end
else
return true
end
end
function scene.fileDropped(arg)-- Not designed for this, but it works and no side effects
if type(arg)~='number' then return end
state=arg
scene.widgetList.email. hide=arg~=1
scene.widgetList.send. hide=arg~=1
scene.widgetList.code. hide=arg~=2
scene.widgetList.verify. hide=arg~=2
scene.widgetList.password. hide=arg~=3
scene.widgetList.password2. hide=arg~=3
scene.widgetList.setPW. hide=arg~=3
if arg==1 then
scene.widgetList.email:setText(USER.email or "")
elseif arg==2 then
scene.widgetList.code:clear()
elseif arg==3 then
scene.widgetList.password:clear()
scene.widgetList.password2:clear()
end
end
scene.widgetList={
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='lY',code=function() SCN.swapTo('login','swipeL') end},
WIDGET.newInputBox{name='email', x=380, y=300,w=626,h=60,limit=128},
WIDGET.newKey{name='send', x=640, y=430,w=250,h=80,font=40,code=_getCode},
WIDGET.newInputBox{name='code', x=380, y=300,w=626,h=60,limit=8},
WIDGET.newKey{name='verify', x=640, y=430,w=300,h=80,font=40,code=_codeLogin},
WIDGET.newInputBox{name='password', x=380, y=250,w=626,h=60,secret=true,regex="[ -~]",limit=64},
WIDGET.newInputBox{name='password2',x=380, y=350,w=626,h=60,secret=true,regex="[ -~]",limit=64},
WIDGET.newKey{name='setPW', x=640, y=480,w=350,h=80,font=40,code=_setPW},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
}
return scene

View File

@@ -0,0 +1,44 @@
local scene={}
local function _setPW()
local code=scene.widgetList.code:getText():upper()
local password= scene.widgetList.password:getText()
local password2=scene.widgetList.password2:getText()
if #code~=8 then
MES.new('error',text.wrongCode)
elseif #password==0 or #password2==0 then
MES.new('error',text.noPassword)
elseif password~=password2 then
MES.new('error',text.diffPassword)
else
NET.setPW(code,password)
end
end
function scene.keyDown(key,rep)
if key=='escape' and not rep then
SCN.back()
elseif key=='return' then
if #scene.widgetList.code:getText()==0 then
_setPW()
else
NET.getCode(USER.email)
end
else
return true
end
end
scene.widgetList={
WIDGET.newText{name='title', x=80, y=50,font=70,align='L'},
WIDGET.newKey{name='send', x=640, y=300,w=300,h=80,font=40,code=function() NET.getCode(USER.email) end},
WIDGET.newInputBox{name='code', x=380, y=170,w=626,h=60,limit=8},
WIDGET.newInputBox{name='password', x=380, y=370,w=626,h=60,secret=true,regex="[ -~]",limit=64},
WIDGET.newInputBox{name='password2',x=380, y=470,w=626,h=60,secret=true,regex="[ -~]",limit=64},
WIDGET.newKey{name='setPW', x=640, y=600,w=350,h=80,font=40,code=_setPW},
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=pressKey'escape'},
}
return scene

View File

@@ -12,8 +12,8 @@ function scene.sceneInit()
last1,last2=0,0 last1,last2=0,0
sfxPack=SETTING.sfxPack sfxPack=SETTING.sfxPack
vocPack=SETTING.vocPack vocPack=SETTING.vocPack
WIDGET.active.sfxPack:reset() scene.widgetList.sfxPack:reset()
WIDGET.active.vocPack:reset() scene.widgetList.vocPack:reset()
BG.set() BG.set()
end end
function scene.sceneBack() function scene.sceneBack()