Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local T, C, L = unpack(Tukui)
- if T.myclass ~= 'ROGUE' then return nil end
- local mod = CreateFrame('StatusBar', 'Tukui_RunicPower', UIParent)
- mod:SetScript('OnEvent', function(self, event, ...) return self[event](self, ...) end)
- mod:RegisterEvent('ADDON_LOADED')
- function mod:ADDON_LOADED(addon)
- if addon == 'Tukui_RunicPower' then
- self:UnregisterEvent('ADDON_LOADED')
- Tukui_RunicPowerDB = Tukui_RunicPowerDB or {
- x = 0,
- y = 0,
- height = 15,
- width = 250,
- }
- self.db = Tukui_RunicPowerDB
- self:SetPoint('TOPLEFT', UIParent, 'TOPLEFT', x, y)
- self:SetWidth(self.db.width)
- self:SetHeight(self.db.height)
- self:SetMovable(true)
- self:SetWidth(self.db.width)
- self:SetHeight(self.db.height)
- self:SetStatusBarTexture(C.media.normTex)
- self:SetTemplate()
- self:CreateShadow()
- self.label = self:CreateFontString(nil, "ARTWORK")
- self.label:SetPoint("CENTER")
- self.label:SetFont(C.media.uffont, 17, "OUTLINE")
- self.label:SetJustifyH("CENTER")
- self:SetScript('OnMouseDown', self.OnMouseDown)
- self:SetScript('OnMouseUp', self.OnMouseUp)
- self:RegisterEvent('UNIT_POWER')
- self:UNIT_POWER('player') -- call this instead of directly calling ResyncValues as a sanity check
- self.InitializeSavedVariables = nil
- self.SetupSlashCommand = nil
- self.ADDON_LOADED = nil
- return true
- end
- end
- function mod:UNIT_POWER(unit)
- return unit == 'player' and self:ResyncValues()
- end
- function mod:OnMouseDown()
- if IsShiftKeyDown() then
- self:StartMoving()
- self.__moving = true
- return true
- end
- end
- function mod:OnMouseUp()
- if self.__moving then
- self:StopMovingOrSizing()
- self.__moving = nil
- self.db.x = self:GetLeft()
- self.db.y = self:GetTop()
- return true
- end
- end
- function mod:SetSize(w, h)
- w, h = tonumber(w), tonumber(h)
- self:SetWidth(w)
- self:SetHeight(h)
- self.db.width = w
- self.db.height = h
- return true
- end
- function mod:ResyncValues()
- local current, max = UnitPower('player'), UnitPowerMax('player')
- self:SetMinMaxValues(0, max)
- self:SetValue(current)
- self:SetStatusBarColor(1-current/max, 0.3, current/max, 1)
- self.label:SetText(current)
- return true
- end
- SLASH_TUKUIRP1 = '/tukuirp'
- SlashCmdList.TUKUIRP = function(msg)
- return mod:SetSize(strsplit('x', msg))
- end
Add Comment
Please, Sign In to add comment