WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Buff orientation? (https://www.wowinterface.com/forums/showthread.php?t=17147)

Cralor 07-15-08 06:36 PM

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.

Cralor 07-20-08 04:54 PM

Does anyone know about doing this? Is it possible?

:)

xConStruct 07-21-08 10:50 AM

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 ;)

Cralor 07-21-08 11:08 AM

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.

Slakah 07-21-08 11:14 AM

Just do the opposite setpoint, "LEFT" becomes "RIGHT" and you x would be x = x * -1

Cralor 07-21-08 12:06 PM

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.

Taffu 07-21-08 12:14 PM

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.

Cralor 07-21-08 12:47 PM

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


xConStruct 07-21-08 01:01 PM

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


Cralor 07-21-08 01:13 PM

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!

Cralor 07-21-08 01:25 PM

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.

xConStruct 07-22-08 10:44 AM

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.

Taffu 07-22-08 12:54 PM

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.

Cralor 07-22-08 07:04 PM

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.


All times are GMT -6. The time now is 10:08 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI