some refactoring
This commit is contained in:
@@ -147,6 +147,8 @@ local methods = {
|
|||||||
elseif IsShiftKeyDown() then
|
elseif IsShiftKeyDown() then
|
||||||
if ChatFrameEditBox:IsVisible() then
|
if ChatFrameEditBox:IsVisible() then
|
||||||
ChatFrameEditBox:Insert(this.row.data.record.hyperlink)
|
ChatFrameEditBox:Insert(this.row.data.record.hyperlink)
|
||||||
|
else
|
||||||
|
Aux.search_frame.start_search(strlower(Aux.static.item_info(this.row.data.record.item_id).name)..'/exact')
|
||||||
end
|
end
|
||||||
elseif IsAltKeyDown() then
|
elseif IsAltKeyDown() then
|
||||||
if this.rt.handlers.OnCellAltClick then
|
if this.rt.handlers.OnCellAltClick then
|
||||||
|
|||||||
+383
-260
@@ -1,279 +1,402 @@
|
|||||||
local private, public = {}, {}
|
local m = {}
|
||||||
Aux.completion = public
|
Aux.completion = m
|
||||||
|
|
||||||
local NUM_MATCHES = 5
|
function m:complete()
|
||||||
|
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
||||||
local fuzzy, generate_suggestions
|
return
|
||||||
|
|
||||||
function fuzzy(input)
|
|
||||||
local uppercase_input = strupper(input)
|
|
||||||
local pattern = '(.*)'
|
|
||||||
for i=1,strlen(uppercase_input) do
|
|
||||||
if strfind(string.sub(uppercase_input, i, i), '%w') or strfind(string.sub(uppercase_input, i, i), '%s') then
|
|
||||||
pattern = pattern .. string.sub(uppercase_input, i, i) .. '(.*)'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return function(item_name)
|
|
||||||
local match = { string.find(strupper(item_name), pattern) }
|
local filter_string = this:GetText()
|
||||||
if match[1] then
|
|
||||||
local rating = 0
|
local completed_filter_string = ({strfind(filter_string, '([^;]*)/[^/;]*$')})[3]
|
||||||
for i=4,getn(match)-1 do
|
local current_filter = completed_filter_string and Aux.scan_util.filter_from_string(completed_filter_string)
|
||||||
if strlen(match[i]) == 0 then
|
|
||||||
rating = rating + 1
|
local options = {}
|
||||||
|
|
||||||
|
if current_filter or not completed_filter_string then
|
||||||
|
current_filter = current_filter or {}
|
||||||
|
|
||||||
|
if current_filter.name
|
||||||
|
and Aux.static.auctionable_items[strupper(current_filter.name)]
|
||||||
|
and not current_filter.min_level
|
||||||
|
and not current_filter.max_level
|
||||||
|
and not current_filter.class
|
||||||
|
and not current_filter.subclass
|
||||||
|
and not current_filter.slot
|
||||||
|
and not current_filter.quality
|
||||||
|
and not current_filter.usable
|
||||||
|
and not current_filter.exact
|
||||||
|
then
|
||||||
|
tinsert(options, 'exact')
|
||||||
|
end
|
||||||
|
|
||||||
|
tinsert(options, 'and')
|
||||||
|
tinsert(options, 'or')
|
||||||
|
tinsert(options, 'not')
|
||||||
|
tinsert(options, 'tt')
|
||||||
|
|
||||||
|
-- classes
|
||||||
|
if not current_filter.class and not current_filter.exact then
|
||||||
|
for _, class in ipairs({ GetAuctionItemClasses() }) do
|
||||||
|
tinsert(options, class)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- subclasses
|
||||||
|
if current_filter.class and not current_filter.subclass then
|
||||||
|
for _, subclass in ipairs({ GetAuctionItemSubClasses(current_filter.class) }) do
|
||||||
|
tinsert(options, subclass)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- slots
|
||||||
|
if current_filter.class and current_filter.subclass and not current_filter.slot then
|
||||||
|
for _, invtype in ipairs({ GetAuctionInvTypes(current_filter.class, current_filter.subclass) }) do
|
||||||
|
tinsert(options, getglobal(invtype))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- usable
|
||||||
|
if not current_filter.usable and not current_filter.exact then
|
||||||
|
tinsert(options, 'usable')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- rarities
|
||||||
|
if not current_filter.quality and not current_filter.exact then
|
||||||
|
for i=0,4 do
|
||||||
|
tinsert(options, getglobal('ITEM_QUALITY'..i..'_DESC'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- discard
|
||||||
|
if not current_filter.discard then
|
||||||
|
tinsert(options, 'discard')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- item names
|
||||||
|
if not completed_filter_string then
|
||||||
|
local item_filters = {}
|
||||||
|
for key, value in Aux.static.auctionable_items do
|
||||||
|
if type(key) == 'number' then
|
||||||
|
tinsert(item_filters, value.name..'/exact')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return rating
|
sort(item_filters)
|
||||||
|
for _, item_name in ipairs(item_filters) do
|
||||||
|
tinsert(options, item_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
|
||||||
|
current_modifier = current_modifier or ''
|
||||||
|
|
||||||
|
for _, option in ipairs(options) do
|
||||||
|
if string.sub(strupper(option), 1, strlen(current_modifier)) == strupper(current_modifier) then
|
||||||
|
this:SetText(strlower(string.sub(filter_string, 1, start_index - 1)..option))
|
||||||
|
this:HighlightText(strlen(filter_string), -1)
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function generate_suggestions(input)
|
function m:complete_item()
|
||||||
local matcher = fuzzy(input)
|
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
||||||
function fuzzy_sort(array)
|
return
|
||||||
sort(array, function(a, b) return strlen(a.name) < strlen(b.name) end)
|
|
||||||
sort(array, function(a, b) return b.rating < a.rating end)
|
|
||||||
return array
|
|
||||||
end
|
|
||||||
|
|
||||||
local best = {}
|
|
||||||
for _, id in ipairs(Aux.static.item_ids()) do
|
|
||||||
local item_info = Aux.static.item_info(id)
|
|
||||||
local rating = matcher(item_info.name)
|
|
||||||
if rating then
|
|
||||||
local candidate = { name=item_info.name, id=item_info.id, rating=rating }
|
|
||||||
if getn(best) < NUM_MATCHES then
|
|
||||||
tinsert(best, candidate)
|
|
||||||
fuzzy_sort(best)
|
|
||||||
else
|
|
||||||
best[getn(best)] = fuzzy_sort({ best[getn(best)], candidate })[1]
|
|
||||||
fuzzy_sort(best)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Aux.util.map(best, function(match) return { text=match.name, display_text='|c'..Aux.quality_color(Aux.static.item_info(match.id).quality)..'['..match.name..']'..'|r', value=match.id } end)
|
local text = this:GetText()
|
||||||
end
|
|
||||||
|
|
||||||
function public.completor(edit_box)
|
local item_names = {}
|
||||||
local self = {}
|
for key, value in Aux.static.auctionable_items do
|
||||||
|
if type(key) == 'number' then
|
||||||
local suggestions = {}
|
tinsert(item_names, value.name)
|
||||||
local index = 0
|
|
||||||
local input
|
|
||||||
local quietly_set_text
|
|
||||||
|
|
||||||
local fill_dropdown, update_dropdown, update_highlighting
|
|
||||||
|
|
||||||
function fill_dropdown()
|
|
||||||
for _, suggestion in ipairs(suggestions) do
|
|
||||||
local text = suggestion.text
|
|
||||||
UIDropDownMenu_AddButton{
|
|
||||||
text = suggestion.display_text,
|
|
||||||
value = suggestion.value,
|
|
||||||
notCheckable = true,
|
|
||||||
func = function()
|
|
||||||
self.set_quietly(text)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
sort(item_names)
|
||||||
|
|
||||||
function update_dropdown()
|
for _, item_name in ipairs(item_names) do
|
||||||
function toggle()
|
if string.sub(strupper(item_name), 1, strlen(text)) == strupper(text) then
|
||||||
ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4)
|
this:SetText(strlower(item_name))
|
||||||
end
|
this:HighlightText(strlen(text), -1)
|
||||||
|
|
||||||
if DropDownList1:IsVisible() then
|
|
||||||
toggle()
|
|
||||||
end
|
|
||||||
toggle()
|
|
||||||
end
|
|
||||||
|
|
||||||
function update_highlighting()
|
|
||||||
for i=1,32 do
|
|
||||||
local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
|
||||||
if i == index then
|
|
||||||
highlight:Show()
|
|
||||||
else
|
|
||||||
highlight:Hide()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.close()
|
|
||||||
CloseDropDownMenus(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.set_quietly(text)
|
|
||||||
quietly_set_text = text
|
|
||||||
edit_box:SetText(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.open()
|
|
||||||
local _, owner = DropDownList1:GetPoint()
|
|
||||||
return DropDownList1:IsVisible() and owner == edit_box
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.suggest()
|
|
||||||
local new_input = edit_box:GetText()
|
|
||||||
if new_input == quietly_set_text then
|
|
||||||
quietly_set_text = nil
|
|
||||||
return
|
return
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function self.next()
|
|
||||||
update_dropdown()
|
|
||||||
if getn(suggestions) > 0 then
|
|
||||||
index = index > 0 and mod(index + 1, getn(suggestions) + 1) or 1
|
|
||||||
update_highlighting()
|
|
||||||
if index == 0 then
|
|
||||||
self.set_quietly(input)
|
|
||||||
else
|
|
||||||
self.set_quietly(suggestions[index].text)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function self.previous()
|
|
||||||
update_dropdown()
|
|
||||||
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].text)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.selector(edit_box, on_click)
|
--local NUM_MATCHES = 5
|
||||||
local self = {}
|
--
|
||||||
|
--local fuzzy, generate_suggestions
|
||||||
local suggestions = {}
|
--
|
||||||
local index = 0
|
--function fuzzy(input)
|
||||||
local input
|
-- local uppercase_input = strupper(input)
|
||||||
|
-- local pattern = '(.*)'
|
||||||
local fill_dropdown, update_dropdown, update_highlighting
|
-- for i=1,strlen(uppercase_input) do
|
||||||
|
-- if strfind(string.sub(uppercase_input, i, i), '%w') or strfind(string.sub(uppercase_input, i, i), '%s') then
|
||||||
function fill_dropdown()
|
-- pattern = pattern .. string.sub(uppercase_input, i, i) .. '(.*)'
|
||||||
for i, suggestion in ipairs(suggestions) do
|
-- end
|
||||||
local text = suggestion.text
|
-- end
|
||||||
UIDropDownMenu_AddButton{
|
-- return function(item_name)
|
||||||
text = suggestion.display_text,
|
-- local match = { string.find(strupper(item_name), pattern) }
|
||||||
value = i,
|
-- if match[1] then
|
||||||
notCheckable = true,
|
-- local rating = 0
|
||||||
func = function()
|
-- for i=4,getn(match)-1 do
|
||||||
index = this.value
|
-- if strlen(match[i]) == 0 then
|
||||||
if on_click then
|
-- rating = rating + 1
|
||||||
on_click()
|
-- end
|
||||||
end
|
-- end
|
||||||
end,
|
-- return rating
|
||||||
}
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
--end
|
||||||
|
--
|
||||||
function update_dropdown()
|
--function generate_suggestions(input)
|
||||||
function toggle()
|
-- local matcher = fuzzy(input)
|
||||||
ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4)
|
-- function fuzzy_sort(array)
|
||||||
end
|
-- sort(array, function(a, b) return strlen(a.name) < strlen(b.name) end)
|
||||||
|
-- sort(array, function(a, b) return b.rating < a.rating end)
|
||||||
if DropDownList1:IsVisible() then
|
-- return array
|
||||||
toggle()
|
-- end
|
||||||
end
|
--
|
||||||
toggle()
|
-- local best = {}
|
||||||
DropDownList1.aux = true
|
-- for _, id in ipairs(Aux.static.item_ids()) do
|
||||||
DropDownList1:SetScript('OnHide', function()
|
-- local item_info = Aux.static.item_info(id)
|
||||||
DropDownList1.aux = false
|
-- local rating = matcher(item_info.name)
|
||||||
end)
|
-- if rating then
|
||||||
end
|
-- local candidate = { name=item_info.name, id=item_info.id, rating=rating }
|
||||||
|
-- if getn(best) < NUM_MATCHES then
|
||||||
function update_highlighting()
|
-- tinsert(best, candidate)
|
||||||
for i=1,32 do
|
-- fuzzy_sort(best)
|
||||||
local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
-- else
|
||||||
if i == index then
|
-- best[getn(best)] = fuzzy_sort({ best[getn(best)], candidate })[1]
|
||||||
highlight:Show()
|
-- fuzzy_sort(best)
|
||||||
else
|
-- end
|
||||||
highlight:Hide()
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
--
|
||||||
end
|
-- return Aux.util.map(best, function(match) return { text=match.name, display_text='|c'..Aux.quality_color(Aux.static.item_info(match.id).quality)..'['..match.name..']'..'|r', value=match.id } end)
|
||||||
|
--end
|
||||||
function self.close()
|
--
|
||||||
CloseDropDownMenus(1)
|
--function public.completor(edit_box)
|
||||||
end
|
-- local self = {}
|
||||||
|
--
|
||||||
function self.open()
|
-- local suggestions = {}
|
||||||
local _, owner = DropDownList1:GetPoint()
|
-- local index = 0
|
||||||
return DropDownList1:IsVisible() and owner == edit_box
|
-- local input
|
||||||
end
|
-- local quietly_set_text
|
||||||
|
--
|
||||||
function self.suggest()
|
-- local fill_dropdown, update_dropdown, update_highlighting
|
||||||
local new_input = edit_box:GetText()
|
--
|
||||||
|
-- function fill_dropdown()
|
||||||
input = new_input
|
-- for _, suggestion in ipairs(suggestions) do
|
||||||
|
-- local text = suggestion.text
|
||||||
if input == '' then
|
-- UIDropDownMenu_AddButton{
|
||||||
suggestions = {}
|
-- text = suggestion.display_text,
|
||||||
else
|
-- value = suggestion.value,
|
||||||
suggestions = generate_suggestions(input)
|
-- notCheckable = true,
|
||||||
UIDropDownMenu_Initialize(AuxCompletionDropDown, fill_dropdown)
|
-- func = function()
|
||||||
end
|
-- self.set_quietly(text)
|
||||||
|
-- end,
|
||||||
index = 1
|
-- }
|
||||||
update_highlighting()
|
-- end
|
||||||
|
-- end
|
||||||
update_dropdown()
|
--
|
||||||
end
|
-- function update_dropdown()
|
||||||
|
-- function toggle()
|
||||||
function self.next()
|
-- ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4)
|
||||||
update_dropdown()
|
-- end
|
||||||
if getn(suggestions) > 0 then
|
--
|
||||||
index = mod(index, getn(suggestions)) + 1
|
-- if DropDownList1:IsVisible() then
|
||||||
update_highlighting()
|
-- toggle()
|
||||||
end
|
-- end
|
||||||
end
|
-- toggle()
|
||||||
|
-- end
|
||||||
function self.previous()
|
--
|
||||||
update_dropdown()
|
-- function update_highlighting()
|
||||||
if getn(suggestions) > 0 then
|
-- for i=1,32 do
|
||||||
index = index > 1 and index - 1 or getn(suggestions)
|
-- local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
||||||
update_highlighting()
|
-- if i == index then
|
||||||
end
|
-- highlight:Show()
|
||||||
end
|
-- else
|
||||||
|
-- highlight:Hide()
|
||||||
function self.selected_value()
|
-- end
|
||||||
return suggestions[index] and suggestions[index].value
|
-- end
|
||||||
end
|
-- end
|
||||||
|
--
|
||||||
function self.clear()
|
-- function self.close()
|
||||||
index = 1
|
-- CloseDropDownMenus(1)
|
||||||
suggestions = {}
|
-- end
|
||||||
end
|
--
|
||||||
|
-- function self.set_quietly(text)
|
||||||
return self
|
-- quietly_set_text = text
|
||||||
end
|
-- edit_box:SetText(text)
|
||||||
|
-- end
|
||||||
function public.UIDropDownMenu_StartCounting(frame)
|
--
|
||||||
if not frame.aux then
|
-- function self.open()
|
||||||
return Aux.orig.UIDropDownMenu_StartCounting(frame)
|
-- local _, owner = DropDownList1:GetPoint()
|
||||||
end
|
-- return DropDownList1:IsVisible() and owner == edit_box
|
||||||
end
|
-- 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()
|
||||||
|
-- update_dropdown()
|
||||||
|
-- if getn(suggestions) > 0 then
|
||||||
|
-- index = index > 0 and mod(index + 1, getn(suggestions) + 1) or 1
|
||||||
|
-- update_highlighting()
|
||||||
|
-- if index == 0 then
|
||||||
|
-- self.set_quietly(input)
|
||||||
|
-- else
|
||||||
|
-- self.set_quietly(suggestions[index].text)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.previous()
|
||||||
|
-- update_dropdown()
|
||||||
|
-- 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].text)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- return self
|
||||||
|
--end
|
||||||
|
--
|
||||||
|
--function public.selector(edit_box, on_click)
|
||||||
|
-- local self = {}
|
||||||
|
--
|
||||||
|
-- local suggestions = {}
|
||||||
|
-- local index = 0
|
||||||
|
-- local input
|
||||||
|
--
|
||||||
|
-- local fill_dropdown, update_dropdown, update_highlighting
|
||||||
|
--
|
||||||
|
-- function fill_dropdown()
|
||||||
|
-- for i, suggestion in ipairs(suggestions) do
|
||||||
|
-- local text = suggestion.text
|
||||||
|
-- UIDropDownMenu_AddButton{
|
||||||
|
-- text = suggestion.display_text,
|
||||||
|
-- value = i,
|
||||||
|
-- notCheckable = true,
|
||||||
|
-- func = function()
|
||||||
|
-- index = this.value
|
||||||
|
-- if on_click then
|
||||||
|
-- on_click()
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
-- }
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function update_dropdown()
|
||||||
|
-- function toggle()
|
||||||
|
-- ToggleDropDownMenu(1, nil, AuxCompletionDropDown, edit_box, -12, 4)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- if DropDownList1:IsVisible() then
|
||||||
|
-- toggle()
|
||||||
|
-- end
|
||||||
|
-- toggle()
|
||||||
|
-- DropDownList1.aux = true
|
||||||
|
-- DropDownList1:SetScript('OnHide', function()
|
||||||
|
-- DropDownList1.aux = false
|
||||||
|
-- end)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function update_highlighting()
|
||||||
|
-- for i=1,32 do
|
||||||
|
-- local highlight = getglobal('DropDownList1Button' .. i .. 'Highlight')
|
||||||
|
-- if i == index then
|
||||||
|
-- highlight:Show()
|
||||||
|
-- else
|
||||||
|
-- highlight:Hide()
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.close()
|
||||||
|
-- CloseDropDownMenus(1)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.open()
|
||||||
|
-- local _, owner = DropDownList1:GetPoint()
|
||||||
|
-- return DropDownList1:IsVisible() and owner == edit_box
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.suggest()
|
||||||
|
-- local new_input = edit_box:GetText()
|
||||||
|
--
|
||||||
|
-- input = new_input
|
||||||
|
--
|
||||||
|
-- if input == '' then
|
||||||
|
-- suggestions = {}
|
||||||
|
-- else
|
||||||
|
-- suggestions = generate_suggestions(input)
|
||||||
|
-- UIDropDownMenu_Initialize(AuxCompletionDropDown, fill_dropdown)
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- index = 1
|
||||||
|
-- update_highlighting()
|
||||||
|
--
|
||||||
|
-- update_dropdown()
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.next()
|
||||||
|
-- update_dropdown()
|
||||||
|
-- if getn(suggestions) > 0 then
|
||||||
|
-- index = mod(index, getn(suggestions)) + 1
|
||||||
|
-- update_highlighting()
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.previous()
|
||||||
|
-- update_dropdown()
|
||||||
|
-- if getn(suggestions) > 0 then
|
||||||
|
-- index = index > 1 and index - 1 or getn(suggestions)
|
||||||
|
-- update_highlighting()
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.selected_value()
|
||||||
|
-- return suggestions[index] and suggestions[index].value
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- function self.clear()
|
||||||
|
-- index = 1
|
||||||
|
-- suggestions = {}
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- return self
|
||||||
|
--end
|
||||||
|
--
|
||||||
|
--function public.UIDropDownMenu_StartCounting(frame)
|
||||||
|
-- if not frame.aux then
|
||||||
|
-- return Aux.orig.UIDropDownMenu_StartCounting(frame)
|
||||||
|
-- end
|
||||||
|
--end
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
AuxVersion = '2.4.13'
|
AuxVersion = '2.4.14'
|
||||||
AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)'
|
AuxAuthors = 'shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)'
|
||||||
|
|
||||||
Aux = {
|
Aux = {
|
||||||
@@ -174,8 +174,8 @@ function Aux.setup_hooks()
|
|||||||
Aux.orig.AuctionFrameAuctions_OnEvent = AuctionFrameAuctions_OnEvent
|
Aux.orig.AuctionFrameAuctions_OnEvent = AuctionFrameAuctions_OnEvent
|
||||||
AuctionFrameAuctions_OnEvent = Aux.AuctionFrameAuctions_OnEvent
|
AuctionFrameAuctions_OnEvent = Aux.AuctionFrameAuctions_OnEvent
|
||||||
|
|
||||||
Aux.orig.UIDropDownMenu_StartCounting = UIDropDownMenu_StartCounting
|
-- Aux.orig.UIDropDownMenu_StartCounting = UIDropDownMenu_StartCounting
|
||||||
UIDropDownMenu_StartCounting = Aux.completion.UIDropDownMenu_StartCounting
|
-- UIDropDownMenu_StartCounting = Aux.completion.UIDropDownMenu_StartCounting
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,6 @@ function m.editbox(parent, name)
|
|||||||
-- frame:Hide()
|
-- frame:Hide()
|
||||||
|
|
||||||
local editbox = CreateFrame('EditBox', name, parent)
|
local editbox = CreateFrame('EditBox', name, parent)
|
||||||
editbox.selector = Aux.completion.selector(editbox)
|
|
||||||
editbox:SetAutoFocus(false)
|
editbox:SetAutoFocus(false)
|
||||||
editbox:SetTextInsets(0, 0, 3, 3)
|
editbox:SetTextInsets(0, 0, 3, 3)
|
||||||
editbox:SetMaxLetters(256)
|
editbox:SetMaxLetters(256)
|
||||||
|
|||||||
+25
-5
@@ -158,6 +158,23 @@ function private.get_form_filter()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function private.prettify_search(search)
|
||||||
|
local item_pattern = '([^/;]+)([^;]*)/exact'
|
||||||
|
while true do
|
||||||
|
local _, _, name, in_between = strfind(search, item_pattern)
|
||||||
|
if name then
|
||||||
|
search = gsub(search, item_pattern, private.display_name(Aux.static.auctionable_items[strupper(name)])..in_between, 1)
|
||||||
|
else
|
||||||
|
return Aux.gui.inline_color({216, 225, 211, 1})..search..'|r'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function private.display_name(item_id)
|
||||||
|
local item_info = Aux.static.item_info(item_id)
|
||||||
|
return '|c'..Aux.quality_color(item_info.quality)..'['..item_info.name..']'..'|r'
|
||||||
|
end
|
||||||
|
|
||||||
function public.on_open()
|
function public.on_open()
|
||||||
private.update_search_listings()
|
private.update_search_listings()
|
||||||
end
|
end
|
||||||
@@ -177,7 +194,7 @@ function public.on_load()
|
|||||||
btn:SetWidth(60)
|
btn:SetWidth(60)
|
||||||
btn:SetHeight(25)
|
btn:SetHeight(25)
|
||||||
btn:SetText('Search')
|
btn:SetText('Search')
|
||||||
btn:SetScript('OnClick', Aux.search_frame.start_search)
|
btn:SetScript('OnClick', public.start_search)
|
||||||
private.search_button = btn
|
private.search_button = btn
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
@@ -194,7 +211,7 @@ function public.on_load()
|
|||||||
local editbox = Aux.gui.editbox(AuxFilterSearchFrame)
|
local editbox = Aux.gui.editbox(AuxFilterSearchFrame)
|
||||||
editbox:SetMaxLetters(nil)
|
editbox:SetMaxLetters(nil)
|
||||||
editbox:EnableMouse(1)
|
editbox:EnableMouse(1)
|
||||||
editbox.complete = Aux.test.complete
|
editbox.complete = Aux.completion.complete
|
||||||
editbox:SetPoint('TOPLEFT', 5, -8)
|
editbox:SetPoint('TOPLEFT', 5, -8)
|
||||||
editbox:SetPoint('RIGHT', private.search_button, 'LEFT', -4, 0)
|
editbox:SetPoint('RIGHT', private.search_button, 'LEFT', -4, 0)
|
||||||
editbox:SetWidth(400)
|
editbox:SetWidth(400)
|
||||||
@@ -314,7 +331,7 @@ function public.on_load()
|
|||||||
end
|
end
|
||||||
do
|
do
|
||||||
local editbox = Aux.gui.editbox(AuxFilterSearchFrameFilter, '$parentNameInputBox')
|
local editbox = Aux.gui.editbox(AuxFilterSearchFrameFilter, '$parentNameInputBox')
|
||||||
editbox.complete_item = Aux.test.complete_item
|
editbox.complete_item = Aux.completion.complete_item
|
||||||
editbox:SetPoint('TOPLEFT', 14, -20)
|
editbox:SetPoint('TOPLEFT', 14, -20)
|
||||||
editbox:SetWidth(300)
|
editbox:SetWidth(300)
|
||||||
editbox:SetScript('OnChar', function()
|
editbox:SetScript('OnChar', function()
|
||||||
@@ -767,9 +784,12 @@ function public.stop_search()
|
|||||||
Aux.scan.abort()
|
Aux.scan.abort()
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.start_search()
|
function public.start_search(filter_string)
|
||||||
|
|
||||||
Aux.scan.abort(function()
|
Aux.scan.abort(function()
|
||||||
|
if filter_string then
|
||||||
|
private.search_box:SetText(filter_string)
|
||||||
|
end
|
||||||
|
|
||||||
local queries
|
local queries
|
||||||
|
|
||||||
@@ -787,7 +807,7 @@ function public.start_search()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
tinsert(aux_recent_searches, 1, { filter_string = private.search_box:GetText(), prettified = Aux.test.prettify_search(private.search_box:GetText()) })
|
tinsert(aux_recent_searches, 1, { filter_string = private.search_box:GetText(), prettified = private.prettify_search(private.search_box:GetText()) })
|
||||||
while getn(aux_recent_searches) > 50 do
|
while getn(aux_recent_searches) > 50 do
|
||||||
tremove(aux_recent_searches)
|
tremove(aux_recent_searches)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,146 +1,6 @@
|
|||||||
local m = {}
|
local m = {}
|
||||||
Aux.test = m
|
Aux.test = m
|
||||||
|
|
||||||
function m.prettify_search(search)
|
|
||||||
local item_pattern = '([^/;]+)([^;]*)/exact'
|
|
||||||
while true do
|
|
||||||
local _, _, name, in_between = strfind(search, item_pattern)
|
|
||||||
if name then
|
|
||||||
search = gsub(search, item_pattern, m.display_name(Aux.static.auctionable_items[strupper(name)])..in_between, 1)
|
|
||||||
else
|
|
||||||
return Aux.gui.inline_color({216, 225, 211, 1})..search..'|r'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function m.display_name(item_id)
|
|
||||||
local item_info = Aux.static.item_info(item_id)
|
|
||||||
return '|c'..Aux.quality_color(item_info.quality)..'['..item_info.name..']'..'|r'
|
|
||||||
end
|
|
||||||
|
|
||||||
function m:complete()
|
|
||||||
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local filter_string = this:GetText()
|
|
||||||
|
|
||||||
local completed_filter_string = ({strfind(filter_string, '([^;]*)/[^/;]*$')})[3]
|
|
||||||
local current_filter = completed_filter_string and Aux.scan_util.filter_from_string(completed_filter_string)
|
|
||||||
|
|
||||||
local options = {}
|
|
||||||
|
|
||||||
if current_filter or not completed_filter_string then
|
|
||||||
current_filter = current_filter or {}
|
|
||||||
|
|
||||||
if current_filter.name
|
|
||||||
and Aux.static.auctionable_items[strupper(current_filter.name)]
|
|
||||||
and not current_filter.min_level
|
|
||||||
and not current_filter.max_level
|
|
||||||
and not current_filter.class
|
|
||||||
and not current_filter.subclass
|
|
||||||
and not current_filter.slot
|
|
||||||
and not current_filter.quality
|
|
||||||
and not current_filter.usable
|
|
||||||
and not current_filter.exact
|
|
||||||
then
|
|
||||||
tinsert(options, 'exact')
|
|
||||||
end
|
|
||||||
|
|
||||||
tinsert(options, 'and')
|
|
||||||
tinsert(options, 'or')
|
|
||||||
tinsert(options, 'not')
|
|
||||||
tinsert(options, 'tt')
|
|
||||||
|
|
||||||
-- classes
|
|
||||||
if not current_filter.class and not current_filter.exact then
|
|
||||||
for _, class in ipairs({ GetAuctionItemClasses() }) do
|
|
||||||
tinsert(options, class)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- subclasses
|
|
||||||
if current_filter.class and not current_filter.subclass then
|
|
||||||
for _, subclass in ipairs({ GetAuctionItemSubClasses(current_filter.class) }) do
|
|
||||||
tinsert(options, subclass)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- slots
|
|
||||||
if current_filter.class and current_filter.subclass and not current_filter.slot then
|
|
||||||
for _, invtype in ipairs({ GetAuctionInvTypes(current_filter.class, current_filter.subclass) }) do
|
|
||||||
tinsert(options, getglobal(invtype))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- usable
|
|
||||||
if not current_filter.usable and not current_filter.exact then
|
|
||||||
tinsert(options, 'usable')
|
|
||||||
end
|
|
||||||
|
|
||||||
-- rarities
|
|
||||||
if not current_filter.quality and not current_filter.exact then
|
|
||||||
for i=0,4 do
|
|
||||||
tinsert(options, getglobal('ITEM_QUALITY'..i..'_DESC'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- discard
|
|
||||||
if not current_filter.discard then
|
|
||||||
tinsert(options, 'discard')
|
|
||||||
end
|
|
||||||
|
|
||||||
-- item names
|
|
||||||
if not completed_filter_string then
|
|
||||||
local item_filters = {}
|
|
||||||
for key, value in Aux.static.auctionable_items do
|
|
||||||
if type(key) == 'number' then
|
|
||||||
tinsert(item_filters, value.name..'/exact')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sort(item_filters)
|
|
||||||
for _, item_name in ipairs(item_filters) do
|
|
||||||
tinsert(options, item_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
|
|
||||||
current_modifier = current_modifier or ''
|
|
||||||
|
|
||||||
for _, option in ipairs(options) do
|
|
||||||
if string.sub(strupper(option), 1, strlen(current_modifier)) == strupper(current_modifier) then
|
|
||||||
this:SetText(strlower(string.sub(filter_string, 1, start_index - 1)..option))
|
|
||||||
this:HighlightText(strlen(filter_string), -1)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function m:complete_item()
|
|
||||||
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local text = this:GetText()
|
|
||||||
|
|
||||||
local item_names = {}
|
|
||||||
for key, value in Aux.static.auctionable_items do
|
|
||||||
if type(key) == 'number' then
|
|
||||||
tinsert(item_names, value.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sort(item_names)
|
|
||||||
|
|
||||||
for _, item_name in ipairs(item_names) do
|
|
||||||
if string.sub(strupper(item_name), 1, strlen(text)) == strupper(text) then
|
|
||||||
this:SetText(strlower(item_name))
|
|
||||||
this:HighlightText(strlen(text), -1)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--StaticPopupDialogs["CANCEL_AUCTION"] = {
|
--StaticPopupDialogs["CANCEL_AUCTION"] = {
|
||||||
-- text = TEXT(CANCEL_AUCTION_CONFIRMATION),
|
-- text = TEXT(CANCEL_AUCTION_CONFIRMATION),
|
||||||
-- button1 = TEXT(ACCEPT),
|
-- button1 = TEXT(ACCEPT),
|
||||||
|
|||||||
Reference in New Issue
Block a user