Jump to content

TipBoard #lag fix


Daemon

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...