View Single Post
04-15-14, 10:48 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yep, the problem is exactly what I suspected:

Code:
		local Stat = CreateFrame('Frame')
		Stat:EnableMouse(true)
		Stat:SetFrameStrata('BACKGROUND')
		Stat:SetFrameLevel(3)

		local Text  = MainPanel:CreateFontString(nil, 'OVERLAY')
		Text:SetFont(db.media.fontNormal, db.media.fontSize,'THINOUTLINE')
		PP(db.datapanel.armor, Text)
Note that your frame has no parent. This is bad for a multitude of reasons -- it won't be properly hidden when the user presses Alt-Z to hide the UI, it won't scale properly when the user changes their UI scale, and it won't inherit anything from the frame that is logically its parent.

You later set the parent of the fontstring, but not the parent of the frame, so while the fontstring gets hidden, the frame does not. You should be passing around (and reparenting, resizing, positioning, etc) the whole plugin frame, not just its fontstring.

------

Unrelated to your actual problem, but somewhat important:

(1) Having functions with names like "PP" is a really bad idea. Nobody who reads your code to try to help you with it will have any clue what "PP" means, and you yourself will probably forget what "PP" means if you don't look at your code for a few weeks, months, or years. Addons aren't macros. Space isn't limited. Use names that make sense. In this case, after wasting a bunch of time finding where this function is defined and reading through its contents, I'd suggest calling it "PlacePlugin".

(2) Also, it's currently a global, along with such gems as "PL", "PC", and "PR", all of which are horrible choices for global variables/names... they're horrible names in general, but they're even worse as globals because if anyone else's addon accidentally leaks its own horribly named "PC" global, for example, it will likely break both addons. And if Blizzard accidentally leaks a global "PC", you could break the entire UI. Even "MainPanel" is not a good choice for a global name. Use unique, descriptive names for globals if you must make them, but avoid making them unless you actually need to. "BasicUI_MainPanel" would be a better choice for the name of this frame, and the left/center/right frames don't need global names at all.

(3) Putting the entire contents of your file in your OnEnable function doesn't really accomplish anything other than making your code unnecessarily unreadable, either. It's okay to define things in the main chunk of your file.

And finally, I know we've addressed this in at least one of your other threads, but you can't override methods on secure frames. This (and the many other sections like it) will not work:

Code:
			PlayerFrame.ClearAllPoints = top
			PlayerFrame.SetPoint = top
__________________
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