/
local bdCore, c, f = select(2, ...):unpack() |
bdCore.auras = {} |
bdCore.auras.raid = { |
---------------------------------------------------- |
-- Highmaul |
---------------------------------------------------- |
-- Kargath |
["Vile Breath"] = true, |
["Impale"] = true, |
["Berserker Rush"] = true, |
["On the Hunt"] = true, |
["Chain Hurl"] = true, |
["Iron Bomb"] = true, |
-- Butcher |
["The Tenderizer"] = true, |
["Gushing Wounds"] = true, |
-- Tectus |
["Crystalline Barrage"] = true, |
["Gift of Earth"] = true, |
-- Brackspore |
["Necrotic Breath"] = true, |
["Decay"] = true, |
["Infesting Spores"] = true, |
-- Twins |
["Blaze"] = true, |
["Enfeebling Roar"] = true, |
["Injured"] = true, |
-- Koragh |
["Caustic Energy"] = true, |
["Suppression Field"] = true, |
["Expel Magic: Arcane"] = true, |
["Expel Magic: Shadow"] = true, |
["Expel Magic: Fire"] = true, |
["Expel Magic: Frost"] = true, |
-- Margok |
["Mark of Chaos"] = true, |
["Crush Armor"] = true, |
["Fixate"] = true, |
["Infinite Darkness"] = true, |
["Gaze of the Abyss"] = true, |
["Destructive Resonance"] = true, |
["Force Nova: Displacement"] = true, |
["Force Nova: Fortification"] = true, |
["Force Nova: Replication"] = true, |
["Branded: Displacement"] = true, |
["Branded: Fortification"] = true, |
["Branded: Replication"] = true, |
---------------------------------------------------- |
-- Blackrock Foundry |
---------------------------------------------------- |
-- Gruul |
["Inferno Slice"] = true, |
["Overwhelming Blows"] = true, |
["Petrify"] = true, |
["Cave In"] = true, |
-- Oregorger |
["Acid Maw"] = true, |
["Acid Torrent"] = true, |
["Retched Blackrock"] = true, |
-- Beastlord |
["Pinned Down"] = true, |
["Rend and Tear"] = true, |
["Seared Flesh"] = true, |
["Crush Armor"] = true, |
["Conflagration"] = true, |
-- Flamebender |
["Charring Breath"] = true, |
["Fixate"] = true, |
["Molten Torrent"] = true, |
["Rising Flames"] = true, |
["Singe"] = true, |
["Lava Slash"] = true, |
["Blazing Radiance"] = true, |
-- Hanz/Franz |
["Shattered Vertebrae"] = true, |
["Disrupting Roar"] = true, |
["Aftershock"] = true, |
-- Operator Thogar |
["Enkindle"] = true, |
["Prototype Pulse Grenade"] = true, |
["Serrated Slash"] = true, |
["Delayed Siege Bomb"] = true, |
["Burning"] = true, |
-- Blast Furance |
["Fixate"] = true, |
["Bomb"] = true, |
["Tempered"] = true, |
["Heat"] = true, |
["Rupture"] = true, |
["Slag Pool"] = true, |
["Melt"] = true, |
["Rupture"] = true, |
-- Kromog |
["Warped Armor"] = true, |
["Thundering Blows"] = true, |
-- Iron Maidens |
["Blood Ritual"] = true, |
["Dominator Blast"] = true, |
["Penetrating Shot"] = true, |
--["Fixate"] = true, |
["Dark Hunt"] = true, |
["Convulsive Shadows"] = true, |
["Bloodsoaked Heartseeker"] = true, |
-- Blackhand |
["Burned"] = true, |
["Slagged"] = true, |
["Marked for Death"] = true, |
["Impaled"] = true, |
["Fixate"] = true, |
["Slag Bombs"] = true, |
["Incendiary Shot"] = true, |
["Broken Bones"] = true, |
["Rending Cleave"] = true, |
---------------------------------------------------- |
-- Hellfire Citadel |
---------------------------------------------------- |
-- Assault |
['Slam'] = true, |
['Howling Axe'] = true, |
['Conducted Shock Pulse'] = true, |
-- Iron Reaver |
["Unstable Orb"] = true, |
["Immolation"] = true, |
["Artillery"] = true, |
-- Killrog deadeye |
['Heart Seeker'] = true, |
['Shredded Armor'] = true, |
-- Gorefiend |
['Doom Well'] = true, |
['Hunger for Life'] = true, |
['Shadow of Death'] = true, |
['Pool of Souls'] = true, |
["Gorefiend's Corruption"] = true, |
--Council |
['Mark of the Necromancer'] = true, |
['Bloodboil'] = true, |
['Fel Rage'] = true, |
-- Kormrok |
["Fiery Burst"] = true, |
["Crush"] = true, |
["Foul Pool"] = true, |
-- Fel Lord Zakuun |
['Latent Energy'] = true, |
['Seed of Destruction'] = true, |
['Befouled'] = true, |
-- Xhul'horac |
['Chains of Fel'] = true, |
['Void Strike'] = true, |
['Fel Strike'] = true, |
['Feltouched'] = true, |
['Voidtouched'] = true, |
['Ablaze'] = true, |
['Fel Surge'] = true, |
['Void Surge'] = true, |
['Empowered Chains of Fel'] = true, |
-- Socrethar |
['Shattered Defenses'] = true, |
['Shadow Word: Agony'] = true, |
["Gift of the Man'ari"] = true, |
-- Iskar |
['Phantasmal Corruption'] = true, |
['Phantasmal Wounds'] = true, |
['Phantasmal Winds'] = true, |
['Fel Bomb'] = true, |
['Radiance of Anzu'] = true, |
['Fel Beam Fixate'] = true, |
['Eye of Anzu'] = true, |
['Fel Fire'] = true, |
-- Tyrant Tumblr |
['Touch of Harm'] = true, |
['Edict of Condemnation'] = true, |
['Seal of Decay'] = true, |
['Font of Corruption'] = true, |
-- Mannoroth |
['Mark of Doom'] = true, |
['Shadowforce'] = true, |
["Wrath of Gul'dan"] = true, |
["Mannoroth's Gaze"] = true, |
["Empowered Mannoroth's Gaze"] = true, |
["Empowered Massive Blast"] = true, |
["Blood of Mannoroth"] = true, |
["Curse of the Legion"] = true, |
["Gripping Shadows"] = true, |
["Doom Spike"] = true, |
-- Archimonde |
['Doomfire'] = true, -- Heal |
['Doomfire Fixate'] = true, -- Run |
['Shackled Torment'] = true, -- p2 shackles, keep them up |
['Shadow Blast'] = true, -- Tanks |
['Devour Life'] = true, -- Healing debuff in heroic |
['Source of Chaos'] = true, -- Tanks in p3 |
['Void Star Fixate'] = true, -- void star in p3 |
['Shadowfel Burst'] = true, -- p1 knock in the air |
['Touch of the Legion'] = true, -- p3 knockback thing |
-- Trash |
['Cheap Shot'] = true, |
['Ambush'] = true, |
['Fel Blaze'] = true, |
['Fel Fury'] = true, |
['Devouring Spirit'] = true, |
-- Players |
['Draenic Channeled Mana Potion'] = true, |
} |
bdCore.auras.whitelist = { |
-- Warriors |
["Die by the Sword"] = true, |
["Shield Wall"] = true, |
["Demoralizing Shout"] = true, |
--["Enraged Regeneration"] = true, |
--["Last Stand"] = true, |
["Safeguard"] = true, |
["Vigilance"] = true, |
-- Druids |
["Barkskin"] = true, |
["Survival Instincts"] = true, |
["Ironbark"] = true, |
["Bristling Fur"] = true, |
-- Shamans |
["Shamanistic Rage"] = true, |
["Astral Shift"] = true, |
["Stone Bulwark Totem"] = true, |
-- Death Knights |
["Icebound Fortitude"] = true, |
--["Anti-Magic Shell"] = true, |
["Anti-Magic Zone"] = true, |
["Vampiric Blood"] = true, |
["Rune Tap"] = true, |
-- Rogues |
["Feint"] = true, |
["Cloak of Shadows"] = true, |
["Evasion"] = true, |
["Smoke Bomb"] = true, |
-- Mages |
["Ice Block"] = true, |
["Temporal Shield"] = true, |
["Cauterize"] = true, |
["Greater Invisibility"] = true, |
["Amplify Magic"] = true, |
["Evanesce"] = true, |
-- Warlocks |
["Dark Bargain"] = true, |
["Unending Resolve"] = true, |
-- Paladins |
["Divine Shield"] = true, |
["Divine Protection"] = true, |
["Hand of Protection"] = true, |
["Hand of Sacrifice"] = true, |
["Hand of Purity"] = true, |
["Ardent Defender"] = true, |
["Guardian of Ancient Kings"] = true, |
["Forbearance"] = true, |
-- Monks |
["Fortifying Brew"] = true, |
["Zen Meditation"] = true, |
["Diffuse Magic"] = true, |
["Dampen Harm"] = true, |
["Touch of Karma"] = true, |
-- Hunters |
["Deterrence"] = true, |
["Roar of Sacrifice"] = true, |
-- Priests |
["Dispersion"] = true, |
["Spectral Guise"] = true, |
["Pain Suppression"] = true, |
} |
bdCore.auras.blacklist = { |
-- paladins |
["Illuminated Healing"] = true, |
["Unyielding Faith"] = true, |
["Glyph of Templar's Verdict"] = true, |
["Beacon's Tribute"] = true, |
-- warlocks |
["Soul Leech"] = true, |
["Empowered Grasp"] = true, |
["Twilight Ward"] = true, |
["Shadow Trance"] = true, |
["Dark Refund"] = true, |
-- warriors |
["Bloody Healing"] = true, |
["Flurry"] = true, |
["Victorious"] = true, |
["Deep Wounds"] = true, |
["Mortal Wounds"] = true, |
["Enrage"] = true, |
["Blood Craze"] = true, |
["Ultimatum"] = true, |
["Sword and Board"] = true, |
-- Death Knights |
["Purgatory"] = true, |
-- misc |
["Honorless Target"] = true, |
["Spirit Heal"] = true, |
["Capacitance"] = true, |
["Sated"] = true, |
["Exhaustion"] = true, |
["Insanity"] = true, |
["Temporal Displacement"] = true, |
["Void-Touched"] = true, |
["Awesome!"] = true, |
["Griefer"] = true, |
["Vivianne Defeated"] = true, |
["Recently Mass Resurrected"] = true, |
-- Priests |
["Weakened Soul"] = true, |
-- Paladins |
["Beacon's Tribute"] = true |
} |
bdCore.auras.player_class = { |
preist = { |
["Weakened Soul"] = true, |
}, |
paladin = { |
}, |
deathknight = { |
}, |
rogue = { |
}, |
shaman = { |
}, |
warlock = { |
}, |
mage = { |
}, |
monk = { |
}, |
hunter = { |
}, |
druid = { |
}, |
warrior = { |
} |
} |
bdCore.auras.mine = { |
["Lifebloom"] = true, |
["Rejuvenation"] = true, |
["Regrowth"] = true, |
["Rejuvenation (Germination)"] = true, |
["Prayer of Mending"] = true, |
["Eternal Flame"] = true, |
["Sacred Shield"] = true, |
["Beacon of Light"] = true, |
["Beacon of Faith"] = true, |
["Weakened Soul"] = true, |
} |
local bdCore, c, f = select(2, ...):unpack() |
bdCore:RegisterEvent("ADDON_LOADED") |
bdCore:RegisterEvent("PLAYER_REGEN_ENABLED") |
bdCore:RegisterEvent("PLAYER_REGEN_DISABLED") |
bdCore:SetScript("OnEvent", function(self, event, arg1, arg2, ...) |
if (event == "ADDON_LOADED" and arg1 == "bdCore") then |
bdCore:triggerEvent('loaded_bdcore') |
if (not bdCoreDataPerChar) then |
bdCoreDataPerChar = c |
end |
c.sv = bdCoreDataPerChar |
c.sv.positions = c.sv.positions or {} |
c.sv.auras = c.sv.auras or {} |
c.sv.auras.raid = c.sv.auras.raid or {} |
c.sv.auras.whitelist = c.sv.auras.whitelist or {} |
c.sv.auras.blacklist = c.sv.auras.blacklist or {} |
c.sv.auras.mine = c.sv.auras.mine or {} |
c.sv.auras.player_class = c.sv.auras.mine.player_class or {} |
c.sv.goldtrack = c.sv.goldtrack or {} |
-- if something is nil, it needs to get set |
for group, options in pairs(c) do |
if (bdCoreDataPerChar[group] == nil) then |
bdCoreDataPerChar[group] = c[group] |
end |
for option, value in pairs(options) do |
if (bdCoreDataPerChar[group][option] == nil) then |
bdCoreDataPerChar[group][option] = value |
end |
end |
end |
for group, options in pairs(c.sv) do |
for option, value in pairs(options) do |
if (not c[group]) then c[group] = {} end |
if (c[group][option] ~= value) then |
c[group][option] = value |
end |
end |
end |
bdCore:addModule("Aura Whitelist", bdCore.whitelistconfig) |
bdCore:addModule("Aura Blacklist", bdCore.blacklistconfig) |
bdCore:addModule("Personal Auras", bdCore.personalconfig) |
bdCore:triggerEvent('bdcore_loaded') |
elseif (event == "PLAYER_REGEN_DISABLED") then |
bdCore:triggerEvent('combat_enter') |
elseif (event == "PLAYER_REGEN_ENABLED") then |
bdCore:triggerEvent('combat_exit') |
end |
return true |
end) |
## Interface: 60200 |
## Title: |cffA02C2Fbd|rCore |
## Version: 0 |
## DefaultState: Enabled |
## LoadOnDemand: 0 |
## SavedVariables: bdCoreData |
## SavedVariables: bdCoreDataPerChar |
core.lua |
api.lua |
functions.lua |
auras.lua |
config\defaults.lua |
config\config.lua |
loading.lua |
local bdCore, c, f = select(2, ...):unpack() |
local media = bdCore.media |
local configdims = { |
width = 400, |
left_col = 140, |
height = 430, |
} |
local cfg = CreateFrame( "Frame", "bdCore config", UIParent) |
cfg:SetPoint("RIGHT", UIParent, "RIGHT", -20, 0) |
cfg:SetSize(configdims.width, configdims.height) |
bdCore:setBackdrop(cfg) |
cfg:SetMovable(true) |
cfg:SetUserPlaced(true) |
cfg:SetFrameStrata("DIALOG") |
cfg:SetClampedToScreen(true) |
bdCore:createShadow(cfg,10) |
cfg:Hide() |
cfg.header = CreateFrame("frame",nil,cfg) |
cfg.header:SetPoint("TOPLEFT",cfg,"TOPLEFT",0,0) |
cfg.header:SetSize(configdims.width,30) |
cfg.header:RegisterForDrag("LeftButton","RightButton") |
cfg.header:EnableMouse(true) |
cfg.header:SetScript("OnDragStart", function(self) cfg:StartMoving() end) |
cfg.header:SetScript("OnDragStop", function(self) cfg:StopMovingOrSizing() end) |
cfg.header.title = CreateFrame( "Frame", nil, cfg.header) |
cfg.header.title:SetSize(configdims.left_col,30) |
cfg.header.title:SetBackdrop({bgFile = media.flat}) |
cfg.header.title:SetBackdropColor(1,1,1,.05) |
cfg.header.title:SetPoint("LEFT", cfg.header, "LEFT") |
cfg.header.title.t = cfg.header.title:CreateFontString(nil, "OVERLAY") |
cfg.header.title.t:SetFont(media.font, 16) |
cfg.header.title.t:SetTextColor(1, 1, 1, 1) |
cfg.header.title.t:SetText("bdCore Config") |
cfg.header.title.t:SetAllPoints(cfg.header.title) |
cfg.header.title.t:SetJustifyH("CENTER") |
-- exit button |
cfg.header.close = CreateFrame("Button", nil, cfg.header) |
cfg.header.close:SetPoint("TOPRIGHT", cfg.header, "TOPRIGHT", 0 ,0) |
cfg.header.close:SetSize(30, 28) |
cfg.header.close:SetBackdrop({bgFile = media.flat}) |
cfg.header.close:SetBackdropColor(unpack(media.red)) |
cfg.header.close:SetAlpha(0.6) |
cfg.header.close:EnableMouse(true) |
cfg.header.close:SetScript("OnEnter", function() |
cfg.header.close:SetAlpha(1) |
end) |
cfg.header.close:SetScript("OnLeave", function() |
cfg.header.close:SetAlpha(0.6) |
end) |
cfg.header.close:SetScript("OnClick", function() |
cfg:Hide() |
end) |
cfg.header.close.x = cfg.header.close:CreateFontString(nil) |
cfg.header.close.x:SetFont(media.font, 12) |
cfg.header.close.x:SetText("x") |
cfg.header.close.x:SetPoint("CENTER", cfg.header.close, "CENTER", .5, 0) |
-- reload button |
cfg.header.reload = CreateFrame("Button", nil, cfg.header) |
cfg.header.reload:SetPoint("RIGHT", cfg.header.close, "LEFT", -2 ,0) |
cfg.header.reload:SetSize(70, 28) |
cfg.header.reload:SetBackdrop({bgFile = media.flat}) |
cfg.header.reload:SetBackdropColor(unpack(media.blue)) |
cfg.header.reload:SetAlpha(0.6) |
cfg.header.reload:EnableMouse(true) |
cfg.header.reload:SetScript("OnEnter", function() |
cfg.header.reload:SetAlpha(1) |
end) |
cfg.header.reload:SetScript("OnLeave", function() |
cfg.header.reload:SetAlpha(0.6) |
end) |
cfg.header.reload:SetScript("OnClick", function() |
ReloadUI() |
end) |
cfg.header.reload.x = cfg.header.reload:CreateFontString(nil) |
cfg.header.reload.x:SetFont(media.font, 12) |
cfg.header.reload.x:SetText("Reload UI") |
cfg.header.reload.x:SetPoint("CENTER", cfg.header.reload, "CENTER", 1, 0) |
-- lock/unlock button |
cfg.header.lock = CreateFrame("Button", nil, cfg.header) |
cfg.header.lock:SetPoint("RIGHT", cfg.header.reload, "LEFT", -2 ,0) |
cfg.header.lock:SetSize(70, 28) |
cfg.header.lock:SetBackdrop({bgFile = media.flat}) |
cfg.header.lock:SetBackdropColor(unpack(media.green)) |
cfg.header.lock:SetAlpha(0.6) |
cfg.header.lock:EnableMouse(true) |
cfg.header.lock:SetScript("OnEnter", function() |
cfg.header.lock:SetAlpha(1) |
end) |
cfg.header.lock:SetScript("OnLeave", function() |
cfg.header.lock:SetAlpha(0.6) |
end) |
cfg.header.lock:SetScript("OnClick", function(self) |
bdCore.toggleLock() |
if (self.x:GetText() == "Lock") then |
self.x:SetText("Unlock") |
else |
self.x:SetText("Lock") |
end |
end) |
cfg.header.lock.x = cfg.header.lock:CreateFontString(nil) |
cfg.header.lock.x:SetFont(media.font, 12) |
cfg.header.lock.x:SetText("Unlock") |
cfg.header.lock.x:SetPoint("CENTER", cfg.header.lock, "CENTER", 1, 0) |
-- main window |
cfg.main = CreateFrame("frame",nil,cfg) |
cfg.main:SetPoint("TOPLEFT",cfg.header,"BOTTOMLEFT") |
cfg.main:SetPoint("BOTTOMRIGHT",cfg,"BOTTOMRIGHT", 0, 0) |
bdCore:setBackdrop(cfg.main) |
-- left |
cfg.left = CreateFrame( "Frame", nil, cfg) |
cfg.left:SetPoint("TOPLEFT", cfg.main, "TOPLEFT", 0, 0) |
cfg.left:SetPoint("BOTTOMRIGHT", cfg.main, "BOTTOMLEFT", configdims.left_col, 0) |
cfg.left:SetBackdrop({bgFile = media.flat}) |
cfg.left:SetBackdropColor(1,1,1,.05) |
-- functions |
cfg.options = {} |
cfg.panels = {} |
cfg.config = {} |
cfg.lastitem = false |
function bdCore:toggleConfig() |
cfg:Show() |
cfg.first.select() |
if (bdCore.moving) then |
cfg.header.lock.x:SetText("Lock") |
else |
cfg.header.lock.x:SetText("Unlock") |
end |
end |
--bdCore:hookEvent("bdcore_loaded",function() bdCore:toggleConfig() end) |
function bdCore:addModule(name,configs) |
local smartconf = {} |
local frame = CreateFrame('frame', nil, cfg) |
frame.name = name |
frame:SetSize(configdims.left_col, 26) |
if (not cfg.lastitem) then |
frame:SetPoint("TOP", cfg.left, "TOP", 0, 0) |
cfg.first = frame |
else |
frame:SetPoint("TOP", cfg.lastitem, "BOTTOM", 0, 0) |
end |
cfg.lastitem = frame |
frame:SetBackdrop({bgFile = media.flat}) |
frame:SetBackdropColor(0,0,0,0) |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", function() |
if (not frame.active) then |
frame:SetBackdropColor(1,1,1,0.1) |
end |
end) |
frame:SetScript("OnLeave", function() |
if (not frame.active) then |
frame:SetBackdropColor(1,1,1,0) |
end |
end) |
frame.select = function() |
if (frame.active) then return end |
for k, v in pairs(cfg.options) do |
cfg.panels[k]:Hide() |
cfg.options[k].active = false |
cfg.options[k]:SetBackdropColor(0,0,0,0) |
end |
cfg.panels[frame.name]:Show() |
frame.active = true |
frame:SetBackdropColor(unpack(media.red)) |
cfg.first = frame |
end |
frame:SetScript("OnMouseUp", function() |
frame.select() |
end) |
frame.text = frame:CreateFontString(nil, "OVERLAY") |
frame.text:SetPoint("LEFT", frame, "LEFT", 8, 0) |
frame.text:SetFont(media.font, 14) |
frame.text:SetText(name) |
--parent frame |
local panel = CreateFrame('frame', nil, cfg) |
panel:SetPoint("TOPLEFT", cfg.left, "TOPRIGHT", 0, -2) |
panel:SetPoint("BOTTOMRIGHT", cfg.main, "BOTTOMRIGHT", -2, 2) |
panel.name = name |
panel:Hide() |
cfg.config[name] = panel |
--scrollframe |
local scrollframe = CreateFrame("ScrollFrame", nil, panel) |
scrollframe:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -30, -10) |
scrollframe:SetSize(panel:GetWidth()-40, panel:GetHeight()-20) |
panel.scrollframe = scrollframe |
--scrollbar |
local scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate") |
scrollbar:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -2, -18) |
scrollbar:SetPoint("BOTTOMLEFT", panel, "BOTTOMRIGHT", -18, 18) |
scrollbar:SetMinMaxValues(1, math.ceil(panel:GetHeight()+1)) |
scrollbar:SetValueStep(1) |
scrollbar.scrollStep = 1 |
scrollbar:SetValue(0) |
scrollbar:SetWidth(16) |
scrollbar:SetScript("OnValueChanged", function (self, value) self:GetParent():SetVerticalScroll(value) self:SetValue(value) end) |
scrollbar:SetBackdrop({bgFile = media.flat}) |
scrollbar:SetBackdropColor(0,0,0,.2) |
panel.scrollbar = scrollbar |
--content frame |
panel.content = CreateFrame("Frame", nil, scrollframe) |
panel.content:SetSize(panel:GetWidth()-40, panel:GetHeight()-20) |
scrollframe.content = panel.content |
scrollframe:SetScrollChild(panel.content) |
--[[panel.text = panel:CreateFontString(nil) |
panel.text:SetFont(media.font, 14) |
panel.text:SetText(name) |
panel.text:SetPoint("TOPLEFT", panel, "TOPLEFT", 10, 24)--]] |
panel:SetScript("OnMouseWheel", function(self, delta) |
self.scrollbar:SetValue(self.scrollbar:GetValue() - (delta*20)) |
end) |
cfg.options[name] = frame |
cfg.panels[name] = panel |
if (configs) then |
local scrollheight = 0 |
for i = 1, #configs do |
local conf = configs[i] |
c[name] = c[name] or {} |
c.sv[name] = c.sv[name] or {} |
for option, info in pairs(conf) do |
if (not c.sv[name][option] == nil) then |
c[name] = c[name] or {} |
c.sv[name][option] = info['value'] |
end |
if (info.type == "slider") then |
bdCore:createSlider(name, option, info) |
scrollheight = scrollheight + 68 |
elseif (info.type == "checkbox") then |
bdCore:createCheckButton(name, option, info) |
scrollheight = scrollheight + 50 |
elseif (info.type == "dropdown") then |
bdCore:createDropdown(name, option, info) |
scrollheight = scrollheight + 70 |
elseif (info.type == "text") then |
bdCore:createText(name, info) |
scrollheight = scrollheight + 50 + ((strlen(info.value)/39)*12) |
elseif (info.type == "list") then |
bdCore:createList(name, option, info) |
scrollheight = scrollheight + 250 |
end |
smartconf[option] = c[name][option] |
end |
end |
scrollheight = scrollheight - 320 |
if (scrollheight < 1) then |
scrollheight = 1 |
panel.scrollbar:Hide() |
else |
panel.scrollbar:Show() |
end |
panel.scrollbar:SetMinMaxValues(1, scrollheight) |
panel.content:SetHeight(scrollheight+320) |
end |
collectgarbage() |
return smartconf |
end |
-------------------------------------------------- |
-- functions here |
-------------------------------------------------- |
function bdCore:createText(group, info) |
local panel = cfg.config[group].content |
local text = panel:CreateFontString(nil) |
text:SetFont(media.font, 14) |
text:SetText(info.value) |
text:SetTextColor(0.8,0.8,0.8) |
text:SetWidth(panel:GetWidth()-10) |
text:SetJustifyH("LEFT") |
if (not panel.lastFrame) then |
text:SetPoint("TOPLEFT", panel, "TOPLEFT", 6, 0) |
else |
text:SetPoint("TOPLEFT", panel.lastFrame, "BOTTOMLEFT", 0, -50) |
end |
panel.lastFrame = text |
return text |
end |
function bdCore:createList(group,option,info) |
local panel = cfg.config[group].content |
local container = CreateFrame("frame",nil,panel) |
container:SetSize(210,200) |
bdCore:setBackdrop(container) |
container.background:SetBackdropColor(.18,.22,.25,1) |
if (not panel.lastFrame) then |
container:SetPoint("TOPLEFT", panel, "TOPLEFT", 10, -30) |
else |
container:SetPoint("TOPLEFT", panel.lastFrame, "BOTTOMLEFT", 0, -70) |
end |
panel.lastFrame = container |
--scrollframe |
local scrollframe = CreateFrame("ScrollFrame", nil, container) |
scrollframe:SetPoint("TOPRIGHT", container, "TOPRIGHT", 0, -6) |
scrollframe:SetSize(container:GetWidth(), container:GetHeight()-12) |
container.scrollframe = scrollframe |
--scrollbar |
local scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate") |
scrollbar:SetPoint("TOPRIGHT", container, "TOPRIGHT", -2, -18) |
scrollbar:SetPoint("BOTTOMLEFT", container, "BOTTOMRIGHT", -18, 18) |
scrollbar:SetMinMaxValues(1, 600) |
scrollbar:SetValueStep(1) |
scrollbar.scrollStep = 1 |
scrollbar:SetValue(0) |
scrollbar:SetWidth(16) |
scrollbar:SetScript("OnValueChanged", function (self, value) self:GetParent():SetVerticalScroll(value) self:SetValue(value) end) |
scrollbar:SetBackdrop({bgFile = media.flat}) |
scrollbar:SetBackdropColor(0,0,0,.2) |
container.scrollbar = scrollbar |
--content frame |
container.content = CreateFrame("Frame", nil, scrollframe) |
container.content:SetSize(container:GetWidth(), container:GetHeight()) |
scrollframe.content = container.content |
scrollframe:SetScrollChild(container.content) |
container.content.text = container.content:CreateFontString(nil) |
container.content.text:SetFont(media.font,12) |
container.content.text:SetPoint("TOPLEFT",container.content,"TOPLEFT",5,0) |
container.content.text:SetHeight(600) |
container.content.text:SetWidth(container:GetWidth()-10) |
container.content.text:SetJustifyH("LEFT") |
container.content.text:SetJustifyV("TOP") |
container.insert = CreateFrame("EditBox",nil,container) |
container.insert:SetPoint("BOTTOMLEFT", container, "TOPLEFT",0,2) |
container.insert:SetSize(144, 24) |
bdCore:setBackdrop(container.insert) |
container.insert.background:SetBackdropColor(.10,.14,.17,1) |
container.insert:SetFont(media.font,12) |
container.insert:SetTextInsets(6, 2, 2, 2) |
container.insert:SetMaxLetters(200) |
container.insert:SetHistoryLines(1000) |
container.insert:SetAutoFocus(false) |
container.insert:SetScript("OnEnterPressed", function(self, key) container.button:Click() end) |
container.insert:SetScript("OnEscapePressed", function(self, key) self:ClearFocus() end) |
-- submit |
container.button = CreateFrame("Button", nil, container) |
container.button:SetPoint("TOPLEFT", container.insert, "TOPRIGHT", 0 ,2) |
container.button:SetSize(68, 28) |
container.button:SetBackdrop({ |
bgFile = bdCore.media.flat, |
edgeFile = bdCore.media.flat, edgeSize = 2, |
insets = { left = 2, right = 2, top = 2, bottom = 2 } |
}) |
container.button:SetBackdropColor(unpack(media.blue)) |
container.button:SetBackdropBorderColor(unpack(media.border)) |
container.button:SetAlpha(0.8) |
container.button:EnableMouse(true) |
container.button:SetScript("OnEnter", function() |
container.button:SetAlpha(1) |
end) |
container.button:SetScript("OnLeave", function() |
container.button:SetAlpha(0.8) |
end) |
container.button:SetScript("OnClick", function() |
local value = container.insert:GetText() |
if (strlen(value) > 0) then |
container.addremove(container.insert:GetText()) |
end |
container.insert:SetText("") |
container.insert:ClearFocus() |
end) |
container.button.x = container.button:CreateFontString(nil) |
container.button.x:SetFont(media.font, 12) |
container.button.x:SetText("Add/Remove") |
container.button.x:SetPoint("CENTER", container.button, "CENTER", 1, 0) |
container.label = container:CreateFontString(nil) |
container.label:SetFont(media.font, 14) |
container.label:SetPoint("BOTTOMLEFT", container.insert, "TOPLEFT", 0, 4) |
container.label:SetText(info.label) |
function container.populate() |
local string = ""; |
local height = 0; |
for k, v in pairs(c.sv[group][option]) do |
string = string..k.."\n"; |
height = height + 14 |
container.insert:AddHistoryLine(k) |
end |
local scrollheight = height-200 |
if (scrollheight < 1) then |
scrollheight = 1 |
container.scrollbar:Hide() |
else |
container.scrollbar:Show() |
container:SetScript("OnMouseWheel", function(self, delta) self.scrollbar:SetValue(self.scrollbar:GetValue() - (delta*30)) end) |
end |
container.scrollbar:SetMinMaxValues(1,scrollheight) |
container.content.text:SetHeight(height) |
container.content.text:SetText(string) |
end |
function container.addremove(value) |
container.insert:AddHistoryLine(value) |
if(c.sv[group][option][value]) then |
c[group][option][value] = nil |
c.sv[group][option][value] = nil |
else |
c[group][option][value] = true |
c.sv[group][option][value] = true |
end |
container.populate() |
end |
container.populate() |
if (info.callback) then |
info:callback() |
end |
end |
function bdCore:createDropdown(group, option, info) |
local panel = cfg.config[group].content |
--local items = {strsplit(",",info.options)} |
local items = info.options |
local container = CreateFrame("Button", "bdCore_"..info.label, panel) |
local dropdown = CreateFrame("Frame", "bdCore_"..info.label, panel) |
container:SetWidth(200) |
container:SetHeight(20) |
bdCore:setBackdrop(container) |
if (not panel.lastFrame) then |
container:SetPoint("TOPLEFT", panel, "TOPLEFT", 10, -30) |
else |
container:SetPoint("TOPLEFT", panel.lastFrame, "BOTTOMLEFT", 0, -50) |
end |
panel.lastFrame = container |
container.arrow = container:CreateTexture(nil,"OVERLAY") |
container.arrow:SetTexture(media.arrowdown) |
container.arrow:SetSize(8, 6) |
container.arrow:SetVertexColor(1,1,1,.4) |
container.arrow:SetPoint("RIGHT", container, "RIGHT", -6, 1) |
container.arrow:Show() |
container.label = container:CreateFontString(nil) |
container.label:SetFont(media.font, 14) |
container.label:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 0, 4) |
container.label:SetText(info.label) |
container.selected = container:CreateFontString(nil) |
container.selected:SetFont(media.font, 13) |
container.selected:SetPoint("LEFT", container, "LEFT", 6, 0) |
container.selected:SetText(c.sv[group][option]) |
function container:click() |
if (dropdown.dropped) then |
dropdown:Hide() |
dropdown.dropped = false |
container.background:SetBackdropColor(.11,.15,.18, 1) |
container.arrow:SetTexture(media.arrowdown) |
else |
dropdown:Show() |
dropdown.dropped = true |
container.background:SetBackdropColor(1,1,1,.05) |
container.arrow:SetTexture(media.arrowup) |
end |
end |
container:SetScript("OnClick", function() container:click()end) |
dropdown:Hide() |
dropdown:SetFrameLevel(10) |
dropdown:SetBackdrop({ |
bgFile = bdCore.media.flat, |
edgeFile = bdCore.media.flat, edgeSize = 2, |
insets = { left = 2, right = 2, top = 2, bottom = 2 } |
}) |
dropdown:SetBackdropColor(.18,.22,.25,1) |
dropdown:SetBackdropBorderColor(.06, .08, .09, 1) |
dropdown.dropped = false |
dropdown.lastframe = false |
dropdown:SetSize(container:GetWidth()+4, 22*#items) |
for i = 1, #items do |
local item = CreateFrame("Button", nil, dropdown) |
item:SetSize(dropdown:GetWidth()-4, 20) |
item:SetBackdrop({bgFile = bdCore.media.flat, }) |
item:SetBackdropColor(0,0,0,0) |
item:SetScript("OnEnter",function() item:SetBackdropColor(.21,.25,.29,1) end) |
item:SetScript("OnLeave",function() item:SetBackdropColor(0,0,0,0) end) |
item.label = item:CreateFontString(nil) |
item.label:SetFont(media.font, 13) |
item.label:SetPoint("LEFT", item, "LEFT", 6, 0) |
item.label:SetText(items[i]) |
item.id = i |
if (not dropdown.lastFrame) then |
item:SetPoint("TOPLEFT", dropdown, "TOPLEFT", 2, -2) |
else |
item:SetPoint("TOPLEFT", dropdown.lastFrame, "BOTTOMLEFT", 0, 0) |
end |
item:SetScript("OnClick", function(self) |
c[group][option] = self.label:GetText() |
c.sv[group][option] = self.label:GetText() |
if (info.callback) then |
info:callback() |
end |
container.selected:SetText(c.sv[group][option]) |
container:click() |
end) |
dropdown.lastFrame = item |
end |
dropdown:SetPoint("TOPLEFT", container, "BOTTOMLEFT", -2, 1) |
return dropdown |
end |
function bdCore:createSlider(group, option, info) |
local panel = cfg.config[group].content |
local slider = CreateFrame("Slider", "bdCore_"..option, panel, "OptionsSliderTemplate") |
slider:SetWidth(200) |
slider:SetHeight(14) |
if (not panel.lastFrame) then |
slider:SetPoint("TOPLEFT", panel, "TOPLEFT", 10, -20) |
else |
slider:SetPoint("TOPLEFT", panel.lastFrame, "BOTTOMLEFT", 0, -40) |
end |
panel.lastFrame = slider |
slider:SetOrientation('HORIZONTAL') |
slider:SetMinMaxValues(info.min,info.max) |
slider:SetValue(c.sv[group][option]) |
slider:SetObeyStepOnDrag(true) |
slider:SetValueStep(info.step) |
slider.tooltipText = info.tooltip |
_G[slider:GetName() .. 'Low']:SetText(info.min); |
_G[slider:GetName() .. 'Low']:SetTextColor(1,1,1); |
_G[slider:GetName() .. 'Low']:SetFont(media.font, 12) |
_G[slider:GetName() .. 'Low']:ClearAllPoints() |
_G[slider:GetName() .. 'Low']:SetPoint("TOP",slider,"BOTTOMLEFT",0,-1) |
_G[slider:GetName() .. 'High']:SetText(info.max); |
_G[slider:GetName() .. 'High']:SetTextColor(1,1,1); |
_G[slider:GetName() .. 'High']:SetFont(media.font, 12) |
_G[slider:GetName() .. 'High']:ClearAllPoints() |
_G[slider:GetName() .. 'High']:SetPoint("TOP",slider,"BOTTOMRIGHT",0,-1) |
_G[slider:GetName() .. 'Text']:SetText(info.label); |
_G[slider:GetName() .. 'Text']:SetTextColor(1,1,1); |
_G[slider:GetName() .. 'Text']:SetFont(media.font, 14) |
slider.value = slider:CreateFontString(nil) |
slider.value:SetFont(media.font, 12) |
slider.value:SetText(c.sv[group][option]) |
slider.value:SetTextColor(1,1,1) |
slider.value:SetPoint("TOP", slider,"BOTTOM", 0, -2) |
slider:Show() |
slider:SetScript("OnValueChanged", function(self) |
local newval = round(slider:GetValue(), 1) |
if (c.sv[group][option] == newval) then -- throttle it changing on every pixel |
return false |
end |
slider:SetValue(newval) |
slider.value:SetText(newval) |
c[group][option] = newval |
c.sv[group][option] = newval |
if (info.callback) then |
info:callback() |
end |
end) |
return slider |
end |
function bdCore:createCheckButton(group, option, info) |
local panel = cfg.config[group].content |
local check = CreateFrame("CheckButton", "bdCore_"..option, panel, "ChatConfigCheckButtonTemplate") |
if (not panel.lastFrame) then |
check:SetPoint("TOPLEFT", panel, "TOPLEFT", 0, 0) |
else |
check:SetPoint("TOPLEFT", panel.lastFrame, "BOTTOMLEFT", 0, -30) |
end |
panel.lastFrame = check |
_G[check:GetName().."Text"]:SetText(info.label) |
_G[check:GetName().."Text"]:SetFont(bdCore.media.font, 14) |
_G[check:GetName().."Text"]:ClearAllPoints() |
_G[check:GetName().."Text"]:SetPoint("LEFT", check, "RIGHT", 2, 1) |
check.tooltip = info.tooltip; |
check:SetChecked(c.sv[group][option]) |
check:SetScript("OnClick", function(self) |
c[group][option] = self:GetChecked() |
c.sv[group][option] = self:GetChecked() |
if (info.callback) then |
info:callback(check) |
end |
end) |
return check |
end |
f.config = cfg |
local bdCore, c, f = select(2, ...):unpack() |
RAID_CLASS_COLORS = { |
["HUNTER"] = { r = 0.67, g = 0.83, b = 0.45, colorStr = "ffabd473" }, |
["WARLOCK"] = { r = 0.58, g = 0.51, b = 0.79, colorStr = "ff9482c9" }, |
["PRIEST"] = { r = 1.0, g = 1.0, b = 1.0, colorStr = "ffffffff" }, |
["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73, colorStr = "fff58cba" }, |
["MAGE"] = { r = 0.41, g = 0.8, b = 0.94, colorStr = "ff69ccf0" }, |
["ROGUE"] = { r = 1.0, g = 0.96, b = 0.41, colorStr = "fffff569" }, |
["DRUID"] = { r = 1.0, g = 0.49, b = 0.04, colorStr = "ffff7d0a" }, |
["SHAMAN"] = { r = 0.0, g = 0.44, b = 0.87, colorStr = "ff0070de" }, |
["WARRIOR"] = { r = 0.78, g = 0.61, b = 0.43, colorStr = "ffc79c6e" }, |
["DEATHKNIGHT"] = { r = 0.77, g = 0.12 , b = 0.23, colorStr = "ffc41f3b" }, |
["MONK"] = { r = 0.0, g = 1.00 , b = 0.59, colorStr = "ff00ff96" }, |
}; |
bdCore.media = { |
flat = "Interface\\Buttons\\WHITE8x8", |
font = "Interface\\Addons\\bdCore\\media\\font.ttf", |
arrow = "Interface\\Addons\\bdCore\\media\\arrow.blp", |
arrowup = "Interface\\Addons\\bdCore\\media\\arrowup.blp", |
arrowdown = "Interface\\Addons\\bdCore\\media\\arrowdown.blp", |
shadow = "Interface\\Addons\\bdCore\\media\\shadow.blp", |
border = {.06, .08, .09, 1}, |
backdrop = {.11,.15,.18, 1}, |
red = {.62,.17,.18,1}, |
blue = {.2, .4, 0.8, 1}, |
green = {.1, .7, 0.3, 1}, |
} |
bdCore.whitelistconfig = { |
[1] = {intro = { |
type = "text", |
value = "Add auras to the whitelist to have them tracked. i.e. Add a boss debuff to have it show on the raid frames.", |
}}, |
[2] = {whitelist = { |
type = "list", |
value = bdCore.auras.whitelist, |
label = "Whitelisted Auras", |
}}, |
} |
bdCore.blacklistconfig = { |
[1] = {intro = { |
type = "text", |
value = "Add auras to the blacklist to have them hidden whenever possible, such as buffs or debuffs that you don't need to track.", |
}}, |
[2] = {blacklist = { |
type = "list", |
value = bdCore.auras.blacklist, |
label = "Blacklisted Auras", |
}}, |
} |
bdCore.personalconfig = { |
[1] = {intro = { |
type = "text", |
value = "Personal auras will only show when they are cast by you, and class auras will only show when you're this class.", |
}}, |
[2] = {mine = { |
type = "list", |
value = bdCore.auras.mine, |
label = "Auras Cast by Me", |
}}, |
[3] = {[bdCore.class] = { |
type = "list", |
value = bdCore.auras.player_class[bdCore.class], |
label = 'All '..bdCore.class.." Auras", |
}}, |
} |
-- modules defaults |
local addon, engine = ... |
engine[1] = CreateFrame("Frame", nil, UIParent) |
engine[2] = {} |
engine[3] = {} |
engine[1]:RegisterEvent("ADDON_LOADED") |
engine[1].class = string.lower(select(1, UnitClass('player'))) |
local roleupdate = CreateFrame("frame",nil) |
roleupdate:RegisterEvent("LFG_ROLE_UPDATE") |
roleupdate:RegisterEvent("PLAYER_ROLES_ASSIGNED") |
roleupdate:RegisterEvent("ROLE_CHANGED_INFORM") |
roleupdate:RegisterEvent("PVP_ROLE_UPDATE") |
roleupdate:SetScript("OnEvent", function(self, event, arg) |
local spec_id = GetSpecialization() |
if (spec_id) then |
engine[1].spec = string.lower(select(2,GetSpecializationInfo(spec_id))) |
engine[1].role = string.lower(select(6,GetSpecializationInfo(spec_id))) |
end |
end) |
function engine:unpack() |
return self[1], self[2], self[3] |
end |
bdCore = engine[1] |
bdCore.colorString = '|cffA02C2Fbd|r' |
bdCore.config = engine[2] |
bdCore.frames = engine[3] |
bdCore.mult = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)") |
--UIParent:SetScale(bdCore.mult) |
SetCVar("useUiScale",1) |
SetCVar("uiScale",bdCore.mult) |
local bdCore, c, f = select(2, ...):unpack() |
bdCore.moving = false |
bdCore.moveFrames = {} |
-- add to our movable list |
function bdCore:makeMovable(frame,resize) |
if not resize then resize = true end |
local name = frame:GetName(); |
local height = frame:GetHeight() |
local width = frame:GetWidth() |
local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint() |
local moveContainer = CreateFrame("frame", "bdCore_"..name, UIParent) |
moveContainer.text = moveContainer:CreateFontString(moveContainer:GetName().."_Text") |
moveContainer.frame = frame |
frame.moveContainer = moveContainer |
if (resize) then |
hooksecurefunc(frame,"SetSize",function() |
local height = frame:GetHeight() |
local width = frame:GetWidth() |
moveContainer:SetSize(width+4, height+4) |
end) |
end |
moveContainer:SetSize(width+4, height+4) |
moveContainer:SetBackdrop({bgFile = bdCore.media.flat}) |
moveContainer:SetBackdropColor(0,0,0,.6) |
moveContainer:SetMovable(true) |
moveContainer:SetFrameStrata("BACKGROUND") |
moveContainer:SetClampedToScreen(true) |
moveContainer:SetAlpha(0) |
bdCore:hookEvent("frames_resized", function() |
local height = frame:GetHeight() |
local width = frame:GetWidth() |
moveContainer:SetSize(width+4, height+4) |
end) |
function moveContainer.dragStop(self) |
self:StopMovingOrSizing() |
c.sv.positions[self.frame:GetName()] = {self:GetPoint()} |
end |
frame:ClearAllPoints() |
frame:SetPoint("TOPRIGHT", moveContainer, "TOPRIGHT", -2, -2) |
moveContainer.text:SetFont(bdCore.media.font, 16) |
moveContainer.text:SetPoint("CENTER", moveContainer, "CENTER", 0, 0) |
moveContainer.text:SetText(name) |
moveContainer.text:SetJustifyH("CENTER") |
moveContainer.text:SetAlpha(0.8) |
moveContainer.text:Hide() |
if (c.sv.positions[name]) then |
moveContainer:SetPoint(unpack(c.sv.positions[name])) |
else |
moveContainer:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs) |
end |
bdCore.moveFrames[#bdCore.moveFrames+1] = moveContainer |
return moveContainer |
end |
function bdCore:toggleLock() |
if (bdCore.moving == true) then |
bdCore.moving = false |
print(bdCore.colorString.."Core: Addons locked") |
else |
bdCore.moving = true |
print(bdCore.colorString.."Core: Addons unlocked") |
end |
bdCore:triggerEvent("bd_toggle_lock") |
for k, v in pairs(bdCore.moveFrames) do |
local frame = v |
if (bdCore.moving) then |
frame:SetAlpha(1) |
frame.text:Show() |
frame:EnableMouse(true) |
frame:RegisterForDrag("LeftButton","RightButton") |
frame:SetScript("OnDragStart", function(self) self:StartMoving() end) |
frame:SetScript("OnDragStop", function(self) self:dragStop(self) end) |
frame:SetFrameStrata("TOOLTIP") |
elseif (not bdCore.moving) then |
frame:SetAlpha(0) |
frame.text:Hide() |
frame:EnableMouse(false) |
frame:SetScript("OnDragStart", function(self) self:StopMovingOrSizing() end) |
frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) |
frame:SetFrameStrata("BACKGROUND") |
end |
end |
end |
-- custom events/hooks |
bdCore.events = {} |
function bdCore:hookEvent(event, func) |
if (not bdCore.events[event]) then |
bdCore.events[event] = {} |
end |
bdCore.events[event][#bdCore.events[event]+1] = func |
end |
function bdCore:triggerEvent(event,...) |
if (bdCore.events[event]) then |
for k, v in pairs(bdCore.events[event]) do |
v(...) |
end |
end |
end |
-- |
function bdCore:colorGradient(perc) |
if perc > 1 then perc = 1 end |
local segment, realperc = math.modf(perc*2) |
r1, g1, b1, r2, g2, b2 = unpack({1, 0, 0,1, 1, 0,0, 1, 0,0, 0, 0}, (segment * 3) + 1) |
return r1 + (r2-r1)*realperc, g1 + (g2-g1)*realperc, b1 + (b2-b1)*realperc |
end |
-- return class color |
function bdCore:unitColor(unitToken) |
if not UnitExists(unitToken) then |
return unpack(bUI.media.unitColors.tapped) |
end |
if UnitIsPlayer(unitToken) then |
return unpack(bUI.media.unitColors.class[select(2, UnitClass(unitToken))]) |
elseif UnitIsTapped(unitToken) and not UnitIsTappedByPlayer(unitToken) then |
return unpack(bUI.media.unitColors.tapped) |
else |
return unpack(bUI.media.unitColors.reaction[UnitReaction(unitToken, 'player')]) |
end |
end |
-- xform r, g, b into rrggbb |
function bdCore:RGBToHex(r, g, b) |
if type(r) ~= 'number' then |
g = r.g |
b = r.b |
r = r.r |
end |
r = r <= 1 and r >= 0 and r or 0 |
g = g <= 1 and g >= 0 and g or 0 |
b = b <= 1 and b >= 0 and b or 0 |
return string.format('%02x%02x%02x', r*255, g*255, b*255) |
end |
-- make it purdy |
function bdCore:setBackdrop(frame) |
if (frame.background) then return false end |
frame.background = CreateFrame('frame', nil, frame) |
frame.background:SetBackdrop({ |
bgFile = bdCore.media.flat, |
edgeFile = bdCore.media.flat, edgeSize = 2, |
insets = { left = 2, right = 2, top = 2, bottom = 2 } |
}) |
frame.background:SetBackdropColor(.11,.15,.18, 1) |
frame.background:SetBackdropBorderColor(.06, .08, .09, 1) |
frame.background:SetPoint("TOPLEFT", frame, "TOPLEFT", -2, 2) |
frame.background:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 2, -2) |
frame.background:SetFrameStrata(frame:GetFrameStrata()) |
frame:SetFrameLevel(frame:GetFrameLevel()+1) |
frame.background:SetFrameLevel(frame:GetFrameLevel()-1) |
end |
function bdCore:createShadow(f,offset) |
if f.Shadow then return end |
local shadow = CreateFrame("Frame", nil, f) |
shadow:SetFrameLevel(1) |
shadow:SetFrameStrata(f:GetFrameStrata()) |
shadow:SetPoint("TOPLEFT", -offset, offset) |
shadow:SetPoint("BOTTOMLEFT", -offset, -offset) |
shadow:SetPoint("TOPRIGHT", offset, offset) |
shadow:SetPoint("BOTTOMRIGHT", offset, -offset) |
shadow:SetAlpha(0.7) |
shadow:SetBackdrop( { |
edgeFile = bdCore.media.shadow, edgeSize = offset, |
insets = {left = offset, right = offset, top = offset, bottom = offset}, |
}) |
shadow:SetBackdropColor(0, 0, 0, 0) |
shadow:SetBackdropBorderColor(0, 0, 0, 0.8) |
f.Shadow = shadow |
end |
-- also comma values |
function comma_value(amount) |
local formatted = amount |
while true do |
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') |
if (k==0) then |
break |
end |
end |
return formatted |
end |
-- not crazy about the built in split function |
function split(str, del) |
local t = {} |
local index = 0; |
while (string.find(str, del)) do |
local s, e = string.find(str, del) |
t[index] = string.sub(str, 1, s-1) |
str = string.sub(str, s+#del) |
index = index + 1; |
end |
table.insert(t, str) |
return t; |
end |
-- lua doesn't have a good function for round |
function round(num, idp) |
local mult = 10^(idp or 0) |
return math.floor(num * mult + 0.5) / mult |
end |
-- lua doesn't have a good function for finding a value in a table |
function in_table ( e, t ) |
for _,v in pairs(t) do |
if (v==e) then return true end |
end |
return false |
end |
-- kill textures |
--[[ |
function bdCore:stripTextures(object, text) |
for i = 1, object:GetNumRegions() do |
local region = select(i, object:GetRegions()) |
if region:GetObjectType() == "Texture" then |
region:SetTexture(nil) |
elseif (text) then |
region:Hide(0) |
region:SetAlpha(0) |
end |
end |
end |
-- kill frame |
function bdCore:kill(object) |
if object.UnregisterAllEvents then |
object:UnregisterAllEvents() |
end |
object.Show = function() return end |
object:Hide() |
object = nil |
end--]] |
-- set up slash commands |
function bdCore:setSlashCommand(name, func, ...) |
SlashCmdList[name] = func |
for i = 1, select('#', ...) do |
_G['SLASH_'..name..i] = '/'..select(i, ...) |
end |
end |
-- filter debuffs/buffs |
function bdCore:filterAura(name,caster) |
local blacklist = c.sv["Aura Blacklist"]["blacklist"] |
local whitelist = c.sv["Aura Whitelist"]["whitelist"] |
local mine = c.sv["Personal Auras"]["mine"] |
local class = c.sv["Personal Auras"][bdCore.class] |
-- raid variables are set in a file, they can be blacklisted though, and added to through whitelist |
local raid = bdCore.auras.raid |
local allow = false |
if (blacklist[name] == true) then |
allow = false |
elseif (whitelist[name] == true) then |
allow = true |
elseif (raid[name] == true) then |
allow = true |
elseif (mine[name] == true and caster == "player") then |
allow = true |
elseif (raid[name] == true) then |
allow = true |
elseif (class[name] == true) then |
allow = true |
end |
return allow |
end |
function bdCore:addOption(name, opts, var) |
local index = #var or 0 |
var[index] = var[index] or {} |
var[index][name] = opts |
return var |
end |
bdCore:setSlashCommand('ReloadUI', ReloadUI, 'rl', 'reset') |
SLASH_BDCORE1, SLASH_BDCORE2 = "/bdcore", '/bd' |
SlashCmdList["BDCORE"] = function(msg, editbox) |
if (msg == "" or msg == " ") then |
print(bdCore.colorString.." Options:") |
print(" /"..bdCore.colorString.." lock - unlocks/locks moving bd addons") |
print(" /"..bdCore.colorString.." config - opens the configuration for bd addons") |
print(" /"..bdCore.colorString.." reset - reset the saved settings account-wide (careful)") |
--print("-- /bui lock - locks the UI") |
elseif (msg == "unlock" or msg == "lock") then |
bdCore.toggleLock() |
elseif (msg == "reset") then |
bdCoreDataPerChar = nil |
for k, frame in pairs(bdCore.moveFrames) do |
frame:SetUserPlaced(false) |
end |
ReloadUI() |
elseif (msg == "config") then |
bdCore:toggleConfig() |
else |
print(bdCore.colorString.." "..msg.." not recognized as a command.") |
end |
end |
local bdCore, c, f = select(2, ...):unpack() |
local waiting = CreateFrame("frame",nil,bdCore) |
waiting.frames = {} |
waiting:RegisterEvent("PLAYER_LEAVE_COMBAT") |
waiting:SetScript("OnEvent", function() |
for key, pack in pairs(waiting.frames) do |
local func, params = unpack(pack) |
func(params) |
waiting.frames[key] = nil |
end |
end) |
local function Size(frame, ...) |
if (not InCombatLockdown()) then |
frame:SetSize(...) |
else |
waiting.frames[frame] = {function(...) Size(...) end, frame, ...} |
end |
end |
local function Width(frame, ...) |
if (not InCombatLockdown()) then |
frame:SetWidth(...) |
else |
waiting.frames[frame] = {function(...) Width(...) end, frame, ...} |
end |
end |
local function Height(frame, ...) |
if (not InCombatLockdown()) then |
frame:SetHeight(...) |
else |
waiting.frames[frame] = {function(...) Height(...) end, frame, ...} |
end |
end |
local function Kill(object) |
if object.UnregisterAllEvents then |
object:UnregisterAllEvents() |
end |
object.Show = function() return end |
object:Hide() |
end |
local function FrameStrata(frame, arg1) |
if (not InCombatLockdown()) then |
frame:SetFrameStrata(arg1) |
else |
waiting.frames[frame] = {function(...) FrameStrata(...) end, frame, arg1} |
end |
end |
local function FrameLevel(frame, arg1) |
if (not InCombatLockdown()) then |
frame:SetFrameLevel(arg1) |
else |
waiting.frames[frame] = {function(...) FrameLevel(...) end, frame, arg1} |
end |
end |
local function ClearPoints(frame) |
if (not InCombatLockdown()) then |
frame:ClearAllPoints() |
else |
waiting.frames[frame] = {function() ClearPoints() end, frame} |
end |
end |
local function Point(frame, ...) |
if (not InCombatLockdown()) then |
frame:SetPoint(...) |
else |
waiting.frames[frame] = {function(...) Point(...) end, frame, ...} |
end |
end |
local function AllPoints(frame, ...) |
if (not InCombatLockdown()) then |
frame:ClearAllPoints() |
frame:SetAllPoints(...) |
else |
waiting.frames[frame] = {function(...) AllPoints(...) end, frame, ...} |
end |
end |
local function StripTextures(Object, Kill, Text) |
for i=1, Object:GetNumRegions() do |
local Region = select(i, Object:GetRegions()) |
if Region:GetObjectType() == "Texture" then |
if Kill then |
Region:Kill() |
else |
Region:SetTexture(nil) |
end |
end |
end |
end |
local function SkinButton(Frame, Strip) |
if Frame:GetName() then |
local Left = _G[Frame:GetName().."Left"] |
local Middle = _G[Frame:GetName().."Middle"] |
local Right = _G[Frame:GetName().."Right"] |
if Left then Left:SetAlpha(0) end |
if Middle then Middle:SetAlpha(0) end |
if Right then Right:SetAlpha(0) end |
end |
if Frame.Left then Frame.Left:SetAlpha(0) end |
if Frame.Right then Frame.Right:SetAlpha(0) end |
if Frame.Middle then Frame.Middle:SetAlpha(0) end |
if Frame.SetNormalTexture then Frame:SetNormalTexture("") end |
if Frame.SetHighlightTexture then Frame:SetHighlightTexture("") end |
if Frame.SetPushedTexture then Frame:SetPushedTexture("") end |
if Frame.SetDisabledTexture then Frame:SetDisabledTexture("") end |
if Strip then StripTextures(Frame) end |
--Frame:SetTemplate() |
Frame:HookScript("OnEnter", function(self) |
local Color = RAID_CLASS_COLORS[select(2, UnitClass("player"))] |
self:SetBackdropColor(Color.r * .15, Color.g * .15, Color.b * .15) |
self:SetBackdropBorderColor(Color.r, Color.g, Color.b) |
end) |
Frame:HookScript("OnLeave", function(self) |
local Color = RAID_CLASS_COLORS[select(2, UnitClass("player"))] |
self:SetBackdropColor(unpack(bdCore.media.backdrop)) |
self:SetBackdropBorderColor(unpack(bdCore.media.border)) |
end) |
end |
--------------------------------------------------- |
-- Full credits to TukUI - merge functions into wow api |
--------------------------------------------------- |
local function AddAPI(object) |
local mt = getmetatable(object).__index |
if not object.Size then mt.Size = Size end |
if not object.Width then mt.Width = Width end |
if not object.Height then mt.Height = Height end |
if not object.Kill then mt.Kill = Kill end |
if not object.FrameStrata then mt.FrameStrata = FrameStrata end |
if not object.FrameLevel then mt.FrameLevel = FrameLevel end |
if not object.StripTextures then mt.StripTextures = StripTextures end |
if not object.StyleButton then mt.StyleButton = StyleButton end |
if not object.Point then mt.Point = Point end |
if not object.AllPoints then mt.AllPoints = AllPoints end |
if not object.ClearPoints then mt.ClearPoints = ClearPoints end |
--[[ |
if not object.SetOutside then mt.SetOutside = SetOutside end |
if not object.SetInside then mt.SetInside = SetInside end |
if not object.SetTemplate then mt.SetTemplate = SetTemplate end |
if not object.CreateBackdrop then mt.CreateBackdrop = CreateBackdrop end |
if not object.CreateShadow then mt.CreateShadow = CreateShadow end |
if not object.FontString then mt.FontString = FontString end |
if not object.HighlightUnit then mt.HighlightUnit = HighlightUnit end |
if not object.HideInsets then mt.HideInsets = HideInsets end |
if not object.SkinEditBox then mt.SkinEditBox = SkinEditBox end |
if not object.SkinButton then mt.SkinButton = SkinButton end |
if not object.SkinCloseButton then mt.SkinCloseButton = SkinCloseButton end |
if not object.SkinArrowButton then mt.SkinArrowButton = SkinArrowButton end |
if not object.SkinDropDown then mt.SkinDropDown = SkinDropDown end |
if not object.SkinCheckBox then mt.SkinCheckBox = SkinCheckBox end |
if not object.SkinTab then mt.SkinTab = SkinTab end |
if not object.SkinScrollBar then mt.SkinScrollBar = SkinScrollBar end--]] |
end |
local Handled = {["Frame"] = true} |
local Object = CreateFrame("Frame") |
AddAPI(Object) |
AddAPI(Object:CreateTexture()) |
AddAPI(Object:CreateFontString()) |
Object = EnumerateFrames() |
while Object do |
if not Object:IsForbidden() and not Handled[Object:GetObjectType()] then |
AddAPI(Object) |
Handled[Object:GetObjectType()] = true |
end |
Object = EnumerateFrames(Object) |
end |