Thread Tools Display Modes
07-29-13, 04:26 AM   #1
Greencap
A Murloc Raider
Join Date: Jul 2013
Posts: 6
Jumping chatframe

I'm having some difficulties positioning my chatframe. I am using Ace3 and in the OnEnable of a module I am repositioning the chatframes. This works well on every reloadui and it also works well in most of the login attempts, however on some login attempts it is slightly off. I cannot figure out what I am doing wrong. Does anyone have any ideas?

Code:
function Module:OnEnable()
	self:SetupChat()
	print("test")
end

function Module:SetupChat()
	self:SetDefaults() -- Sets the default channels, etc 
	... -- Some code that removes some blizzard frames
	for i = 1, NUM_CHAT_WINDOWS do
		self:SetupChatFrame(_G["ChatFrame"..i]) -- Repositions the chatframe (if it is the first one)
	end
end
I am calling FCF_SavePositionAndDimensions(frame) and frame:SetUserPlaced(true). I confirmed that the function is being executed by using the print statement. The strange thing is that in setDefaults I'm calling FCF_ResetChatWindows, which is seemingly being executed as the global channels have been reset (as you can see in the incorrect screenshot), but none of the other code seems to work including joining the correct channels again.

The correct look: http://imgur.com/DVTvqr5
The incorrect look: http://imgur.com/mm21C3z

Thanks for the help!
  Reply With Quote
07-29-13, 05:11 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Greencap View Post
I am calling FCF_SavePositionAndDimensions(frame) and frame:SetUserPlaced(true).
Great, where is that code? It's impossible for us to debug code without being able to see it. Posting random snippets is just useless.
__________________
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
07-29-13, 11:58 PM   #3
Greencap
A Murloc Raider
Join Date: Jul 2013
Posts: 6
Hi Phanx, sorry I thought it was something glaringly obvious as I'm still new to this. Please refer to this link to find the code: http://pastebin.com/d0iN596f
  Reply With Quote
07-30-13, 01:19 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I wouldn't bother trying to get the client to handle the positioning, as your addon is overwriting the positions every time you log in anyway. Just use ClearAllPoints and SetPoint to put the chat frame where you want it, and skip all the SetUserPlaced and FCF_SavePositionAndDimensions stuff.

Alternatively, try getting rid of just the SetUserPlaced call. That's already called (conditionally) by Blizzard's code in FCF_RestorePositionAndDimensions, and calling it unconditionally in your code may be interfering with how the game client is saving the frame position.
__________________
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
07-30-13, 02:16 AM   #5
Greencap
A Murloc Raider
Join Date: Jul 2013
Posts: 6
I will try it again when I am at home. I do remember that the way you suggested is how I actually started in the first place (I only found out about these functions later). I noticed that without them the positioning was way worse.

I'm guessing that I am either running this code too soon or too early and some other blizzard code is interfering. I'm just not sure what.

Is there an easy way to enforce my code to run after blizzard's code has run?
  Reply With Quote
07-30-13, 03:40 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
An easy way that works for any and all Blizzard code? No. It depends on what you're trying to do. If you're overriding something that happens in the main chunk or in an OnLoad script, then you're already doing that, as all such code has already run before your addon is loaded.

If you're overriding something that happens in response to an event (eg. PLAYER_ENTERING_WORLD) then you should post-hook the Blizzard UI function that you want to override (eg. FloatingChatFrame_OnEvent) and run your code after the original function, since simply registering for the same event doesn't guarantee that the Blizzard event handler will run before yours.

Reading the default UI code for the part of the UI you're trying to modify is usually a good starting point -- look at the OnLoad scripts (in XML) and which events are registered, and look at which functions are called from those places.

Back on the original topic, you may want to try removing the clamp insets on the chat frames. Clamp insets let you specify a region that must stay on-screen that's larger (or smaller) than the actual frame, so if the chat frame has a bottom clamp inset of -50px, then the bottom edge of the chat frame can't be moved any closer than 50px from the bottom edge of the screen.

Code:
chatFrame:SetClampRectInsets(0, 0, 0, 0)
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » Jumping chatframe


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