Mercurial > wow > askmrrobot
comparison Gear.lua @ 133:a0894ffebd15 v62
Bug fixes and tweaks for 8.0.
author | yellowfive |
---|---|
date | Wed, 25 Jul 2018 12:17:24 -0700 |
parents | d9a059484b22 |
children | 57be71eccc0a |
comparison
equal
deleted
inserted
replaced
132:2279d58793c6 | 133:a0894ffebd15 |
---|---|
249 local prevElem = icon | 249 local prevElem = icon |
250 for slotNum = 1, #Amr.SlotIds do | 250 for slotNum = 1, #Amr.SlotIds do |
251 local slotId = Amr.SlotIds[slotNum] | 251 local slotId = Amr.SlotIds[slotNum] |
252 | 252 |
253 local equippedItem = equipped and equipped[slotId] or nil | 253 local equippedItem = equipped and equipped[slotId] or nil |
254 local equippedItemLink = equipped and equipped.link or nil | 254 --local equippedItemLink = equipped and equipped.link or nil |
255 local optimalItem = gear[slotId] | 255 local optimalItem = gear[slotId] |
256 local optimalItemLink = Amr.CreateItemLink(optimalItem) | 256 local optimalItemLink = Amr.CreateItemLink(optimalItem) |
257 | 257 |
258 -- see if item is currently equipped, is false if don't have any item for that slot (e.g. OH for a 2-hander) | 258 -- see if item is currently equipped, is false if don't have any item for that slot (e.g. OH for a 2-hander) |
259 local isEquipped = false | 259 local isEquipped = false |
296 lblItem:SetPoint("TOPLEFT", lblEquipped.frame, "TOPRIGHT", 0, 0) | 296 lblItem:SetPoint("TOPLEFT", lblEquipped.frame, "TOPRIGHT", 0, 0) |
297 lblItem:SetWordWrap(false) | 297 lblItem:SetWordWrap(false) |
298 lblItem:SetWidth(345) | 298 lblItem:SetWidth(345) |
299 lblItem:SetFont(Amr.CreateFont(isEquipped and "Regular" or "Bold", isEquipped and 14 or 15, Amr.Colors.White)) | 299 lblItem:SetFont(Amr.CreateFont(isEquipped and "Regular" or "Bold", isEquipped and 14 or 15, Amr.Colors.White)) |
300 | 300 |
301 -- fill the name/ilvl labels, which may require asynchronous loading of item information | 301 -- fill the name/ilvl labels, which may require asynchronous loading of item information |
302 if optimalItemLink then | 302 if optimalItemLink then |
303 Amr.GetItemInfo(optimalItemLink, function(obj, name, link, quality, iLevel) | 303 local gameItem = Item:CreateFromItemLink(optimalItemLink) |
304 -- set item name, tooltip, and ilvl | 304 if gameItem then |
305 obj.nameLabel:SetText(link:gsub("%[", ""):gsub("%]", "")) | 305 local q = gameItem:GetItemQuality() |
306 | 306 if q == 6 then |
307 if quality == 6 then | |
308 -- not quite right but whatever... close enough, artifacts are a thing of the past | |
309 local tmprel = obj.optimalItem.relicBonusIds | |
310 obj.optimalItem.relicBonusIds = nil | |
311 link = Amr.CreateItemLink(obj.optimalItem) | |
312 obj.optimalItem.relicBonusIds = tmprel | |
313 | |
314 -- for artifacts, we consider it equipped if the item id alone matches | 307 -- for artifacts, we consider it equipped if the item id alone matches |
315 if obj.equippedItem and obj.equippedItem.id == obj.optimalItem.id then | 308 if equippedItem and equippedItem.id == optimalItem.id then |
316 obj.isEquipped = true | 309 isEquipped = true |
317 end | 310 end |
318 obj.equipLabel:SetText(obj.isEquipped and "E" or "") | 311 lblEquipped:SetText(isEquipped and "E" or "") |
319 end | 312 end |
320 | 313 |
321 Amr:SetItemTooltip(obj.nameLabel, link, "ANCHOR_TOPRIGHT") | 314 lblItem:SetFont(Amr.CreateFont(isEquipped and "Regular" or "Bold", isEquipped and 14 or 15, Amr.Colors.Qualities[q])) |
322 | 315 lblItem:SetText(gameItem:GetItemName()) |
323 local itemObj = Item:CreateFromItemLink(link) | 316 lblIlvl:SetText(gameItem:GetCurrentItemLevel()) |
324 if itemObj then | 317 Amr:SetItemTooltip(lblItem, gameItem:GetItemLink(), "ANCHOR_TOPRIGHT") |
325 -- game's GetItemInfo method returns the wrong ilvl sometimes, so use the new item api to get it | 318 end |
326 iLevel = itemObj:GetCurrentItemLevel() | |
327 end | |
328 obj.ilvlLabel:SetText(iLevel) | |
329 | |
330 end, { | |
331 ilvlLabel = lblIlvl, | |
332 nameLabel = lblItem, | |
333 equipLabel = lblEquipped, | |
334 optimalItem = optimalItem, | |
335 equippedItem = equippedItem, | |
336 isEquipped = isEquipped | |
337 }) | |
338 end | 319 end |
339 | 320 |
340 -- modifications | 321 -- modifications |
341 if optimalItem then | 322 if optimalItem then |
342 | 323 |
351 local isPowerActive = Amr.Contains(equippedAzt, spellId) | 332 local isPowerActive = Amr.Contains(equippedAzt, spellId) |
352 | 333 |
353 local socketBorder, socketIcon = createSocketWidget(panelMods, prevSocket or lblItem, prevSocket, isPowerActive) | 334 local socketBorder, socketIcon = createSocketWidget(panelMods, prevSocket or lblItem, prevSocket, isPowerActive) |
354 | 335 |
355 -- set icon and tooltip | 336 -- set icon and tooltip |
356 local spellName, _, spellIcon = GetSpellInfo(spellId) | 337 local _, _, spellIcon = GetSpellInfo(spellId) |
357 socketIcon:SetIcon(spellIcon) | 338 socketIcon:SetIcon(spellIcon) |
358 Amr:SetSpellTooltip(socketIcon, spellId, "ANCHOR_TOPRIGHT") | 339 Amr:SetSpellTooltip(socketIcon, spellId, "ANCHOR_TOPRIGHT") |
359 | 340 |
360 prevSocket = socketBorder | 341 prevSocket = socketBorder |
361 end | 342 end |
370 local isGemEquipped = matchItem and matchItem.gemIds and matchItem.gemIds[i] == g | 351 local isGemEquipped = matchItem and matchItem.gemIds and matchItem.gemIds[i] == g |
371 | 352 |
372 local socketBorder, socketIcon = createSocketWidget(panelMods, prevSocket or lblItem, prevSocket, isGemEquipped) | 353 local socketBorder, socketIcon = createSocketWidget(panelMods, prevSocket or lblItem, prevSocket, isGemEquipped) |
373 | 354 |
374 -- get icon for optimized gem | 355 -- get icon for optimized gem |
375 Amr.GetItemInfo(g, function(obj, name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture) | 356 local gameItem = Item:CreateFromItemID(g) |
376 -- set icon and a tooltip | 357 if gameItem then |
377 obj:SetIcon(texture) | 358 socketIcon:SetIcon(gameItem:GetItemIcon()) |
378 Amr:SetItemTooltip(obj, link, "ANCHOR_TOPRIGHT") | 359 Amr:SetItemTooltip(socketIcon, gameItem:GetItemLink(), "ANCHOR_TOPRIGHT") |
379 end, socketIcon) | 360 end |
380 | 361 |
381 prevSocket = socketBorder | 362 prevSocket = socketBorder |
382 end | 363 end |
383 end | 364 end |
384 | 365 |
395 | 376 |
396 local enchInfo = Amr.db.char.ExtraEnchantData[optimalItem.enchantId] | 377 local enchInfo = Amr.db.char.ExtraEnchantData[optimalItem.enchantId] |
397 if enchInfo then | 378 if enchInfo then |
398 lblEnchant:SetText(enchInfo.text) | 379 lblEnchant:SetText(enchInfo.text) |
399 | 380 |
400 Amr.GetItemInfo(enchInfo.itemId, function(obj, name, link) | 381 local gameItem = Item:CreateFromItemID(enchInfo.itemId) |
401 Amr:SetItemTooltip(obj, link, "ANCHOR_TOPRIGHT") | 382 if gameItem then |
402 end, lblEnchant) | 383 Amr:SetItemTooltip(lblEnchant, gameItem:GetItemLink(), "ANCHOR_TOPRIGHT") |
403 --Amr:SetSpellTooltip(lblEnchant, enchInfo.spellId) | 384 end |
404 end | 385 end |
405 | 386 |
406 end | 387 end |
407 end | 388 end |
408 | 389 |
626 -- on completion, create an equipment manager set if desired | 607 -- on completion, create an equipment manager set if desired |
627 local function onEquipGearSetComplete() | 608 local function onEquipGearSetComplete() |
628 if Amr.db.profile.options.disableEm then return end | 609 if Amr.db.profile.options.disableEm then return end |
629 | 610 |
630 -- create an equipment manager set | 611 -- create an equipment manager set |
631 local specId, specName = GetSpecializationInfo(GetSpecialization()) | 612 |
632 | 613 -- note: ignore slots and/or saveset need to be called twice |
614 -- for some reason, the slot is treated as blank if you try to ignore once on the first load of the equipment manager | |
615 | |
616 -- clear any currently ignored slots | |
617 C_EquipmentSet.ClearIgnoredSlotsForSave() | |
618 C_EquipmentSet.ClearIgnoredSlotsForSave() | |
619 | |
620 -- ignore shirt and tabard | |
621 C_EquipmentSet.IgnoreSlotForSave(INVSLOT_BODY) -- shirt | |
622 C_EquipmentSet.IgnoreSlotForSave(INVSLOT_TABARD) | |
623 C_EquipmentSet.IgnoreSlotForSave(INVSLOT_BODY) -- shirt | |
624 C_EquipmentSet.IgnoreSlotForSave(INVSLOT_TABARD) | |
625 | |
626 -- for now use icon of the spec | |
627 local _, specName, _, setIcon = GetSpecializationInfo(GetSpecialization()) | |
628 | |
629 --[[ | |
633 local item = Amr.ParseItemLink(GetInventoryItemLink("player", INVSLOT_MAINHAND)) | 630 local item = Amr.ParseItemLink(GetInventoryItemLink("player", INVSLOT_MAINHAND)) |
634 if not item then | 631 if not item then |
635 item = Amr.ParseItemLink(GetInventoryItemLink("player", INVSLOT_OFFHAND)) | 632 item = Amr.ParseItemLink(GetInventoryItemLink("player", INVSLOT_OFFHAND)) |
636 end | 633 end |
637 if item then | 634 if item then |
638 Amr.GetItemInfo(item.id, function(customArg, name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture) | 635 local itemObj = Item:CreateFromItemID(item.id) |
639 local setname = "AMR " .. specName | 636 if itemObj then |
640 local setid = C_EquipmentSet.GetEquipmentSetID(setname) | 637 setIcon = itemObj:GetItemIcon() |
641 if setid then | 638 end |
642 C_EquipmentSet.SaveEquipmentSet(setid, texture) | 639 end |
643 else | 640 ]] |
644 C_EquipmentSet.CreateEquipmentSet(setname, texture) | 641 |
645 end | 642 local setname = "AMR " .. specName |
646 end) | 643 local setid = C_EquipmentSet.GetEquipmentSetID(setname) |
644 if setid then | |
645 C_EquipmentSet.SaveEquipmentSet(setid, setIcon) | |
646 else | |
647 C_EquipmentSet.CreateEquipmentSet(setname, setIcon) | |
647 end | 648 end |
648 end | 649 end |
649 | 650 |
650 -- stop any currently in-progress gear swapping operation and clean up | 651 -- stop any currently in-progress gear swapping operation and clean up |
651 local function disposeGearOp() | 652 local function disposeGearOp() |