From 8c945478c8a04b20b2e6f5ec66eedaea164fa26e Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 5 Mar 2016 13:12:34 +0100 Subject: [PATCH] working on query extension --- scan_util.lua | 61 ------------------------------------------- search_frame.lua | 68 +++++++++++++++++++++++++++++++++--------------- search_frame.xml | 4 --- 3 files changed, 47 insertions(+), 86 deletions(-) diff --git a/scan_util.lua b/scan_util.lua index ab0583c..bd98c57 100644 --- a/scan_util.lua +++ b/scan_util.lua @@ -596,67 +596,6 @@ function m.suggestions(blizzard_filter, num_parts) return suggestions end -function m.filter_to_string(filter) - - local filter_term = filter.name or '' - - local function add(part) - filter_term = filter_term == '' and part or filter_term..'/'..part - end - - if filter.exact then - add('exact') - end - - if filter.min_level then - add(filter.min_level) - end - - if filter.max_level then - add(filter.max_level) - end - - if filter.usable then - add('usable') - end - - if filter.class then - local classes = { GetAuctionItemClasses() } - add(strlower(classes[filter.class])) - if filter.subclass then - local subclasses = {GetAuctionItemSubClasses(filter.class)} - add(strlower(subclasses[filter.subclass])) - if filter.slot then - add(strlower(getglobal(filter.slot))) - end - end - end - - if filter.quality then - add(strlower(getglobal('ITEM_QUALITY'..filter.quality..'_DESC'))) - end - - if filter.max_price then - add(Aux.money.to_string(filter.max_price, nil, true, nil, nil, true)) - end - - if filter.max_percent then - add(filter.max_percent..'%') - end - - if filter.discard then - add('discard') - end - - if filter.tooltip then - for _, part in ipairs(filter.tooltip) do - add(part) - end - end - - return filter_term -end - function m.blizzard_query(filter) local item_info diff --git a/search_frame.lua b/search_frame.lua index 22419b4..4d96938 100644 --- a/search_frame.lua +++ b/search_frame.lua @@ -90,7 +90,7 @@ function public.set_filter(filter_string) end function private.add_filter(filter_string, replace) - filter_string = filter_string or Aux.scan_util.filter_to_string(private.get_form_filter()) + filter_string = filter_string or private.get_form_filter() local old_filter_string @@ -116,7 +116,6 @@ function private.clear_filter() UIDropDownMenu_ClearAll(private.slot_dropdown) UIDropDownMenu_ClearAll(private.quality_dropdown) AuxSearchFrameFilterUsableCheckButton:SetChecked(nil) - AuxSearchFrameFilterDiscardCheckButton:SetChecked(nil) private.max_buyout_price:SetText('') private.max_percent:SetText('') private.tooltip1:SetText('') @@ -128,19 +127,51 @@ function private.clear_filter() end function private.get_form_filter() - local exact = AuxSearchFrameFilterExactCheckButton:GetChecked() + local filter_term = '' - return { - name = AuxSearchFrameFilterNameInputBox:GetText(), - exact = AuxSearchFrameFilterExactCheckButton:GetChecked(), - min_level = not exact and tonumber(AuxSearchFrameFilterMinLevel:GetText()), - max_level = not exact and tonumber(AuxSearchFrameFilterMaxLevel:GetText()), - class = not exact and UIDropDownMenu_GetSelectedValue(private.class_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.class_dropdown), - subclass = not exact and UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.subclass_dropdown), - slot = not exact and UIDropDownMenu_GetSelectedValue(private.slot_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.slot_dropdown), - quality = not exact and UIDropDownMenu_GetSelectedValue(private.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.quality_dropdown), - usable = not exact and AuxSearchFrameFilterUsableCheckButton:GetChecked(), - } + local function add(part) + filter_term = filter_term == '' and part or filter_term..'/'..part + end + + add(AuxSearchFrameFilterNameInputBox:GetText()) + + if AuxSearchFrameFilterExactCheckButton:GetChecked() then + add('exact') + end + + if tonumber(AuxSearchFrameFilterMinLevel:GetText()) then + add(tonumber(AuxSearchFrameFilterMinLevel:GetText())) + end + + if tonumber(AuxSearchFrameFilterMaxLevel:GetText()) then + add(tonumber(AuxSearchFrameFilterMaxLevel:GetText())) + end + + if AuxSearchFrameFilterUsableCheckButton:GetChecked() then + add('usable') + end + + local class = UIDropDownMenu_GetSelectedValue(private.class_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.class_dropdown) + if class then + local classes = { GetAuctionItemClasses() } + add(strlower(classes[class])) + local subclass = UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) + if subclass then + local subclasses = {GetAuctionItemSubClasses(class)} + add(strlower(subclasses[subclass])) + local slot = UIDropDownMenu_GetSelectedValue(private.slot_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.slot_dropdown) + if slot then + add(strlower(getglobal(slot))) + end + end + end + + local quality = UIDropDownMenu_GetSelectedValue(private.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.quality_dropdown) + if quality then + add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC'))) + end + + return filter_term end function public.on_open() @@ -306,7 +337,7 @@ function public.on_load() end) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then - private.tooltip6:SetFocus() + getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus() else getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() end @@ -362,7 +393,7 @@ function public.on_load() if IsShiftKeyDown() then getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() else - private.max_buyout_price:SetFocus() + getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus() end end) editbox:SetScript('OnEnterPressed', function() @@ -441,11 +472,6 @@ function public.on_load() label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterExactCheckButton, 'TOPLEFT', 1, -3) label:SetText('Exact') end - do - local label = Aux.gui.label(AuxSearchFrameFilterDiscardCheckButton, 13) - label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterDiscardCheckButton, 'TOPLEFT', 1, -3) - label:SetText('Discard') - end do local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13) label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3) diff --git a/search_frame.xml b/search_frame.xml index 95a8123..3db4a06 100644 --- a/search_frame.xml +++ b/search_frame.xml @@ -23,10 +23,6 @@ - - - -