comparison Gear.lua @ 81:0515882856f1 v38

updated for 7.0
author yellowfive
date Tue, 19 Jul 2016 10:05:32 -0700
parents 304d7ebb8e30
children af2474d28bb4
comparison
equal deleted inserted replaced
80:8f235b016212 81:0515882856f1
12 -- different items (id + bonus ids + suffix, constitutes a different physical drop) 12 -- different items (id + bonus ids + suffix, constitutes a different physical drop)
13 if Amr.GetItemUniqueId(item1, true) ~= Amr.GetItemUniqueId(item2, true) then 13 if Amr.GetItemUniqueId(item1, true) ~= Amr.GetItemUniqueId(item2, true) then
14 return 1000 14 return 1000
15 end 15 end
16 16
17 -- different upgrade levels of the same item (only for older gear, player has control over upgrade level) 17 -- different upgrade levels of the same item
18 if item1.upgradeId ~= item2.upgradeId then 18 if item1.upgradeId ~= item2.upgradeId then
19 return 100 19 return 100
20 end 20 end
21 21
22 -- different gems 22 -- different gems
136 icon:SetIconBorderColor(Amr.Colors.Classes[player.Class]) 136 icon:SetIconBorderColor(Amr.Colors.Classes[player.Class])
137 icon:SetWidth(48) 137 icon:SetWidth(48)
138 icon:SetHeight(48) 138 icon:SetHeight(48)
139 139
140 local iconSpec 140 local iconSpec
141 if player.SubSpecs[spec] then 141 if player.SubSpecs and player.SubSpecs[spec] then
142 iconSpec = player.SubSpecs[spec] 142 iconSpec = player.SubSpecs[spec]
143 else 143 else
144 iconSpec = player.Specs[spec] 144 iconSpec = player.Specs[spec]
145 end 145 end
146 146
147 icon:SetIcon("Interface\\Icons\\" .. Amr.SpecIcons[iconSpec]) 147 icon:SetIcon("Interface\\Icons\\" .. Amr.SpecIcons[iconSpec])
148 icon:SetPoint("TOPLEFT", panelGear.content, "TOPLEFT", 10, -10) 148 icon:SetPoint("TOPLEFT", panelGear.content, "TOPLEFT", 10, -10)
149 panelGear:AddChild(icon) 149 panelGear:AddChild(icon)
150 150
151 local btnEquip = AceGUI:Create("AmrUiButton") 151 local btnEquip = AceGUI:Create("AmrUiButton")
152 btnEquip:SetText(L.GearButtonEquip(spec)) 152 btnEquip:SetText(L.GearButtonEquip(L.SpecsShort[player.Specs[spec]]))
153 btnEquip:SetBackgroundColor(Amr.Colors.Green) 153 btnEquip:SetBackgroundColor(Amr.Colors.Green)
154 btnEquip:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) 154 btnEquip:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White))
155 btnEquip:SetWidth(300) 155 btnEquip:SetWidth(300)
156 btnEquip:SetHeight(26) 156 btnEquip:SetHeight(26)
157 btnEquip:SetPoint("LEFT", icon.frame, "RIGHT", 40, 0) 157 btnEquip:SetPoint("LEFT", icon.frame, "RIGHT", 40, 0)
158 btnEquip:SetPoint("RIGHT", panelGear.content, "RIGHT", -40, 0) 158 btnEquip:SetPoint("RIGHT", panelGear.content, "RIGHT", -40, 0)
159 btnEquip:SetCallback("OnClick", function(widget) 159 btnEquip:SetCallback("OnClick", function(widget)
160 Amr:EquipGearSet(spec) 160 Amr:EquipGearSet(spec)
161 end) 161 end)
162 panelGear:AddChild(btnEquip) 162 panelGear:AddChild(btnEquip)
163
164 --[[local btnShop = AceGUI:Create("AmrUiButton")
165 btnShop:SetText(L.GearButtonShop)
166 btnShop:SetBackgroundColor(Amr.Colors.Blue)
167 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White))
168 btnShop:SetWidth(300)
169 btnShop:SetHeight(26)
170 btnShop:SetPoint("LEFT", btnEquip.frame, "RIGHT", 75, 0)
171 btnShop:SetPoint("RIGHT", panelMods.content, "RIGHT", -20, 0)
172 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end)
173 panelMods:AddChild(btnShop)]]
174 163
175 -- each physical item can only be used once, this tracks ones we have already used 164 -- each physical item can only be used once, this tracks ones we have already used
176 local usedItems = {} 165 local usedItems = {}
177 166
178 -- gear list 167 -- gear list
369 lbl2:SetWidth(130) 358 lbl2:SetWidth(130)
370 lbl2:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.Text)) 359 lbl2:SetFont(Amr.CreateFont("Italic", 12, Amr.Colors.Text))
371 lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 10, -5) 360 lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 10, -5)
372 container:AddChild(lbl2) 361 container:AddChild(lbl2)
373 362
374 --[[
375 local btnClean = AceGUI:Create("AmrUiButton")
376 btnClean:SetText(L.GearButtonCleanText)
377 btnClean:SetBackgroundColor(Amr.Colors.Orange)
378 btnClean:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
379 btnClean:SetWidth(120)
380 btnClean:SetHeight(26)
381 btnClean:SetPoint("BOTTOMLEFT", container.content, "BOTTOMLEFT", 0, 5)
382 btnClean:SetCallback("OnClick", function(widget) Amr:CleanBags() end)
383 container:AddChild(btnClean)
384 ]]
385
386 local t = AceGUI:Create("AmrUiTabGroup") 363 local t = AceGUI:Create("AmrUiTabGroup")
387 t:SetLayout("None") 364 t:SetLayout("None")
388 t:SetTabs({ 365
389 {text=L.GearTabPrimary, value="1", style="bold"}, 366 local tabz = {}
390 {text=L.GearTabSecondary, value="2", style="bold"} 367 for pos = 1, 4 do
391 }) 368 local specId = GetSpecializationInfo(pos)
369 if specId then
370 table.insert(tabz, { text = L.SpecsShort[Amr.SpecIds[specId]], value = pos .. "", style = "bold" })
371 end
372 end
373
374 t:SetTabs(tabz)
392 t:SetCallback("OnGroupSelected", onGearTabSelected) 375 t:SetCallback("OnGroupSelected", onGearTabSelected)
393 t:SetPoint("TOPLEFT", container.content, "TOPLEFT", 144, -30) 376 t:SetPoint("TOPLEFT", container.content, "TOPLEFT", 144, -30)
394 t:SetPoint("BOTTOMRIGHT", container.content, "BOTTOMRIGHT") 377 t:SetPoint("BOTTOMRIGHT", container.content, "BOTTOMRIGHT")
395 container:AddChild(t) 378 container:AddChild(t)
396 _gearTabs = t; 379 _gearTabs = t;
397 380
381 --[[
398 local btnShop = AceGUI:Create("AmrUiButton") 382 local btnShop = AceGUI:Create("AmrUiButton")
399 btnShop:SetText(L.GearButtonShop) 383 btnShop:SetText(L.GearButtonShop)
400 btnShop:SetBackgroundColor(Amr.Colors.Blue) 384 btnShop:SetBackgroundColor(Amr.Colors.Blue)
401 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) 385 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White))
402 btnShop:SetWidth(245) 386 btnShop:SetWidth(245)
403 btnShop:SetHeight(26) 387 btnShop:SetHeight(26)
404 btnShop:SetPoint("TOPRIGHT", container.content, "TOPRIGHT", -20, -25) 388 btnShop:SetPoint("TOPRIGHT", container.content, "TOPRIGHT", -20, -25)
405 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) 389 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end)
406 container:AddChild(btnShop) 390 container:AddChild(btnShop)
407 391 ]]
408 392
409 if not _activeTab then 393 if not _activeTab then
410 _activeTab = tostring(GetActiveSpecGroup()) 394 _activeTab = tostring(GetSpecialization())
411 end 395 end
412 396
413 t:SelectTab(_activeTab) 397 t:SelectTab(_activeTab)
414 end 398 end
415 399
705 _pendingEquip = nil 689 _pendingEquip = nil
706 end 690 end
707 end 691 end
708 692
709 local function onActiveTalentGroupChanged() 693 local function onActiveTalentGroupChanged()
694
710 local auto = Amr.db.profile.options.autoGear 695 local auto = Amr.db.profile.options.autoGear
711 local currentSpec = GetActiveSpecGroup() 696 local currentSpec = GetSpecialization()
712 697
713 if currentSpec == _waitingForSpec or auto then 698 if currentSpec == _waitingForSpec or auto then
714 -- spec is what we want, now equip the gear 699 -- spec is what we want, now equip the gear
715 startEquipGearSet(currentSpec) 700 startEquipGearSet(currentSpec)
716 end 701 end
717 702
718 _waitingForSpec = 0 703 _waitingForSpec = 0
719 end 704 end
720 705
721 -- activate the specified spec and then equip the saved gear set for either primary (1) or secondary (2) spec 706 -- activate the specified spec and then equip the saved gear set
722 function Amr:EquipGearSet(spec) 707 function Amr:EquipGearSet(spec)
723 708
724 -- if no argument, then toggle spec 709 -- if no argument, then cycle spec
725 if not spec then 710 if not spec then
726 spec = GetActiveSpecGroup() == 1 and 2 or 1 711 spec = GetSpecialization() + 1
727 end 712 end
728 713
729 -- allow some flexibility in the arguments 714 -- allow some flexibility in the arguments
730 if spec == "primary" or spec == "Primary" then spec = 1 end 715 if spec == "1" or spec == "2" or spec == "3" or spec == "4" then spec = tonumber(spec) end
731 if spec == "secondary" or spec == "Secondary" then spec = 2 end 716
732 if spec == "1" or spec == "2" then spec = tonumber(spec) end 717 local specId = GetSpecializationInfo(spec)
733 718 if not specId then spec = 1 end
734 -- only spec 1 or 2 are valid
735 if spec ~= 1 and spec ~= 2 then return end
736 719
737 if UnitAffectingCombat("player") then 720 if UnitAffectingCombat("player") then
738 Amr:Print(L.GearEquipErrorCombat) 721 Amr:Print(L.GearEquipErrorCombat)
739 return 722 return
740 end 723 end
741 724
742 _waitingForSpec = spec 725 _waitingForSpec = spec
743 726
744 local currentSpec = GetActiveSpecGroup() 727 local currentSpec = GetSpecialization()
745 if currentSpec ~= spec then 728 if currentSpec ~= spec then
746 SetActiveSpecGroup(spec) 729 SetSpecialization(spec)
747 else 730 else
748 onActiveTalentGroupChanged() 731 onActiveTalentGroupChanged()
749 end 732 end
750 end 733 end
751 734
752 -- moves any gear in bags to the bank if not part of main or off spec gear set 735 -- moves any gear in bags to the bank if not part of main or off spec gear set
753 function Amr:CleanBags() 736 function Amr:CleanBags()
754 -- TODO: implement 737 -- TODO: implement
755 end 738 end
756 739
740 --[[
741 local function testfunc(message)
742 print(strsub(message, 13))
743 end
744 ]]
745
757 function Amr:InitializeGear() 746 function Amr:InitializeGear()
758 Amr:AddEventHandler("ACTIVE_TALENT_GROUP_CHANGED", onActiveTalentGroupChanged) 747 Amr:AddEventHandler("PLAYER_SPECIALIZATION_CHANGED", onActiveTalentGroupChanged)
759 748
749 --Amr:AddEventHandler("CHAT_MSG_CHANNEL", testfunc)
750
760 Amr:AddEventHandler("UNIT_INVENTORY_CHANGED", function(unitID) 751 Amr:AddEventHandler("UNIT_INVENTORY_CHANGED", function(unitID)
761 if unitID and unitID ~= "player" then return end 752 if unitID and unitID ~= "player" then return end
762 Amr:RefreshGearTab() 753 Amr:RefreshGearTab()
763 end) 754 end)
764 755