imported the util core module
This commit is contained in:
+10
-10
@@ -92,7 +92,7 @@ function update_inventory_listing()
|
||||
return
|
||||
end
|
||||
|
||||
aux.item_listing.populate(m.item_listing, aux.util.values(aux.util.filter(m.inventory_records, function(record)
|
||||
aux.item_listing.populate(m.item_listing, values(filter(m.inventory_records, function(record)
|
||||
local settings = m.read_settings(record.key)
|
||||
return record.aux_quantity > 0 and (not settings.hidden or m.show_hidden_checkbox:GetChecked())
|
||||
end)))
|
||||
@@ -145,9 +145,9 @@ function update_auction_listing()
|
||||
{value=aux.auction_listing.time_left(auction_record.duration)},
|
||||
{value=auction_record.stack_size == stack_size and aux.gui.color.yellow(auction_record.stack_size) or auction_record.stack_size},
|
||||
{value=aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
|
||||
{value=historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'},
|
||||
{value=historical_value and aux.auction_listing.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'},
|
||||
{value=auction_record.unit_buyout_price > 0 and aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'},
|
||||
{value=auction_record.unit_buyout_price > 0 and historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_buyout_price / historical_value * 100)) or '---'},
|
||||
{value=auction_record.unit_buyout_price > 0 and historical_value and aux.auction_listing.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---'},
|
||||
},
|
||||
record = auction_record,
|
||||
})
|
||||
@@ -175,7 +175,7 @@ function update_auction_listing()
|
||||
end
|
||||
|
||||
function public.select_item(item_key)
|
||||
for _, inventory_record in aux.util.filter(m.inventory_records, function(record) return record.aux_quantity > 0 end) do
|
||||
for _, inventory_record in filter(m.inventory_records, function(record) return record.aux_quantity > 0 end) do
|
||||
if inventory_record.key == item_key then
|
||||
m.set_item(inventory_record)
|
||||
break
|
||||
@@ -190,12 +190,12 @@ function price_update()
|
||||
local start_price_input = m.get_unit_start_price()
|
||||
settings.start_price = start_price_input
|
||||
local historical_value = aux.history.value(m.selected_item.key)
|
||||
m.start_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(aux.util.round(start_price_input / historical_value * 100)) or '---')
|
||||
m.start_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(round(start_price_input / historical_value * 100)) or '---')
|
||||
|
||||
local buyout_price_input = m.get_unit_buyout_price()
|
||||
settings.buyout_price = buyout_price_input
|
||||
local historical_value = aux.history.value(m.selected_item.key)
|
||||
m.buyout_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(aux.util.round(buyout_price_input / historical_value * 100)) or '---')
|
||||
m.buyout_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(round(buyout_price_input / historical_value * 100)) or '---')
|
||||
|
||||
m.write_settings(settings)
|
||||
end
|
||||
@@ -328,8 +328,8 @@ function update_item_configuration()
|
||||
end
|
||||
|
||||
function undercut(record, stack_size, stack)
|
||||
local start_price = aux.util.round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
|
||||
local buyout_price = aux.util.round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
|
||||
local start_price = round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
|
||||
local buyout_price = round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
|
||||
|
||||
if not record.own then
|
||||
start_price = max(0, start_price - 1)
|
||||
@@ -352,7 +352,7 @@ end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
|
||||
for slot in aux.util.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 aux.util.inventory() do
|
||||
for slot in inventory() do
|
||||
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
|
||||
@@ -69,7 +69,7 @@ function create_frames()
|
||||
auction_listing:EnableSorting(false)
|
||||
auction_listing:DisableSelection(true)
|
||||
auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
local column_index = aux.util.key(column, column.row.cols)
|
||||
local column_index = key(column, column.row.cols)
|
||||
local unit_start_price, unit_buyout_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton')
|
||||
if column_index == 3 then
|
||||
stack_size_slider:SetValue(row_data.record.stack_size)
|
||||
|
||||
@@ -106,7 +106,7 @@ end
|
||||
|
||||
function public.add_filter(filter_string)
|
||||
local old_filter_string = m.search_box:GetText()
|
||||
old_filter_string = aux.util.trim(old_filter_string)
|
||||
old_filter_string = trim(old_filter_string)
|
||||
|
||||
if old_filter_string ~= '' then
|
||||
old_filter_string = old_filter_string..';'
|
||||
|
||||
@@ -2,7 +2,7 @@ aux.module 'search_tab'
|
||||
|
||||
function valid_level(str)
|
||||
local level = tonumber(str)
|
||||
return level and aux.util.bound(1, 60, level)
|
||||
return level and bound(1, 60, level)
|
||||
end
|
||||
|
||||
blizzard_query = setmetatable({}, {
|
||||
@@ -92,7 +92,7 @@ function update_form()
|
||||
m.usable_checkbox:Enable()
|
||||
end
|
||||
|
||||
if aux.util.any({'min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'}, function(key) return m.blizzard_query[key] end) then
|
||||
if any({'min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'}, function(key) return m.blizzard_query[key] end) then
|
||||
m.exact_checkbox:Disable()
|
||||
else
|
||||
m.exact_checkbox:Enable()
|
||||
@@ -171,7 +171,7 @@ function clear_form()
|
||||
end
|
||||
|
||||
function import_query_string()
|
||||
local components, error = aux.filter.parse_query_string(aux.util.select(3, strfind(m.search_box:GetText(), '^([^;]*)')))
|
||||
local components, error = aux.filter.parse_query_string(select(3, strfind(m.search_box:GetText(), '^([^;]*)')))
|
||||
if components then
|
||||
m.set_form(components)
|
||||
else
|
||||
@@ -206,7 +206,7 @@ function public.formatted_post_filter(components)
|
||||
component_text = component_text..filter_color(tonumber(component[3]) or '')
|
||||
tinsert(stack, component[3])
|
||||
elseif component[1] == 'filter' then
|
||||
for parameter in aux.util.present(component[3]) do
|
||||
for parameter in present(component[3]) do
|
||||
if component[2] == 'item' then
|
||||
parameter = aux.info.display_name(aux.cache.item_id(parameter)) or '['..parameter..']'
|
||||
elseif aux.filter.filters[component[2]].input_type == 'money' then
|
||||
@@ -261,8 +261,8 @@ function add_component(component)
|
||||
end
|
||||
|
||||
function add_post_filter()
|
||||
for str in aux.util.present(m.filter_input:GetText()) do
|
||||
for filter in aux.util.present(aux.filter.filters[str]) do
|
||||
for str in present(m.filter_input:GetText()) do
|
||||
for filter in present(aux.filter.filters[str]) do
|
||||
if filter.input_type ~= '' then
|
||||
str = str..'/'..m.filter_parameter_input:GetText()
|
||||
end
|
||||
@@ -314,8 +314,8 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
local x_upper_bound = 0
|
||||
local y_lower_bound = 0
|
||||
local y_upper_bound = max(0, height - scroll_frame:GetHeight())
|
||||
scroll_frame:SetHorizontalScroll(aux.util.bound(x_lower_bound, x_upper_bound, x_offset))
|
||||
scroll_frame:SetVerticalScroll(aux.util.bound(y_lower_bound, y_upper_bound, y_offset))
|
||||
scroll_frame:SetHorizontalScroll(bound(x_lower_bound, x_upper_bound, x_offset))
|
||||
scroll_frame:SetVerticalScroll(bound(y_lower_bound, y_upper_bound, y_offset))
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
|
||||
@@ -336,7 +336,7 @@ function create_frames()
|
||||
if filters then
|
||||
tinsert(g.aux_favorite_searches, 1, {
|
||||
filter_string = search_box:GetText(),
|
||||
prettified = table.concat(aux.util.map(filters, function(filter) return filter.prettified end), ';'),
|
||||
prettified = table.concat(map(filters, function(filter) return filter.prettified end), ';'),
|
||||
})
|
||||
end
|
||||
update_search_listings()
|
||||
@@ -536,7 +536,7 @@ function create_frames()
|
||||
input:SetScript('OnTabPressed', function()
|
||||
filter_parameter_input:SetFocus()
|
||||
end)
|
||||
input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(aux.util.keys(aux.filter.filters))} end)
|
||||
input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(keys(aux.filter.filters))} end)
|
||||
input:SetScript('OnChar', function()
|
||||
this:complete()
|
||||
end)
|
||||
@@ -583,7 +583,7 @@ function create_frames()
|
||||
scroll_frame:EnableMouseWheel(true)
|
||||
scroll_frame:SetScript('OnMouseWheel', function()
|
||||
local child = this:GetScrollChild()
|
||||
child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.util.bound(11, 23, aux.util.select(2, child:GetFont()) + arg1*2))
|
||||
child:SetFont('p', [[Fonts\ARIALN.TTF]], bound(11, 23, select(2, child:GetFont()) + arg1*2))
|
||||
update_filter_display()
|
||||
end)
|
||||
scroll_frame:RegisterForDrag('LeftButton')
|
||||
|
||||
@@ -119,7 +119,7 @@ function update_auto_buy_filter()
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
aux.log('Error: The automatic buyout filter may contain only one query')
|
||||
elseif aux.util.size(queries[1].blizzard_query) > 0 then
|
||||
elseif size(queries[1].blizzard_query) > 0 then
|
||||
aux.log('Error: The automatic buyout filter does not support Blizzard filters')
|
||||
else
|
||||
m.auto_buy_validator = queries[1].validator
|
||||
@@ -163,7 +163,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
if search.auto_buy then
|
||||
ctrl.suspend()
|
||||
aux.place_bid('list', auction_record.index, auction_record.buyout_price, aux.C(ctrl.resume, true))
|
||||
aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(ctrl.resume, false))
|
||||
aux.control.thread(aux.control.when, later(GetTime(), 10), aux.C(ctrl.resume, false))
|
||||
else
|
||||
tinsert(new_records, auction_record)
|
||||
end
|
||||
@@ -259,7 +259,7 @@ function start_search(queries, continuation)
|
||||
if search.auto_buy then
|
||||
ctrl.suspend()
|
||||
aux.place_bid('list', auction_record.index, auction_record.buyout_price, aux.C(ctrl.resume, true))
|
||||
aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(ctrl.resume, false))
|
||||
aux.control.thread(aux.control.when, later(GetTime(), 10), aux.C(ctrl.resume, false))
|
||||
elseif getn(search.records) < 1000 then
|
||||
tinsert(search.records, auction_record)
|
||||
if getn(search.records) == 1000 then
|
||||
@@ -335,7 +335,7 @@ function public.execute(resume, real_time)
|
||||
else
|
||||
m.new_search(filter_string)
|
||||
end
|
||||
m.new_recent_search(filter_string, table.concat(aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
||||
m.new_recent_search(filter_string, table.concat(map(queries, function(filter) return filter.prettified end), ';'))
|
||||
else
|
||||
m.current_search().records = {}
|
||||
m.current_search().table:SetDatabase(m.current_search().records)
|
||||
|
||||
Reference in New Issue
Block a user