module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-09-23 09:07:56 +02:00
parent 1344ae0d23
commit 240589eef1
32 changed files with 525 additions and 499 deletions
+7 -7
View File
@@ -1,6 +1,6 @@
aux 'auctions_tab' local scan = aux.scan
auction_records = t
private.auction_records = t
function LOAD()
create_frames()
@@ -15,7 +15,7 @@ function CLOSE()
frame:Hide()
end
function update_listing()
function private.update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -29,7 +29,7 @@ function public.scan_auctions()
update_listing()
scan.start{
type = 'owner',
queries = {{blizzard_query = t}},
queries = {{ blizzard_query = t }},
on_page_loaded = function(page, total_pages)
status_bar:update_status(100 * (page - 1) / total_pages, 0)
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
@@ -49,7 +49,7 @@ function public.scan_auctions()
}
end
function test(record)
function private.test(record)
return function(index)
local auction_info = aux.info.auction(index, 'owner')
return auction_info and auction_info.search_signature == record.search_signature
@@ -62,7 +62,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -78,7 +78,7 @@ do
cancel_button:SetScript('OnClick', function()
if test(record)(index) and listing:ContainsRecord(record) then
cancel_auction(index, partial(listing.RemoveAuctionRecord, listing, record))
cancel_auction(index, papply(listing.RemoveAuctionRecord, listing, record))
end
end)
cancel_button:Enable()
@@ -86,7 +86,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
cancel_button:Disable()
end
+5 -5
View File
@@ -1,7 +1,7 @@
aux 'auctions_tab' local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -11,7 +11,7 @@ function create_frames()
frame.listing:SetPoint('BOTTOMLEFT', aux_frame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', aux_frame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
listing:SetSort(1,2,3,4,5,6,7,8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
@@ -25,7 +25,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -37,7 +37,7 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Cancel')
btn:Disable()
cancel_button = btn
private.cancel_button = btn
end
do
local btn = gui.button(frame)
+8 -8
View File
@@ -1,6 +1,6 @@
aux 'bids_tab' local scan = aux.scan
auction_records = t
private.auction_records = t
function LOAD()
create_frames()
@@ -15,7 +15,7 @@ function CLOSE()
frame:Hide()
end
function update_listing()
function private.update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -29,7 +29,7 @@ function public.scan_bids()
update_listing()
scan.start{
type = 'bidder',
queries = {{blizzard_query=t}},
queries = {{ blizzard_query=t }},
on_page_loaded = function(page, total_pages)
status_bar:update_status(100 * (page - 1) / total_pages, 0)
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
@@ -49,7 +49,7 @@ function public.scan_bids()
}
end
function test(record)
function private.test(record)
return function(index)
local auction_info = aux.info.auction(index, 'bidder')
return auction_info and auction_info.search_signature == record.search_signature
@@ -62,7 +62,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -85,7 +85,7 @@ do
place_bid('bidder', index, record.bid_price, record.bid_price < record.buyout_price and function()
aux.info.bid_update(record)
listing:SetDatabase()
end or partial(listing.RemoveAuctionRecord, listing, record))
end or papply(listing.RemoveAuctionRecord, listing, record))
end
end)
bid_button:Enable()
@@ -94,7 +94,7 @@ do
if record.buyout_price > 0 then
buyout_button:SetScript('OnClick', function()
if test(record)(index) and listing:ContainsRecord(record) then
place_bid('bidder', index, record.buyout_price, partial(listing.RemoveAuctionRecord, listing, record))
place_bid('bidder', index, record.buyout_price, papply(listing.RemoveAuctionRecord, listing, record))
end
end)
buyout_button:Enable()
@@ -103,7 +103,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+6 -6
View File
@@ -1,7 +1,7 @@
aux 'bids_tab' local gui, auction_listing = aux.gui, aux.auction_listing
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -11,7 +11,7 @@ function create_frames()
frame.listing:SetPoint('BOTTOMLEFT', aux_frame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', aux_frame.content, 'BOTTOMRIGHT', 0, 0)
listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
listing:SetSort(1,2,3,4,5,6,7,8)
listing:Reset()
listing:SetHandler('OnCellClick', function(cell, button)
@@ -29,7 +29,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -41,14 +41,14 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Bid')
btn:Disable()
bid_button = btn
private.bid_button = btn
end
do
local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText('Buyout')
btn:Disable()
buyout_button = btn
private.buyout_button = btn
end
do
local btn = gui.button(frame)
+23 -23
View File
@@ -20,19 +20,19 @@ do
end
end
function read_settings(item_key)
function private.read_settings(item_key)
item_key = item_key or selected_item.key
return data[item_key] and persistence.read(settings_schema, data[item_key]) or default_settings
end
function write_settings(settings, item_key)
function private.write_settings(settings, item_key)
item_key = item_key or selected_item.key
data[item_key] = persistence.write(settings_schema, settings)
end
local scan_id, inventory_records, existing_auctions = 0, t, t
function refresh_button_click()
function private.refresh_button_click()
aux.scan.abort(scan_id)
refresh_entries()
refresh = true
@@ -69,25 +69,25 @@ function USE_ITEM(item_info)
select_item(item_info.item_key)
end
function get_unit_start_price()
function private.get_unit_start_price()
local money_text = unit_start_price:GetText()
return aux.money.from_string(money_text) or 0
end
function set_unit_start_price(amount)
function private.set_unit_start_price(amount)
unit_start_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
end
function get_unit_buyout_price()
function private.get_unit_buyout_price()
local money_text = unit_buyout_price:GetText()
return aux.money.from_string(money_text) or 0
end
function set_unit_buyout_price(amount)
function private.set_unit_buyout_price(amount)
unit_buyout_price:SetText(aux.money.to_string(amount, true, nil, 3, nil, true))
end
function update_inventory_listing()
function private.update_inventory_listing()
if not ACTIVE then return end
item_listing.populate(inventory_listing, values(filter(copy(inventory_records), function(record)
local settings = read_settings(record.key)
@@ -95,7 +95,7 @@ function update_inventory_listing()
end)))
end
function update_auction_listing()
function private.update_auction_listing()
if not ACTIVE then return end
local auction_rows = t
if selected_item then
@@ -177,7 +177,7 @@ function public.select_item(item_key)
end
end
function price_update()
function private.price_update()
if selected_item then
local settings = read_settings()
@@ -195,7 +195,7 @@ function price_update()
end
end
function post_auctions()
function private.post_auctions()
if selected_item then
local unit_start_price = get_unit_start_price()
local unit_buyout_price = get_unit_buyout_price()
@@ -239,7 +239,7 @@ function post_auctions()
end
end
function validate_parameters()
function private.validate_parameters()
if not selected_item then
post_button:Disable()
return
@@ -259,7 +259,7 @@ function validate_parameters()
post_button:Enable()
end
function update_item_configuration()
function private.update_item_configuration()
if not selected_item then
refresh_button:Disable()
@@ -314,7 +314,7 @@ function update_item_configuration()
end
end
function undercut(record, stack_size, stack)
function private.undercut(record, stack_size, stack)
local start_price = round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
local buyout_price = round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
if not record.own then
@@ -324,7 +324,7 @@ function undercut(record, stack_size, stack)
return start_price / stack_size, buyout_price / stack_size
end
function quantity_update(max_count)
function private.quantity_update(max_count)
if selected_item then
local max_stack_count = selected_item.max_charges and selected_item.availability[stack_size_slider:GetValue()] or floor(selected_item.availability[0] / stack_size_slider:GetValue())
stack_count_slider:SetMinMaxValues(1, max_stack_count)
@@ -335,7 +335,7 @@ function quantity_update(max_count)
refresh = true
end
function unit_vendor_price(item_key)
function private.unit_vendor_price(item_key)
for slot in info.inventory do auto[slot] = true
local item_info = info.container_item(unpack(slot))
if item_info and item_info.item_key == item_key then
@@ -355,7 +355,7 @@ function unit_vendor_price(item_key)
end
end
function update_historical_value_button()
function private.update_historical_value_button()
if selected_item then
local historical_value = history.value(selected_item.key)
historical_value_button.amount = historical_value
@@ -363,7 +363,7 @@ function update_historical_value_button()
end
end
function set_item(item)
function private.set_item(item)
local settings = read_settings(item.key)
item.unit_vendor_price = unit_vendor_price(item.key)
@@ -398,7 +398,7 @@ function set_item(item)
refresh = true
end
function update_inventory_records()
function private.update_inventory_records()
local auctionable_map = tt
for slot in info.inventory do auto[slot] = true
for item_info in present(info.container_item(unpack(slot))) do
@@ -436,7 +436,7 @@ function update_inventory_records()
refresh = true
end
function refresh_entries()
function private.refresh_entries()
if selected_item then
local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id
local item_key = item_id .. ':' .. suffix_id
@@ -481,7 +481,7 @@ function refresh_entries()
end
end
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
existing_auctions[key] = existing_auctions[key] or t
local entry
for _, record in existing_auctions[key] do
@@ -497,7 +497,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
return entry
end
function on_update()
function private.on_update()
if refresh then
refresh = false
price_update()
@@ -509,7 +509,7 @@ function on_update()
validate_parameters()
end
function initialize_duration_dropdown()
function private.initialize_duration_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(duration_dropdown, this.value)
local settings = read_settings()
+26 -26
View File
@@ -1,7 +1,7 @@
aux 'post_tab' local gui, listing, item_listing, money, search_tab = aux.gui, aux.listing, aux.item_listing, aux.money, aux.search_tab
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -35,12 +35,12 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Show hidden items')
show_hidden_checkbox = checkbox
private.show_hidden_checkbox = checkbox
end
gui.horizontal_line(frame.inventory, -48)
inventory_listing = item_listing.create(
private.inventory_listing = item_listing.create(
frame.inventory,
function()
if arg1 == 'LeftButton' then
@@ -56,15 +56,15 @@ function create_frames()
end
)
auction_listing = listing.CreateScrollingTable(frame.auctions)
private.auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing:SetColInfo{
{name='Auctions', width=.12, align='CENTER'},
{name='Left', width=.1, align='CENTER'},
{name='Qty', width=.08, align='CENTER'},
{name='Bid/ea', width=.22, align='RIGHT'},
{name='Bid Pct', width=.13, align='CENTER'},
{name='Buy/ea', width=.22, align='RIGHT'},
{name='Buy Pct', width=.13, align='CENTER'}
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
{ name='Qty', width=.08, align='CENTER' },
{ name='Bid/ea', width=.22, align='RIGHT' },
{ name='Bid Pct', width=.13, align='CENTER' },
{ name='Buy/ea', width=.22, align='RIGHT' },
{ name='Buy Pct', width=.13, align='CENTER' },
}
auction_listing:EnableSorting(false)
auction_listing:DisableSelection(true)
@@ -81,7 +81,7 @@ function create_frames()
end)
do
status_bar = gui.status_bar(frame)
private.status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
@@ -93,17 +93,17 @@ function create_frames()
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Post')
btn:SetScript('OnClick', post_auctions)
post_button = btn
private.post_button = btn
end
do
local btn = gui.button(frame.parameters)
btn:SetPoint('TOPLEFT', post_button, 'TOPRIGHT', 5, 0)
btn:SetText('Refresh')
btn:SetScript('OnClick', refresh_button_click)
refresh_button = btn
private.refresh_button = btn
end
do
item = gui.item(frame.parameters)
private.item = gui.item(frame.parameters)
item:SetPoint('TOPLEFT', 10, -6)
item.button:SetScript('OnEnter', function()
if selected_item then
@@ -143,7 +143,7 @@ function create_frames()
slider.editbox:SetNumeric(true)
slider.editbox:SetMaxLetters(3)
slider.label:SetText('Stack Size')
stack_size_slider = slider
private.stack_size_slider = slider
end
do
local slider = gui.slider(frame.parameters)
@@ -166,7 +166,7 @@ function create_frames()
end)
slider.editbox:SetNumeric(true)
slider.label:SetText('Stack Count')
stack_count_slider = slider
private.stack_count_slider = slider
end
do
local dropdown = gui.dropdown(frame.parameters)
@@ -179,12 +179,12 @@ function create_frames()
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_duration_dropdown)
end)
duration_dropdown = dropdown
private.duration_dropdown = dropdown
end
do
local label = gui.label(frame.parameters, gui.font_size.medium)
label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0)
deposit = label
private.deposit = label
end
do
local checkbox = gui.checkbox(frame.parameters)
@@ -198,7 +198,7 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Hide this item')
hide_checkbox = checkbox
private.hide_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -231,9 +231,9 @@ function create_frames()
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
start_price_percentage = label
private.start_price_percentage = label
end
unit_start_price = editbox
private.unit_start_price = editbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -266,9 +266,9 @@ function create_frames()
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
buyout_price_percentage = label
private.buyout_price_percentage = label
end
unit_buyout_price = editbox
private.unit_buyout_price = editbox
end
do
local btn = gui.button(frame.parameters, 14)
@@ -285,6 +285,6 @@ function create_frames()
local label = gui.label(btn, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
label:SetText('Historical Value')
historical_value_button = btn
private.historical_value_button = btn
end
end
+5 -3
View File
@@ -19,7 +19,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = {
}
do
local function action()
_G.aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
aux_auto_buy_filter = _G[this:GetParent():GetName() .. 'EditBox']:GetText()
update_auto_buy_filter()
end
@@ -47,7 +47,9 @@ do
}
end
RESULTS, SAVED, FILTER = 1, 2, 3
private.RESULTS = 1
private.SAVED = 2
private.FILTER = 3
function LOAD()
create_frames()
@@ -113,7 +115,7 @@ function public.add_filter(filter_string)
search_box:SetText(old_filter_string .. filter_string)
end
function blizzard_page_index(str)
function private.blizzard_page_index(str)
if tonumber(str) then
return max(0, tonumber(str) - 1)
end
+23 -23
View File
@@ -1,11 +1,11 @@
aux 'search_tab' local filter_util = aux.filter_util
function valid_level(str)
function private.valid_level(str)
local level = tonumber(str)
return level and bounded(1, 60, level)
end
blizzard_query = setmetatable(t, {
private.blizzard_query = setmetatable(t, {
__index = function(_, key)
if key == 'name' then
return name_input:GetText()
@@ -58,7 +58,7 @@ blizzard_query = setmetatable(t, {
end,
})
function update_form()
function private.update_form()
if blizzard_query.class and GetAuctionItemSubClasses(blizzard_query.class) then
subclass_dropdown.button:Enable()
else
@@ -99,7 +99,7 @@ function update_form()
end
end
function get_filter_builder_query()
function private.get_filter_builder_query()
local filter_string
local function add(part)
@@ -143,7 +143,7 @@ function get_filter_builder_query()
return filter_string or ''
end
function set_form(filter)
function private.set_form(filter)
clear_form()
for _, component in filter.components do
if component[1] == 'blizzard' then
@@ -155,7 +155,7 @@ function set_form(filter)
update_filter_display()
end
function clear_form()
function private.clear_form()
blizzard_query.name = ''
name_input:ClearFocus()
blizzard_query.exact = false
@@ -174,14 +174,14 @@ function clear_form()
update_filter_display()
end
function import_filter_string()
function private.import_filter_string()
local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
if filter or print(error) then
set_form(filter)
end
end
function export_filter_string()
function private.export_filter_string()
search_box:SetText(get_filter_builder_query())
filter_parameter_input:ClearFocus()
end
@@ -230,14 +230,14 @@ function public.formatted_post_filter(components)
return '<html><body><p>' .. str .. '</p></body></html>'
end
function data_link(id, str)
function private.data_link(id, str)
return '|H' .. id .. '|h' .. str .. '|h'
end
post_filter = t
filter_builder_state = T('selected', 0)
private.post_filter = t
private.filter_builder_state = T('selected', 0)
function data_link_click()
function private.data_link_click()
local button = arg3
local index = tonumber(arg1)
if button == 'LeftButton' then
@@ -248,7 +248,7 @@ function data_link_click()
update_filter_display()
end
function remove_component(index)
function private.remove_component(index)
index = index or filter_builder_state.selected
if filter_builder_state.selected >= index then
filter_builder_state.selected = max(filter_builder_state.selected - 1, min(1, getn(post_filter)))
@@ -257,12 +257,12 @@ function remove_component(index)
tremove(post_filter, index)
end
function add_component(component)
function private.add_component(component)
filter_builder_state.selected = filter_builder_state.selected + 1
tinsert(post_filter, filter_builder_state.selected, component)
end
function add_post_filter()
function private.add_post_filter()
for str in present(filter_input:GetText()) do
for filter in present(filter_util.filters[str]) do
if filter.input_type ~= '' then
@@ -284,13 +284,13 @@ end
do
local text = ''
function update_filter_display()
function private.update_filter_display()
text = formatted_post_filter(post_filter)
filter_display:SetWidth(filter_display_size())
set_filter_display_offset()
filter_display:SetText(text)
end
function filter_display_size()
function private.filter_display_size()
local font, font_size = filter_display:GetFont()
filter_display.measure:SetFont(font, font_size)
local lines = 0
@@ -304,7 +304,7 @@ do
end
end
function set_filter_display_offset(x_offset, y_offset)
function private.set_filter_display_offset(x_offset, y_offset)
local scroll_frame = filter_display:GetParent()
x_offset, y_offset = x_offset or scroll_frame:GetHorizontalScroll(), y_offset or scroll_frame:GetVerticalScroll()
local width, height = filter_display_size()
@@ -316,7 +316,7 @@ function set_filter_display_offset(x_offset, y_offset)
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
end
function initialize_filter_dropdown()
function private.initialize_filter_dropdown()
for filter in temp-S('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity', 'left', 'utilizable', 'discard') do
UIDropDownMenu_AddButton(T(
'text', filter,
@@ -336,7 +336,7 @@ function initialize_filter_dropdown()
end
end
function initialize_class_dropdown()
function private.initialize_class_dropdown()
local function on_click()
if this.value ~= blizzard_query.class then
UIDropDownMenu_SetSelectedValue(class_dropdown, this.value)
@@ -353,7 +353,7 @@ function initialize_class_dropdown()
end
end
function initialize_subclass_dropdown()
function private.initialize_subclass_dropdown()
local function on_click()
if this.value ~= blizzard_query.subclass then
UIDropDownMenu_SetSelectedValue(subclass_dropdown, this.value)
@@ -371,7 +371,7 @@ function initialize_subclass_dropdown()
end
end
function initialize_slot_dropdown()
function private.initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
update_form()
@@ -386,7 +386,7 @@ function initialize_slot_dropdown()
end
end
function initialize_quality_dropdown()
function private.initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
update_form()
+58 -58
View File
@@ -2,8 +2,8 @@ aux 'search_tab' local gui, completion, listing, auction_listing, filter_util =
FILTER_SPACING = 28.5
function create_frames()
frame = CreateFrame('Frame', nil, aux_frame)
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux_frame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -49,7 +49,7 @@ function create_frames()
fake_icon_part:SetText('_')
end
settings_button = btn
private.settings_button = btn
end
do
local panel = CreateFrame('Frame', nil, frame)
@@ -59,14 +59,14 @@ function create_frames()
panel:SetPoint('RIGHT', 0, 0)
panel:SetHeight(42)
panel:Hide()
settings = panel
private.settings = panel
end
do
local panel = CreateFrame('Frame', nil, frame)
panel:SetPoint('LEFT', settings_button, 'RIGHT', 0, 0)
panel:SetPoint('RIGHT', 0, 1)
panel:SetHeight(40)
controls = panel
private.controls = panel
end
do
local function change()
@@ -93,7 +93,7 @@ function create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0)
label:SetText('Pages')
label:SetTextColor(color.text.enabled())
first_page_input = editbox
private.first_page_input = editbox
end
do
local editbox = gui.editbox(settings)
@@ -107,7 +107,7 @@ function create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0)
label:SetText('-')
label:SetTextColor(color.text.enabled())
last_page_input = editbox
private.last_page_input = editbox
end
end
do
@@ -118,9 +118,9 @@ function create_frames()
btn:SetText('Real Time Mode')
btn:SetScript('OnClick', function()
this:SetChecked(not this:GetChecked())
_G.this = first_page_input
this = first_page_input
first_page_input:GetScript('OnTextChanged')()
_G.this = last_page_input
this = last_page_input
last_page_input:GetScript('OnTextChanged')()
end)
public.real_time_button = btn
@@ -138,7 +138,7 @@ function create_frames()
StaticPopup_Show('AUX_SEARCH_AUTO_BUY')
end
end)
auto_buy_button = btn
private.auto_buy_button = btn
end
do
local btn = gui.checkbutton(settings)
@@ -149,7 +149,7 @@ function create_frames()
btn:SetScript('OnClick', function()
if this:GetChecked() then
this:SetChecked(false)
_G.aux_auto_buy_filter = nil
aux_auto_buy_filter = nil
this.prettified = nil
auto_buy_validator = nil
else
@@ -166,7 +166,7 @@ function create_frames()
btn:SetScript('OnLeave', function()
GameTooltip:Hide()
end)
auto_buy_filter_button = btn
private.auto_buy_filter_button = btn
end
do
local btn = gui.button(controls, 25)
@@ -175,7 +175,7 @@ function create_frames()
btn:SetHeight(25)
btn:SetText('<')
btn:SetScript('OnClick', previous_search)
previous_button = btn
private.previous_button = btn
end
do
local btn = gui.button(controls, 25)
@@ -184,7 +184,7 @@ function create_frames()
btn:SetHeight(25)
btn:SetText('>')
btn:SetScript('OnClick', next_search)
next_button = btn
private.next_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -199,7 +199,7 @@ function create_frames()
end
execute()
end)
start_button = btn
private.start_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -210,7 +210,7 @@ function create_frames()
btn:SetScript('OnClick', function()
aux.scan.abort(search_scan_id)
end)
stop_button = btn
private.stop_button = btn
end
do
local btn = gui.button(controls, gui.font_size.huge)
@@ -221,7 +221,7 @@ function create_frames()
btn:SetScript('OnClick', function()
execute(true)
end)
resume_button = btn
private.resume_button = btn
end
do
local editbox = gui.editbox(controls)
@@ -240,7 +240,7 @@ function create_frames()
this:HighlightText(0, 0)
end)
editbox.enter = execute
search_box = editbox
private.search_box = editbox
end
do
gui.horizontal_line(frame, -40)
@@ -252,7 +252,7 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Search Results')
btn:SetScript('OnClick', function() subtab = RESULTS end)
search_results_button = btn
private.search_results_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -261,7 +261,7 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Saved Searches')
btn:SetScript('OnClick', function() subtab = SAVED end)
saved_searches_button = btn
private.saved_searches_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -270,28 +270,28 @@ function create_frames()
btn:SetHeight(22)
btn:SetText('Filter Builder')
btn:SetScript('OnClick', function() subtab = FILTER end)
new_filter_button = btn
private.new_filter_button = btn
end
do
local frame = CreateFrame('Frame', nil, frame)
frame:SetWidth(265)
frame:SetHeight(25)
frame:SetPoint('TOPLEFT', aux_frame.content, 'BOTTOMLEFT', 0, -6)
status_bar_frame = frame
private.status_bar_frame = frame
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', status_bar_frame, 'TOPRIGHT', 5, 0)
btn:SetText('Bid')
btn:Disable()
bid_button = btn
private.bid_button = btn
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText('Buyout')
btn:Disable()
buyout_button = btn
private.buyout_button = btn
end
do
local btn = gui.button(frame.results)
@@ -340,7 +340,7 @@ function create_frames()
end
do
local editbox = gui.editbox(frame.filter)
editbox.complete_item = completion.complete(function() return _G.aux_auctionable_items end)
editbox.complete_item = completion.complete(function() return aux_auctionable_items end)
editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING)
editbox:SetWidth(260)
editbox.char = function()
@@ -359,11 +359,11 @@ function create_frames()
end
end)
editbox.change = update_form
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Name')
name_input = editbox
private.name_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -372,7 +372,7 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Exact')
exact_checkbox = checkbox
private.exact_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -386,7 +386,7 @@ function create_frames()
max_level_input:SetFocus()
end
end)
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
editbox.change = function()
local valid_level = valid_level(this:GetText())
if tostring(valid_level) ~= this:GetText() then
@@ -397,7 +397,7 @@ function create_frames()
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Level Range')
min_level_input = editbox
private.min_level_input = editbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -411,7 +411,7 @@ function create_frames()
name_input:SetFocus()
end
end)
editbox.enter = partial(editbox.ClearFocus, editbox)
editbox.enter = papply(editbox.ClearFocus, editbox)
editbox.change = function()
local valid_level = valid_level(this:GetText())
if tostring(valid_level) ~= this:GetText() then
@@ -422,7 +422,7 @@ function create_frames()
local label = gui.label(editbox, gui.font_size.medium)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText('-')
max_level_input = editbox
private.max_level_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -431,11 +431,11 @@ function create_frames()
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Usable')
usable_checkbox = checkbox
private.usable_checkbox = checkbox
end
do
local dropdown = gui.dropdown(frame.filter)
class_dropdown = dropdown
private.class_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', min_level_input, 'BOTTOMLEFT', 0, 5 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -448,7 +448,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
subclass_dropdown = dropdown
private.subclass_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', class_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -461,7 +461,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
slot_dropdown = dropdown
private.slot_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', subclass_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -474,7 +474,7 @@ function create_frames()
end
do
local dropdown = gui.dropdown(frame.filter)
quality_dropdown = dropdown
private.quality_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', slot_dropdown, 'BOTTOMLEFT', 0, 10 - FILTER_SPACING)
dropdown:SetWidth(300)
local label = gui.label(dropdown, gui.font_size.small)
@@ -498,7 +498,7 @@ function create_frames()
local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText('Post Filter')
filter_dropdown = dropdown
private.filter_dropdown = dropdown
end
do
local input = gui.editbox(frame.filter)
@@ -525,7 +525,7 @@ function create_frames()
add_post_filter()
end
end
filter_input = input
private.filter_input = input
end
do
local input = gui.editbox(frame.filter)
@@ -537,7 +537,7 @@ function create_frames()
input.char = function() this:complete() end
input.enter = add_post_filter
input:Hide()
filter_parameter_input = input
private.filter_parameter_input = input
end
do
local scroll_frame = CreateFrame('ScrollFrame', nil, frame.filter)
@@ -578,14 +578,14 @@ function create_frames()
scroll_child:SetWidth(1)
scroll_child:SetHeight(1)
scroll_child:SetScript('OnHyperlinkClick', data_link_click)
-- scroll_child:SetHyperlinkFormat("format")
-- scroll_child:SetHyperlinkFormat("format") TODO
scroll_child.measure = scroll_child:CreateFontString()
filter_display = scroll_child
private.filter_display = scroll_child
end
status_bars = t
tables = t
for _=1,5 do
private.status_bars = t
private.tables = t
for _ = 1, 5 do
local status_bar = gui.status_bar(frame)
status_bar:SetAllPoints(status_bar_frame)
status_bar:Hide()
@@ -618,16 +618,16 @@ function create_frames()
add_filter(data.search.filter_string)
elseif button == 'LeftButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index > 1 then
local temp = _G.aux_favorite_searches[data.index - 1]
_G.aux_favorite_searches[data.index - 1] = data.search
_G.aux_favorite_searches[data.index] = temp
local temp = aux_favorite_searches[data.index - 1]
aux_favorite_searches[data.index - 1] = data.search
aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'RightButton' and IsControlKeyDown() then
if st == favorite_searches_listing and data.index < getn(_G.aux_favorite_searches) then
local temp = _G.aux_favorite_searches[data.index + 1]
_G.aux_favorite_searches[data.index + 1] = data.search
_G.aux_favorite_searches[data.index] = temp
if st == favorite_searches_listing and data.index < getn(aux_favorite_searches) then
local temp = aux_favorite_searches[data.index + 1]
aux_favorite_searches[data.index + 1] = data.search
aux_favorite_searches[data.index] = temp
update_search_listings()
end
elseif button == 'LeftButton' then
@@ -635,9 +635,9 @@ function create_frames()
execute()
elseif button == 'RightButton' then
if st == recent_searches_listing then
tinsert(_G.aux_favorite_searches, 1, data.search)
tinsert(aux_favorite_searches, 1, data.search)
elseif st == favorite_searches_listing then
tremove(_G.aux_favorite_searches, data.index)
tremove(aux_favorite_searches, data.index)
end
update_search_listings()
end
@@ -654,16 +654,16 @@ function create_frames()
end
}
recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{ name='Recent Searches', width=1 }}
recent_searches_listing:EnableSorting(false)
recent_searches_listing:DisableSelection(true)
recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}}
private.favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
favorite_searches_listing:SetColInfo{{ name='Favorite Searches', width=1 }}
favorite_searches_listing:EnableSorting(false)
favorite_searches_listing:DisableSelection(true)
favorite_searches_listing:SetHandler('OnClick', handlers.OnClick)
+21 -21
View File
@@ -1,6 +1,6 @@
aux 'search_tab' local info, scan = aux.info, aux.scan
_G.aux_auto_buy_filter = ''
aux_auto_buy_filter = ''
do
local id = 0
@@ -19,7 +19,7 @@ do
function private.current_search.get() return searches[search_index] end
function update_search(index)
function private.update_search(index)
searches[search_index].status_bar:Hide()
searches[search_index].table:Hide()
searches[search_index].table:SetSelectedRecord()
@@ -46,7 +46,7 @@ do
update_continuation()
end
function new_search(filter_string)
function private.new_search(filter_string)
while getn(searches) > search_index do
tremove(searches)
end
@@ -71,26 +71,26 @@ do
update_search(getn(searches))
end
function previous_search()
function private.previous_search()
search_box:ClearFocus()
update_search(search_index - 1)
subtab = RESULTS
end
function next_search()
function private.next_search()
search_box:ClearFocus()
update_search(search_index + 1)
subtab = RESULTS
end
end
function close_settings()
function private.close_settings()
if settings_button.open then
settings_button:Click()
end
end
function update_continuation()
function private.update_continuation()
if current_search.continuation then
resume_button:Show()
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
@@ -100,7 +100,7 @@ function update_continuation()
end
end
function discard_continuation()
function private.discard_continuation()
scan.abort(search_scan_id)
current_search.continuation = nil
update_continuation()
@@ -116,9 +116,9 @@ function update_start_stop()
end
end
function update_auto_buy_filter()
if _G.aux_auto_buy_filter ~= '' then
local queries, error = aux.filter_util.queries(_G.aux_auto_buy_filter)
function private.update_auto_buy_filter()
if aux_auto_buy_filter ~= '' then
local queries, error = aux.filter_util.queries(aux_auto_buy_filter)
if queries then
if getn(queries) > 1 then
print 'Error: The automatic buyout filter does not support multi-queries'
@@ -134,10 +134,10 @@ function update_auto_buy_filter()
print('Invalid auto buy filter:', error)
end
end
_G.aux_auto_buy_filter = ''
aux_auto_buy_filter = ''
end
function start_real_time_scan(query, search, continuation)
function private.start_real_time_scan(query, search, continuation)
local ignore_page
if not search then
@@ -167,7 +167,7 @@ function start_real_time_scan(query, search, continuation)
if not ignore_page then
if search.auto_buy then
ctrl.suspend()
place_bid('list', auction_record.index, auction_record.buyout_price, partial(ctrl.resume, true))
place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true))
thread(when, later(GetTime(), 10), ctrl.resume, false)
else
tinsert(new_records, auction_record)
@@ -211,7 +211,7 @@ function start_real_time_scan(query, search, continuation)
}
end
function start_search(queries, continuation)
function private.start_search(queries, continuation)
local current_query, current_page, total_queries, start_query, start_page
local search = current_search
@@ -260,7 +260,7 @@ function start_search(queries, continuation)
on_auction = function(auction_record, ctrl)
if search.auto_buy then
ctrl.suspend()
place_bid('list', auction_record.index, auction_record.buyout_price, partial(ctrl.resume, true))
place_bid('list', auction_record.index, auction_record.buyout_price, papply(ctrl.resume, true))
thread(when, later(GetTime(), 10), ctrl.resume, false)
elseif getn(search.records) < 1000 then
tinsert(search.records, auction_record)
@@ -368,7 +368,7 @@ function public.execute(resume, real_time)
end
end
function test(record)
function private.test(record)
return function(index)
local auction_info = info.auction(index)
return auction_info and auction_info.search_signature == record.search_signature
@@ -381,7 +381,7 @@ do
local state = IDLE
local found_index
function find_auction(record)
function private.find_auction(record)
local search = current_search
if not search.table:ContainsRecord(record) or is_player(record.owner) then
@@ -414,7 +414,7 @@ do
place_bid('list', index, record.bid_price, record.bid_price < record.buyout_price and function()
info.bid_update(record)
search.table:SetDatabase()
end or partial(search.table.RemoveAuctionRecord, search.table, record))
end or papply(search.table.RemoveAuctionRecord, search.table, record))
end
end)
bid_button:Enable()
@@ -423,7 +423,7 @@ do
if record.buyout_price > 0 then
buyout_button:SetScript('OnClick', function()
if test(record)(index) and search.table:ContainsRecord(record) then
place_bid('list', index, record.buyout_price, partial(search.table.RemoveAuctionRecord, search.table, record))
place_bid('list', index, record.buyout_price, papply(search.table.RemoveAuctionRecord, search.table, record))
end
end)
buyout_button:Enable()
@@ -432,7 +432,7 @@ do
)
end
function on_update()
function private.on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+10 -10
View File
@@ -1,14 +1,14 @@
aux 'search_tab'
_G.aux_favorite_searches = t
_G.aux_recent_searches = t
aux_favorite_searches = t
aux_recent_searches = t
function update_search_listings()
function private.update_search_listings()
local favorite_search_rows = t
for i, favorite_search in _G.aux_favorite_searches do
for i, favorite_search in aux_favorite_searches do
local name = strsub(favorite_search.prettified, 1, 250)
tinsert(favorite_search_rows, {
cols = {{value=name}},
cols = {{ value=name }},
search = favorite_search,
index = i,
})
@@ -16,7 +16,7 @@ function update_search_listings()
favorite_searches_listing:SetData(favorite_search_rows)
local recent_search_rows = t
for i, recent_search in _G.aux_recent_searches do
for i, recent_search in aux_recent_searches do
local name = strsub(recent_search.prettified, 1, 250)
tinsert(recent_search_rows, {
cols = {{ value=name }},
@@ -27,13 +27,13 @@ function update_search_listings()
recent_searches_listing:SetData(recent_search_rows)
end
function new_recent_search(filter_string, prettified)
tinsert(_G.aux_recent_searches, 1, {
function private.new_recent_search(filter_string, prettified)
tinsert(aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,
})
while getn(_G.aux_recent_searches) > 50 do
tremove(_G.aux_recent_searches)
while getn(aux_recent_searches) > 50 do
tremove(aux_recent_searches)
end
update_search_listings()
end