refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-23 12:45:23 +02:00
parent 99ba3e7fdc
commit deb85ad030
18 changed files with 169 additions and 152 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
module 'auctions_tab' import 'scan'
auction_records = nil
auction_records = {}
function LOAD()
create_frames()
@@ -25,7 +25,7 @@ function public.scan_auctions()
status_bar:update_status(0,0)
status_bar:set_text('Scanning auctions...')
auction_records = {}
wipe(auction_records)
update_listing()
scan.start{
type = 'owner',
@@ -58,7 +58,7 @@ end
do
local scan_id = 0
local IDLE, SEARCHING, FOUND = {}, {}, {}
local IDLE, SEARCHING, FOUND = t, t, t
local state = IDLE
local found_index
+2 -2
View File
@@ -1,6 +1,6 @@
module 'bids_tab' import 'scan'
auction_records = nil
auction_records = {}
function LOAD()
create_frames()
@@ -25,7 +25,7 @@ function public.scan_bids()
status_bar:update_status(0,0)
status_bar:set_text('Scanning auctions...')
auction_records = {}
wipe(auction_records)
update_listing()
scan.start{
type = 'bidder',
+7 -7
View File
@@ -1,13 +1,13 @@
module 'post_tab' import 'scan' 'post'
module 'post_tab' import 'scan' 'post' 'info'
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'}}
existing_auctions = {}
inventory_records = nil
scan_id = 0
selected_item = nil
refresh = nil
mutable.inventory_records = nil
mutable.scan_id = 0
mutable.selected_item = nil
mutable.refresh = nil
function LOAD()
create_frames()
@@ -345,7 +345,7 @@ end
function unit_vendor_price(item_key)
for slot in inventory do
for slot in info.inventory do
local item_info = info.container_item(unpack(slot))
if item_info and item_info.item_key == item_key then
@@ -416,7 +416,7 @@ function update_inventory_records()
local auction_candidate_map = {}
for slot in inventory do
for slot in info.inventory do
local item_info = info.container_item(unpack(slot))
if item_info then
+19 -19
View File
@@ -2,10 +2,10 @@ module 'search_tab' import 'filter_util'
function valid_level(str)
local level = tonumber(str)
return level and bound(1, 60, level)
return level and bounded(1, 60, level)
end
blizzard_query = setmetatable({}, {
blizzard_query = setmetatable(t, {
__index = function(_, key)
if key == 'name' then
return name_input:GetText()
@@ -72,14 +72,14 @@ function update_form()
end
if blizzard_query.exact then
for _, key in {'class', 'subclass', 'slot', 'quality'} do
for key in temp-set 'class' 'subclass' 'slot' 'quality' do
_m[key..'_dropdown'].button:Disable()
end
else
class_dropdown.button:Enable()
quality_dropdown.button:Enable()
end
for _, key in {'min_level', 'max_level'} do
for key in temp-set 'min_level' 'max_level' do
if blizzard_query.exact then
_m[key..'_input']:Disable()
else
@@ -92,7 +92,7 @@ function update_form()
usable_checkbox:Enable()
end
if any({'min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'}, function(key) return blizzard_query[key] end) then
if any(temp-list 'min_level' 'max_level' 'usable' 'class' 'subclass' 'slot' 'quality', function(key) return blizzard_query[key] end) then
exact_checkbox:Disable()
else
exact_checkbox:Enable()
@@ -119,11 +119,11 @@ function get_filter_builder_query()
add(blizzard_query.max_level)
add(blizzard_query.usable and 'usable')
for _, class in {blizzard_query.class} do
local classes = {GetAuctionItemClasses()}
for class in present(blizzard_query.class) do
local classes = temp-{GetAuctionItemClasses()}
add(strlower(classes[class]))
for _, subclass in {blizzard_query.subclass} do
local subclasses = {GetAuctionItemSubClasses(class)}
for _, subclass in present(blizzard_query.subclass) do
local subclasses = temp-{GetAuctionItemSubClasses(class)}
add(strlower(subclasses[subclass]))
add(blizzard_query.slot and strlower(_g[blizzard_query.slot]))
end
@@ -134,7 +134,7 @@ function get_filter_builder_query()
add(strlower(_g['ITEM_QUALITY'..quality..'_DESC']))
end
local post_filter_string = filter_util.query_string{blizzard={}, post=post_filter}
local post_filter_string = filter_util.query_string(temp-object :blizzard(tt) :post(post_filter))
add(post_filter_string ~= '' and post_filter_string)
return query_string or ''
@@ -165,8 +165,8 @@ function clear_form()
UIDropDownMenu_ClearAll(slot_dropdown)
UIDropDownMenu_ClearAll(quality_dropdown)
filter_parameter_input:ClearFocus()
post_filter = {}
filter_builder_state = {selected=0}
wipe(post_filter)
wipe(filter_builder_state).selected = 0
update_filter_display()
end
@@ -186,7 +186,7 @@ end
function public.formatted_post_filter(components)
local no_line_break
local stack = {}
local stack = tt
local str = ''
for i, component in components do
@@ -195,7 +195,7 @@ function public.formatted_post_filter(components)
elseif i > 1 then
str = str..'</p><p>'
for _=1,getn(stack) do
str = str..color.content.background('----')
str = str..color.content.background '----'
end
end
no_line_break = component[1] == 'operator' and component[2] == 'not'
@@ -232,8 +232,8 @@ function data_link(id, str)
return '|H'..id..'|h'..str..'|h'
end
post_filter = {}
filter_builder_state = {selected = 0}
post_filter = t
filter_builder_state = -object :selected(0)
function data_link_click()
local button = arg3
@@ -314,12 +314,12 @@ function set_filter_display_offset(x_offset, y_offset)
local x_upper_bound = 0
local y_lower_bound = 0
local y_upper_bound = max(0, height - scroll_frame:GetHeight())
scroll_frame:SetHorizontalScroll(bound(x_lower_bound, x_upper_bound, x_offset))
scroll_frame:SetVerticalScroll(bound(y_lower_bound, y_upper_bound, y_offset))
scroll_frame:SetHorizontalScroll(bounded(x_lower_bound, x_upper_bound, x_offset))
scroll_frame:SetVerticalScroll(bounded(y_lower_bound, y_upper_bound, y_offset))
end
function initialize_filter_dropdown()
for _, filter in -list '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
for _, filter in temp-list '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,
value = filter,
+1 -1
View File
@@ -553,7 +553,7 @@ function create_frames()
scroll_frame:EnableMouseWheel(true)
scroll_frame:SetScript('OnMouseWheel', function()
local child = this:GetScrollChild()
child:SetFont('p', [[Fonts\ARIALN.TTF]], bound(11, 23, select(2, child:GetFont()) + arg1*2))
child:SetFont('p', [[Fonts\ARIALN.TTF]], bounded(11, 23, select(2, child:GetFont()) + arg1*2))
update_filter_display()
end)
scroll_frame:RegisterForDrag('LeftButton')
+10 -15
View File
@@ -2,11 +2,11 @@ module 'search_tab'
_g.aux_auto_buy_filter = ''
search_scan_id = 0
auto_buy_validator = nil
mutable.search_scan_id = 0
mutable.auto_buy_validator = nil
do
local searches = {}
local searches = t
local search_index = 1
function accessor.current_search() return searches[search_index] end
@@ -42,10 +42,7 @@ do
while getn(searches) > search_index do
tremove(searches)
end
local search = {
filter_string = filter_string,
records = {},
}
local search = -object :filter_string(filter_string) :records(t)
tinsert(searches, search)
if getn(searches) > 5 then
tremove(searches, 1)
@@ -56,10 +53,10 @@ do
search.status_bar = status_bars[getn(searches)]
search.status_bar:update_status(100, 100)
search.status_bar:set_text('')
search.status_bar:set_text ''
search.table = tables[getn(searches)]
search.table:SetSort(1,2,3,4,5,6,7,8,9)
search.table:SetSort(1, 2, 3, 4, 5, 6, 7, 8, 9)
search.table:Reset()
search.table:SetDatabase(search.records)
@@ -141,7 +138,7 @@ function start_real_time_scan(query, search, continuation)
end
local next_page
local new_records = {}
local new_records = t
search_scan_id = scan.start{
type = 'list',
queries = {query},
@@ -175,7 +172,7 @@ function start_real_time_scan(query, search, continuation)
for _, record in new_records do
map[record.sniping_signature] = record
end
new_records = t
wipe(new_records)
for _, record in map do
tinsert(new_records, record)
end
@@ -372,7 +369,7 @@ end
do
local scan_id = 0
local IDLE, SEARCHING, FOUND = {}, {}, {}
local IDLE, SEARCHING, FOUND = t, t, t
local state = IDLE
local found_index
@@ -433,9 +430,7 @@ do
bid_button:Disable()
end
if state == SEARCHING then
return
end
if state == SEARCHING then return end
local selection = current_search.table:GetSelection()
if not selection then