Mercurial > wow > worldplan
comparison ClassPlan.lua @ 117:a4dfdd4f1cf3 v7.3.2-20171215
- Fixed filter pins not working on Argus maps
- More taint counter-measures
author | Nenue |
---|---|
date | Fri, 15 Dec 2017 16:38:09 -0500 |
parents | b2be2de2b133 |
children |
comparison
equal
deleted
inserted
replaced
116:bf4a36378bb9 | 117:a4dfdd4f1cf3 |
---|---|
143 | 143 |
144 local profileName = name .. '-' .. realm | 144 local profileName = name .. '-' .. realm |
145 self.profile = characters[profileName] or { | 145 self.profile = characters[profileName] or { |
146 showItems = true | 146 showItems = true |
147 } | 147 } |
148 self.profileName = profileName | |
148 self.characters = characters | 149 self.characters = characters |
149 characters[profileName] = self.profile | 150 characters[profileName] = self.profile |
150 | 151 |
151 local classColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))] | 152 local classColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))] |
152 local className = UnitClass('player') | 153 local className = UnitClass('player') |
173 print('|cFF00FF00 event', event) | 174 print('|cFF00FF00 event', event) |
174 frame:RegisterEvent(event) | 175 frame:RegisterEvent(event) |
175 end | 176 end |
176 frame.sortedItems = {} | 177 frame.sortedItems = {} |
177 for index, listKey in ipairs(frame.listKey) do | 178 for index, listKey in ipairs(frame.listKey) do |
179 self.profile[listKey] = self.profile[listKey] or {} | |
178 frame.profile = self.profile | 180 frame.profile = self.profile |
179 frame.data = self.data | 181 frame.data = self.data |
180 self.profile[listKey] = self.profile[listKey] or {} | |
181 local listTitle = frame.listTitle[index] | 182 local listTitle = frame.listTitle[index] |
182 setmetatable(self.profile[listKey], { __tostring = function() return listTitle end }) | 183 setmetatable(self.profile[listKey], { __tostring = function() return listTitle end }) |
183 frame.sortedItems[listKey] = {} | 184 frame.sortedItems[listKey] = {} |
184 frame.maxItems = self.maxItems | 185 frame.maxItems = self.maxItems |
185 end | 186 end |
233 | 234 |
234 --- Update space | 235 --- Update space |
235 | 236 |
236 local max = math.max | 237 local max = math.max |
237 function ClassPlan:RefreshData() | 238 function ClassPlan:RefreshData() |
238 local detailsFailed | |
239 for index, handler in pairs(self.Handlers) do | 239 for index, handler in pairs(self.Handlers) do |
240 print(' |cFF00FF00'..handler:GetName()..' data update|r') | 240 print(' |cFF00FF00'..handler:GetName()..' data update|r') |
241 handler:RefreshData() | 241 handler:RefreshData() |
242 end | 242 end |
243 if detailsFailed then | |
244 db.print('Unable to obtain player details. Trying again later.') | |
245 else | |
246 self.requestingData = nil | 243 self.requestingData = nil |
247 end | |
248 end | 244 end |
249 | 245 |
250 function ClassPlan:Update() | 246 function ClassPlan:Update() |
251 print('|cFF00FFFF'..self:GetName()..'Refresh()|r') | 247 print('|cFF00FFFF'..self:GetName()..'Refresh()|r') |
252 | 248 |
253 self.currentHeight = 0 | 249 self.currentHeight = 0 |
254 for index, handler in ipairs(self.Handlers) do | 250 for index, handler in ipairs(self.Handlers) do |
255 local itemsHeight = handler:UpdateItems() | 251 local itemsHeight = handler:UpdateItems() |
256 if itemsHeight then | 252 if itemsHeight then |
253 | |
257 self.currentHeight = max(itemsHeight, self.currentHeight) | 254 self.currentHeight = max(itemsHeight, self.currentHeight) |
255 print('calc height', handler, self.currentHeight) | |
258 end | 256 end |
259 end | 257 end |
260 | 258 |
261 local index = 1 | 259 local index = 1 |
262 for key, info in pairs(self.data.characters) do | 260 for key, info in pairs(self.data.characters) do |
296 button.isMine = (info == self.profile) | 294 button.isMine = (info == self.profile) |
297 button:Update() | 295 button:Update() |
298 button:Show() | 296 button:Show() |
299 index = index + 1 | 297 index = index + 1 |
300 end | 298 end |
299 | |
300 for i = index, #self.characterButtons do | |
301 self.characterButtons[i]:Hide() | |
302 end | |
303 | |
301 | 304 |
302 self.HeaderInset:SetHeight(CP_HEADER_SIZE) | 305 self.HeaderInset:SetHeight(CP_HEADER_SIZE) |
303 self.HeaderInset:ClearAllPoints() | 306 self.HeaderInset:ClearAllPoints() |
304 self.HeaderInset:SetPoint('TOPLEFT' ,self, 'TOPLEFT') | 307 self.HeaderInset:SetPoint('TOPLEFT' ,self, 'TOPLEFT') |
305 self.HeaderInset:SetPoint('RIGHT' ,self, 'RIGHT') | 308 self.HeaderInset:SetPoint('RIGHT' ,self, 'RIGHT') |
374 ListTab:ClearAllPoints() | 377 ListTab:ClearAllPoints() |
375 ListTab:SetPoint('TOPLEFT', frame, 'TOPLEFT', 0, 0) | 378 ListTab:SetPoint('TOPLEFT', frame, 'TOPLEFT', 0, 0) |
376 ListTab:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', 0, -CP_HEADER_SIZE) | 379 ListTab:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', 0, -CP_HEADER_SIZE) |
377 ListTab.Label:SetText(frame.listTitle[frame.currentListIndex]) | 380 ListTab.Label:SetText(frame.listTitle[frame.currentListIndex]) |
378 ListTab:Show() | 381 ListTab:Show() |
379 print(ListTab:GetSize()) | 382 print(ListTab:GetName(), ListTab:GetSize()) |
380 end | 383 end |
381 self.currentHeight = max(self.currentHeight, frame.currentHeight or 0) | 384 self.currentHeight = max(self.currentHeight, frame.currentHeight or 0) |
382 end | 385 end |
383 self:SetHeight(self.currentHeight + self.HeaderInset:GetHeight() + self.ClassStripe:GetHeight()) | 386 self:SetHeight(self.currentHeight + self.HeaderInset:GetHeight() + self.ClassStripe:GetHeight()) |
384 | 387 |
468 end | 471 end |
469 | 472 |
470 function ClassPlanHandlerBase:RefreshData() | 473 function ClassPlanHandlerBase:RefreshData() |
471 print('|cFF0088FF'..self:GetName()..':RefreshData()') | 474 print('|cFF0088FF'..self:GetName()..':RefreshData()') |
472 local activeKey = self.activeKey | 475 local activeKey = self.activeKey |
473 local detailsFailed | |
474 self.truncatedItems = 0 | 476 self.truncatedItems = 0 |
475 self.currentTime = time() | 477 self.currentTime = time() |
476 if self:GetParent().profile then | 478 if self:GetParent().profile then |
477 self:GetPlayerData() | 479 self:GetPlayerData() |
478 else | |
479 detailsFailed = true | |
480 end | 480 end |
481 for _, listKey in ipairs(self.listKey) do | 481 for _, listKey in ipairs(self.listKey) do |
482 local sortedItems = self.sortedItems[listKey] | 482 local sortedItems = self.sortedItems[listKey] |
483 wipe(sortedItems) | 483 wipe(sortedItems) |
484 for key, profile in pairs(self.data.characters) do | 484 for key, profile in pairs(self.data.characters) do |
541 self.Owner:SetText(ownerText) | 541 self.Owner:SetText(ownerText) |
542 self.Name:SetText(self.name) | 542 self.Name:SetText(self.name) |
543 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) | 543 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) |
544 end | 544 end |
545 | 545 |
546 function ClassPlanHandlerBase:Acquire(id) | 546 function ClassPlanHandlerBase:Reanchor() end |
547 end | |
548 function ClassPlanHandlerBase:FreeBlock (block) | |
549 end | |
550 | 547 |
551 function ClassPlanHandlerBase:UpdateItems() | 548 function ClassPlanHandlerBase:UpdateItems() |
552 print('|cFF0088FF '..self:GetName()..':UpdateItems()|r', self.activeKey) | 549 print('|cFF0088FF '..self:GetName()..':UpdateItems()|r', self.activeKey) |
553 self.MoreItemsUp:Hide() | 550 self.MoreItemsUp:Hide() |
554 self.MoreItemsDown:Hide() | 551 self.MoreItemsDown:Hide() |
558 if (not sortedItems[scrollOffset+1]) or (numItems <= self.maxItems) then | 555 if (not sortedItems[scrollOffset+1]) or (numItems <= self.maxItems) then |
559 scrollOffset = 0 | 556 scrollOffset = 0 |
560 elseif (numItems > self.maxItems) and (scrollOffset > (numItems - self.maxItems)) then | 557 elseif (numItems > self.maxItems) and (scrollOffset > (numItems - self.maxItems)) then |
561 scrollOffset = (numItems - self.maxItems) | 558 scrollOffset = (numItems - self.maxItems) |
562 end | 559 end |
560 | |
561 if self.OnUpdateRequested then | |
562 local overrideHeight = self:OnUpdateRequested() | |
563 if overrideHeight then | |
564 return overrideHeight | |
565 end | |
566 | |
567 | |
568 end | |
569 | |
563 | 570 |
564 self.ListTab.Count:SetText(numItems) | 571 self.ListTab.Count:SetText(numItems) |
565 self.blocks = self.blocks or {} | 572 self.blocks = self.blocks or {} |
566 local blocks = self.blocks | 573 local blocks = self.blocks |
567 local lastProfile | 574 local lastProfile |
645 end | 652 end |
646 | 653 |
647 | 654 |
648 self.scrollOffset = scrollOffset | 655 self.scrollOffset = scrollOffset |
649 self.isStale = nil | 656 self.isStale = nil |
657 | |
658 | |
659 if self.OnItemsUpdated then | |
660 return self:OnItemsUpdated() | |
661 end | |
662 | |
650 return totalHeight | 663 return totalHeight |
651 end | 664 end |
652 | 665 |
653 function ClassPlanEntryBase:OnAnimFinished() | 666 function ClassPlanEntryBase:OnAnimFinished() |
654 end | 667 end |
706 end | 719 end |
707 function ClassPlanHeaderMixin:OnClick () | 720 function ClassPlanHeaderMixin:OnClick () |
708 local frame = self:GetParent() | 721 local frame = self:GetParent() |
709 frame:SetList() | 722 frame:SetList() |
710 if frame.OnHeaderClick then | 723 if frame.OnHeaderClick then |
711 frame.OnHeaderClick(frame) | 724 frame:OnHeaderClick() |
712 end | 725 end |
713 end | 726 end |
714 | 727 |
715 ClassPlanCharacterButtonMixin = { | 728 ClassPlanCharacterButtonMixin = { |
716 } | 729 } |
721 end | 734 end |
722 self.Icon:SetDesaturated((not self.showItems)) | 735 self.Icon:SetDesaturated((not self.showItems)) |
723 self.SelectGlow:SetShown(self.isMine) | 736 self.SelectGlow:SetShown(self.isMine) |
724 end | 737 end |
725 | 738 |
739 function ClassPlanCharacterButtonMixin:OnLoad() | |
740 self:RegisterForClicks('AnyDown') | |
741 end | |
742 | |
726 function ClassPlanCharacterButtonMixin:OnEnter() | 743 function ClassPlanCharacterButtonMixin:OnEnter() |
727 if not self.profileKey then | 744 if not self.profileKey then |
728 return | 745 return |
729 end | 746 end |
730 | 747 |
731 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') | 748 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') |
732 local info = ClassOrderPlan.data.characters[self.profileKey] | 749 local info = ClassOrderPlan.data.characters[self.profileKey] |
733 GameTooltip:AddLine(self.characterName, self.classColor.r, self.classColor.g, self.classColor.b) | 750 GameTooltip:AddLine(self.characterName .. ' - ' .. self.characterRealm, self.classColor.r, self.classColor.g, self.classColor.b) |
734 local numItems = 0 | 751 local numItems = 0 |
735 if info.missions then | 752 if info.missions then |
736 GameTooltip:AddLine(#info.missions .. ' mission'..((#info.missions == 1) and '' or 's')..' in progress') | 753 GameTooltip:AddLine(#info.missions .. ' mission'..((#info.missions == 1) and '' or 's')..' in progress') |
737 end | 754 end |
738 if info.shipments then | 755 if info.shipments then |
749 GameTooltip:Hide() | 766 GameTooltip:Hide() |
750 end | 767 end |
751 end | 768 end |
752 | 769 |
753 function ClassPlanCharacterButtonMixin:OnClick(button, down) | 770 function ClassPlanCharacterButtonMixin:OnClick(button, down) |
754 print('OnClick', self.profileKey) | |
755 local clist = ClassOrderPlan.data.characters | 771 local clist = ClassOrderPlan.data.characters |
756 | 772 |
757 if button == 'RightButton' then | 773 if button == 'RightButton' then |
758 for _, profile in pairs(clist) do | 774 |
759 profile.showItems = true | 775 if IsShiftKeyDown() then |
760 end | 776 print('delete profile', self.profileKey) |
777 clist[self.profileKey] = nil | |
778 else | |
779 | |
780 for _, profile in pairs(clist) do | |
781 profile.showItems = true | |
782 end | |
783 end | |
784 | |
785 | |
786 | |
761 else | 787 else |
762 if clist[self.profileKey].showItems then | 788 if clist[self.profileKey].showItems then |
763 clist[self.profileKey].showItems = nil | 789 clist[self.profileKey].showItems = nil |
764 else | 790 else |
765 clist[self.profileKey].showItems = true | 791 clist[self.profileKey].showItems = true |
767 end | 793 end |
768 for i, handler in ipairs(ClassOrderPlan.Handlers) do | 794 for i, handler in ipairs(ClassOrderPlan.Handlers) do |
769 handler.isStale = true | 795 handler.isStale = true |
770 end | 796 end |
771 | 797 |
798 | |
799 | |
772 ClassOrderPlan:RefreshData() | 800 ClassOrderPlan:RefreshData() |
773 ClassOrderPlan:Update() | 801 ClassOrderPlan:Update() |
774 print(clist[self.profileKey].showItems) | 802 print('OnClick', self.profileKey) |
775 end | 803 print( clist[self.profileKey] and clist[self.profileKey].showItems) |
804 end |