/
--[[ |
Blessed Options |
by Ailae of Emeriss-EU |
]] |
local addon, Blessed = ... |
local db |
local title, desc = select(2, GetAddOnInfo(addon)) |
local f = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer) |
Blessed.panel = f |
f.name = title |
f:Hide() |
f:SetScript("OnShow", function(self) |
db = BlessedDB |
-- Header |
local header = self:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") |
header:SetPoint("TOPLEFT", 16, -16) |
header:SetText(title) |
-- Tagline |
local tag = self:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
tag:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -5) |
tag:SetText(desc) |
local function Checkers(name, text, tooltip, tooltipText) |
local check = CreateFrame("CheckButton", string.format("%s%sCheck", addon, name), f, "InterfaceOptionsCheckButtonTemplate") |
check.Text:SetText(text) |
check.tooltipText = tooltip |
check.tooltipRequirement = tooltipText |
return check |
end |
local lock = Checkers("Lock", "Lock", "Toggle lock", "Click to toggle lock. When unlocked, press down SHIFT and drag the square to position the frame. This setting will reset to toggled on login.") |
lock:SetPoint("TOPLEFT", tag, "BOTTOMLEFT", 0, -20) |
lock:SetChecked(db.locked) |
lock:SetScript("OnClick", function() |
Blessed:ToggleLock() |
end) |
local lockTip = lock:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
lockTip:SetPoint("TOPLEFT", lock, "BOTTOMLEFT", 0, -5) |
lockTip:SetText("Tip: It's also possible to toggle the lock via the |cffffffff/blessed lock|r slash-command.") |
local reset = CreateFrame("Button", string.format("%sReset", addon), f, "OptionsButtonTemplate") |
reset:SetText("Reset spells") |
reset:SetWidth(reset:GetTextWidth() * 2) |
reset:SetPoint("TOPLEFT", lockTip, "BOTTOMLEFT", 0, -5) |
local items = {} |
for k,v in pairs(db.spells) do |
local n = GetSpellInfo(k) |
local spell = Checkers(k, n, n, "Current duration is |cff00ff00" .. v.duration .. "|r seconds.") |
spell:SetPoint("TOPLEFT", reset, "BOTTOMLEFT", 0, -20 * (#items+1)) |
spell:SetChecked(v.enabled) |
spell:SetScript("OnClick", function() |
v.enabled = not v.enabled |
end) |
table.insert(items, spell) |
end |
self:SetScript("OnShow", nil) |
end) |
InterfaceOptions_AddCategory(f) |
Credits to zork (of Roth UI) for texture. |
]] |
local addon, Blessed = ... |
local pguid |
local locked = true |
-- default position |
-- defaults |
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() |
self:SetBackdrop({ |
local frame = self.frame |
frame:SetBackdrop({ |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
insets = {top = 0, left = 0, bottom = 0, right = 0}, |
}) |
self:SetBackdropColor(1, 1, 1, 0) |
frame:SetBackdropColor(1, 1, 1, 0) |
self:SetWidth(iconSize) |
self:SetHeight(iconSize) |
self:SetPoint(db.framePoint, db.xOfs, db.yOfs) |
frame:SetWidth(iconSize) |
frame:SetHeight(iconSize) |
frame:SetPoint(db.framePoint, db.xOfs, db.yOfs) |
self:SetMovable(true) |
frame:SetMovable(true) |
self:SetScript("OnMouseDown", function() |
if(IsShiftKeyDown() and not locked) then |
self:ClearAllPoints() |
self:StartMoving() |
frame:SetScript("OnMouseDown", function() |
if(IsShiftKeyDown() and not db.locked) then |
frame:ClearAllPoints() |
frame:StartMoving() |
end |
end) |
self:SetScript("OnMouseUp", function() |
self:StopMovingOrSizing() |
db.framePoint, _, _, db.xOfs, db.yOfs = self:GetPoint() |
frame:SetScript("OnMouseUp", function() |
frame:StopMovingOrSizing() |
db.framePoint, _, _, db.xOfs, db.yOfs = frame:GetPoint() |
end) |
local text = self:CreateFontString(nil, "OVERLAY") |
local text = frame:CreateFontString(nil, "OVERLAY") |
text:SetFontObject(SystemFont_Shadow_Med1) |
text:SetPoint("TOP", self, "TOP", 0, 16) |
text:SetPoint("TOP", frame, "TOP", 0, 16) |
text:SetTextColor(1, 0.82, 0) |
self.header = text |
frame.header = text |
end |
function Blessed:ADDON_LOADED(name) |
if name ~= "Blessed" then return end |
self:UnregisterEvent("ADDON_LOADED") |
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 = {} |
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 == "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) |
if (input == "lock") then |
self:ToggleLock() |
else |
Print("Incorrect or no command given. Please use '/blessed test' (display a test-timer) or '/blessed lock' (to toggle lock).") |
InterfaceOptionsFrame_OpenToCategory(self.panel) |
end |
end |
else |
self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") |
end |
-- Check talents for updates |
-- Check talents for updates (Hand of Freedom) |
function Blessed:UpdateDurations() |
-- Hand of Freedom |
if not db.spells[1044] or not db.spells[1044].enabled then return end |
local rank, maxRank = select(5, GetTalentInfo(3, 4)) |
if rank == maxRank then |
spells[1044] = 10 |
db.spells[1044].duration = 10 |
else |
spells[1044] = 6 |
db.spells[1044].duration = 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 spells[spellID] then return end |
if sourceGUID ~= pguid or not db.spells[spellID] or not db.spells[spellID].enabled 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, "CENTER") |
frame:SetPoint("CENTER", self.frame, "CENTER") |
end |
end |
end |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:SetSize(iconSize, iconSize) |
frame:SetPoint("CENTER", self) |
frame:SetPoint("CENTER", self.frame) |
-- 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 = spells[spellID] |
local duration = db.spells[spellID].duration |
if spellID == 84963 then |
duration = select(6, UnitAura("player", INQUISITION)) |
self:UpdateFrames() |
frame:Show() |
end |
## Version: 40200.1 |
## SavedVariables: BlessedDB |
Blessed.lua |