Thread Tools Display Modes
10-19-06, 04:43 AM   #1
Miles
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 16
Show/Hide on UnitFrames

** Reposting from EU-Beta forums, since it's totally dead. Hopefully, this forum will provide more feedback **

Andreas and me have been working on converting ag_Unitframes (temp version: http://www.wowinterface.com/download...nitFrames.html, thread at http://www.wowace.com/forums/index.php?topic=2676.0) to BC, and one of the major problems we've encountered is the Target and Target's Target frame.

Normally, when players don't have a target, the target frame is hidden. When a player selects a target, it gets shown. The same thing happens with target's target, if you select a mob while it's incapacitated, it won't have a target -> frame is hidden, and if it's running after you, it's shown.


In the Burning Crusade, using the new secure unitframes, we're not allowed to change visibility of those frames in combat. So if you deselect a mob in combat, the Target frame will get "stuck", and if the mob doesn't have a target when you enter combat (99.9% of the time), the Target's Target frame won't be shown for the whole fight.

There is currently no function in the SecureTemplate (.lua/.xml) that handles this situation, and the default UI's code doesn't hint what we should do at all:

FrameXML\TargetFrame.lua, line 45:
function TargetFrame_Update()
-- This check is here so the frame will hide when the target goes away
-- even if some of the functions below are hooked by addons.
if ( not UnitExists("target") ) then
this:Hide();
else
this:Show();
<snip>

With the secure = 1 in the toc (aka Blizzard UI I-Win Button), they are allowed to do that. The problem is that any other unitframe addon won't be able to follow.


It seems to me that we're missing some code in the SecureUnitButtonTemplate to handle this situation, in pseudocode:

On PLAYER_TARGET_CHANGED do: if GetAttribute("unit") == "target" / "targettarget" then check UnitExists and Show/Hide the frame.
And do the UnitExists check on an interval (0.2 - 0.5 seconds) for targettarget.
  Reply With Quote
10-20-06, 10:26 PM   #2
tyroney
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 2
Based on some of the documentation buried in the lastest patch, I think that kind of frame hiding might still work fine. Somehow. I'm no expert, I'm only just barely beginning to understand the state business. Here's an excerpt to give you hope:

Code:
-- ADVANCED TOPICS: EXTERNAL STATE CHANGES
--
-- The state header can be sent state changes from other code to sense
-- things such as unit existence changes, or stance changes. This is a
-- generalized mechanism that uses attributes on the header of the form
-- "state-<type>", such as "state-unitexists".
--
-- When one of these attributes is set to <newvalue>, the header is checked
-- for a "statemap-<type>-<newvalue>", and if that is not set, a
-- "statemap-<newvalue>" attribute. If one is found then it will be processed
-- as a state transition specification and the header's state can be
-- changed as a result.
--
-- e.g.
--
-- -- Switch to state 0 on receipt of a false "state-unitexists" value, and
-- -- to state 1 on a true value.
--
-- "statemap-unitexists-false" => "0"
-- "statemap-unitexists-true" => "1"
  Reply With Quote
10-20-06, 10:31 PM   #3
Cairenn
Credendo Vides
 
Cairenn's Avatar
Premium Member
WoWInterface Admin
Join Date: Mar 2004
Posts: 7,134
Don't forget that you can get a lot of the actual documentation along with all of the file changes at wdn.
__________________
“Do what you feel in your heart to be right — for you’ll be criticized anyway.” ~ Eleanor Roosevelt
~~~~~~~~~~~~~~~~~~~
Co-Founder & Admin: MMOUI
FaceBook Profile, Page, Group
Avatar Image by RaffaeleMarinetti
  Reply With Quote
10-21-06, 04:48 PM   #4
Miles
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 16
Yeah, this topic was for 5991, the last patch added UnitWatch (ezmode) and SecureStateHeaderTemplate (hardcore), which solved all the problems.
  Reply With Quote
10-21-06, 04:51 PM   #5
Cairenn
Credendo Vides
 
Cairenn's Avatar
Premium Member
WoWInterface Admin
Join Date: Mar 2004
Posts: 7,134
*Nod*

Just reminding folks about it, since a lot of authors don't seem to know about it yet, and it's such a helpful tool.

/thread-jack off
__________________
“Do what you feel in your heart to be right — for you’ll be criticized anyway.” ~ Eleanor Roosevelt
~~~~~~~~~~~~~~~~~~~
Co-Founder & Admin: MMOUI
FaceBook Profile, Page, Group
Avatar Image by RaffaeleMarinetti
  Reply With Quote
10-31-06, 08:48 PM   #6
Global
A Flamescale Wyrmkin
 
Global's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 95
I'm sure I'm doing this totally wrong, but I figure I should ask before I get too irritated. I'm trying to update my mod, Perl Classic, and I got the first step done (the secure buttons so you can target people). I have a bunch of blocked addon stuff going on in the background do to hide/showing of certain frames inside the mod, but that's fine and can be dealt with later.

The real issue I seem to be having right now is how to hide frames while in combat. Specifically, my Target and ToT frames.

I read the post and saw the easy mode and hard mode options. So I got the latest version of ag_UF and started digging for some real world examples. I'd like to say I learned something from looking at the code, but I really didn't. Here's what I ended up doing, for better or worse.

In my OnLoad function, I added in: RegisterUnitWatch(this, true);

And then for my events, I have this:

Code:
function Perl_Target_Events:PLAYER_TARGET_CHANGED()
	if (UnitExists("target")) then
		Perl_Target_Update_Once();		-- Set the unchanging info for the target
	else
		if (InCombatLockdown()) then
			-- Not sure what to do here
		else
			Perl_Target_Frame:Hide();		-- There is no target, hide the frame
		end
	end
end
And just for good measure, I dropped the same code into UNIT_TARGET since I'm not even sure what that event is used for.

Code:
function Perl_Target_Events:UNIT_TARGET()
	if (arg1 == target) then
		if (UnitExists("target")) then
			Perl_Target_Update_Once();		-- Set the unchanging info for the target
		else
			Perl_Target_Frame:Hide();		-- There is no target, hide the frame
		end
	end
end
I know I'm doing it all wrong, and trying to read Ace2 code and make it work in my style of coding is a little over my head. I'm using RegisterUnitWatch on a frame object in the XML and not inheriting any of the secure templates if that helps. I zipped up a copy of my code in case anyone wants to take a closer look. It can be found here: http://www.g-ball.com/wow/ui/pcuf_v7_lookingforhelp.zip

Any help or points into the right direction would be greatly appreciated.
  Reply With Quote
10-31-06, 09:15 PM   #7
Slouken
Pirate!
 
Slouken's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 116
You can use the UnitWatch.lua registration to have frames shown/hidden based on the existence of units.
  Reply With Quote
10-31-06, 11:48 PM   #8
Global
A Flamescale Wyrmkin
 
Global's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 95
Originally Posted by Slouken
You can use the UnitWatch.lua registration to have frames shown/hidden based on the existence of units.
I guess that's where my problem is. I've looked at the file and just can't decipher exactly how to interface with it more than I already am. If I do something like this:

Code:
function Perl_Target_Events:PLAYER_TARGET_CHANGED()
	if (UnitExists("target")) then
		RegisterUnitWatch(this, true);
		Perl_Target_Update_Once();		-- Set the unchanging info for the target
	else
		UnregisterUnitWatch(this);
	end
end
Doing it this way won't show or hide the frame once in combat. I hate to ask for it, but any chance of a basic code snippet for how a more "basic" unit frame would tackle this?

Edit: So while I was/am waiting for a reply to this, I went ahead and cleaned up all the ADDON_ACTION_BLOCKED errors for the mod in order to prevent any taint if that would be a possible issue for this. The above function i posted is probably wrong since it doesn't work even after fixing all the blocked code. Not to mention, it throws additional action_blocked events. So I guess I'm just asking for the correct syntax on how to make the frame show/hide using the RegisterUnitWatch function.

Last edited by Global : 11-01-06 at 04:47 PM.
  Reply With Quote
11-01-06, 08:20 PM   #9
Miles
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 16
You just create the frame and call RegisterUnitWatch(frame) on it. If UnitExists(this:GetAttribute("unit")) returns true, it's automatically shown, otherwise hidden.

So, at init, do a frame:SetAttribute("unit", "target") and register that frame. Then use hooksecurefunc on OnShow to execute the line Perl_Target_Update_Once();
  Reply With Quote
11-02-06, 01:25 AM   #10
Global
A Flamescale Wyrmkin
 
Global's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 95
That was a great explanation Miles. Thank you very much! I was going insane trying to figure that out on my own. Now I have my target frame working again in combat.
  Reply With Quote
11-02-06, 02:30 AM   #11
Nymbia
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 22
Originally Posted by Global
That was a great explanation Miles. Thank you very much! I was going insane trying to figure that out on my own. Now I have my target frame working again in combat.
when you're done with that, you're fixing my version too, right?


(kidding, of course )
  Reply With Quote
11-02-06, 03:34 AM   #12
Global
A Flamescale Wyrmkin
 
Global's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 95
I think Zek will easily be able to copy it from my mod if he wants to
  Reply With Quote
11-02-06, 04:07 AM   #13
Nymbia
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 22
Originally Posted by Global
I think Zek will easily be able to copy it from my mod if he wants to
well, good that people will finally need to switch from my old kludge to yours or zek's.

bad that the ones who are stuck in their ways with it will all send me a tell about it the day 1.13 comes out.
  Reply With Quote
11-02-06, 04:30 AM   #14
Global
A Flamescale Wyrmkin
 
Global's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2005
Posts: 95
Originally Posted by Miles
Then use hooksecurefunc on OnShow to execute the line Perl_Target_Update_Once();
Is there any reason I couldn't just call Perl_Target_Update_Once() from the PLAYER_TARGET_CHANGED event? If it's for a taint reason, I'm going to have to call it on that event anyway if I change targets without untargeting the mob.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Alpha/Beta AddOns and Compilations » Show/Hide on UnitFrames


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