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. |
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 |
Don't forget that you can get a lot of the actual documentation along with all of the file changes at wdn.
|
Yeah, this topic was for 5991, the last patch added UnitWatch (ezmode) and SecureStateHeaderTemplate (hardcore), which solved all the problems.
|
*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 |
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() Code:
function Perl_Target_Events:UNIT_TARGET() Any help or points into the right direction would be greatly appreciated. |
You can use the UnitWatch.lua registration to have frames shown/hidden based on the existence of units.
|
Quote:
Code:
function Perl_Target_Events:PLAYER_TARGET_CHANGED() 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. |
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(); |
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.
|
Quote:
(kidding, of course ;) ) |
I think Zek will easily be able to copy it from my mod if he wants to :)
|
Quote:
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. |
Quote:
|
All times are GMT -6. The time now is 02:43 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI