r31854 - trunk/PitBull/Aura

3 views
Skip to first unread message

svnco...@wowace.com

unread,
Apr 4, 2007, 9:41:29 AM4/4/07
to wowace-gar...@googlegroups.com
Author: nevcairiel
Date: Wed Apr 4 09:41:28 2007
New Revision: 31854

Log:
PitBull: Aura:
- added options to change the number of Auras per Row
- and options for max number of Rows.
- and options to configure if you prefer debuffs or buffs to be always shown if you run out of space.
- i tested it for like half an hour drinking various potions and trying to get various debuffs, if it breaks do tell
- if someone hates it, hurt me :P
Ominous: ping

Modified:
trunk/PitBull/Aura/Aura.lua

Modified: trunk/PitBull/Aura/Aura.lua
==============================================================================
--- trunk/PitBull/Aura/Aura.lua (original)
+++ trunk/PitBull/Aura/Aura.lua Wed Apr 4 09:41:28 2007
@@ -18,6 +18,7 @@
local UnitDebuff = UnitDebuff
local math_floor = math.floor
local math_min = math.min
+local math_max = math.max

PitBull_Aura:RegisterPitBullChildFrames('auraFrame', 'auraFrame2')

@@ -34,6 +35,11 @@
highlightType = true,
split = false,
filter = true,
+ layoutBuffsCols = 10,
+ layoutBuffsRows = 2,
+ layoutDebuffsCols = 10,
+ layoutDebuffsRows = 2,
+ priorityDebuffs = true,
},
target = {
filter = false,
@@ -82,13 +88,16 @@
buffFrame_OnLeave = wrap(buffFrame_OnLeave, 'Aura/buffFrame_OnLeave')
local debuffFrame_OnLeave = buffFrame_OnLeave

-local maxbuffs, maxdebuffs, max_auras, num_shown_buffs = 32, 40
+local maxbuffs, maxdebuffs, num_buffs = 32, 40

local function UpdateBuffs(unit, frame)
local buffs = frame.auraFrame.buffs or new()
local raidFilter = PitBull_Aura.db.profile[frame.group].filter and 1 or 0
local highlight = PitBull_Aura.db.profile[frame.group].highlight.Buffs
-
+
+ local aura_cols, aura_rows = PitBull_Aura.db.profile[frame.group].layoutBuffsCols, PitBull_Aura.db.profile[frame.group].layoutBuffsRows
+ local aura_size = frame.auraFrame:GetWidth() / aura_cols
+
for i = 1, maxbuffs do
local texture, applications

@@ -113,8 +122,8 @@

local buffFrame = buffs[i] or newFrame('Button', frame.auraFrame)
buffFrame:ClearAllPoints()
- buffFrame:SetWidth(16)
- buffFrame:SetHeight(16)
+ buffFrame:SetWidth(aura_size)
+ buffFrame:SetHeight(aura_size)
local text = buffFrame.text or newFrame('FontString', buffFrame, 'OVERLAY')
buffFrame.text = text
text:SetFontObject(GameFontHighlightSmall)
@@ -143,22 +152,9 @@
buffFrame.raidFilter = raidFilter
buffs[i] = buffFrame
end
- local num_buffs = #buffs
-
- max_auras = math_floor(frame.auraFrame:GetWidth() / 16)
- num_shown_buffs = math_min(num_buffs, max_auras)

- for i = 1, num_shown_buffs do
- local buff = buffs[i]
- buff:Show()
- buff:ClearAllPoints()
- buff:SetPoint('TOPLEFT', frame.auraFrame, 'TOPLEFT', (i-1) * 16, 0)
- end
- for i = num_shown_buffs + 1, num_buffs do
- local buff = buffs[i]
- buff:Hide()
- buff:ClearAllPoints()
- end
+ num_buffs = #buffs
+ frame.auraFrame:SetHeight(aura_size * math_min(math_floor((num_buffs-1) / aura_cols) + 1,aura_rows))

if num_buffs == 0 then
buffs = del(buffs)
@@ -170,9 +166,16 @@
local split, num_shown_debuffs = PitBull_Aura.db.profile[frame.group].split
local raidFilter = PitBull_Aura.db.profile[frame.group].filter and 1 or 0
local debuffs
+ local aura_cols, aura_rows, aura_size
if split then
+ aura_cols = PitBull_Aura.db.profile[frame.group].layoutDebuffsCols
+ aura_rows = PitBull_Aura.db.profile[frame.group].layoutDebuffsRows
+ aura_size = frame.auraFrame2:GetWidth() / aura_cols
debuffs = frame.auraFrame2.debuffs or new()
else
+ aura_cols = PitBull_Aura.db.profile[frame.group].layoutBuffsCols
+ aura_rows = PitBull_Aura.db.profile[frame.group].layoutBuffsRows
+ aura_size = frame.auraFrame:GetWidth() / aura_cols
debuffs = frame.auraFrame.debuffs or new()
end

@@ -201,8 +204,8 @@

local debuffFrame = debuffs[i] or newFrame('Button', split and frame.auraFrame2 or frame.auraFrame)
debuffFrame:ClearAllPoints()
- debuffFrame:SetWidth(16)
- debuffFrame:SetHeight(16)
+ debuffFrame:SetWidth(aura_size)
+ debuffFrame:SetHeight(aura_size)
local text = debuffFrame.text or newFrame('FontString', debuffFrame, 'OVERLAY')
debuffFrame.text = text
text:SetFontObject(GameFontHighlightSmall)
@@ -236,48 +239,99 @@
debuffFrame.raidFilter = raidFilter
debuffs[i] = debuffFrame
end
+
local num_debuffs = #debuffs

+ if num_debuffs == 0 then
+ debuffs = del(debuffs)
+ end
if split then
- local max_debuffs = math_floor(frame.auraFrame2:GetWidth() / 16)
- num_shown_debuffs = math_min(num_debuffs, max_debuffs)
+ frame.auraFrame2.debuffs = debuffs
else
- max_auras = math_floor(frame.auraFrame:GetWidth() / 16)
- if not num_shown_buffs then
- num_shown_buffs = 0
- end
- num_shown_debuffs = math_min(num_debuffs, max_auras - num_shown_buffs)
+ frame.auraFrame.debuffs = debuffs
+ end
+end
+
+local function UpdateAuraPositions(unit, frame)
+ local split, prioD = PitBull_Aura.db.profile[frame.group].split, PitBull_Aura.db.profile[frame.group].priorityDebuffs
+ local buffs, debuffs = frame.auraFrame.buffs or new()
+ if split then
+ debuffs = frame.auraFrame2.debuffs or new()
+ else
+ debuffs = frame.auraFrame.debuffs or new()
end
+
+ local buff_cols, buff_rows = PitBull_Aura.db.profile[frame.group].layoutBuffsCols, PitBull_Aura.db.profile[frame.group].layoutBuffsRows
+ local debuff_cols, debuff_rows = PitBull_Aura.db.profile[frame.group].layoutDebuffsCols, PitBull_Aura.db.profile[frame.group].layoutDebuffsRows
+ local buff_size, debuff_size = frame.auraFrame:GetWidth() / buff_cols, frame.auraFrame:GetWidth() / debuff_cols
+
+ local max_buffs, max_debuffs = buff_cols * buff_rows, debuff_cols * debuff_rows
+ local num_buffs, num_debuffs, num_shown_buffs, num_shown_debuffs = #buffs, #debuffs
+
+ if split then
+ num_shown_buffs = math_min(num_buffs, max_buffs)
+
+ num_shown_debuffs = math_min(num_debuffs, max_debuffs)
for i = 1, num_shown_debuffs do
local debuff = debuffs[i]
debuff:Show()
- debuff:SetBackdropBorderColor(1,0,0)
debuff:ClearAllPoints()
- if split then
- debuff:SetPoint('TOPLEFT', frame.auraFrame2, 'TOPLEFT', (i-1) * 16, 0)
- else
- if buffs then
- debuff:SetPoint('TOPRIGHT', frame.auraFrame, 'TOPRIGHT', (i-1) * -16, 0)
- else
- debuff:SetPoint('TOPLEFT', frame.auraFrame, 'TOPLEFT', (i-1) * 16, 0)
- end
- end
+ local k = math_floor((i-1) / buff_cols)
+ debuff:SetPoint('TOPLEFT', frame.auraFrame2, 'TOPLEFT', ((i-1)-(k*debuff_cols)) * debuff_size, k * -debuff_size)
+ end
+ else
+ if (num_buffs + num_debuffs + 1) < max_buffs then
+ num_shown_buffs = num_buffs
+ num_shown_debuffs = num_debuffs
+ elseif prioD then
+ num_shown_debuffs = math_min(num_debuffs, max_buffs)
+ num_shown_buffs = math_min(num_buffs, max_buffs - (num_shown_debuffs > 0 and (num_shown_debuffs + 1) or 0))
+ else
+ num_shown_buffs = math_min(num_buffs, max_buffs)
+ num_shown_debuffs = math_min(num_debuffs, max_buffs - (num_shown_buffs > 0 and (num_shown_buffs + 1) or 0))
+ end
+
+ local row = math_floor(num_shown_buffs / buff_cols)
+ local debuff_rows = math_floor((num_shown_debuffs-1) / buff_cols) + 1
+ if (num_shown_buffs % buff_cols) + (num_shown_debuffs % buff_cols) + 1 <= buff_cols and num_shown_debuffs > 0 then
+ debuff_rows = debuff_rows - 1
end
- for i = num_shown_debuffs + 1, num_debuffs do
+
+ for i = 1, num_shown_debuffs do
local debuff = debuffs[i]
- debuff:Hide()
+ debuff:Show()
debuff:ClearAllPoints()
+ local k = math_floor((i-1) / buff_cols)
+ local offset = row + debuff_rows - k
+ debuff:SetPoint('TOPRIGHT', frame.auraFrame, 'TOPRIGHT', ((i-1)-(k*buff_cols)) * -buff_size, offset * -buff_size)
end
+ end
+
+ for i = 1, num_shown_buffs do
+ local buff = buffs[i]
+ buff:Show()
+ buff:ClearAllPoints()
+ local k = math_floor((i-1) / buff_cols)
+ buff:SetPoint('TOPLEFT', frame.auraFrame, 'TOPLEFT', ((i-1)-(k*buff_cols)) * buff_size, k * -buff_size)
+ end

+ for i = num_shown_buffs + 1, num_buffs do
+ local buff = buffs[i]
+ buff:Hide()
+ buff:ClearAllPoints()
+ end
+ for i = num_shown_debuffs + 1, num_debuffs do
+ local debuff = debuffs[i]
+ debuff:Hide()
+ debuff:ClearAllPoints()
+ end

+ if num_buffs == 0 then
+ buffs = del(buffs)
+ end
if num_debuffs == 0 then
debuffs = del(debuffs)
end
- if split then
- frame.auraFrame2.debuffs = debuffs
- else
- frame.auraFrame.debuffs = debuffs
- end
end

function PitBull_Aura:UpdateAuras(unit, frame)
@@ -292,6 +346,8 @@
if not self.db.profile[frame.group].hiddenDebuffs then
UpdateDebuffs(unit, frame, buffs)
end
+
+ UpdateAuraPositions(unit, frame)
end
PitBull_Aura.OnUpdateFrame = PitBull_Aura.UpdateAuras

@@ -476,12 +532,12 @@
end

local function getHighlightColor(table)
-local type, type2 = table[1], table[2]
+ local type, type2 = table[1], table[2]
return unpack(type2 and PitBull_Aura.db.profile.colors[type][type2] or PitBull_Aura.db.profile.colors[type])
end

local function setHighlightColor(table, r, g, b, a)
-local type, type2 = table[1], table[2]
+ local type, type2 = table[1], table[2]
if type2 then
PitBull_Aura.db.profile.colors[type][type2] = {r, g, b, a}
else
@@ -509,6 +565,44 @@
end
end

+local function getMultiLayout(table)
+ local group, type, setting = table.group, table.type, table.setting
+ return PitBull_Aura.db.profile[group]['layout'..type..setting]
+end
+
+local function setMultiLayout(table, value)
+ local group, type, setting = table.group, table.type, table.setting
+ PitBull_Aura.db.profile[group]['layout'..type..setting] = value
+
+ for unit, frame in PitBull:IterateUnitFramesByGroup(group) do
+ PitBull_Aura:OnClearUnitFrame(unit, frame)
+ PitBull_Aura:OnPopulateUnitFrame(unit, frame)
+ PitBull_Aura:OnUpdateFrame(unit, frame)
+ unitsShown[unit] = false
+ PitBull:UpdateLayout(unit)
+ end
+end
+
+local function getDebuffPriority(group)
+ return PitBull_Aura.db.profile[group].priorityDebuffs
+end
+
+local function setDebuffPriority(group, value)
+ PitBull_Aura.db.profile[group].priorityDebuffs = value
+
+ for unit, frame in PitBull:IterateUnitFramesByGroup(group) do
+ PitBull_Aura:OnClearUnitFrame(unit, frame)
+ PitBull_Aura:OnPopulateUnitFrame(unit, frame)
+ PitBull_Aura:OnUpdateFrame(unit, frame)
+ unitsShown[unit] = false
+ PitBull:UpdateLayout(unit)
+ end
+end
+
+local function getDebuffSeperated(group)
+ return not getSplit(group)
+end
+
PitBull_Aura:RegisterPitBullOptionsMethod(function(group)
return {
type = 'group',
@@ -653,6 +747,74 @@
}
}
},
+ layout = {
+ type = 'group',
+ name = 'Aura Layout',
+ desc = 'Configure the Layout of the Auras',
+ args = {
+ buffs = {
+ type = 'group',
+ name = 'Buffs',
+ desc = 'Layout of the Buffs ( and Debuffs if not split )',
+ args = {
+ columns = {
+ type = 'range',
+ name = 'Auras per Row',
+ desc = 'Max Number of Auras per Row',
+ min = 4, max = 24, step = 1,
+ get = getMultiLayout,
+ set = setMultiLayout,
+ passValue = {['group'] = group, ['type'] = 'Buffs', ['setting'] = 'Cols'},
+ },
+ rows = {
+ type = 'range',
+ name = 'Rows',
+ desc = 'Max Number Rows',
+ min = 1, max = 4, step = 1,
+ get = getMultiLayout,
+ set = setMultiLayout,
+ passValue = {['group'] = group, ['type'] = 'Buffs', ['setting'] = 'Rows'},
+ },
+ priority = {
+ type = 'toggle',
+ name = 'Priorize Debuffs',
+ desc = 'Always show all Debuffs and omit Buffs if necessary',
+ get = getDebuffPriority,
+ set = setDebuffPriority,
+ disabled = getSplit,
+ passValue = group,
+ },
+ },
+ },
+ debuffs = {
+ type = 'group',
+ name = 'Debuffs',
+ desc = 'Layout of the Debuffs ( only valid if split )',
+ args = {
+ columns = {
+ type = 'range',
+ name = 'Auras per Row',
+ desc = 'Max Number of Auras per Row',
+ min = 4, max = 24, step = 1,
+ get = getMultiLayout,
+ set = setMultiLayout,
+ passValue = {['group'] = group, ['type'] = 'Debuffs', ['setting'] = 'Cols'},
+ },
+ rows = {
+ type = 'range',
+ name = 'Rows',
+ desc = 'Max Number Rows',
+ min = 1, max = 4, step = 1,
+ get = getMultiLayout,
+ set = setMultiLayout,
+ passValue = {['group'] = group, ['type'] = 'Debuffs', ['setting'] = 'Rows'},
+ },
+ },
+ disabled = getDebuffSeperated,
+ passValue = group,
+ },
+ }
+ },
filter = {
type = 'group',
name = 'Filtering',

Reply all
Reply to author
Forward
0 new messages