[PY] Enable colors in Notice Board (1 İzleyici)

[PY] Enable colors in Notice Board
1
1K

admin

PATRON
SİTE YETKİLİSİ
Moderator
ÜYE
Katılım
23 Eki 2022
Mesajlar
3,501
Çözümler
9
Tepkime puanı
2,142
Puanları
113
Yaş
28
Ticaret Puanı: 0 / 0 / 0
1689945668369.png

Open uitip.py and add this to the start of the file:
Python:
import re

Now find class TipBoard(ui.Bar):, and replace it with this:



Python:
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()

Example of use:



Python:
--- in quests:

        notice_all("|cFF29BFBF|hColored text Example#1")
        notice("|cFFFF0000|hColored text Example #2")

--- ingame:
        "n |cFF29BFBF|h Hello World"
 
  • Beğen
Tepkiler: Ene

Ene

ÜYE
Katılım
6 Tem 2024
Mesajlar
9
Tepkime puanı
0
Puanları
1
Yaş
18
Konum
romania
Ticaret Puanı: 0 / 0 / 0
🫣❤️
 

Konuya görüntüleyenler

Benzer konular Forum Tarih
5 C++ / C# / Python 0 952
5 C++ / C# / Python 0 1K

Benzer konular

R10dev.net'i ana ekrana ekle!
Üst