使用aegistudio的新网络库获取公告
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
require("Zframework/toolfunc")
|
||||
color= require("Zframework/color")
|
||||
SCN= require("Zframework/scene")
|
||||
LOG= require("Zframework/log")
|
||||
require("Zframework/toolfunc")
|
||||
SHADER= require("Zframework/shader")
|
||||
VIB= require("Zframework/vib")
|
||||
SFX= require("Zframework/sfx")
|
||||
@@ -15,8 +17,6 @@ IMG= require("Zframework/img")
|
||||
WIDGET= require("Zframework/widget")
|
||||
Widgets=require("Zframework/widgetList")
|
||||
LIGHT= require("Zframework/light")
|
||||
SCN= require("Zframework/scene")
|
||||
LOG= require("Zframework/log")
|
||||
|
||||
local ms=love.mouse
|
||||
local gc=love.graphics
|
||||
@@ -375,7 +375,7 @@ function love.errorhandler(msg)
|
||||
needDraw=true
|
||||
elseif E=="focus"then
|
||||
needDraw=true
|
||||
elseif E=="touchpressed"or E=="keypressed"or E=="mousepressed"then
|
||||
elseif E=="touchpressed"or E=="mousepressed"or E=="keypressed"and a=="space"then
|
||||
if count<3 then
|
||||
count=count+1
|
||||
SFX.play("ready")
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
local langList={
|
||||
{
|
||||
anykey="按任意键继续",
|
||||
newVersion="检测到更新!",
|
||||
newVersion="感谢更新!更新内容如下",
|
||||
httpTimeout="网络连接超时!",
|
||||
marking="游戏作者:MrZ_26\n任何视频/直播不得出现此水印\n任何转述声明无效",
|
||||
holdR="长按以重新开始",
|
||||
|
||||
@@ -553,7 +554,8 @@ local langList={
|
||||
},
|
||||
{
|
||||
anykey="按任意键继续",
|
||||
newVersion="检测到更新!",
|
||||
newVersion="感谢更新!更新内容如下",
|
||||
httpTimeout="网络连接超时!",
|
||||
marking="游戏作者:MrZ_26\n任何视频/直播不得出现此水印\n任何转述声明无效",
|
||||
holdR="长按以重新开始",
|
||||
|
||||
@@ -1103,7 +1105,8 @@ local langList={
|
||||
},
|
||||
{
|
||||
anykey="Press any button",
|
||||
newVersion="Update detected!",
|
||||
newVersion="Thanks for updating! New feature below",
|
||||
httpTimeout="Network connection timed out!",
|
||||
marking="Game Author: MrZ_26\nIllegal recording if you can see this\nAny explanation is invalid",
|
||||
holdR="Hold to restart",
|
||||
|
||||
@@ -1650,7 +1653,8 @@ local langList={
|
||||
},
|
||||
{
|
||||
anykey="↓□↓",
|
||||
newVersion="&!!!",
|
||||
newVersion="&!!!???↓↓",
|
||||
httpTimeout="e??????x",
|
||||
marking="Game Author:MrZ_26\nIllegal recording if see this\nAny explanation invalid",
|
||||
holdR="→→→→R",
|
||||
|
||||
@@ -2194,7 +2198,8 @@ local langList={
|
||||
},
|
||||
{
|
||||
anykey="您开始了",
|
||||
newVersion="感谢更新!",
|
||||
newVersion="感谢更新,请看看更新了些啥",
|
||||
httpTimeout="没网或者网不好?",
|
||||
marking="游戏作者:MrZ_26\n任何视频/直播不得出现此水印\n任何转述声明无效",
|
||||
holdR="长按重开",
|
||||
|
||||
|
||||
@@ -150,36 +150,21 @@ do--dumpTable
|
||||
return s..tabs[t-1].."}"
|
||||
end
|
||||
end
|
||||
do--HTTPrequest
|
||||
local http=require("socket.http")
|
||||
function HTTPrequest(url,method)
|
||||
local data={}
|
||||
local res,code,response_headers,response_body=http.request{
|
||||
url=url,
|
||||
sink=ltn12.sink.table(data),
|
||||
method=method or"GET",
|
||||
}
|
||||
if code~=200 then
|
||||
LOG.print("NET ERROR: code="..(code or"nil"))
|
||||
end
|
||||
return data[1]
|
||||
end
|
||||
--[[
|
||||
LOADLIB("NETlib")
|
||||
function HTTPrequest(url,method)
|
||||
do--httpRequest
|
||||
client=LOADLIB("NETlib")
|
||||
function httpRequest(tick,url,method)
|
||||
local task,err=client.httpraw{
|
||||
url=url,
|
||||
method=method,
|
||||
method=method or"GET",
|
||||
-- header={},
|
||||
-- body="",
|
||||
}
|
||||
if not err then
|
||||
TASK.new(TICK.httpRequest,{code=task,time=0})
|
||||
if task then
|
||||
TASK.new(tick,{task=task,time=0})
|
||||
else
|
||||
LOG.print("NET error: "..err,"error")
|
||||
LOG.print("NETlib error: "..err,"warn")
|
||||
end
|
||||
end
|
||||
]]
|
||||
end
|
||||
do--json
|
||||
--
|
||||
|
||||
@@ -926,20 +926,8 @@ do--intro
|
||||
for i=1,8 do
|
||||
sceneTemp.r[i]=rnd(5)
|
||||
end
|
||||
local notice=HTTPrequest("http://47.103.200.40/api/notice")
|
||||
if notice then
|
||||
LOG.print(notice,"message")
|
||||
else
|
||||
LOG.print(text.getNoticeFail,"warn")
|
||||
end
|
||||
local newVersion=HTTPrequest("http://47.103.200.40/api/version_check")
|
||||
if not newVersion then
|
||||
LOG.print(text.getVersionFail,"warn")
|
||||
elseif newVersion~=gameVersion then
|
||||
LOG.print(string.gsub(text.versionIsOld,"$1",newVersion),"warn")
|
||||
else
|
||||
LOG.print(text.versionIsNew,"message")
|
||||
end
|
||||
|
||||
httpRequest(TICK.httpREQ_launch,"http://47.103.200.40/api/game")
|
||||
end
|
||||
|
||||
function mouseDown.intro(x,y,k)
|
||||
@@ -2414,9 +2402,6 @@ do--play
|
||||
end
|
||||
end
|
||||
do--pause
|
||||
local ranks={
|
||||
|
||||
}
|
||||
local rankColor={
|
||||
Z=color.lYellow,
|
||||
S=color.lGrey,
|
||||
|
||||
@@ -74,4 +74,31 @@ function Tick.autoPause(data)
|
||||
return true
|
||||
end
|
||||
end
|
||||
function Tick.httpREQ_launch(data)
|
||||
local res,err=client.poll(data.task)
|
||||
if res then
|
||||
if res.code==200 then
|
||||
res=json.decode(res.body)
|
||||
LOG.print(res.notice,"message")
|
||||
if gameVersion==res.version then
|
||||
LOG.print(text.versionIsNew,"message")
|
||||
else
|
||||
LOG.print(string.gsub(text.versionIsOld,"$1",res.version),"warn")
|
||||
end
|
||||
return true
|
||||
else
|
||||
LOG.print("Code error: "..res.code,"warn")
|
||||
return true
|
||||
end
|
||||
elseif err then
|
||||
LOG.print(text.getNoticeFail..":"..err,"warn")
|
||||
return true
|
||||
end
|
||||
data.time=data.time+1
|
||||
if data.time==180 then
|
||||
LOG.print(text.httpTimeout,"message")
|
||||
coroutine.resume(data.selfFunc)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return Tick
|
||||
Reference in New Issue
Block a user