WoWInterface SVN Buffed

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 17 to Rev 18
    Reverse comparison

Rev 17 → Rev 18

Buffed!.lua
7,8 → 7,8
local scale = UIParent:GetScale()
local BuffedSorter = {}
local ConfigShown
local ActiveButton -- the button that has been clicked to bring up the menu, needs replacing with self.value in the dropdown intilialisation
BuffedProfiles = {FilterFrames = { BuffedBuffButton = {}, BuffedDebuffButton = {}, TargetBuffedButton = {}, TargetDebuffedButton = {}, },}
local ActiveButton
BuffedProfiles = {}
 
local function BGetPoint(frame)
local x = (floor((frame:GetLeft()+ frame:GetRight())/2*100))/100
67,6 → 67,34
ForAllFrames(function(f) if f.enabled then f:Show() end end)
ConfigShown = 1
else
ForAllFrames(function(f, FrameName, FrameNum, i)
local f = _G["Buffed"..FrameName..i]
local x, y = BGetPoint(f)
local width, height = floor(f:GetWidth() + 0.5), floor(f:GetHeight() + 0.5)
if not BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] then
BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] = {bar = {}, durationb = {}}
end
local t = BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i]
t.width = width t.height = height t.x = x t.y = y t.alpha = f.alpha x, y = BGetPoint(f.bar)
local r, g, b, a = f.bar.tex:GetVertexColor()
width, height = floor(f.bar:GetWidth() + 0.5), floor(f.bar:GetHeight() + 0.5)
t.bar.shown = f.bar:IsShown()
t.bar.horiz = f.bar.horiz
t.bar.width = width
t.bar.height = height
t.bar.x = x t.bar.y = y t.bar.r = r t.bar.g = g t.bar.b = b t.bar.a = a
t.bar.texture = f.bar.tex:GetTexture()
x, y = BGetPoint(f.durationb)
width, height = floor(f.durationb:GetWidth() + 0.5), floor(f.durationb:GetHeight() + 0.5)
t.durationb.shown = f.durationb:IsShown()
t.durationb.width = width t.durationb.height = height
t.durationb.x = x t.durationb.y = y
if FrameName == "Filter" then
t.enabled = f.enabled
t.Btype = f.Btype
t.name = f.name
end
end)
ForAllFrames(function(f, FrameName, FrameNum, i) f:Hide()
if (i > FrameNum) then
f = _G["Buffed"..FrameName.."Button"..i]
84,55 → 112,55
 
local function BuffedOnDragStop(self, index, button) -- stop dragging config frames and set positions
if (button == "LeftButton") then
local BuffButton = _G[self..index]
BuffButton:StopMovingOrSizing()
local left, right, top, bottom = BuffButton:GetLeft(), BuffButton:GetRight(), BuffButton:GetTop(), BuffButton:GetBottom()
local width, height = BuffButton:GetWidth(), BuffButton:GetHeight()
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do
for i = 1, FrameNum do
local frame = _G["Buffed"..FrameName..i]
if not (frame:GetName() == BuffButton:GetName()) then
local BLeft, BRight, BTop, BBottom = frame:GetLeft(), frame:GetRight(), frame:GetTop(), frame:GetBottom()
local BWidth, BHeight = frame:GetWidth(), frame:GetHeight()
local BBCenterX = (right+left)/2
local BBCenterY = (top+bottom)/2
local FCenterX = (BRight+BLeft)/2
local FCenterY = (BTop+BBottom)/2
if (BBCenterX < (FCenterX + 100)) and (BBCenterX > (FCenterX - 100)) and (BBCenterY < (FCenterY + 100)) and (BBCenterY > (FCenterY - 100)) then
if BuffButton.StickySize then
BuffButton:SetWidth(BWidth)
BuffButton:SetHeight(BHeight)
end
if BuffButton.StickyPos then
if (BBCenterX < (FCenterX + 20)) and (BBCenterX > (FCenterX - 20)) then
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", FCenterX, BBCenterY )
local BuffButton = _G[self..index]
BuffButton:StopMovingOrSizing()
local left, right, top, bottom = BuffButton:GetLeft(), BuffButton:GetRight(), BuffButton:GetTop(), BuffButton:GetBottom()
local width, height = BuffButton:GetWidth(), BuffButton:GetHeight()
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do
for i = 1, FrameNum do
local frame = _G["Buffed"..FrameName..i]
if not (frame:GetName() == BuffButton:GetName()) then
local BLeft, BRight, BTop, BBottom = frame:GetLeft(), frame:GetRight(), frame:GetTop(), frame:GetBottom()
local BWidth, BHeight = frame:GetWidth(), frame:GetHeight()
local BBCenterX = (right+left)/2
local BBCenterY = (top+bottom)/2
local FCenterX = (BRight+BLeft)/2
local FCenterY = (BTop+BBottom)/2
if (BBCenterX < (FCenterX + 100)) and (BBCenterX > (FCenterX - 100)) and (BBCenterY < (FCenterY + 100)) and (BBCenterY > (FCenterY - 100)) then
if BuffButton.StickySize then
BuffButton:SetWidth(BWidth)
BuffButton:SetHeight(BHeight)
end
if (BBCenterY < (FCenterY + 20)) and (BBCenterY > (FCenterY - 20)) then
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", BBCenterX, FCenterY )
if BuffButton.StickyPos then
if (BBCenterX < (FCenterX + 20)) and (BBCenterX > (FCenterX - 20)) then
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", FCenterX, BBCenterY )
end
if (BBCenterY < (FCenterY + 20)) and (BBCenterY > (FCenterY - 20)) then
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", BBCenterX, FCenterY )
end
end
end
end
if (BuffButton.padding ~= 0) then
if ((left > (BLeft - BuffButton.padding) and left < (BRight + BuffButton.padding)) or (right > (BLeft - BuffButton.padding) and right < (BRight + BuffButton.padding) )) and ((top > (BBottom - BuffButton.padding) and top < (BTop + BuffButton.padding)) or (bottom > (BBottom - BuffButton.padding) and bottom < (BTop + BuffButton.padding)) ) then
local Xdir = (BBCenterX - FCenterX)/abs(BBCenterX - FCenterX)
local Ydir = (BBCenterY - FCenterY)/abs(BBCenterY - FCenterY)
local x = FCenterX + Xdir*((BRight-BLeft)/2 + (right-left)/2 + BuffButton.padding)
local y = FCenterY + Ydir*((BTop-BBottom)/2 + (top-bottom)/2 + BuffButton.padding)
if abs(BBCenterX - FCenterX) < 10 then
x = FCenterX
elseif abs(BBCenterY - FCenterY) < 10 then
y = FCenterY
if (BuffButton.padding ~= 0) then
if ((left > (BLeft - BuffButton.padding) and left < (BRight + BuffButton.padding)) or (right > (BLeft - BuffButton.padding) and right < (BRight + BuffButton.padding) )) and ((top > (BBottom - BuffButton.padding) and top < (BTop + BuffButton.padding)) or (bottom > (BBottom - BuffButton.padding) and bottom < (BTop + BuffButton.padding)) ) then
local Xdir = (BBCenterX - FCenterX)/abs(BBCenterX - FCenterX)
local Ydir = (BBCenterY - FCenterY)/abs(BBCenterY - FCenterY)
local x = FCenterX + Xdir*((BRight-BLeft)/2 + (right-left)/2 + BuffButton.padding)
local y = FCenterY + Ydir*((BTop-BBottom)/2 + (top-bottom)/2 + BuffButton.padding)
if abs(BBCenterX - FCenterX) < 10 then
x = FCenterX
elseif abs(BBCenterY - FCenterY) < 10 then
y = FCenterY
end
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x, y )
end
BuffButton:ClearAllPoints()
BuffButton:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x, y )
end
end
end
end
end
end
end
 
 
397,7 → 425,7
end
 
local function SetConfigVars(pos, f)
if not pos then return end
if not pos then return end
BSetPoint(f, pos.x, pos.y)
f:SetWidth(pos.width)
f:SetHeight(pos.height)
419,60 → 447,37
CreateConfigFrames()
CreateSettingsMenu()
end
elseif event == "PLAYER_LOGOUT" then
ForAllFrames(function(f, FrameName, FrameNum, i)
if not BuffedProfiles[UnitName("player")] then
BuffedProfiles[UnitName("player")] = {combat = {}, nocombat = {}}
end
local x, y = BGetPoint(f)
local width, height = floor(f:GetWidth() + 0.5), floor(f:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] = {width = width, height = height, x = x, y = y, alpha = f.alpha,}
x, y = BGetPoint(f.bar)
local r, g, b, a = f.bar.tex:GetVertexColor()
width, height = floor(f.bar:GetWidth() + 0.5), floor(f.bar:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i].bar = {shown = f.bar:IsShown(), horiz = f.bar.horiz, width = width, height = height, x = x, y = y, r = r, g = g, b = b, a = a, texture = f.bar.tex:GetTexture()}
x, y = BGetPoint(f.durationb)
width, height = floor(f.durationb:GetWidth() + 0.5), floor(f.durationb:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i].durationb = {shown = f.durationb:IsShown(), width = width, height = height, x = x, y = y}
end)
 
elseif event == "PLAYER_ENTERING_WORLD" then
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do
for i = 1, 32 do
local f = _G["Buffed"..FrameName..i]
if f then
if BuffedProfiles[UnitName("player")] and BuffedProfiles[UnitName("player")].nocombat and BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] then
if not BuffedProfiles[UnitName("player")] then
BuffedProfiles[UnitName("player")] = {combat = {}, nocombat = {}, filterframes = {BuffedBuffButton = {}, BuffedDebuffButton = {}, TargetBuffedButton = {}, TargetDebuffedButton = {},},}
end
if BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] then
local pos = BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i]
SetConfigVars(pos, f)
if FrameName == "Filter" then
f.enabled = pos.enabled
f.Btype = pos.Btype
f.name = pos.name
f.fs:SetText(pos.name)
end
end
end
end
end
BuffedUpdate("force")
BuffedUpdate("force")
if (BuffedSettings.FrameCreation.Wep == 0) then
TemporaryEnchantFrame:Hide()
end
for i = 1, BuffedSettings.FrameCreation.Filter do
if _G["BuffedFilter"..i] then
for Name, Filter in pairs(BuffedProfiles.FilterFrames) do
if Filter and Filter["BuffedFilter"..i] then
local frame = _G["BuffedFilter"..i]
local g = Filter["BuffedFilter"..i]
frame.enabled = g.enabled
frame.name = g.name
frame.Ftype = g.Ftype
frame.fs:SetText(g.text)
end
end
end
end
end
end
 
local moop = CreateFrame("Frame")
moop:RegisterEvent("ADDON_LOADED")
moop:RegisterEvent("PLAYER_ENTERING_WORLD")
moop:RegisterEvent("PLAYER_LOGOUT")
moop:SetScript("OnEvent", BuffedOnLoad)
 
local DropDownTest = CreateFrame("Frame", "BuffedBuffConfig", UIParent, "UIDropDownMenuTemplate")
634,15 → 639,16
info.checked = nil
info.tooltipTitle = "Delete Filter"
info.tooltipText = "Deletes the filter, sending the buff back to the default stack"
info.func = function()
info.hasArrow = false
ActiveButton.enabled = nil
BuffedProfiles.FilterFrames[ActiveButton.Ftype]["BuffedFilter"..i] = nil
print(ActiveButton.name.." filter deleted")
ActiveButton.name = nil
ToggleLock()
ToggleLock()
BuffedUpdate("force")
info.hasArrow = false
info.func = function()
ActiveButton.enabled = false
BuffedProfiles[UnitName()].filterframes[ActiveButton.Btype][ActiveButton.name] = nil
print(ActiveButton.name.." filter deleted")
ActiveButton.name = nil
ActiveButton.Btype = nil
ToggleLock()
ToggleLock()
BuffedUpdate("force")
end
UIDropDownMenu_AddButton(info, level)
end
697,23 → 703,39
info.func = function()
ForAllFrames(function(f, FrameName, FrameNum, i)
local f = _G["Buffed"..FrameName..i]
if not BuffedProfiles[UnitName("player")] then
BuffedProfiles[UnitName("player")] = {combat = {}, nocombat = {}}
end
local x, y = BGetPoint(f)
local x, y = BGetPoint(f)
local width, height = floor(f:GetWidth() + 0.5), floor(f:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i] = {width = width, height = height, x = x, y = y, alpha = f.alpha,}
x, y = BGetPoint(f.bar)
if not BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i] then
BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i] = {}
end
local t = BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i]
t.width = width t.height = height t.x = x t.y = y t.alpha = f.alpha x, y = BGetPoint(f.bar)
local r, g, b, a = f.bar.tex:GetVertexColor()
width, height = floor(f.bar:GetWidth() + 0.5), floor(f.bar:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i].bar = {shown = f.bar:IsShown(), horiz = f.bar.horiz, width = width, height = height, x = x, y = y, r = r, g = g, b = b, a = a, texture = f.bar.tex:GetTexture()}
t.bar.shown = f.bar:IsShown() t.bar.horiz = f.bar.horiz
t.bar.width = width t.bar.height = height
t.bar.x = x t.bar.y = y t.bar.r = r t.bar.g = g t.bar.b = b t.bar.a = a
t.bar.texture = f.bar.tex:GetTexture()
x, y = BGetPoint(f.durationb)
width, height = floor(f.durationb:GetWidth() + 0.5), floor(f.durationb:GetHeight() + 0.5)
BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i].durationb = {shown = f.durationb:IsShown(), width = width, height = height, x = x, y = y}
t.durationb.shown = f.durationb:IsShown()
t.durationb.width = width t.durationb.height = height
t.durationb.x = x t.durationb.y = y
if FrameName == "Filter" then
t.enabled = f.enabled
t.Btype = f.Btype
t.name = f.name
end
end)
end
UIDropDownMenu_AddButton(info, level)
 
info.text = "Load Profile"
info.tooltipTitle = "Load Character Profile"
info.tooltipText = "Load the settings from another Character"
info.value = "Profiles"
info.hasArrow = true
UIDropDownMenu_AddButton(info, level)
 
end
elseif level == 2 then
if value == "Bars" then
752,6 → 774,33
info.opacityFunc = function() local A = OpacitySliderFrame:GetValue() local R,G,B = ColorPickerFrame:GetColorRGB() ActiveButton.bar.tex:SetVertexColor(R,G,B, 1-A) end
UIDropDownMenu_AddButton(info, level)
 
elseif value == "Profiles" then
for name, tables in pairs(BuffedProfiles) do
info.text = name
info.func = function()
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do
for i = 1, 32 do
local f = _G["Buffed"..FrameName..i]
if f then
print("this bit")
if BuffedProfiles[name].nocombat["Buffed"..FrameName..i] then
local pos = BuffedProfiles[name].nocombat["Buffed"..FrameName..i]
SetConfigVars(pos, f)
print(name, f:GetName())
if FrameName == "Filter" then
f.enabled = pos.enabled
f.Btype = pos.Btype
f.name = pos.name
f.fs:SetText(pos.name)
end
end
end
end
end
BuffedUpdate("force")
end
UIDropDownMenu_AddButton(info, level)
end
end
elseif level == 3 then
if value == "Orientation" then
816,16 → 865,9
end
end
end
for i = 1, 20 do
local f = _G["BuffedFilter"..i]
if f and (f.name == buffname) then
if BuffedProfiles.FilterFrames[buttonName]["BuffedFilter"..i] then
if (BuffedProfiles.FilterFrames[buttonName]["BuffedFilter"..i].name == buffname) then
confbuff = f
HiddenCount = HiddenCount + 1
end
end
end
if BuffedProfiles[UnitName("player")].filterframes[buttonName][buffname] then
confbuff = _G[BuffedProfiles[UnitName("player")].filterframes[buttonName][buffname]]
HiddenCount = HiddenCount + 1
end
local duration = _G[confbuff:GetName().."Duration"]
local bduration = _G[buttonName..index.."Duration"]
914,21 → 956,23
end
end
 
