module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-10-14 01:55:38 +02:00
parent 2660b44861
commit cc7139c0e2
30 changed files with 326 additions and 343 deletions
+5 -5
View File
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
TAB 'Auctions'
private.auction_records = t
auction_records = t
function OPEN()
frame:Show()
@@ -20,7 +20,7 @@ function CLOSE()
frame:Hide()
end
function private.update_listing()
function update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -54,7 +54,7 @@ function public.scan_auctions()
}
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index, 'owner')
return auction_info and auction_info.search_signature == record.search_signature
@@ -67,7 +67,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -91,7 +91,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
cancel_button:Disable()
end
+4 -4
View File
@@ -3,7 +3,7 @@ module 'aux.tabs.auctions'
local gui = require 'aux.gui'
local auction_listing = require 'aux.gui.auction_listing'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.auctions_config)
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)
@@ -27,7 +27,7 @@ listing:SetHandler('OnSelectionChanged', function(rt, datum)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -39,7 +39,7 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText'Cancel'
btn:Disable()
private.cancel_button = btn
cancel_button = btn
end
do
local btn = gui.button(frame)
+5 -5
View File
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
TAB 'Bids'
private.auction_records = t
auction_records = t
function OPEN()
frame:Show()
@@ -20,7 +20,7 @@ function CLOSE()
frame:Hide()
end
function private.update_listing()
function update_listing()
if not ACTIVE then return end
listing:SetDatabase(auction_records)
end
@@ -54,7 +54,7 @@ function public.scan_bids()
}
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index, 'bidder')
return auction_info and auction_info.search_signature == record.search_signature
@@ -67,7 +67,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
if not listing:ContainsRecord(record) then return end
scan.abort(scan_id)
@@ -108,7 +108,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+5 -5
View File
@@ -3,7 +3,7 @@ module 'aux.tabs.bids'
local gui = require 'aux.gui'
local auction_listing = require 'aux.gui.auction_listing'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
private.listing = auction_listing.CreateAuctionResultsTable(frame.listing, auction_listing.bids_config)
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)
@@ -31,7 +31,7 @@ listing:SetHandler('OnSelectionChanged', function(rt, datum)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -43,14 +43,14 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText'Bid'
btn:Disable()
private.bid_button = btn
bid_button = btn
end
do
local btn = gui.button(frame)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText'Buyout'
btn:Disable()
private.buyout_button = btn
buyout_button = btn
end
do
local btn = gui.button(frame)
+29 -29
View File
@@ -19,13 +19,13 @@ TAB 'Post'
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'}}
function private.default_settings.get()
function get_default_settings()
return T('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
end
do
local data
function private.data.get()
function get_data()
if not data then
local dataset = persistence.dataset
data = dataset.post or t
@@ -35,19 +35,19 @@ do
end
end
function private.read_settings(item_key)
function 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 private.write_settings(settings, item_key)
function 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 private.refresh_button_click()
function refresh_button_click()
scan.abort(scan_id)
refresh_entries()
refresh = true
@@ -55,14 +55,14 @@ end
do
local item
function private.selected_item.get() return item end
function private.selected_item.set(v) item = v end
function get_selected_item() return item end
function set_selected_item(v) item = v end
end
do
local c = 0
function private.refresh.get() return c end
function private.refresh.set(v) c = v end
function get_refresh() return c end
function set_refresh(v) c = v end
end
function OPEN()
@@ -80,25 +80,25 @@ function USE_ITEM(item_info)
select_item(item_info.item_key)
end
function private.get_unit_start_price()
function get_unit_start_price()
local money_text = unit_start_price:GetText()
return money.from_string(money_text) or 0
end
function private.set_unit_start_price(amount)
function set_unit_start_price(amount)
unit_start_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
end
function private.get_unit_buyout_price()
function get_unit_buyout_price()
local money_text = unit_buyout_price:GetText()
return money.from_string(money_text) or 0
end
function private.set_unit_buyout_price(amount)
function set_unit_buyout_price(amount)
unit_buyout_price:SetText(money.to_string(amount, true, nil, 3, nil, true))
end
function private.update_inventory_listing()
function 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)
@@ -106,7 +106,7 @@ function private.update_inventory_listing()
end)))
end
function private.update_auction_listing()
function update_auction_listing()
if not ACTIVE then return end
local auction_rows = t
if selected_item then
@@ -188,7 +188,7 @@ function public.select_item(item_key)
end
end
function private.price_update()
function price_update()
if selected_item then
local settings = read_settings()
@@ -206,7 +206,7 @@ function private.price_update()
end
end
function private.post_auctions()
function post_auctions()
if selected_item then
local unit_start_price = get_unit_start_price()
local unit_buyout_price = get_unit_buyout_price()
@@ -250,7 +250,7 @@ function private.post_auctions()
end
end
function private.validate_parameters()
function validate_parameters()
if not selected_item then
post_button:Disable()
return
@@ -270,7 +270,7 @@ function private.validate_parameters()
post_button:Enable()
end
function private.update_item_configuration()
function update_item_configuration()
if not selected_item then
refresh_button:Disable()
@@ -325,7 +325,7 @@ function private.update_item_configuration()
end
end
function private.undercut(record, stack_size, stack)
function 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
@@ -335,7 +335,7 @@ function private.undercut(record, stack_size, stack)
return start_price / stack_size, buyout_price / stack_size
end
function private.quantity_update(max_count)
function 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)
@@ -346,7 +346,7 @@ function private.quantity_update(max_count)
refresh = true
end
function private.unit_vendor_price(item_key)
function 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
@@ -366,7 +366,7 @@ function private.unit_vendor_price(item_key)
end
end
function private.update_historical_value_button()
function update_historical_value_button()
if selected_item then
local historical_value = history.value(selected_item.key)
historical_value_button.amount = historical_value
@@ -374,7 +374,7 @@ function private.update_historical_value_button()
end
end
function private.set_item(item)
function set_item(item)
local settings = read_settings(item.key)
item.unit_vendor_price = unit_vendor_price(item.key)
@@ -409,7 +409,7 @@ function private.set_item(item)
refresh = true
end
function private.update_inventory_records()
function 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
@@ -447,7 +447,7 @@ function private.update_inventory_records()
refresh = true
end
function private.refresh_entries()
function 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
@@ -492,7 +492,7 @@ function private.refresh_entries()
end
end
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
function 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
@@ -508,7 +508,7 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
return entry
end
function private.on_update()
function on_update()
if refresh then
refresh = false
price_update()
@@ -520,7 +520,7 @@ function private.on_update()
validate_parameters()
end
function private.initialize_duration_dropdown()
function initialize_duration_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(duration_dropdown, this.value)
local settings = read_settings()
+18 -18
View File
@@ -7,7 +7,7 @@ local listing = require 'aux.gui.listing'
local item_listing = require 'aux.gui.item_listing'
local search_tab = require 'aux.tabs.search'
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -41,12 +41,12 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Show hidden items')
private.show_hidden_checkbox = checkbox
show_hidden_checkbox = checkbox
end
gui.horizontal_line(frame.inventory, -48)
private.inventory_listing = item_listing.create(
inventory_listing = item_listing.create(
frame.inventory,
function()
if arg1 == 'LeftButton' then
@@ -62,7 +62,7 @@ private.inventory_listing = item_listing.create(
end
)
private.auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing = listing.CreateScrollingTable(frame.auctions)
auction_listing:SetColInfo{
{ name='Auctions', width=.12, align='CENTER' },
{ name='Left', width=.1, align='CENTER' },
@@ -87,7 +87,7 @@ auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
end)
do
private.status_bar = gui.status_bar(frame)
status_bar = gui.status_bar(frame)
status_bar:SetWidth(265)
status_bar:SetHeight(25)
status_bar:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
@@ -99,17 +99,17 @@ do
btn:SetPoint('TOPLEFT', status_bar, 'TOPRIGHT', 5, 0)
btn:SetText('Post')
btn:SetScript('OnClick', post_auctions)
private.post_button = btn
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)
private.refresh_button = btn
refresh_button = btn
end
do
private.item = gui.item(frame.parameters)
item = gui.item(frame.parameters)
item:SetPoint('TOPLEFT', 10, -6)
item.button:SetScript('OnEnter', function()
if selected_item then
@@ -149,7 +149,7 @@ do
slider.editbox:SetNumeric(true)
slider.editbox:SetMaxLetters(3)
slider.label:SetText('Stack Size')
private.stack_size_slider = slider
stack_size_slider = slider
end
do
local slider = gui.slider(frame.parameters)
@@ -172,7 +172,7 @@ do
end)
slider.editbox:SetNumeric(true)
slider.label:SetText('Stack Count')
private.stack_count_slider = slider
stack_count_slider = slider
end
do
local dropdown = gui.dropdown(frame.parameters)
@@ -185,12 +185,12 @@ do
dropdown:SetScript('OnShow', function()
UIDropDownMenu_Initialize(this, initialize_duration_dropdown)
end)
private.duration_dropdown = dropdown
duration_dropdown = dropdown
end
do
local label = gui.label(frame.parameters, gui.font_size.medium)
label:SetPoint('LEFT', duration_dropdown, 'RIGHT', 25, 0)
private.deposit = label
deposit = label
end
do
local checkbox = gui.checkbox(frame.parameters)
@@ -204,7 +204,7 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('LEFT', checkbox, 'RIGHT', 4, 1)
label:SetText('Hide this item')
private.hide_checkbox = checkbox
hide_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -237,9 +237,9 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
private.start_price_percentage = label
start_price_percentage = label
end
private.unit_start_price = editbox
unit_start_price = editbox
end
do
local editbox = gui.editbox(frame.parameters)
@@ -272,9 +272,9 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 8, 0)
label:SetWidth(50)
label:SetJustifyH('CENTER')
private.buyout_price_percentage = label
buyout_price_percentage = label
end
private.unit_buyout_price = editbox
unit_buyout_price = editbox
end
do
local btn = gui.button(frame.parameters, 14)
@@ -291,5 +291,5 @@ do
local label = gui.label(btn, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', btn, 'TOPLEFT', -2, 1)
label:SetText('Historical Value')
private.historical_value_button = btn
historical_value_button = btn
end
+6 -16
View File
@@ -12,20 +12,10 @@ StaticPopupDialogs.AUX_SEARCH_TABLE_FULL = {
timeout = 0,
hideOnEscape = 1,
}
--StaticPopupDialogs.AUX_SEARCH_AUTO_BUY = {
-- text = 'Are you sure you want to activate automatic buyout?',
-- button1 = 'Yes',
-- button2 = 'No',
-- OnAccept = function()
-- auto_buy_button:SetChecked(true)
-- end,
-- timeout = 0,
-- hideOnEscape = 1,
--}
private.RESULTS = 1
private.SAVED = 2
private.FILTER = 3
RESULTS = 1
SAVED = 2
FILTER = 3
function LOAD()
-- aux_search_tab_frame.create()
@@ -52,7 +42,7 @@ function USE_ITEM(item_info)
execute(nil, false)
end
function private.subtab.set(tab)
function set_subtab(tab)
search_results_button:UnlockHighlight()
saved_searches_button:UnlockHighlight()
new_filter_button:UnlockHighlight()
@@ -76,7 +66,7 @@ function public.set_filter(filter_string)
search_box:SetText(filter_string)
end
function private.add_filter(filter_string)
function add_filter(filter_string)
local old_filter_string = search_box:GetText()
old_filter_string = trim(old_filter_string)
@@ -87,7 +77,7 @@ function private.add_filter(filter_string)
search_box:SetText(old_filter_string .. filter_string)
end
function private.blizzard_page_index(str)
function blizzard_page_index(str)
if tonumber(str) then
return max(0, tonumber(str) - 1)
end
+24 -24
View File
@@ -5,12 +5,12 @@ local money = require 'aux.util.money'
local cache = require 'aux.core.cache'
local filter_util = require 'aux.util.filter'
function private.valid_level(str)
function valid_level(str)
local level = tonumber(str)
return level and bounded(1, 60, level)
end
private.blizzard_query = setmetatable(t, {
blizzard_query = setmetatable(t, {
__index = function(_, key)
if key == 'name' then
return name_input:GetText()
@@ -63,7 +63,7 @@ private.blizzard_query = setmetatable(t, {
end,
})
function private.update_form()
function update_form()
if blizzard_query.class and GetAuctionItemSubClasses(blizzard_query.class) then
subclass_dropdown.button:Enable()
else
@@ -105,7 +105,7 @@ function private.update_form()
end
end
function private.get_filter_builder_query()
function get_filter_builder_query()
local filter_string
local function add(part)
@@ -149,7 +149,7 @@ function private.get_filter_builder_query()
return filter_string or ''
end
function private.set_form(filter)
function set_form(filter)
clear_form()
for _, component in filter.components do
if component[1] == 'blizzard' then
@@ -161,7 +161,7 @@ function private.set_form(filter)
update_filter_display()
end
function private.clear_form()
function clear_form()
blizzard_query.name = ''
name_input:ClearFocus()
blizzard_query.exact = false
@@ -180,19 +180,19 @@ function private.clear_form()
update_filter_display()
end
function private.import_filter_string()
function 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 private.export_filter_string()
function export_filter_string()
search_box:SetText(get_filter_builder_query())
filter_parameter_input:ClearFocus()
end
function private.formatted_post_filter(components)
function formatted_post_filter(components)
local no_line_break
local stack = tt
local str = ''
@@ -236,14 +236,14 @@ function private.formatted_post_filter(components)
return '<html><body><p>' .. str .. '</p></body></html>'
end
function private.data_link(id, str)
function data_link(id, str)
return '|H' .. id .. '|h' .. str .. '|h'
end
private.post_filter = t
private.filter_builder_state = T('selected', 0)
post_filter = t
filter_builder_state = T('selected', 0)
function private.data_link_click()
function data_link_click()
local button = arg3
local index = tonumber(arg1)
if button == 'LeftButton' then
@@ -254,7 +254,7 @@ function private.data_link_click()
update_filter_display()
end
function private.remove_component(index)
function 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)))
@@ -263,12 +263,12 @@ function private.remove_component(index)
tremove(post_filter, index)
end
function private.add_component(component)
function add_component(component)
filter_builder_state.selected = filter_builder_state.selected + 1
tinsert(post_filter, filter_builder_state.selected, component)
end
function private.add_post_filter()
function 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
@@ -290,13 +290,13 @@ end
do
local text = ''
function private.update_filter_display()
function 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 private.filter_display_size()
function filter_display_size()
local font, font_size = filter_display:GetFont()
filter_display.measure:SetFont(font, font_size)
local lines = 0
@@ -310,7 +310,7 @@ do
end
end
function private.set_filter_display_offset(x_offset, y_offset)
function 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()
@@ -322,7 +322,7 @@ function private.set_filter_display_offset(x_offset, y_offset)
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
end
function private.initialize_filter_dropdown()
function 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,
@@ -342,7 +342,7 @@ function private.initialize_filter_dropdown()
end
end
function private.initialize_class_dropdown()
function initialize_class_dropdown()
local function on_click()
if this.value ~= blizzard_query.class then
UIDropDownMenu_SetSelectedValue(class_dropdown, this.value)
@@ -359,7 +359,7 @@ function private.initialize_class_dropdown()
end
end
function private.initialize_subclass_dropdown()
function initialize_subclass_dropdown()
local function on_click()
if this.value ~= blizzard_query.subclass then
UIDropDownMenu_SetSelectedValue(subclass_dropdown, this.value)
@@ -377,7 +377,7 @@ function private.initialize_subclass_dropdown()
end
end
function private.initialize_slot_dropdown()
function initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
update_form()
@@ -392,7 +392,7 @@ function private.initialize_slot_dropdown()
end
end
function private.initialize_quality_dropdown()
function initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
update_form()
+35 -35
View File
@@ -9,7 +9,7 @@ local auction_listing = require 'aux.gui.auction_listing'
local FILTER_SPACING = 28.5
private.frame = CreateFrame('Frame', nil, AuxFrame)
frame = CreateFrame('Frame', nil, AuxFrame)
frame:SetAllPoints()
frame:SetScript('OnUpdate', on_update)
frame:Hide()
@@ -42,7 +42,7 @@ do
btn:SetHeight(25)
btn:SetText'<'
btn:SetScript('OnClick', previous_search)
private.previous_button = btn
previous_button = btn
end
do
local btn = gui.button(frame, 25)
@@ -51,7 +51,7 @@ do
btn:SetHeight(25)
btn:SetText'>'
btn:SetScript('OnClick', next_search)
private.next_button = btn
next_button = btn
end
do
local btn = gui.button(frame, gui.font_size.small)
@@ -61,7 +61,7 @@ do
btn:SetScript('OnClick', function()
update_real_time(true)
end)
private.range_button = btn
range_button = btn
end
do
local btn = gui.button(frame, gui.font_size.small)
@@ -72,7 +72,7 @@ do
btn:SetScript('OnClick', function()
update_real_time(false)
end)
private.real_time_button = btn
real_time_button = btn
end
do
local function change()
@@ -96,7 +96,7 @@ do
label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0)
label:SetTextColor(color.label.enabled())
label:SetText'-'
private.first_page_input = editbox
first_page_input = editbox
end
do
local editbox = gui.editbox(range_button)
@@ -108,7 +108,7 @@ do
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
editbox.enter = execute
editbox.change = change
private.last_page_input = editbox
last_page_input = editbox
end
end
do
@@ -122,7 +122,7 @@ do
end
execute()
end)
private.start_button = btn
start_button = btn
end
do
local btn = gui.button(frame)
@@ -131,7 +131,7 @@ do
btn:SetScript('OnClick', function()
scan.abort(search_scan_id)
end)
private.stop_button = btn
stop_button = btn
end
do
local btn = gui.button(frame)
@@ -141,7 +141,7 @@ do
btn:SetScript('OnClick', function()
execute(true)
end)
private.resume_button = btn
resume_button = btn
end
do
local editbox = gui.editbox(frame)
@@ -159,7 +159,7 @@ do
this:HighlightText(0, 0)
end)
editbox.enter = execute
private.search_box = editbox
search_box = editbox
end
do
gui.horizontal_line(frame, -40)
@@ -171,7 +171,7 @@ do
btn:SetHeight(22)
btn:SetText'Search Results'
btn:SetScript('OnClick', function() subtab = RESULTS end)
private.search_results_button = btn
search_results_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -180,7 +180,7 @@ do
btn:SetHeight(22)
btn:SetText'Saved Searches'
btn:SetScript('OnClick', function() subtab = SAVED end)
private.saved_searches_button = btn
saved_searches_button = btn
end
do
local btn = gui.button(frame, gui.font_size.large)
@@ -189,28 +189,28 @@ do
btn:SetHeight(22)
btn:SetText'Filter Builder'
btn:SetScript('OnClick', function() subtab = FILTER end)
private.new_filter_button = btn
new_filter_button = btn
end
do
local frame = CreateFrame('Frame', nil, frame)
frame:SetWidth(265)
frame:SetHeight(25)
frame:SetPoint('TOPLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, -6)
private.status_bar_frame = frame
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()
private.bid_button = btn
bid_button = btn
end
do
local btn = gui.button(frame.results)
btn:SetPoint('TOPLEFT', bid_button, 'TOPRIGHT', 5, 0)
btn:SetText'Buyout'
btn:Disable()
private.buyout_button = btn
buyout_button = btn
end
do
local btn = gui.button(frame.results)
@@ -281,7 +281,7 @@ do
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText'Name'
private.name_input = editbox
name_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -290,7 +290,7 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText'Exact'
private.exact_checkbox = checkbox
exact_checkbox = checkbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -316,7 +316,7 @@ do
local label = gui.label(editbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText'Level Range'
private.min_level_input = editbox
min_level_input = editbox
end
do
local editbox = gui.editbox(frame.filter)
@@ -342,7 +342,7 @@ do
local label = gui.label(editbox, gui.font_size.medium)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText'-'
private.max_level_input = editbox
max_level_input = editbox
end
do
local checkbox = gui.checkbox(frame.filter)
@@ -351,11 +351,11 @@ do
local label = gui.label(checkbox, gui.font_size.small)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText'Usable'
private.usable_checkbox = checkbox
usable_checkbox = checkbox
end
do
local dropdown = gui.dropdown(frame.filter)
private.class_dropdown = dropdown
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)
@@ -368,7 +368,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.subclass_dropdown = dropdown
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)
@@ -381,7 +381,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.slot_dropdown = dropdown
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)
@@ -394,7 +394,7 @@ do
end
do
local dropdown = gui.dropdown(frame.filter)
private.quality_dropdown = dropdown
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)
@@ -418,7 +418,7 @@ do
local label = gui.label(dropdown, gui.font_size.medium)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText'Post Filter'
private.filter_dropdown = dropdown
filter_dropdown = dropdown
end
do
local input = gui.editbox(frame.filter)
@@ -445,7 +445,7 @@ do
add_post_filter()
end
end
private.filter_input = input
filter_input = input
end
do
local input = gui.editbox(frame.filter)
@@ -457,7 +457,7 @@ do
input.char = function() this:complete() end
input.enter = add_post_filter
input:Hide()
private.filter_parameter_input = input
filter_parameter_input = input
end
do
local scroll_frame = CreateFrame('ScrollFrame', nil, frame.filter)
@@ -500,11 +500,11 @@ do
scroll_child:SetScript('OnHyperlinkClick', data_link_click)
-- scroll_child:SetHyperlinkFormat("format") TODO
scroll_child.measure = scroll_child:CreateFontString()
private.filter_display = scroll_child
filter_display = scroll_child
end
private.status_bars = t
private.tables = t
status_bars = t
tables = t
for _ = 1, 5 do
local status_bar = gui.status_bar(frame)
status_bar:SetAllPoints(status_bar_frame)
@@ -529,7 +529,7 @@ for _ = 1, 5 do
tinsert(tables, table)
end
private.auto_buy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
auto_buy_listing = listing.CreateScrollingTable(frame.saved.autobuy)
auto_buy_listing:SetColInfo{{name='Auto Buy Filters', width=1}}
auto_buy_listing:EnableSorting(false)
auto_buy_listing:DisableSelection(true)
@@ -537,7 +537,7 @@ auto_buy_listing:SetHandler('OnClick', handlers.OnClick)
auto_buy_listing:SetHandler('OnEnter', handlers.OnEnter)
auto_buy_listing:SetHandler('OnLeave', handlers.OnLeave)
private.recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
recent_searches_listing:EnableSorting(false)
recent_searches_listing:DisableSelection(true)
@@ -545,7 +545,7 @@ recent_searches_listing:SetHandler('OnClick', handlers.OnClick)
recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
private.favorite_searches_listing = listing.CreateScrollingTable(frame.saved.favorite)
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)
+25 -15
View File
@@ -9,7 +9,17 @@ function LOAD()
new_search()
end
function private.update_real_time(enable)
do
local id = 0
function get_search_scan_id()
return id
end
function set_search_scan_id(v)
id = v
end
end
function update_real_time(enable)
if enable then
range_button:Hide()
real_time_button:Show()
@@ -25,11 +35,11 @@ do
local searches = t
local search_index = 1
function private.current_search.get()
function get_current_search()
return searches[search_index]
end
function private.update_search(index)
function update_search(index)
searches[search_index].status_bar:Hide()
searches[search_index].table:Hide()
searches[search_index].table:SetSelectedRecord()
@@ -61,7 +71,7 @@ do
update_continuation()
end
function private.new_search(filter_string, first_page, last_page, real_time)
function new_search(filter_string, first_page, last_page, real_time)
while getn(searches) > search_index do
tremove(searches)
end
@@ -86,26 +96,26 @@ do
update_search(getn(searches))
end
function private.clear_control_focus()
function clear_control_focus()
search_box:ClearFocus()
first_page_input:ClearFocus()
last_page_input:ClearFocus()
end
function private.previous_search()
function previous_search()
clear_control_focus()
update_search(search_index - 1)
subtab = RESULTS
end
function private.next_search()
function next_search()
clear_control_focus()
update_search(search_index + 1)
subtab = RESULTS
end
end
function private.update_continuation()
function update_continuation()
if current_search.continuation then
resume_button:Show()
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
@@ -115,13 +125,13 @@ function private.update_continuation()
end
end
function private.discard_continuation()
function discard_continuation()
scan.abort(search_scan_id)
current_search.continuation = nil
update_continuation()
end
function private.update_start_stop()
function update_start_stop()
if current_search.active then
stop_button:Show()
start_button:Hide()
@@ -131,7 +141,7 @@ function private.update_start_stop()
end
end
function private.start_real_time_scan(query, search, continuation)
function start_real_time_scan(query, search, continuation)
local ignore_page
if not search then
@@ -199,7 +209,7 @@ function private.start_real_time_scan(query, search, continuation)
}
end
function private.start_search(queries, continuation)
function start_search(queries, continuation)
local current_query, current_page, total_queries, start_query, start_page
local search = current_search
@@ -349,7 +359,7 @@ function public.execute(resume, real_time)
end
end
function private.test(record)
function test(record)
return function(index)
local auction_info = info.auction(index)
return auction_info and auction_info.search_signature == record.search_signature
@@ -362,7 +372,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
local search = current_search
if not search.table:ContainsRecord(record) or is_player(record.owner) then
@@ -413,7 +423,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
buyout_button:Disable()
bid_button:Disable()
+11 -11
View File
@@ -2,11 +2,11 @@ module 'aux.tabs.search'
local filter_util = require 'aux.util.filter'
aux_auto_buy_filters = t
aux_favorite_searches = t
aux_recent_searches = t
_G.aux_auto_buy_filters = t
_G.aux_favorite_searches = t
_G.aux_recent_searches = t
function private.update_search_listings()
function update_search_listings()
local autobuy_filter_rows = t
for i, autobuy_filter in aux_auto_buy_filters do
local name = strsub(autobuy_filter.prettified, 1, 250)
@@ -41,7 +41,7 @@ function private.update_search_listings()
recent_searches_listing:SetData(recent_search_rows)
end
function private.new_recent_search(filter_string, prettified)
function new_recent_search(filter_string, prettified)
tinsert(aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,
@@ -52,7 +52,7 @@ function private.new_recent_search(filter_string, prettified)
update_search_listings()
end
private.handlers = {
handlers = {
OnClick = function(st, data, _, button)
if not data then return end
if button == 'LeftButton' and IsShiftKeyDown() then
@@ -104,7 +104,7 @@ private.handlers = {
end
}
function private.auto_buy_validator.get()
function get_auto_buy_validator()
local validators = t
for _, filter in aux_auto_buy_filters do
local queries, error = filter_util.queries(filter.filter_string)
@@ -119,7 +119,7 @@ function private.auto_buy_validator.get()
end
end
function private.add_favorite(filter_string)
function add_favorite(filter_string)
local queries, error = filter_util.queries(filter_string)
if queries then
tinsert(aux_favorite_searches, 1, T(
@@ -132,7 +132,7 @@ function private.add_favorite(filter_string)
end
end
function private.add_auto_buy(filter_string)
function add_auto_buy(filter_string)
local queries, error = filter_util.queries(filter_string)
if queries then
if getn(queries) > 1 then
@@ -150,13 +150,13 @@ function private.add_auto_buy(filter_string)
end
end
function private.move_up(list, index)
function move_up(list, index)
if list[index - 1] then
list[index], list[index - 1] = list[index - 1], list[index]
end
end
function private.move_down(list, index)
function move_down(list, index)
if list[index + 1] then
list[index], list[index + 1] = list[index + 1], list[index]
end