Jump to content

Anuncios coloridos


alexander0195

Recommended Posts

 

Un amigo me preguntó cómo hacerlo y lo hice.
Nota: si es pequeño, se me ocurrirá algo por primera vez


Root > uitip.py class TipBoard(ui.Bar)

 

class TipBoard(ui.Bar):

    SCROLL_WAIT_TIME = 3.0
    TIP_DURATION = 5.0
    STEP_HEIGHT = 17

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

        self.AddFlag("not_pick")
        self.tipList = []
        self.curPos = 0
        self.dstPos = 0
        self.nextScrollTime = 0

        self.width = 370   

        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 = TextBar(370, 300)
        self.textBar.SetParent(self)
        self.textBar.SetPosition(3, 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
        for tip in self.tipList:
            text = tip[1]
            rgb = tip[2]
            if rgb != (0,0,0):
                self.textBar.SetTextColor(rgb[0],rgb[1],rgb[2])
            self.textBar.TextOut(0, index*self.STEP_HEIGHT, text)
            self.textBar.SetTextColor(255,255,255)
            index += 1

    def SetTip(self, text):
        if not app.IsVisibleNotice():
            return

        rgb = (0,0,0)
        mat = re.search("\|cFF([a-zA-Z0-9]+)\|h", text)
        if mat and mat.group(1):
            hexd = mat.group(1)
            rgb = tuple(int(hexd[i:i+2], 16) for i in (0, 2, 4))

        curTime = app.GetTime()
        self.tipList.append((curTime, text, rgb))
        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(3, 5 - self.curPos)
            self.Show()

    def OnUpdate(self):

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

        if app.GetTime() > self.nextScrollTime:
            self.nextScrollTime = app.GetTime() + self.SCROLL_WAIT_TIME

            self.dstPos = self.curPos + self.STEP_HEIGHT

        if self.dstPos > self.curPos:
            self.curPos += 1
            self.textBar.SetPosition(3, 5 - self.curPos)

            if self.curPos > len(self.tipList)*self.STEP_HEIGHT:
                self.curPos = -self.STEP_HEIGHT
                self.dstPos = -self.STEP_HEIGHT

                self.__CleanOldTip()

QUEST

quest Elisia begin

state start begin

when login begin

send_letter("Duyurular")

end -- when

when button or info begin

send_letter("Duyurular")

notice_all("|cFF29BFBF|h<Duyuru> MmoTutkunlari <3")

notice_all("|cFFFF0000|h<Duyuru> MmoTutkunlari <3")

notice_all("|cFF00FF66|h<Duyuru> MmoTutkunlari <3")

notice_all("<Duyuru> MmoTutkunlari <3")

end-- when

end -- state

end -- quest

 

Debes iniciar sesión para ver el contenido del archivo adjunto en esta publicación.

Link 

Debes iniciar sesión para ver el contenido del enlace en esta publicación.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...