Mercurial > wow > buffalo2
view ObjectiveTracker/ExperienceBar.lua @ 45:dd1ae565f559
Hooks and Handlers:
- correct argument mix-ups for AcceptQuest/QUEST_ACCEPTED handlers; fixes auto-watch
- respond to AcknowledgeAutoAcceptQuest; fixes lingering popups
- include Popup and Quest trackers in the response code for CompleteQuest; fixes content artifacts following the rollover of repeating popups seen in Ashran
- clean up wacky OnEvent header
Layout
- add alpha blend options
QuestData
- reset objectives data when a quest is in a completed state; keeps old data from ever reaching the Default.x code
author | Nenue |
---|---|
date | Tue, 26 Apr 2016 14:57:18 -0400 |
parents | c33c17dd97e7 |
children | 07ef62fe201f |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 4/6/2016 4:44 AM local B = select(2,...).frame local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local tostring = tostring local UnitLevel, IsResting, UnitXP, UnitXPMax, GetXPExhaustion, IsXPUserDisabled = UnitLevel, IsResting, UnitXP, UnitXPMax, GetXPExhaustion, IsXPUserDisabled local Wrapper = _G.VeneerObjectiveWrapper local print = B.print('XPTracker') mod.InitializeXPTracker = function() local XPBar = Wrapper.XPBar if UnitLevel('player') == 100 then XPBar:Hide() return end --- xp bar XPBar:SetWidth(mod.Conf.Wrapper.WrapperWidth - Wrapper.CloseButton:GetWidth()) XPBar.statusbg:SetAllPoints(XPBar) XPBar:RegisterEvent('DISABLE_XP_GAIN') XPBar:RegisterEvent('ENABLE_XP_GAIN') XPBar:SetScript('OnEvent', mod.UpdateXP) if not IsXPUserDisabled() then mod.EnableXP(XPBar) else mod.DisableXP(XPBar) end mod.UpdateXP(XPBar) end mod.EnableXP = function(self) self:RegisterEvent('PLAYER_XP_UPDATE') self:RegisterEvent('PLAYER_LEVEL_UP') self:RegisterEvent('PLAYER_UPDATE_RESTING') self.statusbg:SetTexture(0,0,0,.25) self:Show() end mod.DisableXP = function(self) self:UnregisterEvent('PLAYER_XP_UPDATE') self:UnregisterEvent('PLAYER_LEVEL_UP') self:UnregisterEvent('PLAYER_UPDATE_RESTING') self.statusbg:SetTexture(0.5,0.5,0.5,0.5) self:Hide() end mod.UpdateXP = function(self, event) if event == 'DISABLE_XP_GAIN' then mod.DisableXP(self) elseif event == 'ENABLE_XP_GAIN' then mod.EnableXP(self) end if not IsXPUserDisabled() then local xp = UnitXP('player') local xpmax = UnitXPMax('player') local rest = GetXPExhaustion() self.foreground:SetWidth((xp/xpmax) * self:GetWidth()) if rest then self.rested:ClearAllPoints() if xp == 0 then self.rested:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0) else self.rested:SetPoint('TOPLEFT', self.fg, 'TOPRIGHT', 0, 0) end if (xp + rest) > xpmax then self.rested:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 0) else self.rested:SetWidth((rest/xpmax) * self:GetWidth()) end self.rested:SetPoint('BOTTOM', self, 'BOTTOM') self.rested:Show() else self.rested:Hide() end if IsResting() then self.statusbg:SetTexture(.2,.8,.2,.5) else self.statusbg:SetTexture(0,0,0,.25) end self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) end end