修复聊天室清空按钮出现时机错误
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
local gc=love.graphics
|
||||
local Timer=love.timer.getTime
|
||||
|
||||
local ins=table.insert
|
||||
local ins,rem=table.insert,table.remove
|
||||
local max,min=math.max,math.min
|
||||
|
||||
local texts={}
|
||||
local remain--People in chat room
|
||||
local scroll--Bottom message no.
|
||||
local newMessasge=false--If there is a new message
|
||||
local newMessage=false--If there is a new message
|
||||
local heartBeatTimer
|
||||
|
||||
local function focusAtTextbox()
|
||||
@@ -21,7 +21,7 @@ local function sendMessage()
|
||||
end
|
||||
end
|
||||
local function clearHistory()
|
||||
texts={{COLOR.dG,text.chatHistory}}
|
||||
while #texts>1 do rem(texts)end
|
||||
scroll=1
|
||||
SFX.play("fall")
|
||||
collectgarbage()
|
||||
@@ -61,7 +61,7 @@ function scene.keyDown(k)
|
||||
elseif k=="down"then
|
||||
scroll=min(scroll+1,#texts)
|
||||
if scroll==#texts then
|
||||
newMessasge=false
|
||||
newMessage=false
|
||||
end
|
||||
elseif k=="return"then
|
||||
sendMessage()
|
||||
@@ -100,7 +100,7 @@ function scene.socketRead(mes)
|
||||
scroll=scroll+1
|
||||
else
|
||||
SFX.play("spin_0",.8)
|
||||
newMessasge=true
|
||||
newMessage=true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -131,7 +131,7 @@ function scene.draw()
|
||||
end
|
||||
|
||||
--Draw
|
||||
if newMessasge and scroll~=#texts then
|
||||
if newMessage and scroll~=#texts then
|
||||
setFont(40)
|
||||
gc.setColor(1,Timer()%.4<.2 and 1 or 0,0)
|
||||
gc.print("v",8,480)
|
||||
@@ -140,7 +140,7 @@ end
|
||||
|
||||
scene.widgetList={
|
||||
WIDGET.newTextBox{name="text", x=40, y=500,w=980,h=180,font=40},
|
||||
WIDGET.newButton{name="clear", x=1140, y=440,w=170,h=80,font=40,code=clearHistory,hide=function()return #texts>1 and not newMessasge end},
|
||||
WIDGET.newButton{name="clear", x=1140, y=440,w=170,h=80,font=40,code=clearHistory,hide=function()return #texts<2 or newMessage end},
|
||||
WIDGET.newButton{name="send", x=1140, y=540,w=170,h=80,font=40,code=sendMessage},
|
||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user