整理代码

新增没做完的公告页面
因为一些神秘token问题连接失败后会要求重新登录
This commit is contained in:
MrZ_26
2023-01-23 02:14:10 +08:00
parent ee4fd51e0f
commit f212076604
4 changed files with 64 additions and 7 deletions

View File

@@ -602,6 +602,7 @@ end
table.sort(REPLAY,function(a,b) return a.fileName>b.fileName end)
AUTHURL="https://studio26f.org/oauth?product=techmino"
AUTHHOST="cafuuchino1.3322.org:8081"
WS.switchHost('cafuuchino1.3322.org','10026','/techmino/ws/v1')
HTTP.setHost("cafuuchino1.3322.org:10026")
HTTP.setThreadCount(1)

View File

@@ -134,7 +134,7 @@ function NET.login(auto)
if USER.aToken then
local res=getMsg({
pool='login',
url='cafuuchino1.3322.org:8081',
url=AUTHHOST,
path='/studio26f/api/v1/auth/check',
headers={["x-access-token"]=USER.aToken},
},6.26)
@@ -163,7 +163,7 @@ function NET.getUserInfo(uid)
TASK.new(function()
local res=getMsg({
pool='getInfo',
url='cafuuchino1.3322.org:8081',
url=AUTHHOST,
path='/studio26f/api/v1/player/info?playerId='..uid,
},6.26)
@@ -176,7 +176,7 @@ function NET.getAvatar(uid)
TASK.new(function()
local res=getMsg({
pool='getInfo',
url='cafuuchino1.3322.org:8081',
url=AUTHHOST,
path='/studio26f/api/v1/player/avatar?playerId='..uid,
},6.26)
@@ -185,6 +185,20 @@ function NET.getAvatar(uid)
end
end)
end
function NET.getNotice(lang,count)
WAIT{timeout=6.26}
TASK.new(function()
local res=getMsg({
pool='getNotice',
path='/techmino/api/v1/notice?language='..(lang or 'zh_cn')..'&lastCount='..(count or 5),
},6.26)
if res and res.code==200 and type(res.data)=='string' then
local dataStr=""
SCN.go('notice',nil,dataStr)
end
end)
end
--------------------------<NEW WS API>
local actMap={
global_getOnlineCount= 1000,
@@ -560,6 +574,8 @@ function NET.ws_update()
while true do
TEST.yieldT(1/26)
if WS.status('game')=='dead' then
USER.aToken=false
USER.oToken=false
TEST.yieldUntilNextScene()
GAME.playing=false
SCN.backTo('main')

View File

@@ -104,14 +104,19 @@ function scene.keyDown(key,isRep)
end
elseif key=='3' then
if _testButton(10) then
MES.new('warn',text.notFinished)
-- NET.getNotice()
end
elseif key=='4' then
if _testButton(11) then
SCN.go('lang')
end
elseif key=='x' then
if _testButton(11) then
if _testButton(12) then
SCN.go('about')
end
elseif key=='m' then
if _testButton(12) then
if _testButton(13) then
SCN.go('manual')
end
elseif key=='c' then
@@ -215,8 +220,9 @@ scene.widgetList={
WIDGET.newButton{name='dict', x=2480,y=450,w=800,h=100, color='lG',font=40,align='L',edge=30,code=pressKey'l'},
WIDGET.newButton{name='replays',x=2480,y=570,w=800,h=100, color='lC',font=40,align='L',edge=30,code=pressKey','},
WIDGET.newButton{name='music', x=120,y=80,w=100, color='lO',code=pressKey'2',font=70,fText=CHAR.icon.music},
WIDGET.newButton{name='lang', x=280,y=80,w=100, color='lN',code=pressKey'3',font=70,fText=CHAR.icon.language},
WIDGET.newButton{name='music', x=90,y=80,w=100, color='lY',code=pressKey'2',font=70,fText=CHAR.icon.music},
WIDGET.newButton{name='notice', x=210,y=80,w=100, color='lA',code=pressKey'3',font=70,fText=CHAR.key.winMenu},
WIDGET.newButton{name='lang', x=330,y=80,w=100, color='lN',code=pressKey'4',font=70,fText=CHAR.icon.language},
WIDGET.newButton{name='about', x=-110,y=670,w=600,h=70, color='lB',align='R',edge=20,code=pressKey'x',font=50,fText=CHAR.icon.info},
WIDGET.newButton{name='manual', x=1390,y=670,w=600,h=70, color='lR',align='L',edge=20,code=pressKey'm',font=50,fText=CHAR.icon.help},
}

34
parts/scenes/notice.lua Normal file
View File

@@ -0,0 +1,34 @@
local scene={}
function scene.enter()
BG.set('cubes')
if type(SCN.args[1])=='string' then
scene.widgetList.texts:setTexts(SCN.args[1])
else
scene.widgetList.texts:setTexts({"No data"})
end
end
function scene.wheelMoved(_,y)
WHEELMOV(y)
end
function scene.keyDown(key)
if key=='up' then
scene.widgetList.texts:scroll(-5)
elseif key=='down' then
scene.widgetList.texts:scroll(5)
elseif key=='pageup' then
scene.widgetList.texts:scroll(-20)
elseif key=='pagedown' then
scene.widgetList.texts:scroll(20)
elseif key=='escape' then
SCN.back()
end
end
scene.widgetList={
WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=20,fix=true},
WIDGET.newButton{name='back',x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
}
return scene