WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Alpha/Beta AddOns and Compilations (https://www.wowinterface.com/forums/forumdisplay.php?f=33)
-   -   Show/Hide on UnitFrames (https://www.wowinterface.com/forums/showthread.php?t=6592)

Miles 10-19-06 04:43 AM

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.

tyroney 10-20-06 10:26 PM

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"


Cairenn 10-20-06 10:31 PM

Don't forget that you can get a lot of the actual documentation along with all of the file changes at wdn.

Miles 10-21-06 04:48 PM

Yeah, this topic was for 5991, the last patch added UnitWatch (ezmode) and SecureStateHeaderTemplate (hardcore), which solved all the problems.

Cairenn 10-21-06 04:51 PM

*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

Global 10-31-06 08:48 PM

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.

Slouken 10-31-06 09:15 PM

You can use the UnitWatch.lua registration to have frames shown/hidden based on the existence of units.

Global 10-31-06 11:48 PM

Quote:

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.

Miles 11-01-06 08:20 PM

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();

Global 11-02-06 01:25 AM

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.

Nymbia 11-02-06 02:30 AM

Quote:

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? :eek:


(kidding, of course ;) )

Global 11-02-06 03:34 AM

I think Zek will easily be able to copy it from my mod if he wants to :)

Nymbia 11-02-06 04:07 AM

Quote:

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.

Global 11-02-06 04:30 AM

Quote:

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.


All times are GMT -6. The time now is 02:43 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI