Thread Tools Display Modes
07-07-09, 09:04 AM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
castbar - CustomTimeText

I'm currently trying to make my castbar time text look like the second one in the screenshot.



It is already looking like the first one. Code looks like:
Code:
local function CustomTimeText(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f / %.1f', (self.max - duration), self.max)
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f / %.1f', duration, self.max)
	end
end
The question is: How do I format the code above to make it look like the second (photoshop'ed) format.

I'm guessing it's not possible, but maybe if I use TWO different CustomTimeTexts that can be placed and formatted (size, position) differently? If that would be possible, I failed at accomplishing this, until now.

Help!
  Reply With Quote
07-07-09, 10:04 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Add another fontstring.
  Reply With Quote
07-07-09, 01:17 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Yeah I tried. However, I still don't really get it, yet.

I don't know how to call for a second CustomTimeText, without the first one being "overwritten". Using the default time text (for casting time), creating a second fontstring and overwriting the second one with the CustomTimeText doesn't seem to work either, since once I call for
Code:
self.Castbar.CustomTimeText = CustomTimeText
it overwrites all castbar fontstrings, it seems.

Last Thing I tried was this:

Code:
local function CustomTimeText(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f / ', (self.max - duration))
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f / ', duration)
	end
end

local function CustomTimeText2(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f', self.max)
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f', self.max)
	end
end
and

Code:
	    self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY')
	    self.Castbar.Time:SetPoint('RIGHT', self.Castbar, 0, 18)
	    self.Castbar.Time:SetFont(font, fontS, fontF)
	    self.Castbar.Time:SetTextColor(1, 1, 1)
	    self.Castbar.Time:SetJustifyH('RIGHT')

		self.Castbar.CustomTimeText = CustomTimeText
		
	    self.Castbar.Time2 = self.Castbar:CreateFontString(nil, 'OVERLAY')
	    self.Castbar.Time2:SetPoint('RIGHT', self.Castbar, 20, 8)
	    self.Castbar.Time2:SetFont(font, fontS, fontF)
	    self.Castbar.Time2:SetTextColor(1, 1, 1)
	    self.Castbar.Time2:SetJustifyH('RIGHT')

		self.Castbar.CustomTimeText2 = CustomTimeText2
Which simply ignores CustomTimeText2 (removing the 2) results in printing the second CustomTimeText, but overwriting, thus "hiding" the first one and showing the static overall cast time....

What am I doing wrong?
  Reply With Quote
07-07-09, 01:23 PM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Dawn View Post
Yeah I tried. However, I still don't really get it, yet.

I don't know how to call for a second CustomTimeText, without the first one being "overwritten". Using the default time text (for casting time), creating a second fontstring and overwriting the second one with the CustomTimeText doesn't seem to work either, since once I call for
Code:
self.Castbar.CustomTimeText = CustomTimeText
it overwrites all castbar fontstrings, it seems.

Last Thing I tried was this:

Code:
local function CustomTimeText(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f / ', (self.max - duration))
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f / ', duration)
	end
end

local function CustomTimeText2(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f', self.max)
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f', self.max)
	end
end
and

Code:
	    self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY')
	    self.Castbar.Time:SetPoint('RIGHT', self.Castbar, 0, 18)
	    self.Castbar.Time:SetFont(font, fontS, fontF)
	    self.Castbar.Time:SetTextColor(1, 1, 1)
	    self.Castbar.Time:SetJustifyH('RIGHT')

		self.Castbar.CustomTimeText = CustomTimeText
		
	    self.Castbar.Time2 = self.Castbar:CreateFontString(nil, 'OVERLAY')
	    self.Castbar.Time2:SetPoint('RIGHT', self.Castbar, 20, 8)
	    self.Castbar.Time2:SetFont(font, fontS, fontF)
	    self.Castbar.Time2:SetTextColor(1, 1, 1)
	    self.Castbar.Time2:SetJustifyH('RIGHT')

		self.Castbar.CustomTimeText2 = CustomTimeText2
Which simply ignores CustomTimeText2 (removing the 2) results in printing the second CustomTimeText, but overwriting, thus "hiding" the first one and showing the static overall cast time....

What am I doing wrong?

Code:
local function CustomTimeText(self, duration)
	if self.casting then
		self.Time:SetFormattedText('%.1f / ', (self.max - duration))
		self.Time2:SetFormattedText('%.1f', self.max)
	elseif self.channeling then
		self.Time:SetFormattedText('%.1f / ', duration)
		self.Time2:SetFormattedText('%.1f', self.max)
	end
end
and

Code:
self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY')
self.Castbar.Time:SetPoint('RIGHT', self.Castbar, 0, 18)
self.Castbar.Time:SetFont(font, fontS, fontF)
self.Castbar.Time:SetTextColor(1, 1, 1)
self.Castbar.Time:SetJustifyH('RIGHT')

self.Castbar.Time2 = self.Castbar:CreateFontString(nil, 'OVERLAY')
self.Castbar.Time2:SetPoint('RIGHT', self.Castbar, 20, 8)
self.Castbar.Time2:SetFont(font, fontS, fontF)
self.Castbar.Time2:SetTextColor(1, 1, 1)
self.Castbar.Time2:SetJustifyH('RIGHT')

self.Castbar.CustomTimeText = CustomTimeText
Its not rocket science
  Reply With Quote
07-07-09, 02:49 PM   #5
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
But ... I .. err, want to fly! Hmkay, works nice. Thanks
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » castbar - CustomTimeText


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off