refactoring
This commit is contained in:
+4
-4
@@ -208,7 +208,7 @@ public.filters = {
|
||||
|
||||
function operator(str)
|
||||
local operator = str == 'not' and {'operator', 'not', 1}
|
||||
for name in -set 'and', 'or' do
|
||||
for name in -set('and', 'or') do
|
||||
for arity in present(select(3, strfind(str, '^'..name..'(%d*)$'))) do
|
||||
arity = tonumber(arity)
|
||||
operator = not (arity and arity < 2) and {'operator', name, arity}
|
||||
@@ -319,7 +319,7 @@ function public.parse_query_string(str)
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return -object :blizzard(blizzard_filter_parser()) :post(post_filter)
|
||||
return -object('blizzard', blizzard_filter_parser(), 'post', post_filter)
|
||||
end
|
||||
|
||||
function public.query(query_string)
|
||||
@@ -496,7 +496,7 @@ end
|
||||
function blizzard_query(components)
|
||||
local filters = components.blizzard
|
||||
|
||||
local query = -object :name(filters.name and filters.name[2])
|
||||
local query = -object('name', filters.name and filters.name[2])
|
||||
|
||||
local item_info, class_index, subclass_index, slot_index
|
||||
local item_id = cache.item_id(filters.name[2])
|
||||
@@ -517,7 +517,7 @@ function blizzard_query(components)
|
||||
query.slot = slot_index
|
||||
query.quality = item_info.quality
|
||||
else
|
||||
for key in temp-set 'min_level' 'max_level' 'class' 'subclass' 'slot' 'usable' 'quality' do
|
||||
for key in temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do
|
||||
query[key] = index(filters[key], 2)
|
||||
end
|
||||
end
|
||||
|
||||
+11
-12
@@ -44,11 +44,10 @@ function public.container_item(bag, slot)
|
||||
local item_info = 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(function(tt) tt:SetBagItem(bag, slot) end)
|
||||
local tooltip, tooltip_money = tooltip(function(tooltip) tooltip:SetBagItem(bag, slot) end)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
|
||||
return {
|
||||
item_id = item_id,
|
||||
suffix_id = suffix_id,
|
||||
@@ -105,7 +104,7 @@ function public.auction(index, query_type)
|
||||
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 tooltip, tooltip_money = tooltip(function(tt) tt:SetAuctionItem(query_type, index) end)
|
||||
local tooltip, tooltip_money = tooltip(function(tooltip) tooltip:SetAuctionItem(query_type, index) end)
|
||||
local max_charges = max_item_charges(item_id)
|
||||
local charges = max_charges and item_charges(tooltip)
|
||||
local aux_quantity = charges or count
|
||||
@@ -121,8 +120,8 @@ function public.auction(index, query_type)
|
||||
link = link,
|
||||
itemstring = item_info.itemstring,
|
||||
item_key = item_id..':'..suffix_id,
|
||||
search_signature = 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), _g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
|
||||
sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
|
||||
search_signature = join(temp-{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), _g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
|
||||
sniping_signature = join(temp-{item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
|
||||
|
||||
name = name,
|
||||
texture = texture,
|
||||
@@ -166,7 +165,7 @@ function public.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({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, _g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':')
|
||||
auction_record.search_signature = join(temp-{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, _g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':')
|
||||
end
|
||||
|
||||
function public.set_tooltip(itemstring, owner, anchor)
|
||||
@@ -178,20 +177,20 @@ function public.set_shopping_tooltip(slot)
|
||||
local index1, index2 = inventory_index(slot)
|
||||
local tooltips = tt
|
||||
if index1 then
|
||||
local tooltip = tooltip(function(tt) tt:SetInventoryItem('player', index1) end)
|
||||
local tooltip = tooltip(function(tooltip) tooltip:SetInventoryItem('player', index1) end)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
end
|
||||
if index2 then
|
||||
local tooltip = tooltip(function(tt) tt:SetInventoryItem('player', index2) end)
|
||||
local tooltip = tooltip(function(tooltip) tooltip:SetInventoryItem('player', index2) end)
|
||||
if getn(tooltip) > 0 then
|
||||
tinsert(tooltips, tooltip)
|
||||
end
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, temp-object :left_text 'Currently Equipped' :left_color(temp-{.5, .5, .5}))
|
||||
tinsert(tooltips[1], 1, temp-object('left_text', 'Currently Equipped', 'left_color', temp-list(.5, .5, .5)))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
ShoppingTooltip1:Show()
|
||||
@@ -199,7 +198,7 @@ function public.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, temp-object :left_text 'Currently Equipped' :left_color(temp-{.5, .5, .5}))
|
||||
tinsert(tooltips[2], 1, temp-object('left_text', 'Currently Equipped', 'left_color', temp-list(.5, .5, .5)))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
ShoppingTooltip2:Show()
|
||||
@@ -267,10 +266,10 @@ function public.auctionable(tooltip, quality, lootable)
|
||||
and not (durability and durability < max_durability)
|
||||
end
|
||||
|
||||
function public.tooltip(mutator)
|
||||
function public.tooltip(setter)
|
||||
AuxTooltip:SetOwner(UIParent, 'ANCHOR_NONE')
|
||||
AuxTooltip.money = 0
|
||||
mutator(AuxTooltip)
|
||||
setter(AuxTooltip)
|
||||
AuxTooltip:Show()
|
||||
|
||||
local tooltip = t
|
||||
|
||||
+3
-5
@@ -19,13 +19,13 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
|
||||
local blizzard_query1 = copy(auction_record.blizzard_query)
|
||||
blizzard_query1.first_page = auction_record.page
|
||||
blizzard_query1.last_page = auction_record.page
|
||||
tinsert(queries, -object :blizzard_query(blizzard_query1))
|
||||
tinsert(queries, -object('blizzard_query', blizzard_query1))
|
||||
|
||||
if auction_record.page > 0 then
|
||||
local blizzard_query2 = copy(auction_record.blizzard_query)
|
||||
blizzard_query2.first_page = auction_record.page - 1
|
||||
blizzard_query2.last_page = auction_record.page - 1
|
||||
tinsert(queries, -object :blizzard_query(blizzard_query2))
|
||||
tinsert(queries, -object('blizzard_query', blizzard_query2))
|
||||
end
|
||||
|
||||
local item_query = item_query(auction_record.item_id, 1, 1)
|
||||
@@ -78,8 +78,6 @@ function public.item_query(item_id, first_page, last_page)
|
||||
local query = filter_util.query(item_info.name..'/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return -object
|
||||
:validator(query.validator)
|
||||
:blizzard_query(query.blizzard_query)
|
||||
return -object('validator', query.validator, 'blizzard_query', query.blizzard_query)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user