优化textbox控件的行为,联网对战时能显示消息提示了

This commit is contained in:
MrZ626
2021-05-02 02:20:36 +08:00
parent 9adaa3c3d6
commit 72524ab50f
2 changed files with 11 additions and 11 deletions

View File

@@ -871,7 +871,7 @@ function textBox:update()
end end
function textBox:push(t) function textBox:push(t)
ins(self.texts,t) ins(self.texts,t)
if self.scrollPos==#self.texts-1 then if self.scrollPos==#self.texts-1 and not(self.hide==true or self.hide and self.hide())then
self.scrollPos=#self.texts self.scrollPos=#self.texts
else else
self.new=true self.new=true
@@ -902,9 +902,6 @@ function textBox:scroll(n)
self.scrollPos=max(self.scrollPos+n,min(#self.texts,self.capacity)) self.scrollPos=max(self.scrollPos+n,min(#self.texts,self.capacity))
else else
self.scrollPos=min(self.scrollPos+n,#self.texts) self.scrollPos=min(self.scrollPos+n,#self.texts)
if self.scrollPos==#self.texts then
self.new=false
end
end end
end end
function textBox:clear() function textBox:clear()
@@ -918,6 +915,10 @@ function textBox:draw()
local scroll=self.scrollPos local scroll=self.scrollPos
local cap=self.capacity local cap=self.capacity
--Update new message status, necessary when hide==true
if self.scrollPos==#self.texts then
self.new=false
end
--Background --Background
gc.setColor(0,0,0,.3) gc.setColor(0,0,0,.3)

View File

@@ -237,7 +237,7 @@ function scene.draw()
drawFWM() drawFWM()
--Players --Players
for p=textBox.hide and 1 or 2,#PLAYERS do for p=1,#PLAYERS do
PLAYERS[p]:draw() PLAYERS[p]:draw()
end end
@@ -278,11 +278,12 @@ function scene.draw()
--Profile --Profile
drawSelfProfile() drawSelfProfile()
end end
--New message --New message
if textBox.new and textBox.hide then if textBox.new then
setFont(30) setFont(40)
gc.setColor(1,TIME()%.4<.2 and 1 or 0,0) gc.setColor(1,.5+.5*math.sin(TIME()*26),0)
gc.print("M",460,15) gc.print("M",430,10)
end end
end end
scene.widgetList={ scene.widgetList={
@@ -293,7 +294,6 @@ scene.widgetList={
return return
playing or playing or
NET.serverGaming or NET.serverGaming or
not textBox.hide or
PLY_NET[1].ready or PLY_NET[1].ready or
NET.getlock('ready') NET.getlock('ready')
end}, end},
@@ -302,7 +302,6 @@ scene.widgetList={
return return
playing or playing or
NET.serverGaming or NET.serverGaming or
not textBox.hide or
not PLY_NET[1].ready or not PLY_NET[1].ready or
NET.getlock('ready') NET.getlock('ready')
end}, end},