Jump to content

TipBoard #lag fix


Daemon
 Share

Recommended Posts

  • Administrator

Search for uitip.py

class TipBoard(ui.Bar):

Complete replace:

class TipBoard(ui.Bar):
    TIP_DURATION = 5.0
    def __init__(self):
        ui.Bar.__init__(self)
        self.AddFlag("not_pick")
        self.tipList = []
        self.nextScrollTime = 0
        self.SetPosition(0, 70)
        self.SetSize(370, 20)
        self.SetColor(grp.GenerateColor(0.0, 0.0, 0.0, 0.5))
        self.SetWindowHorizontalAlignCenter()
        self.__CreateTextBar()

    def __del__(self):
        ui.Bar.__del__(self)

    def __CreateTextBar(self):
        x, y = self.GetGlobalPosition()
        self.textBar = ui.TextLine()
        self.textBar.SetParent(self)
        self.textBar.SetWindowHorizontalAlignCenter()
        self.textBar.SetHorizontalAlignCenter()
        # self.textBar.SetPackedFontColor(0xfffcda00) #color change
        self.textBar.SetPosition(3, 3)     
        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.Hide()
            self.Hide()
            return

        self.__RefreshBoard()

    def __RefreshBoard(self):
        self.textBar.Hide()
        index = 0
        for tip in self.tipList:
            text = tip[1]
            self.textBar.SetText(str(text))
            self.textBar.Show()
            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()

        if not self.IsShow():
            self.Show()

    def OnUpdate(self):
        if not self.tipList:
            self.Hide()
            return

        if (app.GetTime() > (self.nextScrollTime)):
            self.nextScrollTime = app.GetTime()
            self.__CleanOldTip()
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...