working on query extension

This commit is contained in:
Manuel Simon Hirsig
2016-03-05 13:12:34 +01:00
parent 8351d56f3b
commit 8c945478c8
3 changed files with 47 additions and 86 deletions
-61
View File
@@ -596,67 +596,6 @@ function m.suggestions(blizzard_filter, num_parts)
return suggestions return suggestions
end 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) function m.blizzard_query(filter)
local item_info local item_info
+47 -21
View File
@@ -90,7 +90,7 @@ function public.set_filter(filter_string)
end end
function private.add_filter(filter_string, replace) 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 local old_filter_string
@@ -116,7 +116,6 @@ function private.clear_filter()
UIDropDownMenu_ClearAll(private.slot_dropdown) UIDropDownMenu_ClearAll(private.slot_dropdown)
UIDropDownMenu_ClearAll(private.quality_dropdown) UIDropDownMenu_ClearAll(private.quality_dropdown)
AuxSearchFrameFilterUsableCheckButton:SetChecked(nil) AuxSearchFrameFilterUsableCheckButton:SetChecked(nil)
AuxSearchFrameFilterDiscardCheckButton:SetChecked(nil)
private.max_buyout_price:SetText('') private.max_buyout_price:SetText('')
private.max_percent:SetText('') private.max_percent:SetText('')
private.tooltip1:SetText('') private.tooltip1:SetText('')
@@ -128,19 +127,51 @@ function private.clear_filter()
end end
function private.get_form_filter() function private.get_form_filter()
local exact = AuxSearchFrameFilterExactCheckButton:GetChecked() local filter_term = ''
return { local function add(part)
name = AuxSearchFrameFilterNameInputBox:GetText(), filter_term = filter_term == '' and part or filter_term..'/'..part
exact = AuxSearchFrameFilterExactCheckButton:GetChecked(), end
min_level = not exact and tonumber(AuxSearchFrameFilterMinLevel:GetText()),
max_level = not exact and tonumber(AuxSearchFrameFilterMaxLevel:GetText()), add(AuxSearchFrameFilterNameInputBox: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), if AuxSearchFrameFilterExactCheckButton:GetChecked() then
slot = not exact and UIDropDownMenu_GetSelectedValue(private.slot_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.slot_dropdown), add('exact')
quality = not exact and UIDropDownMenu_GetSelectedValue(private.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.quality_dropdown), end
usable = not exact and AuxSearchFrameFilterUsableCheckButton:GetChecked(),
} 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 end
function public.on_open() function public.on_open()
@@ -306,7 +337,7 @@ function public.on_load()
end) end)
editbox:SetScript('OnTabPressed', function() editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then if IsShiftKeyDown() then
private.tooltip6:SetFocus() getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
else else
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
end end
@@ -362,7 +393,7 @@ function public.on_load()
if IsShiftKeyDown() then if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus() getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
else else
private.max_buyout_price:SetFocus() getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
end end
end) end)
editbox:SetScript('OnEnterPressed', function() editbox:SetScript('OnEnterPressed', function()
@@ -441,11 +472,6 @@ function public.on_load()
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterExactCheckButton, 'TOPLEFT', 1, -3) label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterExactCheckButton, 'TOPLEFT', 1, -3)
label:SetText('Exact') label:SetText('Exact')
end end
do
local label = Aux.gui.label(AuxSearchFrameFilterDiscardCheckButton, 13)
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterDiscardCheckButton, 'TOPLEFT', 1, -3)
label:SetText('Discard')
end
do do
local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13) local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13)
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3) label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3)
-4
View File
@@ -23,10 +23,6 @@
<Size><AbsDimension x="22" y="22"/></Size> <Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentExactCheckButton" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="0" y="-20" /></Offset></Anchor></Anchors> <Anchors><Anchor point="TOPLEFT" relativeTo="$parentExactCheckButton" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="0" y="-20" /></Offset></Anchor></Anchors>
</CheckButton> </CheckButton>
<CheckButton name="$parentDiscardCheckButton" inherits="UICheckButtonTemplate">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT" relativeTo="$parentUsableCheckButton" relativePoint="BOTTOMLEFT"><Offset><AbsDimension x="0" y="-20" /></Offset></Anchor></Anchors>
</CheckButton>
</Frames> </Frames>
</Frame> </Frame>
<Frame name="$parentResults" inherits="AuxFrameBoxTemplate"> <Frame name="$parentResults" inherits="AuxFrameBoxTemplate">