module refactoring
This commit is contained in:
+24
-25
@@ -1,9 +1,8 @@
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
local T = require 'T'
|
||||
|
||||
CreateFrame('GameTooltip', 'AuxTooltip', nil, 'GameTooltipTemplate')
|
||||
AuxTooltip:SetScript('OnTooltipAddMoney', function()
|
||||
@@ -38,7 +37,7 @@ do
|
||||
INVTYPE_TABARD = {19},
|
||||
}
|
||||
function M.inventory_index(slot)
|
||||
return unpack(inventory_index_map[slot] or temp-T)
|
||||
return unpack(inventory_index_map[slot] or T.temp-T.acquire())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,14 +45,14 @@ function M.container_item(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-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 = tooltip('bag', bag, slot)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -88,7 +87,7 @@ end
|
||||
|
||||
function M.auction_sell_item()
|
||||
for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do
|
||||
return O(
|
||||
return T.map(
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
'quality', quality,
|
||||
@@ -105,7 +104,7 @@ function M.auction(index, query_type)
|
||||
local link = GetAuctionItemLink(query_type, index)
|
||||
if link then
|
||||
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
|
||||
local item_info = temp-item(item_id, suffix_id, unique_id, enchant_id)
|
||||
local item_info = T.temp-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)
|
||||
|
||||
@@ -117,7 +116,7 @@ function M.auction(index, query_type)
|
||||
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
|
||||
|
||||
return O(
|
||||
return T.map(
|
||||
'item_id', item_id,
|
||||
'suffix_id', suffix_id,
|
||||
'unique_id', unique_id,
|
||||
@@ -126,8 +125,8 @@ function M.auction(index, query_type)
|
||||
'link', link,
|
||||
'itemstring', item_info.itemstring,
|
||||
'item_key', item_id .. ':' .. suffix_id,
|
||||
'search_signature', join(temp-A(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 (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'search_signature', join(T.temp-T.list(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 (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
'sniping_signature', join(T.temp-T.list(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
|
||||
|
||||
'name', name,
|
||||
'texture', texture,
|
||||
@@ -171,7 +170,7 @@ function M.bid_update(auction_record)
|
||||
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity
|
||||
auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
|
||||
auction_record.high_bidder = 1
|
||||
auction_record.search_signature = join(temp-A(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (cache.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
|
||||
auction_record.search_signature = join(T.temp-T.list(auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
|
||||
end
|
||||
|
||||
function M.set_tooltip(itemstring, owner, anchor)
|
||||
@@ -181,7 +180,7 @@ end
|
||||
|
||||
function M.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = temp-T
|
||||
local tooltips = T.temp-T.acquire()
|
||||
if index1 then
|
||||
local tooltip = tooltip('inventory', 'player', index1)
|
||||
if getn(tooltip) > 0 then
|
||||
@@ -196,14 +195,14 @@ function M.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[1], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_NONE')
|
||||
ShoppingTooltip1:SetPoint('TOPLEFT', GameTooltip, 'TOPRIGHT', 0, -10)
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5)))
|
||||
tinsert(tooltips[2], 1, T.temp-T.map('left_text', 'Currently Equipped', 'left_color', T.temp-T.list(.5, .5, .5)))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_NONE')
|
||||
ShoppingTooltip2:SetPoint('TOPLEFT', ShoppingTooltip1, 'TOPRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
@@ -284,13 +283,13 @@ function M.tooltip(setter, arg1, arg2)
|
||||
elseif setter == 'link' then
|
||||
AuxTooltip:SetHyperlink(arg1)
|
||||
end
|
||||
local tooltip = T
|
||||
local tooltip = T.acquire()
|
||||
for i = 1, AuxTooltip:NumLines() do
|
||||
tinsert(tooltip, O(
|
||||
tinsert(tooltip, T.map(
|
||||
'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(),
|
||||
'left_color', A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'left_color', T.list(_G['AuxTooltipTextLeft' .. i]:GetTextColor()),
|
||||
'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(),
|
||||
'right_color', A(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
'right_color', T.list(_G['AuxTooltipTextRight' .. i]:GetTextColor())
|
||||
))
|
||||
end
|
||||
return tooltip, AuxTooltip.money
|
||||
@@ -372,7 +371,7 @@ end
|
||||
function M.item(item_id, suffix_id)
|
||||
local itemstring = 'item:' .. (item_id or 0) .. ':0:' .. (suffix_id or 0) .. ':0'
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and O(
|
||||
return name and T.map(
|
||||
'name', name,
|
||||
'itemstring', itemstring,
|
||||
'quality', quality,
|
||||
@@ -382,11 +381,11 @@ function M.item(item_id, suffix_id)
|
||||
'slot', slot,
|
||||
'max_stack', max_stack,
|
||||
'texture', texture
|
||||
) or cache.item_info(item_id)
|
||||
) or item_info(item_id)
|
||||
end
|
||||
|
||||
function M.item_class_index(item_class)
|
||||
for i, class in pairs(temp-A(GetAuctionItemClasses())) do
|
||||
for i, class in pairs(T.temp-T.list(GetAuctionItemClasses())) do
|
||||
if strupper(class) == strupper(item_class) then
|
||||
return i, class
|
||||
end
|
||||
@@ -394,7 +393,7 @@ function M.item_class_index(item_class)
|
||||
end
|
||||
|
||||
function M.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in pairs(temp-A(GetAuctionItemSubClasses(class_index))) do
|
||||
for i, subclass in pairs(T.temp-T.list(GetAuctionItemSubClasses(class_index))) do
|
||||
if strupper(subclass) == strupper(item_subclass) then
|
||||
return i, subclass
|
||||
end
|
||||
@@ -402,7 +401,7 @@ function M.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
|
||||
function M.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in pairs(temp-A(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
for i, slot in pairs(T.temp-T.list(GetAuctionInvTypes(class_index, subclass_index))) do
|
||||
if strupper(_G[slot]) == strupper(slot_name) then
|
||||
return i, _G[slot]
|
||||
end
|
||||
@@ -418,7 +417,7 @@ function M.item_quality_index(item_quality)
|
||||
end
|
||||
end
|
||||
|
||||
function M.get.inventory()
|
||||
function M.inventory()
|
||||
local bag, slot = 0, 0
|
||||
return function()
|
||||
if not GetBagName(bag) or slot >= GetContainerNumSlots(bag) then
|
||||
@@ -427,7 +426,7 @@ function M.get.inventory()
|
||||
else
|
||||
slot = slot + 1
|
||||
end
|
||||
if bag <= 4 then return A(bag, slot), bag_type(bag) end
|
||||
if bag <= 4 then return T.list(bag, slot), bag_type(bag) end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user