more refactoring
This commit is contained in:
@@ -147,7 +147,7 @@ function merchant_buy_scan()
|
||||
end
|
||||
|
||||
function merchant_sell_scan()
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||
|
||||
@@ -23,7 +23,7 @@ function locked(slot)
|
||||
end
|
||||
|
||||
function find_item_slot(partial)
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
if m.matching_item(slot, partial) and not eq(slot, m.state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
@@ -36,7 +36,7 @@ function matching_item(slot, partial)
|
||||
end
|
||||
|
||||
function find_empty_slot()
|
||||
for slot, type in inventory() do
|
||||
for slot, type in inventory do
|
||||
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
|
||||
return slot
|
||||
end
|
||||
@@ -44,7 +44,7 @@ function find_empty_slot()
|
||||
end
|
||||
|
||||
function find_charge_item_slot()
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then
|
||||
return slot
|
||||
end
|
||||
|
||||
+39
-39
@@ -6,16 +6,16 @@ game_tooltip_hooks = {}
|
||||
hooked_setter = nil
|
||||
game_tooltip_money = nil
|
||||
|
||||
function m.LOAD()
|
||||
for func, hook in m.game_tooltip_hooks do
|
||||
function LOAD()
|
||||
for func, hook in game_tooltip_hooks do
|
||||
local func, hook = func, hook
|
||||
aux.hook(
|
||||
func,
|
||||
function(...)
|
||||
m.hooked_setter = true
|
||||
m.game_tooltip_money = 0
|
||||
hooked_setter = true
|
||||
game_tooltip_money = 0
|
||||
local results = {aux.orig[GameTooltip][func](unpack(arg)) }
|
||||
m.hooked_setter = false
|
||||
hooked_setter = false
|
||||
hook(unpack(arg))
|
||||
return unpack(results)
|
||||
end,
|
||||
@@ -29,14 +29,14 @@ function m.LOAD()
|
||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||
local _, _, _, hex = GetItemQualityColor(quality)
|
||||
local link = hex.. '|H'..arg[1]..'|h['..name..']|h'..FONT_COLOR_CODE_CLOSE
|
||||
m.extend_tooltip(ItemRefTooltip, link, 1)
|
||||
extend_tooltip(ItemRefTooltip, link, 1)
|
||||
end
|
||||
return result
|
||||
end)
|
||||
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', function(...)
|
||||
if m.hooked_setter then
|
||||
m.game_tooltip_money = arg1
|
||||
if hooked_setter then
|
||||
game_tooltip_money = arg1
|
||||
else
|
||||
return orig(unpack(arg))
|
||||
end
|
||||
@@ -112,71 +112,71 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
|
||||
local value = aux.history.value(item_key)
|
||||
if auctionable then
|
||||
if g.aux_tooltip_value then
|
||||
if aux_tooltip_value then
|
||||
tooltip:AddLine('Value: '..(value and aux.money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
if g.aux_tooltip_daily then
|
||||
if aux_tooltip_daily then
|
||||
local market_value = aux.history.market_value(item_key)
|
||||
tooltip:AddLine('Today: '..(market_value and aux.money.to_string2(market_value * quantity)..' ('..aux.auction_listing.percentage_historical(round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
if tooltip == GameTooltip and m.game_tooltip_money > 0 then
|
||||
SetTooltipMoney(tooltip, m.game_tooltip_money)
|
||||
if tooltip == GameTooltip and game_tooltip_money > 0 then
|
||||
SetTooltipMoney(tooltip, game_tooltip_money)
|
||||
end
|
||||
tooltip:Show()
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
function game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
local name, _, quality = GetItemInfo(itemstring)
|
||||
if name then
|
||||
local _, _, _, hex = GetItemQualityColor(quality)
|
||||
local link = hex.. '|H'..itemstring..'|h['..name..']|h'..FONT_COLOR_CODE_CLOSE
|
||||
m.extend_tooltip(GameTooltip, link, 1)
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
function game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
local link = GetAuctionItemLink(type, index)
|
||||
if link then
|
||||
local _, _, quantity = GetAuctionItemInfo(type, index)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetLootItem(slot)
|
||||
function game_tooltip_hooks:SetLootItem(slot)
|
||||
local link = GetLootSlotLink(slot)
|
||||
if link then
|
||||
local _, _, quantity = GetLootSlotInfo(slot)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
function game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
local link = GetQuestItemLink(qtype, slot)
|
||||
if link then
|
||||
local _, _, quantity = GetQuestItemInfo(qtype, slot)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
function game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
local link = GetQuestLogItemLink(qtype, slot)
|
||||
if link then
|
||||
local _, _, quantity = GetQuestLogRewardInfo(slot)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
function game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local _, quantity = GetContainerItemInfo(bag, slot)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetInboxItem(index)
|
||||
function game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
|
||||
local id = name and aux.cache.item_id(name)
|
||||
@@ -184,26 +184,26 @@ function m.game_tooltip_hooks:SetInboxItem(index)
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local _, _, _, hex = GetItemQualityColor(tonumber(quality))
|
||||
local link = hex.. '|H'..itemstring..'|h['..name..']|h'..FONT_COLOR_CODE_CLOSE
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetInventoryItem(unit, slot)
|
||||
function game_tooltip_hooks:SetInventoryItem(unit, slot)
|
||||
local link = GetInventoryItemLink(unit, slot)
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, 1)
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetMerchantItem(slot)
|
||||
function game_tooltip_hooks:SetMerchantItem(slot)
|
||||
local link = GetMerchantItemLink(slot)
|
||||
if link then
|
||||
local _, _, _, quantity = GetMerchantItemInfo(slot)
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
function game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link = GetCraftReagentItemLink(skill, slot)
|
||||
@@ -213,18 +213,18 @@ function m.game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
quantity = 1
|
||||
end
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetCraftSpell(slot)
|
||||
function game_tooltip_hooks:SetCraftSpell(slot)
|
||||
local link = GetCraftItemLink(slot)
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, 1)
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
function game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link = GetTradeSkillReagentItemLink(skill, slot)
|
||||
@@ -234,17 +234,17 @@ function m.game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
quantity = 1
|
||||
end
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function m.game_tooltip_hooks:SetAuctionSellItem()
|
||||
function game_tooltip_hooks:SetAuctionSellItem()
|
||||
local name, _, quantity, _, _, _ = GetAuctionSellItemInfo()
|
||||
if name then
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
local link = GetContainerItemLink(unpack(slot))
|
||||
if link and ({aux.info.parse_link(link)})[5] == name then
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -352,7 +352,7 @@ end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
@@ -423,7 +423,7 @@ function update_inventory_records()
|
||||
|
||||
local auction_candidate_map = {}
|
||||
|
||||
for slot in inventory() do
|
||||
for slot in inventory do
|
||||
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ function public.round(x)
|
||||
return floor(x + 0.5)
|
||||
end
|
||||
|
||||
function public.inventory()
|
||||
function public.accessor.inventory()
|
||||
local bag, slot = 0, 0
|
||||
|
||||
return function()
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
|
||||
})
|
||||
end
|
||||
|
||||
local item_query = m.item_query(auction_record.item_id, 1, 1)
|
||||
local item_query = item_query(auction_record.item_id, 1, 1)
|
||||
if not eq(auction_record.blizzard_query, item_query.blizzard_query) then
|
||||
tinsert(queries, item_query)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user