WoWInterface - View Single Post - HOWTO: Change PerfectRaid's Visual Layout
View Single Post
07-28-07, 06:15 AM   #1
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 1,935
HOWTO: Change PerfectRaid's Visual Layout

Since I've gotten this question a bunch of times, but have not had the opportunity to get everything I'd like done with PerfectRaid, I wanted to post a quick tutorial on how the visual style of PerfectRaid is coded, and give you all an idea of how you can alter it to customize the visual style.

The layout is all done in module functions called UpdateButtonLayout, with the initial layout being done in PerfectRaid.lua. This function is called with the unit frame, which contains a number of member frames:

* button - the unit frame
* button.leftbox - A bounding box on the left-hand side of the frame. This is by default 70 pixels wide
* button.rightbox - A bounding box on the right-hand side of the frame. This is by default 70 pixels wide
* button.healthbar - The health bar, anchored in between the two bounding boxes.. so this will be the frame size - 140.
* button.manabar - The mana bar, anchored to the bottom of the health bar
* button.status - The "DEAD, GHOST and HPMISSING" text.. this is always anchored to the right of the health bar.
* button.name - The unit's name. This is anchored to one of the bounding boxes, depending on the "ALIGN RIGHT" option.
* button.aura - Defined in PerfectRaid_Buffs.lua, this is the "buffs" text that appears by default next to the right-hand side of the health bar.

That's all the stuff in PerfectRaid.lua, everythign else is provided by a module. Here's how you would change some common things:

How do I make the overall frame larger
This unfortunately is done by the secure templates, and needs to be changed outside the LayoutButton function. On PerfectRaid.lua:625 and PerfectRaid.lua:626 you will see lines:

button:SetAttribute("initial-width", 225)
button:SetAttribute("initial-height", 14)
These two attributes dictate how large the frame is width and height-wise. To make it larger, you simply change these numbers.

How do I put the name inside the health bar?
This one is pretty easy, actually but will take some tweaking to get it to look just right. First off, remember that the frame looks like this by default:


and in default mode, the rightbox contains the buff text, and the leftbox contains the name. What you can do to experiment is, change the leftbox to 1 pixel width, and then anchor the name. Do this:

PerfectRaid.lua:697 - Change to button.leftbox:SetPoint("BOTTOMRIGHT", button, "BOTTOMLEFT", 1, 0)

PerfectRaid.lua:729/730 - Change these two lines to:
button.name:SetPoint("LEFT", button.healthbar, "LEFT", 0, 0)
button.name:SetPoint("RIGHT", button.healthbar, "RIGHT", 0, 0)
This should make the left bound box smaller, and anchor the name to the left hand side of the healthbar. If the name is too long, it will run into the status text, but you could fix this with anchoring.

How do I alter the code to allow dragging the frame off-screen
In PerfectRaid.lua, lines 340 and 670, the ClampedToScreen setting is set on both the button, and the header (if you don't understand these, it doesn't matter all that much). Simply comment those lines out by adding a -- at the start of them, and you should be able to drag PerfectRaid without having it dock to the screen. I will likely add an option for this relatively soon, when I have a spare moment.

Buff text
The buff text is layed out in PerfectRaid_Buffs.lua (in the Buffs:UpdateButtonLayout() function). In addition to handling the buff text, this also handles the setting and resetting of the highlight backdrops. This is done here, since those highlights are triggered from this module (also note, there is no PerfectRaid_Highlight.lua file, that options pane is defined in this file.

That's really it. What I could do, is provide a separate file that can be used to code layouts in Lua by providing a new master UpdateButtonLayout() function. This way, people could share their customizations on the PerfectRaid visual style. Would that be interesting to anyone?
"There's only one thing that I know how to do well and I've often been told that you only can do what you know how to do well, and that's be you-- be what you're like-- be like yourself. And so I'm having a wonderful time, but I'd rather be whistling in the dark..."

Last edited by Cladhaire : 07-28-07 at 06:21 AM.
  Reply With Quote