lots of additions in the filter search
This commit is contained in:
@@ -24,6 +24,8 @@ function Aux_OnLoad()
|
||||
LoadAddOn('EnhTooltip')
|
||||
if IsAddOnLoaded('EnhTooltip') then
|
||||
Stubby.RegisterFunctionHook('EnhTooltip.AddTooltip', 100, function(_ ,_ ,_ ,_ , link, _, count)
|
||||
if EnhTooltip.LinkType(link) ~= 'item' then return end
|
||||
|
||||
local item_id, suffix_id = EnhTooltip.BreakLink(link)
|
||||
local item_key = (item_id or 0)..':'..(suffix_id or 0)
|
||||
|
||||
@@ -383,7 +385,7 @@ end
|
||||
|
||||
function Aux.item_class_index(item_class)
|
||||
for i, class in ipairs({ GetAuctionItemClasses() }) do
|
||||
if class == item_class then
|
||||
if strlower(class) == strlower(item_class) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
@@ -391,7 +393,7 @@ end
|
||||
|
||||
function Aux.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in ipairs({ GetAuctionItemSubClasses(class_index) }) do
|
||||
if subclass == item_subclass then
|
||||
if strlower(subclass) == strlower(item_subclass) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
|
||||
+178
-61
@@ -1,11 +1,71 @@
|
||||
local private, public = {}, {}
|
||||
Aux.filter_search_frame = public
|
||||
|
||||
aux_favorite_searches = {}
|
||||
aux_recent_searches = {}
|
||||
|
||||
local auctions
|
||||
local tooltip_patterns = {}
|
||||
local refresh
|
||||
local selected_auction
|
||||
|
||||
local RESULTS, SAVED, FILTER = {}, {}, {}
|
||||
|
||||
function private.update_search_listings()
|
||||
Aux.sheet.populate(private.listings.favorite_searches, aux_favorite_searches)
|
||||
Aux.sheet.populate(private.listings.recent_searches, aux_recent_searches)
|
||||
end
|
||||
|
||||
function private.update_tab(tab)
|
||||
|
||||
private.search_results_button:UnlockHighlight()
|
||||
private.saved_searches_button:UnlockHighlight()
|
||||
private.new_filter_button:UnlockHighlight()
|
||||
AuxFilterSearchFrameResults:Hide()
|
||||
AuxFilterSearchFrameSaved:Hide()
|
||||
AuxFilterSearchFrameFilters:Hide()
|
||||
|
||||
if tab == RESULTS then
|
||||
AuxFilterSearchFrameResults:Show()
|
||||
private.search_results_button:LockHighlight()
|
||||
elseif tab == SAVED then
|
||||
AuxFilterSearchFrameSaved:Show()
|
||||
elseif tab == FILTER then
|
||||
AuxFilterSearchFrameFilters:Show()
|
||||
private.new_filter_button:LockHighlight()
|
||||
end
|
||||
end
|
||||
|
||||
function private.add_filter()
|
||||
local old_filter_string = private.search_box:GetText()
|
||||
old_filter_string = Aux.util.trim(old_filter_string)
|
||||
|
||||
if not string.sub(old_filter_string, strlen(old_filter_string), strlen(old_filter_string)) == ';' then
|
||||
old_filter_string = old_filter_string..';'
|
||||
end
|
||||
|
||||
private.search_box:SetText(old_filter_string..Aux.scan_util.filter_to_string(private.get_form_filter()))
|
||||
end
|
||||
|
||||
function private.clear_filter()
|
||||
|
||||
end
|
||||
|
||||
function private.get_form_filter()
|
||||
local category = UIDropDownMenu_GetSelectedValue(AuxFilterSearchFrameFiltersCategoryDropDown)
|
||||
|
||||
return {
|
||||
name = AuxFilterSearchFrameFiltersNameInputBox:GetText(),
|
||||
min_level = tonumber(AuxFilterSearchFrameFiltersMinLevel:GetText()),
|
||||
max_level = tonumber(AuxFilterSearchFrameFiltersMaxLevel:GetText()),
|
||||
slot = category and category.slot,
|
||||
class = category and category.class,
|
||||
subclass = category and category.subclass,
|
||||
quality = UIDropDownMenu_GetSelectedValue(AuxFilterSearchFrameFiltersQualityDropDown),
|
||||
usable_only = AuxFilterSearchFrameFiltersUsableCheckButton:GetChecked()
|
||||
}
|
||||
end
|
||||
|
||||
function private.select_auction(entry)
|
||||
selected_auction = entry
|
||||
refresh = true
|
||||
@@ -25,10 +85,53 @@ function public.on_close()
|
||||
end
|
||||
|
||||
function public.on_open()
|
||||
private.tab_group:set_tab(aux_view)
|
||||
private.update_search_listings()
|
||||
private.update_tab(RESULTS)
|
||||
-- private.tab_group:set_tab(aux_view)
|
||||
Aux.filter_search_frame.set_view(aux_view)
|
||||
end
|
||||
|
||||
function public.on_load()
|
||||
private.recent_searches_config = {
|
||||
plain = true,
|
||||
frame = AuxFilterSearchFrameSavedFavoriteListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
-- sheet.data[data_index]
|
||||
end,
|
||||
columns = {
|
||||
{
|
||||
width = 300,
|
||||
comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, filter_string)
|
||||
cell.text:SetText(filter_string)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {},
|
||||
}
|
||||
private.favorite_searches_config = {
|
||||
plain = true,
|
||||
frame = AuxFilterSearchFrameSavedRecentListing,
|
||||
on_row_click = function (sheet, row_index)
|
||||
PlaySound('igMainMenuOptionCheckBoxOn')
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
-- sheet.data[data_index]
|
||||
end,
|
||||
columns = {
|
||||
{
|
||||
width = 300,
|
||||
comparator = function(filter_string1, filter_string2) return Aux.util.compare(filter_string1, filter_string2, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('LEFT'),
|
||||
cell_setter = function(cell, filter_string)
|
||||
cell.text:SetText(filter_string)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {},
|
||||
}
|
||||
private.views = {
|
||||
[Aux.view.BUYOUT] = {
|
||||
frame = AuxFilterSearchFrameResultsBuyListing,
|
||||
@@ -386,6 +489,8 @@ function public.on_load()
|
||||
}
|
||||
|
||||
private.listings = {
|
||||
favorite_searches = Aux.sheet.create(private.favorite_searches_config),
|
||||
recent_searches = Aux.sheet.create(private.recent_searches_config),
|
||||
[Aux.view.BUYOUT] = Aux.sheet.create(private.views[Aux.view.BUYOUT]),
|
||||
[Aux.view.BID] = Aux.sheet.create(private.views[Aux.view.BID]),
|
||||
[Aux.view.FULL] = Aux.sheet.create(private.views[Aux.view.FULL]),
|
||||
@@ -399,10 +504,20 @@ function public.on_load()
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.start_search)
|
||||
private.search_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxFilterSearchFrame, 22)
|
||||
btn:SetPoint('TOPRIGHT', -5, -3)
|
||||
btn:SetWidth(60)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText('Stop')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.stop_search)
|
||||
btn:Hide()
|
||||
private.stop_button = btn
|
||||
end
|
||||
do
|
||||
local editbox = Aux.gui.editbox(AuxFilterSearchFrame)
|
||||
editbox:SetPoint('TOPLEFT', 5, -3)
|
||||
editbox:SetPoint('TOPRIGHT', private.search_button, 'TOPLEFT', -4, 0)
|
||||
editbox:SetPoint('TOPRIGHT', private.search_button, 'TOPLEFT', -4, -5)
|
||||
editbox:SetWidth(400)
|
||||
editbox:SetHeight(25)
|
||||
-- editbox:SetScript('OnTabPressed', function()
|
||||
@@ -414,7 +529,7 @@ function public.on_load()
|
||||
-- end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -430,7 +545,7 @@ function public.on_load()
|
||||
btn:SetWidth(220)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Search Results')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.start_search)
|
||||
btn:SetScript('OnClick', function() private.update_tab(RESULTS) end)
|
||||
private.search_results_button = btn
|
||||
end
|
||||
do
|
||||
@@ -439,7 +554,7 @@ function public.on_load()
|
||||
btn:SetWidth(220)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Saved Searches')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.start_search)
|
||||
btn:SetScript('OnClick', function() private.update_tab(SAVED) end)
|
||||
private.saved_searches_button = btn
|
||||
end
|
||||
do
|
||||
@@ -448,33 +563,45 @@ function public.on_load()
|
||||
btn:SetWidth(220)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('New Filter')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.start_search)
|
||||
btn:SetScript('OnClick', function() private.update_tab(FILTER) end)
|
||||
private.new_filter_button = btn
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxFilterSearchFrameFilters, 16, '$parentSearchButton')
|
||||
btn:SetPoint('BOTTOMLEFT', 8, 15)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Search')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.start_search)
|
||||
local btn1 = Aux.gui.button(AuxFilterSearchFrameFilters, 16)
|
||||
btn1:SetPoint('BOTTOMLEFT', 8, 15)
|
||||
btn1:SetWidth(80)
|
||||
btn1:SetHeight(24)
|
||||
btn1:SetText('Add Filter')
|
||||
btn1:SetScript('OnClick', private.add_filter)
|
||||
|
||||
local btn2 = Aux.gui.button(AuxFilterSearchFrameFilters, 16)
|
||||
btn2:SetPoint('LEFT', btn1, 'RIGHT', 5, 0)
|
||||
btn2:SetWidth(80)
|
||||
btn2:SetHeight(24)
|
||||
btn2:SetText('Search Filter')
|
||||
btn2:SetScript('OnClick', function()
|
||||
private.search_box:SetText('')
|
||||
private.add_filter()
|
||||
public.start_search()
|
||||
end)
|
||||
|
||||
local btn3 = Aux.gui.button(AuxFilterSearchFrameFilters, 16)
|
||||
btn3:SetPoint('LEFT', btn2, 'RIGHT', 5, 0)
|
||||
btn3:SetWidth(80)
|
||||
btn3:SetHeight(24)
|
||||
btn3:SetText('Clear Filter')
|
||||
btn3:SetScript('OnClick', function()
|
||||
private.clear_filter()
|
||||
end)
|
||||
end
|
||||
do
|
||||
local btn = Aux.gui.button(AuxFilterSearchFrameFilters, 16, '$parentStopButton')
|
||||
btn:SetPoint('BOTTOMLEFT', 8, 15)
|
||||
btn:SetWidth(80)
|
||||
btn:SetHeight(24)
|
||||
btn:SetText('Stop')
|
||||
btn:SetScript('OnClick', Aux.filter_search_frame.stop_search)
|
||||
btn:Hide()
|
||||
end
|
||||
do
|
||||
local tab_group = Aux.gui.tab_group(AuxFilterSearchFrameResults, 'TOP')
|
||||
tab_group:create_tab('Buy')
|
||||
tab_group:create_tab('Bid')
|
||||
tab_group:create_tab('Full')
|
||||
tab_group.on_select = Aux.filter_search_frame.set_view
|
||||
private.tab_group = tab_group
|
||||
-- local tab_group = Aux.gui.tab_group(AuxFilterSearchFrameResults, 'TOP')
|
||||
-- tab_group:create_tab('Buy')
|
||||
-- tab_group:create_tab('Bid')
|
||||
-- tab_group:create_tab('Full')
|
||||
-- tab_group.on_select = Aux.filter_search_frame.set_view
|
||||
-- private.tab_group = tab_group
|
||||
-- tab_group.container:Hide()
|
||||
end
|
||||
do
|
||||
local status_bar = Aux.gui.status_bar(AuxFilterSearchFrame)
|
||||
@@ -516,7 +643,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -550,7 +677,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -574,7 +701,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -601,7 +728,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -623,7 +750,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -642,7 +769,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -661,7 +788,7 @@ function public.on_load()
|
||||
end)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -676,7 +803,7 @@ function public.on_load()
|
||||
editbox:SetWidth(30)
|
||||
editbox:SetScript('OnEnterPressed', function()
|
||||
this:ClearFocus()
|
||||
Aux.filter_search_frame.start_search()
|
||||
public.start_search()
|
||||
end)
|
||||
editbox:SetScript('OnEscapePressed', function()
|
||||
this:ClearFocus()
|
||||
@@ -737,18 +864,18 @@ function private.update_listing()
|
||||
local buyout_auctions = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') and auction.buyout_price end) or {}
|
||||
Aux.sheet.populate(private.listings[Aux.view.BUYOUT], auctions and Aux.util.group_by(buyout_auctions, function(a1, a2) return a1.item_id == a2.item_id and a1.suffix_id == a2.suffix_id and a1.enchant_id == a2.enchant_id and a1.aux_quantity == a2.aux_quantity and a1.buyout_price == a2.buyout_price end) or {})
|
||||
AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsBuyListing:GetWidth() + 40)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
elseif aux_view == Aux.view.BID then
|
||||
AuxFilterSearchFrameResultsBidListing:Show()
|
||||
local bid_auctions = auctions and Aux.util.filter(auctions, function(auction) return auction.owner ~= UnitName('player') end) or {}
|
||||
Aux.sheet.populate(private.listings[Aux.view.BID], bid_auctions)
|
||||
AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsBidListing:GetWidth() + 40)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
elseif aux_view == Aux.view.FULL then
|
||||
AuxFilterSearchFrameResultsFullListing:Show()
|
||||
Aux.sheet.populate(private.listings[Aux.view.FULL], auctions or {})
|
||||
AuxFilterSearchFrameResults:SetWidth(AuxFilterSearchFrameResultsFullListing:GetWidth() + 40)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameFilters:GetWidth() + AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
AuxFrame:SetWidth(AuxFilterSearchFrameResults:GetWidth() + 15)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -758,34 +885,24 @@ function public.set_view(view)
|
||||
refresh = true
|
||||
end
|
||||
|
||||
function private.create_filter_query()
|
||||
local category = UIDropDownMenu_GetSelectedValue(AuxFilterSearchFrameFiltersCategoryDropDown)
|
||||
|
||||
return {
|
||||
type = 'list',
|
||||
start_page = AuxFilterSearchFrameFiltersAllPagesCheckButton:GetChecked() and 0 or AuxFilterSearchFrameFiltersPageEditBox:GetNumber(),
|
||||
name = AuxFilterSearchFrameFiltersNameInputBox:GetText(),
|
||||
min_level = AuxFilterSearchFrameFiltersMinLevel:GetText(),
|
||||
max_level = AuxFilterSearchFrameFiltersMaxLevel:GetText(),
|
||||
slot = category and category.slot,
|
||||
class = category and category.class,
|
||||
subclass = category and category.subclass,
|
||||
quality = UIDropDownMenu_GetSelectedValue(AuxFilterSearchFrameFiltersQualityDropDown),
|
||||
usable = AuxFilterSearchFrameFiltersUsableCheckButton:GetChecked()
|
||||
}
|
||||
end
|
||||
|
||||
function public.start_search()
|
||||
|
||||
tinsert(aux_recent_searches, 1, private.search_box:GetText())
|
||||
while getn(aux_recent_searches) > 50 do
|
||||
tremove(aux_recent_searches)
|
||||
end
|
||||
|
||||
Aux.scan.abort(function()
|
||||
|
||||
private.update_tab(RESULTS)
|
||||
|
||||
private.clear_selection()
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
AuxFilterSearchFrameFiltersSearchButton:Hide()
|
||||
AuxFilterSearchFrameFiltersStopButton:Show()
|
||||
private.search_button:Hide()
|
||||
private.stop_button:Show()
|
||||
|
||||
auctions = nil
|
||||
|
||||
@@ -840,16 +957,16 @@ function public.start_search()
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
|
||||
AuxFilterSearchFrameFiltersStopButton:Hide()
|
||||
AuxFilterSearchFrameFiltersSearchButton:Show()
|
||||
private.stop_button:Hide()
|
||||
private.search_button:Show()
|
||||
refresh = true
|
||||
end,
|
||||
on_abort = function()
|
||||
auctions = auctions or {}
|
||||
private.status_bar:update_status(100, 100)
|
||||
private.status_bar:set_text('Done Scanning')
|
||||
AuxFilterSearchFrameFiltersStopButton:Hide()
|
||||
AuxFilterSearchFrameFiltersSearchButton:Show()
|
||||
private.stop_button:Hide()
|
||||
private.search_button:Show()
|
||||
refresh = true
|
||||
end,
|
||||
}
|
||||
|
||||
+22
-2
@@ -65,9 +65,9 @@
|
||||
</Frame>
|
||||
<Frame name="$parentResults" inherits="AuxFrameBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="655" y="326"/>
|
||||
<AbsDimension x="655" y="300"/>
|
||||
</Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentFilters"><Offset><AbsDimension x="3" y="0"/></Offset></Anchor></Anchors>
|
||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="3" y="-65"/></Offset></Anchor></Anchors>
|
||||
<Frames>
|
||||
<Frame name="$parentBuyListing" hidden="true">
|
||||
<Anchors>
|
||||
@@ -88,6 +88,26 @@
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
<Frame name="$parentSaved" inherits="AuxFrameBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="655" y="300"/>
|
||||
</Size>
|
||||
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="3" y="-65"/></Offset></Anchor></Anchors>
|
||||
<Frames>
|
||||
<Frame name="$parentFavoriteListing" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentRecentListing" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT" relativepoint="TOPRIGHT" relativeto="$parentFavoriteListing"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOM"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
|
||||
+1
-54
@@ -11,57 +11,4 @@ function m.parse_item_key(item_key)
|
||||
return tonumber(item_id), suffix_id == '' and 0 or tonumber(suffix_id)
|
||||
end
|
||||
|
||||
m.test_group = '13127,9510,4438,16254,12006,13131,13012,4413,1482'
|
||||
|
||||
|
||||
--function private:StartFilterSearch()
|
||||
-- local filter = private.frame.filter.filterInputBox:GetText()
|
||||
--
|
||||
-- local minLevel = private.frame.filter.levelMinBox:GetNumber()
|
||||
-- local maxLevel = private.frame.filter.levelMaxBox:GetNumber()
|
||||
-- if maxLevel > 0 then
|
||||
-- filter = format("%s/%d/%d", filter, minLevel, maxLevel)
|
||||
-- elseif minLevel > 0 then
|
||||
-- filter = format("%s/%d", filter, minLevel)
|
||||
-- end
|
||||
--
|
||||
-- local minItemLevel = private.frame.filter.itemLevelMinBox:GetNumber()
|
||||
-- local maxItemLevel = private.frame.filter.itemLevelMaxBox:GetNumber()
|
||||
-- if maxItemLevel > 0 then
|
||||
-- filter = format("%s/i%d/i%d", filter, minItemLevel, maxItemLevel)
|
||||
-- elseif minItemLevel > 0 then
|
||||
-- filter = format("%s/i%d", filter, minItemLevel)
|
||||
-- end
|
||||
--
|
||||
-- local class = private.frame.filter.classDropdown:GetValue()
|
||||
-- if class then
|
||||
-- local classes = {GetAuctionItemClasses()}
|
||||
-- filter = format("%s/%s", filter, classes[class])
|
||||
-- local subClass = private.frame.filter.subClassDropdown:GetValue()
|
||||
-- if subClass then
|
||||
-- local subClasses = {GetAuctionItemSubClasses(class)}
|
||||
-- filter = format("%s/%s", filter, subClasses[subClass])
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- local rarity = private.frame.filter.rarityDropdown:GetValue()
|
||||
-- if rarity then
|
||||
-- filter = format("%s/%s", filter, _G["ITEM_QUALITY"..rarity.."_DESC"])
|
||||
-- end
|
||||
--
|
||||
-- if private.frame.filter.usableCheckBox:GetValue() then
|
||||
-- filter = format("%s/usable", filter)
|
||||
-- end
|
||||
--
|
||||
-- if private.frame.filter.exactCheckBox:GetValue() then
|
||||
-- filter = format("%s/exact", filter)
|
||||
-- end
|
||||
--
|
||||
-- local maxQty = private.frame.filter.maxQtyBox:GetNumber()
|
||||
-- if maxQty > 0 then
|
||||
-- filter = format("%s/x%d", filter, maxQty)
|
||||
-- end
|
||||
--
|
||||
-- local searchInfo = {searchMode="normal", extraInfo={searchType="filter"}, filter=filter}
|
||||
-- TSM.AuctionTab:StartSearch(searchInfo)
|
||||
--end
|
||||
m.test_group = '13127;9510;4438;16254;12006;13131;13012;4413;1482'
|
||||
+4
-10
@@ -504,7 +504,7 @@ function public.set_item(item_id)
|
||||
end)
|
||||
tinsert(updated_recently_searched, 1, { item_id=item_id, time=time() })
|
||||
while getn(updated_recently_searched) > 50 do
|
||||
tremove(updated_recently_searched, getn(updated_recently_searched))
|
||||
tremove(updated_recently_searched)
|
||||
end
|
||||
aux_recently_searched = updated_recently_searched
|
||||
|
||||
@@ -549,11 +549,7 @@ function public.start_search()
|
||||
|
||||
local item_id = private.item_id
|
||||
|
||||
local query = Aux.scan_util.create_item_query(
|
||||
item_id,
|
||||
'list',
|
||||
AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber()
|
||||
)
|
||||
local query = Aux.scan_util.create_item_query(item_id)
|
||||
|
||||
Aux.scan.start{
|
||||
queries = { query },
|
||||
@@ -562,10 +558,8 @@ function public.start_search()
|
||||
private.status_bar:set_text(format('Scanning (Page %d / %d)', page + 1, total_pages))
|
||||
end,
|
||||
on_read_auction = function(auction_info)
|
||||
if auction_info.item_id == item_id then
|
||||
auctions = auctions or {}
|
||||
tinsert(auctions, private.create_auction_record(auction_info))
|
||||
end
|
||||
auctions = auctions or {}
|
||||
tinsert(auctions, private.create_auction_record(auction_info))
|
||||
end,
|
||||
on_complete = function()
|
||||
auctions = auctions or {}
|
||||
|
||||
+3
-5
@@ -233,6 +233,7 @@ function public.on_load()
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.editbox:SetMaxLetters(3)
|
||||
slider.label:SetText('Stack Size')
|
||||
slider.label:SetTextHeight(13)
|
||||
private.stack_size_slider = slider
|
||||
end
|
||||
do
|
||||
@@ -266,6 +267,7 @@ function public.on_load()
|
||||
slider.editbox:SetWidth(50)
|
||||
slider.editbox:SetNumeric(true)
|
||||
slider.label:SetText('Stack Count')
|
||||
slider.label:SetTextHeight(13)
|
||||
private.stack_count_slider = slider
|
||||
end
|
||||
do
|
||||
@@ -694,11 +696,7 @@ function private.refresh_entries()
|
||||
|
||||
existing_auctions[item_key] = nil
|
||||
|
||||
local query = Aux.scan_util.create_item_query(
|
||||
item_id,
|
||||
'list',
|
||||
0
|
||||
)
|
||||
local query = Aux.scan_util.create_item_query(item_id)
|
||||
|
||||
private.status_bar:update_status(0,0)
|
||||
private.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
+97
-57
@@ -47,49 +47,57 @@ function m.find(test, query, page, status_bar, on_failure, on_success)
|
||||
end)
|
||||
end
|
||||
|
||||
function m.create_item_query(item_id, type, start_page, next_page)
|
||||
function m.create_item_filter(item_id)
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
|
||||
local function validator(auction_info)
|
||||
return auction_info.item_id == item_id
|
||||
if item_info then
|
||||
local class_index = Aux.item_class_index(item_info.class)
|
||||
local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass)
|
||||
|
||||
return {
|
||||
name = item_info.name,
|
||||
min_level = item_info.level,
|
||||
min_level = item_info.level,
|
||||
slot = item_info.slot,
|
||||
class = class_index,
|
||||
subclass = subclass_index,
|
||||
subclass = item_info.subclass,
|
||||
quality = item_info.quality,
|
||||
usable = item_info.usable,
|
||||
}
|
||||
end
|
||||
-- local class_index = Aux.item_class_index(item_info.class)
|
||||
-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed
|
||||
end
|
||||
|
||||
function m.create_item_query(item_id)
|
||||
local item_info = Aux.static.item_info(item_id)
|
||||
|
||||
local filter = m.create_item_filter(item_id)
|
||||
|
||||
return item_info and {
|
||||
type = type,
|
||||
start_page = start_page,
|
||||
next_page = next_page,
|
||||
name = item_info.name,
|
||||
min_level = item_info.level,
|
||||
min_level = item_info.level,
|
||||
slot = item_info.slot,
|
||||
-- class = class_index,
|
||||
-- subclass = subclass_index,
|
||||
-- class = Aux.item_class_index(item_info.class),
|
||||
-- subclass = item_info.subclass,
|
||||
quality = item_info.quality,
|
||||
usable = item_info.usable,
|
||||
type = 'list',
|
||||
start_page = 0,
|
||||
validator = m.validator(filter),
|
||||
blizzard_query = m.blizzard_query(filter),
|
||||
}
|
||||
end
|
||||
|
||||
function m.parse_filter_string(filter_string)
|
||||
local parts = {Aux.persistence.deserialize(filter_string, ';')}
|
||||
local parts = Aux.persistence.deserialize(filter_string, ';')
|
||||
|
||||
local filters = {}
|
||||
for _, str in ipairs(parts) do
|
||||
str = Aux.util.trim(str)
|
||||
if tonumber(str) then
|
||||
local filter = Aux.scan_util.create_item_query(tonumber(str))
|
||||
local filter = m.create_item_filter(tonumber(str))
|
||||
if filter then
|
||||
tinsert(filters, filter)
|
||||
end
|
||||
else
|
||||
local filter, error = m.filter(str)
|
||||
local filter, error = m.filter_from_string(str)
|
||||
|
||||
if not filter then
|
||||
Aux.log('Invalid filter: '..error)
|
||||
elseif strlen(filter.query_string) > 63 then
|
||||
elseif filter.name and strlen(filter.name) > 63 then
|
||||
|
||||
else
|
||||
tinsert(filters, filter)
|
||||
@@ -100,84 +108,116 @@ function m.parse_filter_string(filter_string)
|
||||
return filters
|
||||
end
|
||||
|
||||
function m.filter(filter_term)
|
||||
local parts = {Aux.persistence.deserialize(filter_term, '/')}
|
||||
local query_string, class, subclass, min_level, max_level, quality, usable_only, exact_only, even_only, min_profit, max_percentage
|
||||
|
||||
if getn(parts) == 0 then
|
||||
return false, 'Invalid Filter'
|
||||
end
|
||||
function m.filter_from_string(filter_term)
|
||||
local parts = Aux.persistence.deserialize(filter_term, '/')
|
||||
|
||||
local filter = {}
|
||||
for i, str in ipairs(parts) do
|
||||
str = Aux.util.trim(str)
|
||||
|
||||
if tonumber(str) then
|
||||
if not min_level then
|
||||
min_level = tonumber(str)
|
||||
elseif not max_level then
|
||||
max_level = tonumber(str)
|
||||
if not filter.min_level then
|
||||
filter.min_level = tonumber(str)
|
||||
elseif not filter.max_level then
|
||||
filter.max_level = tonumber(str)
|
||||
else
|
||||
return false, 'Invalid Min Level'
|
||||
end
|
||||
elseif not class and Aux.item_class_index(str) then
|
||||
if not class then
|
||||
class = Aux.item_class_index(str)
|
||||
elseif not filter.class and Aux.item_class_index(str) then
|
||||
if not filter.class then
|
||||
filter.class = Aux.item_class_index(str)
|
||||
else
|
||||
return false, 'Invalid Item Type'
|
||||
end
|
||||
elseif Aux.item_subclass_index(class, str) then
|
||||
if not subclass then
|
||||
subclass = Aux.item_subclass_index(class, str)
|
||||
elseif filter.class and Aux.item_subclass_index(filter.class, str) then
|
||||
if not filter.subclass then
|
||||
filter.subclass = Aux.item_subclass_index(filter.class, str)
|
||||
else
|
||||
return false, 'Invalid Item SubType'
|
||||
end
|
||||
elseif Aux.item_quality_index(str) then
|
||||
if not quality then
|
||||
quality = Aux.item_quality_index(str)
|
||||
if not filter.quality then
|
||||
filter.quality = Aux.item_quality_index(str)
|
||||
else
|
||||
return false, 'Invalid Item Rarity'
|
||||
end
|
||||
elseif strlower(str) == 'usable' then
|
||||
if not usable_only then
|
||||
usable_only = true
|
||||
if not filter.usable_only then
|
||||
filter.usable_only = true
|
||||
else
|
||||
return false, 'Invalid Usable Only Filter'
|
||||
end
|
||||
elseif strlower(str) == 'exact' then
|
||||
if not exact_only then
|
||||
exact_only = true
|
||||
if not filter.exact_only then
|
||||
filter.exact_only = true
|
||||
else
|
||||
return false, 'Invalid Exact Only Filter'
|
||||
end
|
||||
elseif strlower(str) == 'even' then
|
||||
if not even_only then
|
||||
even_only = true
|
||||
if not filter.even_only then
|
||||
filter.even_only = true
|
||||
else
|
||||
return false, 'Invalid Even Only Filter'
|
||||
end
|
||||
elseif Aux.money.from_string(str) then
|
||||
min_profit = Aux.money.from_string(str)
|
||||
-- elseif Aux.money.from_string(str) then
|
||||
-- filter.min_profit = Aux.money.from_string(str)
|
||||
elseif i == 1 then
|
||||
query_string = str
|
||||
filter.name = str
|
||||
else
|
||||
return false, 'Unknown Filter'
|
||||
end
|
||||
end
|
||||
|
||||
min_level, max_level = min(min_level, max_level), max(min_level, max_level)
|
||||
if filter.max_level then
|
||||
filter.min_level, filter.max_level = min(filter.min_level, filter.max_level), max(filter.min_level, filter.max_level)
|
||||
end
|
||||
|
||||
return { query_string or '', class or 0, subclass or 0, min_level or 0, max_level or 0, quality or 0, usable_only or 0, exact_only or nil, even_only or nil, min_profit }
|
||||
return filter
|
||||
end
|
||||
|
||||
function m.filter_to_string(filter)
|
||||
|
||||
local filter_term = filter.name or ''
|
||||
|
||||
if filter.max_level then
|
||||
filter_term = format('%s/%d/%d', filter_term, filter.min_level, filter.max_level)
|
||||
elseif filter.min_level then
|
||||
filter_term = format('%s/%d', filter_term, filter.min_level)
|
||||
end
|
||||
|
||||
if filter.class then
|
||||
local classes = { GetAuctionItemClasses() }
|
||||
filter_term = format('%s/%s', filter_term, classes[filter.class])
|
||||
if filter.subclass then
|
||||
local subclasses = {GetAuctionItemSubClasses(filter.class)}
|
||||
filter_term = format('%s/%s', filter_term, subclasses[filter.subclass])
|
||||
end
|
||||
end
|
||||
|
||||
if filter.quality then
|
||||
filter_term = format('%s/%s', filter_term, _G["ITEM_QUALITY"..filter.quality.."_DESC"])
|
||||
end
|
||||
|
||||
if filter.usable_only then
|
||||
filter_term = format('%s/usable', filter_term)
|
||||
end
|
||||
|
||||
if filter.exact_only then
|
||||
filter_term = format('%s/exact', filter_term)
|
||||
end
|
||||
|
||||
return filter_term
|
||||
end
|
||||
|
||||
function m.blizzard_query(filter)
|
||||
return {
|
||||
name = filter.query_string,
|
||||
name = filter.name,
|
||||
min_level = filter.min_level,
|
||||
max_level = filter.max_level,
|
||||
slot = filter.slot,
|
||||
class = filter.class,
|
||||
subclass = filter.subclass,
|
||||
usable = filter.usable_only,
|
||||
usable = filter.usable_only and 1 or 0,
|
||||
quality = filter.quality,
|
||||
}
|
||||
end
|
||||
@@ -186,7 +226,7 @@ function m.validator(filter)
|
||||
|
||||
return function(record)
|
||||
|
||||
if filter.exact_only and record.name ~= record.name then
|
||||
if filter.exact_only and record.name ~= filter.name then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -194,11 +234,11 @@ function m.validator(filter)
|
||||
return
|
||||
end
|
||||
|
||||
if filter.min_level > 0 and record.level < record.min_level then
|
||||
if filter.min_level and record.level < filter.min_level then
|
||||
return
|
||||
end
|
||||
|
||||
if filter.max_level > 0 and record.level > record.max_level then
|
||||
if filter.max_level and record.level > filter.max_level then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user