增加正在联网提示

This commit is contained in:
MrZ626
2020-10-20 13:37:08 +08:00
parent 33df3fcb49
commit 8ac1720e9d
4 changed files with 30 additions and 19 deletions

View File

@@ -532,6 +532,13 @@ function love.run()
_.draw(_.time)
end
--Draw network working
if TASK.netTaskCount>0 then
setFont(30)
gc.setColor(color.rainbow(Timer()*5))
gc.print("E",1250,0,.26+.355*math.sin(Timer()*6.26))
end
--Draw FPS
gc.setColor(1,1,1)
setFont(15)

View File

@@ -1,7 +1,9 @@
local rem=table.remove
local tasks={}
local TASK={}
local TASK={
netTaskCount=0,
}
function TASK.getCount()
return #tasks
end
@@ -9,6 +11,9 @@ function TASK.update()
for i=#tasks,1,-1 do
local T=tasks[i]
if T.code(T.data)then
if T.data.net then
TASK.netTaskCount=TASK.netTaskCount-1
end
rem(tasks,i)
end
end

View File

@@ -164,24 +164,23 @@ do--dumpTable
end
do--httpRequest
client=LOADLIB("NETlib")
if client then
function httpRequest(tick,url,method,header,body)
local task,err=client.httpraw{
url=url,
method=method or"GET",
header=header,
body=body,
}
if task then
TASK.new(tick,{task=task,time=0})
else
LOG.print("NETlib error: "..err,"warn")
end
end
else
function httpRequest(...)
LOG.print("[NO NETlib]",5,color.yellow)
httpRequest=
client and function(tick,api,method,header,body)
local task,err=client.httpraw{
url="http://47.103.200.40/"..api,
method=method or"GET",
header=header,
body=body,
}
if task then
TASK.new(tick,{task=task,time=0,net=true})
else
LOG.print("NETlib error: "..err,"warn")
end
TASK.netTaskCount=TASK.netTaskCount+1
end or
function()
LOG.print("[NO NETlib]",5,color.yellow)
end
end
do--json

View File

@@ -232,7 +232,7 @@ do--load
--------------------------
SFX.play("welcome_sfx")
VOC.play("welcome_voc")
httpRequest(TICK.httpREQ_launch,"http://47.103.200.40/api/game")
httpRequest(TICK.httpREQ_launch,"api/game")
else
S.cur=S.cur+1
S.tar=S.cur