Mercurial > wow > buffalo2
comparison Modules/WorldState.lua @ 115:8c94bee4fdfc
- AddHandler simplified
- Centralized combat start/stop hooks
- WorldState removed
author | Nenue |
---|---|
date | Tue, 28 Mar 2017 07:02:26 -0400 |
parents | 6748c98a6c6c |
children | ddfe19d70a34 |
comparison
equal
deleted
inserted
replaced
114:6748c98a6c6c | 115:8c94bee4fdfc |
---|---|
3 -- Created: 10/7/2016 10:55 PM | 3 -- Created: 10/7/2016 10:55 PM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- An extensible panel group for HUD values | 5 -- An extensible panel group for HUD values |
6 | 6 |
7 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop | 7 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop |
8 local WorldStateBlockMixin = {} | 8 |
9 VeneerOrderHallMixin = { | 9 VeneerOrderHallMixin = { |
10 anchorPoint = 'TOP', | 10 anchorPoint = 'TOP', |
11 anchorFrom = 'TOP', | 11 anchorFrom = 'TOP', |
12 anchorPriority = 1, | 12 anchorPriority = 1, |
13 anchorX = 0, | 13 anchorX = 0, |
14 anchorY = 0, | 14 anchorY = 0, |
15 addonTrigger = 'Blizzard_OrderHallUI', | 15 addonTrigger = 'Blizzard_OrderHallUI', |
16 addonFrame = 'OrderHallCommandBar', | 16 addonFrame = 'OrderHallCommandBar', |
17 } | 17 } |
18 | |
19 VeneerWorldStateMixin = { | |
20 maxHeight = 0, | |
21 detectedFrames = {}, | |
22 anchorPoint = 'TOP', | |
23 modules = {} | |
24 } | |
25 | |
26 function VeneerWorldStateMixin:Reset() | |
27 for i, frame in ipairs(self.modules) do | |
28 if frame.Reset then | |
29 frame:Reset() | |
30 end | |
31 end | |
32 self:Update() | |
33 end | |
34 | |
35 function VeneerWorldStateMixin:Setup() | |
36 --DEFAULT_CHAT_FRAME:AddMessage('Loaded') | |
37 print('|cFFFFFF00'..self:GetName()..'|r:Setup()') | |
38 | |
39 for i, frame in ipairs(self.modules) do | |
40 print('--'.. frame:GetName()..' exists') | |
41 if frame.Setup then | |
42 print('--'.. frame:GetName()..':Setup()') | |
43 frame:Setup() | |
44 end | |
45 | |
46 | |
47 for k,v in pairs(WorldStateBlockMixin) do | |
48 if not frame[k] then | |
49 frame[k] = v | |
50 if k:match('^On') then | |
51 frame:SetScript(k, v) | |
52 end | |
53 end | |
54 end | |
55 | |
56 end | |
57 self:UnregisterEvent('PLAYER_LOGIN') | |
58 end | |
59 | |
60 function VeneerWorldStateMixin:SetOrderHallUIMods() | |
61 print('|cFFFF4400remove me', debugstack()) | |
62 end | |
63 | |
64 | |
65 function VeneerWorldStateMixin:OnLoad () | |
66 self.modules = {self:GetChildren()} | |
67 print('|cFFFFFF00'..self:GetName()..'|r!') | |
68 self:RegisterEvent('PLAYER_ENTERING_WORLD') | |
69 self:RegisterEvent('PLAYER_REGEN_ENABLED') | |
70 self:RegisterEvent('PLAYER_REGEN_DISABLED') | |
71 Veneer:AddHandler(self, self.anchorPoint, self.anchorPriority) | |
72 SLASH_VENEERWORLDSTATE1 = "/vws" | |
73 SLASH_VENEERWORLDSTATE2 = "/worldstate" | |
74 SlashCmdList.VENEERWORLDSTATE = function() | |
75 self:Reset() | |
76 end | |
77 end | |
78 | |
79 function VeneerWorldStateMixin:OnEvent(event, arg) | |
80 print(event, arg) | |
81 if event == 'PLAYER_ENTERING_WORLD' then | |
82 self:Update() | |
83 elseif event == 'PLAYER_REGEN_ENABLED' then | |
84 self:Update(true) | |
85 elseif event == 'PLAYER_REGEN_DISABLED' then | |
86 self:Update(true) | |
87 end | |
88 end | |
89 | |
90 function VeneerWorldStateMixin:Update(isBatchUpdate) | |
91 print('|cFFFFFF00All:Update()|r') | |
92 local canShow = false | |
93 for index, frame in ipairs(self.modules) do | |
94 if frame.Update then | |
95 print(' '..index..' |cFFFF00FFUpdate:|r '.. frame:GetName()) | |
96 frame:Update(isBatchUpdate) | |
97 print(' ', frame:IsVisible(), frame:IsShown()) | |
98 if frame:IsShown() then | |
99 canShow = true | |
100 end | |
101 | |
102 end | |
103 end | |
104 self:SetShown(canShow) | |
105 end | |
106 | |
107 function VeneerWorldStateMixin:OnShow() | |
108 print('OnShow()', debugstack()) | |
109 end | |
110 | |
111 function VeneerWorldStateMixin:Reanchor(isUpdate) | |
112 print(' |cFF0088FF'..self:GetName()..':Reanchor()|r', #self.modules, 'blocks') | |
113 self.maxHeight = 0 | |
114 local lastFrame | |
115 for i, frame in ipairs(self.modules) do | |
116 print(' '..frame:GetName()..':',frame:IsShown(), frame:GetHeight()) | |
117 if frame:IsShown() then | |
118 if lastFrame then | |
119 frame:SetPoint('TOP', lastFrame, 'BOTTOM') | |
120 else | |
121 frame:SetPoint('TOP', self, 'TOP') | |
122 end | |
123 | |
124 self.maxHeight = self.maxHeight + frame:GetHeight() | |
125 lastFrame = frame | |
126 end | |
127 end | |
128 if (self.maxHeight == 0) or InCombatLockdown() then | |
129 print (' hiding; combat =', InCombatLockdown()) | |
130 self:SetShown(false) | |
131 else | |
132 print (' height update:', self.maxHeight) | |
133 self:SetHeight(self.maxHeight) | |
134 self:SetShown(true) | |
135 end | |
136 | |
137 if not isUpdate then | |
138 Veneer:InternalReanchor(self, print) | |
139 end | |
140 | |
141 WorldStateAlwaysUpFrame:ClearAllPoints() | |
142 WorldStateAlwaysUpFrame:SetPoint('TOP', self, 'BOTTOM', 0, 0) | |
143 end | |
144 | |
145 | |
146 | |
147 function VeneerWorldStateMixin:OnMouseDown() | |
148 end | |
149 | |
150 --- Order Hall mod | 18 --- Order Hall mod |
151 local requiresUpdate | 19 local requiresUpdate |
152 local ocb | 20 local ocb |
153 function VeneerOrderHallMixin:Setup() | 21 function VeneerOrderHallMixin:Setup() |
154 print('|cFFFFFF00'..self:GetName()..':Setup()') | 22 print('|cFFFFFF00'..self:GetName()..':Setup()') |
198 end | 66 end |
199 | 67 |
200 end | 68 end |
201 | 69 |
202 function VeneerOrderHallMixin:OnLoad() | 70 function VeneerOrderHallMixin:OnLoad() |
203 Veneer:AddHandler(self, 'TOP', 1) | 71 Veneer:AddHandler(self) |
204 self:EnableMouse(false) | 72 self:EnableMouse(false) |
205 end | 73 end |
206 | 74 |
207 | 75 |
208 function VeneerOrderHallMixin:OnShow() | 76 function VeneerOrderHallMixin:OnShow() |
246 Veneer:DynamicReanchor() | 114 Veneer:DynamicReanchor() |
247 end | 115 end |
248 | 116 |
249 | 117 |
250 | 118 |
251 do | |
252 function WorldStateBlockMixin:ShowPanel() | |
253 print('|cFF0088FF'..self:GetName()..':ShowPanel()') | |
254 self:SetShown(true) | |
255 self:SetAlpha(1) | |
256 VeneerWorldState:Show() | |
257 end | |
258 function WorldStateBlockMixin:HidePanel() | |
259 print('|cFF0088FF'..self:GetName()..':HidePanel()') | |
260 self:SetShown(false) | |
261 VeneerWorldState:Reanchor() | |
262 end | |
263 | 119 |
264 function WorldStateBlockMixin:OnSizeChanged () | |
265 local h = self:GetHeight() | |
266 if h > VeneerWorldState.maxHeight then | |
267 VeneerWorldState.maxHeight = h | |
268 VeneerWorldState:SetHeight(h) | |
269 print('updating max height:', h) | |
270 elseif h < VeneerWorldState.maxHeight then | |
271 VeneerWorldState:Reanchor() | |
272 end | |
273 end | |
274 function WorldStateBlockMixin:OnHide () | |
275 print('|cFF0088FF'..self:GetName()..':OnHide()') | |
276 VeneerWorldState:Reanchor() | |
277 end | |
278 function WorldStateBlockMixin:OnShow () | |
279 self.timeLived = 0 | |
280 print('|cFF0088FF'..self:GetName()..':OnShow()') | |
281 VeneerWorldState:Reanchor() | |
282 end | |
283 function WorldStateBlockMixin:Setup() | |
284 print('|cFF0088FF'..self:GetName()..':Setup()|r -- nop') | |
285 self:Update() | |
286 end | |
287 function WorldStateBlockMixin:Reset() | |
288 print('|cFF0088FF'..self:GetName()..':Reset()') | |
289 self.keepOpen = true | |
290 self:Setup() | |
291 end | |
292 end | |
293 | |
294 |