refactoring
This commit is contained in:
@@ -2,26 +2,6 @@ local addon = aux_module()
|
|||||||
aux = tremove(addon, 1)
|
aux = tremove(addon, 1)
|
||||||
local m, public, private = unpack(addon)
|
local m, public, private = unpack(addon)
|
||||||
|
|
||||||
--m.enum TODO
|
|
||||||
--setmetatable({}, { aux -> aux
|
|
||||||
-- __index = function(self, key)
|
|
||||||
-- self[key] = true
|
|
||||||
-- return self
|
|
||||||
-- end,
|
|
||||||
-- __call = function(self, key)
|
|
||||||
-- for key in self do
|
|
||||||
-- decl[key] =
|
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
--})
|
|
||||||
--.INVTYPE_HEAD
|
|
||||||
--.INVTYPE_NECK
|
|
||||||
--.INVTYPE_SHOULDER
|
|
||||||
--()
|
|
||||||
|
|
||||||
--for notnil in {maybenil} do TODO
|
|
||||||
--end
|
|
||||||
|
|
||||||
private.modules = { aux }
|
private.modules = { aux }
|
||||||
function public.module(name)
|
function public.module(name)
|
||||||
local module = aux_module()
|
local module = aux_module()
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ function public.values(t)
|
|||||||
return vs
|
return vs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function public.select(i, ...)
|
||||||
|
return arg[i]
|
||||||
|
end
|
||||||
|
|
||||||
function public.eq(t1, t2)
|
function public.eq(t1, t2)
|
||||||
if not t1 or not t2 then
|
if not t1 or not t2 then
|
||||||
return false
|
return false
|
||||||
|
|||||||
+102
-118
@@ -1,7 +1,5 @@
|
|||||||
local m, public, private = aux.module'info'
|
local m, public, private = aux.module'info'
|
||||||
|
|
||||||
local TOOLTIP_LENGTH = 30
|
|
||||||
|
|
||||||
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
|
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
|
||||||
AuxTooltip:SetScript('OnTooltipAddMoney', function()
|
AuxTooltip:SetScript('OnTooltipAddMoney', function()
|
||||||
this.money = arg1
|
this.money = arg1
|
||||||
@@ -40,51 +38,48 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.container_item(bag, slot)
|
function public.container_item(bag, slot)
|
||||||
local hyperlink = GetContainerItemLink(bag, slot)
|
for _, hyperlink in {GetContainerItemLink(bag, slot)} do
|
||||||
|
|
||||||
if not hyperlink then
|
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||||
return
|
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||||
|
|
||||||
|
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
||||||
|
local tooltip, tooltip_money = m.tooltip(function(tt) tt:SetBagItem(bag, slot) end)
|
||||||
|
local max_charges = m.max_item_charges(item_id)
|
||||||
|
local charges = max_charges and m.item_charges(tooltip)
|
||||||
|
local aux_quantity = charges or count
|
||||||
|
|
||||||
|
return {
|
||||||
|
item_id = item_id,
|
||||||
|
suffix_id = suffix_id,
|
||||||
|
unique_id = unique_id,
|
||||||
|
enchant_id = enchant_id,
|
||||||
|
|
||||||
|
hyperlink = hyperlink,
|
||||||
|
itemstring = item_info.itemstring,
|
||||||
|
item_key = item_id..':'..suffix_id,
|
||||||
|
|
||||||
|
name = item_info.name,
|
||||||
|
texture = texture,
|
||||||
|
level = item_info.level,
|
||||||
|
type = item_info.type,
|
||||||
|
subtype = item_info.subtype,
|
||||||
|
slot = item_info.slot,
|
||||||
|
quality = item_info.quality,
|
||||||
|
max_stack = item_info.max_stack,
|
||||||
|
|
||||||
|
count = count,
|
||||||
|
locked = locked,
|
||||||
|
readable = readable,
|
||||||
|
lootable = lootable,
|
||||||
|
|
||||||
|
tooltip = tooltip,
|
||||||
|
tooltip_money = tooltip_money,
|
||||||
|
max_charges = max_charges,
|
||||||
|
charges = charges,
|
||||||
|
aux_quantity = aux_quantity,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
|
||||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
|
||||||
|
|
||||||
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
|
||||||
local tooltip, tooltip_money = m.tooltip(function(tt) tt:SetBagItem(bag, slot) end)
|
|
||||||
local max_charges = m.max_item_charges(item_id)
|
|
||||||
local charges = max_charges and m.item_charges(tooltip)
|
|
||||||
local aux_quantity = charges or count
|
|
||||||
|
|
||||||
return {
|
|
||||||
item_id = item_id,
|
|
||||||
suffix_id = suffix_id,
|
|
||||||
unique_id = unique_id,
|
|
||||||
enchant_id = enchant_id,
|
|
||||||
|
|
||||||
hyperlink = hyperlink,
|
|
||||||
itemstring = item_info.itemstring,
|
|
||||||
item_key = item_id..':'..suffix_id,
|
|
||||||
|
|
||||||
name = item_info.name,
|
|
||||||
texture = texture,
|
|
||||||
level = item_info.level,
|
|
||||||
type = item_info.type,
|
|
||||||
subtype = item_info.subtype,
|
|
||||||
slot = item_info.slot,
|
|
||||||
quality = item_info.quality,
|
|
||||||
max_stack = item_info.max_stack,
|
|
||||||
|
|
||||||
count = count,
|
|
||||||
locked = locked,
|
|
||||||
readable = readable,
|
|
||||||
lootable = lootable,
|
|
||||||
|
|
||||||
tooltip = tooltip,
|
|
||||||
tooltip_money = tooltip_money,
|
|
||||||
max_charges = max_charges,
|
|
||||||
charges = charges,
|
|
||||||
aux_quantity = aux_quantity,
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.auction_sell_item()
|
function public.auction_sell_item()
|
||||||
@@ -105,68 +100,65 @@ end
|
|||||||
function public.auction(index, query_type)
|
function public.auction(index, query_type)
|
||||||
query_type = query_type or 'list'
|
query_type = query_type or 'list'
|
||||||
|
|
||||||
local hyperlink = GetAuctionItemLink(query_type, index)
|
for _, hyperlink in {GetAuctionItemLink(query_type, index)} do
|
||||||
|
|
||||||
if not hyperlink then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||||
|
|
||||||
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index)
|
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index)
|
||||||
|
|
||||||
local duration = GetAuctionItemTimeLeft(query_type, index)
|
local duration = GetAuctionItemTimeLeft(query_type, index)
|
||||||
local tooltip, tooltip_money = m.tooltip(function(tt) tt:SetAuctionItem(query_type, index) end)
|
local tooltip, tooltip_money = m.tooltip(function(tt) tt:SetAuctionItem(query_type, index) end)
|
||||||
local max_charges = m.max_item_charges(item_id)
|
local max_charges = m.max_item_charges(item_id)
|
||||||
local charges = max_charges and m.item_charges(tooltip)
|
local charges = max_charges and m.item_charges(tooltip)
|
||||||
local aux_quantity = charges or count
|
local aux_quantity = charges or count
|
||||||
local blizzard_bid = high_bid > 0 and high_bid or start_price
|
local blizzard_bid = high_bid > 0 and high_bid or start_price
|
||||||
local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price
|
local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price
|
||||||
|
|
||||||
return {
|
return {
|
||||||
item_id = item_id,
|
item_id = item_id,
|
||||||
suffix_id = suffix_id,
|
suffix_id = suffix_id,
|
||||||
unique_id = unique_id,
|
unique_id = unique_id,
|
||||||
enchant_id = enchant_id,
|
enchant_id = enchant_id,
|
||||||
|
|
||||||
hyperlink = hyperlink,
|
hyperlink = hyperlink,
|
||||||
itemstring = item_info.itemstring,
|
itemstring = item_info.itemstring,
|
||||||
item_key = item_id..':'..suffix_id,
|
item_key = item_id..':'..suffix_id,
|
||||||
search_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
|
search_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
|
||||||
sniping_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
|
sniping_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
|
||||||
|
|
||||||
name = name,
|
name = name,
|
||||||
texture = texture,
|
texture = texture,
|
||||||
level = item_info.level,
|
level = item_info.level,
|
||||||
type = item_info.type,
|
type = item_info.type,
|
||||||
subtype = item_info.subtype,
|
subtype = item_info.subtype,
|
||||||
slot = item_info.slot,
|
slot = item_info.slot,
|
||||||
quality = quality,
|
quality = quality,
|
||||||
max_stack = item_info.max_stack,
|
max_stack = item_info.max_stack,
|
||||||
|
|
||||||
count = count,
|
count = count,
|
||||||
start_price = start_price,
|
start_price = start_price,
|
||||||
high_bid = high_bid,
|
high_bid = high_bid,
|
||||||
min_increment = min_increment,
|
min_increment = min_increment,
|
||||||
blizzard_bid = blizzard_bid,
|
blizzard_bid = blizzard_bid,
|
||||||
bid_price = bid_price,
|
bid_price = bid_price,
|
||||||
buyout_price = buyout_price,
|
buyout_price = buyout_price,
|
||||||
unit_blizzard_bid = blizzard_bid / aux_quantity,
|
unit_blizzard_bid = blizzard_bid / aux_quantity,
|
||||||
unit_bid_price = bid_price / aux_quantity,
|
unit_bid_price = bid_price / aux_quantity,
|
||||||
unit_buyout_price = buyout_price / aux_quantity,
|
unit_buyout_price = buyout_price / aux_quantity,
|
||||||
high_bidder = high_bidder,
|
high_bidder = high_bidder,
|
||||||
owner = owner,
|
owner = owner,
|
||||||
sale_status = sale_status,
|
sale_status = sale_status,
|
||||||
duration = duration,
|
duration = duration,
|
||||||
usable = usable,
|
usable = usable,
|
||||||
|
|
||||||
tooltip = tooltip,
|
tooltip = tooltip,
|
||||||
tooltip_money = tooltip_money,
|
tooltip_money = tooltip_money,
|
||||||
max_charges = max_charges,
|
max_charges = max_charges,
|
||||||
charges = charges,
|
charges = charges,
|
||||||
aux_quantity = aux_quantity,
|
aux_quantity = aux_quantity,
|
||||||
}
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.bid_update(auction_record)
|
function public.bid_update(auction_record)
|
||||||
@@ -244,6 +236,7 @@ function public.tooltip_find(pattern, tooltip)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.load_tooltip(frame, tooltip)
|
function public.load_tooltip(frame, tooltip)
|
||||||
|
tooltip:ClearLines()
|
||||||
for _, line in tooltip do
|
for _, line in tooltip do
|
||||||
if line.right_text then
|
if line.right_text then
|
||||||
frame:AddDoubleLine(line.left_text, line.right_text, line.left_color[1], line.left_color[2], line.left_color[3], line.right_color[1], line.right_color[2], line.right_color[3])
|
frame:AddDoubleLine(line.left_text, line.right_text, line.left_color[1], line.left_color[2], line.left_color[3], line.right_color[1], line.right_color[2], line.right_color[3])
|
||||||
@@ -251,15 +244,14 @@ function public.load_tooltip(frame, tooltip)
|
|||||||
frame:AddLine(line.left_text, line.left_color[1], line.left_color[2], line.left_color[3], true)
|
frame:AddLine(line.left_text, line.left_color[1], line.left_color[2], line.left_color[3], true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1,TOOLTIP_LENGTH do -- TODO why is this needed?
|
for i =1,getn(tooltip) do -- TODO why is this needed?
|
||||||
getglobal(frame:GetName()..'TextLeft'..i):SetJustifyH('LEFT')
|
getglobal(frame:GetName()..'TextLeft'..i):SetJustifyH('LEFT')
|
||||||
getglobal(frame:GetName()..'TextRight'..i):SetJustifyH('LEFT')
|
getglobal(frame:GetName()..'TextRight'..i):SetJustifyH('LEFT')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.display_name(item_id, no_brackets, no_color)
|
function public.display_name(item_id, no_brackets, no_color)
|
||||||
local item_info = aux.info.item(item_id)
|
for _, item_info in {aux.info.item(item_id)} do
|
||||||
if item_info then
|
|
||||||
local name = item_info.name
|
local name = item_info.name
|
||||||
if not no_brackets then
|
if not no_brackets then
|
||||||
name = '['..name..']'
|
name = '['..name..']'
|
||||||
@@ -289,21 +281,13 @@ function public.tooltip(setter)
|
|||||||
AuxTooltip:Show()
|
AuxTooltip:Show()
|
||||||
|
|
||||||
local tooltip = {}
|
local tooltip = {}
|
||||||
for i = 1,TOOLTIP_LENGTH do
|
for i = 1,AuxTooltip:NumLines() do
|
||||||
local left_text = getglobal('AuxTooltipTextLeft'..i):GetText()
|
tinsert(tooltip, {
|
||||||
local left_color = { getglobal('AuxTooltipTextLeft'..i):GetTextColor() }
|
left_text = getglobal('AuxTooltipTextLeft'..i):GetText(),
|
||||||
|
left_color = {getglobal('AuxTooltipTextLeft'..i):GetTextColor()},
|
||||||
local right_text = getglobal('AuxTooltipTextRight'..i):IsVisible() and getglobal('AuxTooltipTextRight'..i):GetText() -- the right side is only hidden, not cleared
|
right_text = getglobal('AuxTooltipTextRight'..i):IsVisible() and getglobal('AuxTooltipTextRight'..i):GetText(),
|
||||||
local right_color = { getglobal('AuxTooltipTextRight'..i):GetTextColor() }
|
right_color = {getglobal('AuxTooltipTextRight'..i):GetTextColor()},
|
||||||
|
})
|
||||||
if left_text or right_text then
|
|
||||||
tinsert(tooltip, {
|
|
||||||
left_text = left_text,
|
|
||||||
left_color = left_color,
|
|
||||||
right_text = right_text,
|
|
||||||
right_color = right_color,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return tooltip, AuxTooltip.money
|
return tooltip, AuxTooltip.money
|
||||||
|
|||||||
Reference in New Issue
Block a user