auto buy refactoring
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
## Interface: 11200
|
||||
## Title: aux
|
||||
## Description: Auction House AddOn
|
||||
## SavedVariablesPerCharacter: aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
|
||||
## SavedVariablesPerCharacter: aux_auto_buy_filters, aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source
|
||||
## SavedVariables: aux_datasets, aux_items, aux_item_ids, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell, aux_characters, aux_recent_searches, aux_favorite_searches, aux_ignore_owner, aux_price_per_unit
|
||||
|
||||
libs\inspect.lua
|
||||
|
||||
+6
-1
@@ -156,7 +156,12 @@ function private.scan_page(i)
|
||||
|
||||
history.process_auction(auction_info)
|
||||
|
||||
if not query.validator or query.validator(auction_info) then
|
||||
if (state.params.auto_buy_validator or nop)(auction_info) then
|
||||
local send_signal, signal_received = signal()
|
||||
when(signal_received, recurse)
|
||||
place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, papply(send_signal, true))
|
||||
return thread(when, later(GetTime(), 10), send_signal, false)
|
||||
elseif not query.validator or query.validator(auction_info) then
|
||||
return wait_for_callback(state.params.on_auction, auction_info, function(removed)
|
||||
if removed then
|
||||
return recurse(true)
|
||||
|
||||
+41
-44
@@ -37,8 +37,8 @@ frame.saved.recent:SetPoint('TOPLEFT', frame.saved.favorite, 'TOPRIGHT', 2.5, 0)
|
||||
frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
do
|
||||
local btn = gui.checkbutton(frame)
|
||||
btn:SetPoint('TOPLEFT', 5, -10)
|
||||
btn:SetWidth(100)
|
||||
btn:SetPoint('TOPLEFT', 5, -9)
|
||||
btn:SetWidth(90)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Real Time'
|
||||
btn:SetScript('OnClick', function()
|
||||
@@ -50,47 +50,9 @@ do
|
||||
end)
|
||||
private.real_time_button = btn
|
||||
end
|
||||
do
|
||||
local function change()
|
||||
local page = tonumber(this:GetText())
|
||||
local valid_input = page and tostring(max(1, page)) or ''
|
||||
if this:GetText() ~= valid_input then
|
||||
this:SetText(valid_input)
|
||||
end
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetPoint('LEFT', real_time_button, 'RIGHT', 5, 0)
|
||||
editbox:SetWidth(50)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, 16)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0)
|
||||
label:SetTextColor(color.text.enabled())
|
||||
private.first_page_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 10, 0)
|
||||
editbox:SetWidth(50)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, gui.font_size.medium)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0)
|
||||
label:SetText'-'
|
||||
label:SetTextColor(color.text.enabled())
|
||||
private.last_page_input = editbox
|
||||
end
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, 25)
|
||||
btn:SetPoint('LEFT', last_page_input, 'RIGHT', 5, 0)
|
||||
btn:SetPoint('LEFT', real_time_button, 'RIGHT', 4, 0)
|
||||
btn:SetWidth(30)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'<'
|
||||
@@ -106,9 +68,43 @@ do
|
||||
btn:SetScript('OnClick', next_search)
|
||||
private.next_button = btn
|
||||
end
|
||||
do
|
||||
local function change()
|
||||
local page = tonumber(this:GetText())
|
||||
local valid_input = page and tostring(max(1, page)) or ''
|
||||
if this:GetText() ~= valid_input then
|
||||
this:SetText(valid_input)
|
||||
end
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
private.first_page_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 7, 0)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, gui.font_size.medium)
|
||||
label:SetPoint('RIGHT', editbox, 'LEFT', -2, 0)
|
||||
label:SetText'-'
|
||||
label:SetTextColor(color.label.enabled())
|
||||
private.last_page_input = editbox
|
||||
end
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.huge)
|
||||
btn:SetPoint('TOPRIGHT', -5, -10)
|
||||
btn:SetPoint('TOPRIGHT', -5, -9)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Start'
|
||||
@@ -123,7 +119,7 @@ do
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.huge)
|
||||
btn:SetPoint('TOPRIGHT', -5, -10)
|
||||
btn:SetPoint('TOPRIGHT', -5, -9)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Stop'
|
||||
@@ -151,6 +147,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:SetPoint('LEFT', last_page_input, 'RIGHT', 4, 0)
|
||||
editbox:SetPoint('RIGHT', start_button, 'LEFT', -4, 0)
|
||||
editbox:SetHeight(25)
|
||||
editbox.char = function()
|
||||
@@ -530,7 +527,7 @@ for _ = 1, 5 do
|
||||
end
|
||||
|
||||
private.autobuy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
|
||||
autobuy_listing:SetColInfo{{name='Autobuy Filters', width=1}}
|
||||
autobuy_listing:SetColInfo{{name='Auto Buy Filters', width=1}}
|
||||
autobuy_listing:EnableSorting(false)
|
||||
autobuy_listing:DisableSelection(true)
|
||||
autobuy_listing:SetHandler('OnClick', handlers.OnClick)
|
||||
|
||||
+2
-32
@@ -10,17 +10,6 @@ function LOAD()
|
||||
current_search.dummy = true
|
||||
end
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function private.search_scan_id.get() return id end
|
||||
function private.search_scan_id.set(v) id = v end
|
||||
end
|
||||
do
|
||||
local validator
|
||||
function private.auto_buy_validator.get() return validator end
|
||||
function private.auto_buy_validator.set(v) validator = v end
|
||||
end
|
||||
|
||||
do
|
||||
local searches = t
|
||||
local search_index = 1
|
||||
@@ -47,10 +36,10 @@ do
|
||||
end
|
||||
if search_index == getn(searches) then
|
||||
next_button:Hide()
|
||||
search_box:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0)
|
||||
first_page_input:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0)
|
||||
else
|
||||
next_button:Show()
|
||||
search_box:SetPoint('LEFT', next_button, 'RIGHT', 4, 0)
|
||||
first_page_input:SetPoint('LEFT', next_button, 'RIGHT', 4, 0)
|
||||
end
|
||||
update_start_stop()
|
||||
update_continuation()
|
||||
@@ -120,25 +109,6 @@ function private.update_start_stop()
|
||||
end
|
||||
end
|
||||
|
||||
function private.update_auto_buy_filter()
|
||||
if aux_auto_buy_filter ~= '' then
|
||||
local queries, error = filter_util.queries(aux_auto_buy_filter)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
print 'Error: The automatic buyout filter does not support multi-queries'
|
||||
elseif size(queries[1].blizzard_query) > 0 then
|
||||
print 'Error: The automatic buyout filter does not support Blizzard filters'
|
||||
else
|
||||
auto_buy_validator = queries[1].validator
|
||||
return
|
||||
end
|
||||
else
|
||||
print('Invalid auto buy filter:', error)
|
||||
end
|
||||
end
|
||||
aux_auto_buy_filter = ''
|
||||
end
|
||||
|
||||
function private.start_real_time_scan(query, search, continuation)
|
||||
|
||||
local ignore_page
|
||||
|
||||
+28
-5
@@ -1,12 +1,14 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
aux_autobuy_filters = t
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
aux_auto_buy_filters = t
|
||||
aux_favorite_searches = t
|
||||
aux_recent_searches = t
|
||||
|
||||
function private.update_search_listings()
|
||||
local autobuy_filter_rows = t
|
||||
for i, autobuy_filter in aux_autobuy_filters do
|
||||
for i, autobuy_filter in aux_auto_buy_filters do
|
||||
local name = strsub(autobuy_filter.prettified, 1, 250)
|
||||
tinsert(autobuy_filter_rows, {
|
||||
cols = {{ value=name }},
|
||||
@@ -73,7 +75,7 @@ private.handlers = {
|
||||
end
|
||||
elseif button == 'RightButton' and IsAltKeyDown() then
|
||||
if st ~= autobuy_listing then
|
||||
tinsert(aux_autobuy_filters, 1, data.search)
|
||||
tinsert(aux_auto_buy_filters, 1, data.search)
|
||||
update_search_listings()
|
||||
end
|
||||
elseif button == 'LeftButton' then
|
||||
@@ -81,7 +83,7 @@ private.handlers = {
|
||||
execute()
|
||||
elseif button == 'RightButton' then
|
||||
if st == autobuy_listing then
|
||||
tremove(aux_autobuy_filters, data.index)
|
||||
tremove(aux_auto_buy_filters, data.index)
|
||||
elseif st == recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
elseif st == favorite_searches_listing then
|
||||
@@ -100,4 +102,25 @@ private.handlers = {
|
||||
GameTooltip:ClearLines()
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
function private.auto_buy_validator.get()
|
||||
local validators = t
|
||||
for _, filter in aux_auto_buy_filters do
|
||||
local queries, error = filter_util.queries(filter.filter_string)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
return nil, 'The automatic buyout filter does not support multi-queries'
|
||||
-- elseif size(queries[1].blizzard_query) > 0 then TODO allow exact
|
||||
-- return nil, 'The automatic buyout filter does not support Blizzard filters'
|
||||
else
|
||||
tinsert(validators, queries[1].validator)
|
||||
end
|
||||
else
|
||||
print('Invalid auto buy filter:', error)
|
||||
end
|
||||
end
|
||||
return function(record)
|
||||
return any(validators, function(validator) return validator(record) end)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user