Thread Tools Display Modes
07-15-08, 06:36 PM   #1
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Buff orientation?

How would I go about making the buffs go from Left to Right, instead of Right to Left?

I am curious because I moved my buffs to the left side, and I'd like to anchor it to the left so that if I get more buffs, it goes to the right.

Thank you.
__________________
Never be satisfied with satisfactory.
  Reply With Quote
07-20-08, 04:54 PM   #2
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Does anyone know about doing this? Is it possible?

__________________
Never be satisfied with satisfactory.
  Reply With Quote
07-21-08, 10:50 AM   #3
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
I would start by looking in Blizzard's function BuffButton_UpdateAnchors in FrameXML/BuffFrame.lua.It shows the way how the default interface handles this and provides a good start for modifying it.
Maybe just copying this function in your addon and replacing "LEFT" with "RIGHT" (and the other way round) should do it? Ah, and don't forget to change the X-offset in the SetPoint's.
Code:
   So
buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
   would become
buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "LEFT", 5, 0);
Just an (untested) idea which came to my mind
  Reply With Quote
07-21-08, 11:08 AM   #4
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Ah, yes. I forgot about the WoW Dev Network. Thanks for your help.

I'll try that out and see what I can come up with.

Thanks again.
__________________
Never be satisfied with satisfactory.
  Reply With Quote
07-21-08, 11:14 AM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Just do the opposite setpoint, "LEFT" becomes "RIGHT" and you x would be x = x * -1
  Reply With Quote
07-21-08, 12:06 PM   #6
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
I've tried both.

Cargor: How would I set it up so that I could use getglobal and buttonName? Specifically, I get this error:

Code:
[2008/07/21 14:10:33-1191-x1]: cLayouts-1.0\cLayouts.lua:41: attempt to index global 'button' (a nil value)
This is my code for editing the buffs thus far:

Code:
local buttonName = button:GetName();
local buffName = buttonName..index;
local buff = getglobal(buffName);

buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "LEFT", 5, 0);
Slakah: I don't know if you understand me . I am trying to "flip" the buttons.

Like this:
By default the buffs are like this (with the arrow showing the direction in which each buff adds).

<---#3--#2--#1

I want them to go like this

#1--#2--#3--->

Changing the setpoint will only change the area in which it is anchored, not the "orientation" of which the buffs are growing.

Thank you for your responses. I will try messing with the code to see what I can come up with.
__________________
Never be satisfied with satisfactory.

Last edited by Cralor : 07-21-08 at 12:16 PM.
  Reply With Quote
07-21-08, 12:14 PM   #7
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
I would call the entire BuffButton_UpdateAnchors function and make the following changes:

Code:
function BuffButton_UpdateAnchors(buttonName, index, filter)
	local rows = ceil(BUFF_ACTUAL_DISPLAY/BUFFS_PER_ROW);
	local buff = getglobal(buttonName..index);
	local buffHeight = TempEnchant1:GetHeight();
 
	if ( filter == "HELPFUL" ) then
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			if ( index == BUFFS_PER_ROW+1 ) then
				buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
			else
				buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
			end
		elseif ( index == 1 ) then
			buff:SetPoint("TOPRIGHT", BuffFrame, "TOPRIGHT", 0, 0);
		else
			buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
		end
	else
		-- Position debuffs
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
		elseif ( index == 1 ) then
			if ( rows < 2 ) then
				buff:SetPoint("TOPRIGHT", TempEnchant1, "BOTTOMRIGHT", 0, -1*((2*BUFF_ROW_SPACING)+buffHeight));
			else
				buff:SetPoint("TOPRIGHT", TempEnchant1, "BOTTOMRIGHT", 0, -rows*(BUFF_ROW_SPACING+buffHeight));
			end
		else
			buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
		end
	end
You'll want to change this:
Code:
buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
...to:
Code:
buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
You'll also want to adjust the "-- New Row" marked up area to reflect your new anchor point (Left side of screen) if it conflicts with what you've already done. You can modify the debuffs as you see fit as well if you like in the same function.
  Reply With Quote
07-21-08, 12:47 PM   #8
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Code:
cLayouts-1.0\cLayouts.lua:43: attempt to index global 'button' (a nil value)
How do I define 'button'? (specific part of code is bold below)

Thanks for your reply Taffu.

Current code:

Code:
local buttonName = button:GetName();
local buffName = buttonName..index;
local buff = getglobal(buffName);

function BuffButton_UpdateAnchors(buttonName, index, filter)
	local rows = ceil(BUFF_ACTUAL_DISPLAY/BUFFS_PER_ROW);
	local buff = getglobal(buttonName..index);
	local buffHeight = TempEnchant1:GetHeight();
 
	if ( filter == "HELPFUL" ) then
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			if ( index == BUFFS_PER_ROW+1 ) then
				buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
			else
				buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
			end
		elseif ( index == 1 ) then
			buff:SetPoint("TOPRIGHT", BuffFrame, "TOPRIGHT", 0, 0);
		else
			buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
		end
	else
		-- Position debuffs
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
		elseif ( index == 1 ) then
			if ( rows < 2 ) then
				buff:SetPoint("TOPRIGHT", TempEnchant1, "BOTTOMRIGHT", 0, -1*((2*BUFF_ROW_SPACING)+buffHeight));
			else
				buff:SetPoint("TOPRIGHT", TempEnchant1, "BOTTOMRIGHT", 0, -rows*(BUFF_ROW_SPACING+buffHeight));
			end
		else
			buff:SetPoint("RIGHT", getglobal(buttonName..(index-1)), "LEFT", -5, 0);
		end
	end
end
__________________
Never be satisfied with satisfactory.
  Reply With Quote
07-21-08, 01:01 PM   #9
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
You only need the function posted by Taffu and not the first three lines before.
So removing
Code:
local buttonName = button:GetName();
local buffName = buttonName..index;
local buff = getglobal(buffName);
should work.

There are also a lot of RIGHT's and TOPRIGHT's left in the function which could also be changed to LEFT or TOPLEFT. For example notice the fourth last line

I came up with this:
Code:
function BuffButton_UpdateAnchors(buttonName, index, filter)
	local rows = ceil(BUFF_ACTUAL_DISPLAY/BUFFS_PER_ROW);
	local buff = getglobal(buttonName..index);
	local buffHeight = TempEnchant1:GetHeight();
 
	if ( filter == "HELPFUL" ) then
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			if ( index == BUFFS_PER_ROW+1 ) then
				buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
			else
				buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
			end
		elseif ( index == 1 ) then
			buff:SetPoint("TOPLEFT", BuffFrame, "TOPLEFT", 0, 0);
		else
			buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
		end
	else
		-- Position debuffs
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
		elseif ( index == 1 ) then
			if ( rows < 2 ) then
				buff:SetPoint("TOPLEFT", TempEnchant1, "BOTTOMLEFT", 0, -1*((2*BUFF_ROW_SPACING)+buffHeight));
			else
				buff:SetPoint("TOPLEFT", TempEnchant1, "BOTTOMLEFT", 0, -rows*(BUFF_ROW_SPACING+buffHeight));
			end
		else
			buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
		end
	end
  Reply With Quote
07-21-08, 01:13 PM   #10
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Okay I have no errors now, but I still have the buffs to the right.
Although, the buffs do have the right orientation now.

I have also changed the wording like you have shown.

This is what I have:

Code:
function BuffButton_UpdateAnchors(buttonName, index, filter)
	local rows = ceil(BUFF_ACTUAL_DISPLAY/BUFFS_PER_ROW);
	local buff = getglobal(buttonName..index);
	local buffHeight = TempEnchant1:GetHeight();
 
	if ( filter == "HELPFUL" ) then
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			if ( index == BUFFS_PER_ROW+1 ) then
				buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
			else
				buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
			end
		elseif ( index == 1 ) then
			buff:SetPoint("TOPLEFT", BuffFrame, "TOPLEFT", 0, 0);
		else
			buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
		end
	else
		-- Position debuffs
		if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
			-- New row
			buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
		elseif ( index == 1 ) then
			if ( rows < 2 ) then
				buff:SetPoint("TOPLEFT", TempEnchant1, "BOTTOMLEFT", 0, -1*((2*BUFF_ROW_SPACING)+buffHeight));
			else
				buff:SetPoint("TOPLEFT", TempEnchant1, "BOTTOMLEFT", 0, -rows*(BUFF_ROW_SPACING+buffHeight));
			end
		else
			buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
		end
	end
