Mercurial > wow > buffalo2
comparison Modules/PaperDoll.lua @ 96:bb38bc0e787f
- fix weapon slot anchors for paperdoll
author | Nenue |
---|---|
date | Tue, 03 Jan 2017 14:06:41 -0500 |
parents | caded2668701 |
children | 1e511e9aaca5 |
comparison
equal
deleted
inserted
replaced
95:43303398d1b9 | 96:bb38bc0e787f |
---|---|
2 -- PaperDoll.lua | 2 -- PaperDoll.lua |
3 -- Created: 8/16/2016 8:18 AM | 3 -- Created: 8/16/2016 8:18 AM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- Displays the item level and modifications of character sheet equipment, including artifact power | 5 -- Displays the item level and modifications of character sheet equipment, including artifact power |
6 local print = DEVIAN_WORKSPACE and function(...) print('PaperDoll', ...) end or nop | 6 local print = DEVIAN_WORKSPACE and function(...) print('PaperDoll', ...) end or nop |
7 | 7 local artifactSlot |
8 local slot_overlays = {} | 8 local slot_overlays = {} |
9 VeneerPaperDollMixin = { | 9 VeneerPaperDollMixin = { |
10 anchorFrame = 'CharacterFrame', | 10 anchorFrame = 'CharacterFrame', |
11 anchorPoint = 'TOPLEFT', | 11 anchorPoint = 'TOPLEFT', |
12 KnownRelics = {}, | 12 KnownRelics = {}, |
73 self:GetSlotButton(InspectFrame, ...) | 73 self:GetSlotButton(InspectFrame, ...) |
74 end) | 74 end) |
75 self:RegisterEvent('INSPECT_READY') | 75 self:RegisterEvent('INSPECT_READY') |
76 end | 76 end |
77 function VeneerPaperDollMixin:SetupArtifactUI() | 77 function VeneerPaperDollMixin:SetupArtifactUI() |
78 self:RegisterEvent('ARTIFACT_UPDATE') | |
79 end | 78 end |
80 | 79 |
81 function VeneerPaperDollMixin:Setup() | 80 function VeneerPaperDollMixin:Setup() |
82 VeneerData.PaperDoll = VeneerData.PaperDoll or {} | 81 VeneerData.PaperDoll = VeneerData.PaperDoll or {} |
83 VeneerData.PaperDoll.KnownRelics = VeneerData.PaperDoll.KnownRelics or {} | 82 VeneerData.PaperDoll.KnownRelics = VeneerData.PaperDoll.KnownRelics or {} |
84 self.KnownRelics = VeneerData.PaperDoll.KnownRelics | 83 self.KnownRelics = VeneerData.PaperDoll.KnownRelics |
85 | 84 |
86 self:RegisterEvent('UNIT_INVENTORY_CHANGED') | 85 self:RegisterEvent('UNIT_INVENTORY_CHANGED') |
87 self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') | 86 self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') |
88 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') | 87 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') |
88 self:RegisterEvent('ARTIFACT_UPDATE') | |
89 | 89 |
90 self:MarkForUpdate() | 90 self:MarkForUpdate() |
91 end | 91 end |
92 | 92 |
93 function VeneerPaperDollMixin:MarkForUpdate() | 93 function VeneerPaperDollMixin:MarkForUpdate() |
110 local unit = panel.unit or 'player' | 110 local unit = panel.unit or 'player' |
111 if slot_anchors[slot] then | 111 if slot_anchors[slot] then |
112 slot_overlays[panel] = slot_overlays[panel] or {} | 112 slot_overlays[panel] = slot_overlays[panel] or {} |
113 local overlay = slot_overlays[panel][slot] | 113 local overlay = slot_overlays[panel][slot] |
114 if not overlay then | 114 if not overlay then |
115 print('creating slot overlay', slot) | |
115 overlay = CreateFrame('Frame', 'VeneerPaperDollSlot' .. unit .. slot, frame, 'VeneerPaperDollSlotInfoTemplate') | 116 overlay = CreateFrame('Frame', 'VeneerPaperDollSlot' .. unit .. slot, frame, 'VeneerPaperDollSlotInfoTemplate') |
116 overlay:SetID(slot) | 117 overlay:SetID(slot) |
117 slot_overlays[panel][slot] = overlay | 118 slot_overlays[panel][slot] = overlay |
118 overlay.checkRelic = frame.checkRelic | 119 overlay.checkRelic = frame.checkRelic |
119 | 120 |
133 overlay.Sockets:ClearAllPoints() | 134 overlay.Sockets:ClearAllPoints() |
134 overlay.Sockets:SetPoint('BOTTOM', CharacterFrameInsetBg, 'BOTTOM', 0, frame:GetHeight() + 14) | 135 overlay.Sockets:SetPoint('BOTTOM', CharacterFrameInsetBg, 'BOTTOM', 0, frame:GetHeight() + 14) |
135 overlay.ItemLevel:SetFontObject(VeneerNumberFontLarge) | 136 overlay.ItemLevel:SetFontObject(VeneerNumberFontLarge) |
136 overlay.ItemLevel:ClearAllPoints() | 137 overlay.ItemLevel:ClearAllPoints() |
137 overlay.ItemLevel:SetPoint('BOTTOM', overlay.Sockets, 'TOP', 0, 4) | 138 overlay.ItemLevel:SetPoint('BOTTOM', overlay.Sockets, 'TOP', 0, 4) |
139 if unit == 'player' then | |
140 artifactSlot = overlay | |
141 end | |
142 | |
138 end | 143 end |
139 | 144 |
140 print(overlay.Sockets:GetPoint(1)) | 145 print(overlay.Sockets:GetPoint(1)) |
141 overlay.anchors = slot_anchors[slot] | 146 overlay.anchors = slot_anchors[slot] |
142 end | 147 end |
171 if arg == 'Blizzard_ArtifactUI' then | 176 if arg == 'Blizzard_ArtifactUI' then |
172 self:SetupArtifactUI() | 177 self:SetupArtifactUI() |
173 self:MarkForUpdate() | 178 self:MarkForUpdate() |
174 end | 179 end |
175 elseif event == 'ARTIFACT_UPDATE' then | 180 elseif event == 'ARTIFACT_UPDATE' then |
176 self:MarkForUpdate() | 181 |
182 if artifactSlot then | |
183 print('just udpate artifact slot') | |
184 artifactSlot:Update(true) | |
185 end | |
186 | |
187 | |
177 else | 188 else |
178 if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then | 189 if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then |
179 if arg ~= 'player' then | 190 if arg ~= 'player' then |
180 return | 191 return |
181 end | 192 end |
262 local tooltip = VeneerPaperDollTooltip | 273 local tooltip = VeneerPaperDollTooltip |
263 tooltip:SetOwner(self, 'ANCHOR_NONE') | 274 tooltip:SetOwner(self, 'ANCHOR_NONE') |
264 self.hasRelicSlots = true | 275 self.hasRelicSlots = true |
265 if numRelics and isEquipped then | 276 if numRelics and isEquipped then |
266 print('Relic Query:', itemID, numRelics) | 277 print('Relic Query:', itemID, numRelics) |
267 self.checkRelic = nil | |
268 for i = 1, numRelics do | 278 for i = 1, numRelics do |
269 local lockedReason, relicName, relicIcon, relicLink = C_ArtifactUI.GetRelicInfo(i); | 279 local lockedReason, relicName, relicIcon, relicLink = C_ArtifactUI.GetRelicInfo(i); |
270 local relicType = C_ArtifactUI.GetRelicSlotType(i); | 280 local relicType = C_ArtifactUI.GetRelicSlotType(i); |
271 if relicIcon then | 281 if relicIcon then |
272 tooltip:SetHyperlink(relicLink) | 282 tooltip:SetHyperlink(relicLink) |
306 self.SocketLink[i] = relicLink | 316 self.SocketLink[i] = relicLink |
307 end | 317 end |
308 end | 318 end |
309 end | 319 end |
310 | 320 |
311 local SocketIcon_Update = function(frame) | 321 function VeneerPaperDollSlotMixin:Update(forced) |
312 end | |
313 | |
314 function VeneerPaperDollSlotMixin:Update() | |
315 local id = self:GetID() | 322 local id = self:GetID() |
316 | 323 |
317 self.SocketInfo = self.SocketInfo or {} | 324 self.SocketInfo = self.SocketInfo or {} |
318 table.wipe(self.SocketInfo) | 325 table.wipe(self.SocketInfo) |
319 self.ItemLevel:SetText(nil) | 326 self.ItemLevel:SetText(nil) |
320 | 327 |
321 local tooltip = VeneerPaperDollTooltip | 328 local tooltip = VeneerPaperDollTooltip |
322 tooltip:SetOwner(self, 'ANCHOR_NONE') | 329 tooltip:SetOwner(self, 'ANCHOR_NONE') |
323 print('refresh', self.unit, id) | 330 if forced then |
331 print('refresh', self.unit, id) | |
332 end | |
333 | |
324 tooltip:SetInventoryItem(self.unit or 'player', id) | 334 tooltip:SetInventoryItem(self.unit or 'player', id) |
325 tooltip:Show() | 335 tooltip:Show() |
326 | 336 |
327 local numLines = tooltip:NumLines() | 337 local numLines = tooltip:NumLines() |
328 local numTextures = 0 | 338 local numTextures = 0 |
329 local itemLevel | 339 local itemLevel |
330 local itemLevelLine | 340 local itemLevelLine |
331 print('|cFFFFFF00Sockets scan:', numLines) | 341 --print('|cFFFFFF00Sockets scan:', numLines) |
332 for i = 1, numLines do | 342 for i = 1, numLines do |
333 local line = _G['VeneerPaperDollTooltipTextLeft'..i] | 343 local line = _G['VeneerPaperDollTooltipTextLeft'..i] |
334 local text = line and line:GetText() | 344 local text = line and line:GetText() |
335 if text then | 345 if text then |
336 itemLevel = text:match('Item Level (%d+)') | 346 itemLevel = text:match('Item Level (%d+)') |
341 end | 351 end |
342 | 352 |
343 local texture = _G['VeneerPaperDollTooltipTexture'..i] | 353 local texture = _G['VeneerPaperDollTooltipTexture'..i] |
344 if texture and texture:IsShown() then | 354 if texture and texture:IsShown() then |
345 numTextures = numTextures + 1 | 355 numTextures = numTextures + 1 |
346 print('picked up socket', numTextures, texture:GetTexture()) | 356 --print('picked up socket', numTextures, texture:GetTexture()) |
347 self.SocketInfo[numTextures] = texture:GetTexture() | 357 self.SocketInfo[numTextures] = texture:GetTexture() |
348 end | 358 end |
349 end | 359 end |
350 if self.checkRelic then | 360 if self.checkRelic then |
351 self:UpdateRelicInfo() | 361 self:UpdateRelicInfo() |
355 local relativeIcon | 365 local relativeIcon |
356 local socketsWidth = 0 | 366 local socketsWidth = 0 |
357 local socketsHeight = 24 | 367 local socketsHeight = 24 |
358 for index, icon in ipairs(self.Sockets.SocketIcon) do | 368 for index, icon in ipairs(self.Sockets.SocketIcon) do |
359 if self.SocketInfo[index] then | 369 if self.SocketInfo[index] then |
360 print('|cFF0088FFsocketInfo|r', index, self.SocketInfo[index]) | 370 --print('|cFF0088FFsocketInfo|r', index, self.SocketInfo[index]) |
361 icon:ClearAllPoints() | 371 icon:ClearAllPoints() |
362 | 372 |
363 icon:SetTexture(self.SocketInfo[index]) | 373 icon:SetTexture(self.SocketInfo[index]) |
364 icon:SetSize(16, 16) | 374 icon:SetSize(16, 16) |
365 icon:Show() | 375 icon:Show() |
375 icon:SetPoint('LEFT', relativeIcon, 'RIGHT', 2, 0) | 385 icon:SetPoint('LEFT', relativeIcon, 'RIGHT', 2, 0) |
376 socketsWidth = socketsWidth + 2 | 386 socketsWidth = socketsWidth + 2 |
377 end | 387 end |
378 socketsWidth = socketsWidth + icon:GetWidth() | 388 socketsWidth = socketsWidth + icon:GetWidth() |
379 end | 389 end |
390 print( '|cFFFF4400', icon:GetPoint(1)) | |
380 | 391 |
381 local label = self.Sockets.SocketLabel[index] | 392 local label = self.Sockets.SocketLabel[index] |
382 label:ClearAllPoints() | 393 label:ClearAllPoints() |
383 label:SetPoint('BOTTOM', icon, 'TOP',0, 2) | 394 label:SetPoint('BOTTOM', icon, 'TOP',0, 2) |
384 label:SetFontObject(VeneerNumberFont) | 395 label:SetFontObject(VeneerNumberFont) |
389 self.Sockets.SocketBg = self.Sockets.SocketBg or {} | 400 self.Sockets.SocketBg = self.Sockets.SocketBg or {} |
390 self.Sockets.SocketBg[index] = self.Sockets.SocketBg[index] or self.Sockets:CreateTexture() | 401 self.Sockets.SocketBg[index] = self.Sockets.SocketBg[index] or self.Sockets:CreateTexture() |
391 self.Sockets.SocketBg[index]:SetAtlas(relicAtlasName) | 402 self.Sockets.SocketBg[index]:SetAtlas(relicAtlasName) |
392 self.Sockets.SocketBg[index]:SetPoint('TOPRIGHT', icon, 'TOPRIGHT', 12, 12) | 403 self.Sockets.SocketBg[index]:SetPoint('TOPRIGHT', icon, 'TOPRIGHT', 12, 12) |
393 self.Sockets.SocketBg[index]:SetPoint('BOTTOMLEFT', icon, 'BOTTOMLEFT', -12,-12) | 404 self.Sockets.SocketBg[index]:SetPoint('BOTTOMLEFT', icon, 'BOTTOMLEFT', -12,-12) |
394 print('', self.SocketType[index], relicAtlasName) | 405 --print('', self.SocketType[index], relicAtlasName) |
395 | 406 |
396 socketsHeight = self.Sockets.SocketBg[index]:GetHeight() | 407 socketsHeight = self.Sockets.SocketBg[index]:GetHeight() |
408 print(socketsWidth, socketsHeight) | |
397 end | 409 end |
398 | 410 |
399 | 411 |
400 relativeIcon = icon | 412 relativeIcon = icon |
401 else | 413 else |