From d5c657701b72c324202693ce2d753daacc7d3507 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 12 Oct 2020 08:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8aegistudio=E7=9A=84=E6=96=B0?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E5=BA=93=E8=8E=B7=E5=8F=96=E5=85=AC=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 8 ++++---- Zframework/languages.lua | 15 ++++++++++----- Zframework/toolfunc.lua | 29 +++++++---------------------- parts/scenes.lua | 19 ++----------------- parts/tick.lua | 27 +++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 48 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 57dcc77c..a001d575 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -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") diff --git a/Zframework/languages.lua b/Zframework/languages.lua index 9e5db973..63983dcc 100644 --- a/Zframework/languages.lua +++ b/Zframework/languages.lua @@ -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="长按重开", diff --git a/Zframework/toolfunc.lua b/Zframework/toolfunc.lua index ecbb0fdb..e39f9b04 100644 --- a/Zframework/toolfunc.lua +++ b/Zframework/toolfunc.lua @@ -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 -- diff --git a/parts/scenes.lua b/parts/scenes.lua index 29b52b2d..da4d029a 100644 --- a/parts/scenes.lua +++ b/parts/scenes.lua @@ -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, diff --git a/parts/tick.lua b/parts/tick.lua index fd4e71ce..70ffeac0 100644 --- a/parts/tick.lua +++ b/parts/tick.lua @@ -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 \ No newline at end of file