module refactoring
This commit is contained in:
+10
-9
@@ -1,21 +1,22 @@
|
||||
module 'aux.tabs.auctions'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Auctions'
|
||||
local tab = TAB 'Auctions'
|
||||
|
||||
auction_records = T
|
||||
auction_records = T.acquire()
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
scan_auctions()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
@@ -28,11 +29,11 @@ function M.scan_auctions()
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Scanning auctions...')
|
||||
|
||||
wipe(auction_records)
|
||||
T.wipe(auction_records)
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'owner',
|
||||
queries = {{blizzard_query = T}},
|
||||
queries = {{blizzard_query = T.acquire()}},
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -54,7 +55,7 @@ end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = T, T, T
|
||||
local IDLE, SEARCHING, FOUND = T.acquire(), T.acquire(), T.acquire()
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
@@ -96,7 +97,7 @@ do
|
||||
find_auction(selection.record)
|
||||
elseif state == FOUND and not scan_util.test(selection.record, found_index) then
|
||||
cancel_button:Disable()
|
||||
if not cancel_in_progress then state = IDLE end
|
||||
if not cancel_in_progress() then state = IDLE end
|
||||
end
|
||||
end
|
||||
end
|
||||
+8
-7
@@ -1,22 +1,23 @@
|
||||
module 'aux.tabs.bids'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Bids'
|
||||
local tab = TAB 'Bids'
|
||||
|
||||
auction_records = {}
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
scan_bids()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
@@ -29,11 +30,11 @@ function M.scan_bids()
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Scanning auctions...')
|
||||
|
||||
wipe(auction_records)
|
||||
T.wipe(auction_records)
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'bidder',
|
||||
queries = A(O('blizzard_query', T)),
|
||||
queries = T.list(T.map('blizzard_query', T.acquire())),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -120,7 +121,7 @@ do
|
||||
elseif state == FOUND and not scan_util.test(selection.record, found_index) then
|
||||
buyout_button:Disable()
|
||||
bid_button:Disable()
|
||||
if not bid_in_progress then state = IDLE end
|
||||
if not bid_in_progress() then state = IDLE end
|
||||
end
|
||||
end
|
||||
end
|
||||
+75
-82
@@ -1,8 +1,9 @@
|
||||
module 'aux.tabs.post'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local sort_util = require 'aux.util.sort'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
@@ -11,28 +12,31 @@ local scan_util = require 'aux.util.scan'
|
||||
local post = require 'aux.core.post'
|
||||
local scan = require 'aux.core.scan'
|
||||
local history = require 'aux.core.history'
|
||||
local cache = require 'aux.core.cache'
|
||||
local item_listing = require 'aux.gui.item_listing'
|
||||
local al = require 'aux.gui.auction_listing'
|
||||
|
||||
TAB 'Post'
|
||||
local tab = TAB 'Post'
|
||||
|
||||
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||
local settings_schema = {'tuple', '#', {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||
|
||||
local scan_id, inventory_records, bid_records, buyout_records = 0, {}, {}, {}
|
||||
|
||||
function get.default_settings()
|
||||
return O('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
refresh = true
|
||||
|
||||
selected_item = nil
|
||||
|
||||
function get_default_settings()
|
||||
return T.map('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
end
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
data = faction_data'post'
|
||||
end
|
||||
|
||||
function read_settings(item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
|
||||
return data[item_key] and persistence.read(settings_schema, data[item_key]) or get_default_settings()
|
||||
end
|
||||
function write_settings(settings, item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
@@ -41,16 +45,16 @@ end
|
||||
|
||||
do
|
||||
local bid_selections, buyout_selections = {}, {}
|
||||
function get.bid_selection()
|
||||
function get_bid_selection()
|
||||
return bid_selections[selected_item.key]
|
||||
end
|
||||
function set.bid_selection(record)
|
||||
function set_bid_selection(record)
|
||||
bid_selections[selected_item.key] = record
|
||||
end
|
||||
function get.buyout_selection()
|
||||
function get_buyout_selection()
|
||||
return buyout_selections[selected_item.key]
|
||||
end
|
||||
function set.buyout_selection(record)
|
||||
function set_buyout_selection(record)
|
||||
buyout_selections[selected_item.key] = record
|
||||
end
|
||||
end
|
||||
@@ -61,48 +65,36 @@ function refresh_button_click()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
do
|
||||
local item
|
||||
function get.selected_item() return item end
|
||||
function set.selected_item(v) item = v end
|
||||
end
|
||||
|
||||
do
|
||||
local c = 0
|
||||
function get.refresh() return c end
|
||||
function set.refresh(v) c = v end
|
||||
end
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
update_inventory_records()
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
function tab.CLOSE()
|
||||
selected_item = nil
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
function USE_ITEM(item_info)
|
||||
function tab.USE_ITEM(item_info)
|
||||
select_item(item_info.item_key)
|
||||
end
|
||||
|
||||
function get.unit_start_price()
|
||||
function get_unit_start_price()
|
||||
return selected_item and read_settings().start_price or 0
|
||||
end
|
||||
|
||||
function set.unit_start_price(amount)
|
||||
function set_unit_start_price(amount)
|
||||
local settings = read_settings()
|
||||
settings.start_price = amount
|
||||
write_settings(settings)
|
||||
end
|
||||
|
||||
function get.unit_buyout_price()
|
||||
function get_unit_buyout_price()
|
||||
return selected_item and read_settings().buyout_price or 0
|
||||
end
|
||||
|
||||
function set.unit_buyout_price(amount)
|
||||
function set_unit_buyout_price(amount)
|
||||
local settings = read_settings()
|
||||
settings.buyout_price = amount
|
||||
write_settings(settings)
|
||||
@@ -118,34 +110,34 @@ function update_inventory_listing()
|
||||
end
|
||||
|
||||
function update_auction_listing(listing, records, reference)
|
||||
local rows = T
|
||||
local rows = T.acquire()
|
||||
if selected_item then
|
||||
local historical_value = history.value(selected_item.key)
|
||||
local stack_size = stack_size_slider:GetValue()
|
||||
for _, record in pairs(records[selected_item.key] or empty) do
|
||||
for _, record in pairs(records[selected_item.key] or T.empty) do
|
||||
local price_color = undercut(record, stack_size_slider:GetValue(), listing == 'bid') < reference and color.red
|
||||
local price = record.unit_price * (listing == 'bid' and record.stack_size / stack_size_slider:GetValue() or 1)
|
||||
tinsert(rows, O(
|
||||
'cols', A(
|
||||
O('value', record.own and color.green(record.count) or record.count),
|
||||
O('value', al.time_left(record.duration)),
|
||||
O('value', record.stack_size == stack_size and color.green(record.stack_size) or record.stack_size),
|
||||
O('value', money.to_string(price, true, nil, price_color)),
|
||||
O('value', historical_value and al.percentage_historical(round(price / historical_value * 100)) or '---')
|
||||
tinsert(rows, T.map(
|
||||
'cols', T.list(
|
||||
T.map('value', record.own and color.green(record.count) or record.count),
|
||||
T.map('value', al.time_left(record.duration)),
|
||||
T.map('value', record.stack_size == stack_size and color.green(record.stack_size) or record.stack_size),
|
||||
T.map('value', money.to_string(price, true, nil, price_color)),
|
||||
T.map('value', historical_value and al.percentage_historical(round(price / historical_value * 100)) or '---')
|
||||
),
|
||||
'record', record
|
||||
))
|
||||
end
|
||||
if historical_value then
|
||||
tinsert(rows, O(
|
||||
'cols', A(
|
||||
O('value', '---'),
|
||||
O('value', '---'),
|
||||
O('value', '---'),
|
||||
O('value', money.to_string(historical_value, true, nil, color.green)),
|
||||
O('value', historical_value and al.percentage_historical(100) or '---')
|
||||
tinsert(rows, T.map(
|
||||
'cols', T.list(
|
||||
T.map('value', '---'),
|
||||
T.map('value', '---'),
|
||||
T.map('value', '---'),
|
||||
T.map('value', money.to_string(historical_value, true, nil, color.green)),
|
||||
T.map('value', historical_value and al.percentage_historical(100) or '---')
|
||||
),
|
||||
'record', O('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true)
|
||||
'record', T.map('historical_value', true, 'stack_size', stack_size, 'unit_price', historical_value, 'own', true)
|
||||
))
|
||||
end
|
||||
sort(rows, function(a, b)
|
||||
@@ -175,8 +167,8 @@ function update_auction_listing(listing, records, reference)
|
||||
end
|
||||
|
||||
function update_auction_listings()
|
||||
update_auction_listing('bid', bid_records, unit_start_price)
|
||||
update_auction_listing('buyout', buyout_records, unit_buyout_price)
|
||||
update_auction_listing('bid', bid_records, get_unit_start_price())
|
||||
update_auction_listing('buyout', buyout_records, get_unit_buyout_price())
|
||||
end
|
||||
|
||||
function M.select_item(item_key)
|
||||
@@ -191,23 +183,23 @@ end
|
||||
function price_update()
|
||||
if selected_item then
|
||||
local historical_value = history.value(selected_item.key)
|
||||
if bid_selection or buyout_selection then
|
||||
unit_start_price = undercut(bid_selection or buyout_selection, stack_size_slider:GetValue(), bid_selection)
|
||||
unit_start_price_input:SetText(money.to_string(unit_start_price, true, nil, nil, true))
|
||||
if get_bid_selection() or get_buyout_selection() then
|
||||
set_unit_start_price(undercut(get_bid_selection() or get_buyout_selection(), stack_size_slider:GetValue(), get_bid_selection()))
|
||||
unit_start_price_input:SetText(money.to_string(get_unit_start_price(), true, nil, nil, true))
|
||||
end
|
||||
if buyout_selection then
|
||||
unit_buyout_price = undercut(buyout_selection, stack_size_slider:GetValue())
|
||||
unit_buyout_price_input:SetText(money.to_string(unit_buyout_price, true, nil, nil, true))
|
||||
if get_buyout_selection() then
|
||||
set_unit_buyout_price(undercut(get_buyout_selection(), stack_size_slider:GetValue()))
|
||||
unit_buyout_price_input:SetText(money.to_string(get_unit_buyout_price(), true, nil, nil, true))
|
||||
end
|
||||
start_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_start_price / historical_value * 100)) or '---')
|
||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(unit_buyout_price / historical_value * 100)) or '---')
|
||||
start_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_start_price() / historical_value * 100)) or '---')
|
||||
buyout_price_percentage:SetText(historical_value and al.percentage_historical(round(get_unit_buyout_price() / historical_value * 100)) or '---')
|
||||
end
|
||||
end
|
||||
|
||||
function post_auctions()
|
||||
if selected_item then
|
||||
local unit_start_price = unit_start_price
|
||||
local unit_buyout_price = unit_buyout_price
|
||||
local unit_start_price = get_unit_start_price()
|
||||
local unit_buyout_price = get_unit_buyout_price()
|
||||
local stack_size = stack_size_slider:GetValue()
|
||||
local stack_count
|
||||
stack_count = stack_count_slider:GetValue()
|
||||
@@ -258,11 +250,11 @@ function validate_parameters()
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
if unit_buyout_price > 0 and unit_start_price > unit_buyout_price then
|
||||
if get_unit_buyout_price() > 0 and get_unit_start_price() > get_unit_buyout_price() then
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
if unit_start_price == 0 then
|
||||
if get_unit_start_price() == 0 then
|
||||
post_button:Disable()
|
||||
return
|
||||
end
|
||||
@@ -345,15 +337,15 @@ function quantity_update(maximize_count)
|
||||
end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local item_info = T.temp-info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
if info.auctionable(item_info.tooltip, nil, true) and not item_info.lootable then
|
||||
ClearCursor()
|
||||
PickupContainerItem(unpack(slot))
|
||||
ClickAuctionSellItemButton()
|
||||
local auction_sell_item = temp-info.auction_sell_item()
|
||||
local auction_sell_item = T.temp-info.auction_sell_item()
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
@@ -411,20 +403,20 @@ function update_item(item)
|
||||
end
|
||||
|
||||
function update_inventory_records()
|
||||
local auctionable_map = temp-T
|
||||
for slot in info.inventory do
|
||||
temp(slot)
|
||||
local item_info = temp-info.container_item(unpack(slot))
|
||||
local auctionable_map = T.temp-T.acquire()
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local item_info = T.temp-info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
local charge_class = item_info.charges or 0
|
||||
if info.auctionable(item_info.tooltip, nil, true) and not item_info.lootable then
|
||||
if not auctionable_map[item_info.item_key] then
|
||||
local availability = T
|
||||
local availability = T.acquire()
|
||||
for i = 0, 10 do
|
||||
availability[i] = 0
|
||||
end
|
||||
availability[charge_class] = item_info.count
|
||||
auctionable_map[item_info.item_key] = O(
|
||||
auctionable_map[item_info.item_key] = T.map(
|
||||
'item_id', item_info.item_id,
|
||||
'suffix_id', item_info.suffix_id,
|
||||
'key', item_info.item_key,
|
||||
@@ -445,7 +437,7 @@ function update_inventory_records()
|
||||
end
|
||||
end
|
||||
end
|
||||
release(inventory_records)
|
||||
T.release(inventory_records)
|
||||
inventory_records = values(auctionable_map)
|
||||
refresh = true
|
||||
end
|
||||
@@ -453,7 +445,8 @@ end
|
||||
function refresh_entries()
|
||||
if selected_item then
|
||||
local item_key = selected_item.key
|
||||
bid_selection, buyout_selection = nil, nil
|
||||
set_bid_selection()
|
||||
set_buyout_selection()
|
||||
bid_records[item_key], buyout_records[item_key] = nil, nil
|
||||
local query = scan_util.item_query(selected_item.item_id)
|
||||
status_bar:update_status(0, 0)
|
||||
@@ -462,7 +455,7 @@ function refresh_entries()
|
||||
scan_id = scan.start{
|
||||
type = 'list',
|
||||
ignore_owner = true,
|
||||
queries = A(query),
|
||||
queries = T.list(query),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status(page / total_pages, 0) -- TODO
|
||||
status_bar:set_text(format('Scanning Page %d / %d', page, total_pages))
|
||||
@@ -485,8 +478,8 @@ function refresh_entries()
|
||||
status_bar:set_text('Scan aborted')
|
||||
end,
|
||||
on_complete = function()
|
||||
bid_records[item_key] = bid_records[item_key] or T
|
||||
buyout_records[item_key] = buyout_records[item_key] or T
|
||||
bid_records[item_key] = bid_records[item_key] or T.acquire()
|
||||
buyout_records[item_key] = buyout_records[item_key] or T.acquire()
|
||||
refresh = true
|
||||
status_bar:update_status(1, 1)
|
||||
status_bar:set_text('Scan complete')
|
||||
@@ -496,31 +489,31 @@ function refresh_entries()
|
||||
end
|
||||
|
||||
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
bid_records[key] = bid_records[key] or T
|
||||
bid_records[key] = bid_records[key] or T.acquire()
|
||||
do
|
||||
local entry
|
||||
for _, record in pairs(bid_records[key]) do
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and info.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
entry = T.map('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', info.is_player(owner), 'count', 0)
|
||||
tinsert(bid_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
end
|
||||
buyout_records[key] = buyout_records[key] or T
|
||||
buyout_records[key] = buyout_records[key] or T.acquire()
|
||||
if unit_buyout_price == 0 then return end
|
||||
do
|
||||
local entry
|
||||
for _, record in pairs(buyout_records[key]) do
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and info.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
entry = T.map('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', info.is_player(owner), 'count', 0)
|
||||
tinsert(buyout_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
|
||||
+17
-17
@@ -61,8 +61,8 @@ do
|
||||
if arg1 == 'LeftButton' then
|
||||
update_item(this.item_record)
|
||||
elseif arg1 == 'RightButton' then
|
||||
tab = 1
|
||||
search_tab.filter = strlower(info.item(this.item_record.item_id).name) .. '/exact'
|
||||
set_tab(1)
|
||||
search_tab.set_filter(strlower(info.item(this.item_record.item_id).name) .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
end
|
||||
end,
|
||||
@@ -81,13 +81,13 @@ bid_listing:SetColInfo{
|
||||
{name='% Hist.\nValue', width=.21, align='CENTER'},
|
||||
}
|
||||
bid_listing:SetSelection(function(data)
|
||||
return data.record == bid_selection or data.record.historical_value and bid_selection and bid_selection.historical_value
|
||||
return data.record == get_bid_selection() or data.record.historical_value and get_bid_selection() and get_bid_selection().historical_value
|
||||
end)
|
||||
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
if row_data.record == bid_selection or row_data.record.historical_value and bid_selection and bid_selection.historical_value then
|
||||
bid_selection = nil
|
||||
if row_data.record == get_bid_selection() or row_data.record.historical_value and get_bid_selection() and get_bid_selection().historical_value then
|
||||
set_bid_selection()
|
||||
else
|
||||
bid_selection = row_data.record
|
||||
set_bid_selection(row_data.record)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -105,13 +105,13 @@ buyout_listing:SetColInfo{
|
||||
{name='% Hist.\nValue', width=.20, align='CENTER'},
|
||||
}
|
||||
buyout_listing:SetSelection(function(data)
|
||||
return data.record == buyout_selection or data.record.historical_value and buyout_selection and buyout_selection.historical_value
|
||||
return data.record == get_buyout_selection() or data.record.historical_value and get_buyout_selection() and get_buyout_selection().historical_value
|
||||
end)
|
||||
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
|
||||
if row_data.record == buyout_selection or row_data.record.historical_value and buyout_selection and buyout_selection.historical_value then
|
||||
buyout_selection = nil
|
||||
if row_data.record == get_buyout_selection() or row_data.record.historical_value and get_buyout_selection() and get_buyout_selection().historical_value then
|
||||
set_buyout_selection()
|
||||
else
|
||||
buyout_selection = row_data.record
|
||||
set_buyout_selection(row_data.record)
|
||||
end
|
||||
refresh = true
|
||||
end)
|
||||
@@ -248,12 +248,12 @@ do
|
||||
unit_buyout_price_input:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.formatter = function() return money.to_string(unit_start_price, true) end
|
||||
editbox.char = function() bid_selection, buyout_selection = nil, nil; unit_start_price = money.from_string(this:GetText()) end
|
||||
editbox.formatter = function() return money.to_string(get_unit_start_price(), true) end
|
||||
editbox.char = function() set_bid_selection(); set_buyout_selection(); set_unit_start_price(money.from_string(this:GetText())) end
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
this:SetText(money.to_string(unit_start_price, true, nil, nil, true))
|
||||
this:SetText(money.to_string(get_unit_start_price(), true, nil, nil, true))
|
||||
end
|
||||
do
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
@@ -283,12 +283,12 @@ do
|
||||
stack_size_slider.editbox:SetFocus()
|
||||
end
|
||||
end)
|
||||
editbox.formatter = function() return money.to_string(unit_buyout_price, true) end
|
||||
editbox.char = function() buyout_selection = nil; unit_buyout_price = money.from_string(this:GetText()) end
|
||||
editbox.formatter = function() return money.to_string(get_unit_buyout_price(), true) end
|
||||
editbox.char = function() set_buyout_selection(); set_unit_buyout_price(money.from_string(this:GetText())) end
|
||||
editbox.change = function() refresh = true end
|
||||
editbox.enter = function() this:ClearFocus() end
|
||||
editbox.focus_loss = function()
|
||||
this:SetText(money.to_string(unit_buyout_price, true, nil, nil, true))
|
||||
this:SetText(money.to_string(get_unit_buyout_price(), true, nil, nil, true))
|
||||
end
|
||||
do
|
||||
local label = gui.label(editbox, gui.font_size.small)
|
||||
@@ -310,7 +310,7 @@ do
|
||||
deposit = label
|
||||
end
|
||||
|
||||
function LOAD()
|
||||
function handle.LOAD()
|
||||
if not aux_post_bid then
|
||||
frame.bid_listing:Hide()
|
||||
frame.buyout_listing:SetPoint('BOTTOMLEFT', frame.inventory, 'BOTTOMRIGHT', 2.5, 0)
|
||||
|
||||
+15
-14
@@ -1,11 +1,12 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
include 'T'
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
TAB 'Search'
|
||||
local tab = TAB 'Search'
|
||||
|
||||
StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = {
|
||||
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
|
||||
@@ -19,32 +20,32 @@ RESULTS = 1
|
||||
SAVED = 2
|
||||
FILTER = 3
|
||||
|
||||
function LOAD()
|
||||
subtab = SAVED
|
||||
function handle.LOAD()
|
||||
set_subtab(SAVED)
|
||||
end
|
||||
|
||||
function OPEN()
|
||||
function tab.OPEN()
|
||||
frame:Show()
|
||||
update_search_listings()
|
||||
update_filter_display()
|
||||
end
|
||||
|
||||
function CLOSE()
|
||||
current_search.table:SetSelectedRecord()
|
||||
function tab.CLOSE()
|
||||
get_current_search().table:SetSelectedRecord()
|
||||
frame:Hide()
|
||||
end
|
||||
|
||||
function CLICK_LINK(item_info)
|
||||
filter = strlower(item_info.name) .. '/exact'
|
||||
function tab.CLICK_LINK(item_info)
|
||||
set_filter(strlower(item_info.name) .. '/exact')
|
||||
execute(nil, false)
|
||||
end
|
||||
|
||||
function USE_ITEM(item_info)
|
||||
filter = strlower(info.item(item_info.item_id).name) .. '/exact'
|
||||
function tab.USE_ITEM(item_info)
|
||||
set_filter(strlower(info.item(item_info.item_id).name) .. '/exact')
|
||||
execute(nil, false)
|
||||
end
|
||||
|
||||
function set.subtab(tab)
|
||||
function set_subtab(tab)
|
||||
CloseDropDownMenus()
|
||||
search_results_button:UnlockHighlight()
|
||||
saved_searches_button:UnlockHighlight()
|
||||
@@ -65,7 +66,7 @@ function set.subtab(tab)
|
||||
end
|
||||
end
|
||||
|
||||
function M.set.filter(filter_string)
|
||||
function M.set_filter(filter_string)
|
||||
search_box:SetFocus()
|
||||
search_box:SetText(filter_string)
|
||||
end
|
||||
@@ -78,7 +79,7 @@ function add_filter(filter_string)
|
||||
old_filter_string = old_filter_string .. ';'
|
||||
end
|
||||
|
||||
filter = old_filter_string .. filter_string
|
||||
set_filter(old_filter_string .. filter_string)
|
||||
end
|
||||
|
||||
function blizzard_page_index(str)
|
||||
|
||||
+30
-29
@@ -1,8 +1,9 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
local post_filter = {}
|
||||
@@ -13,7 +14,7 @@ function valid_level(str)
|
||||
return level and bounded(1, 60, level)
|
||||
end
|
||||
|
||||
blizzard_query = setmetatable(T, {
|
||||
blizzard_query = setmetatable(T.acquire(), {
|
||||
__index = function(_, key)
|
||||
if key == 'name' then
|
||||
return name_input:GetText()
|
||||
@@ -81,31 +82,31 @@ function update_form()
|
||||
|
||||
if blizzard_query.exact then
|
||||
usable_checkbox:Disable()
|
||||
for key in pairs(temp-S('min_level', 'max_level')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level')) do
|
||||
_M[key .. '_input']:EnableMouse(false)
|
||||
_M[key .. '_input']:ClearFocus()
|
||||
end
|
||||
for key in pairs(temp-S('class', 'subclass', 'slot', 'quality')) do
|
||||
for key in pairs(T.temp-T.set('class', 'subclass', 'slot', 'quality')) do
|
||||
_M[key .. '_dropdown'].button:Disable()
|
||||
end
|
||||
CloseDropDownMenus()
|
||||
else
|
||||
usable_checkbox:Enable()
|
||||
for key in pairs(temp-S('min_level', 'max_level')) do
|
||||
for key in pairs(T.temp-T.set('min_level', 'max_level')) do
|
||||
_M[key .. '_input']:EnableMouse(true)
|
||||
end
|
||||
class_dropdown.button:Enable()
|
||||
quality_dropdown.button:Enable()
|
||||
end
|
||||
|
||||
if any(temp-A('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
|
||||
if any(T.temp-T.list('min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'), function(key) return blizzard_query[key] end) then
|
||||
exact_checkbox:Disable()
|
||||
else
|
||||
exact_checkbox:Enable()
|
||||
end
|
||||
end
|
||||
|
||||
function get.filter_builder_query()
|
||||
function get_filter_builder_query()
|
||||
local filter_string
|
||||
|
||||
local function add(part)
|
||||
@@ -125,17 +126,17 @@ function get.filter_builder_query()
|
||||
add(blizzard_query.max_level)
|
||||
add(blizzard_query.usable and 'usable')
|
||||
|
||||
local classes = temp-A(GetAuctionItemClasses())
|
||||
local classes = T.temp-T.list(GetAuctionItemClasses())
|
||||
if blizzard_query.class and blizzard_query.class > 0 then
|
||||
add(strlower(classes[blizzard_query.class]))
|
||||
end
|
||||
local subclasses = temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0))
|
||||
local subclasses = T.temp-T.list(GetAuctionItemSubClasses(blizzard_query.class or 0))
|
||||
if blizzard_query.subclass and blizzard_query.subclass > 0 then
|
||||
add(strlower(subclasses[blizzard_query.subclass]))
|
||||
end
|
||||
local slot_index = blizzard_query.slot
|
||||
if slot_index then
|
||||
local slots = temp-A(GetAuctionInvTypes(blizzard_query.class or 0, blizzard_query.subclass or 0))
|
||||
local slots = T.temp-T.list(GetAuctionInvTypes(blizzard_query.class or 0, blizzard_query.subclass or 0))
|
||||
add(strlower(_G[slots[slot_index]]))
|
||||
end
|
||||
|
||||
@@ -150,7 +151,7 @@ function get.filter_builder_query()
|
||||
return filter_string or ''
|
||||
end
|
||||
|
||||
function set.form(filter)
|
||||
function set_form(filter)
|
||||
clear_form()
|
||||
for _, component in ipairs(filter.components) do
|
||||
if component[1] == 'blizzard' then
|
||||
@@ -176,7 +177,7 @@ function clear_form()
|
||||
UIDropDownMenu_ClearAll(slot_dropdown)
|
||||
UIDropDownMenu_ClearAll(quality_dropdown)
|
||||
filter_parameter_input:ClearFocus()
|
||||
wipe(post_filter)
|
||||
T.wipe(post_filter)
|
||||
post_filter_index = 0
|
||||
update_filter_display()
|
||||
end
|
||||
@@ -184,18 +185,18 @@ end
|
||||
function import_filter_string()
|
||||
local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
if filter or print(error) then
|
||||
set.form(filter)
|
||||
set_form(filter)
|
||||
end
|
||||
update_form()
|
||||
end
|
||||
|
||||
function export_filter_string()
|
||||
filter = filter_builder_query
|
||||
set_filter(get_filter_builder_query())
|
||||
end
|
||||
|
||||
function formatted_post_filter(components)
|
||||
local no_line_break
|
||||
local stack = temp-T
|
||||
local stack = T.temp-T.acquire()
|
||||
local str = ''
|
||||
|
||||
for i, component in ipairs(components) do
|
||||
@@ -218,7 +219,7 @@ function formatted_post_filter(components)
|
||||
local parameter = component[3]
|
||||
if parameter then
|
||||
if component[2] == 'item' then
|
||||
parameter = info.display_name(cache.item_id(parameter)) or '[' .. parameter .. ']'
|
||||
parameter = info.display_name(info.item_id(parameter)) or '[' .. parameter .. ']'
|
||||
elseif filter_util.filters[component[2]].input_type == 'money' then
|
||||
parameter = money.to_string(money.from_string(parameter), nil, true)
|
||||
end
|
||||
@@ -322,8 +323,8 @@ function set_filter_display_offset(x_offset, y_offset)
|
||||
end
|
||||
|
||||
function initialize_filter_dropdown()
|
||||
for _, filter in ipairs(temp-A('and', 'or', 'not', 'price', 'profit', 'vendor-profit', 'disenchant-profit', 'percent', 'bid-price', 'bid-profit', 'bid-vendor-profit', 'bid-disenchant-profit', 'bid-percent', 'item', 'tooltip', 'min-level', 'max-level', 'rarity', 'left', 'utilizable')) do
|
||||
UIDropDownMenu_AddButton(O(
|
||||
for _, filter in ipairs(T.temp-T.list('and', 'or', 'not', 'price', 'profit', 'vendor-profit', 'disenchant-profit', 'percent', 'bid-price', 'bid-profit', 'bid-vendor-profit', 'bid-disenchant-profit', 'bid-percent', 'item', 'tooltip', 'min-level', 'max-level', 'rarity', 'left', 'utilizable')) do
|
||||
UIDropDownMenu_AddButton(T.map(
|
||||
'text', filter,
|
||||
'value', filter,
|
||||
'func', function()
|
||||
@@ -352,9 +353,9 @@ function initialize_class_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, class in ipairs(temp-A(GetAuctionItemClasses())) do
|
||||
UIDropDownMenu_AddButton(O('text', class, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, class in ipairs(T.temp-T.list(GetAuctionItemClasses())) do
|
||||
UIDropDownMenu_AddButton(T.map('text', class, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -365,9 +366,9 @@ function initialize_subclass_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, subclass in ipairs(temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0))) do
|
||||
UIDropDownMenu_AddButton(O('text', subclass, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, subclass in ipairs(T.temp-T.list(GetAuctionItemSubClasses(blizzard_query.class or 0))) do
|
||||
UIDropDownMenu_AddButton(T.map('text', subclass, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -376,9 +377,9 @@ function initialize_slot_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, slot in ipairs(temp-A(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0))) do
|
||||
UIDropDownMenu_AddButton(O('text', _G[slot], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, slot in ipairs(T.temp-T.list(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0))) do
|
||||
UIDropDownMenu_AddButton(T.map('text', _G[slot], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -387,8 +388,8 @@ function initialize_quality_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', -1, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', ALL, 'value', -1, 'func', on_click))
|
||||
for i = 0, 4 do
|
||||
UIDropDownMenu_AddButton(O('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(T.map('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
+13
-11
@@ -1,5 +1,7 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local completion = require 'aux.util.completion'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan = require 'aux.core.scan'
|
||||
@@ -126,7 +128,7 @@ do
|
||||
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
||||
btn:SetScript('OnClick', function()
|
||||
if arg1 == 'RightButton' then
|
||||
filter = current_search.filter_string
|
||||
set_filter(get_current_search().filter_string)
|
||||
end
|
||||
execute()
|
||||
end)
|
||||
@@ -161,7 +163,7 @@ do
|
||||
return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str)
|
||||
end
|
||||
editbox.complete = completion.complete_filter
|
||||
editbox.focus_loss = function() this:SetText(current_search.filter_string or '') end
|
||||
editbox.focus_loss = function() this:SetText(get_current_search().filter_string or '') end
|
||||
editbox:SetHeight(25)
|
||||
editbox.char = function()
|
||||
this:complete()
|
||||
@@ -185,7 +187,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Search Results')
|
||||
btn:SetScript('OnClick', function() subtab = RESULTS end)
|
||||
btn:SetScript('OnClick', function() set_subtab(RESULTS) end)
|
||||
search_results_button = btn
|
||||
end
|
||||
do
|
||||
@@ -194,7 +196,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Saved Searches')
|
||||
btn:SetScript('OnClick', function() subtab = SAVED end)
|
||||
btn:SetScript('OnClick', function() set_subtab(SAVED) end)
|
||||
saved_searches_button = btn
|
||||
end
|
||||
do
|
||||
@@ -203,7 +205,7 @@ do
|
||||
btn:SetWidth(243)
|
||||
btn:SetHeight(22)
|
||||
btn:SetText('Filter Builder')
|
||||
btn:SetScript('OnClick', function() subtab = FILTER end)
|
||||
btn:SetScript('OnClick', function() set_subtab(FILTER) end)
|
||||
new_filter_button = btn
|
||||
end
|
||||
do
|
||||
@@ -232,8 +234,8 @@ do
|
||||
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
|
||||
btn:SetText('Clear')
|
||||
btn:SetScript('OnClick', function()
|
||||
while tremove(current_search.records) do end
|
||||
current_search.table:SetDatabase()
|
||||
while tremove(get_current_search().records) do end
|
||||
get_current_search().table:SetDatabase()
|
||||
end)
|
||||
end
|
||||
do
|
||||
@@ -432,14 +434,14 @@ do
|
||||
input:SetPoint('CENTER', filter_dropdown, 'CENTER', 0, 0)
|
||||
input:SetWidth(150)
|
||||
input:SetScript('OnTabPressed', function() filter_parameter_input:SetFocus() end)
|
||||
input.complete = completion.complete(function() return temp-A('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
|
||||
input.complete = completion.complete(function() return T.temp-T.list('and', 'or', 'not', unpack(keys(filter_util.filters))) end)
|
||||
input.char = function() this:complete() end
|
||||
input.change = function()
|
||||
local text = this:GetText()
|
||||
if filter_util.filters[text] and filter_util.filters[text].input_type ~= '' then
|
||||
local _, _, suggestions = filter_util.parse_filter_string(text .. '/')
|
||||
filter_parameter_input:SetNumeric(filter_util.filters[text].input_type == 'number')
|
||||
filter_parameter_input.complete = completion.complete(function() return suggestions or empty end)
|
||||
filter_parameter_input.complete = completion.complete(function() return suggestions or T.empty end)
|
||||
filter_parameter_input:Show()
|
||||
else
|
||||
filter_parameter_input:Hide()
|
||||
@@ -519,7 +521,7 @@ for _ = 1, 5 do
|
||||
|
||||
local table = auction_listing.new(frame.results, 16, auction_listing.search_columns)
|
||||
table:SetHandler('OnClick', function(row, button)
|
||||
if IsAltKeyDown() and current_search.table:GetSelection().record == row.record then
|
||||
if IsAltKeyDown() and get_current_search().table:GetSelection().record == row.record then
|
||||
if button == 'LeftButton' then
|
||||
buyout_button:Click()
|
||||
elseif button == 'RightButton' then
|
||||
@@ -541,7 +543,7 @@ favorite_searches_listing:SetColInfo{{name='Auto Buy', width=.07, align='CENTER'
|
||||
recent_searches_listing = listing.new(frame.saved.recent)
|
||||
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
||||
|
||||
for listing in pairs(temp-S(favorite_searches_listing, recent_searches_listing)) do
|
||||
for listing in pairs(T.temp-T.set(favorite_searches_listing, recent_searches_listing)) do
|
||||
for k, v in pairs(handlers) do
|
||||
listing:SetHandler(k, v)
|
||||
end
|
||||
|
||||
+46
-51
@@ -1,25 +1,18 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
local cache = require 'aux.core.cache'
|
||||
|
||||
function LOAD()
|
||||
search_scan_id = 0
|
||||
|
||||
function handle.LOAD()
|
||||
new_search()
|
||||
end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function get.search_scan_id()
|
||||
return id
|
||||
end
|
||||
function set.search_scan_id(v)
|
||||
id = v
|
||||
end
|
||||
end
|
||||
|
||||
function update_real_time(enable)
|
||||
if enable then
|
||||
range_button:Hide()
|
||||
@@ -36,7 +29,7 @@ do
|
||||
local searches = {}
|
||||
local search_index = 1
|
||||
|
||||
function get.current_search()
|
||||
function get_current_search()
|
||||
return searches[search_index]
|
||||
end
|
||||
|
||||
@@ -76,7 +69,7 @@ do
|
||||
while getn(searches) > search_index do
|
||||
tremove(searches)
|
||||
end
|
||||
local search = O('records', T, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
local search = T.map('records', T.acquire(), 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
tinsert(searches, search)
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
@@ -106,18 +99,18 @@ do
|
||||
function previous_search()
|
||||
clear_control_focus()
|
||||
update_search(search_index - 1)
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
end
|
||||
|
||||
function next_search()
|
||||
clear_control_focus()
|
||||
update_search(search_index + 1)
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
end
|
||||
end
|
||||
|
||||
function update_continuation()
|
||||
if current_search.continuation then
|
||||
if get_current_search().continuation then
|
||||
resume_button:Show()
|
||||
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
|
||||
else
|
||||
@@ -128,12 +121,12 @@ end
|
||||
|
||||
function discard_continuation()
|
||||
scan.abort(search_scan_id)
|
||||
current_search.continuation = nil
|
||||
get_current_search().continuation = nil
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
function update_start_stop()
|
||||
if current_search.active then
|
||||
if get_current_search().active then
|
||||
stop_button:Show()
|
||||
start_button:Hide()
|
||||
else
|
||||
@@ -146,14 +139,14 @@ function start_real_time_scan(query, search, continuation)
|
||||
|
||||
local ignore_page
|
||||
if not search then
|
||||
search = current_search
|
||||
search = get_current_search()
|
||||
query.blizzard_query.first_page = tonumber(continuation) or 0
|
||||
query.blizzard_query.last_page = tonumber(continuation) or 0
|
||||
ignore_page = not tonumber(continuation)
|
||||
end
|
||||
|
||||
local next_page
|
||||
local new_records = T
|
||||
local new_records = T.acquire()
|
||||
search_scan_id = scan.start{
|
||||
type = 'list',
|
||||
queries = {query},
|
||||
@@ -174,14 +167,14 @@ function start_real_time_scan(query, search, continuation)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
local map = temp-T
|
||||
local map = T.temp-T.acquire()
|
||||
for _, record in pairs(search.records) do
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
for _, record in pairs(new_records) do
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
release(new_records)
|
||||
T.release(new_records)
|
||||
new_records = values(map)
|
||||
|
||||
if getn(new_records) > 2000 then
|
||||
@@ -201,7 +194,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
|
||||
search.continuation = next_page or not ignore_page and query.blizzard_query.first_page or true
|
||||
|
||||
if current_search == search then
|
||||
if get_current_search() == search then
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
@@ -214,7 +207,7 @@ end
|
||||
function start_search(queries, continuation)
|
||||
local current_query, current_page, total_queries, start_query, start_page
|
||||
|
||||
local search = current_search
|
||||
local search = get_current_search()
|
||||
|
||||
total_queries = getn(queries)
|
||||
|
||||
@@ -269,8 +262,8 @@ function start_search(queries, continuation)
|
||||
search.status_bar:update_status(1, 1)
|
||||
search.status_bar:set_text('Scan complete')
|
||||
|
||||
if current_search == search and frame.results:IsVisible() and getn(search.records) == 0 then
|
||||
subtab = SAVED
|
||||
if get_current_search() == search and frame.results:IsVisible() and getn(search.records) == 0 then
|
||||
set_subtab(SAVED)
|
||||
end
|
||||
|
||||
search.active = false
|
||||
@@ -285,7 +278,7 @@ function start_search(queries, continuation)
|
||||
else
|
||||
search.continuation = {start_query, start_page}
|
||||
end
|
||||
if current_search == search then
|
||||
if get_current_search() == search then
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
@@ -298,13 +291,13 @@ end
|
||||
function M.execute(resume, real_time)
|
||||
|
||||
if resume then
|
||||
real_time = current_search.real_time
|
||||
real_time = get_current_search().real_time
|
||||
elseif real_time == nil then
|
||||
real_time = real_time_button:IsShown()
|
||||
end
|
||||
|
||||
if resume then
|
||||
search_box:SetText(current_search.filter_string)
|
||||
search_box:SetText(get_current_search().filter_string)
|
||||
end
|
||||
local filter_string, first_page, last_page = search_box:GetText(), blizzard_page_index(first_page_input:GetText()), blizzard_page_index(last_page_input:GetText())
|
||||
|
||||
@@ -323,38 +316,40 @@ function M.execute(resume, real_time)
|
||||
end
|
||||
|
||||
if resume then
|
||||
current_search.table:SetSelectedRecord()
|
||||
get_current_search().table:SetSelectedRecord()
|
||||
else
|
||||
if filter_string ~= current_search.filter_string then
|
||||
if current_search.filter_string then
|
||||
if filter_string ~= get_current_search().filter_string then
|
||||
if get_current_search().filter_string then
|
||||
new_search(filter_string, first_page, last_page, real_time)
|
||||
else
|
||||
current_search.filter_string = filter_string
|
||||
get_current_search().filter_string = filter_string
|
||||
end
|
||||
new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';'))
|
||||
else
|
||||
current_search.records = T
|
||||
current_search.table:Reset()
|
||||
current_search.table:SetDatabase(current_search.records)
|
||||
local search = get_current_search()
|
||||
search.records = T.acquire()
|
||||
search.table:Reset()
|
||||
search.table:SetDatabase(search.records)
|
||||
end
|
||||
current_search.first_page = first_page
|
||||
current_search.last_page = last_page
|
||||
current_search.real_time = real_time
|
||||
current_search.auto_buy_validator = auto_buy_validator
|
||||
local search = get_current_search()
|
||||
search.first_page = first_page
|
||||
search.last_page = last_page
|
||||
search.real_time = real_time
|
||||
search.auto_buy_validator = get_auto_buy_validator()
|
||||
end
|
||||
|
||||
local continuation = resume and current_search.continuation
|
||||
local continuation = resume and get_current_search().continuation
|
||||
discard_continuation()
|
||||
current_search.active = true
|
||||
get_current_search().active = true
|
||||
update_start_stop()
|
||||
clear_control_focus()
|
||||
subtab = RESULTS
|
||||
set_subtab(RESULTS)
|
||||
if real_time then
|
||||
start_real_time_scan(queries[1], nil, continuation)
|
||||
else
|
||||
for _, query in pairs(queries) do
|
||||
query.blizzard_query.first_page = current_search.first_page
|
||||
query.blizzard_query.last_page = current_search.last_page
|
||||
query.blizzard_query.first_page = get_current_search().first_page
|
||||
query.blizzard_query.last_page = get_current_search().last_page
|
||||
end
|
||||
start_search(queries, continuation)
|
||||
end
|
||||
@@ -367,9 +362,9 @@ do
|
||||
local found_index
|
||||
|
||||
function find_auction(record)
|
||||
local search = current_search
|
||||
local search = get_current_search()
|
||||
|
||||
if not search.table:ContainsRecord(record) or cache.is_player(record.owner) then
|
||||
if not search.table:ContainsRecord(record) or info.is_player(record.owner) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -377,7 +372,7 @@ do
|
||||
state = SEARCHING
|
||||
scan_id = scan_util.find(
|
||||
record,
|
||||
current_search.status_bar,
|
||||
get_current_search().status_bar,
|
||||
function()
|
||||
state = IDLE
|
||||
end,
|
||||
@@ -429,7 +424,7 @@ do
|
||||
|
||||
if state == SEARCHING then return end
|
||||
|
||||
local selection = current_search.table:GetSelection()
|
||||
local selection = get_current_search().table:GetSelection()
|
||||
if not selection then
|
||||
state = IDLE
|
||||
elseif selection and state == IDLE then
|
||||
@@ -437,7 +432,7 @@ do
|
||||
elseif state == FOUND and not scan_util.test(selection.record, found_index) then
|
||||
buyout_button:Disable()
|
||||
bid_button:Disable()
|
||||
if not bid_in_progress then
|
||||
if not bid_in_progress() then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
|
||||
+15
-13
@@ -1,31 +1,33 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local gui = require 'aux.gui'
|
||||
|
||||
function LOAD2()
|
||||
function handle.LOAD2()
|
||||
recent_searches, favorite_searches = realm_data'recent_searches', realm_data'favorite_searches'
|
||||
end
|
||||
|
||||
function update_search_listings()
|
||||
local favorite_search_rows = T
|
||||
local favorite_search_rows = T.acquire()
|
||||
for i = 1, getn(favorite_searches) do
|
||||
local search = favorite_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, O(
|
||||
'cols', A(O('value', search.auto_buy and color.red'X' or ''), O('value', name)),
|
||||
tinsert(favorite_search_rows, T.map(
|
||||
'cols', T.list(T.map('value', search.auto_buy and color.red'X' or ''), T.map('value', name)),
|
||||
'search', search,
|
||||
'index', i
|
||||
))
|
||||
end
|
||||
favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = T
|
||||
local recent_search_rows = T.acquire()
|
||||
for i = 1, getn(recent_searches) do
|
||||
local search = recent_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(recent_search_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
tinsert(recent_search_rows, T.map(
|
||||
'cols', T.list(T.map('value', name)),
|
||||
'search', search,
|
||||
'index', i
|
||||
))
|
||||
@@ -34,7 +36,7 @@ function update_search_listings()
|
||||
end
|
||||
|
||||
function new_recent_search(filter_string, prettified)
|
||||
tinsert(recent_searches, 1, O(
|
||||
tinsert(recent_searches, 1, T.map(
|
||||
'filter_string', filter_string,
|
||||
'prettified', prettified
|
||||
))
|
||||
@@ -48,11 +50,11 @@ handlers = {
|
||||
OnClick = function(st, data, _, button)
|
||||
if not data then return end
|
||||
if button == 'LeftButton' and IsShiftKeyDown() then
|
||||
filter = data.search.filter_string
|
||||
set_filter(data.search.filter_string)
|
||||
elseif button == 'RightButton' and IsShiftKeyDown() then
|
||||
add_filter(data.search.filter_string)
|
||||
elseif button == 'LeftButton' then
|
||||
filter = data.search.filter_string
|
||||
set_filter(data.search.filter_string)
|
||||
execute()
|
||||
elseif button == 'RightButton' then
|
||||
local u = update_search_listings
|
||||
@@ -82,8 +84,8 @@ handlers = {
|
||||
end
|
||||
}
|
||||
|
||||
function get.auto_buy_validator()
|
||||
local validators = T
|
||||
function get_auto_buy_validator()
|
||||
local validators = T.acquire()
|
||||
for _, search in pairs(favorite_searches) do
|
||||
if search.auto_buy then
|
||||
local queries, error = filter_util.queries(search.filter_string)
|
||||
@@ -102,7 +104,7 @@ end
|
||||
function add_favorite(filter_string)
|
||||
local queries, error = filter_util.queries(filter_string)
|
||||
if queries then
|
||||
tinsert(favorite_searches, 1, O(
|
||||
tinsert(favorite_searches, 1, T.map(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user