Thread Tools Display Modes
08-19-11, 07:21 AM   #1
Dangergoppel
A Murloc Raider
Join Date: Oct 2008
Posts: 7
Remaining cast time as a tag?

(Might be obvious to most, but hey - I'm a newb at this, bear with me!)
I'm sure this is possible, but I've spent this whole morning trying to figure it out. Also, which event(s) is/are the best for updating this? I've gotten so far as to having the remaining duration without updates, and with like 100 decimals.

Any help appreciated.
  Reply With Quote
08-20-11, 03:52 AM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You define within your layout (if you want them to be custom):

self.Castbar.CustomTimeText
self.Castbar.CustomDelayText

and

self.Castbar.Time which is a font string

Here my custom time thingy:
lua Code:
  1. local CustomCastTimeText = function(self, duration)
  2.     self.Time:SetText(("%.1f / %.2f"):format(self.channeling and duration or self.max - duration, self.max))
  3. end
  4. ns.CustomCastTimeText = CustomCastTimeText
  5.  
  6. local CustomCastDelayText = function(self, duration)
  7.     self.Time:SetText(("%.1f |cffaf5050%s %.1f|r"):format(self.channeling and duration or self.max - duration, self.channeling and "- " or "+", self.delay))
  8. end
  9. ns.CustomCastDelayText = CustomCastDelayText

In order to show/hide them I use a script like that:
lua Code:
  1. self.Castbar:HookScript("OnShow", function() self.Castbar.Text:Show(); self.Castbar.Time:Show() end)
  2. self.Castbar:HookScript("OnHide", function() self.Castbar.Text:Hide(); self.Castbar.Time:Hide() end)

(self.Castbar.Text is the font string for the spell name on the castbar)

Hopefully this helps.
  Reply With Quote
08-20-11, 01:53 PM   #3
Dangergoppel
A Murloc Raider
Join Date: Oct 2008
Posts: 7
Either I'm just very confused, or you told me about how to change the castbar time text, not how to use it in a tag. (I guess I could've been more specific.)

What I want to do with it is something similar to my cast name/hp tag, which looks like this:
Code:
oUF.Tags['kwi:hpspell'] = function(unit)
	if(UnitCastingInfo(unit) == nil and UnitChannelInfo(unit) == nil) then
		return numFormat(UnitHealth(unit))
	end
	return UnitCastingInfo(unit) or UnitChannelInfo(unit)
end
  Reply With Quote
08-20-11, 10:18 PM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
You will probably run into issues with updating the tag, properly. Sticking with the functions described would be better.

Since the cast time is a font string you can still align it easily to be in line with your "tags font string". Like "BOTTOMLEFT", yourtagstring, "BOTTOMRIGHT" .... or something like that.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
08-21-11, 10:27 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
You can make oUF poll tags:
Code:
   fontstring.frequentUpdates = .1
   self:Tag(fontstring, '[my:Tag]')
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-21-11, 11:15 AM   #6
Dangergoppel
A Murloc Raider
Join Date: Oct 2008
Posts: 7
Okay, so I went with Dawn's way, but now I have encountered another problem. When I cast a spell, the times appears where it should, but when the decimal reaches the number 7, it jumps one pixel to the right, and then back again at 8.

Image example, if it helps:



Not the biggest thing, but pixel perfect is pixel perfect. <_<

Also, it only seems to happen when casting, not when channeling.
  Reply With Quote
08-21-11, 11:18 AM   #7
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Looks like its due to your font not being monospaced.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-21-11, 04:09 PM   #8
Dangergoppel
A Murloc Raider
Join Date: Oct 2008
Posts: 7
I don't want to question your expertise, but why does it work while channeling if that's the issue?

Edit: apparently it differs with which spell I channel, and what percentage of mana I'm on (which determines the string that it's hooked to). It feel kind of obvious that I'm doing something wrong, but what?

Code:
local ppval
ppval = lib.gen_fontstring(f.Health, FONT, 8, "OUTLINEMONOCHROME")
ppval:SetPoint("RIGHT", f.Health, "RIGHT", 2, -16)

if f.pptag then
	f:Tag(ppval, f.pptag)
else
	f:Tag(ppval, "[raidcolor][kwi:shards][kwi:ppcol][perpp]")
end

local t = lib.gen_fontstring(s, FONT, 8, "OUTLINEMONOCHROME")
t:SetPoint("RIGHT", hpval, "LEFT", 2, 0)

f.Castbar.Time = t
Might have shortened it down too much, hopefully not.

Last edited by Dangergoppel : 08-21-11 at 04:23 PM.
  Reply With Quote
08-22-11, 01:43 AM   #9
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Questioning my expertise is always good

Probably a combination/one of the following:
- Your font isn't monospaced at least, so the text will move slightly depending on what numbers are preset. For example the 7 is 3 pixels in width, while 4 is 4 pixels.
- Your fontstrings don't have any width, so they will grow/shrink based on how much space the text uses.

What you could do is use your own custom tag with proper padding:
Code:
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> =string.format('%3i', 100)
100
> return string.format('%3i', 95)
 95
This will create a small gap however. The text might still shift if the size of "1" is smaller than the size of the space character in the font. Another solution would be to split it into multiple fontstrings with proper widths.

It does sound odd that it would work correctly for one thing and not the other, as the input to the fontstring should be the same. I'm kinda assuming that it isn't exactly the case.
__________________
「貴方は1人じゃないよ」
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Remaining cast time as a tag?


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