Mercurial > wow > buffalo2
comparison Modules/OrderHall.lua @ 80:bb6b532c5d2f
- added "world state" frame for zone-specific currencies and context-based artifact/experience progress
| author | Nenue |
|---|---|
| date | Tue, 11 Oct 2016 08:03:41 -0400 |
| parents | |
| children | 65ec88b30eb8 |
comparison
equal
deleted
inserted
replaced
| 79:0784b87f9722 | 80:bb6b532c5d2f |
|---|---|
| 1 -- Veneer | |
| 2 -- OrderHall.lua | |
| 3 -- Created: 10/7/2016 10:55 PM | |
| 4 -- %file-revision% | |
| 5 -- | |
| 6 | |
| 7 VeneerWorldStateCurrencyMixin = {} | |
| 8 VeneerWorldStateMixin = {} | |
| 9 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop | |
| 10 | |
| 11 function VeneerWorldStateMixin:Setup() | |
| 12 hooksecurefunc(OrderHallCommandBar,'Show', function() | |
| 13 self:Refresh() | |
| 14 end) | |
| 15 self:Refresh() | |
| 16 --DEFAULT_CHAT_FRAME:AddMessage('Loaded') | |
| 17 end | |
| 18 | |
| 19 function VeneerWorldStateMixin:Refresh() | |
| 20 OrderHallCommandBar:ClearAllPoints() | |
| 21 OrderHallCommandBar:SetPoint('TOP') | |
| 22 OrderHallCommandBar:SetWidth(600) | |
| 23 OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5) | |
| 24 OrderHallCommandBar.WorldMapButton:Hide() | |
| 25 OrderHallCommandBar:EnableMouse(false) | |
| 26 end | |
| 27 local initialized | |
| 28 function VeneerWorldStateMixin:OnEvent(event, arg) | |
| 29 print(event, arg) | |
| 30 if OrderHallCommandBar and not initialized then | |
| 31 initialized = true | |
| 32 self:Setup() | |
| 33 self:UnregisterEvent('ADDON_LOADED') | |
| 34 end | |
| 35 | |
| 36 if event == 'PLAYER_ENTERING_WORLD' then | |
| 37 self:Update() | |
| 38 end | |
| 39 end | |
| 40 | |
| 41 function VeneerWorldStateMixin:Update() | |
| 42 local frames = {self:GetChildren()} | |
| 43 print('|cFFFFFF00All:Update()|r') | |
| 44 for i, frame in ipairs(frames) do | |
| 45 if frame.Update then | |
| 46 print(frame:GetName()) | |
| 47 frame:Update() | |
| 48 end | |
| 49 end | |
| 50 end | |
| 51 | |
| 52 | |
| 53 | |
| 54 function VeneerWorldStateMixin:OnLoad () | |
| 55 self:RegisterEvent('ADDON_LOADED') | |
| 56 self:RegisterEvent('ARTIFACT_UPDATE') | |
| 57 self:RegisterEvent('ARTIFACT_XP_UPDATE') | |
| 58 self:RegisterEvent('PLAYER_ENTERING_WORLD') | |
| 59 | |
| 60 end | |
| 61 | |
| 62 function VeneerWorldStateCurrencyMixin:OnLoad () | |
| 63 | |
| 64 self:RegisterEvent('ZONE_CHANGED') | |
| 65 self:RegisterEvent('CURRENCY_DISPLAY_UPDATE') | |
| 66 self:RegisterEvent('CHAT_MSG_CURRENCY') | |
| 67 | |
| 68 end | |
| 69 | |
| 70 function VeneerWorldStateCurrencyMixin:OnEvent (event, arg) | |
| 71 self:Update() | |
| 72 end | |
| 73 | |
| 74 | |
| 75 function VeneerWorldStateCurrencyMixin:Update() | |
| 76 local mapID = GetCurrentMapAreaID() | |
| 77 print('currency refresh: zone =', mapID) | |
| 78 if mapID == 1033 then | |
| 79 local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(1155) | |
| 80 | |
| 81 self.Icon:SetTexture(texture) | |
| 82 self.Label:SetFormattedText("%d / %d", earned, totalMax) | |
| 83 self:Show() | |
| 84 self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6) | |
| 85 else | |
| 86 self:Hide() | |
| 87 end | |
| 88 end |