end
Thanks for your help!
__________________
Never be satisfied with satisfactory.

Last edited by Cralor : 07-21-08 at 01:20 PM.
  Reply With Quote
07-21-08, 01:25 PM   #11
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
Sorry for the double post, but that one will get cluttered.

I am successful on moving the frame (with the x and y coords) and the right orientation, but I'd like to see if there is a better way.

Like I said, if I do not touch the coords, it is still to the right.

I'm trying to find a better way, so that if people with different resolutions use this addon, it's not off the screen because the coords are too high or low. (This is why Blizz made Anchors for one reason.)

So, if you see any reason why the anchors aren't putting the buff frame to the left, please let me know.

Thanks for all your help.
__________________
Never be satisfied with satisfactory.
  Reply With Quote
07-22-08, 10:44 AM   #12
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
How do you move the frame?
The upper code was only for changing the direction, not for moving the frame.

When I'm remembering right, it is done with:
Code:
      TemporaryEnchantFrame:ClearAllPoints()
      TemporaryEnchantFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 10, -10)
      TemporaryEnchantFrame.SetPoint = function() end
This would move the buff+debuff frames to the topleft corner of the interface.
  Reply With Quote
07-22-08, 12:54 PM   #13
Taffu
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 149
There's a lot of things that you have to be sure of before doing this. The reason you don't need to call the locals is because the function I posted is ripped right out of Blizzards UI structure.

One thing is, do you want to continue with the Temporary Enchants frame to be part of the BuffFrame? Same with Debuffs...do you want those in identical positions, just mirrored, as they originally come (below Buffs).

For instance, within the function:

Code:
if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
        -- New row
	if ( index == BUFFS_PER_ROW+1 ) then
		buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
        else
		buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
	end
elseif ( index == 1 ) then
	buff:SetPoint("TOPLEFT", BuffFrame, "TOPLEFT", 0, 0);
else
	buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
end
The bold portion is for new rows that do not consist of the first anchoring of a buff. So anytime your BuffButton count exceeds that of the BUFF_PER_ROW value, this is what's directing the anchoring.

Code:
if ( (index > 1) and (mod(index, BUFFS_PER_ROW) == 1) ) then
        -- New row
	if ( index == BUFFS_PER_ROW+1 ) then
		buff:SetPoint("TOP", TempEnchant1, "BOTTOM", 0, -BUFF_ROW_SPACING);
        else
		buff:SetPoint("TOP", getglobal(buttonName..(index-BUFFS_PER_ROW)), "BOTTOM", 0, -BUFF_ROW_SPACING);
	end
elseif ( index == 1 ) then
	buff:SetPoint("TOPLEFT", BuffFrame, "TOPLEFT", 0, 0);
else
	buff:SetPoint("LEFT", getglobal(buttonName..(index-1)), "RIGHT", 5, 0);
end
In bold is the "First" anchoring, which always is related to the BuffFrame itself. The last part indicates the "Growth" portion of the anchoring, meaning that (as is above) the "Left" side of the new button anchors to the "Right" side of the previous button (which indicates growth to the right).

You can change this however you need to, to build a custom growth system for the BuffButtons (and same with the Debuffs). Remember to move the entire BuffFrame to the location want as well.

It really all depends on what you want to do. If you want to take "exactly" what Blizzard defaults to the right side adjacent the Minimap, you simply need to reverse all the growth structure anchors for all the applicable frames. If you want to seperate them, this can be done simply by seperating them and using different anchor points in relation to where they're going to be seated in your UI.
  Reply With Quote
07-22-08, 07:04 PM   #14
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
I am just looking to move the whole "buffs" frame. (This means both Good and Bad buffs [debuffs].)

I originally has the Temp. code Cargor has posted, but I thought that was not needed with this new code. I believe I can just add that and I will be just fine.

Thanks for the wonderful help.
__________________
Never be satisfied with satisfactory.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Buff orientation?


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