Mercurial > wow > askmrrobot
comparison Gear.lua @ 61:cf2b6b9a8337 v23
6.2 update, shopping list bug fixes, ui scale option
author | yellowfive |
---|---|
date | Tue, 23 Jun 2015 00:27:21 -0700 |
parents | ee701ce45354 |
children | 932885bb1a6f |
comparison
equal
deleted
inserted
replaced
60:017c05f42fd4 | 61:cf2b6b9a8337 |
---|---|
157 btnEquip:SetCallback("OnClick", function(widget) | 157 btnEquip:SetCallback("OnClick", function(widget) |
158 Amr:EquipGearSet(spec) | 158 Amr:EquipGearSet(spec) |
159 end) | 159 end) |
160 panelGear:AddChild(btnEquip) | 160 panelGear:AddChild(btnEquip) |
161 | 161 |
162 local btnShop = AceGUI:Create("AmrUiButton") | 162 --[[local btnShop = AceGUI:Create("AmrUiButton") |
163 btnShop:SetText(L.GearButtonShop) | 163 btnShop:SetText(L.GearButtonShop) |
164 btnShop:SetBackgroundColor(Amr.Colors.Blue) | 164 btnShop:SetBackgroundColor(Amr.Colors.Blue) |
165 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) | 165 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) |
166 btnShop:SetWidth(300) | 166 btnShop:SetWidth(300) |
167 btnShop:SetHeight(26) | 167 btnShop:SetHeight(26) |
168 btnShop:SetPoint("LEFT", btnEquip.frame, "RIGHT", 75, 0) | 168 btnShop:SetPoint("LEFT", btnEquip.frame, "RIGHT", 75, 0) |
169 btnShop:SetPoint("RIGHT", panelMods.content, "RIGHT", -20, 0) | 169 btnShop:SetPoint("RIGHT", panelMods.content, "RIGHT", -20, 0) |
170 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) | 170 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) |
171 panelMods:AddChild(btnShop) | 171 panelMods:AddChild(btnShop)]] |
172 | 172 |
173 -- each physical item can only be used once, this tracks ones we have already used | 173 -- each physical item can only be used once, this tracks ones we have already used |
174 local usedItems = {} | 174 local usedItems = {} |
175 | 175 |
176 -- gear list | 176 -- gear list |
391 t:SetPoint("TOPLEFT", container.content, "TOPLEFT", 144, -30) | 391 t:SetPoint("TOPLEFT", container.content, "TOPLEFT", 144, -30) |
392 t:SetPoint("BOTTOMRIGHT", container.content, "BOTTOMRIGHT") | 392 t:SetPoint("BOTTOMRIGHT", container.content, "BOTTOMRIGHT") |
393 container:AddChild(t) | 393 container:AddChild(t) |
394 _gearTabs = t; | 394 _gearTabs = t; |
395 | 395 |
396 local btnShop = AceGUI:Create("AmrUiButton") | |
397 btnShop:SetText(L.GearButtonShop) | |
398 btnShop:SetBackgroundColor(Amr.Colors.Blue) | |
399 btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) | |
400 btnShop:SetWidth(245) | |
401 btnShop:SetHeight(26) | |
402 btnShop:SetPoint("TOPRIGHT", container.content, "TOPRIGHT", -20, -25) | |
403 btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) | |
404 container:AddChild(btnShop) | |
405 | |
406 | |
396 if not _activeTab then | 407 if not _activeTab then |
397 _activeTab = tostring(GetActiveSpecGroup()) | 408 _activeTab = tostring(GetActiveSpecGroup()) |
398 end | 409 end |
399 | 410 |
400 t:SelectTab(_activeTab) | 411 t:SelectTab(_activeTab) |
473 local function finishEquipGearSet() | 484 local function finishEquipGearSet() |
474 if not _pendingEquip then return end | 485 if not _pendingEquip then return end |
475 | 486 |
476 _pendingEquip.tries = _pendingEquip.tries + 1 | 487 _pendingEquip.tries = _pendingEquip.tries + 1 |
477 if _pendingEquip.tries > 16 then | 488 if _pendingEquip.tries > 16 then |
489 -- too many tries, just give up (shouldn't happen but just to be safe) | |
478 _pendingEquip = nil | 490 _pendingEquip = nil |
479 else | 491 else |
480 -- start over again, trying any items that could not be equipped in the previous pass (unique constraints) | 492 -- start over again, trying any items that could not be equipped in the previous pass (unique constraints) |
481 Amr:EquipGearSet(_pendingEquip.spec) | 493 Amr:EquipGearSet(_pendingEquip.spec) |
482 end | 494 end |
492 local bestLink = nil | 504 local bestLink = nil |
493 local bestDiff = 1000 | 505 local bestDiff = 1000 |
494 | 506 |
495 -- find the best matching item | 507 -- find the best matching item |
496 | 508 |
497 -- equipped items | 509 -- equipped items, but skip slots we have just equipped (to avoid e.g. just moving 2 of the same item back and forth between mh oh weapon slots) |
498 for slotNum = 1, #Amr.SlotIds do | 510 for slotNum = 1, #Amr.SlotIds do |
499 local slotId = Amr.SlotIds[slotNum] | 511 local slotId = Amr.SlotIds[slotNum] |
500 local itemLink = GetInventoryItemLink("player", slotId) | 512 if not _pendingEquip.doneSlots[slotId] then |
501 if itemLink then | 513 local itemLink = GetInventoryItemLink("player", slotId) |
502 local invItem = Amr.ParseItemLink(itemLink) | 514 if itemLink then |
503 if invItem ~= nil then | 515 local invItem = Amr.ParseItemLink(itemLink) |
504 local diff = countItemDifferences(item, invItem) | 516 if invItem ~= nil then |
505 if diff < bestDiff then | 517 local diff = countItemDifferences(item, invItem) |
506 bestItem = { slot = slotId } | 518 if diff < bestDiff then |
507 bestDiff = diff | 519 bestItem = { slot = slotId } |
508 bestLink = itemLink | 520 bestDiff = diff |
521 bestLink = itemLink | |
522 end | |
509 end | 523 end |
510 end | 524 end |
511 end | 525 end |
512 end | 526 end |
513 | 527 |
575 else | 589 else |
576 PickupInventoryItem(bestItem.slot) | 590 PickupInventoryItem(bestItem.slot) |
577 end | 591 end |
578 PickupInventoryItem(slotId) | 592 PickupInventoryItem(slotId) |
579 ClearCursor() | 593 ClearCursor() |
594 | |
595 -- wait for game events to continue | |
580 end | 596 end |
581 end | 597 end |
582 | 598 |
583 end | 599 end |
584 | 600 |
605 -- inventory slot we're swapping from is still locked, can't continue yet | 621 -- inventory slot we're swapping from is still locked, can't continue yet |
606 if IsInventoryItemLocked(_pendingEquip.slot) then return end | 622 if IsInventoryItemLocked(_pendingEquip.slot) then return end |
607 end | 623 end |
608 | 624 |
609 -- move on to the next item, this item is done | 625 -- move on to the next item, this item is done |
626 _pendingEquip.doneSlots[_pendingEquip.destSlot] = true | |
610 _pendingEquip.itemsToEquip[_pendingEquip.destSlot] = nil | 627 _pendingEquip.itemsToEquip[_pendingEquip.destSlot] = nil |
611 _pendingEquip.destSlot = nil | 628 _pendingEquip.destSlot = nil |
612 _pendingEquip.bag = nil | 629 _pendingEquip.bag = nil |
613 _pendingEquip.slot = nil | 630 _pendingEquip.slot = nil |
614 | 631 |
668 _pendingEquip = { | 685 _pendingEquip = { |
669 tries = _pendingEquip and _pendingEquip.spec == spec and _pendingEquip.tries or 0, | 686 tries = _pendingEquip and _pendingEquip.spec == spec and _pendingEquip.tries or 0, |
670 spec = spec, | 687 spec = spec, |
671 itemsToEquip = itemsToEquip, | 688 itemsToEquip = itemsToEquip, |
672 remaining = remaining, | 689 remaining = remaining, |
690 doneSlots = {}, | |
673 nextSlot = firstSlot | 691 nextSlot = firstSlot |
674 } | 692 } |
675 | 693 |
676 -- starting item | 694 -- starting item |
677 for slotId, item in pairs(_pendingEquip.itemsToEquip) do | 695 for slotId, item in pairs(_pendingEquip.itemsToEquip) do |