diff --git a/parts/net.lua b/parts/net.lua index 3cc71ad5..f6c6abdc 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -188,12 +188,24 @@ function NET.getAvatar(uid) end) end +local noticeLang={ + en='en_us', + fr='en_us', -- fr_fr + es='en_us', -- es_es + id='en_us', -- id_id + pt='en_us', -- pt_pt + symbol='en_us', -- ga_os + ja='en_us', -- ja_jp + vi='en_us', -- vi_vn + zh='zh_cn', + zh_trad='zh_tw', + zh_code='zh_cn', +} function NET.launchNotice() - local lang=SETTING.locale:find('zh') and 'zh_cn' or 'en_us' TASK.new(function() local res=getMsg({ pool='getNotice', - path='/techmino/api/v1/notice?language='..lang..'&lastCount=1', + path='/techmino/api/v1/notice?language='..noticeLang[SETTING.locale]..'&lastCount=1', },6.26) if res and res.code==200 then @@ -207,17 +219,16 @@ function NET.launchNotice() end) end function NET.getNotice(count) - local lang=SETTING.locale:find('zh') and 'zh_cn' or 'en_us' WAIT{timeout=6.26} TASK.new(function() local res=getMsg({ pool='getNotice', - path='/techmino/api/v1/notice?language='..lang..'&lastCount='..(count or 5), + path='/techmino/api/v1/notice?language='..noticeLang[SETTING.locale]..'&lastCount='..(count or 5), },6.26) if res and res.code==200 then - local dataStr=TABLE.dump(res.data) - SCN.go('notice',nil,dataStr) + WAIT.interrupt() + SCN.go('notice',nil,res.data.contents) end end) end diff --git a/parts/scenes/notice.lua b/parts/scenes/notice.lua index d7387308..e3a1deb9 100644 --- a/parts/scenes/notice.lua +++ b/parts/scenes/notice.lua @@ -2,8 +2,16 @@ local scene={} function scene.enter() BG.set('cubes') - if type(SCN.args[1])=='string' then - scene.widgetList.texts:setTexts(SCN.args[1]) + local data=SCN.args[1] + if data then + local texts={} + for i=1,#data do + table.insert(texts,data[i].timestamp or "20??/??/??") + table.insert(texts,data[i].content) + table.insert(texts,"") + table.insert(texts,"——————————————————————————") + end + scene.widgetList.texts:setTexts(texts) else scene.widgetList.texts:setTexts({"No data"}) end @@ -27,7 +35,7 @@ function scene.keyDown(key) end scene.widgetList={ - WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=20,fix=true}, + WIDGET.newTextBox{name='texts',x=30,y=45,w=1000,h=640,font=25,fix=true,lineH=45}, WIDGET.newButton{name='back',x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, }