/
Credits to zork (of Roth UI) for texture. |
]] |
local addon, Blessed = ... |
local pguid |
local locked = true |
-- defaults |
-- default position |
local defaults = { |
framePoint = "CENTER", |
xOfs = 0, |
yOfs = -150, |
locked = true, |
spells = { |
[1044] = { -- Hand of Freedom |
enabled = true, |
duration = 6, |
}, |
[1022] = { -- Hand of Protection |
enabled = true, |
duration = 10, |
}, |
[6940] = { -- Hand of Sacrifice |
enabled = true, |
duration = 12, |
}, |
[1038] = { -- Hand of Salvation |
enabled = true, |
duration = 10, |
}, |
[53563] = { -- Light's Beacon |
enabled = true, |
duration = 300, |
}, |
[54428] = { -- Divine Plea |
enabled = true, |
duration = 9, |
}, |
[53657] = { -- Judgement of the Pure (3/3) |
enabled = true, |
duration = 60, |
}, |
[20925] = { -- Holy Shield |
enabled = true, |
duration = 10, |
}, |
[84963] = { -- Inquisition |
enabled = true, |
duration = 12, |
}, |
[82327] = { -- Holy Radiance |
enabled = true, |
duration = 10, |
}, |
[88819] = { -- Daybreak |
enabled = false, |
duration = 12, |
}, |
[85433] = { -- Sacred Duty |
enabled = true, |
duration = 10, |
}, |
[94686] = { -- Crusader |
enabled = true, |
duration = 15, |
}, |
[54149] = { -- Infusion of Light |
enabled = true, |
duration = 15, |
}, |
} |
} |
local db |
-- cosmetics |
local iconSize = 36 |
local Blessed = CreateFrame("Frame", nil, UIParent) |
Blessed:RegisterEvent("ADDON_LOADED") |
Blessed:SetScript("OnEvent", function(self, event, ...) |
self[event](self, ...) |
end) |
-- Add a prefix |
local function Print(...) |
print("|cff00aaffBlessed:|r", ...) |
end |
-- Format: [spell] = (duration) |
local spells = { |
[1044] = 6, -- Hand of Freedom |
[1022] = 10, -- Hand of Protection |
[6940] = 12, -- Hand of Sacrifice |
[1038] = 10, -- Hand of Salvation |
[53563] = 300, -- Light's Beacon |
[54428] = 9, -- Divine Plea |
[53657] = 60, -- Judgement of the Pure (Rank 3, but who hasn't got 3/3 in this?) |
[20925] = 10, -- Holy Shield |
[84963] = 12, -- Inquisition |
[82327] = 10, -- Holy Radiance |
-- [88819] = 12, -- Daybreak |
[85433] = 10, -- Sacred Duty |
[94686] = 15, -- Crusader |
[54149] = 15, -- Infusion of Light |
} |
local INQUISITION = GetSpellInfo(84963) |
local colors = setmetatable({ |
DEATHKNIGHT = "c41e3a", |
local framePool = {} |
function Blessed:Init() |
local frame = self.frame |
frame:SetBackdrop({ |
self:SetBackdrop({ |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
insets = {top = 0, left = 0, bottom = 0, right = 0}, |
}) |
frame:SetBackdropColor(1, 1, 1, 0) |
self:SetBackdropColor(1, 1, 1, 0) |
frame:SetWidth(iconSize) |
frame:SetHeight(iconSize) |
frame:SetPoint(db.framePoint, db.xOfs, db.yOfs) |
self:SetWidth(iconSize) |
self:SetHeight(iconSize) |
self:SetPoint(db.framePoint, db.xOfs, db.yOfs) |
frame:SetMovable(true) |
self:SetMovable(true) |
frame:SetScript("OnMouseDown", function() |
if(IsShiftKeyDown() and not db.locked) then |
frame:ClearAllPoints() |
frame:StartMoving() |
self:SetScript("OnMouseDown", function() |
if(IsShiftKeyDown() and not locked) then |
self:ClearAllPoints() |
self:StartMoving() |
end |
end) |
frame:SetScript("OnMouseUp", function() |
frame:StopMovingOrSizing() |
db.framePoint, _, _, db.xOfs, db.yOfs = frame:GetPoint() |
self:SetScript("OnMouseUp", function() |
self:StopMovingOrSizing() |
db.framePoint, _, _, db.xOfs, db.yOfs = self:GetPoint() |
end) |
local text = frame:CreateFontString(nil, "OVERLAY") |
local text = self:CreateFontString(nil, "OVERLAY") |
text:SetFontObject(SystemFont_Shadow_Med1) |
text:SetPoint("TOP", frame, "TOP", 0, 16) |
text:SetPoint("TOP", self, "TOP", 0, 16) |
text:SetTextColor(1, 0.82, 0) |
frame.header = text |
self.header = text |
end |
function Blessed:ToggleLock() |
if db.locked then |
self.frame.header:SetText(addon) |
self.frame:SetBackdropColor(1, 1, 1, 0.25) |
else |
self.frame.header:SetText("") |
self.frame:SetBackdropColor(1, 1, 1, 0) |
end |
self.frame:EnableMouse(db.locked) |
db.locked = not db.locked |
end |
function Blessed:RestoreDefaultSpells() |
db.spells = {} |
function Blessed:ADDON_LOADED(name) |
if name ~= "Blessed" then return end |
self:UnregisterEvent("ADDON_LOADED") |
for k,v in pairs(defaults.spells) do |
db.spells[k] = v |
end |
Print("Spells have been reset to default.") |
end |
function Blessed:PLAYER_LOGIN() |
BlessedDB = BlessedDB or defaults |
db = BlessedDB |
if not db.spells then |
self:RestoreDefaultSpells() |
end |
-- Force lock on login |
if not db.locked then db.locked = true end |
local class = select(2, UnitClass("player")) |
if class == "PALADIN" then -- only do stuff if player is a paladin |
self:RegisterEvent("PLAYER_ENTERING_WORLD") |
SLASH_Blessed1 = "/blessed" |
SlashCmdList.Blessed = function(input) |
local input = string.lower(input) |
if (input == "lock") then |
self:ToggleLock() |
if (input == "test") then |
self:SetupIcon(54428, "Test Icon", pguid) |
Print("Showing test-timer.") |
elseif (input == "lock") then |
if locked then |
self.header:SetText("Blessed") |
self:SetBackdropColor(1, 1, 1, 0.25) |
Print("Unlocked. Press down SHIFT and drag the square to move.") |
else |
self.header:SetText("") |
self:SetBackdropColor(1, 1, 1, 0) |
Print("Locked.") |
end |
locked = not locked |
self:EnableMouse(not locked) |
elseif input == "size" then |
Print("Active frames:", #frames) |
Print("Pool:", #framePool) |
Print("Total:", #frames+#framePool) |
else |
InterfaceOptionsFrame_OpenToCategory(self.panel) |
Print("Incorrect or no command given. Please use '/blessed test' (display a test-timer) or '/blessed lock' (to toggle lock).") |
end |
end |
else |
self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") |
end |
-- Check talents for updates (Hand of Freedom) |
-- Check talents for updates |
function Blessed:UpdateDurations() |
if not db.spells[1044] or not db.spells[1044].enabled then return end |
-- Hand of Freedom |
local rank, maxRank = select(5, GetTalentInfo(3, 4)) |
if rank == maxRank then |
db.spells[1044].duration = 10 |
spells[1044] = 10 |
else |
db.spells[1044].duration = 6 |
spells[1044] = 6 |
end |
self:UnregisterEvent("PLAYER_ALIVE") |
end |
-- Handle stuff, plx |
function Blessed:COMBAT_LOG_EVENT_UNFILTERED(timestamp, combatEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlagsTwo, destGUID, destName, destFlags, destFlagsTwo, spellID, ...) |
if sourceGUID ~= pguid or not db.spells[spellID] or not db.spells[spellID].enabled then return end |
if sourceGUID ~= pguid or not spells[spellID] then return end |
if (combatEvent == "SPELL_AURA_REMOVED") then |
self:RemoveFrame(spellID, false) |
if i > 1 then |
frame:SetPoint("LEFT", frames[i - 1], "RIGHT", 15, 0) |
else |
frame:SetPoint("CENTER", self.frame, "CENTER") |
frame:SetPoint("CENTER", self, "CENTER") |
end |
end |
end |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:SetSize(iconSize, iconSize) |
frame:SetPoint("CENTER", self.frame) |
frame:SetPoint("CENTER", self) |
-- Icon |
frame.icon = frame:CreateTexture(nil, "ARTWORK") |
-- Cooldown-model (beta) |
frame.cd = CreateFrame("Cooldown", nil, frame, "CooldownFrameTemplate") |
-- frame.cd:SetSize(iconSize, iconSize) |
frame.cd:SetSize(iconSize, iconSize) |
frame.cd:SetPoint("TOPLEFT", frame, "TOPLEFT", 2, -2) |
frame.cd:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 2) |
frame.cd.noCooldownCount = true -- prevent OmniCC if present |
-- Setup a timer |
function Blessed:SetupIcon(spellID, targetName, targetGUID) |
local frame = self:GetFrame() |
local duration = db.spells[spellID].duration |
local duration = spells[spellID] |
if spellID == 84963 then |
duration = select(6, UnitAura("player", INQUISITION)) |
self:UpdateFrames() |
frame:Show() |
end |
Blessed.frame = CreateFrame("Frame", nil, UIParent) |
Blessed.frame:SetScript("OnEvent", function(self, event, ...) return Blessed[event] and Blessed[event](Blessed, ...) end) |
function Blessed:RegisterEvent(event) return self.frame:RegisterEvent(event) end |
function Blessed:UnregisterEvent(event) return self.frame:UnregisterEvent(event) end |
Blessed:RegisterEvent("PLAYER_LOGIN") |
## Version: 40200.1 |
## SavedVariables: BlessedDB |
Blessed.lua |
Options.lua |