Thread Tools Display Modes
02-21-09, 07:58 PM   #781
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by MoonWitch View Post
I'm just trying to clean up my code, and avoid loooong if loops
You cant do it that way.
You cannot use SetManyAttributes() within the layout code neither
 
02-21-09, 08:15 PM   #782
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by p3lim View Post
You cant do it that way.
You cannot use SetManyAttributes() within the layout code neither
*sad panda face*

But I tried :P I'll still have a good deal of if-loops, but it's probably unavoidable. Now onto working with those tags :P And getting colors right for once.
 
02-21-09, 10:23 PM   #783
Dimpf
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 25
I've got a question about SetFont(), I suppose. My text seems to be working for health, power, name, and info objects, but it refuses to work for cast bar and druid mana.

My mana bar code is:
Code:
if unit == "player" and playerClass == "DRUID" then
	self.DruidPower = CreateFrame('StatusBar', nil, self)
	self.DruidPower:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', -2, 0)
	self.DruidPower:SetStatusBarTexture(texture)
	self.DruidPower:SetHeight(playerHPHeight)
	self.DruidPower:SetWidth(playerHPWidth)
	self.DruidPower:SetFrameStrata("HIGH")
	self.DruidPower:SetAlpha(0)
	
	self.DruidPower.value = self.DruidPower:CreateFontString(nil, "OVERLAY")
	self.DruidPower.value:SetFont(font, 10, "NONE")
	self.DruidPower.value:SetShadowOffset(1, -1)
	self.DruidPower.value:SetPoint('CENTER', 0, 3)
	self.DruidPower.value:SetTextColor(1, 1, 1)

	self.DruidPower.bg = self.DruidPower:CreateTexture(nil, 'BORDER')
	self.DruidPower.bg:SetAllPoints(self.DruidPower)
	self.DruidPower.bg:SetTexture(0, 0, 0, 0.6)
	
	self:RegisterEvent('UNIT_MANA', UpdateDruidPower)
	self:RegisterEvent('UNIT_ENERGY', UpdateDruidPower)
	self:RegisterEvent('PLAYER_LOGIN', UpdateDruidPower)
end
...which creates the frame well enough.

This is my update function:
Code:
local function UpdateDruidPower(self)
	local bar = self.DruidPower
	local num, str = UnitPowerType('player')
	local min = UnitPower('player', (num ~= 0) and 0 or 3)
	local max = UnitPowerMax('player', (num ~= 0) and 0 or 3)

	bar:SetMinMaxValues(0, max)

	if(min ~= max) then
		bar:SetValue(min)
		bar:SetAlpha(1)
		bar:SetStatusBarColor(unpack(oUF.colors.power['MANA']))
		bar.value:SetFormattedText('%d / %d', min, max)
	else
		bar:SetAlpha(0)
		bar.value:SetText()
	end
end
This is throwing errors whenever I shift in and out:

