【警告】联网不能用,不要随便试
联网重制ing,提交一下做个中继点
This commit is contained in:
Submodule Zframework updated: 5bd04c8ce2...2ba3ffea4c
6
main.lua
6
main.lua
@@ -546,7 +546,7 @@ do
|
||||
STAT.version=VERSION.code
|
||||
needSave=true
|
||||
end
|
||||
SETTING.appLock,SETTING.dataSaving,SETTING.swap=nil
|
||||
SETTING.appLock,SETTING.dataSaving,SETTING.swap,SETTING.autoLogin=nil
|
||||
if not SETTING.VKSkin then SETTING.VKSkin=1 end
|
||||
for _,v in next,SETTING.skin do if v<1 or v>17 then v=17 end end
|
||||
if not RSlist[SETTING.RS]then SETTING.RS='TRS'end
|
||||
@@ -692,4 +692,6 @@ if TABLE.find(arg,'--test')then
|
||||
love.event.quit(1)
|
||||
end)
|
||||
end
|
||||
WS.switchHost('101.43.110.22','10026','/tech/socket/v1')
|
||||
WS.switchHost('cafuuchino1.3322.org','10026','/tech/socket/v1')
|
||||
HTTP.setHost("cafuuchino1.3322.org:10026")
|
||||
HTTP.setThreadCount(1)
|
||||
|
||||
@@ -873,11 +873,6 @@ do--function drawSelfProfile()
|
||||
end
|
||||
gc_draw(textObj,-82,26,nil,scaleK,nil,width,offY)
|
||||
|
||||
--Draw lv. & xp.
|
||||
gc_draw(lvIcon[USER.lv],-295,50)
|
||||
gc_line(-270,55,-80,55,-80,70,-270,70)
|
||||
gc_rectangle('fill',-210,55,150*USER.xp/USER.lv/USER.lv,15)
|
||||
|
||||
gc_pop()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -575,12 +575,10 @@ do--Game data tables
|
||||
end
|
||||
do--Userdata tables
|
||||
USER={--User infomation
|
||||
--Network infos
|
||||
uid=false,
|
||||
authToken=false,
|
||||
|
||||
--Local data
|
||||
xp=0,lv=1,
|
||||
email=false,
|
||||
password=false,
|
||||
rToken=false,
|
||||
aToken=false,
|
||||
}
|
||||
SETTING={--Settings
|
||||
--Tuning
|
||||
@@ -598,7 +596,6 @@ do--Userdata tables
|
||||
menuPos='middle',
|
||||
fine=false,
|
||||
autoSave=false,
|
||||
autoLogin=true,
|
||||
simpMode=false,
|
||||
sysCursor=true,
|
||||
maxFPS=60,
|
||||
|
||||
@@ -322,6 +322,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Support the author",
|
||||
WidgetText={
|
||||
@@ -437,7 +438,6 @@ return{
|
||||
sysCursor="Use System Cursor",
|
||||
autoPause="Pause When Unfocused",
|
||||
autoSave="Auto-save New Records",
|
||||
autoLogin="Auto-login on Start",
|
||||
simpMode="Simplistic Mode",
|
||||
},
|
||||
setting_video={
|
||||
@@ -694,18 +694,18 @@ return{
|
||||
email="Email Address",
|
||||
password="Password",
|
||||
showEmail="Show Email",
|
||||
keepPW="Remember me",
|
||||
login="Log In",
|
||||
},
|
||||
register={
|
||||
title="Sign Up",
|
||||
login="Sign In",
|
||||
username="Username",
|
||||
email="Email Address",
|
||||
send="Send code",
|
||||
code="Verification Code",
|
||||
verify="Verify",
|
||||
password="Password",
|
||||
password2="Re-enter Password",
|
||||
register="Sign Up",
|
||||
registering="Waiting for response…",
|
||||
setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="Account",
|
||||
|
||||
@@ -322,6 +322,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Apoyen al Autor",
|
||||
WidgetText={
|
||||
@@ -437,7 +438,6 @@ return{
|
||||
sysCursor="Usar cursor del sistema",
|
||||
autoPause="Pausar cuando la ventana no está enfocada",
|
||||
autoSave="Autograbar Récords",
|
||||
autoLogin="Autologueo al Iniciar",
|
||||
simpMode="Modo Sencillo",
|
||||
},
|
||||
setting_video={
|
||||
@@ -686,18 +686,18 @@ return{
|
||||
email="Correo Elec.",
|
||||
password="Contraseña",
|
||||
showEmail="Mostrar Correo",
|
||||
keepPW="Recordar credenciales",
|
||||
login="Entrar",
|
||||
},
|
||||
register={
|
||||
title="Registrarse",
|
||||
login="Entrar",
|
||||
username="Nombre de Usuario",
|
||||
email="Correo Elec.",
|
||||
-- send="Send code",
|
||||
-- code="Verification Code",
|
||||
-- verify="Verify",
|
||||
password="Contraseña",
|
||||
password2="Repetir Contr.",
|
||||
register="Registrarse",
|
||||
registering="Esperando respuesta...",
|
||||
-- setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="Cuenta",
|
||||
|
||||
@@ -289,6 +289,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Aider le créateur",
|
||||
WidgetText={
|
||||
@@ -400,7 +401,6 @@ return{
|
||||
-- sysCursor="Use system cursor",
|
||||
autoPause="Mettre en pause en cas de perte de focus",
|
||||
-- autoSave="Auto save new-best",
|
||||
-- autoLogin="Auto Login on Start",
|
||||
-- simpMode="Simple mode",
|
||||
},
|
||||
setting_video={
|
||||
@@ -648,18 +648,18 @@ return{
|
||||
email="E-mail",
|
||||
password="Mot de passe",
|
||||
-- showEmail="Show Email",
|
||||
-- keepPW="Remember me",
|
||||
login="Connexion",
|
||||
},
|
||||
register={
|
||||
title="Enregistrement",
|
||||
login="Connexion",
|
||||
username="Nom d'utilisateur",
|
||||
email="E-mail",
|
||||
-- send="Send code",
|
||||
-- code="Verification Code",
|
||||
-- verify="Verify",
|
||||
password="Mot de passe",
|
||||
password2="Confirmer le mot de passe",
|
||||
register="Enregistrement",
|
||||
-- registering="Waiting for response...",
|
||||
-- setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="Compte",
|
||||
|
||||
@@ -323,6 +323,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Dukung pencipta",
|
||||
WidgetText={
|
||||
@@ -438,7 +439,6 @@ return{
|
||||
sysCursor="Guna Mouse Bawaan",
|
||||
autoPause="Jeda Jika Tidak Difokus",
|
||||
autoSave="Simpan Rekor Otomatis",
|
||||
autoLogin="Auto-login Saat Membuka",
|
||||
simpMode="Mode Sederhana",
|
||||
},
|
||||
setting_video={
|
||||
@@ -695,18 +695,18 @@ return{
|
||||
email="Alamat Email",
|
||||
password="Password",
|
||||
showEmail="Tunjukkan Email",
|
||||
keepPW="Ingat Saya",
|
||||
login="Masuk",
|
||||
},
|
||||
register={
|
||||
title="Daftar",
|
||||
login="Masuk",
|
||||
username="Username",
|
||||
email="Alamat Email",
|
||||
-- send="Send code",
|
||||
-- code="Verification Code",
|
||||
-- verify="Verify",
|
||||
password="Password",
|
||||
password2="Ulangi Password",
|
||||
register="Daftar",
|
||||
registering="Menunggu respon…",
|
||||
-- setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="Akun",
|
||||
|
||||
@@ -324,6 +324,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Support the Author",
|
||||
WidgetText={
|
||||
@@ -439,7 +440,6 @@ return{
|
||||
sysCursor="システムカーソル",
|
||||
autoPause="ゲーム中断時のオートポーズ",
|
||||
autoSave="最高得点を更新したときオートセーブ",
|
||||
autoLogin="オートログイン",
|
||||
simpMode="シンプルなホーム画面",
|
||||
},
|
||||
setting_video={
|
||||
@@ -696,18 +696,18 @@ return{
|
||||
email="Eメールアドレス",
|
||||
password="パスワード",
|
||||
-- showEmail="Show Email",
|
||||
keepPW="常にログイン",
|
||||
login="ログイン",
|
||||
},
|
||||
register={
|
||||
title="サインアップ",
|
||||
login="サインイン",
|
||||
username="ユーザーネーム",
|
||||
email="Eメールアドレス",
|
||||
-- send="Send code",
|
||||
-- code="Verification Code",
|
||||
-- verify="Verify",
|
||||
password="パスワード",
|
||||
password2="パスワード(確認)",
|
||||
register="これで登録する",
|
||||
registering="応答待機中...",
|
||||
-- setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="アカウント",
|
||||
|
||||
@@ -311,6 +311,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="Support author",
|
||||
WidgetText={
|
||||
@@ -426,7 +427,6 @@ return{
|
||||
-- sysCursor="Use system cursor",
|
||||
autoPause="Pausar quando foco for perco",
|
||||
-- autoSave="Auto save new-best",
|
||||
-- autoLogin="Auto Login on Start",
|
||||
-- simpMode="Simple mode",
|
||||
},
|
||||
setting_video={
|
||||
@@ -684,18 +684,18 @@ return{
|
||||
email="Endereço De Email",
|
||||
password="Senha",
|
||||
-- showEmail="Show Email",
|
||||
-- keepPW="Remember me",
|
||||
login="Log in",
|
||||
},
|
||||
register={
|
||||
title="Registrar",
|
||||
login="Log in",
|
||||
username="Nome De Usuário",
|
||||
email="Endereço De Email",
|
||||
-- send="Send code",
|
||||
-- code="Verification Code",
|
||||
-- verify="Verify",
|
||||
password="Senha",
|
||||
password2="Entre Senha Novamente",
|
||||
register="Registrar",
|
||||
-- registering="Waiting for response...",
|
||||
-- setPW="Set Password",
|
||||
},
|
||||
account={
|
||||
title="Conta",
|
||||
|
||||
@@ -242,7 +242,6 @@ return{
|
||||
sysCursor="?→*",
|
||||
autoPause="A||",
|
||||
autoSave="!!!>%",
|
||||
autoLogin="#Log in#",
|
||||
simpMode=".",
|
||||
},
|
||||
setting_video={
|
||||
@@ -490,18 +489,18 @@ return{
|
||||
email="@",
|
||||
password="*",
|
||||
showEmail="?",
|
||||
keepPW="!",
|
||||
login="Log in",
|
||||
},
|
||||
register={
|
||||
title="Sign up",
|
||||
login="Log in",
|
||||
username="#",
|
||||
email="@",
|
||||
send="→",
|
||||
code="←",
|
||||
verify="!",
|
||||
password="*",
|
||||
password2="*",
|
||||
register="Sign up",
|
||||
registering="......",
|
||||
setPW="##",
|
||||
},
|
||||
account={
|
||||
title="@_@",
|
||||
|
||||
@@ -323,6 +323,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="支持作者",
|
||||
WidgetText={
|
||||
@@ -438,7 +439,6 @@ return{
|
||||
sysCursor="使用系统光标",
|
||||
autoPause="失去焦点自动暂停",
|
||||
autoSave="破纪录自动保存",
|
||||
autoLogin="启动时自动登录",
|
||||
simpMode="简洁模式",
|
||||
},
|
||||
setting_video={
|
||||
@@ -694,18 +694,18 @@ return{
|
||||
email="邮箱",
|
||||
password="密码",
|
||||
showEmail="显示邮箱",
|
||||
keepPW="保存密码",
|
||||
login="登录",
|
||||
},
|
||||
register={
|
||||
title="注册",
|
||||
login="登录",
|
||||
username="用户名",
|
||||
email="邮箱:",
|
||||
send="发送验证码",
|
||||
code="验证码",
|
||||
verify="验证邮箱",
|
||||
password="密码:",
|
||||
password2="确认密码:",
|
||||
register="注册",
|
||||
registering="等待服务器响应……",
|
||||
setPW="设置密码",
|
||||
},
|
||||
account={
|
||||
title="帐户",
|
||||
|
||||
@@ -324,6 +324,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="支持作者",
|
||||
WidgetText={
|
||||
@@ -439,7 +440,6 @@ return{
|
||||
sysCursor="Set.SysCursor",
|
||||
autoPause="Set.AutoPause",
|
||||
autoSave="Set.AutoSave",
|
||||
autoLogin="Set.AutoLogin",
|
||||
simpMode="Set.SimpMode",
|
||||
},
|
||||
setting_video={
|
||||
@@ -695,18 +695,18 @@ return{
|
||||
email="Email=",
|
||||
password="Password=",
|
||||
showEmail="ShowEmail",
|
||||
keepPW="KeepPassword",
|
||||
login="Login();",
|
||||
},
|
||||
register={
|
||||
title="Register.UI",
|
||||
login="Login();",
|
||||
username="Username=",
|
||||
email="Email=",
|
||||
send="Send()",
|
||||
code="V-code=",
|
||||
verify="Verify()",
|
||||
password="Password=",
|
||||
password2="RePassword=",
|
||||
register="Register();",
|
||||
registering="Waiting();",
|
||||
setPW="SetPassword()",
|
||||
},
|
||||
account={
|
||||
title="Account.UI",
|
||||
|
||||
@@ -323,6 +323,7 @@ return{
|
||||
Cold_Clear [MinusKelvin]
|
||||
json.lua [rxi]
|
||||
profile.lua [itraykov]
|
||||
sha2 [Egor Skriptunoff]
|
||||
]],
|
||||
support="支持作者",
|
||||
WidgetText={
|
||||
@@ -438,7 +439,6 @@ return{
|
||||
sysCursor="使用系統光標",
|
||||
autoPause="失去焦點時暫停",
|
||||
autoSave="打破紀錄時自動保存",
|
||||
autoLogin="啟動時自動登錄",
|
||||
simpMode="簡潔模式",
|
||||
},
|
||||
setting_video={
|
||||
@@ -694,18 +694,18 @@ return{
|
||||
email="電郵",
|
||||
password="密碼",
|
||||
showEmail="顯示郵箱",
|
||||
keepPW="保存密碼",
|
||||
login="登錄",
|
||||
},
|
||||
register={
|
||||
title="註冊",
|
||||
login="登錄",
|
||||
username="用戶名",
|
||||
email="電郵",
|
||||
send="發送驗證碼",
|
||||
code="驗證碼",
|
||||
verify="驗證郵箱",
|
||||
password="密碼",
|
||||
password2="確認密碼",
|
||||
register="註冊",
|
||||
registering="等待伺服器響應……",
|
||||
setPW="設置密碼",
|
||||
},
|
||||
account={
|
||||
title="賬戶",
|
||||
|
||||
690
parts/net.lua
690
parts/net.lua
@@ -76,22 +76,6 @@ local function _parse(res)
|
||||
end
|
||||
end
|
||||
|
||||
--Parse notice
|
||||
local function _parseNotice(str)
|
||||
if str:find("///")then
|
||||
str=str:split("///")
|
||||
for i=1,#str do
|
||||
local m=str[i]
|
||||
if m:find("=")then
|
||||
str[m:sub(1,m:find("=")-1)]=m:sub(m:find("=")+1)
|
||||
end
|
||||
end
|
||||
return str[SETTING.locale]or SETTING.locale:find'zh'and str.zh or str.en
|
||||
else
|
||||
return str
|
||||
end
|
||||
end
|
||||
|
||||
--WS close message
|
||||
local function _closeMessage(message)
|
||||
local mes=JSON.decode(message)
|
||||
@@ -102,125 +86,283 @@ local function _closeMessage(message)
|
||||
end
|
||||
end
|
||||
|
||||
--Remove player when leave
|
||||
local function _removePlayer(L,sid)
|
||||
for i=1,#L do
|
||||
if L[i].sid==sid then
|
||||
rem(L,i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Push stream data to players
|
||||
local function _pumpStream(d)
|
||||
if d.uid~=USER.uid then
|
||||
for _,P in next,PLAYERS do
|
||||
if P.uid==d.uid then
|
||||
local res,stream=pcall(loveDecode,'string','base64',d.stream)
|
||||
if res then
|
||||
DATA.pumpRecording(stream,P.stream)
|
||||
else
|
||||
MES.new('error',"Bad stream from "..P.username.."#"..P.uid,.2)
|
||||
end
|
||||
break
|
||||
|
||||
--------------------------<NEW API>
|
||||
local function getMsg(request,timeout)
|
||||
HTTP(request)
|
||||
local totalTime=0
|
||||
while true do
|
||||
local mes=HTTP.pollMsg(request.pool)
|
||||
if mes then
|
||||
if type(mes.body)=='string' then
|
||||
return JSON.decode(mes.body)
|
||||
end
|
||||
else
|
||||
totalTime=totalTime+yield()
|
||||
if totalTime>timeout then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.getCode(email)
|
||||
if not NET.lock('getCode') then return end
|
||||
TASK.new(function()
|
||||
local res=getMsg({
|
||||
pool='getCode',
|
||||
path='/techmino/api/v1/auth/verify/email',
|
||||
body={email=email},
|
||||
},12.6)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
USER.email=email
|
||||
SCN.fileDropped(2)
|
||||
MES.new('info',"Please check your email",5)
|
||||
else
|
||||
MES.new('error',res.message,5)
|
||||
end
|
||||
else
|
||||
MES.new('error',"Time out",5)
|
||||
end
|
||||
|
||||
WAIT.interrupt()
|
||||
end)
|
||||
WAIT{
|
||||
quit=function()
|
||||
NET.unlock('getCode')
|
||||
HTTP.deletePool('getCode')
|
||||
end,
|
||||
timeout=12.6,
|
||||
}
|
||||
end
|
||||
function NET.codeLogin(code)
|
||||
if not NET.lock('codeLogin') then return end
|
||||
TASK.new(function()
|
||||
local res=getMsg({
|
||||
pool='codeLogin',
|
||||
path='/techmino/api/v1/auth/login/email',
|
||||
body={
|
||||
email=USER.email,
|
||||
code=code,
|
||||
},
|
||||
},6.26)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
USER.rToken=res.refreshToken
|
||||
USER.aToken=res.accessToken
|
||||
-- TODO: connect WS
|
||||
SCN.go('net_game')
|
||||
elseif res.code==201 then
|
||||
USER.rToken=res.refreshToken
|
||||
USER.aToken=res.accessToken
|
||||
SCN.fileDropped(3)-- Not designed for this, but it works and no side effects
|
||||
MES.new('info',"Please set your password",5)
|
||||
else
|
||||
MES.new('error',res.message,5)
|
||||
end
|
||||
else
|
||||
MES.new('error',"Time out",5)
|
||||
end
|
||||
|
||||
WAIT.interrupt()
|
||||
end)
|
||||
WAIT{
|
||||
quit=function()
|
||||
NET.unlock('codeLogin')
|
||||
HTTP.deletePool('codeLogin')
|
||||
end,
|
||||
timeout=6.26,
|
||||
}
|
||||
end
|
||||
function NET.setPW(code,pw)
|
||||
if not NET.lock('setPW') then return end
|
||||
TASK.new(function()
|
||||
pw=HASH.hmac()
|
||||
|
||||
local res=getMsg({
|
||||
pool='setPW',
|
||||
method='PUT',
|
||||
path='/techmino/api/v1/auth/reset/email',
|
||||
body={
|
||||
email=USER.email,
|
||||
code=code,
|
||||
newPassword=pw,
|
||||
},
|
||||
},6.26)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
SCN.back()
|
||||
MES.new('info',"Password set! Now you can login",5)
|
||||
else
|
||||
MES.new('error',res.message,5)
|
||||
end
|
||||
else
|
||||
MES.new('error',"Time out",5)
|
||||
end
|
||||
|
||||
WAIT.interrupt()
|
||||
end)
|
||||
WAIT{
|
||||
quit=function()
|
||||
NET.unlock('setPW')
|
||||
HTTP.deletePool('setPW')
|
||||
end,
|
||||
timeout=6.26,
|
||||
}
|
||||
end
|
||||
function NET.autoLogin()
|
||||
if not USER.password then
|
||||
SCN.go('login')
|
||||
return
|
||||
end
|
||||
if not NET.lock('autoLogin') then return end
|
||||
TASK.new(function()
|
||||
if USER.aToken then
|
||||
local res=getMsg({
|
||||
pool='autoLogin',
|
||||
path='/techmino/api/v1/auth/check',
|
||||
headers={["x-access-token"]=USER.aToken},
|
||||
},6.26)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
-- TODO: connect WS
|
||||
SCN.go('net_game')
|
||||
WAIT.interrupt()
|
||||
return
|
||||
else
|
||||
MES.new('warning',res.message,5)
|
||||
end
|
||||
else
|
||||
WAIT.interrupt()
|
||||
return
|
||||
end
|
||||
end
|
||||
if USER.rToken then
|
||||
local res=getMsg({
|
||||
pool='autoLogin',
|
||||
path='/techmino/api/v1/auth/refresh',
|
||||
headers={["x-refresh-token"]=USER.rToken},
|
||||
},6.26)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
USER.rToken=res.refreshToken
|
||||
USER.aToken=res.accessToken
|
||||
-- TODO: connect WS
|
||||
MES.new('info',"Login successed",5)
|
||||
SCN.go('net_game')
|
||||
WAIT.interrupt()
|
||||
return
|
||||
else
|
||||
MES.new('warning',res.message,5)
|
||||
end
|
||||
else
|
||||
WAIT.interrupt()
|
||||
return
|
||||
end
|
||||
end
|
||||
if USER.password then
|
||||
local res=getMsg({
|
||||
pool='pwLogin',
|
||||
path='/techmino/api/v1/auth/login/email',
|
||||
body={
|
||||
email=USER.email,
|
||||
password=USER.password,
|
||||
},
|
||||
},6.26)
|
||||
if res then
|
||||
if res.code==200 then
|
||||
USER.rToken=res.refreshToken
|
||||
USER.aToken=res.accessToken
|
||||
-- TODO: connect WS
|
||||
MES.new('info',"Login successed",5)
|
||||
SCN.go('net_game')
|
||||
WAIT.interrupt()
|
||||
return
|
||||
else
|
||||
MES.new('warning',res.message,5)
|
||||
end
|
||||
else
|
||||
WAIT.interrupt()
|
||||
end
|
||||
end
|
||||
|
||||
SCN.go('login')
|
||||
WAIT.interrupt()
|
||||
end)
|
||||
WAIT{
|
||||
quit=function()
|
||||
NET.unlock('autoLogin')
|
||||
HTTP.deletePool('autoLogin')
|
||||
end,
|
||||
timeout=12.6,
|
||||
}
|
||||
end
|
||||
function NET.pwLogin(email,pw)
|
||||
if not NET.lock('pwLogin') then return end
|
||||
TASK.new(function()
|
||||
pw=STRING.digezt(pw)
|
||||
|
||||
local res=getMsg({
|
||||
pool='pwLogin',
|
||||
path='/techmino/api/v1/auth/login/email',
|
||||
body={
|
||||
email=email,
|
||||
password=pw,
|
||||
},
|
||||
},6.26)
|
||||
|
||||
if res then
|
||||
if res.code==200 then
|
||||
USER.email=email
|
||||
USER.password=pw
|
||||
USER.rToken=res.refreshToken
|
||||
USER.aToken=res.accessToken
|
||||
-- TODO: connect WS
|
||||
SCN.go('net_game')
|
||||
else
|
||||
MES.new('error',res.message,5)
|
||||
end
|
||||
else
|
||||
MES.new('error',"Time out",5)
|
||||
end
|
||||
|
||||
WAIT.interrupt()
|
||||
end)
|
||||
WAIT{
|
||||
quit=function()
|
||||
NET.unlock('pwLogin')
|
||||
HTTP.deletePool('pwLogin')
|
||||
end,
|
||||
timeout=12.6,
|
||||
}
|
||||
end
|
||||
--------------------------</NEW API>
|
||||
|
||||
|
||||
|
||||
--Connect
|
||||
function NET.wsconn_app()
|
||||
if WS.status('app')=='dead'then
|
||||
WS.connect('app','/app',nil,6)
|
||||
TASK.new(NET.updateWS_app)
|
||||
end
|
||||
end
|
||||
function NET.wsconn_user_pswd(email,password)
|
||||
if WS.status('user')=='dead'then
|
||||
WS.connect('user','/user',JSON.encode{
|
||||
email=email,
|
||||
password=password,
|
||||
},6)
|
||||
TASK.new(NET.updateWS_user)
|
||||
end
|
||||
end
|
||||
function NET.wsconn_user_token(uid,authToken)
|
||||
if WS.status('user')=='dead'then
|
||||
WS.connect('user','/user',JSON.encode{
|
||||
uid=uid,
|
||||
authToken=authToken,
|
||||
},6)
|
||||
TASK.new(NET.updateWS_user)
|
||||
end
|
||||
end
|
||||
function NET.wsconn_play()
|
||||
if WS.status('play')=='dead'then
|
||||
WS.connect('play','/play',JSON.encode{
|
||||
uid=USER.uid,
|
||||
accessToken=NET.accessToken,
|
||||
},6)
|
||||
TASK.new(NET.updateWS_play)
|
||||
end
|
||||
end
|
||||
function NET.wsconn_stream(srid)
|
||||
function NET.wsconn()
|
||||
if WS.status('stream')=='dead'then
|
||||
NET.roomState.start=true
|
||||
WS.connect('stream','/stream',JSON.encode{
|
||||
uid=USER.uid,
|
||||
accessToken=NET.accessToken,
|
||||
srid=srid,
|
||||
accessToken=USER.aToken,
|
||||
},6)
|
||||
TASK.new(NET.updateWS_stream)
|
||||
end
|
||||
end
|
||||
function NET.wsconn_manage()
|
||||
if WS.status('manage')=='dead'then
|
||||
WS.connect('manage','/manage',JSON.encode{
|
||||
uid=USER.uid,
|
||||
authToken=USER.authToken,
|
||||
},6)
|
||||
TASK.new(NET.updateWS_manage)
|
||||
end
|
||||
end
|
||||
|
||||
--Disconnect
|
||||
function NET.wsclose_app()WS.close('app')end
|
||||
function NET.wsclose_user()WS.close('user')end
|
||||
function NET.wsclose_play()WS.close('play')end
|
||||
function NET.wsclose_stream()
|
||||
NET.roomState.start=false
|
||||
WS.close('stream')
|
||||
function NET.wsclose()
|
||||
-- WS.close()
|
||||
end
|
||||
|
||||
--Account & User
|
||||
function NET.register(username,email,password)
|
||||
if NET.lock('register')then
|
||||
WS.send('app',JSON.encode{
|
||||
action=2,
|
||||
data={
|
||||
username=username,
|
||||
email=email,
|
||||
password=password,
|
||||
}
|
||||
})
|
||||
MES.new('info',text.registerRequestSent)
|
||||
end
|
||||
end
|
||||
function NET.tryLogin(ifAuto)
|
||||
if NET.allow_online then
|
||||
if WS.status('user')=='running'then
|
||||
if NET.lock('access_and_login',8)then
|
||||
WS.send('user',JSON.encode{action=0})
|
||||
end
|
||||
elseif not ifAuto then
|
||||
SCN.go('login')
|
||||
end
|
||||
else
|
||||
TEXT.show(text.needUpdate,640,450,60,'flicker')
|
||||
SFX.play('finesseError')
|
||||
end
|
||||
end
|
||||
function NET.getUserInfo(uid)
|
||||
WS.send('user',JSON.encode{
|
||||
action=1,
|
||||
@@ -389,62 +531,6 @@ function NET.freshPlayerCount()
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_app()
|
||||
while WS.status('app')~='dead'do
|
||||
yield()
|
||||
local message,op=WS.read('app')
|
||||
if message then
|
||||
if op=='ping'then
|
||||
elseif op=='pong'then
|
||||
elseif op=='close'then
|
||||
_closeMessage(message)
|
||||
return
|
||||
else
|
||||
local res=_parse(message)
|
||||
if res then
|
||||
if res.type=='Connect'then
|
||||
if VERSION.code>=res.lowest then
|
||||
NET.allow_online=true
|
||||
if USER.authToken then
|
||||
NET.wsconn_user_token(USER.uid,USER.authToken)
|
||||
elseif SCN.cur=='main'then
|
||||
SCN.go('login')
|
||||
end
|
||||
end
|
||||
if VERSION.code<res.newestCode then
|
||||
MES.new('warn',text.oldVersion:gsub("$1",res.newestName),3)
|
||||
end
|
||||
MES.new('broadcast',_parseNotice(res.notice),5)
|
||||
NET.tryLogin(true)
|
||||
TASK.new(NET.freshPlayerCount)
|
||||
elseif res.action==0 then--Broadcast
|
||||
MES.new('broadcast',res.data.message,5)
|
||||
elseif res.action==1 then--Get notice
|
||||
--?
|
||||
elseif res.action==2 then--Register
|
||||
if res.type=='Self'or res.type=='Server'then
|
||||
MES.new('info',res.data.message,5)
|
||||
if SCN.cur=='register'then
|
||||
SCN.back()
|
||||
end
|
||||
else
|
||||
MES.new('warn',res.reason or"Registration failed",5)
|
||||
end
|
||||
NET.unlock('register')
|
||||
elseif res.action==3 then--Get player counts
|
||||
NET.UserCount=res.data.User
|
||||
NET.PlayCount=res.data.Play
|
||||
NET.StreamCount=res.data.Stream
|
||||
--res.data.Chat
|
||||
NET.unlock('freshPlayerCount')
|
||||
end
|
||||
else
|
||||
WS.alert('app')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_user()
|
||||
while WS.status('user')~='dead'do
|
||||
yield()
|
||||
@@ -493,265 +579,5 @@ function NET.updateWS_user()
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_play()
|
||||
while WS.status('play')~='dead'do
|
||||
yield()
|
||||
local message,op=WS.read('play')
|
||||
if message then
|
||||
if op=='ping'then
|
||||
elseif op=='pong'then
|
||||
elseif op=='close'then
|
||||
_closeMessage(message)
|
||||
return
|
||||
else
|
||||
local res=_parse(message)
|
||||
if res then
|
||||
local d=res.data
|
||||
if res.type=='Connect'then
|
||||
SCN.go('net_menu')
|
||||
NET.unlock('wsc_play')
|
||||
NET.unlock('access_and_login')
|
||||
SFX.play('connected')
|
||||
elseif res.action==0 then--Fetch rooms
|
||||
if SCN.cur=="net_rooms"then
|
||||
WIDGET.active.roomList:setList(res.roomList)
|
||||
end
|
||||
NET.unlock('fetchRoom')
|
||||
elseif res.action==1 then--Create room (not used)
|
||||
--?
|
||||
elseif res.action==2 then--Player join
|
||||
if res.type=='Self'then
|
||||
--Enter new room
|
||||
NETPLY.clear()
|
||||
if d.players then
|
||||
for _,p in next,d.players do
|
||||
NETPLY.add{
|
||||
uid=p.uid,
|
||||
username=p.username,
|
||||
sid=p.sid,
|
||||
mode=p.mode,
|
||||
config=p.config,
|
||||
}
|
||||
end
|
||||
end
|
||||
NET.roomState.roomInfo=d.roomInfo
|
||||
NET.roomState.roomData=d.roomData
|
||||
NET.roomState.count=d.count
|
||||
NET.roomState.capacity=d.capacity
|
||||
NET.roomState.private=d.private
|
||||
NET.roomState.start=d.start
|
||||
|
||||
NET.roomReadyState=false
|
||||
|
||||
NET.spectate=false
|
||||
|
||||
if d.srid then
|
||||
NET.spectate=true
|
||||
NET.specSRID=d.srid
|
||||
NET.roomReadyState='connecting'
|
||||
end
|
||||
loadGame('netBattle',true,true)
|
||||
else
|
||||
--Load other players
|
||||
NETPLY.add{
|
||||
uid=d.uid,
|
||||
username=d.username,
|
||||
sid=d.sid,
|
||||
mode=d.mode,
|
||||
config=d.config,
|
||||
}
|
||||
if SCN.cur=='net_game'then
|
||||
SCN.socketRead('join',d)
|
||||
end
|
||||
if NET.roomReadyState=='allReady'then
|
||||
NET.roomReadyState=false
|
||||
end
|
||||
end
|
||||
elseif res.action==3 then--Player leave
|
||||
if not d.uid then
|
||||
NET.wsclose_stream()
|
||||
NET.unlock('quit')
|
||||
if SCN.stack[#SCN.stack-1]=='net_newRoom'then
|
||||
SCN.pop()
|
||||
end
|
||||
SCN.back()
|
||||
else
|
||||
NETPLY.remove(d.sid)
|
||||
_removePlayer(PLAYERS,d.sid)
|
||||
_removePlayer(PLY_ALIVE,d.sid)
|
||||
if SCN.cur=='net_game'then
|
||||
SCN.socketRead('leave',d)
|
||||
end
|
||||
end
|
||||
elseif res.action==4 then--Player talk
|
||||
if SCN.cur=='net_game'then
|
||||
SCN.socketRead('talk',d)
|
||||
end
|
||||
elseif res.action==5 then--Player change settings
|
||||
NETPLY.setConf(d.uid,d.config)
|
||||
elseif res.action==6 then--Player change join mode
|
||||
NETPLY.setJoinMode(d.uid,d.mode)
|
||||
elseif res.action==7 then--All Ready
|
||||
SFX.play('reach',.6)
|
||||
NET.roomReadyState='allReady'
|
||||
elseif res.action==8 then--Set
|
||||
NET.roomReadyState='connecting'
|
||||
NET.wsconn_stream(d.srid)
|
||||
elseif res.action==9 then--Game finished
|
||||
if SCN.cur=='net_game'then
|
||||
SCN.socketRead('finish',d)
|
||||
end
|
||||
|
||||
--d.result: list of {place,survivalTime,uid,score}
|
||||
for _,p in next,d.result do
|
||||
for _,P in next,PLAYERS do
|
||||
if P.uid==p.uid then
|
||||
NETPLY.setStat(p.uid,P.stat)
|
||||
NETPLY.setPlace(p.uid,p.place)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
NETPLY.resetState()
|
||||
NETPLY.freshPos()
|
||||
NET.roomState.start=false
|
||||
if NET.spectate then
|
||||
NET.signal_setMode(2)
|
||||
end
|
||||
NET.spectate=false
|
||||
NET.wsclose_stream()
|
||||
end
|
||||
else
|
||||
WS.alert('play')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_stream()
|
||||
while WS.status('stream')~='dead'do
|
||||
yield()
|
||||
local message,op=WS.read('stream')
|
||||
if message then
|
||||
if op=='ping'then
|
||||
elseif op=='pong'then
|
||||
elseif op=='close'then
|
||||
_closeMessage(message)
|
||||
return
|
||||
else
|
||||
local res=_parse(message)
|
||||
if res then
|
||||
local d=res.data
|
||||
if res.type=='Connect'then
|
||||
NET.unlock('wsc_stream')
|
||||
NET.roomReadyState=false
|
||||
elseif res.action==0 then--Game start
|
||||
NET.roomReadyState=false
|
||||
SCN.socketRead('go')
|
||||
elseif res.action==1 then--Game finished
|
||||
--?
|
||||
elseif res.action==2 then--Player join
|
||||
if res.type=='Self'then
|
||||
NET.seed=d.seed
|
||||
NET.spectate=d.spectate
|
||||
NETPLY.setConnect(d.uid)
|
||||
for _,p in next,d.connected do
|
||||
if not p.spectate then
|
||||
NETPLY.setConnect(p.uid)
|
||||
end
|
||||
end
|
||||
if d.spectate then
|
||||
if d.start then
|
||||
SCN.socketRead('go')
|
||||
if d.history then
|
||||
for _,v in next,d.history do
|
||||
_pumpStream(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
NET.roomReadyState='waitConn'
|
||||
end
|
||||
else
|
||||
if d.spectate then
|
||||
NETPLY.setJoinMode(d.uid,2)
|
||||
else
|
||||
NETPLY.setConnect(d.uid)
|
||||
end
|
||||
end
|
||||
elseif res.action==3 then--Player leave
|
||||
--?
|
||||
elseif res.action==4 then--Player died
|
||||
for _,P in next,PLY_ALIVE do
|
||||
if P.uid==d.uid then
|
||||
P:lose(true)
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif res.action==5 then--Receive stream
|
||||
_pumpStream(d)
|
||||
end
|
||||
else
|
||||
WS.alert('stream')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_chat()
|
||||
while WS.status('chat')~='dead'do
|
||||
yield()
|
||||
local message,op=WS.read('chat')
|
||||
if message then
|
||||
if op=='ping'then
|
||||
elseif op=='pong'then
|
||||
elseif op=='close'then
|
||||
_closeMessage(message)
|
||||
return
|
||||
else
|
||||
local res=_parse(message)
|
||||
if res then
|
||||
--TODO
|
||||
else
|
||||
WS.alert('chat')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.updateWS_manage()
|
||||
while WS.status('manage')~='dead'do
|
||||
yield()
|
||||
local message,op=WS.read('manage')
|
||||
if message then
|
||||
if op=='ping'then
|
||||
elseif op=='pong'then
|
||||
elseif op=='close'then
|
||||
_closeMessage(message)
|
||||
return
|
||||
else
|
||||
local res=_parse(message)
|
||||
if res then
|
||||
if res.type=='Connect'then
|
||||
MES.new('check',"Manage connected")
|
||||
elseif res.action==0 then
|
||||
MES.new('check',"success")
|
||||
elseif res.action==9 then
|
||||
MES.new('check',"success")
|
||||
elseif res.action==10 then
|
||||
MES.new('info',TABLE.dump(res.data))
|
||||
elseif res.action==11 then
|
||||
MES.new('info',TABLE.dump(res.data))
|
||||
elseif res.action==12 then
|
||||
MES.new('info',TABLE.dump(res.data))
|
||||
end
|
||||
else
|
||||
WS.alert('manage')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return NET
|
||||
|
||||
@@ -33,7 +33,7 @@ function scene.draw()
|
||||
|
||||
--Lib used
|
||||
setFont(15)
|
||||
gc.print(text.used,495,462)--❤Flandre❤
|
||||
gc.print(text.used,495,426)--❤Flandre❤
|
||||
|
||||
--Logo
|
||||
gc.draw(TEXTURE.title,280,610,.1,.4+.03*sin(TIME()*2.6),nil,580,118)
|
||||
|
||||
@@ -9,10 +9,7 @@ function scene.sceneInit()
|
||||
sysAndScn=SYSTEM.."-"..VERSION.string.." scene:"..Z.getErr('#').scene
|
||||
errorText=LOADED and text.errorMsg or"An error has occurred while the game was loading.\nAn error log has been created so you can send it to the author."
|
||||
errorShot,errorInfo=Z.getErr('#').shot,Z.getErr('#').mes
|
||||
NET.wsclose_app()
|
||||
NET.wsclose_user()
|
||||
NET.wsclose_play()
|
||||
NET.wsclose_stream()
|
||||
NET.wsclose()
|
||||
if SETTING then
|
||||
SFX.fplay('error',SETTING.voc*.8 or 0)
|
||||
end
|
||||
|
||||
@@ -100,11 +100,6 @@ local loadingThread=coroutine.wrap(function()
|
||||
YIELD('loadOther')
|
||||
STAT.run=STAT.run+1
|
||||
|
||||
--Connect to server
|
||||
if SETTING.autoLogin then
|
||||
NET.wsconn_app()
|
||||
end
|
||||
|
||||
SFX.play('enter',.8)
|
||||
SFX.play('welcome')
|
||||
VOC.play('welcome')
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local emailBox=WIDGET.newInputBox{name='email',x=380,y=200,w=500,h=60,limit=128}
|
||||
local passwordBox=WIDGET.newInputBox{name='password',x=380,y=300,w=620,h=60,secret=true,regex="[ -~]",limit=64}
|
||||
|
||||
local savePW=false
|
||||
local showEmail=true
|
||||
|
||||
local function _login()
|
||||
@@ -12,25 +11,16 @@ local function _login()
|
||||
MES.new('error',text.noPassword)return
|
||||
end
|
||||
-- password=STRING.digezt(password)
|
||||
NET.wsconn_user_pswd(email,password)
|
||||
if savePW then
|
||||
saveFile({email,password},'conf/account')
|
||||
else
|
||||
love.filesystem.remove('conf/account')
|
||||
end
|
||||
NET.pwLogin(email,password)
|
||||
end
|
||||
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
local data=loadFile('conf/account','-canSkip')
|
||||
if data then
|
||||
savePW=true
|
||||
showEmail=false
|
||||
emailBox.secret=true
|
||||
emailBox:setText(data[1])
|
||||
passwordBox:setText(data[2])
|
||||
end
|
||||
showEmail=false
|
||||
emailBox.secret=true
|
||||
emailBox:setText(USER.email)
|
||||
passwordBox:setText(USER.password)
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
@@ -39,7 +29,6 @@ scene.widgetList={
|
||||
emailBox,
|
||||
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='keepPW', x=900, y=420,disp=function()return savePW end,code=function()savePW=not savePW end},
|
||||
WIDGET.newKey{name='login', x=1140,y=540,w=170,h=80,font=40,code=_login},
|
||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||
}
|
||||
|
||||
@@ -47,14 +47,10 @@ function scene.mouseDown(x,y)
|
||||
end
|
||||
scene.touchDown=scene.mouseDown
|
||||
local function _testButton(n)
|
||||
if NET.getlock('access_and_login')then
|
||||
MES.new('warn',text.wsConnecting)
|
||||
if WIDGET.isFocus(scene.widgetList[n])then
|
||||
return true
|
||||
else
|
||||
if WIDGET.isFocus(scene.widgetList[n])then
|
||||
return true
|
||||
else
|
||||
WIDGET.focus(scene.widgetList[n])
|
||||
end
|
||||
WIDGET.focus(scene.widgetList[n])
|
||||
end
|
||||
end
|
||||
function scene.keyDown(key,isRep)
|
||||
@@ -69,13 +65,7 @@ function scene.keyDown(key,isRep)
|
||||
end
|
||||
elseif key=='a'then
|
||||
if _testButton(3)then
|
||||
if WS.status('app')=='running'then
|
||||
NET.tryLogin(false)
|
||||
elseif WS.status('app')=='dead'then
|
||||
NET.wsconn_app()
|
||||
SFX.play('connect')
|
||||
MES.new('info',text.wsConnecting)
|
||||
end
|
||||
NET.autoLogin()
|
||||
end
|
||||
elseif key=='z'then
|
||||
if _testButton(4)then
|
||||
@@ -173,14 +163,6 @@ function scene.draw()
|
||||
|
||||
--Player count
|
||||
drawOnlinePlayerCount()
|
||||
|
||||
--Connecting mark
|
||||
if NET.getlock('access_and_login')then
|
||||
GC.setColor(COLOR.Z)
|
||||
GC.setLineWidth(10)
|
||||
local t=TIME()*6.26%6.2832
|
||||
GC.arc('line','open',scene.widgetList[3].x+865,450,40,t,t+4.26)
|
||||
end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
|
||||
@@ -1,34 +1,90 @@
|
||||
local scene={}
|
||||
|
||||
local function _register()
|
||||
local username= WIDGET.active.username:getText()
|
||||
local email= WIDGET.active.email:getText()
|
||||
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',"Wrong code length")
|
||||
else
|
||||
NET.codeLogin(code)
|
||||
end
|
||||
end
|
||||
|
||||
local function _setPW()
|
||||
local password= WIDGET.active.password:getText()
|
||||
local password2=WIDGET.active.password2:getText()
|
||||
if #username==0 then
|
||||
MES.new('error',text.noUsername)return
|
||||
elseif not STRING.simpEmailCheck(email)then
|
||||
MES.new('error',text.wrongEmail)return
|
||||
elseif #password==0 or #password2==0 then
|
||||
MES.new('error',text.noPassword)return
|
||||
if #password==0 or #password2==0 then
|
||||
MES.new('error',text.noPassword)
|
||||
elseif password~=password2 then
|
||||
MES.new('error',text.diffPassword)return
|
||||
MES.new('error',text.diffPassword)
|
||||
else
|
||||
NET.setPW(code,password)
|
||||
end
|
||||
NET.register(username,email,password)
|
||||
end
|
||||
|
||||
function scene.sceneInit()
|
||||
state=1
|
||||
scene.fileDropped(state)
|
||||
end
|
||||
|
||||
function scene.keyDown(key,rep)
|
||||
if key=='escape' and not rep then
|
||||
if state==1 then
|
||||
SCN.back()
|
||||
else
|
||||
scene.fileDropped(state-1)
|
||||
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
|
||||
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='username', x=380, y=200,w=500,h=60,regex="[0-9A-Za-z_]",limit=64},
|
||||
|
||||
WIDGET.newInputBox{name='email', x=380, y=300,w=626,h=60,limit=128},
|
||||
WIDGET.newInputBox{name='password', x=380, y=400,w=626,h=60,secret=true,regex="[ -~]",limit=64},
|
||||
WIDGET.newInputBox{name='password2',x=380, y=500,w=626,h=60,secret=true,regex="[ -~]",limit=64},
|
||||
WIDGET.newKey{name='send', x=640, y=430,w=250,h=80,font=40,code=_getCode},
|
||||
|
||||
WIDGET.newKey{name='register', x=640, y=640,w=300,h=80,font=40,code=_register,hideF=function()return NET.getlock('register')end},
|
||||
WIDGET.newText{name='registering', x=640, y=605,font=50,hideF=function()return not NET.getlock('register')end},
|
||||
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.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||
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
|
||||
|
||||
@@ -48,7 +48,6 @@ scene.widgetList={
|
||||
WIDGET.newSwitch{name='sysCursor',x=1060, y=400, lim=580, disp=SETval('sysCursor'),code=function()SETTING.sysCursor=not SETTING.sysCursor applySettings()end},
|
||||
WIDGET.newSwitch{name='autoPause',x=1060, y=470, lim=580, disp=SETval('autoPause'),code=SETrev('autoPause')},
|
||||
WIDGET.newSwitch{name='autoSave', x=1060, y=540, lim=580, disp=SETval('autoSave'), code=SETrev('autoSave')},
|
||||
WIDGET.newSwitch{name='autoLogin',x=960, y=610, lim=480, disp=SETval('autoLogin'),code=SETrev('autoLogin')},
|
||||
WIDGET.newSwitch{name='simpMode', x=960, y=670, lim=480, disp=SETval('simpMode'),
|
||||
code=function()
|
||||
SETTING.simpMode=not SETTING.simpMode
|
||||
|
||||
Reference in New Issue
Block a user