Thread Tools Display Modes
06-23-09, 11:50 AM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
WorldFrame wackiness

Experiencing some wierdness with the WorldFrame with CFM.

1) Added "WorldFrame"
2) Adjust size to 500x500 and center in screen.
3) /reload
4) WorldFrame returns to original size
5) /reload
6) WorldFrame applies it's settings
7) /reload
8) repeats 4-6

Relevant code:
Code:
function CFM_OnUpdate(self, elapsed)
	if self.delay then
		self.delay = self.delay - elapsed
		if self.delay < 0 then
			self.delay = nil
			CFM_Loaded = true
			for k,_ in pairs(activeProfile) do
				if _G[k] == nil or not _G[k]:IsVisible() then return else CFM_ApplySettings(k) end
				print("Debug: "..k)
			end
			self:SetScript("OnUpdate", nil)
			self:Hide()
		end
	else
		if CFM_Delay and not CFM_Loaded then
			self.delay = 2
		end
	end
end
Put in the debug print and found it will list all the other saved frames on every /reload, but for some reason the WorldFrame would only every other time.

I'm assuming there's something up with the WorldFrame itself that I don't know about that causes this behavior. Just doesn't make any sense why it would only be found on every time while the rest are found every time.
  Reply With Quote
06-23-09, 02:41 PM   #2
Tristanian
Andúril
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 279
You could try setting the UserPlaced attribute to true, so that the frame's size/position is saved in the layout cache file, BUT you really shouldn't be messing around with the WorldFrame. The reason is quite simple, if anyone EVER enables nameplates (even if he disables them for the duration of that session), those frames are created as protected children of the WorldFrame, making it implicitly protected as well. I'm not really sure if you use IsProtected() or even InCombatLockdown() checks in your code, but imo if you aren't, you should start doing so, because the moment you get into combat and you attempt to move/resize/hide/whatever a protected frame (most, if not all Blizzard frames are protected in combat), well you get blockage and there is absolutely no way around that.
__________________
  Reply With Quote
06-23-09, 03:12 PM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
As it is, CFM does nothing unless it's done in the config frame or after login/reload. I haven't received any combat lockdown errors as of yet, but if there ever becomes an issue I'll gladly add the checks. The issue isn't whether the frame is protected or not, it's just simply not being found on every other reload with my code, which as I said before is just plain odd.

As far as UserPlaced, that's something new to me. Where does one find the info on that?
  Reply With Quote
06-23-09, 03:45 PM   #4
Tristanian
Andúril
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 279
The code also checks if the frame is visible in addition to _G[<frame>] I believe. Perhaps thats your problem. As for the UserPlaced attribute :

http://www.wowwiki.com/API_Frame_IsUserPlaced
http://www.wowwiki.com/API_Frame_SetUserPlaced
__________________
  Reply With Quote
06-23-09, 04:02 PM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Tristanian View Post
The code also checks if the frame is visible in addition to _G[<frame>] I believe. Perhaps thats your problem. As for the UserPlaced attribute :

http://www.wowwiki.com/API_Frame_IsUserPlaced
http://www.wowwiki.com/API_Frame_SetUserPlaced
Found the wiki already, but thanks for links. Is there a way to read the values ingame (i.e. pull the x/y position info)? If so, I could possibly use this in place of CFM's database and save some work.

Put in another debug print test to my already present checks:
Code:
function CFM_ApplySettings(frame)
	if frame == "restore" or frame == "useProfile" or not _G[frame]:IsVisible() or activeProfile[frame] == nil or _G[frame] == nil then print(frame.. " not found") return end
Still nothing on the times WorldFrame isn't found. I did test the UserPlaced option and works on each reload with no issues. If I can't seem to get it to work each time with just CFM controlling it, I'll compensate by adding the few lines of code to set WorldFrame as UserPlaced.
  Reply With Quote
06-30-09, 10:35 PM   #6
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Tristanian View Post
You could try setting the UserPlaced attribute to true, so that the frame's size/position is saved in the layout cache file, BUT you really shouldn't be messing around with the WorldFrame. The reason is quite simple, if anyone EVER enables nameplates (even if he disables them for the duration of that session), those frames are created as protected children of the WorldFrame, making it implicitly protected as well. I'm not really sure if you use IsProtected() or even InCombatLockdown() checks in your code, but imo if you aren't, you should start doing so, because the moment you get into combat and you attempt to move/resize/hide/whatever a protected frame (most, if not all Blizzard frames are protected in combat), well you get blockage and there is absolutely no way around that.
After adding a bunch more stuff, I've finally come across a combat lockdown with the TargetFrame.

Here's the deal. Someone tries to forceHide the TargetFrame.
Player targets a mob OOC -> PlayerFrame hidden
Player targets mob OOC, then targets another mob -> PlayerFrame shows, lockdown error
Player gains aggro -> PlayerFrame shows, lockdown error

So here's the question: How are other mods (notably unit frame mods) able to hide the TargetFrame through gaining aggro and target changes without popping the error?
  Reply With Quote
07-01-09, 01:30 AM   #7
Dayve
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 15
Originally Posted by ChaosInc View Post
So here's the question: How are other mods (notably unit frame mods) able to hide the TargetFrame through gaining aggro and target changes without popping the error?
If you really don't want it showing up again you can nuke it. Here's a utility function taken straight from my own unit frames that does the trick:

Code:
function main:NukeFrame(frame)
	-- Boom!
	frame:UnregisterAllEvents();
	frame:SetScript("OnUpdate", nil);
	frame:SetAttribute("unit", "none");
	frame:Hide();
end
To get it working again after that wouldn't be so easy, you'd have to check the FrameXML unit frame code.
  Reply With Quote
07-01-09, 11:42 AM   #8
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Dayve View Post
frame:UnregisterAllEvents();
Actually, just this may work for my needs. Didn't even think about it. I'll give it a whirl and post results.
  Reply With Quote
07-01-09, 12:26 PM   #9
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Had another idea, but have run into an issue:

Code:
activeProfile[selFrame].origOnUpdate = _G[selFrame]:GetScript("OnUpdate")
_G[selFrame]:SetScript("OnUpdate", nil)
saved var
Code:
["origOnUpdate"] = nil --[[ skipped inline function ]],
I have no idea what this means as I have no knowledge in C++.
  Reply With Quote
07-01-09, 12:54 PM   #10
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Decided to look at Xperl's method. Follows the same as Dayve posted. Using similar example (just not unregistering anything) and working fine.

Code:
function XPerl_BlizzFrameDisable(self)
	UnregisterUnitWatch(self)		-- Should stop Archaeologist from re-showing target frame
	self:UnregisterAllEvents()
	self:Hide()
	-- Make it so it won't be visible, even if shown by another mod
	self:ClearAllPoints()
	self:SetPoint("BOTTOMLEFT", UIParent, "TOPLEFT", -400, 500)
Of course, trying to make the solution more complicated than it needs to be.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » WorldFrame wackiness


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