oUF_Saone-1.0\ouf_saone.lua:154: <unnamed>:SetText(): Font not set
oUF_Saone-1.0\ouf_saone.lua:154: in function `?'
oUF-1.3.5\ouf.lua:112: in function <Interface\AddOns\oUF\ouf.lua:110>

...and another for the other SetFormattedText() earlier (line 154 is bar.value:SetText())

Any ideas? It's obviously something to do with my font, but I declared that correctly. This is driving me nuts, and I don't *THINK* I'm doing anything horribly wrong.

Also, any ideas on how to make it despawn faster? It seems to linger for a few seconds after I shift out.

Edit:

If I change my
self.DruidPower.value = self.DruidPower:CreateFontString(nil, "OVERLAY")
to:
self.DruidPower.value = self.DruidPower:CreateFontString(nil, "OVERLAY", "GameFontHighlightExtraSmall")
...it works, but that's not entirely what I'm trying to achieve.

Edit again:

Looks like self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", UpdateDruidPower); helps the frame despawn faster. I'm not familiar with other oUF modules using that, so I figured I'd mention it.

/sigh...

Last edited by Dimpf : 02-21-09 at 10:33 PM.
 
02-22-09, 07:08 AM   #784
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
In your SetFont declaration...

self.DruidPower.value:SetFont(font, 10)

Remove the none
 
02-22-09, 11:06 AM   #785
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Sorry for repeating myself, but does anyone have an idea about debuff filtering, yet?

Last edited by Dawn : 02-22-09 at 11:12 AM.
 
02-22-09, 04:26 PM   #786
coree
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 28
i would like to know how to add an event to an existing function (ie PostUpdateHealth) ?
Just RegisterEvent("EVENT_NAME",PostUpdateHealth) ?
 
02-22-09, 04:33 PM   #787
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Yes. Why not just try it?
 
02-22-09, 04:35 PM   #788
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by coree View Post
i would like to know how to add an event to an existing function (ie PostUpdateHealth) ?
Just RegisterEvent("EVENT_NAME",PostUpdateHealth) ?
Always test something before you ask..
In other words, yes.
 
02-23-09, 05:28 AM   #789
coree
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 28
Originally Posted by p3lim View Post
Always test something before you ask..
In other words, yes.
thanks,
i tried it before, but it didnt work.
therefore i asked wether it is the correct code or not.

edit: ok events work, but i get a different error.
here my code:
Code:
local function PostUpdateHealth(self, event, unit, bar, min, max)
  local min, max = UnitHealth(unit), UnitHealthMax(unit)
  local bar = self.Health
  local d = floor(min/max*100)
  if(unit == "player" or unit == "target") then 
    if(not UnitIsConnected(unit)) then
      bar.Text:SetText('Offline')
    elseif(UnitIsDead(unit)) then
      bar.Text:SetText('Dead')
    elseif(UnitIsGhost(unit)) then
      bar.Text:SetText('Ghost')
    else
      if (unit == 'target') then
        if (targetshort == true) then	
          bar.Text:SetText(ShortHp(min))
        else
          bar.Text:SetText(min)
        end	
      else
        if(min ~= max) then
          bar.Text:SetText(min)
        else
          if (UnitMana("player") > 0) then
            bar.Text:SetText(min)
          elseif (UnitMana("player") == 0) then
            bar.Text:SetText()
          elseif(UnitAffectingCombat("player") == 1) then
            bar.Text:SetText(min)
          else
            bar.Text:SetText()
          end
        end
      end
    end
  end
end
Code:
local func = function(settings, self, unit)
...
  self:RegisterEvent("UNIT_MANA", PostUpdateHealth)
  self:RegisterEvent("UNIT_RAGE", PostUpdateHealth)
  self:RegisterEvent("UNIT_ENERGY", PostUpdateHealth)
  self:RegisterEvent("UNIT_RUNIC_POWER", PostUpdateHealth)
  self:RegisterEvent("PLAYER_REGEN_DISABLED", PostUpdateHealth)
  self:RegisterEvent("PLAYER_REGEN_ENABLED", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXMANA", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXRAGE", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXFOCUS", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXENERGY", PostUpdateHealth)
  self:RegisterEvent("UNIT_DISPLAYPOWER", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXRUNIC_POWER", PostUpdateHealth)
end
And here you can see my problem:
With Rage = 0:

With Rage > 0 :


as you can see, my targets hp are now the same as my own hp.
:/

Last edited by coree : 02-23-09 at 10:20 AM.
 
02-23-09, 10:19 AM   #790
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by coree View Post
thanks,
i tried it before, but it didnt work.
therefore i asked wether it is the correct code or not.
Don't expect anything here. The "pro's" like use their time to post a one liner, telling you how you should know it yourself, instead of pointing you in a direction.
 
02-23-09, 10:23 AM   #791
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
You're registering onto an event, which fires for every frame, regardless of unit. In other words - you have to validate the unit that your event handler receives.

Also - editing posts means that people who use e-mail pings won't see them (such as myself).
 
02-23-09, 11:49 AM   #792
coree
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 28
Originally Posted by haste View Post
You're registering onto an event, which fires for every frame, regardless of unit. In other words - you have to validate the unit that your event handler receives.
Ok, i added the following code to fix this problem.
Code:
if(unit == "player") then
  self:RegisterEvent("UNIT_MANA", PostUpdateHealth)
  self:RegisterEvent("UNIT_RAGE", PostUpdateHealth)
  self:RegisterEvent("UNIT_ENERGY", PostUpdateHealth)
  self:RegisterEvent("UNIT_RUNIC_POWER", PostUpdateHealth)
  self:RegisterEvent("PLAYER_REGEN_DISABLED", PostUpdateHealth)
  self:RegisterEvent("PLAYER_REGEN_ENABLED", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXMANA", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXRAGE", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXFOCUS", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXENERGY", PostUpdateHealth)
  self:RegisterEvent("UNIT_DISPLAYPOWER", PostUpdateHealth)
  self:RegisterEvent("UNIT_MAXRUNIC_POWER", PostUpdateHealth)	
end
but when my target loses health, my own hpvalue gets the value of my target.
 
02-23-09, 12:00 PM   #793
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
you still don't prevent it from updating on the player frame when it fires for the target unit.

You can add the following in the top of your function, and it only execute for the correct unit. Another thing you should do is to remove the if(unit == 'target' or unit == 'player') part of your code.
Code:
if(self.unit ~= unit) then return end
 
02-23-09, 12:21 PM   #794
coree
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 28
Originally Posted by haste View Post
Another thing you should do is to remove the if(unit == 'target' or unit == 'player') part of your code.
thanks now it works !
i have the if(unit == target or unit == player) part because,i have another text for targettarget, pet, focus

thats the whole function:
Code:
local function PostUpdateHealth(self, event, unit, bar, min, max)
  if(self.unit ~= unit) then return end
  local min, max = UnitHealth(unit), UnitHealthMax(unit)
  local bar = self.Health
  local d = floor(min/max*100)
    if(not UnitIsConnected(unit)) then
      bar.Text:SetText('Offline')
    elseif(UnitIsDead(unit)) then
      bar.Text:SetText('Dead')
    elseif(UnitIsGhost(unit)) then
      bar.Text:SetText('Ghost')
    else
      if (unit == 'target') then
        if (targetshort == true) then
          bar.Text:SetText(ShortHp(min))
        else
          bar.Text:SetText(min)
        end			
      else
        if(min ~= max) then
          bar.Text:SetText(min)
        else
          if (UnitMana("player") > 0) then
            bar.Text:SetText(min)
          elseif (UnitMana("player") == 0) then
            bar.Text:SetText()
          elseif(UnitAffectingCombat("player") == 1) then
            bar.Text:SetText(min)
          else
            bar.Text:SetText()
          end
        end
      end
    end
  end
  if(not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit)) then
    bar.Text2:SetText()
  else
    if (unit == 'target') then	
      if (min ~= max) then
        bar.Text2:SetText(d.."%")
      else
        bar.Text2:SetText()			
      end
    else
      if(min ~= max) then
        if(d < 100) then
          bar.Text2:SetText(d.."%")
        end
      else
        bar.Text2:SetText()
      end
    end
  end	
end
ok i could delete the if (unit == target or unit == player) part and hide this text in the layout.
 
02-24-09, 11:02 AM   #795
Zyonin
Coffee powered Kaldorei
 
Zyonin's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 1,443
OK, here is what I am trying to do:

I want to be able to set the layout's font (aka a custom font) and size of the font in question. Previously I had been using a method stolen from Wimpface's layout (oUF_Faith), however I want to have the font contained within the layout's folder as a opposed to a external AddOn.

Aka

oUF_Layout
- oUF_Layout.lua
- font

Or have the font in a Media folder in my layout folder.

I have tried studying those layouts that use a font other than the standard game fonts (aka I don't want "GameFontHighlightSmall", etc.). My first attempt was to simply try a GameFontHighlightSmall (GameFontHighLightSmall is the font in the p3lim's layout, which is the layout I am learning from) = font of my choice, and while I get the font I want, I cannot control the size of the font. I have then looked at other layouts however no single layout ever seems to use the same method. I have tried adapting other methods to my current Frankenstein of a layout however I have yet to get anything other than my layout going belly up and Bugsack yelling at me. I am learning from my n00bish mistakes, however I have yet to get the results I want.

So I do I replace:

Code:
self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
With a string to specify 1) My chosen font. 2) The font size?

Currently I have my specified font in a local at the top of my layout in the following format (example only):

Code:
local font = "Interface\\AddOns\\oUF_Example\\Example_Font.ttf"
Or am I simply barking up the wrong friggin tree? Once I get this issue licked, I cn tackle more interesting things as I am getting my layout to do what I want (mostly).
__________________
Twitter

Last edited by Zyonin : 02-24-09 at 11:09 AM.
 
02-24-09, 11:21 AM   #796
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Lykofos View Post
OK, here is what I am trying to do:

I want to be able to set the layout's font (aka a custom font) and size of the font in question. Previously I had been using a method stolen from Wimpface's layout (oUF_Faith), however I want to have the font contained within the layout's folder as a opposed to a external AddOn.

Aka

oUF_Layout
- oUF_Layout.lua
- font

Or have the font in a Media folder in my layout folder.

I have tried studying those layouts that use a font other than the standard game fonts (aka I don't want "GameFontHighlightSmall", etc.). My first attempt was to simply try a GameFontHighlightSmall (GameFontHighLightSmall is the font in the p3lim's layout, which is the layout I am learning from) = font of my choice, and while I get the font I want, I cannot control the size of the font. I have then looked at other layouts however no single layout ever seems to use the same method. I have tried adapting other methods to my current Frankenstein of a layout however I have yet to get anything other than my layout going belly up and Bugsack yelling at me. I am learning from my n00bish mistakes, however I have yet to get the results I want.

So I do I replace:

Code:
self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
With a string to specify 1) My chosen font. 2) The font size?

Currently I have my specified font in a local at the top of my layout in the following format (example only):

Code:
local font = "Interface\\AddOns\\oUF_Example\\Example_Font.ttf"
Or am I simply barking up the wrong friggin tree? Once I get this issue licked, I cn tackle more interesting things as I am getting my layout to do what I want (mostly).
I inherit my fonts in the CreateFontString.
An other way to do the same would be 'fontstring:SetFontObject()'
Your example.
Code:
fontstring:SetFontObject('GameFontHighlightSmallRight')
is the same as
Code:
fontstring:SetFont('Fonts\\FRIZQT__.TTF', 12)
fontstring:SetTextColor(1, 1, 1)
fontstring:SetJustifyH('RIGHT')
fontstring:SetShadowColor(0, 0, 0)
fontstring:SetShadowOffset(1, -1)
In other words, its pre-made font styles by blizzard

Last edited by p3lim : 02-24-09 at 11:24 AM.
 
02-24-09, 12:14 PM   #797
Zyonin
Coffee powered Kaldorei
 
Zyonin's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 1,443
Hmm, so I redo my font stings as thus:

Health:
Code:
	self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
	self.Health.Text:SetFont('Interface\AddOns\oUF_Lyk\font.ttf', 14)
Power:
Code:
		local power = self.Power:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
		power:SetFont('Interface\AddOns\oUF_Lyk\font.ttf', 14)
Target Name:
Code:
		local info = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
		info:SetFont('Interface\AddOns\oUF_Lyk\font.ttf', 14)
following the same format as the SetPoint line in each section.

All other modules (such as CastBar, etc) are currently disabled (their relavent sections are commented out) until I pin this down.
Worked through the idiot mistakes (like ")" in a weird spot due to a stupid typo on my part) and I get this barfed at me:

Code:
[2009/02/24 19:04:04-136-x1]: oUF-1.3.3\elements\tags.lua:269: <unnamed>:SetFormattedText(): Font not set
oUF-1.3.3\elements\tags.lua:269: in function `UpdateTag'
oUF-1.3.3\elements\tags.lua:142: in function `func'
oUF-1.3.3\ouf.lua:452: in function <Interface\AddOns\oUF\ouf.lua:447>
<in C code>: in function `Show'
Interface\FrameXML\SecureStateDriver.lua:72: in function <Interface\FrameXML\SecureStateDriver.lua:62>:
Interface\FrameXML\SecureStateDriver.lua:109: in function <Interface\FrameXML\SecureStateDriver.lua:79>:

  ---
