/trunk
local floor, select, UnitAura, UnitName, GetTime, next, pairs = floor, select, UnitAura, UnitName, GetTime, next, pairs |
BuffedSettings = {FrameCreation = {TargetBuff = 7, Buff = 7, Debuff = 7, Wep = 2, TargetDebuff = 7, Master = 1, Filter = 20,}, duration = false, } |
BuffedSettings.texture = {"Interface\\AddOns\\Buffed!\\Flat",} |
local texturelist = {"Interface\\AddOns\\Buffed!\\Flat",} |
local FontColour = {r = 1, g = 1, b = 1, a = 1} |
local scale = UIParent:GetScale() |
end |
local function CreateSettingsMenu() |
local ConFrame = CreateFrame("Frame") |
local ConfigLayout = { |
local ConFrame = CreateFrame("Frame") |
local ConfigLayout = { |
BuffSlider = { Ftype = "Slider", Inherits = "OptionsSliderTemplate", |
FName = "BuffedBuffSlider", Location = "CENTER", Xoff = 0,Yoff = 150, Parent = ConFrame, |
Min = 0, Max = 32, Step = 1, StartVal = BuffedSettings.FrameCreation.Buff,LowText = 0, HighText = 32, |
WepEnchLabel = { Ftype = "FontString", Location = "CENTER", Xoff = -120, Yoff = -50, Parent = ConFrame, |
R = 1, G = 1, B = 1, Width = 200, Height = 15, StringVal = "Show Weapon Enchants:", |
}, |
DurationLabel = { Ftype = "FontString", Location = "CENTER", Xoff = -120, Yoff = -100, Parent = ConFrame, |
R = 1, G = 1, B = 1, Width = 200, Height = 15, StringVal = "Sort By Duration", |
}, |
WepEnchToggle = { Ftype = "CheckButton", Inherits = "InterfaceOptionsCheckButtonTemplate", |
FName = "BuffedTargetDebuffSlider", Location = "CENTER", Xoff = 0, Yoff = -50, Parent = ConFrame, |
Script1 = {event = "OnMouseUp", func = function(self) if TemporaryEnchantFrame:IsShown() then BuffedSettings.FrameCreation.Wep = 0; TemporaryEnchantFrame:Hide() else BuffedSettings.FrameCreation.Wep = 2; TemporaryEnchantFrame:Show() BuffedUpdate("force") end; |
} |
local Text = {} |
for Name, values in pairs(ConfigLayout) do |
if ( values.Ftype == "Frame" ) or ( values.Ftype == "Slider" ) or ( values.Ftype == "CheckButton" ) then |
ConFrame[Name] = CreateFrame(values.Ftype, values.FName, values.Parent, values.Inherits) |
if ( values.Ftype == "Slider" ) then |
ConFrame[Name]:SetMinMaxValues(values.Min,values.Max) |
ConFrame[Name]:SetValueStep(values.Step) |
ConFrame[Name]:SetValue(values.StartVal) |
_G[values.FName.."Low"]:SetText(values.LowText) |
_G[values.FName.."High"]:SetText(values.HighText) |
end |
if (values.Ftype == "CheckButton") then |
if values.variable then |
ConFrame[Name]:SetChecked(true) |
else |
ConFrame[Name]:SetChecked(false) |
for Name, values in pairs(ConfigLayout) do |
if ( values.Ftype == "Frame" ) or ( values.Ftype == "Slider" ) or ( values.Ftype == "CheckButton" ) then |
ConFrame[Name] = CreateFrame(values.Ftype, values.FName, values.Parent, values.Inherits) |
if ( values.Ftype == "Slider" ) then |
ConFrame[Name]:SetMinMaxValues(values.Min,values.Max) |
ConFrame[Name]:SetValueStep(values.Step) |
ConFrame[Name]:SetValue(values.StartVal) |
_G[values.FName.."Low"]:SetText(values.LowText) |
_G[values.FName.."High"]:SetText(values.HighText) |
end |
end |
if values["Script1"] then |
if (values.Ftype == "CheckButton") then |
if values.variable then |
ConFrame[Name]:SetChecked(true) |
else |
ConFrame[Name]:SetChecked(false) |
end |
end |
if values["Script1"] then |
ConFrame[Name]:SetScript(values["Script1"].event, values["Script1"].func) |
end |
ConFrame[Name]:SetScript(values["Script1"].event, values["Script1"].func) |
if values["Script2"] then |
ConFrame[Name]:SetScript(values["Script2"].event, values["Script2"].func) |
end |
end |
ConFrame[Name]:SetScript(values["Script1"].event, values["Script1"].func) |
if values["Script2"] then |
ConFrame[Name]:SetScript(values["Script2"].event, values["Script2"].func) |
if ( values.Ftype == "FontString" ) then |
ConFrame[Name] = ConFrame:CreateFontString(Name, "OVERLAY", "GameFontNormal") |
ConFrame[Name]:SetWidth(values.Width) |
ConFrame[Name]:SetHeight(values.Height) |
ConFrame[Name]:SetTextColor(values.R,values.G,values.B) |
if values.StringVal then |
ConFrame[Name]:SetText(values.StringVal) |
end |
end |
ConFrame[Name]:SetPoint(values.Location,values.Xoff,values.Yoff) |
end |
if ( values.Ftype == "FontString" ) then |
ConFrame[Name] = ConFrame:CreateFontString(Name, "OVERLAY", "GameFontNormal") |
ConFrame[Name]:SetWidth(values.Width) |
ConFrame[Name]:SetHeight(values.Height) |
ConFrame[Name]:SetTextColor(values.R,values.G,values.B) |
if values.StringVal then |
ConFrame[Name]:SetText(values.StringVal) |
end |
end |
ConFrame[Name]:SetPoint(values.Location,values.Xoff,values.Yoff) |
end |
ConFrame.name = "Buffed!" |
InterfaceOptions_AddCategory(ConFrame) |
end |
local function SetConfigVars(pos, f) |
if not pos then return end |
BSetPoint(f, pos.x, pos.y) |
f:SetWidth(pos.width) |
f:SetHeight(pos.height) |
f.alpha = pos.alpha |
if pos.bar and pos.bar.shown then f.bar:Show() else f.bar:Hide() end |
f.bar.horiz = pos.bar.horiz |
f.bar:SetWidth(pos.bar.width) |
f.bar:SetHeight(pos.bar.height) |
f.bar.tex:SetTexture(pos.bar.texture) |
f.bar.tex:SetVertexColor(0,0,0) |
f.bar.tex:SetVertexColor(pos.bar.r, pos.bar.g, pos.bar.b, pos.bar.a) |
BSetPoint(f.bar, pos.bar.x-pos.x, pos.bar.y-pos.y, f, "CENTER") |
BSetPoint(f.durationb, pos.durationb.x-pos.x, pos.durationb.y-pos.y, f, "CENTER") |
end |
local function BuffedOnLoad(self, event, ...) |
if event == "ADDON_LOADED" then |
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 |
if f then |
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] |
BSetPoint(f, pos.x, pos.y) |
f:SetWidth(pos.width) |
f:SetHeight(pos.height) |
f.alpha = pos.alpha |
if pos.bar and pos.bar.shown then f.bar:Show() else f.bar:Hide() end |
f.bar.horiz = pos.bar.horiz |
f.bar:SetWidth(pos.bar.width) |
f.bar:SetHeight(pos.bar.height) |
f.bar.tex:SetTexture(pos.bar.texture) |
f.bar.tex:SetVertexColor(0,0,0) |
f.bar.tex:SetVertexColor(pos.bar.r, pos.bar.g, pos.bar.b, pos.bar.a) |
BSetPoint(f.bar, pos.bar.x-pos.x, pos.bar.y-pos.y, f, "CENTER") |
BSetPoint(f.durationb, pos.durationb.x-pos.x, pos.durationb.y-pos.y, f, "CENTER") |
SetConfigVars(pos, f) |
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") |
UIDropDownMenu_SetSelectedValue(this.owner, this.value); |
end |
local function AlphaSlider() |
local Slider |
if not _G["SwishAlphaSlider"] then |
Slider = CreateFrame("Slider", "SwishAlphaSlider", UIParent, "OptionsSliderTemplate") |
if ActiveButton.alpha then |
Slider:SetValue(ActiveButton.alpha) |
else |
Slider:SetValue(0.5) |
end |
Slider:SetMinMaxValues(0,1) |
Slider:SetValueStep(0.05) |
_G["SwishAlphaSliderLow"]:SetText(0) |
_G["SwishAlphaSliderHigh"]:SetText(1) |
Slider:SetScript("OnValueChanged", function(self) |
ActiveButton.ti:SetAlpha(self:GetValue()); |
ActiveButton.alpha = self:GetValue(); |
if (ActiveButton:GetName() == "BuffedMaster1") then |
ForAllFrames(function(f) f.ti:SetAlpha(self:GetValue()) f.alpha = self:GetValue() end) |
end |
end) |
Slider:SetScript("OnMouseUp", function(self) self:Hide(); BuffedUpdate("force") end) |
Slider:SetWidth(ActiveButton:GetWidth() + 30) |
else |
Slider = _G["SwishAlphaSlider"] |
if ActiveButton.alpha then |
Slider:SetValue(ActiveButton.alpha) |
else |
Slider:SetValue(0.5) |
end |
Slider:SetScript("OnValueChanged", function(self) |
ActiveButton.ti:SetAlpha(self:GetValue()); |
ActiveButton.alpha = self:GetValue(); |
if (ActiveButton:GetName() == "BuffedMaster1") then |
ForAllFrames(function(f) f.ti:SetAlpha(self:GetValue()) f.alpha = self:GetValue() end) |
end |
end) |
end |
Slider:ClearAllPoints() |
Slider:SetPoint("CENTER", ActiveButton, "TOP", 0, 10) |
Slider:Show() |
end |
local function MasterOptions(var, val1, val2) |
if ActiveButton[var] then |
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do |
if (ActiveButton:GetName() == "BuffedMaster1") then |
info.func = function() |
if (ActiveButton.padding == 10) then |
ForAllFrames(function(f) |
f.padding = 0 end) |
ForAllFrames(function(f)f.padding = 0 end) |
else |
for FrameName, FrameNum in pairs(BuffedSettings.FrameCreation) do |
for i = 1, FrameNum do |
info.text = "Alpha" |
info.value = "Alpha" |
info.checked = nil |
info.hasArrow = true |
info.tooltipTitle = "Alpha" |
info.tooltipText = "Set the Alpha for this frame" |
info.func = function() AlphaSlider() end |
info.hasOpacity = 1 |
info.opacity = ActiveButton.ti:GetAlpha() |
if (ActiveButton:GetName() == "BuffedMaster1") then |
info.opacityFunc = function() ForAllFrames(function(f)local A = OpacitySliderFrame:GetValue() f.ti:SetAlpha(A) f.alpha = A end)end |
else |
info.opacityFunc = function() local A = OpacitySliderFrame:GetValue() ActiveButton.ti:SetAlpha(A) ActiveButton.alpha = A end |
end |
UIDropDownMenu_AddButton(info, level) |
local duration = _G[ActiveButton:GetName().."Duration"] |
info.hasOpacity = nil |
info.hasArrow = false |
info.text = "Show Dummy Timers" |
info.value = 3 |
info.checked = duration:IsShown() |
end |
end |
else |
info.func = function() if duration:IsShown() then duration:Hide() else duration:Show() end end |
info.func = function() if duration:IsShown() then duration:Hide() else duration:Show() end end |
end |
UIDropDownMenu_AddButton(info, level) |
end |
UIDropDownMenu_AddButton(info, level) |
info.text = "Save Settings" |
info.value = 3 |
info.checked = nil |
info.tooltipTitle = "Save the current position of all buffs" |
info.tooltipText = "Save the current buff position as the location for buffs out of combat" |
info.func = function() 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) end |
UIDropDownMenu_AddButton(info, level) |
end |
elseif level == 2 then |
if value == "Bars" then |
end |
UIDropDownMenu_AddButton(info, level) |
elseif value == "Texture" then |
for num, val in ipairs(BuffedSettings.texture) do |
for num, val in ipairs(texturelist) do |
local valshort = val:match("([^\\]+)$") |
info.text = valshort |
info.value = val |
end |
end |
end |
UIDropDownMenu_Initialize(DropDownTest, DropDownTest_Initialize, "MENU") |
--------------------------------- anchor all buff frames --------------------------------- |
local buff = _G[buttonName..index] |
local confbuff = _G[tag..index-HiddenCount] |
if BuffedSettings.BuffIsMine and not (IsMine == "player") then |
buff:Hide() |
HiddenCount = HiddenCount + 1 |
return |
buff:Hide() |
HiddenCount = HiddenCount + 1 |
return |
end |
if next(BuffedSorter) then |
for i = 1, #BuffedSorter do |
if confbuff.alpha then |
buff:SetAlpha(confbuff.alpha) |
end |
buff:SetAllPoints(confbuff) |
buff.parent = confbuff |
buff:SetAllPoints(confbuff) |
buff.parent = confbuff |
end |
local function OpenConfig() |
local hours = floor(timer/3600) |
local minutes = floor((timer-hours*3600)/60) |
local seconds = floor((timer-hours*3600 -minutes*60)) |
if self.verbose then |
if self.verbose then |
else |
if hours > 0 and minutes > 0 then |
if minutes >= 10 then |
if not self.divider then |
self.divider = 0 |
end |
self.divider = self.divider + elapsed |
self.timeLeft = max(self.timeLeft - elapsed, 0); |
self.divider = self.divider + elapsed |
self.timeLeft = max(self.timeLeft - elapsed, 0); |
if self.divider > 0.1 then |
self.dbar:SetValue(self.timeLeft) |
if self.parent and self.parent.bar then |
end |
end |
local function BuffedButtonUpdate(buttonName, index, filter, unit, tag) |
local name, rank, texture, count, debuffType, duration, expirationTime, IsMine = UnitAura(unit, index, filter); |
local buffName = buttonName..index; |
buff.border:SetAllPoints(buff) |
end |
end |
-- Setup Buff |
buff.namePrefix = buttonName; |
buff:SetID(index); |
buff.unit = unit; |
buff.filter = filter; |
buff:Show(); |
-- Set filter-specific attributes |
BuffedBuffButtonAnchors(buttonName, index, IsMine, name, tag) |
if not helpful then |
if ( buff.border ) then |
end |
if ( duration > 0 and expirationTime ) then |
buff.duration:Show(); |
if parent and parent.bar and parent.bar:IsShown() then |
buff.dbar:SetWidth(parent.bar:GetWidth()) --this whole chunk needs moving |
buff.dbar:SetHeight(parent.bar:GetHeight()) |
end |
buff.timeLeft = nil; |
end |
buff.icon:SetTexture(texture); |
if ( count > 1 ) then |
buff.count:SetText(count); |
buff.count:Show(); |
else |
buff.count:Hide(); |
end |
if ( GameTooltip:IsOwned(buff) ) then -- Refresh tooltip |
GameTooltip:SetUnitAura(unit, index, filter); |
end |
end |
end |
--[[ |
As you can see, the problem with sorting the buffs by duration is that it requires UnitAura to be called twice as often: |
once, to determine the duration of all of the buffs and sort them, and then again to set the buff frames and positions up. |
--]] |
function BuffedUpdate(self, event, unit, ...) |
if (event == "UNIT_AURA") and (unit == "player") or (self == "force") then |
HiddenCount = 0 -- reset each time |
h:RegisterEvent("PLAYER_TARGET_CHANGED") |
h:SetScript("OnEvent", BuffedUpdate) |
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] |
BSetPoint(f, pos.x, pos.y) |
f:SetWidth(pos.width) |
f:SetHeight(pos.height) |
f.alpha = pos.alpha |
if pos.bar.shown then f.bar:Show() else f.bar:Hide() end |
f.bar.horiz = pos.bar.horiz |
f.bar:SetWidth(pos.bar.width) |
f.bar:SetHeight(pos.bar.height) |
f.bar.tex:SetVertexColor(0,0,0) |
f.bar.tex:SetVertexColor(pos.bar.r, pos.bar.g, pos.bar.b, pos.bar.a) |
BSetPoint(f.bar, pos.bar.x-pos.x, pos.bar.y-pos.y, f, "CENTER") |
BSetPoint(f.durationb, pos.durationb.x-pos.x, pos.durationb.y-pos.y, f, "CENTER") |
SetConfigVars(pos, f) |
end |
end) |
BuffedUpdate("force") |
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] |
BSetPoint(f, pos.x, pos.y) |
f:SetWidth(pos.width) |
f:SetHeight(pos.height) |
f.alpha = pos.alpha |
if pos.bar.shown then f.bar:Show() else f.bar:Hide() end |
f.bar.horiz = pos.bar.horiz |
f.bar:SetWidth(pos.bar.width) |
f.bar:SetHeight(pos.bar.height) |
f.bar.tex:SetVertexColor(0,0,0) |
f.bar.tex:SetVertexColor(pos.bar.r, pos.bar.g, pos.bar.b, pos.bar.a) |
BSetPoint(f.bar, pos.bar.x-pos.x, pos.bar.y-pos.y, f, "CENTER") |
BSetPoint(f.durationb, pos.durationb.x-pos.x, pos.durationb.y-pos.y, f, "CENTER") |
SetConfigVars(pos, f) |
end |
end) |
BuffedUpdate("force") |
g:RegisterEvent("PLAYER_REGEN_DISABLED") |
g:SetScript("OnEvent", BuffedPositioning) |
function BuffFrame_Update() |
end |
function TargetFrame_UpdateAuras (self) |
end |
function BuffFrame_Update() end |
function TargetFrame_UpdateAuras (self) end |
## Interface: 30100 |
## Title: Buffed! |
## Notes: Buff frame mod? |
## Version 2.05 Alpha |
## Version 2.05 Beta |
## Author: Kraftman |
## SavedVariables: BuffedSettings, BuffedProfiles |
Buffed!.lua |