Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HolyPowerIndicator = LibStub("AceAddon-3.0"):NewAddon("HolyPowerIndicator", "AceConsole-3.0", "AceEvent-3.0")
- local options = {
- name = "HolyPowerIndicator",
- handler = HolyPowerIndicator,
- type ="group",
- args = {
- locked = {
- type = "toggle",
- name = "Lock",
- desc = "Locks the Holy Power frame.",
- descStyle = "inline",
- width = "full",
- order = 1,
- get = "GetLocked",
- set = "SetLocked",
- },
- alpha = {
- type = "range",
- name = "Alpha",
- desc = "Set the frame's alpha.",
- descStyle = "inline",
- width = "full",
- min = 0.1,
- max = 1,
- step = 0.1,
- order = 2,
- get = "GetAlpha",
- set = "SetAlpha",
- },
- scale = {
- type = "range",
- name = "Scale",
- desc = "Set the frame's scale.",
- descStyle = "inline",
- width = "full",
- min = 0.5,
- max = 5,
- step = 0.5,
- order = 3,
- get = "GetScale",
- set = "SetScale",
- },
- textureSelect = {
- type = "select",
- name = "Texture",
- desc = "Select the texture.",
- descStyle = "inline",
- width = "full",
- values = {
- ["1-Number"] = "Interface\\AddOns\\HolyPowerIndicator\\Number\\",
- ["2-Alliance"] = "Interface\\AddOns\\HolyPowerIndicator\\Alliance\\",
- ["3-Horde"] = "Interface\\AddOns\\HolyPowerIndicator\\Horde\\",
- ["4-Dot"] = "Interface\\AddOns\\HolyPowerIndicator\\Dot\\",
- ["5-Coins"] = "Interface\\AddOns\\HolyPowerIndicator\\Coins\\",
- ["6-Bar"] = "Interface\\AddOns\\HolyPowerIndicator\\Bar\\",
- ["7-PvPRank"] = "Interface\\AddOns\\HolyPowerIndicator\\PvPRank\\",
- ["8-TukBar"] = "Interface\\AddOns\\HolyPowerIndicator\\TukBar\\",
- },
- style = "dropdown",
- get = "GetTexture",
- set= "SetTexture",
- },
- },
- }
- local defaults = {
- profile = {
- locked = true,
- alpha = 1,
- scale = 1,
- textureSelect = "Interface\\AddOns\\HolyPowerIndicator\\TukBar\\",
- },
- }
- function HolyPowerIndicator:OnInitialize()
- -- Called when the addon is loaded
- self.db = LibStub("AceDB-3.0"):New("HolyPowerIndicatorDB", defaults, "Default")
- LibStub("AceConfig-3.0"):RegisterOptionsTable("HolyPowerIndicator", options)
- self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("HolyPowerIndicator", "HolyPowerIndicator")
- self:RegisterChatCommand("hpi", "ChatCommand")
- self:RegisterChatCommand("holypowerindicator", "ChatCommand")
- end
- --Check Class
- if select(2, UnitClass('player')) ~= "PALADIN" then
- DisableAddOn("HolyPowerIndicator")
- return
- end
- --Remove Blizzard Frame
- PaladinPowerBar:SetAlpha(0)
- --Frame
- local frame, events = CreateFrame("Frame", "HPI", UIParent),{}
- local texture = frame:CreateTexture()
- frame:SetMovable()
- frame:EnableMouse(false)
- frame:SetPoint("CENTER",0, 0)
- frame:SetWidth(128)
- frame:SetHeight(128)
- texture:SetAllPoints(frame)
- frame:SetUserPlaced(true)
- --Lock/Unlock Frame
- function frame:toggleLock()
- if locked then
- locked = false
- frame:EnableMouse(true)
- frame:RegisterForDrag("LeftButton")
- frame:SetScript("OnDragStart", function(self)
- self:StartMoving()
- end)
- frame:SetScript("OnDragStop", function(self)
- self:StopMovingOrSizing()
- end)
- texture:SetTexture(textureSelect.."3.tga")
- frame:Show()
- else
- locked = true
- frame:EnableMouse(false)
- frame:RegisterForDrag(nil)
- frame:SetScript("OnDragStart", nil)
- frame:SetScript("OnDragStop", nil)
- frame:Hide()
- end
- end
- SLASH_HOLYPOWERINDICATOR1 = "/hpi";
- SlashCmdList["HOLYPOWERINDICATOR"] = function(msg)
- if msg == "lock" then
- frame:toggleLock()
- end
- end
- --Find Holy Power & display count
- function events:UNIT_POWER(source,type)
- if source == "player" and type == "HOLY_POWER" then
- local power = UnitPower("player",9)
- if power == 1 then
- texture:SetTexture(self.db.textureSelect.."1.tga")
- frame:Show()
- elseif power == 2 then
- texture:SetTexture(self.db.textureSelect.."2.tga")
- frame:Show()
- elseif power == 3 then
- texture:SetTexture(self.db.textureSelect.."3.tga")
- frame:Show()
- elseif power == 0 then
- frame:Hide()
- end
- end
- end
- --Register Events
- frame:SetScript("OnEvent",function(self,event,...) events[event](self,...) end)
- for k,v in pairs(events) do
- frame:RegisterEvent(k)
- end
- function HolyPowerIndicator:GetLocked(info)
- return self.db.profile.locked
- end
- function HolyPowerIndicator:SetLocked(info, value)
- self.db.profile.locked = value
- end
- function HolyPowerIndicator:GetAlpha(info)
- return self.db.profile.alpha
- end
- function HolyPowerIndicator:SetAlpha(info, value)
- self.db.profile.Alpha = value
- end
- function HolyPowerIndicator:GetScale(info)
- return self.db.profile.scale
- end
- function HolyPowerIndicator:SetScale(info, value)
- self.db.profile.scale = value
- end
- function HolyPowerIndicator:GetTexture(info)
- return self.db.profile.textureSelect
- end
- function HolyPowerIndicator:SetTexture(info, value)
- self.db.profile.textureSelect = value
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement