completely implemented polish notation tooltip filters
This commit is contained in:
@@ -326,10 +326,10 @@ function Aux.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
end
|
||||
|
||||
function Aux.item_slot(class_index, subclass_index, slot_name)
|
||||
for _, slot in ipairs({ GetAuctionInvTypes(class_index, subclass_index) }) do
|
||||
function Aux.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in ipairs({ GetAuctionInvTypes(class_index, subclass_index) }) do
|
||||
if strupper(getglobal(slot)) == strupper(slot_name) then
|
||||
return slot
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -188,10 +188,10 @@ function public.tooltip(setter)
|
||||
local left, right = {}, {}
|
||||
|
||||
left.text = getglobal('AuxInfoTooltipTextLeft'..i):GetText()
|
||||
left.r, left.b, left.g = getglobal('AuxInfoTooltipTextLeft'..i):GetTextColor()
|
||||
left.color = { getglobal('AuxInfoTooltipTextLeft'..i):GetTextColor() }
|
||||
|
||||
right.text = getglobal('AuxInfoTooltipTextRight'..i):GetText()
|
||||
right.r, right.b, right.g = getglobal('AuxInfoTooltipTextRight'..i):GetTextColor()
|
||||
right.color = { getglobal('AuxInfoTooltipTextRight'..i):GetTextColor() }
|
||||
|
||||
tinsert(tooltip, {left or '', right or ''})
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ end
|
||||
function wait_for_owner_data(k)
|
||||
local t0 = time()
|
||||
return controller().wait(function()
|
||||
if time() - t0 > 10 then -- we won't wait longer than 10 seconds
|
||||
if time() - t0 > 4 then -- we won't wait longer than 4 seconds
|
||||
return true
|
||||
end
|
||||
local count, _ = GetNumAuctionItems(current_query().type)
|
||||
|
||||
+35
-5
@@ -91,7 +91,13 @@ function m.filter_from_string(filter_term)
|
||||
for i, str in ipairs(parts) do
|
||||
str = Aux.util.trim(str)
|
||||
|
||||
if tonumber(str) then
|
||||
if strupper(str) == 'AND' or strupper(str) == 'OR' or strupper(str) == 'NOT' or strupper(str) == 'TT' then
|
||||
filter.tooltip = {}
|
||||
for j=i,getn(parts) do
|
||||
tinsert(filter.tooltip, parts[j])
|
||||
end
|
||||
break
|
||||
elseif tonumber(str) then
|
||||
if not filter.min_level then
|
||||
filter.min_level = tonumber(str)
|
||||
elseif not filter.max_level and tonumber(str) >= filter.min_level then
|
||||
@@ -99,7 +105,7 @@ function m.filter_from_string(filter_term)
|
||||
else
|
||||
return false, 'Invalid Level Range'
|
||||
end
|
||||
elseif not filter.class and Aux.item_class_index(str) then
|
||||
elseif Aux.item_class_index(str) then
|
||||
if not filter.class then
|
||||
filter.class = Aux.item_class_index(str)
|
||||
else
|
||||
@@ -111,9 +117,9 @@ function m.filter_from_string(filter_term)
|
||||
else
|
||||
return false, 'Invalid Item Subclass'
|
||||
end
|
||||
elseif filter.subclass and Aux.item_slot(filter.class, filter.class, str) then
|
||||
elseif filter.subclass and Aux.item_slot_index(filter.class, filter.subclass, str) then
|
||||
if not filter.slot then
|
||||
filter.slot = Aux.item_slot(filter.class, filter.class, str)
|
||||
filter.slot = Aux.item_slot_index(filter.class, filter.subclass, str)
|
||||
else
|
||||
return false, 'Invalid Item Slot'
|
||||
end
|
||||
@@ -221,6 +227,12 @@ function m.filter_to_string(filter)
|
||||
add('/discard')
|
||||
end
|
||||
|
||||
if filter.tooltip then
|
||||
for _, part in ipairs(filter.tooltip) do
|
||||
add(part)
|
||||
end
|
||||
end
|
||||
|
||||
return filter_term
|
||||
end
|
||||
|
||||
@@ -236,9 +248,9 @@ function m.blizzard_query(filter)
|
||||
name = filter.name,
|
||||
min_level = filter.exact and item_info.level or filter.min_level,
|
||||
max_level = filter.exact and item_info.level or filter.max_level,
|
||||
slot = filter.exact and item_info.slot or filter.slot,
|
||||
class = filter.exact and item_info.class or filter.class,
|
||||
subclass = filter.exact and item_info.subclass or filter.subclass,
|
||||
slot = filter.exact and (item_info.class and item_info.subclass and Aux.item_slot_index(item_info.class, item_info.subclass, item_info.slot)) or filter.slot,
|
||||
usable = filter.exact and item_info.usable or filter.usable and 1 or 0,
|
||||
quality = filter.exact and item_info.quality or filter.quality,
|
||||
}
|
||||
@@ -268,6 +280,24 @@ function m.validator(filter)
|
||||
then
|
||||
return
|
||||
end
|
||||
if filter.tooltip then
|
||||
local stack = {}
|
||||
for i=getn(filter.tooltip),1,-1 do
|
||||
local op = strupper(filter.tooltip[i])
|
||||
if op == 'AND' then
|
||||
tinsert(stack, tremove(stack) and tremove(stack))
|
||||
elseif op == 'OR' then
|
||||
tinsert(stack, tremove(stack) or tremove(stack))
|
||||
elseif op == 'NOT' then
|
||||
tinsert(stack, not tremove(stack))
|
||||
elseif op ~= 'TT' then
|
||||
tinsert(stack, Aux.util.any(record.tooltip, function(entry)
|
||||
return strfind(strupper(entry[1].text or ''), strupper(op), 1, true) or strfind(strupper(entry[2].text or ''), strupper(op), 1, true)
|
||||
end))
|
||||
end
|
||||
end
|
||||
return tremove(stack)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
+20
-8
@@ -113,11 +113,30 @@ function private.clear_filter()
|
||||
AuxFilterSearchFrameFilterDiscardCheckButton:SetChecked(nil)
|
||||
private.max_buyout_price:SetText('')
|
||||
private.max_percent:SetText('')
|
||||
private.tooltip1:SetText('')
|
||||
private.tooltip2:SetText('')
|
||||
private.tooltip3:SetText('')
|
||||
private.tooltip4:SetText('')
|
||||
private.tooltip5:SetText('')
|
||||
private.tooltip6:SetText('')
|
||||
end
|
||||
|
||||
function private.get_form_filter()
|
||||
local exact = AuxFilterSearchFrameFilterExactCheckButton:GetChecked()
|
||||
local max_price = Aux.money.from_string(private.max_buyout_price:GetText())
|
||||
local tooltip = Aux.util.filter({
|
||||
private.tooltip1:GetText(),
|
||||
private.tooltip2:GetText(),
|
||||
private.tooltip3:GetText(),
|
||||
private.tooltip4:GetText(),
|
||||
private.tooltip5:GetText(),
|
||||
private.tooltip6:GetText(),
|
||||
}, function(entry) return entry ~= '' end)
|
||||
|
||||
for i=1,getn(tooltip)-1 do
|
||||
tinsert(tooltip, 1, 'and')
|
||||
end
|
||||
|
||||
return {
|
||||
name = AuxFilterSearchFrameFilterNameInputBox:GetText(),
|
||||
exact = AuxFilterSearchFrameFilterExactCheckButton:GetChecked(),
|
||||
@@ -131,6 +150,7 @@ function private.get_form_filter()
|
||||
discard = AuxFilterSearchFrameFilterDiscardCheckButton:GetChecked(),
|
||||
max_price = max_price > 0 and max_price,
|
||||
max_percent = tonumber(private.max_percent:GetText()),
|
||||
tooltip = getn(tooltip) > 0 and tooltip,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -712,14 +732,6 @@ function public.start_search()
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
-- local tooltip_patterns = {}
|
||||
-- for i=1,4 do
|
||||
-- local tooltip_pattern = getglobal('AuxFilterSearchFrameFilterTooltipInputBox'..i):GetText()
|
||||
-- if tooltip_pattern ~= '' then
|
||||
-- tinsert(tooltip_patterns, tooltip_pattern)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local queries
|
||||
|
||||
local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText())
|
||||
|
||||
@@ -59,7 +59,7 @@ function m:complete()
|
||||
end
|
||||
|
||||
-- slots
|
||||
if current_filter.class and current_filter.subclass then
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user