Only Show 1 notice
And please qualify my english. X/10
Video GIF:

Same code in pastebin:

Code:
Code:
##Mr.Toll, Zeler-* Strel
##Espero te sirva de mucho
class TipBoard(ui.Bar):
SCROLL_WAIT_TIME = 1.0#3.0
TIP_DURATION = 1.0#5.0
STEP_HEIGHT = 17
def __init__(self):
ui.Bar.__init__(self)
self.ceh=0
self.AddFlag("not_pick")
self.tipList = []
self.curPos = 0
self.dstPos = 0
self.nextScrollTime = 0
self.lastclock = time.clock()
self.width = wndMgr.GetScreenWidth()
self.SetPosition(0, 70)
self.SetSize(wndMgr.GetScreenWidth(), 20)
self.SetColor(grp.GenerateColor(0.0, 1.0, 0.0, 0.1))
# self.SetWindowHorizontalAlignLeft()
self.__CreateTextBar()
def __del__(self):
ui.Bar.__del__(self)
def __CreateTextBar(self):
x, y = self.GetGlobalPosition()
self.textBar = TextBar(wndMgr.GetScreenWidth(), 300)
self.textBar.SetParent(self)
self.textBar.SetPosition(wndMgr.GetScreenWidth(), 5)
self.textBar.SetClipRect(0, y, wndMgr.GetScreenWidth(), y+18)
self.textBar.Show()
def __CleanOldTip(self):
leaveList = []
for tip in self.tipList:
madeTime = tip[0]
if app.GetTime() - madeTime > self.TIP_DURATION:
pass
else:
leaveList.append(tip)
self.tipList = leaveList
if not leaveList:
self.textBar.ClearBar()
self.Hide()
return
# self.__RefreshBoard()
# def __RefreshBoard(self):
# self.textBar.ClearBar()
# index = 0
# dt = time.clock() - self.lastclock
# for tip in self.tipList:
# text = tip[1]
# self.textBar.TextOut(int(self.textBar.GetGlobalPosition()[1]+dt*200), index*self.STEP_HEIGHT, text)
# index += 1
def SetTip(self, text):
if not app.IsVisibleNotice():
return
curTime = app.GetTime()
self.tipList.append((curTime, text))
# self.__RefreshBoard()
self.nextScrollTime = app.GetTime() + 1.0
if not self.IsShow():
self.curPos = -self.STEP_HEIGHT
self.dstPos = -self.STEP_HEIGHT
self.textBar.SetPosition(wndMgr.GetScreenWidth(),0)
self.Show()
return
def Refresca(self):
dt = time.clock() - self.lastclock
ca=int(wndMgr.GetScreenWidth()-dt*15)
cas=0.0
if int(ca)==int(cas):
self.Hide()
self.__CleanOldTip()
def OnUpdate(self):
if self.ceh==0:
self.Refresca()
self.ceh=1
elif self.ceh==1:
self.Refresca()
self.ceh=0
self.Refresca()
self.textBar.ClearBar()
index = 0
dt = time.clock() - self.lastclock
for tip in self.tipList:
text = tip[1]
self.textBar.TextOut(int(wndMgr.GetScreenWidth()-dt*20), index*self.STEP_HEIGHT, text)
index += 1
if not self.tipList:
self.Hide()
return
self.dstPos = 18
if self.dstPos > self.curPos:
self.curPos += 1
self.textBar.SetPosition(3 , 6)







