refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-07-15 20:40:27 +02:00
parent a9290f2885
commit 54eb2a67ef
15 changed files with 724 additions and 725 deletions
+29 -39
View File
@@ -21,13 +21,10 @@ end
function Aux_module(name)
local interface, data, private, public, is_public = {}, {}, {}, {}, {}
setmetatable(interface, {
-- __newindex = function()
-- error('Illegal write on interface of "'..name..'"!')
-- end,
__newindex = function(_, key)
error('Illegal write of attribute "'..key..'" on interface of "'..name..'"!')
end,
__index = function(_, key)
if rawget(interface, key) then -- TODO remove
return rawget(interface, key) -- TODO remove
end -- TODO remove
if is_public[key] then
return data[key]
end
@@ -42,7 +39,7 @@ function Aux_module(name)
end,
__index = function(_, key)
if rawget(data, key) == nil then
-- error('Access of undeclared attribute "'..key..'" of module"'..name..'"!')
error('Access of undeclared attribute "'..key..'" of module"'..name..'"!')
else
return Aux_unwrap(rawget(data, key))
end
@@ -95,12 +92,15 @@ local addon = Aux_addon('Aux')
Aux = tremove(addon, 1)
local m, private, public = unpack(addon)
private.tabs = {}
function public.tab(index, name)
local ret = { m.module(name) }
m.tabs[index] = m[name]
m.tabs[index] = m.modules[name]
return unpack(ret)
end
private.active_tab = nil
function public.on_load()
public.version = '2.16.2'
public.blizzard_ui_shown = false
@@ -155,13 +155,9 @@ function public.on_load()
for _, module in m.modules do
if module.LOAD then
module:LOAD()
module.LOAD()
end
end
Aux.search_frame.on_load()
Aux.post_frame.on_load()
Aux.auctions_frame.on_load()
Aux.bids_frame.on_load()
end
function public.on_event()
@@ -369,45 +365,39 @@ function public.neutral_faction()
return not UnitFactionGroup('npc')
end
function private:on_auction_house_closed()
function private.on_auction_house_closed()
m.post.stop()
m.stack.stop()
m.scan.abort()
-- Aux.tabs[self.active_tab].CLOSE() TODO
Aux.search_frame.on_close()
Aux.post_frame.on_close()
Aux.auctions_frame.on_close()
Aux.bids_frame.on_close()
m.tabs[m.active_tab].CLOSE()
AuxFrame:Hide()
end
function private:on_tab_click(index)
-- Aux.tabs[self.active_tab].CLOSE() TODO
Aux.search_frame.on_close()
Aux.post_frame.on_close()
Aux.auctions_frame.on_close()
Aux.bids_frame.on_close()
function private.on_tab_click(index)
if m.active_tab then
m.tabs[m.active_tab].CLOSE()
end
AuxSearchFrame:Hide()
AuxPostFrame:Hide()
AuxAuctionsFrame:Hide()
AuxBidsFrame:Hide()
-- Aux.tabs[index].OPEN() TODO
if index == 1 then
AuxSearchFrame:Show()
Aux.search_frame.on_open()
elseif index == 2 then
AuxPostFrame:Show()
Aux.post_frame.on_open()
elseif index == 3 then
AuxAuctionsFrame:Show()
Aux.auctions_frame.on_open()
elseif index == 4 then
AuxBidsFrame:Show()
Aux.bids_frame.on_open()
end
m.tabs[index].OPEN()
-- if index == 1 then
-- AuxSearchFrame:Show()
-- Aux.search_frame.on_open()
-- elseif index == 2 then
-- AuxPostFrame:Show()
-- Aux.post_frame.on_open()
-- elseif index == 3 then
-- AuxAuctionsFrame:Show()
-- Aux.auctions_frame.on_open()
-- elseif index == 4 then
-- AuxBidsFrame:Show()
-- Aux.bids_frame.on_open()
-- end
m.active_tab = index
end
+7 -8
View File
@@ -1,5 +1,4 @@
local private, public = {}, {}
Aux.post = public
local m, private, public = Aux.module'post'
local state
@@ -19,14 +18,14 @@ function private.process()
return Aux.control.wait_until(function() return stacking_complete end, function()
if target_slot then
return private.post_auction(target_slot, private.process)
return m.post_auction(target_slot, m.process)
else
return public.stop()
return m.stop()
end
end)
end
return public.stop()
return m.stop()
end
function private.post_auction(slot, k)
@@ -57,7 +56,7 @@ function private.post_auction(slot, k)
end)
else
return public.stop()
return m.stop()
end
end
@@ -77,9 +76,9 @@ function public.stop()
end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
public.stop()
m.stop()
local thread_id = Aux.control.new_thread(private.process)
local thread_id = Aux.control.new_thread(m.process)
state = {
thread_id = thread_id,
+27 -28
View File
@@ -1,5 +1,4 @@
local private, public = {}, {}
Aux.stack = public
local m, private, public = Aux.module'stack'
local state
@@ -25,7 +24,7 @@ end
function private.find_item_slot(partial)
for slot in Aux.util.inventory() do
if private.matching_item(slot, partial) and not Aux.util.table_eq(slot, state.target_slot) then
if m.matching_item(slot, partial) and not Aux.util.table_eq(slot, state.target_slot) then
return slot
end
end
@@ -46,7 +45,7 @@ end
function private.find_charge_item_slot()
for slot in Aux.util.inventory() do
if private.matching_item(slot) and private.charges(slot) == state.target_size then
if m.matching_item(slot) and m.charges(slot) == state.target_size then
return slot
end
end
@@ -54,57 +53,57 @@ end
function private.move_item(from_slot, to_slot, amount, k)
if private.locked(from_slot) or private.locked(to_slot) then
if m.locked(from_slot) or m.locked(to_slot) then
return Aux.control.wait(k)
end
amount = min(private.max_stack(from_slot) - private.stack_size(to_slot), private.stack_size(from_slot), amount)
local expected_size = private.stack_size(to_slot) + amount
amount = min(m.max_stack(from_slot) - m.stack_size(to_slot), m.stack_size(from_slot), amount)
local expected_size = m.stack_size(to_slot) + amount
ClearCursor()
SplitContainerItem(from_slot[1], from_slot[2], amount)
PickupContainerItem(unpack(to_slot))
return Aux.control.wait_until(function() return private.stack_size(to_slot) == expected_size end, k)
return Aux.control.wait_until(function() return m.stack_size(to_slot) == expected_size end, k)
end
function private.process()
if not state.target_slot or not private.matching_item(state.target_slot) then
state.target_slot = private.find_item_slot()
if not state.target_slot or not m.matching_item(state.target_slot) then
state.target_slot = m.find_item_slot()
if not state.target_slot then
return public.stop()
return m.stop()
end
end
if private.charges(state.target_slot) then
state.target_slot = private.find_charge_item_slot()
return public.stop()
if m.charges(state.target_slot) then
state.target_slot = m.find_charge_item_slot()
return m.stop()
end
if private.stack_size(state.target_slot) > state.target_size then
local slot = private.find_item_slot(true) or private.find_empty_slot()
if m.stack_size(state.target_slot) > state.target_size then
local slot = m.find_item_slot(true) or m.find_empty_slot()
if slot then
return private.move_item(
return m.move_item(
state.target_slot,
slot,
private.stack_size(state.target_slot) - state.target_size,
private.process
m.stack_size(state.target_slot) - state.target_size,
m.process
)
end
elseif private.stack_size(state.target_slot) < state.target_size then
local slot = private.find_item_slot()
elseif m.stack_size(state.target_slot) < state.target_size then
local slot = m.find_item_slot()
if slot then
return private.move_item(
return m.move_item(
slot,
state.target_slot,
state.target_size - private.stack_size(state.target_slot),
private.process
state.target_size - m.stack_size(state.target_slot),
m.process
)
end
end
return public.stop()
return m.stop()
end
function public.stop()
@@ -112,7 +111,7 @@ function public.stop()
Aux.control.kill_thread(state.thread_id)
local callback, slot = state.callback, state.target_slot
if slot and not private.matching_item(slot) then
if slot and not m.matching_item(slot) then
slot = nil
end
@@ -125,9 +124,9 @@ function public.stop()
end
function public.start(item_key, size, callback)
public.stop()
m.stop()
local thread_id = Aux.control.new_thread(private.process)
local thread_id = Aux.control.new_thread(m.process)
state = {
thread_id = thread_id,
+38 -35
View File
@@ -1,10 +1,20 @@
local private, public = {}, {}
Aux.auctions_frame = public
local m, private, public = Aux.tab(3, 'auctions_frame')
local auction_records
function public.on_load()
public.create_frames(private, public)
function public.FRAMES(f)
private.create_frames = f
end
function public.LOAD()
m.create_frames(m, private, public)
end
function public.OPEN()
m.scan_auctions()
end
function public.CLOSE()
end
function private.update_listing()
@@ -12,41 +22,34 @@ function private.update_listing()
return
end
private.listing:SetDatabase(auction_records)
end
function public.on_open()
public.scan_auctions()
end
function public.on_close()
m.listing:SetDatabase(auction_records)
end
function public.scan_auctions()
private.status_bar:update_status(0,0)
private.status_bar:set_text('Scanning auctions...')
m.status_bar:update_status(0,0)
m.status_bar:set_text('Scanning auctions...')
auction_records = {}
private.update_listing()
m.update_listing()
Aux.scan.start{
type = 'owner',
queries = {{ blizzard_query = {} }},
on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page - 1) / total_pages, 0)
private.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
m.status_bar:update_status(100 * (page - 1) / total_pages, 0)
m.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
end,
on_auction = function(auction_record)
tinsert(auction_records, auction_record)
end,
on_complete = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
private.update_listing()
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
m.update_listing()
end,
on_abort = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
end,
}
end
@@ -60,7 +63,7 @@ end
function private.record_remover(record)
return function()
private.listing:RemoveAuctionRecord(record)
m.listing:RemoveAuctionRecord(record)
end
end
@@ -71,7 +74,7 @@ do
local found_index
function private.find_auction(record)
if not private.listing:ContainsRecord(record) then
if not m.listing:ContainsRecord(record) then
return
end
@@ -79,44 +82,44 @@ do
state = SEARCHING
scan_id = Aux.scan_util.find(
record,
private.status_bar,
m.status_bar,
function()
state = IDLE
end,
function()
state = IDLE
private.record_remover(record)()
m.record_remover(record)()
end,
function(index)
state = FOUND
found_index = index
private.cancel_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
Aux.cancel_auction(index, private.record_remover(record))
m.cancel_button:SetScript('OnClick', function()
if m.test(record)(index) and m.listing:ContainsRecord(record) then
Aux.cancel_auction(index, m.record_remover(record))
end
end)
private.cancel_button:Enable()
m.cancel_button:Enable()
end
)
end
function public.on_update()
if state == IDLE or state == SEARCHING then
private.cancel_button:Disable()
m.cancel_button:Disable()
end
if state == SEARCHING then
return
end
local selection = private.listing:GetSelection()
local selection = m.listing:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then
private.find_auction(selection.record)
elseif state == FOUND and not private.test(selection.record)(found_index) then
private.cancel_button:Disable()
m.find_auction(selection.record)
elseif state == FOUND and not m.test(selection.record)(found_index) then
m.cancel_button:Disable()
-- if not Aux.bid_in_progress() then
state = IDLE
-- end
+12 -12
View File
@@ -1,15 +1,15 @@
function Aux.auctions_frame.create_frames(private, public)
Aux.auctions_frame.FRAMES(function(m, private, public)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxAuctionsFrameListing, Aux.auction_listing.auctions_config)
private.listing:SetSort(1,2,3,4,5,6,7,8)
private.listing:Reset()
private.listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record and private.cancel_button:IsEnabled() then
private.cancel_button:Click()
m.listing:SetSort(1,2,3,4,5,6,7,8)
m.listing:Reset()
m.listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and m.listing:GetSelection().record == cell.row.data.record and m.cancel_button:IsEnabled() then
m.cancel_button:Click()
end
end)
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
m.listing:SetHandler('OnSelectionChanged', function(rt, datum)
if not datum then return end
private.find_auction(datum.record)
m.find_auction(datum.record)
end)
do
@@ -23,7 +23,7 @@ function Aux.auctions_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxAuctionsFrame, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Cancel')
@@ -32,12 +32,12 @@ function Aux.auctions_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxAuctionsFrame, 16)
btn:SetPoint('TOPLEFT', private.cancel_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.cancel_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', function()
public.scan_auctions()
m.scan_auctions()
end)
end
end
end)
+45 -42
View File
@@ -1,10 +1,20 @@
local private, public = {}, {}
Aux.bids_frame = public
local m, private, public = Aux.tab(4, 'bids_frame')
local auction_records
function public.on_load()
public.create_frames(private, public)
function public.FRAMES(f)
private.create_frames = f
end
function public.LOAD()
m.create_frames(m, private, public)
end
function public.OPEN()
m.scan_bids()
end
function public.CLOSE()
end
function private.update_listing()
@@ -12,41 +22,34 @@ function private.update_listing()
return
end
private.listing:SetDatabase(auction_records)
end
function public.on_open()
public.scan_bids()
end
function public.on_close()
m.listing:SetDatabase(auction_records)
end
function public.scan_bids()
private.status_bar:update_status(0,0)
private.status_bar:set_text('Scanning auctions...')
m.status_bar:update_status(0,0)
m.status_bar:set_text('Scanning auctions...')
auction_records = {}
private.update_listing()
m.update_listing()
Aux.scan.start{
type = 'bidder',
queries = {{ blizzard_query = {} }},
on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page - 1) / total_pages, 0)
private.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
m.status_bar:update_status(100 * (page - 1) / total_pages, 0)
m.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
end,
on_auction = function(auction_record)
tinsert(auction_records, auction_record)
end,
on_complete = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
private.update_listing()
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
m.update_listing()
end,
on_abort = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
end,
}
end
@@ -60,7 +63,7 @@ end
function private.record_remover(record)
return function()
private.listing:RemoveAuctionRecord(record)
m.listing:RemoveAuctionRecord(record)
end
end
@@ -71,7 +74,7 @@ do
local found_index
function private.find_auction(record)
if not private.listing:ContainsRecord(record) then
if not m.listing:ContainsRecord(record) then
return
end
@@ -79,37 +82,37 @@ do
state = SEARCHING
scan_id = Aux.scan_util.find(
record,
private.status_bar,
m.status_bar,
function()
state = IDLE
end,
function()
state = IDLE
private.record_remover(record)()
m.record_remover(record)()
end,
function(index)
state = FOUND
found_index = index
if not record.high_bidder then
private.bid_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
m.bid_button:SetScript('OnClick', function()
if m.test(record)(index) and m.listing:ContainsRecord(record) then
Aux.place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function()
Aux.info.bid_update(record)
private.listing:SetDatabase()
end or private.record_remover(record))
m.listing:SetDatabase()
end or m.record_remover(record))
end
end)
private.bid_button:Enable()
m.bid_button:Enable()
end
if record.buyout_price > 0 then
private.buyout_button:SetScript('OnClick', function()
if private.test(record)(index) and private.listing:ContainsRecord(record) then
Aux.place_bid('bidder', index, record.buyout_price, private.record_remover(record))
m.buyout_button:SetScript('OnClick', function()
if m.test(record)(index) and m.listing:ContainsRecord(record) then
Aux.place_bid('bidder', index, record.buyout_price, m.record_remover(record))
end
end)
private.buyout_button:Enable()
m.buyout_button:Enable()
end
end
)
@@ -117,22 +120,22 @@ do
function public.on_update()
if state == IDLE or state == SEARCHING then
private.buyout_button:Disable()
private.bid_button:Disable()
m.buyout_button:Disable()
m.bid_button:Disable()
end
if state == SEARCHING then
return
end
local selection = private.listing:GetSelection()
local selection = m.listing:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then
private.find_auction(selection.record)
elseif state == FOUND and not private.test(selection.record)(found_index) then
private.buyout_button:Disable()
private.bid_button:Disable()
m.find_auction(selection.record)
elseif state == FOUND and not m.test(selection.record)(found_index) then
m.buyout_button:Disable()
m.bid_button:Disable()
if not Aux.bid_in_progress() then
state = IDLE
end
+16 -16
View File
@@ -1,19 +1,19 @@
function Aux.bids_frame.create_frames(private, public)
Aux.bids_frame.FRAMES(function(m, private, public)
private.listing = Aux.auction_listing.CreateAuctionResultsTable(AuxBidsFrameListing, Aux.auction_listing.bids_config)
private.listing:SetSort(1,2,3,4,5,6,7,8)
private.listing:Reset()
private.listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and private.listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
private.buyout_button:Click()
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
private.bid_button:Click()
m.listing:SetSort(1,2,3,4,5,6,7,8)
m.listing:Reset()
m.listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and m.listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and m.buyout_button:IsEnabled() then
m.buyout_button:Click()
elseif button == 'RightButton' and m.bid_button:IsEnabled() then
m.bid_button:Click()
end
end
end)
private.listing:SetHandler('OnSelectionChanged', function(rt, datum)
m.listing:SetHandler('OnSelectionChanged', function(rt, datum)
if not datum then return end
private.find_auction(datum.record)
m.find_auction(datum.record)
end)
do
@@ -27,7 +27,7 @@ function Aux.bids_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxBidsFrame, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Bid')
@@ -36,7 +36,7 @@ function Aux.bids_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxBidsFrame, 16)
btn:SetPoint('TOPLEFT', private.bid_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.bid_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout')
@@ -45,12 +45,12 @@ function Aux.bids_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxBidsFrame, 16)
btn:SetPoint('TOPLEFT', private.buyout_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.buyout_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', function()
public.scan_bids()
m.scan_bids()
end)
end
end
end)
+161 -156
View File
@@ -1,13 +1,37 @@
local private, public = {}, {}
Aux.post_frame = public
local m, private, public = Aux.tab(2, 'post_frame')
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
local existing_auctions = {}
local inventory_records
local scan_id = 0
local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
private.selected_item = nil
private.refresh = nil
local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
function public.FRAMES(f)
private.create_frames = f
end
function public.LOAD()
m.create_frames(m, private, public)
end
function public.OPEN()
m.deposit:SetText('Deposit: '..Aux.money.to_string(0, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
m.set_unit_start_price(0)
m.set_unit_buyout_price(0)
m.update_inventory_records()
m.refresh = true
end
function public.CLOSE()
m.selected_item = nil
end
function private.default_settings()
return {
@@ -20,7 +44,7 @@ function private.default_settings()
end
function private.read_settings(item_key)
item_key = item_key or private.selected_item.key
item_key = item_key or m.selected_item.key
local dataset = Aux.persistence.load_dataset()
dataset.post = dataset.post or {}
@@ -28,13 +52,13 @@ function private.read_settings(item_key)
if dataset.post[item_key] then
settings = Aux.persistence.read(settings_schema, dataset.post[item_key])
else
settings = private.default_settings()
settings = m.default_settings()
end
return settings
end
function private.write_settings(settings, item_key)
item_key = item_key or private.selected_item.key
item_key = item_key or m.selected_item.key
local dataset = Aux.persistence.load_dataset()
dataset.post = dataset.post or {}
@@ -43,21 +67,21 @@ function private.write_settings(settings, item_key)
end
function private.get_unit_start_price()
local money_text = private.unit_start_price:GetText()
local money_text = m.unit_start_price:GetText()
return Aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
end
function private.set_unit_start_price(amount)
private.unit_start_price:SetText(Aux.money.to_string(amount, true, nil, 3))
m.unit_start_price:SetText(Aux.money.to_string(amount, true, nil, 3))
end
function private.get_unit_buyout_price()
local money_text = private.unit_buyout_price:GetText()
local money_text = m.unit_buyout_price:GetText()
return Aux.money.from_string(money_text) or (tonumber(money_text) and tonumber(money_text) * 10000) or 0
end
function private.set_unit_buyout_price(amount)
private.unit_buyout_price:SetText(Aux.money.to_string(amount, true, nil, 3))
m.unit_buyout_price:SetText(Aux.money.to_string(amount, true, nil, 3))
end
function private.update_inventory_listing()
@@ -65,9 +89,9 @@ function private.update_inventory_listing()
return
end
Aux.item_listing.populate(private.item_listing, Aux.util.filter(inventory_records, function(record)
local settings = private.read_settings(record.key)
return record.aux_quantity > 0 and (not settings.hidden or private.show_hidden_checkbox:GetChecked())
Aux.item_listing.populate(m.item_listing, Aux.util.filter(inventory_records, function(record)
local settings = m.read_settings(record.key)
return record.aux_quantity > 0 and (not settings.hidden or m.show_hidden_checkbox:GetChecked())
end))
end
@@ -77,22 +101,22 @@ function private.update_auction_listing()
end
local auction_rows = {}
if private.selected_item then
local unit_start_price = private.get_unit_start_price()
local unit_buyout_price = private.get_unit_buyout_price()
if m.selected_item then
local unit_start_price = m.get_unit_start_price()
local unit_buyout_price = m.get_unit_buyout_price()
for i, auction_record in ipairs(existing_auctions[private.selected_item.key] or {}) do
for i, auction_record in ipairs(existing_auctions[m.selected_item.key] or {}) do
local blizzard_bid_undercut, buyout_price_undercut = private.undercut(auction_record, private.stack_size_slider:GetValue())
local blizzard_bid_undercut, buyout_price_undercut = m.undercut(auction_record, m.stack_size_slider:GetValue())
blizzard_bid_undercut = Aux.money.from_string(Aux.money.to_string(blizzard_bid_undercut, true, nil, 3))
buyout_price_undercut = Aux.money.from_string(Aux.money.to_string(buyout_price_undercut, true, nil, 3))
local stack_blizzard_bid_undercut, stack_buyout_price_undercut = private.undercut(auction_record, private.stack_size_slider:GetValue(), true)
local stack_blizzard_bid_undercut, stack_buyout_price_undercut = m.undercut(auction_record, m.stack_size_slider:GetValue(), true)
stack_blizzard_bid_undercut = Aux.money.from_string(Aux.money.to_string(stack_blizzard_bid_undercut, true, nil, 3))
stack_buyout_price_undercut = Aux.money.from_string(Aux.money.to_string(stack_buyout_price_undercut, true, nil, 3))
local stack_size = private.stack_size_slider:GetValue()
local historical_value = Aux.history.value(private.selected_item.key)
local stack_size = m.stack_size_slider:GetValue()
local historical_value = Aux.history.value(m.selected_item.key)
local bid_color
if blizzard_bid_undercut < unit_start_price and stack_blizzard_bid_undercut < unit_start_price then
@@ -144,64 +168,45 @@ function private.update_auction_listing()
)
end)
end
private.auction_listing:SetData(auction_rows)
m.auction_listing:SetData(auction_rows)
end
function public.select_item(item_key)
for _, inventory_record in ipairs(Aux.util.filter(inventory_records, function(record) return record.aux_quantity > 0 end)) do
if inventory_record.key == item_key then
private.set_item(inventory_record)
m.set_item(inventory_record)
break
end
end
end
function public.on_load()
public.create_frames(private, public)
end
function private.price_update()
if private.selected_item then
local settings = private.read_settings()
if m.selected_item then
local settings = m.read_settings()
local start_price_input = private.get_unit_start_price()
local start_price_input = m.get_unit_start_price()
settings.start_price = start_price_input
local historical_value = Aux.history.value(private.selected_item.key)
private.start_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(start_price_input / historical_value * 100)) or '---')
local historical_value = Aux.history.value(m.selected_item.key)
m.start_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(start_price_input / historical_value * 100)) or '---')
local buyout_price_input = private.get_unit_buyout_price()
local buyout_price_input = m.get_unit_buyout_price()
settings.buyout_price = buyout_price_input
local historical_value = Aux.history.value(private.selected_item.key)
private.buyout_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(buyout_price_input / historical_value * 100)) or '---')
local historical_value = Aux.history.value(m.selected_item.key)
m.buyout_price_percentage:SetText(historical_value and Aux.auction_listing.percentage_historical(Aux.round(buyout_price_input / historical_value * 100)) or '---')
private.write_settings(settings)
m.write_settings(settings)
end
end
function public.on_open()
private.deposit:SetText('Deposit: '..Aux.money.to_string(0, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
private.set_unit_start_price(0)
private.set_unit_buyout_price(0)
private.update_inventory_records()
private.refresh = true
end
function public.on_close()
private.selected_item = nil
end
function private.post_auctions()
if private.selected_item then
local unit_start_price = private.get_unit_start_price()
local unit_buyout_price = private.get_unit_buyout_price()
local stack_size = private.stack_size_slider:GetValue()
if m.selected_item then
local unit_start_price = m.get_unit_start_price()
local unit_buyout_price = m.get_unit_buyout_price()
local stack_size = m.stack_size_slider:GetValue()
local stack_count
stack_count = private.stack_count_slider:GetValue()
local duration = UIDropDownMenu_GetSelectedValue(private.duration_dropdown)
local key = private.selected_item.key
stack_count = m.stack_count_slider:GetValue()
local duration = UIDropDownMenu_GetSelectedValue(m.duration_dropdown)
local key = m.selected_item.key
local duration_code
if duration == DURATION_4 then
@@ -222,18 +227,18 @@ function private.post_auctions()
function(posted)
local new_auction_record
for i = 1, posted do
new_auction_record = private.record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName('player'))
new_auction_record = m.record_auction(key, stack_size, unit_start_price, unit_buyout_price, duration_code, UnitName('player'))
end
private.update_inventory_records()
private.selected_item = nil
m.update_inventory_records()
m.selected_item = nil
for _, record in ipairs(inventory_records) do
if record.key == key then
private.set_item(record)
m.set_item(record)
end
end
private.refresh = true
m.refresh = true
end
)
end
@@ -241,81 +246,81 @@ end
function private.validate_parameters()
if not private.selected_item then
private.post_button:Disable()
if not m.selected_item then
m.post_button:Disable()
return
end
if private.get_unit_buyout_price() > 0 and private.get_unit_start_price() > private.get_unit_buyout_price() then
private.post_button:Disable()
if m.get_unit_buyout_price() > 0 and m.get_unit_start_price() > m.get_unit_buyout_price() then
m.post_button:Disable()
return
end
if private.get_unit_start_price() == 0 then
private.post_button:Disable()
if m.get_unit_start_price() == 0 then
m.post_button:Disable()
return
end
if private.stack_count_slider:GetValue() == 0 then
private.post_button:Disable()
if m.stack_count_slider:GetValue() == 0 then
m.post_button:Disable()
return
end
private.post_button:Enable()
m.post_button:Enable()
end
function private.update_item_configuration()
if not private.selected_item then
private.refresh_button:Disable()
if not m.selected_item then
m.refresh_button:Disable()
AuxPostParametersItemIconTexture:SetTexture(nil)
AuxPostParametersItemCount:SetText()
AuxPostParametersItemName:SetTextColor(unpack(Aux.gui.config.label_color.enabled))
AuxPostParametersItemName:SetText('No item selected')
private.unit_start_price:Hide()
private.unit_buyout_price:Hide()
private.stack_size_slider:Hide()
private.stack_count_slider:Hide()
private.deposit:Hide()
private.duration_dropdown:Hide()
private.historical_value_button:Hide()
private.hide_checkbox:Hide()
m.unit_start_price:Hide()
m.unit_buyout_price:Hide()
m.stack_size_slider:Hide()
m.stack_count_slider:Hide()
m.deposit:Hide()
m.duration_dropdown:Hide()
m.historical_value_button:Hide()
m.hide_checkbox:Hide()
else
private.unit_start_price:Show()
private.unit_buyout_price:Show()
private.stack_size_slider:Show()
private.stack_count_slider:Show()
private.deposit:Show()
private.duration_dropdown:Show()
private.historical_value_button:Show()
private.hide_checkbox:Show()
m.unit_start_price:Show()
m.unit_buyout_price:Show()
m.stack_size_slider:Show()
m.stack_count_slider:Show()
m.deposit:Show()
m.duration_dropdown:Show()
m.historical_value_button:Show()
m.hide_checkbox:Show()
AuxPostParametersItemIconTexture:SetTexture(private.selected_item.texture)
AuxPostParametersItemName:SetText('['..private.selected_item.name..']')
local color = ITEM_QUALITY_COLORS[private.selected_item.quality]
AuxPostParametersItemIconTexture:SetTexture(m.selected_item.texture)
AuxPostParametersItemName:SetText('['..m.selected_item.name..']')
local color = ITEM_QUALITY_COLORS[m.selected_item.quality]
AuxPostParametersItemName:SetTextColor(color.r, color.g, color.b)
if private.selected_item.aux_quantity > 1 then
AuxPostParametersItemCount:SetText(private.selected_item.aux_quantity)
if m.selected_item.aux_quantity > 1 then
AuxPostParametersItemCount:SetText(m.selected_item.aux_quantity)
else
AuxPostParametersItemCount:SetText()
end
private.stack_size_slider.editbox:SetNumber(private.stack_size_slider:GetValue())
private.stack_count_slider.editbox:SetNumber(private.stack_count_slider:GetValue())
m.stack_size_slider.editbox:SetNumber(m.stack_size_slider:GetValue())
m.stack_count_slider.editbox:SetNumber(m.stack_count_slider:GetValue())
do
local deposit_factor = Aux.neutral_faction() and 0.25 or 0.05
local stack_size = private.stack_size_slider:GetValue()
local stack_size = m.stack_size_slider:GetValue()
local stack_count
stack_count = private.stack_count_slider:GetValue()
local deposit = floor(private.selected_item.unit_vendor_price * deposit_factor * (private.selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(private.duration_dropdown) / 120
stack_count = m.stack_count_slider:GetValue()
local deposit = floor(m.selected_item.unit_vendor_price * deposit_factor * (m.selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(m.duration_dropdown) / 120
private.deposit:SetText('Deposit: '..Aux.money.to_string(deposit, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
m.deposit:SetText('Deposit: '..Aux.money.to_string(deposit, nil, nil, nil, Aux.gui.inline_color({255, 254, 250, 1})))
end
private.refresh_button:Enable()
m.refresh_button:Enable()
end
end
@@ -332,14 +337,14 @@ function private.undercut(record, stack_size, stack)
end
function private.quantity_update(max_count)
if private.selected_item then
local max_stack_count = private.selected_item.max_charges and private.selected_item.availability[private.stack_size_slider:GetValue()] or floor(private.selected_item.availability[0] / private.stack_size_slider:GetValue())
private.stack_count_slider:SetMinMaxValues(1, max_stack_count)
if m.selected_item then
local max_stack_count = m.selected_item.max_charges and m.selected_item.availability[m.stack_size_slider:GetValue()] or floor(m.selected_item.availability[0] / m.stack_size_slider:GetValue())
m.stack_count_slider:SetMinMaxValues(1, max_stack_count)
if max_count then
private.stack_count_slider:SetValue(max_stack_count)
m.stack_count_slider:SetValue(max_stack_count)
end
end
private.refresh = true
m.refresh = true
end
function private.unit_vendor_price(item_key)
@@ -367,51 +372,51 @@ function private.unit_vendor_price(item_key)
end
function private.update_historical_value_button()
if private.selected_item then
local historical_value = Aux.history.value(private.selected_item.key)
private.historical_value_button.amount = historical_value
private.historical_value_button:SetText(historical_value and Aux.money.to_string(historical_value, true, nil, 3) or '---')
if m.selected_item then
local historical_value = Aux.history.value(m.selected_item.key)
m.historical_value_button.amount = historical_value
m.historical_value_button:SetText(historical_value and Aux.money.to_string(historical_value, true, nil, 3) or '---')
end
end
function private.set_item(item)
local settings = private.read_settings(item.key)
local settings = m.read_settings(item.key)
item.unit_vendor_price = private.unit_vendor_price(item.key)
item.unit_vendor_price = m.unit_vendor_price(item.key)
if not item.unit_vendor_price then
settings.hidden = 1
private.write_settings(settings, item.key)
private.refresh = true
m.write_settings(settings, item.key)
m.refresh = true
return
end
Aux.scan.abort(scan_id)
private.selected_item = item
m.selected_item = item
UIDropDownMenu_Initialize(private.duration_dropdown, private.initialize_duration_dropdown) -- TODO, wtf, why is this needed
UIDropDownMenu_SetSelectedValue(private.duration_dropdown, settings.duration)
UIDropDownMenu_Initialize(m.duration_dropdown, m.initialize_duration_dropdown) -- TODO, wtf, why is this needed
UIDropDownMenu_SetSelectedValue(m.duration_dropdown, settings.duration)
private.hide_checkbox:SetChecked(settings.hidden)
m.hide_checkbox:SetChecked(settings.hidden)
private.stack_size_slider:SetMinMaxValues(1, private.selected_item.max_charges or private.selected_item.max_stack)
private.stack_size_slider:SetValue(settings.stack_size)
private.quantity_update(true)
m.stack_size_slider:SetMinMaxValues(1, m.selected_item.max_charges or m.selected_item.max_stack)
m.stack_size_slider:SetValue(settings.stack_size)
m.quantity_update(true)
private.unit_start_price:SetText(Aux.money.to_string(settings.start_price, true, nil, 3, nil, true))
private.unit_buyout_price:SetText(Aux.money.to_string(settings.buyout_price, true, nil, 3, nil, true))
m.unit_start_price:SetText(Aux.money.to_string(settings.start_price, true, nil, 3, nil, true))
m.unit_buyout_price:SetText(Aux.money.to_string(settings.buyout_price, true, nil, 3, nil, true))
if not existing_auctions[private.selected_item.key] then
private.refresh_entries()
if not existing_auctions[m.selected_item.key] then
m.refresh_entries()
end
private.write_settings(settings, item.key)
private.refresh = true
m.write_settings(settings, item.key)
m.refresh = true
end
function private.update_inventory_records()
inventory_records = {}
private.refresh = true
m.refresh = true
local auction_candidate_map = {}
@@ -459,32 +464,32 @@ function private.update_inventory_records()
tinsert(inventory_records, auction_candidate)
end
sort(inventory_records, function(a, b) return a.name < b.name end)
private.refresh = true
m.refresh = true
end
function private.refresh_entries()
if private.selected_item then
local item_id, suffix_id = private.selected_item.item_id, private.selected_item.suffix_id
if m.selected_item then
local item_id, suffix_id = m.selected_item.item_id, m.selected_item.suffix_id
local item_key = item_id..':'..suffix_id
existing_auctions[item_key] = nil
local query = Aux.scan_util.item_query(item_id)
private.status_bar:update_status(0,0)
private.status_bar:set_text('Scanning auctions...')
m.status_bar:update_status(0,0)
m.status_bar:set_text('Scanning auctions...')
scan_id = Aux.scan.start{
type = 'list',
ignore_owner = true,
queries = { query },
on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page - 1) / total_pages, 0) -- TODO
private.status_bar:set_text(format('Scanning Page %d / %d', page, total_pages))
m.status_bar:update_status(100 * (page - 1) / total_pages, 0) -- TODO
m.status_bar:set_text(format('Scanning Page %d / %d', page, total_pages))
end,
on_auction = function(auction_record)
if auction_record.item_key == item_key then
private.record_auction(
m.record_auction(
auction_record.item_key,
auction_record.aux_quantity,
auction_record.unit_blizzard_bid,
@@ -496,15 +501,15 @@ function private.refresh_entries()
end,
on_abort = function()
existing_auctions[item_key] = nil
private.update_historical_value_button()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.update_historical_value_button()
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
end,
on_complete = function()
existing_auctions[item_key] = existing_auctions[item_key] or {}
private.refresh = true
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.refresh = true
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
end,
}
end
@@ -537,26 +542,26 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
end
function public.on_update()
if private.refresh then
private.refresh = false
private.price_update()
private.update_historical_value_button()
private.update_item_configuration()
private.update_inventory_listing()
private.update_auction_listing()
if m.refresh then
m.refresh = false
m.price_update()
m.update_historical_value_button()
m.update_item_configuration()
m.update_inventory_listing()
m.update_auction_listing()
end
private.validate_parameters()
m.validate_parameters()
end
function private.initialize_duration_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(private.duration_dropdown, this.value)
local settings = private.read_settings()
UIDropDownMenu_SetSelectedValue(m.duration_dropdown, this.value)
local settings = m.read_settings()
settings.duration = this.value
private.write_settings(settings)
private.refresh = true
m.write_settings(settings)
m.refresh = true
end
UIDropDownMenu_AddButton{
+56 -56
View File
@@ -1,18 +1,18 @@
function Aux.post_frame.create_frames(private, public)
Aux.post_frame.FRAMES(function(m, private, public)
Aux.gui.vertical_line(AuxPostFrameContent, 219)
AuxPostParametersItem:EnableMouse()
AuxPostParametersItem:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item()
if item_info then
public.select_item(item_info.item_key)
m.select_item(item_info.item_key)
end
ClearCursor()
end)
AuxPostParametersItem:SetScript('OnClick', function()
local item_info = Aux.cursor_item()
if item_info then
public.select_item(item_info.item_key)
m.select_item(item_info.item_key)
end
ClearCursor()
end)
@@ -22,8 +22,8 @@ function Aux.post_frame.create_frames(private, public)
highlight:SetTexture(1, .9, .9, .1)
AuxPostParametersItem:SetScript('OnEnter', function()
highlight:Show()
if private.selected_item then
Aux.info.set_tooltip(private.selected_item.itemstring, this, 'ANCHOR_RIGHT')
if m.selected_item then
Aux.info.set_tooltip(m.selected_item.itemstring, this, 'ANCHOR_RIGHT')
end
end)
AuxPostParametersItem:SetScript('OnLeave', function()
@@ -37,7 +37,7 @@ function Aux.post_frame.create_frames(private, public)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPLEFT', 45, -15)
checkbox:SetScript('OnClick', function()
private.refresh = true
m.refresh = true
end)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
@@ -51,7 +51,7 @@ function Aux.post_frame.create_frames(private, public)
AuxPostInventory,
function()
if arg1 == 'LeftButton' then
private.set_item(this.item_record)
m.set_item(this.item_record)
elseif arg1 == 'RightButton' then
Aux.tab_group:set_tab(1)
Aux.search_frame.set_filter(strlower(Aux.info.item(this.item_record.item_id).name)..'/exact')
@@ -66,12 +66,12 @@ function Aux.post_frame.create_frames(private, public)
GameTooltip:Hide()
end,
function(item_record)
return item_record == private.selected_item
return item_record == m.selected_item
end
)
private.auction_listing = Aux.listing.CreateScrollingTable(AuxPostAuctions)
private.auction_listing:SetColInfo({
m.auction_listing:SetColInfo({
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
{ name='Qty', width=.08, align='CENTER' },
@@ -80,17 +80,17 @@ function Aux.post_frame.create_frames(private, public)
{ name='Buy/ea', width=.23, align='RIGHT' },
{ name='Buy Pct', width=.12, align='CENTER' }
})
private.auction_listing:EnableSorting(false)
private.auction_listing:DisableSelection(true)
private.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
m.auction_listing:EnableSorting(false)
m.auction_listing:DisableSelection(true)
m.auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
local column_index = Aux.util.index_of(column, column.row.cols)
local unit_start_price, unit_buyout_price = private.undercut(row_data.record, private.stack_size_slider:GetValue(), button == 'RightButton')
local unit_start_price, unit_buyout_price = m.undercut(row_data.record, m.stack_size_slider:GetValue(), button == 'RightButton')
if column_index == 3 then
private.stack_size_slider:SetValue(row_data.record.stack_size)
m.stack_size_slider:SetValue(row_data.record.stack_size)
elseif column_index == 4 then
private.set_unit_start_price(unit_start_price)
m.set_unit_start_price(unit_start_price)
elseif column_index == 6 then
private.set_unit_buyout_price(unit_buyout_price)
m.set_unit_buyout_price(unit_buyout_price)
end
end)
@@ -105,20 +105,20 @@ function Aux.post_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxPostParameters, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Post')
btn:SetScript('OnClick', private.post_auctions)
btn:SetScript('OnClick', m.post_auctions)
private.post_button = btn
end
do
local btn = Aux.gui.button(AuxPostParameters, 16)
btn:SetPoint('TOPLEFT', private.post_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.post_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', private.refresh)
-- btn:SetScript('OnClick', m.refresh) TODO
private.refresh_button = btn
end
do
@@ -127,24 +127,24 @@ function Aux.post_frame.create_frames(private, public)
slider:SetPoint('TOPLEFT', 16, -75)
slider:SetWidth(190)
slider:SetScript('OnValueChanged', function()
private.quantity_update(true)
m.quantity_update(true)
end)
slider.editbox:SetScript('OnTextChanged', function()
slider:SetValue(this:GetNumber())
private.quantity_update(true)
if private.selected_item then
local settings = private.read_settings()
m.quantity_update(true)
if m.selected_item then
local settings = m.read_settings()
settings.stack_size = this:GetNumber()
private.write_settings(settings)
m.write_settings(settings)
end
end)
slider.editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.unit_buyout_price:SetFocus()
elseif private.stack_count_slider.editbox:IsVisible() then
private.stack_count_slider.editbox:SetFocus()
m.unit_buyout_price:SetFocus()
elseif m.stack_count_slider.editbox:IsVisible() then
m.stack_count_slider.editbox:SetFocus()
else
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
end
end)
slider.editbox:SetWidth(50)
@@ -157,20 +157,20 @@ function Aux.post_frame.create_frames(private, public)
do
local slider = Aux.gui.slider(AuxPostParameters)
slider:SetValueStep(1)
slider:SetPoint('TOPLEFT', private.stack_size_slider, 'BOTTOMLEFT', 0, -30)
slider:SetPoint('TOPLEFT', m.stack_size_slider, 'BOTTOMLEFT', 0, -30)
slider:SetWidth(190)
slider:SetScript('OnValueChanged', function()
private.quantity_update()
m.quantity_update()
end)
slider.editbox:SetScript('OnTextChanged', function()
slider:SetValue(this:GetNumber())
private.quantity_update()
m.quantity_update()
end)
slider.editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
else
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
end
end)
slider.editbox:SetWidth(50)
@@ -181,15 +181,15 @@ function Aux.post_frame.create_frames(private, public)
end
do
local dropdown = Aux.gui.dropdown(AuxPostParameters)
dropdown:SetPoint('TOPLEFT', private.stack_count_slider, 'BOTTOMLEFT', 0, -19)
dropdown:SetPoint('TOPLEFT', m.stack_count_slider, 'BOTTOMLEFT', 0, -19)
dropdown:SetWidth(90)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Duration')
UIDropDownMenu_Initialize(dropdown, private.initialize_duration_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_duration_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_duration_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_duration_dropdown)
end)
local label = Aux.gui.label(dropdown, 15)
label:SetPoint('LEFT', dropdown, 'RIGHT', 25, 0)
@@ -202,10 +202,10 @@ function Aux.post_frame.create_frames(private, public)
checkbox:SetHeight(22)
checkbox:SetPoint('TOPRIGHT', -85, -6)
checkbox:SetScript('OnClick', function()
local settings = private.read_settings()
local settings = m.read_settings()
settings.hidden = this:GetChecked()
private.write_settings(settings)
private.refresh = true
m.write_settings(settings)
m.refresh = true
end)
local label = Aux.gui.label(checkbox, 13)
label:SetPoint('LEFT', checkbox, 'RIGHT', 2, 1)
@@ -218,16 +218,16 @@ function Aux.post_frame.create_frames(private, public)
editbox:SetJustifyH('RIGHT')
editbox:SetWidth(150)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3))
private.refresh = true
this.pretty:SetText(Aux.money.to_string(m.get_unit_start_price(), true, nil, 3))
m.refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() and private.stack_count_slider.editbox:IsVisible() then
private.stack_count_slider.editbox:SetFocus()
if IsShiftKeyDown() and m.stack_count_slider.editbox:IsVisible() then
m.stack_count_slider.editbox:SetFocus()
elseif IsShiftKeyDown() then
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
else
private.unit_buyout_price:SetFocus()
m.unit_buyout_price:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -238,7 +238,7 @@ function Aux.post_frame.create_frames(private, public)
this.pretty:Hide()
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(Aux.money.to_string(private.get_unit_start_price(), true, nil, 3, nil, true))
this:SetText(Aux.money.to_string(m.get_unit_start_price(), true, nil, 3, nil, true))
this.pretty:Show()
end)
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
@@ -260,18 +260,18 @@ function Aux.post_frame.create_frames(private, public)
end
do
local editbox = Aux.gui.editbox(AuxPostParameters)
editbox:SetPoint('TOPRIGHT', private.unit_start_price, 'BOTTOMRIGHT', 0, -18)
editbox:SetPoint('TOPRIGHT', m.unit_start_price, 'BOTTOMRIGHT', 0, -18)
editbox:SetJustifyH('RIGHT')
editbox:SetWidth(150)
editbox:SetScript('OnTextChanged', function()
this.pretty:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3))
private.refresh = true
this.pretty:SetText(Aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3))
m.refresh = true
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.unit_start_price:SetFocus()
m.unit_start_price:SetFocus()
else
private.stack_size_slider.editbox:SetFocus()
m.stack_size_slider.editbox:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
@@ -282,7 +282,7 @@ function Aux.post_frame.create_frames(private, public)
this.pretty:Hide()
end)
editbox:SetScript('OnEditFocusLost', function()
this:SetText(Aux.money.to_string(private.get_unit_buyout_price(), true, nil, 3, nil, true))
this:SetText(Aux.money.to_string(m.get_unit_buyout_price(), true, nil, 3, nil, true))
this.pretty:Show()
end)
editbox.pretty = Aux.gui.label(editbox, Aux.gui.config.normal_font_size)
@@ -312,8 +312,8 @@ function Aux.post_frame.create_frames(private, public)
btn:GetFontString():SetPoint('RIGHT', 0, 0)
btn:SetScript('OnClick', function()
if this.amount then
private.set_unit_start_price(this.amount)
private.set_unit_buyout_price(this.amount)
m.set_unit_start_price(this.amount)
m.set_unit_buyout_price(this.amount)
end
end)
local label = Aux.gui.label(btn, 13)
@@ -321,4 +321,4 @@ function Aux.post_frame.create_frames(private, public)
label:SetText('Historical Value')
private.historical_value_button = btn
end
end
end)
+176 -171
View File
@@ -1,10 +1,11 @@
local private, public = {}, {}
Aux.search_frame = public
local m, private, public = Aux.tab(1, 'search_frame')
aux_favorite_searches = {}
aux_recent_searches = {}
private.search_scan_id = 0
private.snipe_auto = nil
private.snipe = nil
private.popup_info = {
rename = {}
@@ -12,8 +13,8 @@ private.popup_info = {
do
local function action()
private.popup_info.rename.name = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
private.update_search_listings()
m.popup_info.rename.name = getglobal(this:GetParent():GetName()..'EditBox'):GetText()
m.update_search_listings()
end
StaticPopupDialogs['AUX_SEARCH_SAVED_RENAME'] = {
@@ -22,7 +23,7 @@ do
button2 = 'Cancel',
hasEditBox = 1,
OnShow = function()
local rename_info = private.popup_info.rename
local rename_info = m.popup_info.rename
local edit_box = getglobal(this:GetName()..'EditBox')
edit_box:SetText(rename_info.name or '')
edit_box:SetFocus()
@@ -52,9 +53,9 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_SNIPING'] = {
button1 = 'Yes',
button2 = 'No',
OnAccept = function()
private.snipe_button.auto = true
m.snipe_button.auto = true
local color = RED_FONT_COLOR
private.snipe_button:GetFontString():SetTextColor(color.r, color.g, color.b)
m.snipe_button:GetFontString():SetTextColor(color.r, color.g, color.b)
end,
timeout = 0,
hideOnEscape = 1,
@@ -63,11 +64,30 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_SNIPING'] = {
private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3
private.elements = {
[private.RESULTS] = {},
[private.SAVED] = {},
[private.FILTER] = {},
[m.RESULTS] = {},
[m.SAVED] = {},
[m.FILTER] = {},
}
function public.FRAMES(f)
private.create_frames = f
end
function public.LOAD()
m.create_frames(m, private, public)
m:disable_sniping()
m.update_search()
m.update_tab(m.SAVED)
end
function public.OPEN()
m.update_search_listings()
end
function public.CLOSE()
m.results_listing:SetSelectedRecord()
end
function private.update_search_listings()
local favorite_search_rows = {}
for i, favorite_search in ipairs(aux_favorite_searches) do
@@ -79,7 +99,7 @@ function private.update_search_listings()
name = name,
})
end
private.favorite_searches_listing:SetData(favorite_search_rows)
m.favorite_searches_listing:SetData(favorite_search_rows)
local recent_search_rows = {}
for i, recent_search in ipairs(aux_recent_searches) do
@@ -91,41 +111,41 @@ function private.update_search_listings()
name = name,
})
end
private.recent_searches_listing:SetData(recent_search_rows)
m.recent_searches_listing:SetData(recent_search_rows)
end
function private.update_tab(tab)
private.search_results_button:UnlockHighlight()
private.saved_searches_button:UnlockHighlight()
private.new_filter_button:UnlockHighlight()
m.search_results_button:UnlockHighlight()
m.saved_searches_button:UnlockHighlight()
m.new_filter_button:UnlockHighlight()
AuxSearchFrameResults:Hide()
AuxSearchFrameSaved:Hide()
AuxSearchFrameFilter:Hide()
if tab == private.RESULTS then
if tab == m.RESULTS then
AuxSearchFrameResults:Show()
private.search_results_button:LockHighlight()
elseif tab == private.SAVED then
m.search_results_button:LockHighlight()
elseif tab == m.SAVED then
AuxSearchFrameSaved:Show()
private.saved_searches_button:LockHighlight()
elseif tab == private.FILTER then
m.saved_searches_button:LockHighlight()
elseif tab == m.FILTER then
AuxSearchFrameFilter:Show()
private.new_filter_button:LockHighlight()
m.new_filter_button:LockHighlight()
end
end
function public.set_filter(filter_string)
private.search_box:SetText(filter_string)
m.search_box:SetText(filter_string)
end
function private.add_filter(filter_string, replace)
filter_string = filter_string or private.get_form_filter()
filter_string = filter_string or m.get_form_filter()
local old_filter_string
if not replace then
old_filter_string = private.search_box:GetText()
old_filter_string = m.search_box:GetText()
old_filter_string = Aux.util.trim(old_filter_string)
if strlen(old_filter_string) > 0 then
@@ -133,7 +153,7 @@ function private.add_filter(filter_string, replace)
end
end
private.search_box:SetText((old_filter_string or '')..filter_string)
m.search_box:SetText((old_filter_string or '')..filter_string)
end
function private.clear_form()
@@ -142,12 +162,12 @@ function private.clear_form()
AuxSearchFrameFilterMinLevel:SetText('')
AuxSearchFrameFilterMaxLevel:SetText('')
AuxSearchFrameFilterUsableCheckButton:SetChecked(nil)
UIDropDownMenu_ClearAll(private.class_dropdown)
UIDropDownMenu_ClearAll(private.subclass_dropdown)
UIDropDownMenu_ClearAll(private.slot_dropdown)
UIDropDownMenu_ClearAll(private.quality_dropdown)
private.first_page_editbox:SetText('')
private.last_page_editbox:SetText('')
UIDropDownMenu_ClearAll(m.class_dropdown)
UIDropDownMenu_ClearAll(m.subclass_dropdown)
UIDropDownMenu_ClearAll(m.slot_dropdown)
UIDropDownMenu_ClearAll(m.quality_dropdown)
m.first_page_editbox:SetText('')
m.last_page_editbox:SetText('')
end
function private.get_form_filter()
@@ -175,27 +195,27 @@ function private.get_form_filter()
add('usable')
end
local class = UIDropDownMenu_GetSelectedValue(private.class_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(private.class_dropdown)
local class = UIDropDownMenu_GetSelectedValue(m.class_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(m.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)
local subclass = UIDropDownMenu_GetSelectedValue(m.subclass_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(m.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)
local slot = UIDropDownMenu_GetSelectedValue(m.slot_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(m.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)
local quality = UIDropDownMenu_GetSelectedValue(m.quality_dropdown) ~= 0 and UIDropDownMenu_GetSelectedValue(m.quality_dropdown)
if quality then
add(strlower(getglobal('ITEM_QUALITY'..quality..'_DESC')))
end
local first_page, last_page = tonumber(private.first_page_editbox:GetText()), tonumber(private.last_page_editbox:GetText())
local first_page, last_page = tonumber(m.first_page_editbox:GetText()), tonumber(m.last_page_editbox:GetText())
first_page = first_page and max(1, first_page)
last_page = last_page and max(1, last_page)
if first_page or last_page then
@@ -205,55 +225,40 @@ function private.get_form_filter()
return filter_term
end
function public.on_open()
private.update_search_listings()
end
function public.on_close()
private.results_listing:SetSelectedRecord()
end
function public.on_load()
public.create_frames(private, public)
public:disable_sniping()
private.update_search()
private.update_tab(private.SAVED)
end
function private.discard_continuation()
Aux.scan.abort(private.search_scan_id)
private.current_search().continuation = nil
private.update_resume()
Aux.scan.abort(m.search_scan_id)
m.current_search().continuation = nil
m.update_resume()
end
function private:enable_stop()
Aux.scan.abort(private.search_scan_id)
private.stop_button:Show()
private.start_button:Hide()
Aux.scan.abort(m.search_scan_id)
m.stop_button:Show()
m.start_button:Hide()
end
function private:enable_start()
private.start_button:Show()
private.stop_button:Hide()
m.start_button:Show()
m.stop_button:Hide()
end
function public.enable_sniping()
Aux.scan.abort(private.search_scan_id)
private.snipe = true
private.snipe_button:LockHighlight()
Aux.scan.abort(m.search_scan_id)
m.snipe = true
m.snipe_button:LockHighlight()
end
function public.disable_sniping()
Aux.scan.abort(private.search_scan_id)
private.snipe = false
private.snipe_button:UnlockHighlight()
Aux.scan.abort(m.search_scan_id)
m.snipe = false
m.snipe_button:UnlockHighlight()
end
function private.start_sniping(query, search)
local ignore_page
if not search then
search = private.current_search()
search = m.current_search()
query.blizzard_query.first_page = 0
query.blizzard_query.last_page = 0
ignore_page = true
@@ -265,12 +270,12 @@ function private.start_sniping(query, search)
end
local next_page
private.search_scan_id = Aux.scan.start{
m.search_scan_id = Aux.scan.start{
type = 'list',
queries = {query},
on_scan_start = function()
private.status_bar:update_status(99.99, 99.99)
private.status_bar:set_text('Sniping ...')
m.status_bar:update_status(99.99, 99.99)
m.status_bar:set_text('Sniping ...')
end,
on_page_loaded = function(_, _, last_page)
next_page = last_page
@@ -280,7 +285,7 @@ function private.start_sniping(query, search)
end,
on_auction = function(auction_record)
if not ignore_page then
if private.snipe_button.auto then
if m.snipe_button.auto then
PlaceAuctionBid('list', auction_record.index, auction_record.buyout_price)
else
sniping_map[auction_record.sniping_signature] = auction_record
@@ -295,23 +300,23 @@ function private.start_sniping(query, search)
for _, record in sniping_map do
tinsert(search.records, record)
end
private.results_listing:SetDatabase(search.records)
m.results_listing:SetDatabase(search.records)
end
query.blizzard_query.first_page = next_page
query.blizzard_query.last_page = next_page
private.start_sniping(query, search)
m.start_sniping(query, search)
end,
on_abort = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Sniping')
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Sniping')
search.continuation = true
if private.current_search() == search then
private.update_resume()
if m.current_search() == search then
m.update_resume()
end
private:enable_start()
m:enable_start()
end,
}
end
@@ -327,21 +332,21 @@ function private.start_search(queries, continuation)
tremove(queries, 1)
end
queries[1].blizzard_query.first_page = (queries[1].blizzard_query.first_page or 0) + start_page - 1
private.results_listing:SetSelectedRecord()
m.results_listing:SetSelectedRecord()
else
start_query, start_page = 1, 1
end
local search = private.current_search()
private.search_scan_id = Aux.scan.start{
local search = m.current_search()
m.search_scan_id = Aux.scan.start{
type = 'list',
queries = queries,
on_scan_start = function()
private.status_bar:update_status(0,0)
m.status_bar:update_status(0,0)
if resume then
private.status_bar:set_text('Resuming scan...')
m.status_bar:set_text('Resuming scan...')
else
private.status_bar:set_text('Scanning auctions...')
m.status_bar:set_text('Scanning auctions...')
end
end,
on_page_loaded = function(_, total_scan_pages)
@@ -349,11 +354,11 @@ function private.start_search(queries, continuation)
total_scan_pages = total_scan_pages + (start_page - 1)
total_scan_pages = max(total_scan_pages, 1)
current_page = min(current_page, total_scan_pages)
private.status_bar:update_status(100 * (current_query - 1) / getn(queries), 100 * (current_page - 1) / total_scan_pages)
private.status_bar:set_text(format('Scanning %d / %d (Page %d / %d)', current_query, total_queries, current_page, total_scan_pages))
m.status_bar:update_status(100 * (current_query - 1) / getn(queries), 100 * (current_page - 1) / total_scan_pages)
m.status_bar:set_text(format('Scanning %d / %d (Page %d / %d)', current_query, total_queries, current_page, total_scan_pages))
end,
on_page_scanned = function()
private.results_listing:SetDatabase()
m.results_listing:SetDatabase()
end,
on_start_query = function(query)
current_query = current_query and current_query + 1 or start_query
@@ -368,43 +373,43 @@ function private.start_search(queries, continuation)
end
end,
on_complete = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
if private.current_search() == search and AuxSearchFrameResults:IsVisible() and getn(search.records) == 0 then
private.update_tab(private.SAVED)
if m.current_search() == search and AuxSearchFrameResults:IsVisible() and getn(search.records) == 0 then
m.update_tab(m.SAVED)
end
private:enable_start()
m.enable_start()
end,
on_abort = function()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
m.status_bar:update_status(100, 100)
m.status_bar:set_text('Done Scanning')
if current_query then
search.continuation = {current_query, current_page + 1}
else
search.continuation = {start_query, start_page}
end
if private.current_search() == search then
private.update_resume()
if m.current_search() == search then
m.update_resume()
end
private:enable_start()
m.enable_start()
end,
}
end
function public.execute(resume)
if resume then
private.search_box:SetText(private.current_search().filter_string)
m.search_box:SetText(m.current_search().filter_string)
end
local filter_string = private.search_box:GetText()
local filter_string = m.search_box:GetText()
local queries = Aux.scan_util.parse_filter_string(filter_string)
if not queries then
return
elseif private.snipe then
elseif m.snipe then
if getn(queries) > 1 then
Aux.log('Invalid filter: The sniping mode does not support multiple queries')
return
@@ -414,32 +419,32 @@ function public.execute(resume)
end
end
if filter_string ~= private.current_search().filter_string then
private.new_search(filter_string, Aux.util.join(Aux.util.map(queries, function(filter) return filter.prettified end), ';'))
if filter_string ~= m.current_search().filter_string then
m.new_search(filter_string, Aux.util.join(Aux.util.map(queries, function(filter) return filter.prettified end), ';'))
else
private.search_box:ClearFocus()
m.search_box:ClearFocus()
if resume then
private.results_listing:SetSelectedRecord()
m.results_listing:SetSelectedRecord()
else
if private.current_search().snipe ~= private.snipe then
private.results_listing:Reset()
if m.current_search().snipe ~= m.snipe then
m.results_listing:Reset()
end
private.current_search().records = {}
private.results_listing:SetDatabase(private.current_search().records)
m.current_search().records = {}
m.results_listing:SetDatabase(m.current_search().records)
end
end
local continuation = private.current_search().continuation
private.discard_continuation()
private:enable_stop()
local continuation = m.current_search().continuation
m.discard_continuation()
m:enable_stop()
private.update_tab(private.RESULTS)
if private.snipe then
private.current_search().snipe = true
private.start_sniping(queries[1])
m.update_tab(m.RESULTS)
if m.snipe then
m.current_search().snipe = true
m.start_sniping(queries[1])
else
private.current_search().snipe = false
private.start_search(queries, resume and continuation)
m.current_search().snipe = false
m.start_search(queries, resume and continuation)
end
end
@@ -452,7 +457,7 @@ end
function private.record_remover(record)
return function()
private.results_listing:RemoveAuctionRecord(record)
m.results_listing:RemoveAuctionRecord(record)
end
end
@@ -467,7 +472,7 @@ do
local found_index
function private.find_auction(record)
if not private.results_listing:ContainsRecord(record) or Aux.is_player(record.owner) then
if not m.results_listing:ContainsRecord(record) or Aux.is_player(record.owner) then
return
end
@@ -475,37 +480,37 @@ do
state = SEARCHING
scan_id = Aux.scan_util.find(
record,
private.status_bar,
m.status_bar,
function()
state = IDLE
end,
function()
state = IDLE
private.record_remover(record)()
m.record_remover(record)()
end,
function(index)
state = FOUND
found_index = index
if not record.high_bidder then
private.bid_button:SetScript('OnClick', function()
if private.test(record)(index) and private.results_listing:ContainsRecord(record) then
m.bid_button:SetScript('OnClick', function()
if m.test(record)(index) and m.results_listing:ContainsRecord(record) then
Aux.place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
Aux.info.bid_update(record)
private.results_listing:SetDatabase()
end or private.record_remover(record))
m.results_listing:SetDatabase()
end or m.record_remover(record))
end
end)
private.bid_button:Enable()
m.bid_button:Enable()
end
if record.buyout_price > 0 then
private.buyout_button:SetScript('OnClick', function()
if private.test(record)(index) and private.results_listing:ContainsRecord(record) then
Aux.place_bid('list', index, record.buyout_price, private.record_remover(record))
m.buyout_button:SetScript('OnClick', function()
if m.test(record)(index) and m.results_listing:ContainsRecord(record) then
Aux.place_bid('list', index, record.buyout_price, m.record_remover(record))
end
end)
private.buyout_button:Enable()
m.buyout_button:Enable()
end
end
)
@@ -513,22 +518,22 @@ do
function public.on_update()
if state == IDLE or state == SEARCHING then
private.buyout_button:Disable()
private.bid_button:Disable()
m.buyout_button:Disable()
m.bid_button:Disable()
end
if state == SEARCHING then
return
end
local selection = private.results_listing:GetSelection()
local selection = m.results_listing:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then
private.find_auction(selection.record)
elseif state == FOUND and not private.test(selection.record)(found_index) then
private.buyout_button:Disable()
private.bid_button:Disable()
m.find_auction(selection.record)
elseif state == FOUND and not m.test(selection.record)(found_index) then
m.buyout_button:Disable()
m.bid_button:Disable()
if not Aux.bid_in_progress() then
state = IDLE
end
@@ -537,12 +542,12 @@ do
end
function private.update_resume()
if private.current_search().continuation and private.current_search().snipe == private.snipe then
private.resume_button:Show()
private.search_box:SetPoint('RIGHT', private.resume_button, 'LEFT', -4, 0)
if m.current_search().continuation and m.current_search().snipe == m.snipe then
m.resume_button:Show()
m.search_box:SetPoint('RIGHT', m.resume_button, 'LEFT', -4, 0)
else
private.resume_button:Hide()
private.search_box:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
m.resume_button:Hide()
m.search_box:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
end
end
@@ -558,24 +563,24 @@ do
end
function private.update_search()
Aux.scan.abort(private.search_scan_id)
private.search_box:ClearFocus()
private.search_box:SetText(searches[search_index].filter_string)
private.results_listing:Reset()
private.results_listing:SetDatabase(searches[search_index].records)
Aux.scan.abort(m.search_scan_id)
m.search_box:ClearFocus()
m.search_box:SetText(searches[search_index].filter_string)
m.results_listing:Reset()
m.results_listing:SetDatabase(searches[search_index].records)
if search_index == 1 or search_index == 0 then
private.previous_button:Disable()
m.previous_button:Disable()
else
private.previous_button:Enable()
m.previous_button:Enable()
end
if search_index == getn(searches) or search_index == 0 then
private.next_button:Hide()
private.search_box:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
m.next_button:Hide()
m.search_box:SetPoint('LEFT', m.previous_button, 'RIGHT', 4, 0)
else
private.next_button:Show()
private.search_box:SetPoint('LEFT', private.next_button, 'RIGHT', 4, 0)
m.next_button:Show()
m.search_box:SetPoint('LEFT', m.next_button, 'RIGHT', 4, 0)
end
private.update_resume()
m.update_resume()
end
function private.new_search(filter_string, prettified)
@@ -586,7 +591,7 @@ do
while getn(aux_recent_searches) > 50 do
tremove(aux_recent_searches)
end
private.update_search_listings()
m.update_search_listings()
tinsert(searches, search_index + 1, {
filter_string = filter_string,
@@ -599,29 +604,29 @@ do
tremove(searches, 1)
end
search_index = getn(searches)
private.update_search()
m.update_search()
end
function private.previous_search()
search_index = search_index - 1
private.update_search()
private.update_tab(private.RESULTS)
m.update_search()
m.update_tab(m.RESULTS)
end
function private.next_search()
search_index = search_index + 1
private.update_search()
private.update_tab(private.RESULTS)
m.update_search()
m.update_tab(m.RESULTS)
end
end
function private.initialize_class_dropdown()
local function on_click()
if this.value ~= UIDropDownMenu_GetSelectedValue(private.class_dropdown) then
UIDropDownMenu_ClearAll(private.subclass_dropdown)
UIDropDownMenu_ClearAll(private.slot_dropdown)
if this.value ~= UIDropDownMenu_GetSelectedValue(m.class_dropdown) then
UIDropDownMenu_ClearAll(m.subclass_dropdown)
UIDropDownMenu_ClearAll(m.slot_dropdown)
end
UIDropDownMenu_SetSelectedValue(private.class_dropdown, this.value)
UIDropDownMenu_SetSelectedValue(m.class_dropdown, this.value)
end
UIDropDownMenu_AddButton{
@@ -642,13 +647,13 @@ end
function private.initialize_subclass_dropdown()
local function on_click()
if this.value ~= UIDropDownMenu_GetSelectedValue(private.subclass_dropdown) then
UIDropDownMenu_ClearAll(private.slot_dropdown)
if this.value ~= UIDropDownMenu_GetSelectedValue(m.subclass_dropdown) then
UIDropDownMenu_ClearAll(m.slot_dropdown)
end
UIDropDownMenu_SetSelectedValue(private.subclass_dropdown, this.value)
UIDropDownMenu_SetSelectedValue(m.subclass_dropdown, this.value)
end
local class_index = UIDropDownMenu_GetSelectedValue(private.class_dropdown)
local class_index = UIDropDownMenu_GetSelectedValue(m.class_dropdown)
if class_index and GetAuctionItemSubClasses(class_index) then
UIDropDownMenu_AddButton{
@@ -670,11 +675,11 @@ end
function private.initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(private.slot_dropdown, this.value)
UIDropDownMenu_SetSelectedValue(m.slot_dropdown, this.value)
end
local class_index = UIDropDownMenu_GetSelectedValue(private.class_dropdown)
local subclass_index = UIDropDownMenu_GetSelectedValue(private.subclass_dropdown)
local class_index = UIDropDownMenu_GetSelectedValue(m.class_dropdown)
local subclass_index = UIDropDownMenu_GetSelectedValue(m.subclass_dropdown)
if class_index and subclass_index and GetAuctionInvTypes(class_index, subclass_index) then
UIDropDownMenu_AddButton{
@@ -697,7 +702,7 @@ end
function private.initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(private.quality_dropdown, this.value)
UIDropDownMenu_SetSelectedValue(m.quality_dropdown, this.value)
end
UIDropDownMenu_AddButton{
+145 -145
View File
@@ -1,4 +1,4 @@
function Aux.search_frame.create_frames(private, public)
Aux.search_frame.FRAMES(function(m, private, public)
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('TOPLEFT', 5, -8)
@@ -8,12 +8,12 @@ function Aux.search_frame.create_frames(private, public)
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
if arg1 == 'LeftButton' then
if private.snipe then
public.disable_sniping()
if m.snipe then
m.disable_sniping()
else
public.enable_sniping()
m.enable_sniping()
end
private.update_resume()
m.update_resume()
elseif arg1 == 'RightButton' then
if this.auto then
this.auto = false
@@ -29,20 +29,20 @@ function Aux.search_frame.create_frames(private, public)
Aux.gui.vertical_line(AuxSearchFrame, 80, nil, 408)
do
local btn = Aux.gui.button(AuxSearchFrame, 26)
btn:SetPoint('LEFT', private.snipe_button, 'RIGHT', 12, 0)
btn:SetPoint('LEFT', m.snipe_button, 'RIGHT', 12, 0)
btn:SetWidth(30)
btn:SetHeight(25)
btn:SetText('<')
btn:SetScript('OnClick', private.previous_search)
btn:SetScript('OnClick', m.previous_search)
private.previous_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 26)
btn:SetPoint('LEFT', private.previous_button, 'RIGHT', 4, 0)
btn:SetPoint('LEFT', m.previous_button, 'RIGHT', 4, 0)
btn:SetWidth(30)
btn:SetHeight(25)
btn:SetText('>')
btn:SetScript('OnClick', private.next_search)
btn:SetScript('OnClick', m.next_search)
private.next_button = btn
end
do
@@ -54,9 +54,9 @@ function Aux.search_frame.create_frames(private, public)
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
if arg1 == 'RightButton' then
public.set_filter(private.current_search().filter_string)
m.set_filter(m.current_search().filter_string)
end
public.execute()
m.execute()
end)
private.start_button = btn
end
@@ -67,19 +67,19 @@ function Aux.search_frame.create_frames(private, public)
btn:SetHeight(25)
btn:SetText('Stop')
btn:SetScript('OnClick', function()
Aux.scan.abort(private.search_scan_id)
Aux.scan.abort(m.search_scan_id)
end)
btn:Hide()
private.stop_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 22)
btn:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
btn:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
btn:SetWidth(70)
btn:SetHeight(25)
btn:SetText(GREEN_FONT_COLOR_CODE..'Resume'..FONT_COLOR_CODE_CLOSE)
btn:SetScript('OnClick', function()
public.execute(true)
m.execute(true)
end)
private.resume_button = btn
end
@@ -88,7 +88,7 @@ function Aux.search_frame.create_frames(private, public)
editbox:SetMaxLetters(nil)
editbox:EnableMouse(1)
editbox.complete = Aux.completion.complete
editbox:SetPoint('RIGHT', private.start_button, 'LEFT', -4, 0)
editbox:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
editbox:SetHeight(25)
editbox:SetScript('OnChar', function()
this:complete()
@@ -99,14 +99,14 @@ function Aux.search_frame.create_frames(private, public)
editbox:SetScript('OnEnterPressed', function()
this:HighlightText(0, 0)
this:ClearFocus()
public.execute()
m.execute()
end)
editbox:SetScript('OnReceiveDrag', function()
local item_info = Aux.cursor_item() and Aux.info.item(Aux.cursor_item().item_id)
if item_info then
public.set_filter(strlower(item_info.name)..'/exact')
public.disable_sniping()
public.execute()
m.set_filter(strlower(item_info.name)..'/exact')
m.disable_sniping()
m.execute()
end
ClearCursor()
end)
@@ -121,25 +121,25 @@ function Aux.search_frame.create_frames(private, public)
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('Search Results')
btn:SetScript('OnClick', function() private.update_tab(private.RESULTS) end)
btn:SetScript('OnClick', function() m.update_tab(m.RESULTS) end)
private.search_results_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 18)
btn:SetPoint('TOPLEFT', private.search_results_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.search_results_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('Saved Searches')
btn:SetScript('OnClick', function() private.update_tab(private.SAVED) end)
btn:SetScript('OnClick', function() m.update_tab(m.SAVED) end)
private.saved_searches_button = btn
end
do
local btn = Aux.gui.button(AuxSearchFrame, 18)
btn:SetPoint('TOPLEFT', private.saved_searches_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.saved_searches_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(243)
btn:SetHeight(22)
btn:SetText('New Filter')
btn:SetScript('OnClick', function() private.update_tab(private.FILTER) end)
btn:SetScript('OnClick', function() m.update_tab(m.FILTER) end)
private.new_filter_button = btn
end
do
@@ -153,7 +153,7 @@ function Aux.search_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Bid')
@@ -162,7 +162,7 @@ function Aux.search_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
btn:SetPoint('TOPLEFT', private.bid_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.bid_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout')
@@ -171,43 +171,43 @@ function Aux.search_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxSearchFrameResults, 16)
btn:SetPoint('TOPLEFT', private.buyout_button, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.buyout_button, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Clear')
btn:SetScript('OnClick', function()
while tremove(private:current_search().records) do end
private.results_listing:SetDatabase()
while tremove(m.current_search().records) do end
m.results_listing:SetDatabase()
end)
end
do
local btn = Aux.gui.button(AuxSearchFrameSaved, 16)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Favorite')
btn:SetScript('OnClick', function()
local filters = Aux.scan_util.parse_filter_string(private.search_box:GetText())
local filters = Aux.scan_util.parse_filter_string(m.search_box:GetText())
if filters then
tinsert(aux_favorite_searches, 1, {
filter_string = private.search_box:GetText(),
filter_string = m.search_box:GetText(),
prettified = Aux.util.join(Aux.util.map(filters, function(filter) return filter.prettified end), ';'),
})
end
private.update_search_listings()
m.update_search_listings()
end)
end
do
local btn1 = Aux.gui.button(AuxSearchFrameFilter, 16)
btn1:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn1:SetPoint('TOPLEFT', m.status_bar, 'TOPRIGHT', 5, 0)
btn1:SetWidth(80)
btn1:SetHeight(24)
btn1:SetText('Search')
btn1:SetScript('OnClick', function()
private.search_box:SetText('')
private.add_filter()
private.clear_form()
public.execute()
m.search_box:SetText('')
m.add_filter()
m.clear_form()
m.execute()
end)
local btn2 = Aux.gui.button(AuxSearchFrameFilter, 16)
@@ -216,8 +216,8 @@ function Aux.search_frame.create_frames(private, public)
btn2:SetHeight(24)
btn2:SetText('Add')
btn2:SetScript('OnClick', function()
private.add_filter()
private.clear_form()
m.add_filter()
m.clear_form()
end)
local btn3 = Aux.gui.button(AuxSearchFrameFilter, 16)
@@ -226,8 +226,8 @@ function Aux.search_frame.create_frames(private, public)
btn3:SetHeight(24)
btn3:SetText('Replace')
btn3:SetScript('OnClick', function()
private.add_filter(nil, true)
private.clear_form()
m.add_filter(nil, true)
m.clear_form()
end)
end
do
@@ -242,14 +242,14 @@ function Aux.search_frame.create_frames(private, public)
end)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.last_page_editbox:SetFocus()
m.last_page_editbox:SetFocus()
else
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
this:ClearFocus()
public.execute()
m.execute()
end)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -280,7 +280,7 @@ function Aux.search_frame.create_frames(private, public)
end)
editbox:SetScript('OnEnterPressed', function()
this:ClearFocus()
public.execute()
m.execute()
end)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -296,12 +296,12 @@ function Aux.search_frame.create_frames(private, public)
if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'MinLevel'):SetFocus()
else
private.first_page_editbox:SetFocus()
m.first_page_editbox:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
this:ClearFocus()
public.execute()
m.execute()
end)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
@@ -315,7 +315,7 @@ function Aux.search_frame.create_frames(private, public)
local label = Aux.gui.label(AuxSearchFrameFilterUsableCheckButton, 13)
label:SetPoint('BOTTOMLEFT', AuxSearchFrameFilterUsableCheckButton, 'TOPLEFT', 1, -3)
label:SetText('Usable')
private.show_hidden_checkbox = checkbox
private.usable_checkbox = checkbox
end
do
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
@@ -325,57 +325,57 @@ function Aux.search_frame.create_frames(private, public)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Item Class')
UIDropDownMenu_Initialize(dropdown, private.initialize_class_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_class_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_class_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_class_dropdown)
end)
private.class_dropdown = dropdown
end
do
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
dropdown:SetPoint('TOPLEFT', private.class_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetPoint('TOPLEFT', m.class_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetWidth(300)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Item Subclass')
UIDropDownMenu_Initialize(dropdown, private.initialize_subclass_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_subclass_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_subclass_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_subclass_dropdown)
end)
private.subclass_dropdown = dropdown
end
do
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
dropdown:SetPoint('TOPLEFT', private.subclass_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetPoint('TOPLEFT', m.subclass_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetWidth(300)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Item Slot')
UIDropDownMenu_Initialize(dropdown, private.initialize_slot_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_slot_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_slot_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_slot_dropdown)
end)
private.slot_dropdown = dropdown
end
do
local dropdown = Aux.gui.dropdown(AuxSearchFrameFilter)
dropdown:SetPoint('TOPLEFT', private.slot_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetPoint('TOPLEFT', m.slot_dropdown, 'BOTTOMLEFT', 0, -18)
dropdown:SetWidth(300)
dropdown:SetHeight(10)
local label = Aux.gui.label(dropdown, 13)
label:SetPoint('BOTTOMLEFT', dropdown, 'TOPLEFT', -2, -4)
label:SetText('Min Rarity')
UIDropDownMenu_Initialize(dropdown, private.initialize_quality_dropdown)
UIDropDownMenu_Initialize(dropdown, m.initialize_quality_dropdown)
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, private.initialize_quality_dropdown)
UIDropDownMenu_Initialize(this, m.initialize_quality_dropdown)
end)
private.quality_dropdown = dropdown
end
do
local editbox = Aux.gui.editbox(AuxSearchFrameFilter)
editbox:SetPoint('TOPLEFT', private.quality_dropdown, 'BOTTOMLEFT', 0, -18)
editbox:SetPoint('TOPLEFT', m.quality_dropdown, 'BOTTOMLEFT', 0, -18)
editbox:SetWidth(145)
editbox:SetNumeric(true)
editbox:SetMaxLetters(2)
@@ -383,12 +383,12 @@ function Aux.search_frame.create_frames(private, public)
if IsShiftKeyDown() then
getglobal(this:GetParent():GetName()..'MaxLevel'):SetFocus()
else
private.last_page_editbox:SetFocus()
m.last_page_editbox:SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
this:ClearFocus()
public.execute()
m.execute()
end)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
@@ -397,20 +397,20 @@ function Aux.search_frame.create_frames(private, public)
end
do
local editbox = Aux.gui.editbox(AuxSearchFrameFilter)
editbox:SetPoint('TOPLEFT', private.first_page_editbox, 'TOPRIGHT', 10, 0)
editbox:SetPoint('TOPLEFT', m.first_page_editbox, 'TOPRIGHT', 10, 0)
editbox:SetWidth(145)
editbox:SetNumeric(true)
editbox:SetMaxLetters(2)
editbox:SetScript('OnTabPressed', function()
if IsShiftKeyDown() then
private.first_page_editbox:SetFocus()
m.first_page_editbox:SetFocus()
else
getglobal(this:GetParent():GetName()..'NameInputBox'):SetFocus()
end
end)
editbox:SetScript('OnEnterPressed', function()
this:ClearFocus()
public.execute()
m.execute()
end)
local label = Aux.gui.label(editbox, 13)
label:SetPoint('RIGHT', editbox, 'LEFT', -4, 0)
@@ -424,14 +424,14 @@ function Aux.search_frame.create_frames(private, public)
label:SetText('Usable')
end
local function add_modifier(...)
local current_filter_string = private.search_box:GetText()
local current_filter_string = m.search_box:GetText()
for i=1,arg.n do
if current_filter_string ~= '' and strsub(current_filter_string, -1) ~= '/' then
current_filter_string = current_filter_string..'/'
end
current_filter_string = current_filter_string..arg[i]
end
private.search_box:SetText(current_filter_string)
m.search_box:SetText(current_filter_string)
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
@@ -446,7 +446,7 @@ function Aux.search_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('LEFT', private.and_operator_button, 'RIGHT', 10, 0)
btn:SetPoint('LEFT', m.and_operator_button, 'RIGHT', 10, 0)
btn:SetWidth(50)
btn:SetHeight(19)
btn:SetText('or')
@@ -457,7 +457,7 @@ function Aux.search_frame.create_frames(private, public)
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('LEFT', private.or_operator_button, 'RIGHT', 10, 0)
btn:SetPoint('LEFT', m.or_operator_button, 'RIGHT', 10, 0)
btn:SetWidth(50)
btn:SetHeight(19)
btn:SetText('not')
@@ -469,105 +469,105 @@ function Aux.search_frame.create_frames(private, public)
private.modifier_buttons = {}
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.and_operator_button, 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['min-unit-bid'] = btn
btn:SetPoint('TOPLEFT', m.and_operator_button, 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-unit-bid'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-unit-bid'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['min-unit-buy'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-unit-bid'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-unit-buy'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-unit-buy'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['max-unit-bid'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-unit-buy'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-unit-bid'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-unit-bid'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['max-unit-buy'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-unit-bid'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-unit-buy'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-unit-buy'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['bid-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-unit-buy'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-profit'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['buy-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-profit'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['bid-vend-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-vend-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-vend-profit'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['buy-vend-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-vend-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-vend-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-vend-profit'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['bid-dis-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-vend-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['bid-dis-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-dis-profit'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['buy-dis-profit'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-dis-profit'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-dis-profit'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.and_operator_button, 'BOTTOMLEFT', 205, -10)
private.modifier_buttons['bid-pct'] = btn
btn:SetPoint('TOPLEFT', m.and_operator_button, 'BOTTOMLEFT', 205, -10)
m.modifier_buttons['bid-pct'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['bid-pct'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['buy-pct'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['bid-pct'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['buy-pct'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['buy-pct'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['item'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['buy-pct'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['item'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['item'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['tooltip'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['item'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['tooltip'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['tooltip'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['min-lvl'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['tooltip'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['min-lvl'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['min-lvl'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['max-lvl'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['min-lvl'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['max-lvl'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['max-lvl'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['rarity'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['max-lvl'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['rarity'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['rarity'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['left'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['rarity'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['left'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['left'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['utilizable'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['left'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['utilizable'] = btn
end
do
local btn = Aux.gui.button(AuxSearchFrameFilter, 16)
btn:SetPoint('TOPLEFT', private.modifier_buttons['utilizable'], 'BOTTOMLEFT', 0, -10)
private.modifier_buttons['discard'] = btn
btn:SetPoint('TOPLEFT', m.modifier_buttons['utilizable'], 'BOTTOMLEFT', 0, -10)
m.modifier_buttons['discard'] = btn
end
for modifier_name, btn in private.modifier_buttons do
for modifier_name, btn in m.modifier_buttons do
local modifier_name = modifier_name
local btn = btn
@@ -606,58 +606,58 @@ function Aux.search_frame.create_frames(private, public)
end
private.results_listing = Aux.auction_listing.CreateAuctionResultsTable(AuxSearchFrameResults, Aux.auction_listing.search_config)
private.results_listing:SetSort(1,2,3,4,5,6,7,8,9)
private.results_listing:Reset()
private.results_listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and private.results_listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and private.buyout_button:IsEnabled() then
private.buyout_button:Click()
elseif button == 'RightButton' and private.bid_button:IsEnabled() then
private.bid_button:Click()
m.results_listing:SetSort(1,2,3,4,5,6,7,8,9)
m.results_listing:Reset()
m.results_listing:SetHandler('OnCellClick', function(cell, button)
if IsAltKeyDown() and m.results_listing:GetSelection().record == cell.row.data.record then
if button == 'LeftButton' and m.buyout_button:IsEnabled() then
m.buyout_button:Click()
elseif button == 'RightButton' and m.bid_button:IsEnabled() then
m.bid_button:Click()
end
end
end)
private.results_listing:SetHandler('OnSelectionChanged', function(rt, datum)
m.results_listing:SetHandler('OnSelectionChanged', function(rt, datum)
if not datum then return end
private.find_auction(datum.record)
m.find_auction(datum.record)
end)
local handlers = {
OnClick = function(st, data, _, button)
if not data then return end
if button == 'LeftButton' and IsShiftKeyDown() then
private.search_box:SetText(data.search.filter_string)
m.search_box:SetText(data.search.filter_string)
elseif button == 'RightButton' and IsShiftKeyDown() then
private.add_filter(data.search.filter_string)
m.add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsAltKeyDown() then
private.popup_info.rename = data.search
m.popup_info.rename = data.search
StaticPopup_Show('AUX_SEARCH_SAVED_RENAME')
elseif button == 'RightButton' and IsAltKeyDown() then
-- unused
elseif button == 'LeftButton' and IsControlKeyDown() then
if st == private.favorite_searches_listing and data.index > 1 then
if st == m.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
private.update_search_listings()
m.update_search_listings()
end
elseif button == 'RightButton' and IsControlKeyDown() then
if st == private.favorite_searches_listing and data.index < getn(aux_favorite_searches) then
if st == m.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
private.update_search_listings()
m.update_search_listings()
end
elseif button == 'LeftButton' then
private.search_box:SetText(data.search.filter_string)
public.execute()
m.search_box:SetText(data.search.filter_string)
m.execute()
elseif button == 'RightButton' then
if st == private.recent_searches_listing then
if st == m.recent_searches_listing then
tinsert(aux_favorite_searches, 1, data.search)
elseif st == private.favorite_searches_listing then
elseif st == m.favorite_searches_listing then
tremove(aux_favorite_searches, data.index)
end
private.update_search_listings()
m.update_search_listings()
end
end,
OnEnter = function(st, data, self)
@@ -674,20 +674,20 @@ function Aux.search_frame.create_frames(private, public)
}
private.recent_searches_listing = Aux.listing.CreateScrollingTable(AuxSearchFrameSavedRecent)
private.recent_searches_listing:SetColInfo({{name='Recent Searches', width=1}})
private.recent_searches_listing:EnableSorting(false)
private.recent_searches_listing:DisableSelection(true)
private.recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
private.recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
private.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
m.recent_searches_listing:SetColInfo({{name='Recent Searches', width=1}})
m.recent_searches_listing:EnableSorting(false)
m.recent_searches_listing:DisableSelection(true)
m.recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
m.recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
m.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
Aux.gui.vertical_line(AuxSearchFrameSaved, 379)
private.favorite_searches_listing = Aux.listing.CreateScrollingTable(AuxSearchFrameSavedFavorite)
private.favorite_searches_listing:SetColInfo({{name='Favorite Searches', width=1}})
private.favorite_searches_listing:EnableSorting(false)
private.favorite_searches_listing:DisableSelection(true)
private.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
private.favorite_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
private.favorite_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
end
m.favorite_searches_listing:SetColInfo({{name='Favorite Searches', width=1}})
m.favorite_searches_listing:EnableSorting(false)
m.favorite_searches_listing:DisableSelection(true)
m.favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
m.favorite_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
m.favorite_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
end)
+8 -9
View File
@@ -1,5 +1,4 @@
local private, public = {}, {}
Aux.auction_listing = public
local m, private, public = Aux.module'auction_listing'
local RT_COUNT = 1
local HEAD_HEIGHT = 27
@@ -51,7 +50,7 @@ public.search_config = {
{
title = 'Item',
width = 0.35,
init = private.item_column_init,
init = m.item_column_init,
set = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
@@ -206,12 +205,12 @@ public.search_config = {
width = 0.08,
align = 'CENTER',
set = function(cell, record)
local pct, bidPct = private.record_percentage(record)
cell:SetText((pct or bidPct) and public.percentage_historical(pct or bidPct, not pct) or '---')
local pct, bidPct = m.record_percentage(record)
cell:SetText((pct or bidPct) and m.percentage_historical(pct or bidPct, not pct) or '---')
end,
cmp = function(record_a, record_b, desc)
local pct_a = private.record_percentage(record_a) or (desc and -Aux.huge or Aux.huge)
local pct_b = private.record_percentage(record_b) or (desc and -Aux.huge or Aux.huge)
local pct_a = m.record_percentage(record_a) or (desc and -Aux.huge or Aux.huge)
local pct_b = m.record_percentage(record_b) or (desc and -Aux.huge or Aux.huge)
return Aux.sort.compare(pct_a, pct_b, desc)
end,
},
@@ -221,7 +220,7 @@ public.auctions_config = {
{
title = 'Item',
width = 0.35,
init = private.item_column_init,
init = m.item_column_init,
set = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
@@ -368,7 +367,7 @@ public.bids_config = {
{
title = 'Item',
width = 0.35,
init = private.item_column_init,
init = m.item_column_init,
set = function(cell, record, _, _, _, indented)
cell.icon:SetTexture(record.texture)
if indented then
+3 -5
View File
@@ -1,6 +1,4 @@
local private, public = {}, {}
Aux.item_listing = public
local m, private, public = Aux.module'item_listing'
local ROW_HEIGHT = 38
@@ -53,7 +51,7 @@ function public.create(parent, on_click, on_enter, on_leave, selected)
local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', parent, 'FauxScrollFrameTemplate')
scroll_frame:SetScript('OnVerticalScroll', function(self, offset)
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() public.render(this.item_listing) end)
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() m.render(this.item_listing) end)
end)
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
@@ -117,5 +115,5 @@ end
function public.populate(item_listing, item_records)
item_listing.item_records = item_records
public.render(item_listing)
m.render(item_listing)
end
+1 -2
View File
@@ -1,5 +1,4 @@
local private, public = {}, {}
Aux.listing = public
local m, private, public = Aux.module'listing'
local ST_COUNT = 0
-1
View File
@@ -1,5 +1,4 @@
local m, private, public = Aux.module'completion'
Aux.completion = m
function public:complete()
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution