- Joined
- Apr 6, 2008
- Messages
- 760
Why does this give a "|c" in the start of the texttag where i create the bar?
JASS:
library BarSystem needs ARGB, Table
globals
private integer DEFAULT_BACKGROUND_COLOR = 0xFF808080
private integer DEFAULT_BAR_COLOR = 0xFFFF0000
endglobals
interface BarInterface
endinterface
struct Bar extends BarInterface
texttag Text
unit Target
integer BarSize
integer PlayerIndex
real TextSize
string Txt
string PText
string BarType
ARGB Color
ARGB BackColor
private boolean Locked = false
private static integer Index = 0
private static integer array IndexStack
private static timer Time = CreateTimer()
static method create takes string BarType, integer BarSize, real TextSize, real x, real y returns thistype
local thistype this = thistype.allocate()
set .Text = CreateTextTag()
set .BarSize = BarSize
set .BarType = BarType
set .Color = ARGB(DEFAULT_BAR_COLOR)
set .BackColor = ARGB(DEFAULT_BACKGROUND_COLOR)
set .TextSize = TextSize
call .BuildBar()
call SetTextTagText(.Text, .PText, .TextSize)
call SetTextTagColor(.Text, .BackColor.red, .BackColor.green, .BackColor.blue, .BackColor.alpha)
call SetTextTagPos(.Text, x, y, -400)
return this
endmethod
method BuildBar takes nothing returns nothing
local integer index = 0
set .PText = ""
loop
exitwhen index >= .BarSize
set .PText = .PText + .BarType
set index = index + 1
endloop
endmethod
method operator Value= takes integer value returns nothing
if value > .BarSize then
set value = .BarSize
debug call BJDebugMsg(SCOPE_PREFIX+" value > then BarSize")
endif
set .Txt = ""
set .Txt = .Color.str(SubString(.PText,0, value))
set .Txt = .Txt + SubString(.PText, value, .BarSize)
call SetTextTagText(.Text, .Txt, .TextSize)
endmethod
method LockToUnit takes unit u returns nothing
set .Target = u
set .Locked = true
set .IndexStack[.Index] = this
set .Index = .Index + 1
if .Index == 1 then
call BJDebugMsg("START")
call TimerStart(.Time, 0.03,true,function thistype.MoveBar)
endif
endmethod
static method MoveBar takes nothing returns nothing
local thistype this
local integer index = .Index - 1
loop
exitwhen index < 0
set this = .IndexStack[index]
call SetTextTagPos(.Text,GetUnitX(.Target),GetUnitY(.Target),-400)
set index = index - 1
endloop
endmethod
endlibrary