refactoring
This commit is contained in:
+13
-13
@@ -1,15 +1,15 @@
|
||||
local m, public, private = Aux.module'post'
|
||||
|
||||
local state
|
||||
private.state = nil
|
||||
|
||||
function private.process()
|
||||
if state.posted < state.count then
|
||||
if m.state.posted < m.state.count then
|
||||
|
||||
local stacking_complete, target_slot
|
||||
|
||||
Aux.stack.start(
|
||||
state.item_key,
|
||||
state.stack_size,
|
||||
m.state.item_key,
|
||||
m.state.stack_size,
|
||||
function(slot)
|
||||
stacking_complete = true
|
||||
target_slot = slot
|
||||
@@ -30,7 +30,7 @@ end
|
||||
|
||||
function private.post_auction(slot, k)
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
if item_info.item_key == state.item_key and Aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
|
||||
if item_info.item_key == m.state.item_key and Aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
|
||||
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
@@ -39,7 +39,7 @@ function private.post_auction(slot, k)
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
StartAuction(max(1, Aux.round(state.unit_start_price * item_info.aux_quantity)), Aux.round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
|
||||
StartAuction(max(1, Aux.round(m.state.unit_start_price * item_info.aux_quantity)), Aux.round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
|
||||
|
||||
local posted
|
||||
local listener = Aux.control.event_listener('CHAT_MSG_SYSTEM')
|
||||
@@ -51,7 +51,7 @@ function private.post_auction(slot, k)
|
||||
end)
|
||||
listener:start()
|
||||
Aux.control.wait_until(function() return posted end, function()
|
||||
state.posted = state.posted + 1
|
||||
m.state.posted = m.state.posted + 1
|
||||
return k()
|
||||
end)
|
||||
|
||||
@@ -61,13 +61,13 @@ function private.post_auction(slot, k)
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
if state then
|
||||
Aux.control.kill_thread(state.thread_id)
|
||||
if m.state then
|
||||
Aux.control.kill_thread(m.state.thread_id)
|
||||
|
||||
local callback = state.callback
|
||||
local posted = state.posted
|
||||
local callback = m.state.callback
|
||||
local posted = m.state.posted
|
||||
|
||||
state = nil
|
||||
m.state = nil
|
||||
|
||||
if callback then
|
||||
callback(posted)
|
||||
@@ -80,7 +80,7 @@ function public.start(item_key, stack_size, duration, unit_start_price, unit_buy
|
||||
|
||||
local thread_id = Aux.control.new_thread(m.process)
|
||||
|
||||
state = {
|
||||
m.state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
stack_size = stack_size,
|
||||
|
||||
+8
-9
@@ -2,8 +2,7 @@ local m, public, private = Aux.module'scan'
|
||||
|
||||
local PAGE_SIZE = 50
|
||||
|
||||
local state
|
||||
local threads = {}
|
||||
private.threads = {}
|
||||
|
||||
function private.total_pages(total_auctions)
|
||||
return math.ceil(total_auctions / PAGE_SIZE)
|
||||
@@ -20,7 +19,7 @@ function private.current_query()
|
||||
end
|
||||
|
||||
function private.current_thread()
|
||||
for _, thread in threads do
|
||||
for _, thread in m.threads do
|
||||
if thread.id == Aux.control.thread_id then
|
||||
return thread
|
||||
end
|
||||
@@ -28,14 +27,14 @@ function private.current_thread()
|
||||
end
|
||||
|
||||
function public.start(params)
|
||||
if threads[params.type] then
|
||||
m.abort(threads[params.type].id)
|
||||
if m.threads[params.type] then
|
||||
m.abort(m.threads[params.type].id)
|
||||
end
|
||||
|
||||
local thread_id = Aux.control.new_thread(function()
|
||||
return m.wait_for_callback(m.current_thread().params.on_scan_start, m.scan)
|
||||
end)
|
||||
threads[params.type] = {
|
||||
m.threads[params.type] = {
|
||||
id = thread_id,
|
||||
params = params,
|
||||
}
|
||||
@@ -44,10 +43,10 @@ end
|
||||
|
||||
function public.abort(scan_id)
|
||||
local aborted_threads = {}
|
||||
for t, thread in threads do
|
||||
for t, thread in m.threads do
|
||||
if not scan_id or thread.id == scan_id then
|
||||
Aux.control.kill_thread(thread.id)
|
||||
threads[t] = nil
|
||||
m.threads[t] = nil
|
||||
tinsert(aborted_threads, thread)
|
||||
end
|
||||
end
|
||||
@@ -146,7 +145,7 @@ function private.scan()
|
||||
m.wait_for_callback(m.current_thread().params.on_start_query, m.current_thread().query_index, m.process_query)
|
||||
else
|
||||
local on_complete = m.current_thread().params.on_complete
|
||||
threads[m.current_thread().params.type] = nil
|
||||
m.threads[m.current_thread().params.type] = nil
|
||||
if on_complete then
|
||||
return on_complete()
|
||||
end
|
||||
|
||||
+20
-20
@@ -1,6 +1,6 @@
|
||||
local m, public, private = Aux.module'stack'
|
||||
|
||||
local state
|
||||
private.state = nil
|
||||
|
||||
function private.stack_size(slot)
|
||||
local container_item_info = Aux.info.container_item(unpack(slot))
|
||||
@@ -24,7 +24,7 @@ end
|
||||
|
||||
function private.find_item_slot(partial)
|
||||
for slot in Aux.util.inventory() do
|
||||
if m.matching_item(slot, partial) and not Aux.util.table_eq(slot, state.target_slot) then
|
||||
if m.matching_item(slot, partial) and not Aux.util.table_eq(slot, m.state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,7 @@ end
|
||||
|
||||
function private.matching_item(slot, partial)
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == state.item_key and Aux.info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
return item_info and item_info.item_key == m.state.item_key and Aux.info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
end
|
||||
|
||||
function private.find_empty_slot()
|
||||
@@ -45,7 +45,7 @@ end
|
||||
|
||||
function private.find_charge_item_slot()
|
||||
for slot in Aux.util.inventory() do
|
||||
if m.matching_item(slot) and m.charges(slot) == state.target_size then
|
||||
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
@@ -69,35 +69,35 @@ end
|
||||
|
||||
function private.process()
|
||||
|
||||
if not state.target_slot or not m.matching_item(state.target_slot) then
|
||||
state.target_slot = m.find_item_slot()
|
||||
if not state.target_slot then
|
||||
if not m.state.target_slot or not m.matching_item(m.state.target_slot) then
|
||||
m.state.target_slot = m.find_item_slot()
|
||||
if not m.state.target_slot then
|
||||
return m.stop()
|
||||
end
|
||||
end
|
||||
|
||||
if m.charges(state.target_slot) then
|
||||
state.target_slot = m.find_charge_item_slot()
|
||||
if m.charges(m.state.target_slot) then
|
||||
m.state.target_slot = m.find_charge_item_slot()
|
||||
return m.stop()
|
||||
end
|
||||
|
||||
if m.stack_size(state.target_slot) > state.target_size then
|
||||
if m.stack_size(m.state.target_slot) > m.state.target_size then
|
||||
local slot = m.find_item_slot(true) or m.find_empty_slot()
|
||||
if slot then
|
||||
return m.move_item(
|
||||
state.target_slot,
|
||||
m.state.target_slot,
|
||||
slot,
|
||||
m.stack_size(state.target_slot) - state.target_size,
|
||||
m.stack_size(m.state.target_slot) - m.state.target_size,
|
||||
m.process
|
||||
)
|
||||
end
|
||||
elseif m.stack_size(state.target_slot) < state.target_size then
|
||||
elseif m.stack_size(m.state.target_slot) < m.state.target_size then
|
||||
local slot = m.find_item_slot()
|
||||
if slot then
|
||||
return m.move_item(
|
||||
slot,
|
||||
state.target_slot,
|
||||
state.target_size - m.stack_size(state.target_slot),
|
||||
m.state.target_slot,
|
||||
m.state.target_size - m.stack_size(m.state.target_slot),
|
||||
m.process
|
||||
)
|
||||
end
|
||||
@@ -107,15 +107,15 @@ function private.process()
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
if state then
|
||||
Aux.control.kill_thread(state.thread_id)
|
||||
if m.state then
|
||||
Aux.control.kill_thread(m.state.thread_id)
|
||||
|
||||
local callback, slot = state.callback, state.target_slot
|
||||
local callback, slot = m.state.callback, m.state.target_slot
|
||||
if slot and not m.matching_item(slot) then
|
||||
slot = nil
|
||||
end
|
||||
|
||||
state = nil
|
||||
m.state = nil
|
||||
|
||||
if callback then
|
||||
callback(slot)
|
||||
@@ -128,7 +128,7 @@ function public.start(item_key, size, callback)
|
||||
|
||||
local thread_id = Aux.control.new_thread(m.process)
|
||||
|
||||
state = {
|
||||
m.state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
target_size = size,
|
||||
|
||||
+24
-24
@@ -2,20 +2,20 @@ local m, public, private = Aux.module'tooltip'
|
||||
|
||||
aux_tooltip_value = true
|
||||
|
||||
local game_tooltip_hooks = {}
|
||||
local hooked_setter
|
||||
local game_tooltip_money
|
||||
private.game_tooltip_hooks = {}
|
||||
private.hooked_setter = nil
|
||||
private.game_tooltip_money = nil
|
||||
|
||||
function public.LOAD()
|
||||
for func, hook in game_tooltip_hooks do
|
||||
for func, hook in m.game_tooltip_hooks do
|
||||
local func, hook = func, hook
|
||||
Aux.hook(
|
||||
func,
|
||||
function(...)
|
||||
hooked_setter = true
|
||||
game_tooltip_money = 0
|
||||
m.hooked_setter = true
|
||||
m.game_tooltip_money = 0
|
||||
local results = {Aux.orig[GameTooltip][func](unpack(arg)) }
|
||||
hooked_setter = false
|
||||
m.hooked_setter = false
|
||||
hook(unpack(arg))
|
||||
return unpack(results)
|
||||
end,
|
||||
@@ -35,8 +35,8 @@ function public.LOAD()
|
||||
end
|
||||
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', function(...)
|
||||
if hooked_setter then
|
||||
game_tooltip_money = arg1
|
||||
if m.hooked_setter then
|
||||
m.game_tooltip_money = arg1
|
||||
else
|
||||
return orig(unpack(arg))
|
||||
end
|
||||
@@ -121,13 +121,13 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
if tooltip == GameTooltip and game_tooltip_money > 0 then
|
||||
SetTooltipMoney(tooltip, game_tooltip_money)
|
||||
if tooltip == GameTooltip and m.game_tooltip_money > 0 then
|
||||
SetTooltipMoney(tooltip, m.game_tooltip_money)
|
||||
end
|
||||
tooltip:Show()
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
function m.game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
local name, _, quality = GetItemInfo(itemstring)
|
||||
if name then
|
||||
local _, _, _, hex = GetItemQualityColor(quality)
|
||||
@@ -136,7 +136,7 @@ function game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
function m.game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
local link = GetAuctionItemLink(type, index)
|
||||
if link then
|
||||
local _, _, quantity = GetAuctionItemInfo(type, index)
|
||||
@@ -144,7 +144,7 @@ function game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetLootItem(slot)
|
||||
function m.game_tooltip_hooks:SetLootItem(slot)
|
||||
local link = GetLootSlotLink(slot)
|
||||
if link then
|
||||
local _, _, quantity = GetLootSlotInfo(slot)
|
||||
@@ -152,7 +152,7 @@ function game_tooltip_hooks:SetLootItem(slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
function m.game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
local link = GetQuestItemLink(qtype, slot)
|
||||
if link then
|
||||
local _, _, quantity = GetQuestItemInfo(qtype, slot)
|
||||
@@ -160,7 +160,7 @@ function game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
function m.game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
local link = GetQuestLogItemLink(qtype, slot)
|
||||
if link then
|
||||
local _, _, quantity = GetQuestLogRewardInfo(slot)
|
||||
@@ -168,7 +168,7 @@ function game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
function m.game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local _, quantity = GetContainerItemInfo(bag, slot)
|
||||
@@ -176,7 +176,7 @@ function game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetInboxItem(index)
|
||||
function m.game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
|
||||
local id = name and Aux.cache.item_id(name)
|
||||
@@ -188,14 +188,14 @@ function game_tooltip_hooks:SetInboxItem(index)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetInventoryItem(unit, slot)
|
||||
function m.game_tooltip_hooks:SetInventoryItem(unit, slot)
|
||||
local link = GetInventoryItemLink(unit, slot)
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetMerchantItem(slot)
|
||||
function m.game_tooltip_hooks:SetMerchantItem(slot)
|
||||
local link = GetMerchantItemLink(slot)
|
||||
if link then
|
||||
local _, _, _, quantity = GetMerchantItemInfo(slot)
|
||||
@@ -203,7 +203,7 @@ function game_tooltip_hooks:SetMerchantItem(slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
function m.game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link = GetCraftReagentItemLink(skill, slot)
|
||||
@@ -217,14 +217,14 @@ function game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetCraftSpell(slot)
|
||||
function m.game_tooltip_hooks:SetCraftSpell(slot)
|
||||
local link = GetCraftItemLink(slot)
|
||||
if link then
|
||||
m.extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
function m.game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link = GetTradeSkillReagentItemLink(skill, slot)
|
||||
@@ -238,7 +238,7 @@ function game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetAuctionSellItem()
|
||||
function m.game_tooltip_hooks:SetAuctionSellItem()
|
||||
local name, _, quantity, _, _, _ = GetAuctionSellItemInfo()
|
||||
if name then
|
||||
for slot in Aux.util.inventory() do
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ local m, public, private = Aux.module'control'
|
||||
|
||||
private.event_listeners = {}
|
||||
private.threads = {}
|
||||
public.thread_id = Aux.null
|
||||
public.thread_id = nil
|
||||
|
||||
function public.on_event()
|
||||
for listener, _ in m.event_listeners do
|
||||
@@ -28,7 +28,7 @@ function public.on_update()
|
||||
thread.k = nil
|
||||
m.thread_id = thread_id
|
||||
k()
|
||||
m.thread_id = Aux.null
|
||||
m.thread_id = nil
|
||||
if not thread.k then
|
||||
thread.killed = true
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local m, public, private = Aux.tab(3, 'auctions_tab')
|
||||
|
||||
local auction_records
|
||||
private.auction_records = nil
|
||||
|
||||
function public.FRAMES(f)
|
||||
private.create_frames = f
|
||||
@@ -24,7 +24,7 @@ function private.update_listing()
|
||||
return
|
||||
end
|
||||
|
||||
m.listing:SetDatabase(auction_records)
|
||||
m.listing:SetDatabase(m.auction_records)
|
||||
end
|
||||
|
||||
function public.scan_auctions()
|
||||
@@ -32,7 +32,7 @@ function public.scan_auctions()
|
||||
m.status_bar:update_status(0,0)
|
||||
m.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
auction_records = {}
|
||||
m.auction_records = {}
|
||||
m.update_listing()
|
||||
Aux.scan.start{
|
||||
type = 'owner',
|
||||
@@ -42,7 +42,7 @@ function public.scan_auctions()
|
||||
m.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
tinsert(m.auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
m.status_bar:update_status(100, 100)
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
local m, public, private = Aux.tab(4, 'bids_tab')
|
||||
|
||||
local auction_records
|
||||
private.auction_records = nil
|
||||
|
||||
function public.FRAMES(f)
|
||||
private.create_frames = f
|
||||
@@ -24,7 +24,7 @@ function private.update_listing()
|
||||
return
|
||||
end
|
||||
|
||||
m.listing:SetDatabase(auction_records)
|
||||
m.listing:SetDatabase(m.auction_records)
|
||||
end
|
||||
|
||||
function public.scan_bids()
|
||||
@@ -32,7 +32,7 @@ function public.scan_bids()
|
||||
m.status_bar:update_status(0,0)
|
||||
m.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
auction_records = {}
|
||||
m.auction_records = {}
|
||||
m.update_listing()
|
||||
Aux.scan.start{
|
||||
type = 'bidder',
|
||||
@@ -42,7 +42,7 @@ function public.scan_bids()
|
||||
m.status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages))
|
||||
end,
|
||||
on_auction = function(auction_record)
|
||||
tinsert(auction_records, auction_record)
|
||||
tinsert(m.auction_records, auction_record)
|
||||
end,
|
||||
on_complete = function()
|
||||
m.status_bar:update_status(100, 100)
|
||||
|
||||
+20
-21
@@ -3,10 +3,9 @@ local m, public, private = Aux.tab(2, 'post_tab')
|
||||
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'}}
|
||||
|
||||
local existing_auctions = {}
|
||||
local inventory_records
|
||||
local scan_id = 0
|
||||
|
||||
private.existing_auctions = {}
|
||||
private.inventory_records = nil
|
||||
private.scan_id = 0
|
||||
private.selected_item = nil
|
||||
private.refresh = nil
|
||||
|
||||
@@ -92,7 +91,7 @@ function private.update_inventory_listing()
|
||||
return
|
||||
end
|
||||
|
||||
Aux.item_listing.populate(m.item_listing, Aux.util.filter(inventory_records, function(record)
|
||||
Aux.item_listing.populate(m.item_listing, Aux.util.filter(m.inventory_records, function(record)
|
||||
local settings = m.read_settings(record.key)
|
||||
return record.aux_quantity > 0 and (not settings.hidden or m.show_hidden_checkbox:GetChecked())
|
||||
end))
|
||||
@@ -108,7 +107,7 @@ function private.update_auction_listing()
|
||||
local unit_start_price = m.get_unit_start_price()
|
||||
local unit_buyout_price = m.get_unit_buyout_price()
|
||||
|
||||
for i, auction_record in ipairs(existing_auctions[m.selected_item.key] or {}) do
|
||||
for i, auction_record in ipairs(m.existing_auctions[m.selected_item.key] or {}) do
|
||||
|
||||
local blizzard_bid_undercut, buyout_price_undercut = m.undercut(auction_record, m.stack_size_slider:GetValue())
|
||||
blizzard_bid_undercut = Aux.money.from_string(Aux.money.to_string(blizzard_bid_undercut, true, nil, 3))
|
||||
@@ -175,7 +174,7 @@ function private.update_auction_listing()
|
||||
end
|
||||
|
||||
function public.select_item(item_key)
|
||||
for _, inventory_record in ipairs(Aux.util.filter(inventory_records, function(record) return record.aux_quantity > 0 end)) do
|
||||
for _, inventory_record in ipairs(Aux.util.filter(m.inventory_records, function(record) return record.aux_quantity > 0 end)) do
|
||||
if inventory_record.key == item_key then
|
||||
m.set_item(inventory_record)
|
||||
break
|
||||
@@ -235,7 +234,7 @@ function private.post_auctions()
|
||||
|
||||
m.update_inventory_records()
|
||||
m.selected_item = nil
|
||||
for _, record in ipairs(inventory_records) do
|
||||
for _, record in ipairs(m.inventory_records) do
|
||||
if record.key == key then
|
||||
m.set_item(record)
|
||||
end
|
||||
@@ -393,7 +392,7 @@ function private.set_item(item)
|
||||
return
|
||||
end
|
||||
|
||||
Aux.scan.abort(scan_id)
|
||||
Aux.scan.abort(m.scan_id)
|
||||
|
||||
m.selected_item = item
|
||||
|
||||
@@ -409,7 +408,7 @@ function private.set_item(item)
|
||||
m.unit_start_price:SetText(Aux.money.to_string(settings.start_price, true, nil, 3, nil, true))
|
||||
m.unit_buyout_price:SetText(Aux.money.to_string(settings.buyout_price, true, nil, 3, nil, true))
|
||||
|
||||
if not existing_auctions[m.selected_item.key] then
|
||||
if not m.existing_auctions[m.selected_item.key] then
|
||||
m.refresh_entries()
|
||||
end
|
||||
|
||||
@@ -418,7 +417,7 @@ function private.set_item(item)
|
||||
end
|
||||
|
||||
function private.update_inventory_records()
|
||||
inventory_records = {}
|
||||
m.inventory_records = {}
|
||||
m.refresh = true
|
||||
|
||||
local auction_candidate_map = {}
|
||||
@@ -462,11 +461,11 @@ function private.update_inventory_records()
|
||||
end
|
||||
end
|
||||
|
||||
inventory_records = {}
|
||||
m.inventory_records = {}
|
||||
for _, auction_candidate in pairs(auction_candidate_map) do
|
||||
tinsert(inventory_records, auction_candidate)
|
||||
tinsert(m.inventory_records, auction_candidate)
|
||||
end
|
||||
sort(inventory_records, function(a, b) return a.name < b.name end)
|
||||
sort(m.inventory_records, function(a, b) return a.name < b.name end)
|
||||
m.refresh = true
|
||||
end
|
||||
|
||||
@@ -475,14 +474,14 @@ function private.refresh_entries()
|
||||
local item_id, suffix_id = m.selected_item.item_id, m.selected_item.suffix_id
|
||||
local item_key = item_id..':'..suffix_id
|
||||
|
||||
existing_auctions[item_key] = nil
|
||||
m.existing_auctions[item_key] = nil
|
||||
|
||||
local query = Aux.scan_util.item_query(item_id)
|
||||
|
||||
m.status_bar:update_status(0,0)
|
||||
m.status_bar:set_text('Scanning auctions...')
|
||||
|
||||
scan_id = Aux.scan.start{
|
||||
m.scan_id = Aux.scan.start{
|
||||
type = 'list',
|
||||
ignore_owner = true,
|
||||
queries = { query },
|
||||
@@ -503,13 +502,13 @@ function private.refresh_entries()
|
||||
end
|
||||
end,
|
||||
on_abort = function()
|
||||
existing_auctions[item_key] = nil
|
||||
m.existing_auctions[item_key] = nil
|
||||
m.update_historical_value_button()
|
||||
m.status_bar:update_status(100, 100)
|
||||
m.status_bar:set_text('Done Scanning')
|
||||
end,
|
||||
on_complete = function()
|
||||
existing_auctions[item_key] = existing_auctions[item_key] or {}
|
||||
m.existing_auctions[item_key] = m.existing_auctions[item_key] or {}
|
||||
m.refresh = true
|
||||
m.status_bar:update_status(100, 100)
|
||||
m.status_bar:set_text('Done Scanning')
|
||||
@@ -519,9 +518,9 @@ function private.refresh_entries()
|
||||
end
|
||||
|
||||
function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner)
|
||||
existing_auctions[key] = existing_auctions[key] or {}
|
||||
m.existing_auctions[key] = m.existing_auctions[key] or {}
|
||||
local entry
|
||||
for _, existing_entry in ipairs(existing_auctions[key]) do
|
||||
for _, existing_entry in ipairs(m.existing_auctions[key]) do
|
||||
if unit_blizzard_bid == existing_entry.unit_blizzard_bid and unit_buyout_price == existing_entry.unit_buyout_price and aux_quantity == existing_entry.stack_size and duration == existing_entry.duration and Aux.is_player(owner) == existing_entry.own then
|
||||
entry = existing_entry
|
||||
end
|
||||
@@ -536,7 +535,7 @@ function private.record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyou
|
||||
own = Aux.is_player(owner),
|
||||
count = 0,
|
||||
}
|
||||
tinsert(existing_auctions[key], entry)
|
||||
tinsert(m.existing_auctions[key], entry)
|
||||
end
|
||||
|
||||
entry.count = entry.count + 1
|
||||
|
||||
+16
-20
@@ -25,14 +25,14 @@ function public.wipe(table)
|
||||
while getn(table) > 0 do
|
||||
tremove(table)
|
||||
end
|
||||
for k, _ in pairs(table) do
|
||||
for k, _ in table do
|
||||
table[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function public.copy_table(table)
|
||||
local copy = {}
|
||||
for k, v in pairs(table) do
|
||||
for k, v in table do
|
||||
copy[k] = v
|
||||
end
|
||||
return copy
|
||||
@@ -69,20 +69,16 @@ function public.inventory()
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local bag_types = { GetAuctionItemSubClasses(3) }
|
||||
function public.bag_type(bag)
|
||||
if bag == 0 then
|
||||
return 1
|
||||
end
|
||||
|
||||
function public.bag_type(bag)
|
||||
if bag == 0 then
|
||||
return 1
|
||||
end
|
||||
|
||||
local link = GetInventoryItemLink('player', ContainerIDToInventoryID(bag))
|
||||
if link then
|
||||
local item_id = Aux.info.parse_hyperlink(GetInventoryItemLink('player', ContainerIDToInventoryID(bag)))
|
||||
local item_info = Aux.info.item(item_id)
|
||||
return Aux.item_subclass_index(3, item_info.subclass)
|
||||
end
|
||||
local link = GetInventoryItemLink('player', ContainerIDToInventoryID(bag))
|
||||
if link then
|
||||
local item_id = Aux.info.parse_hyperlink(GetInventoryItemLink('player', ContainerIDToInventoryID(bag)))
|
||||
local item_info = Aux.info.item(item_id)
|
||||
return Aux.item_subclass_index(3, item_info.subclass)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -144,7 +140,7 @@ end
|
||||
|
||||
function public.set_size(set)
|
||||
local size = 0
|
||||
for _,_ in pairs(set) do
|
||||
for _,_ in set do
|
||||
size = size + 1
|
||||
end
|
||||
return size
|
||||
@@ -152,7 +148,7 @@ end
|
||||
|
||||
function public.set_to_array(set)
|
||||
local array = {}
|
||||
for element, _ in pairs(set) do
|
||||
for element, _ in set do
|
||||
tinsert(array, element)
|
||||
end
|
||||
return array
|
||||
@@ -176,7 +172,7 @@ end
|
||||
|
||||
function public.set_filter(xs, p)
|
||||
local ys = {}
|
||||
for x, _ in pairs(xs) do
|
||||
for x, _ in xs do
|
||||
if p(x) then
|
||||
m.set_add(ys, x)
|
||||
end
|
||||
@@ -196,7 +192,7 @@ end
|
||||
|
||||
function public.map(xs, f)
|
||||
local ys = {}
|
||||
for _, x in ipairs(xs) do
|
||||
for _, x in xs do
|
||||
tinsert(ys, f(x))
|
||||
end
|
||||
return ys
|
||||
@@ -313,7 +309,7 @@ function public.set()
|
||||
|
||||
function self:values()
|
||||
local values = {}
|
||||
for value, _ in pairs(data) do
|
||||
for value, _ in data do
|
||||
tinsert(values, value)
|
||||
end
|
||||
return values
|
||||
|
||||
Reference in New Issue
Block a user