module refactoring
This commit is contained in:
+17
-17
@@ -1,11 +1,11 @@
|
||||
module 'aux.core.tooltip'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
local history = require 'aux.core.history'
|
||||
local auction_listing = require 'aux.gui.auction_listing'
|
||||
@@ -14,23 +14,23 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
|
||||
|
||||
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
settings = character_data('tooltip', {value=true})
|
||||
do
|
||||
local inside_hook = false
|
||||
for name, f in pairs(game_tooltip_hooks) do
|
||||
local name, f = name, f
|
||||
hook(name, GameTooltip, vararg-function(arg)
|
||||
hook(name, GameTooltip, T.vararg-function(arg)
|
||||
inside_hook = true
|
||||
game_tooltip_money = 0
|
||||
local tmp = A(orig[GameTooltip][name](unpack(arg)))
|
||||
local tmp = T.list(orig[GameTooltip][name](unpack(arg)))
|
||||
inside_hook = false
|
||||
f(unpack(arg))
|
||||
return ret(tmp)
|
||||
return T.unpack(tmp)
|
||||
end)
|
||||
end
|
||||
local orig = GameTooltip:GetScript'OnTooltipAddMoney'
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', vararg-function(arg)
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', T.vararg-function(arg)
|
||||
if inside_hook then
|
||||
game_tooltip_money = arg1
|
||||
else
|
||||
@@ -39,22 +39,22 @@ function LOAD()
|
||||
end)
|
||||
end
|
||||
local orig = SetItemRef
|
||||
setglobal('SetItemRef', vararg-function(arg)
|
||||
setglobal('SetItemRef', T.vararg-function(arg)
|
||||
local name, _, quality = GetItemInfo(arg[1])
|
||||
local tmp = A(orig(unpack(arg)))
|
||||
local tmp = T.list(orig(unpack(arg)))
|
||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||
local color_code = select(4, GetItemQualityColor(quality))
|
||||
local link = color_code .. '|H' .. arg[1] .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
extend_tooltip(ItemRefTooltip, link, 1)
|
||||
end
|
||||
return ret(tmp)
|
||||
return T.unpack(tmp)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.extend_tooltip(tooltip, link, quantity)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
local item_info = temp-info.item(item_id)
|
||||
local item_info = T.temp-info.item(item_id)
|
||||
if item_info then
|
||||
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
if getn(distribution) > 0 then
|
||||
@@ -72,18 +72,18 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
if settings.merchant_buy then
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
local _, price, limited = info.merchant_info(item_id)
|
||||
if price then
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.tooltip.merchant())
|
||||
end
|
||||
end
|
||||
if settings.merchant_sell then
|
||||
local price = cache.merchant_info(item_id)
|
||||
local price = info.merchant_info(item_id)
|
||||
if price ~= 0 then
|
||||
tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), color.tooltip.merchant())
|
||||
end
|
||||
end
|
||||
local auctionable = not item_info or info.auctionable(temp-info.tooltip('link', item_info.itemstring), item_info.quality)
|
||||
local auctionable = not item_info or info.auctionable(T.temp-info.tooltip('link', item_info.itemstring), item_info.quality)
|
||||
local item_key = (item_id or 0) .. ':' .. (suffix_id or 0)
|
||||
local value = history.value(item_key)
|
||||
if auctionable then
|
||||
@@ -148,7 +148,7 @@ end
|
||||
|
||||
function game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
local id = name and cache.item_id(name)
|
||||
local id = name and info.item_id(name)
|
||||
if id then
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local hex = select(4, GetItemQualityColor(tonumber(quality)))
|
||||
@@ -206,8 +206,8 @@ end
|
||||
function game_tooltip_hooks:SetAuctionSellItem()
|
||||
local name, _, quantity = GetAuctionSellItemInfo()
|
||||
if name then
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local link = GetContainerItemLink(unpack(slot))
|
||||
if link and select(5, info.parse_link(link)) == name then
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
|
||||
Reference in New Issue
Block a user