local function BuffedRightClick(self, button, Bname, buttonName)
local function BuffedRightClick(self, button)
if ( button == "RightButton" ) then
CancelUnitBuff(self.unit, self:GetID(), self.filter)
elseif ( button == "LeftButton" ) then
if IsShiftKeyDown() then
if not BuffedProfiles.FilterFrames[buttonName][Bname] then
if not BuffedProfiles[UnitName("player")].filterframes[self.namePrefix][self.name] then
for i = 1, 16 do
frame = _G["BuffedFilter"..i]
if frame and not frame.name then
print("Added "..Bname.." to filter frames")
BuffedProfiles.FilterFrames[buttonName]["BuffedFilter"..i] = {name = Bname, enabled = true, Ftype = buttonName, text = Bname}
local frame = _G["BuffedFilter"..i]
if frame and (not frame.name) then
print("Added "..self.name.." to filter frames")
BuffedProfiles[UnitName("player")].filterframes[self.namePrefix][self.name] = "BuffedFilter"..i
frame.name = self.name
frame.Btype = self.namePrefix
frame.enabled = true
frame.name = Bname
frame.Ftype = buttonName
frame.fs:SetText(Bname)
print(frame.enabled)
frame.fs:SetText(self.name)
ToggleLock() ToggleLock()
BuffedUpdate("force")
return
end
938,7 → 982,7
end
end
 
local function BuffedButtonUpdate(buttonName, index, filter, unit, tag)
local function BuffedButtonUpdate(buttonName, index, filter, unit, tag) --ideally these need to be integrated into the config frames
local name, rank, texture, count, debuffType, duration, expirationTime, IsMine = UnitAura(unit, index, filter);
local buffName = buttonName..index;
local buff = _G[buffName]
973,7 → 1017,7
buff.dbar:Hide()
buff.icon = buff:CreateTexture(buff:GetName().."Icon", "HIGH")
buff.icon:SetAllPoints(buff)
buff:SetScript("OnMouseUp", function(self, button) BuffedRightClick(self, button, name, buttonName) end)
buff:SetScript("OnMouseUp", function(self, button) BuffedRightClick(self, button) end)
buff:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
GameTooltip:SetUnitAura(unit, self:GetID(), self.filter); end)
986,6 → 1030,7
end
end
buff.namePrefix = buttonName;
buff.name = name
buff:SetID(index);
buff.unit = unit;
buff.filter = filter;
1088,7 → 1133,7
BuffedButtonUpdate("BuffedDebuffButton", i, "HARMFUL", "player", "BuffedDebuff")
end
end
if (event == "UNIT_AURA") and (unit == "target") or (event == "PLAYER_TARGET_CHANGED") then
if (event == "UNIT_AURA") and (unit == "target") or (event == "PLAYER_TARGET_CHANGED") or (self == "force") then
HiddenCount = 0
BuffedSort(BuffedSettings.FrameCreation.TargetBuff, "target", "HELPFUL")
for i=1, BuffedSettings.FrameCreation.TargetBuff do
1119,17 → 1164,15
local function BuffedPositioning(self, event, ...)
if (event == "PLAYER_REGEN_ENABLED") then
ForAllFrames(function(f, FrameName, FrameNum, i)
if BuffedProfiles[UnitName("player")] and BuffedProfiles[UnitName("player")].nocombat and BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] then
local pos = BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i]
SetConfigVars(pos, f)
if BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i] then
SetConfigVars(BuffedProfiles[UnitName("player")].nocombat["Buffed"..FrameName..i], f)
end
end)
BuffedUpdate("force")
elseif (event == "PLAYER_REGEN_DISABLED") then
ForAllFrames(function(f, FrameName, FrameNum, i)
if BuffedProfiles[UnitName("player")] and BuffedProfiles[UnitName("player")].combat and BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i] then
local pos = BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i]
SetConfigVars(pos, f)
if BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i] then
SetConfigVars(BuffedProfiles[UnitName("player")].combat["Buffed"..FrameName..i], f)
end
end)
BuffedUpdate("force")