refactoring
This commit is contained in:
+7
-7
@@ -56,11 +56,11 @@ do
|
||||
__newindex=function(_, _, value) return f(value) end, __unm=function(self) return self end,
|
||||
})
|
||||
end
|
||||
local temp, perm = modifier(function(t) transient[t] = true; return t end), modifier(function(t) transient[t] = nil; return t end)
|
||||
public.temp() -- TODO or 'auto' 'free' 'release' 'unlock'?
|
||||
local temp, perm = modifier(function(t) transient[t] = true; return setmetatable(t, nil) end), modifier(function(t) transient[t] = nil; return t end)
|
||||
public.temp() -- TODO or 'auto' 'free' 'release'?
|
||||
function accessor() return temp end
|
||||
function mutator(t) return temp(t) end
|
||||
public.perm() -- TODO or 'persist' 'lock'??
|
||||
public.perm()
|
||||
function accessor() return perm end
|
||||
function mutator(t) return perm(t) end
|
||||
|
||||
@@ -87,7 +87,7 @@ do
|
||||
end
|
||||
do
|
||||
local mt = collector_mt(function(self, value)
|
||||
rawset(self, value, true)
|
||||
self[value] = true
|
||||
end)
|
||||
function public.accessor.set()
|
||||
return setmetatable(t, mt)
|
||||
@@ -97,7 +97,7 @@ do
|
||||
local key
|
||||
local mt = collector_mt(function(self, value)
|
||||
if key ~= nil then
|
||||
rawset(self, key, value)
|
||||
self[key] = value
|
||||
key = nil
|
||||
else
|
||||
key = value
|
||||
@@ -298,7 +298,7 @@ do
|
||||
end
|
||||
function ADDON_LOADED.Blizzard_CraftUI()
|
||||
hook('CraftFrame_SetSelection', function(...) temp=arg
|
||||
local results = {orig.CraftFrame_SetSelection(unpack(arg))}
|
||||
local results = temp-{orig.CraftFrame_SetSelection(unpack(arg))}
|
||||
local id = GetCraftSelectionIndex()
|
||||
local reagent_count = GetCraftNumReagents(id)
|
||||
local total_cost = 0
|
||||
@@ -325,7 +325,7 @@ do
|
||||
end
|
||||
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
||||
hook('TradeSkillFrame_SetSelection', function(...) temp=arg
|
||||
local results = {orig.TradeSkillFrame_SetSelection(unpack(arg))}
|
||||
local results = temp-{orig.TradeSkillFrame_SetSelection(unpack(arg))}
|
||||
local id = GetTradeSkillSelectionIndex()
|
||||
local reagent_count = GetTradeSkillNumReagents(id)
|
||||
local total_cost = 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module 'auction_listing' import 'gui'
|
||||
module 'auction_listing' import 'gui' 'sorting' 'history' 'money'
|
||||
|
||||
_g.aux_price_per_unit = false
|
||||
|
||||
|
||||
+8
-8
@@ -3,7 +3,7 @@ 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 = {}
|
||||
existing_auctions = t
|
||||
mutable.inventory_records = nil
|
||||
mutable.scan_id = 0
|
||||
mutable.selected_item = nil
|
||||
@@ -35,7 +35,7 @@ function USE_ITEM(item_info)
|
||||
select_item(item_info.item_key)
|
||||
end
|
||||
|
||||
function default_settings()
|
||||
function accessor.default_settings()
|
||||
return {
|
||||
duration = DURATION_8,
|
||||
stack_size = 1,
|
||||
@@ -48,13 +48,13 @@ end
|
||||
function read_settings(item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
local dataset = persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
dataset.post = dataset.post or t
|
||||
|
||||
local settings
|
||||
if dataset.post[item_key] then
|
||||
settings = persistence.read(settings_schema, dataset.post[item_key])
|
||||
else
|
||||
settings = default_settings()
|
||||
settings = default_settings
|
||||
end
|
||||
return settings
|
||||
end
|
||||
@@ -63,7 +63,7 @@ function write_settings(settings, item_key)
|
||||
item_key = item_key or selected_item.key
|
||||
|
||||
local dataset = persistence.load_dataset()
|
||||
dataset.post = dataset.post or {}
|
||||
dataset.post = dataset.post or t
|
||||
|
||||
dataset.post[item_key] = persistence.write(settings_schema, settings)
|
||||
end
|
||||
@@ -96,12 +96,12 @@ end
|
||||
|
||||
function update_auction_listing()
|
||||
if not ACTIVE then return end
|
||||
local auction_rows = {}
|
||||
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 {} do
|
||||
for i, auction_record in existing_auctions[selected_item.key] or tt 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))
|
||||
@@ -345,7 +345,7 @@ end
|
||||
|
||||
function unit_vendor_price(item_key)
|
||||
|
||||
for slot in info.inventory do
|
||||
for slot in info.inventory do temp=slot
|
||||
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
if item_info and item_info.item_key == item_key then
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module 'search_tab' import 'scan'
|
||||
module 'search_tab' import 'scan' 'scan_util'
|
||||
|
||||
StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = {
|
||||
text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.',
|
||||
|
||||
+3
-3
@@ -19,14 +19,14 @@ do
|
||||
end
|
||||
|
||||
do
|
||||
local formal_parameters = {}
|
||||
local formal_parameters = t
|
||||
for i=1,9 do
|
||||
local key = '_'..i
|
||||
public[key] = {}
|
||||
public[key] = t
|
||||
formal_parameters[_m[key]] = i
|
||||
end
|
||||
local function helper(f, arg1, arg2)
|
||||
local params = {}
|
||||
local params = t
|
||||
for i=1,arg1.n do
|
||||
if formal_parameters[arg1[i]] then
|
||||
tinsert(params, arg2[formal_parameters[arg1[i]]])
|
||||
|
||||
+19
-22
@@ -33,7 +33,7 @@ do
|
||||
INVTYPE_TABARD = {19},
|
||||
}
|
||||
function public.inventory_index(slot)
|
||||
return unpack(inventory_index_map[slot] or {})
|
||||
return unpack(inventory_index_map[slot] or tt)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -191,7 +191,7 @@ function public.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, {left_text='Currently Equipped', left_color={ 0.5, 0.5, 0.5 }})
|
||||
tinsert(tooltips[1], 1, temp-object :left_text 'Currently Equipped' :left_color(temp-{.5, .5, .5}))
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
ShoppingTooltip1:Show()
|
||||
@@ -199,7 +199,7 @@ function public.set_shopping_tooltip(slot)
|
||||
end
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, {left_text='Currently Equipped', left_color={ 0.5, 0.5, 0.5 }})
|
||||
tinsert(tooltips[2], 1, temp-object :left_text 'Currently Equipped' :left_color(temp-{.5, .5, .5}))
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT')
|
||||
load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
ShoppingTooltip2:Show()
|
||||
@@ -237,7 +237,7 @@ function public.load_tooltip(frame, tooltip)
|
||||
frame:AddLine(line.left_text, line.left_color[1], line.left_color[2], line.left_color[3], true)
|
||||
end
|
||||
end
|
||||
for i =1,getn(tooltip) do -- TODO why is this needed?
|
||||
for i=1,getn(tooltip) do -- TODO why is this needed?
|
||||
_g[frame:GetName()..'TextLeft'..i]:SetJustifyH('LEFT')
|
||||
_g[frame:GetName()..'TextRight'..i]:SetJustifyH('LEFT')
|
||||
end
|
||||
@@ -357,24 +357,22 @@ end
|
||||
|
||||
function public.item(item_id, suffix_id)
|
||||
local itemstring = 'item:'..(item_id or 0)..':0:'..(suffix_id or 0)..':0'
|
||||
for name, itemstring, quality, level, class, subclass, max_stack, slot, texture in present(GetItemInfo(itemstring)) do
|
||||
return {
|
||||
name = name,
|
||||
itemstring = itemstring,
|
||||
quality = quality,
|
||||
level = level,
|
||||
class = class,
|
||||
subclass = subclass,
|
||||
slot = slot,
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
}
|
||||
end
|
||||
return cache.item_info(item_id)
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and {
|
||||
name = name,
|
||||
itemstring = itemstring,
|
||||
quality = quality,
|
||||
level = level,
|
||||
class = class,
|
||||
subclass = subclass,
|
||||
slot = slot,
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
} or cache.item_info(item_id)
|
||||
end
|
||||
|
||||
function public.item_class_index(item_class)
|
||||
for i, class in {GetAuctionItemClasses()} do
|
||||
for i, class in temp-{GetAuctionItemClasses()} do
|
||||
if strupper(class) == strupper(item_class) then
|
||||
return i, class
|
||||
end
|
||||
@@ -382,7 +380,7 @@ function public.item_class_index(item_class)
|
||||
end
|
||||
|
||||
function public.item_subclass_index(class_index, item_subclass)
|
||||
for i, subclass in {GetAuctionItemSubClasses(class_index)} do
|
||||
for i, subclass in temp-{GetAuctionItemSubClasses(class_index)} do
|
||||
if strupper(subclass) == strupper(item_subclass) then
|
||||
return i, subclass
|
||||
end
|
||||
@@ -390,7 +388,7 @@ function public.item_subclass_index(class_index, item_subclass)
|
||||
end
|
||||
|
||||
function public.item_slot_index(class_index, subclass_index, slot_name)
|
||||
for i, slot in {GetAuctionInvTypes(class_index, subclass_index)} do
|
||||
for i, slot in temp-{GetAuctionInvTypes(class_index, subclass_index)} do
|
||||
if strupper(_g[slot]) == strupper(slot_name) then
|
||||
return i, _g[slot]
|
||||
end
|
||||
@@ -424,7 +422,6 @@ function public.bag_type(bag)
|
||||
for link in present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
|
||||
local item_id = parse_link(link)
|
||||
local item_info = item(item_id)
|
||||
log(link, item_id, item_info, item_info.subclass)
|
||||
return item_subclass_index(3, item_info.subclass)
|
||||
end
|
||||
end
|
||||
+10
-15
@@ -1,4 +1,4 @@
|
||||
module 'scan_util'
|
||||
module 'scan_util' import 'info'
|
||||
|
||||
function public.find(auction_record, status_bar, on_abort, on_failure, on_success)
|
||||
|
||||
@@ -15,17 +15,13 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
|
||||
local blizzard_query1 = copy(auction_record.blizzard_query)
|
||||
blizzard_query1.first_page = auction_record.page
|
||||
blizzard_query1.last_page = auction_record.page
|
||||
tinsert(queries, {
|
||||
blizzard_query = blizzard_query1,
|
||||
})
|
||||
tinsert(queries, -object :blizzard_query(blizzard_query1))
|
||||
|
||||
if auction_record.page > 0 then
|
||||
local blizzard_query2 = copy(auction_record.blizzard_query)
|
||||
blizzard_query2.first_page = auction_record.page - 1
|
||||
blizzard_query2.last_page = auction_record.page - 1
|
||||
tinsert(queries, {
|
||||
blizzard_query = blizzard_query1,
|
||||
})
|
||||
tinsert(queries, -object :blizzard_query(blizzard_query2))
|
||||
end
|
||||
|
||||
local item_query = item_query(auction_record.item_id, 1, 1)
|
||||
@@ -41,7 +37,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
|
||||
queries = queries,
|
||||
on_scan_start = function()
|
||||
status_bar:update_status(0, 0)
|
||||
status_bar:set_text('Searching auction...')
|
||||
status_bar:set_text 'Searching auction...'
|
||||
end,
|
||||
on_start_query = function(query_index)
|
||||
status_bar:update_status((query_index - 1) / getn(queries) * 100, 0)
|
||||
@@ -51,20 +47,20 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
|
||||
found = true
|
||||
ctrl.suspend()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction found')
|
||||
status_bar:set_text 'Auction found'
|
||||
return on_success(auction_record.index)
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
if not found then
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction not found')
|
||||
status_bar:set_text 'Auction not found'
|
||||
return on_abort()
|
||||
end
|
||||
end,
|
||||
on_complete = function()
|
||||
status_bar:update_status(100, 100)
|
||||
status_bar:set_text('Auction not found')
|
||||
status_bar:set_text 'Auction not found'
|
||||
return on_failure()
|
||||
end,
|
||||
}
|
||||
@@ -78,9 +74,8 @@ function public.item_query(item_id, first_page, last_page)
|
||||
local query = filter_util.query(item_info.name..'/exact')
|
||||
query.blizzard_query.first_page = first_page
|
||||
query.blizzard_query.last_page = last_page
|
||||
return {
|
||||
validator = query.validator,
|
||||
blizzard_query = query.blizzard_query,
|
||||
}
|
||||
return -object
|
||||
:validator(query.validator)
|
||||
:blizzard_query(query.blizzard_query)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user