Duyuruların Renkli Geçmesi

AhmetTeyfik

Süper Moderatör
Süper Moderatör
Premium Üye
Geliştirici
Yardımsever Üye
Editör
Mesaj
840
Çözümler
44
Beğeni
886
Puan
959
Ticaret Puanı
0
Bir arkadaş sormuş bende nasıl yapılır diye bakındım ve bunu yaptım.
Not: küçükde olsa ilk defa ortaya kendim bir şey çıkardım alırım bir like :D

Linkleri görebilmek için giriş yap veya kayıt ol.


Root > uitip.py class TipBoard(ui.Bar): komple değiştir.
Root > uitip.py:
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()

Örnek 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

0923_014309.jpg
 
Son düzenleme:
artık o [Dev] tagını hak ettiğimi düşünüyorum :D
 
Geri
Üst