Mercurial > wow > askmrrobot
comparison Shopping.lua @ 131:318c93e0cd6b v61
Fixed an issue with the shopping list.
author | yellowfive |
---|---|
date | Wed, 18 Jul 2018 15:19:04 -0700 |
parents | e31b02b24488 |
children | a0894ffebd15 |
comparison
equal
deleted
inserted
replaced
130:559f1d35bc72 | 131:318c93e0cd6b |
---|---|
208 btn:SetHoverFont(Amr.CreateFont("Bold", 14, Amr.Colors.White)) | 208 btn:SetHoverFont(Amr.CreateFont("Bold", 14, Amr.Colors.White)) |
209 btn:SetCallback("OnClick", onItemClick) | 209 btn:SetCallback("OnClick", onItemClick) |
210 panel:AddChild(btn) | 210 panel:AddChild(btn) |
211 btn:SetPoint("LEFT", icon.frame, "RIGHT", 5, 0) | 211 btn:SetPoint("LEFT", icon.frame, "RIGHT", 5, 0) |
212 | 212 |
213 Amr.GetItemInfo(itemId, function(obj, name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture) | 213 local item = Item:CreateFromItemID(itemId) |
214 -- set icon, name, and a tooltip | 214 if item then |
215 obj.itemIcon:SetIcon(texture) | 215 local itemLink = item:GetItemLink() |
216 obj.itemText:SetText(link:gsub("%[", ""):gsub("%]", "")) | 216 if itemLink then |
217 obj.itemText:SetUserData("itemName", name) | 217 icon:SetIcon(item:GetItemIcon()) |
218 Amr:SetItemTooltip(obj.itemText, link) | 218 btn:SetText(itemLink:gsub("%[", ""):gsub("%]", "")) |
219 end, { itemIcon = icon, itemText = btn }) | 219 btn:SetUserData("itemName", item:GetItemName()) |
220 Amr:SetItemTooltip(btn, itemLink) | |
221 end | |
222 end | |
220 end | 223 end |
221 | 224 |
222 end | 225 end |
223 | 226 |
224 -- get the number of a specified gem/enchant/material that the player currently owns | 227 -- get the number of a specified gem/enchant/material that the player currently owns |
360 | 363 |
361 end | 364 end |
362 | 365 |
363 -- compare gear to everything the player owns, and return the minimum gems/enchants/materials needed to optimize, | 366 -- compare gear to everything the player owns, and return the minimum gems/enchants/materials needed to optimize, |
364 -- grouped by inventory ID so that we can combine multiple specs without double-counting | 367 -- grouped by inventory ID so that we can combine multiple specs without double-counting |
365 local function getShoppingData(player, gear, spec) | 368 local function getShoppingData(player, gear) |
366 | 369 |
367 local ret = {} | 370 local ret = {} |
368 | 371 |
369 -- used to prevent considering the same item twice | 372 -- used to prevent considering the same item twice |
370 local usedItems = {} | 373 local usedItems = {} |
377 | 380 |
378 -- gems | 381 -- gems |
379 if not optimalItem.relicBonusIds and (not matchItem or not matchItem.relicBonusIds) then | 382 if not optimalItem.relicBonusIds and (not matchItem or not matchItem.relicBonusIds) then |
380 for i = 1, 3 do | 383 for i = 1, 3 do |
381 local g = optimalItem.gemIds[i] | 384 local g = optimalItem.gemIds[i] |
382 local isGemEquipped = g ~= 0 and matchItem and matchItem.gemIds and matchItem.gemIds[i] == g | 385 local isGemEquipped = g == 0 or (matchItem and matchItem.gemIds and matchItem.gemIds[i] == g) |
383 | |
384 if not isGemEquipped then | 386 if not isGemEquipped then |
385 if not ret[inventoryId] then | 387 if not ret[inventoryId] then |
386 ret[inventoryId] = { gems = {}, enchants = {}, materials = {} } | 388 ret[inventoryId] = { gems = {}, enchants = {}, materials = {} } |
387 end | 389 end |
388 incrementTableItem(ret[inventoryId].gems, g, 1) | 390 incrementTableItem(ret[inventoryId].gems, g, 1) |
426 } | 428 } |
427 | 429 |
428 local enchantItemIdToId = {} | 430 local enchantItemIdToId = {} |
429 | 431 |
430 for i, spec in ipairs(required.specs) do | 432 for i, spec in ipairs(required.specs) do |
431 local gear = Amr.db.char.GearSets[spec] | 433 local gear = Amr.db.char.GearSets[i] |
432 if gear then | 434 if gear then |
433 required.stuff[i] = getShoppingData(player, gear, spec) | 435 required.stuff[i] = getShoppingData(player, gear) |
434 else | 436 else |
435 required.stuff[i] = {} | 437 required.stuff[i] = {} |
436 end | 438 end |
437 end | 439 end |
438 | 440 |