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