refactoring

This commit is contained in:
Manuel Simon Hirsig
2017-11-25 18:30:20 +01:00
parent ad204207bc
commit 069700554f
3 changed files with 30 additions and 30 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ function tab.OPEN()
end
function tab.CLOSE()
get_current_search().table:SetSelectedRecord()
current_search().table:SetSelectedRecord()
frame:Hide()
end
+5 -5
View File
@@ -129,7 +129,7 @@ do
btn:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
btn:SetScript('OnClick', function()
if arg1 == 'RightButton' then
set_filter(get_current_search().filter_string)
set_filter(current_search().filter_string)
end
execute()
end)
@@ -164,7 +164,7 @@ do
return queries and aux.join(aux.map(aux.copy(queries), function(query) return query.prettified end), ';') or aux.color.red(str)
end
editbox.complete = completion.complete_filter
editbox.escape = function() this:SetText(get_current_search().filter_string or '') end
editbox.escape = function() this:SetText(current_search().filter_string or '') end
editbox:SetHeight(25)
editbox.char = function()
this:complete()
@@ -235,8 +235,8 @@ do
btn:SetPoint('TOPLEFT', buyout_button, 'TOPRIGHT', 5, 0)
btn:SetText('Clear')
btn:SetScript('OnClick', function()
while tremove(get_current_search().records) do end
get_current_search().table:SetDatabase()
while tremove(current_search().records) do end
current_search().table:SetDatabase()
end)
end
do
@@ -523,7 +523,7 @@ for _ = 1, 5 do
local table = auction_listing.new(frame.results, 16, auction_listing.search_columns)
table:SetHandler('OnClick', function(row, button)
if IsAltKeyDown() then
if get_current_search().table:GetSelection().record == row.record then
if current_search().table:GetSelection().record == row.record then
if button == 'LeftButton' then
buyout_button:Click()
elseif button == 'RightButton' then
+24 -24
View File
@@ -29,7 +29,7 @@ do
local searches = {}
local search_index = 1
function get_current_search()
function current_search()
return searches[search_index]
end
@@ -110,7 +110,7 @@ do
end
function update_continuation()
if get_current_search().continuation then
if current_search().continuation then
resume_button:Show()
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
else
@@ -121,12 +121,12 @@ end
function discard_continuation()
scan.abort(search_scan_id)
get_current_search().continuation = nil
current_search().continuation = nil
update_continuation()
end
function update_start_stop()
if get_current_search().active then
if current_search().active then
stop_button:Show()
start_button:Hide()
else
@@ -139,7 +139,7 @@ function start_real_time_scan(query, search, continuation)
local ignore_page
if not search then
search = get_current_search()
search = current_search()
query.blizzard_query.first_page = tonumber(continuation) or 0
query.blizzard_query.last_page = tonumber(continuation) or 0
ignore_page = not tonumber(continuation)
@@ -194,7 +194,7 @@ function start_real_time_scan(query, search, continuation)
search.continuation = next_page or not ignore_page and query.blizzard_query.first_page or true
if get_current_search() == search then
if current_search() == search then
update_continuation()
end
@@ -207,7 +207,7 @@ end
function start_search(queries, continuation)
local current_query, current_page, total_queries, start_query, start_page
local search = get_current_search()
local search = current_search()
total_queries = getn(queries)
@@ -262,7 +262,7 @@ function start_search(queries, continuation)
search.status_bar:update_status(1, 1)
search.status_bar:set_text('Scan complete')
if get_current_search() == search and frame.results:IsVisible() and getn(search.records) == 0 then
if current_search() == search and frame.results:IsVisible() and getn(search.records) == 0 then
set_subtab(SAVED)
end
@@ -278,7 +278,7 @@ function start_search(queries, continuation)
else
search.continuation = {start_query, start_page}
end
if get_current_search() == search then
if current_search() == search then
update_continuation()
end
@@ -291,13 +291,13 @@ end
function M.execute(resume, real_time)
if resume then
real_time = get_current_search().real_time
real_time = current_search().real_time
elseif real_time == nil then
real_time = real_time_button:IsShown()
end
if resume then
search_box:SetText(get_current_search().filter_string)
search_box:SetText(current_search().filter_string)
end
local filter_string, first_page, last_page = search_box:GetText(), blizzard_page_index(first_page_input:GetText()), blizzard_page_index(last_page_input:GetText())
@@ -316,31 +316,31 @@ function M.execute(resume, real_time)
end
if resume then
get_current_search().table:SetSelectedRecord()
current_search().table:SetSelectedRecord()
else
if filter_string ~= get_current_search().filter_string then
if get_current_search().filter_string then
if filter_string ~= current_search().filter_string then
if current_search().filter_string then
new_search(filter_string, first_page, last_page, real_time)
else
get_current_search().filter_string = filter_string
current_search().filter_string = filter_string
end
new_recent_search(filter_string, aux.join(aux.map(aux.copy(queries), function(filter) return filter.prettified end), ';'))
else
local search = get_current_search()
local search = current_search()
search.records = T.acquire()
search.table:Reset()
search.table:SetDatabase(search.records)
end
local search = get_current_search()
local search = current_search()
search.first_page = first_page
search.last_page = last_page
search.real_time = real_time
search.auto_buy_validator = get_auto_buy_validator()
end
local continuation = resume and get_current_search().continuation
local continuation = resume and current_search().continuation
discard_continuation()
get_current_search().active = true
current_search().active = true
update_start_stop()
clear_control_focus()
set_subtab(RESULTS)
@@ -348,8 +348,8 @@ function M.execute(resume, real_time)
start_real_time_scan(queries[1], nil, continuation)
else
for _, query in queries do
query.blizzard_query.first_page = get_current_search().first_page
query.blizzard_query.last_page = get_current_search().last_page
query.blizzard_query.first_page = current_search().first_page
query.blizzard_query.last_page = current_search().last_page
end
start_search(queries, continuation)
end
@@ -362,7 +362,7 @@ do
local found_index
function find_auction(record)
local search = get_current_search()
local search = current_search()
if not search.table:ContainsRecord(record) or info.is_player(record.owner) then
return
@@ -372,7 +372,7 @@ do
state = SEARCHING
scan_id = scan_util.find(
record,
get_current_search().status_bar,
current_search().status_bar,
function()
state = IDLE
end,
@@ -424,7 +424,7 @@ do
if state == SEARCHING then return end
local selection = get_current_search().table:GetSelection()
local selection = current_search().table:GetSelection()
if not selection then
state = IDLE
elseif selection and state == IDLE then