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