Thread Tools Display Modes
04-08-13, 02:08 PM   #1
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
on mouse over show

Code:
	--Value
	local powa = lib.gen_fontstring(f.Health, cfg.font, 14, "OUTLINE")
	     powa:SetPoint("BOTTOMRIGHT", f.Health, "BOTTOMRIGHT", 0, -10)
	     powa:SetJustifyH("RIGHT")
	     f:Tag(powa, "[fail:pp]")
This is the code to show power value.

Code:
    --gen hilight texture
    lib.gen_highlight = function(f)
    local OnEnter = function(f)
		UnitFrame_OnEnter(f)
		f.Highlight:Show()
    end
    local OnLeave = function(f)
      UnitFrame_OnLeave(f)
      f.Highlight:Hide()
    end
    f:SetScript("OnEnter", OnEnter)
    f:SetScript("OnLeave", OnLeave)
    local hl = f.Health:CreateTexture(nil, "OVERLAY")
    hl:SetAllPoints(f.Health)
    hl:SetTexture(cfg.statusbar_texture)
    hl:SetVertexColor(.5,.5,.5,.1)
    hl:SetBlendMode("ADD")
    hl:Hide()
    f.Highlight = hl
  end
This is the hover effect code.

I'm looking for a way to make the power value show when i hover over the frame. I tried adding another OnEnter.. with the powervalue code. Got no errors but its messed up and not working correctly. I'm kinda stuck:S

Another thing is that whenever i have the power value show on the player frame, it also shows on the player frame in the party. If that makes sense:P How can i distinguish between the frames.

Puh that was alot of questions. I have limited lua knowledge(copy/paste. trial and error) I would very much appreciate some help

Btw this is all in the ouf_fail layout.
  Reply With Quote
04-08-13, 02:50 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
First, you need to add some way to access the fontstring after creating it, eg:
Code:
local powa = lib.gen_fontstring(f.Health, cfg.font, 14, "OUTLINE")
powa:SetPoint("BOTTOMRIGHT", f.Health, "BOTTOMRIGHT", 0, -10)
powa:SetJustifyH("RIGHT")
f:Tag(powa, "[fail:pp]")
f.powaText = powa
Then just add it to the existing OnEnter function (you can only have one, and setting another one overwrites the first one):

Code:
local OnEnter = function(f)
	UnitFrame_OnEnter(f)
	f.Highlight:Show()
	f.powaText:Show()
end
Don't forget to add a corresponding line in the OnLeave function to hide it again on mouseout.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-09-13, 03:28 AM   #3
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
Thanks for the quick answer. I actually got it to work just after posting:P And its exactly as you suggested
The new issue is that the valuetext will now show up on login/relog. Have to mouseover the frame to get it working.

Edit:hehe fixed with a simple powa:Hide()

Trying to show the rep/exp text on mouseover throws errors at me when hovering over other frames then player. So i tried to add something like this:
Code:
    local OnEnter = function(f)
		UnitFrame_OnEnter(f)
		f.Highlight:Show()
		f.powaText:Show()
		if ( UnitFrame:GetName() == "PlayerFrame" ) then
			f.exptext:Show()
		end
Simply does not work.

Last edited by lynce : 04-09-13 at 04:36 AM.
  Reply With Quote
04-09-13, 03:16 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Just check for the existence of the thing you want to show, instead of some random other condition that may or may not be relevant, especially if the other condition requires function calls, comparison operations, or other slow things:

Code:
if f.exptext then
    f.exptext:Show()
end
Also, your code does not work because UnitFrame is not defined; if you changed it to f:GetName() it should work -- assuming the name of the player frame is actually just "PlayerFrame", which is a really bad idea since that name is already in use by the Blizzard player frame, and reassigning it to your own object will likely raise errors in other code that is expecting to access the Blizzard frame by that name.

Make sure you have BugSack installed and enabled while working with code -- being able to see the actual error messages being raised is immensely helpful. Without that info, you are working in the dark.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 04-09-13 at 03:19 PM.
  Reply With Quote
04-10-13, 02:39 AM   #5
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
Well eh i really don't know much about lua, so half of what you wrote was kinda Greek to me:P Trial and error
I did however get it to work:
Code:
  lib.gen_highlight = function(f)
    local OnEnter = function(f)
		UnitFrame_OnEnter(f)
		f.Highlight:Show()
		f.powaText:Show()
		if(IsAddOnLoaded('oUF_Experience')) and UnitLevel("player") ~= MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] then
			if ( f:GetName() == "oUF_failPlayer" ) then
				f.exptext:Show()
			end
		end
It may be terrible coding, but it works and that's enough for me
Thanks again
  Reply With Quote
04-10-13, 04:49 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Change:
Code:
		if(IsAddOnLoaded('oUF_Experience')) and UnitLevel("player") ~= MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] then
			if ( f:GetName() == "oUF_failPlayer" ) then
				f.exptext:Show()
			end
		end
to:
Code:
		if f.exptext then
			f.exptext:Show()
		end
Unless the layout is doing something really stupid, those other conditions are all checked when the frame first loads, and if any of them aren't met, no XP text is created for that frame. There's no reason to check all that other stuff. Just check if the frame has an XP text.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-11-13, 10:20 AM   #7
lynce
A Cyclonian
 
lynce's Avatar
Join Date: Jul 2008
Posts: 48
Thank you so much! I't works like a charm
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » on mouse over show


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