Whatever I have done appears to make WoW blame oUF\elements\tags.lua even though I never touched it. For the time being I am going to revert back to the method that previously worked so I have a working layout for tonight, however I would like to get this pinned down.
__________________
Twitter

Last edited by Zyonin : 02-24-09 at 12:24 PM.
 
02-24-09, 12:20 PM   #798
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Youre giving SetFont() a wrong argument
 
02-24-09, 01:53 PM   #799
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by Lykofos View Post
Hmm, so I redo my font stings as thus:

Health:
Code:
	self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
	self.Health.Text:SetFont('Interface\AddOns\oUF_Lyk\font.ttf', 14)

Whatever I have done appears to make WoW blame oUF\elements\tags.lua even though I never touched it. For the time being I am going to revert back to the method that previously worked so I have a working layout for tonight, however I would like to get this pinned down.
local font = "Interface\\AddOnName\\font.ttf"

fontString = parentFrame:CreateFontString(nil, "OVERLAY")
fontString:SetFont(font, fontSizeOfYourChoice)
fontString:SetTextColor(r, g, b)

Note : when specifying folders in locations of files, you or use "x\\x\\x" (double \) or [=[x\x\x]=]

In your first line (self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')) -> you are already giving a font to use. Drop that part.
 
02-24-09, 04:21 PM   #800
Zyonin
Coffee powered Kaldorei
 
Zyonin's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 1,443
Originally Posted by MoonWitch View Post
local font = "Interface\\AddOnName\\font.ttf"

fontString = parentFrame:CreateFontString(nil, "OVERLAY")
fontString:SetFont(font, fontSizeOfYourChoice)
fontString:SetTextColor(r, g, b)

Note : when specifying folders in locations of files, you or use "x\\x\\x" (double \) or [=[x\x\x]=]

In your first line (self.Health.Text = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')) -> you are already giving a font to use. Drop that part.
Thanks MW, its getting late in my part of the world so i will continue my banging away at this tomarrow. I know I am close, this might be just the crack I need to get through.
__________________
Twitter
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - Layout discussion

Thread Tools
Display Modes

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