Merge branch 'dev' of https://github.com/shirsig/Aux-Addon into dev
This commit is contained in:
@@ -78,18 +78,16 @@ function Aux.buy.SearchButton_onclick()
|
|||||||
on_page_loaded = function(page)
|
on_page_loaded = function(page)
|
||||||
current_page = page
|
current_page = page
|
||||||
end,
|
end,
|
||||||
on_start_page = function(ok, page, total_pages)
|
on_start_page = function(page, total_pages)
|
||||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
||||||
return ok()
|
|
||||||
end,
|
end,
|
||||||
on_read_auction = function(ok, i)
|
on_read_auction = function(i)
|
||||||
local auction_item = Aux.info.auction_item(i)
|
local auction_item = Aux.info.auction_item(i)
|
||||||
if auction_item then
|
if auction_item then
|
||||||
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(tooltip_patterns, auction_item.tooltip) then
|
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(tooltip_patterns, auction_item.tooltip) then
|
||||||
process_auction(auction_item, current_page)
|
process_auction(auction_item, current_page)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ok()
|
|
||||||
end,
|
end,
|
||||||
on_complete = function()
|
on_complete = function()
|
||||||
entries = entries or {}
|
entries = entries or {}
|
||||||
@@ -203,11 +201,11 @@ function find_auction(entry, buyout_mode, express_mode)
|
|||||||
on_page_loaded = function(page)
|
on_page_loaded = function(page)
|
||||||
current_page = page
|
current_page = page
|
||||||
end,
|
end,
|
||||||
on_read_auction = function(ok, i)
|
on_read_auction = function(i, ctrl)
|
||||||
local auction_item = Aux.info.auction_item(i)
|
local auction_item = Aux.info.auction_item(i)
|
||||||
|
|
||||||
if not auction_item then
|
if not auction_item then
|
||||||
return ok()
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local stack_size = auction_item.charges or auction_item.count
|
local stack_size = auction_item.charges or auction_item.count
|
||||||
@@ -223,6 +221,7 @@ function find_auction(entry, buyout_mode, express_mode)
|
|||||||
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_amount)
|
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_amount)
|
||||||
|
|
||||||
if key == order_key then
|
if key == order_key then
|
||||||
|
ctrl.suspend()
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
if express_mode then
|
if express_mode then
|
||||||
@@ -250,8 +249,6 @@ function find_auction(entry, buyout_mode, express_mode)
|
|||||||
end
|
end
|
||||||
AuxBuyConfirmationActionButton:Enable()
|
AuxBuyConfirmationActionButton:Enable()
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return ok()
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_complete = function()
|
on_complete = function()
|
||||||
|
|||||||
+88
-82
@@ -2,7 +2,7 @@ Aux.completion = {}
|
|||||||
|
|
||||||
local NUM_MATCHES = 5
|
local NUM_MATCHES = 5
|
||||||
|
|
||||||
local fuzzy, populate_dropdown, toggle_dropdown, suggestions, update_highlighting
|
local fuzzy, make_suggestions
|
||||||
|
|
||||||
local item_names = {}
|
local item_names = {}
|
||||||
|
|
||||||
@@ -33,18 +33,7 @@ function fuzzy(input)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_highlighting()
|
function generate_suggestions(input)
|
||||||
for i=1,32 do
|
|
||||||
local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
|
||||||
if i == selected_index then
|
|
||||||
highlight:Show()
|
|
||||||
else
|
|
||||||
highlight:Hide()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function suggestions(input)
|
|
||||||
local matcher = fuzzy(input)
|
local matcher = fuzzy(input)
|
||||||
function fuzzy_sort(array)
|
function fuzzy_sort(array)
|
||||||
sort(array, function(a, b) return strlen(a.name) < strlen(b.name) end)
|
sort(array, function(a, b) return strlen(a.name) < strlen(b.name) end)
|
||||||
@@ -70,93 +59,110 @@ function suggestions(input)
|
|||||||
return Aux.util.map(best, function(match) return match.name end)
|
return Aux.util.map(best, function(match) return match.name end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function populate_dropdown(input_box, suggestions)
|
function Aux.completion.completor(edit_box)
|
||||||
for _, suggestion in ipairs(suggestions) do
|
|
||||||
UIDropDownMenu_AddButton{
|
|
||||||
text = suggestion,
|
|
||||||
value = suggestion,
|
|
||||||
notCheckable = true,
|
|
||||||
func = function()
|
|
||||||
Aux.completion.set_quietly(input_box, this.value)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function toggle_dropdown(input_box)
|
|
||||||
ToggleDropDownMenu(1, nil, AuxCompletionDropDown, input_box, -12, 4)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Aux.completion.completor()
|
|
||||||
local self = {}
|
local self = {}
|
||||||
|
|
||||||
local current_suggestions = {}
|
local suggestions = {}
|
||||||
local selected_index = 0
|
local index = 0
|
||||||
local current_input
|
local input
|
||||||
local programmatically_set_input
|
local quietly_set_text
|
||||||
|
|
||||||
function self.close()
|
local fill_dropdown, update_dropdown, update_highlighting
|
||||||
CloseDropDownMenus(1)
|
|
||||||
|
function fill_dropdown()
|
||||||
|
for _, suggestion in ipairs(suggestions) do
|
||||||
|
UIDropDownMenu_AddButton{
|
||||||
|
text = suggestion,
|
||||||
|
value = suggestion,
|
||||||
|
notCheckable = true,
|
||||||
|
func = function()
|
||||||
|
self:set_quietly(edit_box, this.value)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.set_quietly(edit_box, text)
|
function update_dropdown()
|
||||||
programmatically_set_input = text
|
function toggle()
|
||||||
edit_box:SetText(text)
|
ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4)
|
||||||
end
|
|
||||||
|
|
||||||
function self.highlighted()
|
|
||||||
return selected_index ~= 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.suggest(input_box)
|
|
||||||
|
|
||||||
local input = input_box:GetText()
|
|
||||||
if programmatically_set_input == input then
|
|
||||||
programmatically_set_input = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
programmatically_set_input = nil
|
|
||||||
|
|
||||||
current_input = input
|
|
||||||
selected_index = 0
|
|
||||||
update_highlighting()
|
|
||||||
|
|
||||||
if current_input == '' then
|
|
||||||
current_suggestions = {}
|
|
||||||
else
|
|
||||||
current_suggestions = suggestions(current_input)
|
|
||||||
UIDropDownMenu_Initialize(AuxCompletionDropDown, function() populate_dropdown(input_box, current_suggestions) end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if DropDownList1:IsVisible() then
|
if DropDownList1:IsVisible() then
|
||||||
toggle_dropdown(input_box)
|
toggle()
|
||||||
end
|
end
|
||||||
toggle_dropdown(input_box)
|
toggle()
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.next(input_box)
|
function update_highlighting()
|
||||||
if getn(current_suggestions) > 0 then
|
for i=1,32 do
|
||||||
selected_index = selected_index > 0 and math.mod(selected_index + 1, getn(current_suggestions) + 1) or 1
|
local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
||||||
update_highlighting()
|
if i == index then
|
||||||
if selected_index == 0 then
|
highlight:Show()
|
||||||
Aux.completion.set_quietly(input_box, current_input)
|
else
|
||||||
else
|
highlight:Hide()
|
||||||
Aux.completion.set_quietly(input_box, current_suggestions[selected_index])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.previous(input_box)
|
function self:close()
|
||||||
if getn(current_suggestions) > 0 then
|
CloseDropDownMenus(1)
|
||||||
selected_index = selected_index > 0 and math.mod(selected_index + 1, getn(current_suggestions) + 1) or 1
|
end
|
||||||
update_highlighting()
|
|
||||||
if selected_index == 0 then
|
function self:set_quietly(text)
|
||||||
Aux.completion.set_quietly(input_box, current_input)
|
quietly_set_text = text
|
||||||
|
edit_box:SetText(text)
|
||||||
|
end
|
||||||
|
|
||||||
|
function self:completed()
|
||||||
|
return index ~= 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function self:suggest()
|
||||||
|
|
||||||
|
local new_input = edit_box:GetText()
|
||||||
|
if new_input == quietly_set_text then
|
||||||
|
quietly_set_text = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
|
quietly_set_text = nil
|
||||||
|
|
||||||
|
input = new_input
|
||||||
|
index = 0
|
||||||
|
update_highlighting()
|
||||||
|
|
||||||
|
if input == '' then
|
||||||
|
suggestions = {}
|
||||||
|
else
|
||||||
|
suggestions = generate_suggestions(input)
|
||||||
|
UIDropDownMenu_Initialize(AuxCompletionDropDown, function() fill_dropdown() end)
|
||||||
|
end
|
||||||
|
|
||||||
|
update_dropdown()
|
||||||
|
end
|
||||||
|
|
||||||
|
function self:next()
|
||||||
|
if getn(suggestions) > 0 then
|
||||||
|
index = index > 0 and math.mod(index + 1, getn(suggestions) + 1) or 1
|
||||||
|
self:update_highlighting()
|
||||||
|
if index == 0 then
|
||||||
|
self:set_quietly(input)
|
||||||
else
|
else
|
||||||
Aux.completion.set_quietly(input_box, current_suggestions[selected_index])
|
self:set_quietly(suggestions[index])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function self.previous()
|
||||||
|
if getn(suggestions) > 0 then
|
||||||
|
index = index > 0 and index - 1 or getn(suggestions)
|
||||||
|
update_highlighting()
|
||||||
|
if index == 0 then
|
||||||
|
self:set_quietly(input)
|
||||||
|
else
|
||||||
|
self:set_quietly(suggestions[index])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -66,16 +66,21 @@ function wait_for_complete_results(k)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function wait_for_callback(f, args, k)
|
function wait_for_callback(f, args, k)
|
||||||
local ok
|
local ok = true
|
||||||
|
|
||||||
if not f then
|
if f then
|
||||||
ok = true
|
tinsert(args, {
|
||||||
else
|
suspend = function() ok = false end,
|
||||||
tinsert(args, 1, function() ok = true end)
|
resume = function() ok = true end,
|
||||||
|
})
|
||||||
f(unpack(args))
|
f(unpack(args))
|
||||||
end
|
end
|
||||||
|
|
||||||
return controller().wait(function() return ok end, k)
|
if ok then
|
||||||
|
return k()
|
||||||
|
else
|
||||||
|
return controller().wait(function() return ok end, k)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scan()
|
function scan()
|
||||||
@@ -147,4 +152,4 @@ function submit_query(k)
|
|||||||
else
|
else
|
||||||
return k()
|
return k()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -341,17 +341,15 @@ function refresh_entries()
|
|||||||
subclass = subclass_index,
|
subclass = subclass_index,
|
||||||
},
|
},
|
||||||
page = 0,
|
page = 0,
|
||||||
on_start_page = function(k, page, total_pages)
|
on_start_page = function(page, total_pages)
|
||||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
||||||
return k()
|
|
||||||
end,
|
end,
|
||||||
on_read_auction = function(k, i)
|
on_read_auction = function(i)
|
||||||
local auction_item = Aux.info.auction_item(i)
|
local auction_item = Aux.info.auction_item(i)
|
||||||
if auction_item and auction_item.name == name then
|
if auction_item and auction_item.name == name then
|
||||||
local stack_size = auction_item.charges or auction_item.count
|
local stack_size = auction_item.charges or auction_item.count
|
||||||
record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.duration, auction_item.owner)
|
record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.duration, auction_item.owner)
|
||||||
end
|
end
|
||||||
return k()
|
|
||||||
end,
|
end,
|
||||||
on_abort = function()
|
on_abort = function()
|
||||||
auxSellEntries[name] = nil
|
auxSellEntries[name] = nil
|
||||||
|
|||||||
@@ -234,4 +234,18 @@ function Aux.util.money_string(money)
|
|||||||
return format(GSC_1, c)
|
return format(GSC_1, c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Aux.util.group_by(tables, keys)
|
||||||
|
local groups = {}
|
||||||
|
Aux.util.map(tables, function(table)
|
||||||
|
for _, group in ipairs(groups) do
|
||||||
|
if Aux.util.all(keys, function(key) table[key] == group[1][key] end) then
|
||||||
|
tinsert(group, table)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tinsert(groups, { table })
|
||||||
|
end)
|
||||||
|
return groups
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user