finished new auto buy mechanism (alt-right-click to add/remove)
This commit is contained in:
+11
-10
@@ -37,7 +37,7 @@ frame.saved.recent:SetPoint('TOPLEFT', frame.saved.favorite, 'TOPRIGHT', 2.5, 0)
|
||||
frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
do
|
||||
local btn = gui.checkbutton(frame)
|
||||
btn:SetPoint('TOPLEFT', 5, -9)
|
||||
btn:SetPoint('TOPLEFT', 5, -8)
|
||||
btn:SetWidth(90)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Real Time'
|
||||
@@ -70,7 +70,7 @@ do
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.huge)
|
||||
btn:SetPoint('TOPRIGHT', -5, -9)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Start'
|
||||
@@ -85,7 +85,7 @@ do
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.huge)
|
||||
btn:SetPoint('TOPRIGHT', -5, -9)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
btn:SetWidth(70)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Stop'
|
||||
@@ -232,6 +232,7 @@ do
|
||||
btn2:SetText'Auto Buy'
|
||||
btn2:SetScript('OnClick', function()
|
||||
add_auto_buy(search_box:GetText())
|
||||
update_search_listings()
|
||||
end)
|
||||
end
|
||||
do
|
||||
@@ -524,13 +525,13 @@ for _ = 1, 5 do
|
||||
tinsert(tables, table)
|
||||
end
|
||||
|
||||
private.autobuy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
|
||||
autobuy_listing:SetColInfo{{name='Auto Buy Filters', width=1}}
|
||||
autobuy_listing:EnableSorting(false)
|
||||
autobuy_listing:DisableSelection(true)
|
||||
autobuy_listing:SetHandler('OnClick', handlers.OnClick)
|
||||
autobuy_listing:SetHandler('OnEnter', handlers.OnEnter)
|
||||
autobuy_listing:SetHandler('OnLeave', handlers.OnLeave)
|
||||
private.auto_buy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
|
||||
auto_buy_listing:SetColInfo{{name='Auto Buy Filters', width=1}}
|
||||
auto_buy_listing:EnableSorting(false)
|
||||
auto_buy_listing:DisableSelection(true)
|
||||
auto_buy_listing:SetHandler('OnClick', handlers.OnClick)
|
||||
auto_buy_listing:SetHandler('OnEnter', handlers.OnEnter)
|
||||
auto_buy_listing:SetHandler('OnLeave', handlers.OnLeave)
|
||||
|
||||
private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
|
||||
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
|
||||
|
||||
+32
-20
@@ -16,7 +16,7 @@ function private.update_search_listings()
|
||||
index = i,
|
||||
})
|
||||
end
|
||||
autobuy_listing:SetData(autobuy_filter_rows)
|
||||
auto_buy_listing:SetData(autobuy_filter_rows)
|
||||
|
||||
local favorite_search_rows = t
|
||||
for i, favorite_search in aux_favorite_searches do
|
||||
@@ -60,33 +60,34 @@ private.handlers = {
|
||||
elseif button == 'RightButton' and IsShiftKeyDown() then
|
||||
add_filter(data.search.filter_string)
|
||||
elseif button == 'LeftButton' and IsControlKeyDown() then
|
||||
if st == favorite_searches_listing and data.index > 1 then
|
||||
local temp = aux_favorite_searches[data.index - 1]
|
||||
aux_favorite_searches[data.index - 1] = data.search
|
||||
aux_favorite_searches[data.index] = temp
|
||||
update_search_listings()
|
||||
if st == favorite_searches_listing then
|
||||
move_up(aux_favorite_searches, data.index)
|
||||
elseif st == auto_buy_listing then
|
||||
move_up(aux_auto_buy_filters, data.index)
|
||||
end
|
||||
update_search_listings()
|
||||
elseif button == 'RightButton' and IsControlKeyDown() then
|
||||
if st == favorite_searches_listing and data.index < getn(aux_favorite_searches) then
|
||||
local temp = aux_favorite_searches[data.index + 1]
|
||||
aux_favorite_searches[data.index + 1] = data.search
|
||||
aux_favorite_searches[data.index] = temp
|
||||
update_search_listings()
|
||||
if st == favorite_searches_listing then
|
||||
move_down(aux_favorite_searches, data.index)
|
||||
elseif st == auto_buy_listing then
|
||||
move_down(aux_auto_buy_filters, data.index)
|
||||
end
|
||||
update_search_listings()
|
||||
elseif button == 'RightButton' and IsAltKeyDown() then
|
||||
if st ~= autobuy_listing then
|
||||
if st == auto_buy_listing then
|
||||
tremove(aux_auto_buy_filters, data.index)
|
||||
else
|
||||
add_auto_buy(data.search.filter_string)
|
||||
end
|
||||
update_search_listings()
|
||||
elseif button == 'LeftButton' then
|
||||
search_box:SetText(data.search.filter_string)
|
||||
execute()
|
||||
elseif button == 'RightButton' then
|
||||
if st == autobuy_listing then
|
||||
tremove(aux_auto_buy_filters, data.index)
|
||||
elseif st == recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
elseif st == favorite_searches_listing then
|
||||
if st == favorite_searches_listing then
|
||||
tremove(aux_favorite_searches, data.index)
|
||||
else
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
end
|
||||
update_search_listings()
|
||||
end
|
||||
@@ -136,16 +137,27 @@ function private.add_auto_buy(filter_string)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
print'Error: The automatic buyout filter does not support multi-queries'
|
||||
-- elseif size(queries[1].blizzard_query) > 0 then TODO allow exact
|
||||
-- print'Error: The automatic buyout filter does not support Blizzard filters'
|
||||
elseif size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(filter_string).blizzard.exact then
|
||||
print'Error: The automatic buyout filter does not support Blizzard filters'
|
||||
else
|
||||
tinsert(aux_auto_buy_filters, 1, T(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
update_search_listings()
|
||||
end
|
||||
else
|
||||
print('Invalid filter:', error)
|
||||
end
|
||||
end
|
||||
|
||||
function private.move_up(list, index)
|
||||
if list[index - 1] then
|
||||
list[index], list[index - 1] = list[index - 1], list[index]
|
||||
end
|
||||
end
|
||||
|
||||
function private.move_down(list, index)
|
||||
if list[index + 1] then
|
||||
list[index], list[index + 1] = list[index + 1], list[index]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user