Advertisement
Guest User

Untitled

a guest
Mar 15th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.01 KB | None | 0 0
  1. HolyPowerIndicator = LibStub("AceAddon-3.0"):NewAddon("HolyPowerIndicator", "AceConsole-3.0", "AceEvent-3.0")
  2.  
  3. local options = {
  4.     name = "HolyPowerIndicator",
  5.     handler = HolyPowerIndicator,
  6.     type ="group",
  7.     args = {
  8.         locked = {
  9.             type = "toggle",
  10.             name = "Lock",
  11.             desc = "Locks the Holy Power frame.",
  12.             descStyle = "inline",
  13.             width = "full",
  14.             order = 1,
  15.             get = "GetLocked",
  16.             set = "SetLocked",
  17.         },
  18.         alpha = {
  19.             type = "range",
  20.             name = "Alpha",
  21.             desc = "Set the frame's alpha.",
  22.             descStyle = "inline",
  23.             width = "full",
  24.             min = 0.1,
  25.             max = 1,
  26.             step = 0.1,
  27.             order = 2,
  28.             get = "GetAlpha",
  29.             set = "SetAlpha",
  30.         },
  31.         scale = {
  32.             type = "range",
  33.             name = "Scale",
  34.             desc = "Set the frame's scale.",
  35.             descStyle = "inline",
  36.             width = "full",
  37.             min = 0.5,
  38.             max = 5,
  39.             step = 0.5,
  40.             order = 3,
  41.             get = "GetScale",
  42.             set = "SetScale",
  43.         },
  44.         textureSelect = {
  45.             type = "select",
  46.             name = "Texture",
  47.             desc = "Select the texture.",
  48.             descStyle = "inline",
  49.             width = "full",
  50.             values = {
  51.                 ["1-Number"] = "Interface\\AddOns\\HolyPowerIndicator\\Number\\",
  52.                 ["2-Alliance"] = "Interface\\AddOns\\HolyPowerIndicator\\Alliance\\",
  53.                 ["3-Horde"] = "Interface\\AddOns\\HolyPowerIndicator\\Horde\\",
  54.                 ["4-Dot"] = "Interface\\AddOns\\HolyPowerIndicator\\Dot\\",
  55.                 ["5-Coins"] = "Interface\\AddOns\\HolyPowerIndicator\\Coins\\",
  56.                 ["6-Bar"] = "Interface\\AddOns\\HolyPowerIndicator\\Bar\\",
  57.                 ["7-PvPRank"] = "Interface\\AddOns\\HolyPowerIndicator\\PvPRank\\",
  58.                 ["8-TukBar"] = "Interface\\AddOns\\HolyPowerIndicator\\TukBar\\",
  59.             },
  60.             style = "dropdown",
  61.             get = "GetTexture",
  62.             set= "SetTexture",
  63.         },
  64.     },
  65. }  
  66.  
  67. local defaults = {
  68.     profile = {
  69.         locked = true,
  70.         alpha = 1,
  71.         scale = 1,
  72.         textureSelect = "Interface\\AddOns\\HolyPowerIndicator\\TukBar\\",
  73.     },
  74. }
  75.  
  76.  
  77.  
  78.  
  79. function HolyPowerIndicator:OnInitialize()
  80.     -- Called when the addon is loaded
  81.     self.db = LibStub("AceDB-3.0"):New("HolyPowerIndicatorDB", defaults, "Default")
  82.  
  83.     LibStub("AceConfig-3.0"):RegisterOptionsTable("HolyPowerIndicator", options)
  84.     self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("HolyPowerIndicator", "HolyPowerIndicator")
  85.     self:RegisterChatCommand("hpi", "ChatCommand")
  86.     self:RegisterChatCommand("holypowerindicator", "ChatCommand")
  87. end
  88.  
  89. --Check Class
  90. if select(2, UnitClass('player')) ~= "PALADIN" then
  91.     DisableAddOn("HolyPowerIndicator")
  92.     return
  93. end
  94.  
  95.  
  96. --Remove Blizzard Frame
  97. PaladinPowerBar:SetAlpha(0)
  98.  
  99.  
  100. --Frame
  101. local frame, events = CreateFrame("Frame", "HPI", UIParent),{}
  102. local texture = frame:CreateTexture()
  103. frame:SetMovable()
  104. frame:EnableMouse(false)
  105. frame:SetPoint("CENTER",0, 0)
  106. frame:SetWidth(128)
  107. frame:SetHeight(128)
  108. texture:SetAllPoints(frame)
  109. frame:SetUserPlaced(true)
  110.  
  111.  
  112. --Lock/Unlock Frame
  113. function frame:toggleLock()
  114.     if locked then
  115.         locked = false
  116.         frame:EnableMouse(true)
  117.         frame:RegisterForDrag("LeftButton")
  118.         frame:SetScript("OnDragStart", function(self)
  119.             self:StartMoving()
  120.         end)
  121.         frame:SetScript("OnDragStop", function(self)
  122.             self:StopMovingOrSizing()
  123.         end)
  124.         texture:SetTexture(textureSelect.."3.tga")
  125.                             frame:Show()
  126.     else
  127.         locked = true
  128.         frame:EnableMouse(false)
  129.         frame:RegisterForDrag(nil)
  130.         frame:SetScript("OnDragStart", nil)
  131.         frame:SetScript("OnDragStop", nil)
  132.         frame:Hide()
  133.     end
  134. end
  135.  
  136.  
  137. SLASH_HOLYPOWERINDICATOR1 = "/hpi";
  138. SlashCmdList["HOLYPOWERINDICATOR"] = function(msg)
  139.     if msg == "lock" then
  140.         frame:toggleLock()
  141.     end
  142. end
  143.  
  144.  
  145. --Find Holy Power & display count
  146. function events:UNIT_POWER(source,type)
  147.     if source == "player" and type == "HOLY_POWER" then
  148.         local power = UnitPower("player",9)
  149.  
  150.         if power == 1 then
  151.             texture:SetTexture(self.db.textureSelect.."1.tga")
  152.             frame:Show()
  153.  
  154.         elseif power == 2 then
  155.             texture:SetTexture(self.db.textureSelect.."2.tga")
  156.             frame:Show()
  157.  
  158.         elseif power == 3 then
  159.             texture:SetTexture(self.db.textureSelect.."3.tga")
  160.             frame:Show()
  161.  
  162.         elseif power == 0 then
  163.             frame:Hide()
  164.         end
  165.     end
  166. end
  167.  
  168. --Register Events
  169. frame:SetScript("OnEvent",function(self,event,...) events[event](self,...) end)
  170.  
  171. for k,v in pairs(events) do
  172.     frame:RegisterEvent(k)
  173. end
  174.  
  175. function HolyPowerIndicator:GetLocked(info)
  176.     return self.db.profile.locked
  177. end
  178.  
  179. function HolyPowerIndicator:SetLocked(info, value)
  180.     self.db.profile.locked = value
  181. end
  182.  
  183. function HolyPowerIndicator:GetAlpha(info)
  184.     return self.db.profile.alpha
  185. end
  186.  
  187. function HolyPowerIndicator:SetAlpha(info, value)
  188.     self.db.profile.Alpha = value
  189. end
  190. function HolyPowerIndicator:GetScale(info)
  191.     return self.db.profile.scale
  192. end
  193.  
  194. function HolyPowerIndicator:SetScale(info, value)
  195.     self.db.profile.scale = value
  196. end
  197. function HolyPowerIndicator:GetTexture(info)
  198.     return self.db.profile.textureSelect
  199. end
  200.  
  201. function HolyPowerIndicator:SetTexture(info, value)
  202.     self.db.profile.textureSelect = value
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement