greent refactoring
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module 'aux.tabs.auctions'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Auctions'
|
||||
|
||||
auction_records = t
|
||||
auction_records = T
|
||||
|
||||
function OPEN()
|
||||
frame:Show()
|
||||
@@ -34,7 +34,7 @@ function M.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((page - 1) / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
@@ -56,7 +56,7 @@ end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = t, t, t
|
||||
local IDLE, SEARCHING, FOUND = T, T, T
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
module 'aux.tabs.bids'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
@@ -9,7 +9,7 @@ local scan = require 'aux.core.scan'
|
||||
|
||||
TAB 'Bids'
|
||||
|
||||
auction_records = t
|
||||
auction_records = T
|
||||
|
||||
function OPEN()
|
||||
frame:Show()
|
||||
@@ -34,7 +34,7 @@ function M.scan_bids()
|
||||
update_listing()
|
||||
scan.start{
|
||||
type = 'bidder',
|
||||
queries = A(T('blizzard_query', t)),
|
||||
queries = A(O('blizzard_query', T)),
|
||||
on_page_loaded = function(page, total_pages)
|
||||
status_bar:update_status((page - 1) / total_pages, 0)
|
||||
status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
|
||||
+20
-20
@@ -1,6 +1,6 @@
|
||||
module 'aux.tabs.post'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
@@ -20,7 +20,7 @@ local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440
|
||||
local settings_schema = {'tuple', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}}
|
||||
|
||||
function get_default_settings()
|
||||
return T('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
return O('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
end
|
||||
|
||||
do
|
||||
@@ -28,7 +28,7 @@ do
|
||||
function get_data()
|
||||
if not data then
|
||||
local dataset = persistence.dataset
|
||||
data = dataset.post or t
|
||||
data = dataset.post or T
|
||||
dataset.post = data
|
||||
end
|
||||
return data
|
||||
@@ -45,7 +45,7 @@ function write_settings(settings, item_key)
|
||||
data[item_key] = persistence.write(settings_schema, settings)
|
||||
end
|
||||
|
||||
local scan_id, inventory_records, existing_auctions = 0, t, t
|
||||
local scan_id, inventory_records, existing_auctions = 0, T, T
|
||||
|
||||
function refresh_button_click()
|
||||
scan.abort(scan_id)
|
||||
@@ -108,12 +108,12 @@ end
|
||||
|
||||
function update_auction_listing()
|
||||
if not ACTIVE then return end
|
||||
local auction_rows = t
|
||||
local auction_rows = T
|
||||
if selected_item then
|
||||
local unit_start_price = get_unit_start_price()
|
||||
local unit_buyout_price = get_unit_buyout_price()
|
||||
|
||||
for i, auction_record in existing_auctions[selected_item.key] or tt do
|
||||
for i, auction_record in existing_auctions[selected_item.key] or temp-T do
|
||||
|
||||
local blizzard_bid_undercut, buyout_price_undercut = undercut(auction_record, stack_size_slider:GetValue())
|
||||
blizzard_bid_undercut = money.from_string(money.to_string(blizzard_bid_undercut, true, nil, 3))
|
||||
@@ -144,15 +144,15 @@ function update_auction_listing()
|
||||
buyout_color = inline_color.yellow
|
||||
end
|
||||
|
||||
tinsert(auction_rows, T(
|
||||
tinsert(auction_rows, O(
|
||||
'cols', A(
|
||||
T('value', auction_record.own and color.yellow(auction_record.count) or auction_record.count),
|
||||
T('value', al.time_left(auction_record.duration)),
|
||||
T('value', auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size),
|
||||
T('value', money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)),
|
||||
T('value', historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'),
|
||||
T('value', auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'),
|
||||
T('value', auction_record.unit_buyout_price > 0 and historical_value and al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---')
|
||||
O('value', auction_record.own and color.yellow(auction_record.count) or auction_record.count),
|
||||
O('value', al.time_left(auction_record.duration)),
|
||||
O('value', auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size),
|
||||
O('value', money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)),
|
||||
O('value', historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'),
|
||||
O('value', auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'),
|
||||
O('value', auction_record.unit_buyout_price > 0 and historical_value and al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---')
|
||||
),
|
||||
'record', auction_record
|
||||
))
|
||||
@@ -407,18 +407,18 @@ function update_item(item)
|
||||
end
|
||||
|
||||
function update_inventory_records()
|
||||
local auctionable_map = tt
|
||||
local auctionable_map = temp-T
|
||||
for slot in info.inventory do auto_release(slot, true)
|
||||
for item_info in present(temp-info.container_item(unpack(slot))) do
|
||||
local charge_class = item_info.charges or 0
|
||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||
if not auctionable_map[item_info.item_key] then
|
||||
local availability = t
|
||||
local availability = T
|
||||
for i = 0, 10 do
|
||||
availability[i] = 0
|
||||
end
|
||||
availability[charge_class] = item_info.count
|
||||
auctionable_map[item_info.item_key] = T(
|
||||
auctionable_map[item_info.item_key] = O(
|
||||
'item_id', item_info.item_id,
|
||||
'suffix_id', item_info.suffix_id,
|
||||
'key', item_info.item_key,
|
||||
@@ -481,7 +481,7 @@ function refresh_entries()
|
||||
status_bar:set_text('Scan aborted')
|
||||
end,
|
||||
on_complete = function()
|
||||
existing_auctions[item_key] = existing_auctions[item_key] or t
|
||||
existing_auctions[item_key] = existing_auctions[item_key] or T
|
||||
refresh = true
|
||||
status_bar:update_status(1, 1)
|
||||
status_bar:set_text('Scan complete')
|
||||
@@ -491,7 +491,7 @@ function refresh_entries()
|
||||
end
|
||||
|
||||
function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
existing_auctions[key] = existing_auctions[key] or t
|
||||
existing_auctions[key] = existing_auctions[key] or T
|
||||
local entry
|
||||
for _, record in existing_auctions[key] do
|
||||
if unit_blizzard_bid == record.unit_blizzard_bid and unit_buyout_price == record.unit_buyout_price and aux_quantity == record.stack_size and duration == record.duration and is_player(owner) == record.own then
|
||||
@@ -499,7 +499,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = T('stack_size', aux_quantity, 'unit_blizzard_bid', unit_blizzard_bid, 'unit_buyout_price', unit_buyout_price, 'duration', duration, 'own', is_player(owner), 'count', 0)
|
||||
entry = O('stack_size', aux_quantity, 'unit_blizzard_bid', unit_blizzard_bid, 'unit_buyout_price', unit_buyout_price, 'duration', duration, 'own', is_player(owner), 'count', 0)
|
||||
tinsert(existing_auctions[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module 'aux.tabs.search'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
include 'aux'
|
||||
|
||||
TAB 'Search'
|
||||
|
||||
+13
-13
@@ -10,7 +10,7 @@ function valid_level(str)
|
||||
return level and bounded(1, 60, level)
|
||||
end
|
||||
|
||||
blizzard_query = setmetatable(t, {
|
||||
blizzard_query = setmetatable(T, {
|
||||
__index = function(_, key)
|
||||
if key == 'name' then
|
||||
return name_input:GetText()
|
||||
@@ -195,7 +195,7 @@ end
|
||||
|
||||
function formatted_post_filter(components)
|
||||
local no_line_break
|
||||
local stack = tt
|
||||
local stack = temp-T
|
||||
local str = ''
|
||||
|
||||
for i, component in components do
|
||||
@@ -241,8 +241,8 @@ function data_link(id, str)
|
||||
return '|H' .. id .. '|h' .. str .. '|h'
|
||||
end
|
||||
|
||||
post_filter = t
|
||||
filter_builder_state = T('selected', 0)
|
||||
post_filter = T
|
||||
filter_builder_state = O('selected', 0)
|
||||
|
||||
function data_link_click()
|
||||
local button = arg3
|
||||
@@ -325,7 +325,7 @@ end
|
||||
|
||||
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(
|
||||
UIDropDownMenu_AddButton(O(
|
||||
'text', filter,
|
||||
'value', filter,
|
||||
'func', function()
|
||||
@@ -354,9 +354,9 @@ function initialize_class_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, class in temp-A(GetAuctionItemClasses()) do
|
||||
UIDropDownMenu_AddButton(T('text', class, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', class, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -367,9 +367,9 @@ function initialize_subclass_dropdown()
|
||||
update_form()
|
||||
end
|
||||
end
|
||||
UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click))
|
||||
for i, subclass in temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0)) do
|
||||
UIDropDownMenu_AddButton(T('text', subclass, 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', subclass, 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -378,9 +378,9 @@ function initialize_slot_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(T('text', ALL, 'value', '', 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', '', 'func', on_click))
|
||||
for i, slot in temp-A(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0)) do
|
||||
UIDropDownMenu_AddButton(T('text', _G[slot], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', _G[slot], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -389,8 +389,8 @@ function initialize_quality_dropdown()
|
||||
UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value)
|
||||
update_form()
|
||||
end
|
||||
UIDropDownMenu_AddButton(T('text', ALL, 'value', -1, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', ALL, 'value', -1, 'func', on_click))
|
||||
for i = 0, 4 do
|
||||
UIDropDownMenu_AddButton(T('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
UIDropDownMenu_AddButton(O('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -520,8 +520,8 @@ do
|
||||
filter_display = scroll_child
|
||||
end
|
||||
|
||||
status_bars = t
|
||||
tables = t
|
||||
status_bars = T
|
||||
tables = T
|
||||
for _ = 1, 5 do
|
||||
local status_bar = gui.status_bar(frame)
|
||||
status_bar:SetAllPoints(status_bar_frame)
|
||||
|
||||
@@ -32,7 +32,7 @@ function update_real_time(enable)
|
||||
end
|
||||
|
||||
do
|
||||
local searches = t
|
||||
local searches = T
|
||||
local search_index = 1
|
||||
|
||||
function get_current_search()
|
||||
@@ -75,7 +75,7 @@ do
|
||||
while getn(searches) > search_index do
|
||||
tremove(searches)
|
||||
end
|
||||
local search = T('records', t, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
local search = O('records', T, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
tinsert(searches, search)
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
@@ -152,7 +152,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
end
|
||||
|
||||
local next_page
|
||||
local new_records = t
|
||||
local new_records = T
|
||||
search_scan_id = scan.start{
|
||||
type = 'list',
|
||||
queries = {query},
|
||||
@@ -173,7 +173,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
local map = tt
|
||||
local map = temp-T
|
||||
for _, record in search.records do
|
||||
map[record.sniping_signature] = record
|
||||
end
|
||||
@@ -334,7 +334,7 @@ function M.execute(resume, real_time)
|
||||
end
|
||||
new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';'))
|
||||
else
|
||||
current_search.records = t
|
||||
current_search.records = T
|
||||
current_search.table:SetDatabase(current_search.records)
|
||||
end
|
||||
current_search.first_page = first_page
|
||||
@@ -362,7 +362,7 @@ end
|
||||
|
||||
do
|
||||
local scan_id = 0
|
||||
local IDLE, SEARCHING, FOUND = t, t, t
|
||||
local IDLE, SEARCHING, FOUND = T, T, T
|
||||
local state = IDLE
|
||||
local found_index
|
||||
|
||||
|
||||
+16
-16
@@ -2,38 +2,38 @@ module 'aux.tabs.search'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
|
||||
_G.aux_auto_buy_filters = t
|
||||
_G.aux_favorite_searches = t
|
||||
_G.aux_recent_searches = t
|
||||
_G.aux_auto_buy_filters = T
|
||||
_G.aux_favorite_searches = T
|
||||
_G.aux_recent_searches = T
|
||||
|
||||
function update_search_listings()
|
||||
local autobuy_filter_rows = t
|
||||
local autobuy_filter_rows = T
|
||||
for i, autobuy_filter in aux_auto_buy_filters do
|
||||
local name = strsub(autobuy_filter.prettified, 1, 250)
|
||||
tinsert(autobuy_filter_rows, T(
|
||||
'cols', A(T('value', name)),
|
||||
tinsert(autobuy_filter_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
'search', autobuy_filter,
|
||||
'index', i
|
||||
))
|
||||
end
|
||||
auto_buy_listing:SetData(autobuy_filter_rows)
|
||||
|
||||
local favorite_search_rows = t
|
||||
local favorite_search_rows = T
|
||||
for i, favorite_search in aux_favorite_searches do
|
||||
local name = strsub(favorite_search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, T(
|
||||
'cols', A(T('value', name)),
|
||||
tinsert(favorite_search_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
'search', favorite_search,
|
||||
'index', i
|
||||
))
|
||||
end
|
||||
favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = t
|
||||
local recent_search_rows = T
|
||||
for i, recent_search in aux_recent_searches do
|
||||
local name = strsub(recent_search.prettified, 1, 250)
|
||||
tinsert(recent_search_rows, T(
|
||||
'cols', A(T('value', name)),
|
||||
tinsert(recent_search_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
'search', recent_search,
|
||||
'index', i
|
||||
))
|
||||
@@ -42,7 +42,7 @@ function update_search_listings()
|
||||
end
|
||||
|
||||
function new_recent_search(filter_string, prettified)
|
||||
tinsert(aux_recent_searches, 1, T(
|
||||
tinsert(aux_recent_searches, 1, O(
|
||||
'filter_string', filter_string,
|
||||
'prettified', prettified
|
||||
))
|
||||
@@ -105,7 +105,7 @@ handlers = {
|
||||
}
|
||||
|
||||
function get_auto_buy_validator()
|
||||
local validators = t
|
||||
local validators = T
|
||||
for _, filter in aux_auto_buy_filters do
|
||||
local queries, error = filter_util.queries(filter.filter_string)
|
||||
if queries then
|
||||
@@ -122,7 +122,7 @@ end
|
||||
function add_favorite(filter_string)
|
||||
local queries, error = filter_util.queries(filter_string)
|
||||
if queries then
|
||||
tinsert(aux_favorite_searches, 1, T(
|
||||
tinsert(aux_favorite_searches, 1, O(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
@@ -140,7 +140,7 @@ function add_auto_buy(filter_string)
|
||||
elseif size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(filter_string).blizzard.exact then
|
||||
print('Error: The automatic buyout filter does not support Blizzard filters')
|
||||
else
|
||||
tinsert(aux_auto_buy_filters, 1, T(
|
||||
tinsert(aux_auto_buy_filters, 1, O(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user