big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-19 11:57:12 +02:00
parent 667990f7d8
commit 7740ba2f7a
28 changed files with 271 additions and 266 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ do
}
end
private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3
RESULTS, SAVED, FILTER = 1, 2, 3
function m.LOAD()
m.create_frames()
@@ -79,7 +79,7 @@ function m.USE_ITEM(item_info)
m.execute(nil, false)
end
function private.update_tab(tab)
function update_tab(tab)
m.search_results_button:UnlockHighlight()
m.saved_searches_button:UnlockHighlight()
@@ -115,7 +115,7 @@ function public.add_filter(filter_string)
m.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
+23 -23
View File
@@ -1,11 +1,11 @@
aux.module 'search_tab'
function private.valid_level(str)
function valid_level(str)
local level = tonumber(str)
return level and aux.util.bound(1, 60, level)
end
private.blizzard_query = setmetatable({}, {
blizzard_query = setmetatable({}, {
__newindex = function(_, key, value)
if key == 'name' then
m.name_input:SetText(value)
@@ -58,7 +58,7 @@ private.blizzard_query = setmetatable({}, {
end,
})
function private.update_form()
function update_form()
if m.blizzard_query.class and GetAuctionItemSubClasses(m.blizzard_query.class) then
m.subclass_dropdown.button:Enable()
else
@@ -99,7 +99,7 @@ function private.update_form()
end
end
function private.get_filter_builder_query()
function get_filter_builder_query()
local query_string
local function add(part)
@@ -140,7 +140,7 @@ function private.get_filter_builder_query()
return query_string or ''
end
function private.set_form(components)
function set_form(components)
m.clear_form()
for key, filter in components.blizzard do
m.blizzard_query[key] = filter[2]
@@ -151,7 +151,7 @@ function private.set_form(components)
m.update_filter_display()
end
function private.clear_form()
function clear_form()
m.blizzard_query.name = ''
m.name_input:ClearFocus()
m.blizzard_query.exact = false
@@ -170,7 +170,7 @@ function private.clear_form()
m.update_filter_display()
end
function private.import_query_string()
function import_query_string()
local components, error = aux.filter.parse_query_string(aux.util.select(3, strfind(m.search_box:GetText(), '^([^;]*)')))
if components then
m.set_form(components)
@@ -179,7 +179,7 @@ function private.import_query_string()
end
end
function private.export_query_string()
function export_query_string()
m.search_box:SetText(m.get_filter_builder_query())
m.filter_parameter_input:ClearFocus()
end
@@ -228,14 +228,14 @@ function public.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 = {}
private.filter_builder_state = {selected = 0}
post_filter = {}
filter_builder_state = {selected = 0}
function private.data_link_click()
function data_link_click()
local button = arg3
local index = tonumber(arg1)
if button == 'LeftButton' then
@@ -246,7 +246,7 @@ function private.data_link_click()
m.update_filter_display()
end
function private.remove_component(index)
function remove_component(index)
index = index or m.filter_builder_state.selected
if m.filter_builder_state.selected >= index then
m.filter_builder_state.selected = max(m.filter_builder_state.selected - 1, min(1, getn(m.post_filter)))
@@ -255,12 +255,12 @@ function private.remove_component(index)
tremove(m.post_filter, index)
end
function private.add_component(component)
function add_component(component)
m.filter_builder_state.selected = m.filter_builder_state.selected + 1
tinsert(m.post_filter, m.filter_builder_state.selected, component)
end
function private.add_post_filter()
function add_post_filter()
for str in aux.util.present(m.filter_input:GetText()) do
for filter in aux.util.present(aux.filter.filters[str]) do
if filter.input_type ~= '' then
@@ -285,14 +285,14 @@ end
do
local text = ''
function private.update_filter_display()
function update_filter_display()
text = m.formatted_post_filter(m.post_filter)
m.filter_display:SetWidth(m.filter_display_size())
m.set_filter_display_offset()
m.filter_display:SetText(text)
end
function private.filter_display_size()
function filter_display_size()
local font, font_size = m.filter_display:GetFont()
m.filter_display.measure:SetFont(font, font_size)
local lines = 0
@@ -306,7 +306,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 = m.filter_display:GetParent()
x_offset, y_offset = x_offset or scroll_frame:GetHorizontalScroll(), y_offset or scroll_frame:GetVerticalScroll()
local width, height = m.filter_display_size()
@@ -318,7 +318,7 @@ function private.set_filter_display_offset(x_offset, y_offset)
scroll_frame:SetVerticalScroll(aux.util.bound(y_lower_bound, y_upper_bound, y_offset))
end
function private.initialize_filter_dropdown()
function initialize_filter_dropdown()
for _, filter in {'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{
text = filter,
@@ -338,7 +338,7 @@ function private.initialize_filter_dropdown()
end
end
function private.initialize_class_dropdown()
function initialize_class_dropdown()
local function on_click()
if this.value ~= m.blizzard_query.class then
UIDropDownMenu_SetSelectedValue(m.class_dropdown, this.value)
@@ -365,7 +365,7 @@ function private.initialize_class_dropdown()
end
end
function private.initialize_subclass_dropdown()
function initialize_subclass_dropdown()
local function on_click()
if this.value ~= m.blizzard_query.subclass then
UIDropDownMenu_SetSelectedValue(m.subclass_dropdown, this.value)
@@ -394,7 +394,7 @@ function private.initialize_subclass_dropdown()
end
end
function private.initialize_slot_dropdown()
function initialize_slot_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(m.slot_dropdown, this.value)
m.update_form()
@@ -420,7 +420,7 @@ function private.initialize_slot_dropdown()
end
end
function private.initialize_quality_dropdown()
function initialize_quality_dropdown()
local function on_click()
UIDropDownMenu_SetSelectedValue(m.quality_dropdown, this.value)
m.update_form()
+39 -39
View File
@@ -1,9 +1,9 @@
aux.module 'search_tab'
private.FILTER_SPACING = 28.5
FILTER_SPACING = 28.5
function private.create_frames()
private.frame = CreateFrame('Frame', nil, aux.frame)
function create_frames()
frame = CreateFrame('Frame', nil, aux.frame)
m.frame:SetAllPoints()
m.frame:SetScript('OnUpdate', m.on_update)
m.frame:Hide()
@@ -49,7 +49,7 @@ function private.create_frames()
fake_icon_part:SetText('_')
end
private.settings_button = btn
settings_button = btn
end
do
local panel = CreateFrame('Frame', nil, m.frame)
@@ -59,14 +59,14 @@ function private.create_frames()
panel:SetPoint('RIGHT', 0, 0)
panel:SetHeight(42)
panel:Hide()
private.settings = panel
settings = panel
end
do
local panel = CreateFrame('Frame', nil, m.frame)
panel:SetPoint('LEFT', m.settings_button, 'RIGHT', 0, 0)
panel:SetPoint('RIGHT', 0, 1)
panel:SetHeight(40)
private.controls = panel
controls = panel
end
do
local editbox = aux.gui.editbox(m.settings)
@@ -97,7 +97,7 @@ function private.create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -6, 0)
label:SetText('Pages')
label:SetTextColor(unpack(aux.gui.color.text.enabled))
private.first_page_input = editbox
first_page_input = editbox
end
do
local editbox = aux.gui.editbox(m.settings)
@@ -128,7 +128,7 @@ function private.create_frames()
label:SetPoint('RIGHT', editbox, 'LEFT', -3.5, 0)
label:SetText('-')
label:SetTextColor(unpack(aux.gui.color.text.enabled))
private.last_page_input = editbox
last_page_input = editbox
end
do
local btn = aux.gui.checkbutton(m.settings)
@@ -158,7 +158,7 @@ function private.create_frames()
StaticPopup_Show('AUX_SEARCH_AUTO_BUY')
end
end)
private.auto_buy_button = btn
auto_buy_button = btn
end
do
local btn = aux.gui.checkbutton(m.settings)
@@ -186,7 +186,7 @@ function private.create_frames()
btn:SetScript('OnLeave', function()
GameTooltip:Hide()
end)
private.auto_buy_filter_button = btn
auto_buy_filter_button = btn
end
do
local btn = aux.gui.button(m.controls, 25)
@@ -195,7 +195,7 @@ function private.create_frames()
btn:SetHeight(25)
btn:SetText('<')
btn:SetScript('OnClick', m.previous_search)
private.previous_button = btn
previous_button = btn
end
do
local btn = aux.gui.button(m.controls, 25)
@@ -204,7 +204,7 @@ function private.create_frames()
btn:SetHeight(25)
btn:SetText('>')
btn:SetScript('OnClick', m.next_search)
private.next_button = btn
next_button = btn
end
do
local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size)
@@ -219,7 +219,7 @@ function private.create_frames()
end
m.execute()
end)
private.start_button = btn
start_button = btn
end
do
local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size)
@@ -230,7 +230,7 @@ function private.create_frames()
btn:SetScript('OnClick', function()
aux.scan.abort(m.search_scan_id)
end)
private.stop_button = btn
stop_button = btn
end
do
local btn = aux.gui.button(m.controls, aux.gui.config.huge_font_size)
@@ -241,7 +241,7 @@ function private.create_frames()
btn:SetScript('OnClick', function()
m.execute(true)
end)
private.resume_button = btn
resume_button = btn
end
do
local editbox = aux.gui.editbox(m.controls)
@@ -257,7 +257,7 @@ function private.create_frames()
this:HighlightText(0, 0)
end)
editbox:SetScript('OnEnterPressed', m.execute)
private.search_box = editbox
search_box = editbox
end
do
aux.gui.horizontal_line(m.frame, -40)
@@ -269,7 +269,7 @@ function private.create_frames()
btn:SetHeight(22)
btn:SetText('Search Results')
btn:SetScript('OnClick', function() m.update_tab(m.RESULTS) end)
private.search_results_button = btn
search_results_button = btn
end
do
local btn = aux.gui.button(m.frame, aux.gui.config.large_font_size2)
@@ -278,7 +278,7 @@ function private.create_frames()
btn:SetHeight(22)
btn:SetText('Saved Searches')
btn:SetScript('OnClick', function() m.update_tab(m.SAVED) end)
private.saved_searches_button = btn
saved_searches_button = btn
end
do
local btn = aux.gui.button(m.frame, aux.gui.config.large_font_size2)
@@ -287,14 +287,14 @@ function private.create_frames()
btn:SetHeight(22)
btn:SetText('Filter Builder')
btn:SetScript('OnClick', function() m.update_tab(m.FILTER) end)
private.new_filter_button = btn
new_filter_button = btn
end
do
local frame = CreateFrame('Frame', nil, m.frame)
frame:SetWidth(265)
frame:SetHeight(25)
frame:SetPoint('TOPLEFT', aux.frame.content, 'BOTTOMLEFT', 0, -6)
private.status_bar_frame = frame
status_bar_frame = frame
end
do
local btn = aux.gui.button(m.frame.results, 16)
@@ -303,7 +303,7 @@ function private.create_frames()
btn:SetHeight(24)
btn:SetText('Bid')
btn:Disable()
private.bid_button = btn
bid_button = btn
end
do
local btn = aux.gui.button(m.frame.results, 16)
@@ -312,7 +312,7 @@ function private.create_frames()
btn:SetHeight(24)
btn:SetText('Buyout')
btn:Disable()
private.buyout_button = btn
buyout_button = btn
end
do
local btn = aux.gui.button(m.frame.results, 16)
@@ -392,7 +392,7 @@ function private.create_frames()
local label = aux.gui.label(editbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Name')
private.name_input = editbox
name_input = editbox
end
do
local checkbox = aux.gui.checkbox(m.frame.filter)
@@ -401,7 +401,7 @@ function private.create_frames()
local label = aux.gui.label(checkbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Exact')
private.exact_checkbox = checkbox
exact_checkbox = checkbox
end
do
local editbox = aux.gui.editbox(m.frame.filter)
@@ -426,7 +426,7 @@ function private.create_frames()
local label = aux.gui.label(editbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', editbox, 'TOPLEFT', -2, 1)
label:SetText('Level Range')
private.min_level_input = editbox
min_level_input = editbox
end
do
local editbox = aux.gui.editbox(m.frame.filter)
@@ -451,7 +451,7 @@ function private.create_frames()
local label = aux.gui.label(editbox, aux.gui.config.medium_font_size)
label:SetPoint('RIGHT', editbox, 'LEFT', -3, 0)
label:SetText('-')
private.max_level_input = editbox
max_level_input = editbox
end
do
local checkbox = aux.gui.checkbox(m.frame.filter)
@@ -460,11 +460,11 @@ function private.create_frames()
local label = aux.gui.label(checkbox, aux.gui.config.small_font_size)
label:SetPoint('BOTTOMLEFT', checkbox, 'TOPLEFT', -2, 1)
label:SetText('Usable')
private.usable_checkbox = checkbox
usable_checkbox = checkbox
end
do
local dropdown = aux.gui.dropdown(m.frame.filter)
private.class_dropdown = dropdown
class_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', m.min_level_input, 'BOTTOMLEFT', 0, 5 - m.FILTER_SPACING)
dropdown:SetWidth(300)
local label = aux.gui.label(dropdown, aux.gui.config.small_font_size)
@@ -477,7 +477,7 @@ function private.create_frames()
end
do
local dropdown = aux.gui.dropdown(m.frame.filter)
private.subclass_dropdown = dropdown
subclass_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', m.class_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING)
dropdown:SetWidth(300)
local label = aux.gui.label(dropdown, aux.gui.config.small_font_size)
@@ -490,7 +490,7 @@ function private.create_frames()
end
do
local dropdown = aux.gui.dropdown(m.frame.filter)
private.slot_dropdown = dropdown
slot_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', m.subclass_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING)
dropdown:SetWidth(300)
local label = aux.gui.label(dropdown, aux.gui.config.small_font_size)
@@ -503,7 +503,7 @@ function private.create_frames()
end
do
local dropdown = aux.gui.dropdown(m.frame.filter)
private.quality_dropdown = dropdown
quality_dropdown = dropdown
dropdown:SetPoint('TOPLEFT', m.slot_dropdown, 'BOTTOMLEFT', 0, 10 - m.FILTER_SPACING)
dropdown:SetWidth(300)
local label = aux.gui.label(dropdown, aux.gui.config.small_font_size)
@@ -527,7 +527,7 @@ function private.create_frames()
local label = aux.gui.label(dropdown, aux.gui.config.medium_font_size)
label:SetPoint('RIGHT', dropdown, 'LEFT', -15, 0)
label:SetText('Post Filter')
private.filter_dropdown = dropdown
filter_dropdown = dropdown
end
do
local input = aux.gui.editbox(m.frame.filter)
@@ -558,7 +558,7 @@ function private.create_frames()
m.add_post_filter()
end
end)
private.filter_input = input
filter_input = input
end
do
local input = aux.gui.editbox(m.frame.filter)
@@ -572,7 +572,7 @@ function private.create_frames()
end)
input:SetScript('OnEnterPressed', m.add_post_filter)
input:Hide()
private.filter_parameter_input = input
filter_parameter_input = input
end
do
local scroll_frame = CreateFrame('ScrollFrame', nil, m.frame.filter)
@@ -615,11 +615,11 @@ function private.create_frames()
scroll_child:SetScript('OnHyperlinkClick', m.data_link_click)
-- scroll_child:SetHyperlinkFormat("format")
scroll_child.measure = scroll_child:CreateFontString()
private.filter_display = scroll_child
filter_display = scroll_child
end
private.status_bars = {}
private.tables = {}
status_bars = {}
tables = {}
for _=1,5 do
local status_bar = aux.gui.status_bar(m.frame)
status_bar:SetAllPoints(m.status_bar_frame)
@@ -689,7 +689,7 @@ function private.create_frames()
end
}
private.recent_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.recent)
recent_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.recent)
m.recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
m.recent_searches_listing:EnableSorting(false)
m.recent_searches_listing:DisableSelection(true)
@@ -697,7 +697,7 @@ function private.create_frames()
m.recent_searches_listing:SetHandler('OnEnter', handlers.OnEnter)
m.recent_searches_listing:SetHandler('OnLeave', handlers.OnLeave)
private.favorite_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.favorite)
favorite_searches_listing = aux.listing.CreateScrollingTable(m.frame.saved.favorite)
m.favorite_searches_listing:SetColInfo{{name='Favorite Searches', width=1}}
m.favorite_searches_listing:EnableSorting(false)
m.favorite_searches_listing:DisableSelection(true)
+16 -16
View File
@@ -2,18 +2,18 @@ aux.module 'search_tab'
_G.aux_auto_buy_filter = ''
private.search_scan_id = 0
private.auto_buy_validator = nil
search_scan_id = 0
auto_buy_validator = nil
do
local searches = {}
local search_index = 1
function private.current_search()
function 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()
@@ -40,7 +40,7 @@ do
m.update_continuation()
end
function private.new_search(filter_string)
function new_search(filter_string)
while getn(searches) > search_index do
tremove(searches)
end
@@ -68,26 +68,26 @@ do
m.update_search(getn(searches))
end
function private.previous_search()
function previous_search()
m.search_box:ClearFocus()
m.update_search(search_index - 1)
m.update_tab(m.RESULTS)
end
function private.next_search()
function next_search()
m.search_box:ClearFocus()
m.update_search(search_index + 1)
m.update_tab(m.RESULTS)
end
end
function private.close_settings()
function close_settings()
if m.settings_button.open then
m.settings_button:Click()
end
end
function private.update_continuation()
function update_continuation()
if m.current_search().continuation then
m.resume_button:Show()
m.search_box:SetPoint('RIGHT', m.resume_button, 'LEFT', -4, 0)
@@ -97,7 +97,7 @@ function private.update_continuation()
end
end
function private.discard_continuation()
function discard_continuation()
aux.scan.abort(m.search_scan_id)
m.current_search().continuation = nil
m.update_continuation()
@@ -113,7 +113,7 @@ function private:update_start_stop()
end
end
function private.update_auto_buy_filter()
function update_auto_buy_filter()
if _G.aux_auto_buy_filter ~= '' then
local queries = aux.filter.queries(_G.aux_auto_buy_filter)
if queries then
@@ -132,7 +132,7 @@ function private.update_auto_buy_filter()
_G.aux_auto_buy_filter = ''
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
@@ -209,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 = m.current_search()
@@ -365,7 +365,7 @@ function public.execute(resume, real_time)
end
end
function private.test(record)
function test(record)
return function(index)
local auction_info = aux.info.auction(index)
return auction_info and auction_info.search_signature == record.search_signature
@@ -378,7 +378,7 @@ do
local state = IDLE
local found_index
function private.find_auction(record)
function find_auction(record)
local search = m.current_search()
if not search.table:ContainsRecord(record) or aux.is_player(record.owner) then
@@ -429,7 +429,7 @@ do
)
end
function private.on_update()
function on_update()
if state == IDLE or state == SEARCHING then
m.buyout_button:Disable()
m.bid_button:Disable()
+2 -2
View File
@@ -3,7 +3,7 @@ aux.module 'search_tab'
_G.aux_favorite_searches = {}
_G.aux_recent_searches = {}
function private.update_search_listings()
function update_search_listings()
local favorite_search_rows = {}
for i, favorite_search in _G.aux_favorite_searches do
local name = strsub(favorite_search.prettified, 1, 250)
@@ -27,7 +27,7 @@ function private.update_search_listings()
m.recent_searches_listing:SetData(recent_search_rows)
end
function private.new_recent_search(filter_string, prettified)
function new_recent_search(filter_string, prettified)
tinsert(_G.aux_recent_searches, 1, {
filter_string = filter_string,
prettified = prettified,