module refactoring
This commit is contained in:
+13
-15
@@ -1,9 +1,7 @@
|
||||
module 'aux.util.info'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
local MIN_ITEM_ID = 1
|
||||
@@ -18,17 +16,17 @@ _G.aux_auctionable_items = {}
|
||||
_G.aux_merchant_buy = {}
|
||||
_G.aux_merchant_sell = {}
|
||||
|
||||
function handle.LOAD()
|
||||
function aux.handle.LOAD()
|
||||
scan_wdb()
|
||||
|
||||
event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
event_listener('MERCHANT_CLOSED', on_merchant_closed)
|
||||
event_listener('MERCHANT_UPDATE', on_merchant_update)
|
||||
event_listener('BAG_UPDATE', on_bag_update)
|
||||
aux.event_listener('MERCHANT_SHOW', on_merchant_show)
|
||||
aux.event_listener('MERCHANT_CLOSED', on_merchant_closed)
|
||||
aux.event_listener('MERCHANT_UPDATE', on_merchant_update)
|
||||
aux.event_listener('BAG_UPDATE', on_bag_update)
|
||||
|
||||
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update)
|
||||
|
||||
event_listener('NEW_AUCTION_UPDATE', function()
|
||||
aux.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
local data = auction_sell_item()
|
||||
if data then
|
||||
local item_id = item_id(data.name)
|
||||
@@ -44,8 +42,8 @@ do
|
||||
function M.is_player(name)
|
||||
return not not characters[name]
|
||||
end
|
||||
function handle.LOAD2()
|
||||
characters = realm_data'characters'
|
||||
function aux.handle.LOAD2()
|
||||
characters = aux.realm_data'characters'
|
||||
for k, v in characters do
|
||||
if GetTime() > v + 60 * 60 * 24 * 30 then
|
||||
characters[k] = nil
|
||||
@@ -199,7 +197,7 @@ function scan_wdb(item_id)
|
||||
end
|
||||
|
||||
if item_id <= MAX_ITEM_ID then
|
||||
thread(when, later(.5), scan_wdb, item_id)
|
||||
aux.thread(when, aux.later(.5), scan_wdb, item_id)
|
||||
else
|
||||
sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
@@ -208,12 +206,12 @@ end
|
||||
function M.populate_wdb(item_id)
|
||||
item_id = item_id or MIN_ITEM_ID
|
||||
if item_id > MAX_ITEM_ID then
|
||||
print'Cache populated.'
|
||||
aux.print('Cache populated.')
|
||||
return
|
||||
end
|
||||
if not GetItemInfo('item:' .. item_id) then
|
||||
print('Fetching item ' .. item_id .. '.')
|
||||
aux.print('Fetching item ' .. item_id .. '.')
|
||||
AuxTooltip:SetHyperlink('item:' .. item_id)
|
||||
end
|
||||
thread(populate_wdb, item_id + 1)
|
||||
aux.thread(populate_wdb, item_id + 1)
|
||||
end
|
||||
+11
-13
@@ -1,16 +1,14 @@
|
||||
module 'aux.core.crafting'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local history = require 'aux.core.history'
|
||||
local search_tab = require 'aux.tabs.search'
|
||||
|
||||
function handle.LOAD()
|
||||
event_listener('ADDON_LOADED', function()
|
||||
function aux.handle.LOAD()
|
||||
aux.event_listener('ADDON_LOADED', function()
|
||||
if arg1 == 'Blizzard_CraftUI' then
|
||||
craft_ui_loaded()
|
||||
elseif arg1 == 'Blizzard_TradeSkillUI' then
|
||||
@@ -29,8 +27,8 @@ do
|
||||
local function hook_quest_item(f)
|
||||
f:SetScript('OnMouseUp', function()
|
||||
if arg1 == 'RightButton' then
|
||||
if get_active_tab() then
|
||||
set_tab(1)
|
||||
if aux.get_tab() then
|
||||
aux.set_tab(1)
|
||||
search_tab.set_filter(_G[this:GetName() .. 'Name']:GetText() .. '/exact')
|
||||
search_tab.execute(nil, false)
|
||||
end
|
||||
@@ -38,8 +36,8 @@ do
|
||||
end)
|
||||
end
|
||||
function craft_ui_loaded()
|
||||
hook('CraftFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||
aux.hook('CraftFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(aux.orig.CraftFrame_SetSelection(unpack(arg)))
|
||||
local id = GetCraftSelectionIndex()
|
||||
local total_cost = 0
|
||||
for i = 1, GetCraftNumReagents(id) do
|
||||
@@ -49,7 +47,7 @@ do
|
||||
break
|
||||
end
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetCraftReagentInfo(id, i))
|
||||
local count = aux.select(3, GetCraftReagentInfo(id, i))
|
||||
local _, price, limited = info.merchant_info(item_id)
|
||||
local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id)
|
||||
if not value then
|
||||
@@ -67,8 +65,8 @@ do
|
||||
end
|
||||
end
|
||||
function trade_skill_ui_loaded()
|
||||
hook('TradeSkillFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||
aux.hook('TradeSkillFrame_SetSelection', T.vararg-function(arg)
|
||||
local ret = T.temp-T.list(aux.orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||
local id = GetTradeSkillSelectionIndex()
|
||||
local total_cost = 0
|
||||
for i = 1, GetTradeSkillNumReagents(id) do
|
||||
@@ -78,7 +76,7 @@ do
|
||||
break
|
||||
end
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetTradeSkillReagentInfo(id, i))
|
||||
local count = aux.select(3, GetTradeSkillReagentInfo(id, i))
|
||||
local _, price, limited = info.merchant_info(item_id)
|
||||
local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id)
|
||||
if not value then
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
module 'aux.core.disenchant'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local history = require 'aux.core.history'
|
||||
|
||||
local UNCOMMON, RARE, EPIC = 2, 3, 4
|
||||
|
||||
+5
-6
@@ -1,8 +1,7 @@
|
||||
module 'aux.core.history'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
local aux = require 'aux'
|
||||
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
@@ -10,8 +9,8 @@ local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='n
|
||||
|
||||
local value_cache = {}
|
||||
|
||||
function handle.LOAD2()
|
||||
data = faction_data'history'
|
||||
function aux.handle.LOAD2()
|
||||
data = aux.faction_data'history'
|
||||
end
|
||||
|
||||
do
|
||||
@@ -50,7 +49,7 @@ end
|
||||
function M.process_auction(auction_record)
|
||||
local item_record = read_record(auction_record.item_key)
|
||||
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
|
||||
if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or huge) then
|
||||
if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or aux.huge) then
|
||||
item_record.daily_min_buyout = unit_buyout_price
|
||||
write_record(auction_record.item_key, item_record)
|
||||
end
|
||||
@@ -67,7 +66,7 @@ function M.value(item_key)
|
||||
if getn(item_record.data_points) > 0 then
|
||||
local total_weight, weighted_values = 0, T.temp-T.acquire()
|
||||
for _, data_point in item_record.data_points do
|
||||
local weight = .99 ^ round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24))
|
||||
local weight = .99 ^ aux.round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24))
|
||||
total_weight = total_weight + weight
|
||||
tinsert(weighted_values, T.map('value', data_point.value, 'weight', weight))
|
||||
end
|
||||
|
||||
+10
-11
@@ -1,13 +1,12 @@
|
||||
module 'aux.core.post'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local stack = require 'aux.core.stack'
|
||||
|
||||
local state
|
||||
|
||||
function handle.CLOSE()
|
||||
function aux.handle.CLOSE()
|
||||
stop()
|
||||
end
|
||||
|
||||
@@ -16,8 +15,8 @@ function process()
|
||||
|
||||
local stacking_complete
|
||||
|
||||
local send_signal, signal_received = signal()
|
||||
when(signal_received, function()
|
||||
local send_signal, signal_received = aux.signal()
|
||||
aux.when(signal_received, function()
|
||||
local slot = signal_received()[1]
|
||||
if slot then
|
||||
return post_auction(slot, process)
|
||||
@@ -43,16 +42,16 @@ function post_auction(slot, k)
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
|
||||
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)
|
||||
|
||||
local send_signal, signal_received = signal()
|
||||
when(signal_received, function()
|
||||
local send_signal, signal_received = aux.signal()
|
||||
aux.when(signal_received, function()
|
||||
state.posted = state.posted + 1
|
||||
return k()
|
||||
end)
|
||||
|
||||
local posted
|
||||
event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||
aux.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||
if arg1 == ERR_AUCTION_STARTED then
|
||||
send_signal()
|
||||
kill()
|
||||
@@ -65,7 +64,7 @@ end
|
||||
|
||||
function M.stop()
|
||||
if state then
|
||||
kill_thread(state.thread_id)
|
||||
aux.kill_thread(state.thread_id)
|
||||
|
||||
local callback = state.callback
|
||||
local posted = state.posted
|
||||
@@ -81,7 +80,7 @@ end
|
||||
function M.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
|
||||
stop()
|
||||
state = {
|
||||
thread_id = thread(process),
|
||||
thread_id = aux.thread(process),
|
||||
item_key = item_key,
|
||||
stack_size = stack_size,
|
||||
duration = duration,
|
||||
|
||||
+26
-28
@@ -1,15 +1,13 @@
|
||||
module 'aux.core.scan'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local history = require 'aux.core.history'
|
||||
|
||||
local PAGE_SIZE = 50
|
||||
|
||||
function handle.CLOSE()
|
||||
function aux.handle.CLOSE()
|
||||
abort()
|
||||
end
|
||||
|
||||
@@ -21,8 +19,8 @@ do
|
||||
if old_state then
|
||||
abort(old_state.id)
|
||||
end
|
||||
do (params.on_scan_start or nop)() end
|
||||
local thread_id = thread(scan)
|
||||
do (params.on_scan_start or pass)() end
|
||||
local thread_id = aux.thread(scan)
|
||||
scan_states[params.type] = {
|
||||
id = thread_id,
|
||||
params = params,
|
||||
@@ -34,13 +32,13 @@ do
|
||||
local aborted = T.acquire()
|
||||
for type, state in scan_states do
|
||||
if not scan_id or state.id == scan_id then
|
||||
kill_thread(state.id)
|
||||
aux.kill_thread(state.id)
|
||||
scan_states[type] = nil
|
||||
tinsert(aborted, state)
|
||||
end
|
||||
end
|
||||
for _, state in aborted do
|
||||
do (state.params.on_abort or nop)() end
|
||||
do (state.params.on_abort or pass)() end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,12 +49,12 @@ do
|
||||
function complete()
|
||||
local on_complete = get_state().params.on_complete
|
||||
scan_states[get_state().params.type] = nil
|
||||
do (on_complete or nop)() end
|
||||
do (on_complete or pass)() end
|
||||
end
|
||||
|
||||
function get_state()
|
||||
for _, state in scan_states do
|
||||
if state.id == thread_id() then
|
||||
if state.id == aux.thread_id() then
|
||||
return state
|
||||
end
|
||||
end
|
||||
@@ -80,9 +78,9 @@ end
|
||||
function scan()
|
||||
get_state().query_index = get_state().query_index and get_state().query_index + 1 or 1
|
||||
if get_query() and not get_state().stopped then
|
||||
do (get_state().params.on_start_query or nop)(get_state().query_index) end
|
||||
do (get_state().params.on_start_query or pass)(get_state().query_index) end
|
||||
if get_query().blizzard_query then
|
||||
if (get_query().blizzard_query.first_page or 0) <= (get_query().blizzard_query.last_page or huge) then
|
||||
if (get_query().blizzard_query.first_page or 0) <= (get_query().blizzard_query.last_page or aux.huge) then
|
||||
get_state().page = get_query().blizzard_query.first_page or 0
|
||||
return submit_query()
|
||||
end
|
||||
@@ -122,7 +120,7 @@ do
|
||||
if get_state().params.type ~= 'list' then
|
||||
return submit()
|
||||
else
|
||||
return when(CanSendAuctionQuery, submit)
|
||||
return aux.when(CanSendAuctionQuery, submit)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -131,7 +129,7 @@ function scan_page(i)
|
||||
i = i or 1
|
||||
|
||||
if i > PAGE_SIZE then
|
||||
do (get_state().params.on_page_scanned or nop)() end
|
||||
do (get_state().params.on_page_scanned or pass)() end
|
||||
if get_query().blizzard_query and get_state().page < last_page(get_state().total_auctions) then
|
||||
get_state().page = get_state().page + 1
|
||||
return submit_query()
|
||||
@@ -149,12 +147,12 @@ function scan_page(i)
|
||||
|
||||
history.process_auction(auction_info)
|
||||
|
||||
if (get_state().params.auto_buy_validator or nop)(auction_info) then
|
||||
local send_signal, signal_received = signal()
|
||||
when(signal_received, scan_page, i)
|
||||
return place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, send_signal)
|
||||
if (get_state().params.auto_buy_validator or pass)(auction_info) then
|
||||
local send_signal, signal_received = aux.signal()
|
||||
aux.when(signal_received, scan_page, i)
|
||||
return aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, send_signal)
|
||||
elseif not get_query().validator or get_query().validator(auction_info) then
|
||||
do (get_state().params.on_auction or nop)(auction_info) end
|
||||
do (get_state().params.on_auction or pass)(auction_info) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -163,7 +161,7 @@ end
|
||||
|
||||
function wait_for_results()
|
||||
if get_state().params.type == 'bidder' then
|
||||
return when(function() return bids_loaded() end, accept_results)
|
||||
return aux.when(function() return aux.bids_loaded() end, accept_results)
|
||||
elseif get_state().params.type == 'owner' then
|
||||
return wait_for_owner_results()
|
||||
elseif get_state().params.type == 'list' then
|
||||
@@ -174,7 +172,7 @@ end
|
||||
function accept_results()
|
||||
_, get_state().total_auctions = GetNumAuctionItems(get_state().params.type)
|
||||
do
|
||||
(get_state().params.on_page_loaded or nop)(
|
||||
(get_state().params.on_page_loaded or pass)(
|
||||
get_state().page - (get_query().blizzard_query.first_page or 0) + 1,
|
||||
last_page(get_state().total_auctions) - (get_query().blizzard_query.first_page or 0) + 1,
|
||||
total_pages(get_state().total_auctions) - 1
|
||||
@@ -184,24 +182,24 @@ function accept_results()
|
||||
end
|
||||
|
||||
function wait_for_owner_results()
|
||||
if get_state().page == current_owner_page() then
|
||||
if get_state().page == aux.current_owner_page() then
|
||||
return accept_results()
|
||||
else
|
||||
local updated
|
||||
on_next_event('AUCTION_OWNED_LIST_UPDATE', function() updated = true end)
|
||||
return when(function() return updated end, accept_results)
|
||||
aux.on_next_event('AUCTION_OWNED_LIST_UPDATE', function() updated = true end)
|
||||
return aux.when(function() return updated end, accept_results)
|
||||
end
|
||||
end
|
||||
|
||||
function wait_for_list_results()
|
||||
local updated, last_update
|
||||
local listener_id = event_listener('AUCTION_ITEM_LIST_UPDATE', function()
|
||||
local listener_id = aux.event_listener('AUCTION_ITEM_LIST_UPDATE', function()
|
||||
last_update = GetTime()
|
||||
updated = true
|
||||
end)
|
||||
local timeout = later(5, get_state().last_list_query)
|
||||
local timeout = aux.later(5, get_state().last_list_query)
|
||||
local ignore_owner = get_state().params.ignore_owner or aux_ignore_owner
|
||||
return when(function()
|
||||
return aux.when(function()
|
||||
if not last_update and timeout() then
|
||||
return true
|
||||
end
|
||||
@@ -214,7 +212,7 @@ function wait_for_list_results()
|
||||
end
|
||||
updated = false
|
||||
end, function()
|
||||
kill_listener(listener_id)
|
||||
aux.kill_listener(listener_id)
|
||||
if not last_update and timeout() then
|
||||
return submit_query()
|
||||
else
|
||||
|
||||
+7
-9
@@ -1,20 +1,18 @@
|
||||
module 'aux.core.shortcut'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
do
|
||||
local orig = SetItemRef
|
||||
_G.SetItemRef = T.vararg-function(arg)
|
||||
if arg[3] ~= 'RightButton' or not index(get_active_tab(), 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
||||
if arg[3] ~= 'RightButton' or not aux.index(aux.get_tab(), 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
||||
return orig(unpack(arg))
|
||||
end
|
||||
local item_info = info.item(tonumber(select(3, strfind(arg[1], '^item:(%d+)'))))
|
||||
local item_info = info.item(tonumber(aux.select(3, strfind(arg[1], '^item:(%d+)'))))
|
||||
if item_info then
|
||||
return get_active_tab().CLICK_LINK(item_info)
|
||||
return aux.get_tab().CLICK_LINK(item_info)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -22,12 +20,12 @@ end
|
||||
do
|
||||
local orig = UseContainerItem
|
||||
_G.UseContainerItem = T.vararg-function(arg)
|
||||
if modified() or not get_active_tab() then
|
||||
if aux.modified() or not aux.get_tab() then
|
||||
return orig(unpack(arg))
|
||||
end
|
||||
local item_info = info.container_item(arg[1], arg[2])
|
||||
if item_info and get_active_tab().USE_ITEM then
|
||||
get_active_tab().USE_ITEM(item_info)
|
||||
if item_info and aux.get_tab().USE_ITEM then
|
||||
aux.get_tab().USE_ITEM(item_info)
|
||||
end
|
||||
end
|
||||
end
|
||||
+27
-29
@@ -1,71 +1,69 @@
|
||||
module 'aux.core.slash'
|
||||
|
||||
include 'aux'
|
||||
local aux = require 'aux'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
function handle.LOAD2()
|
||||
tooltip_settings = character_data'tooltip'
|
||||
function aux.handle.LOAD2()
|
||||
tooltip_settings = aux.character_data'tooltip'
|
||||
end
|
||||
|
||||
_G.aux_ignore_owner = true
|
||||
|
||||
function status(enabled)
|
||||
return (enabled and color.green'on' or color.red'off')
|
||||
return (enabled and aux.color.green'on' or aux.color.red'off')
|
||||
end
|
||||
|
||||
_G.SLASH_AUX1 = '/aux'
|
||||
function SlashCmdList.AUX(command)
|
||||
if not command then return end
|
||||
local arguments = tokenize(command)
|
||||
local arguments = aux.tokenize(command)
|
||||
|
||||
if arguments[1] == 'scale' and tonumber(arguments[2]) then
|
||||
local scale = tonumber(arguments[2])
|
||||
AuxFrame:SetScale(scale)
|
||||
aux.frame:SetScale(scale)
|
||||
_G.aux_scale = scale
|
||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||
_G.aux_ignore_owner = not aux_ignore_owner
|
||||
print('ignore owner ' .. status(aux_ignore_owner))
|
||||
aux.print('ignore owner ' .. status(aux_ignore_owner))
|
||||
elseif arguments[1] == 'post' and arguments[2] == 'bid' then
|
||||
_G.aux_post_bid = not aux_post_bid
|
||||
print('post bid ' .. status(aux_post_bid))
|
||||
aux.print('post bid ' .. status(aux_post_bid))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
tooltip_settings.value = not tooltip_settings.value
|
||||
print('tooltip value ' .. status(tooltip_settings.value))
|
||||
aux.print('tooltip value ' .. status(tooltip_settings.value))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
tooltip_settings.daily = not tooltip_settings.daily
|
||||
print('tooltip daily ' .. status(tooltip_settings.daily))
|
||||
aux.print('tooltip daily ' .. status(tooltip_settings.daily))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
tooltip_settings.merchant_buy = not tooltip_settings.merchant_buy
|
||||
print('tooltip merchant buy ' .. status(tooltip_settings.merchant_buy))
|
||||
aux.print('tooltip merchant buy ' .. status(tooltip_settings.merchant_buy))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
tooltip_settings.merchant_sell = not tooltip_settings.merchant_sell
|
||||
print('tooltip merchant sell ' .. status(tooltip_settings.merchant_sell))
|
||||
aux.print('tooltip merchant sell ' .. status(tooltip_settings.merchant_sell))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
||||
tooltip_settings.disenchant_value = not tooltip_settings.disenchant_value
|
||||
print('tooltip disenchant value ' .. status(tooltip_settings.disenchant_value))
|
||||
aux.print('tooltip disenchant value ' .. status(tooltip_settings.disenchant_value))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
|
||||
tooltip_settings.disenchant_distribution = not tooltip_settings.disenchant_distribution
|
||||
print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution))
|
||||
aux.print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution))
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
_G.aux_items = {}
|
||||
_G.aux_item_ids = {}
|
||||
_G.aux_auctionable_items = {}
|
||||
print('Item cache cleared.')
|
||||
aux.print('Item cache cleared.')
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
info.populate_wdb()
|
||||
else
|
||||
print('Usage:')
|
||||
print('- scale [' .. color.blue(aux_scale) .. ']')
|
||||
print('- ignore owner [' .. status(aux_ignore_owner) .. ']')
|
||||
print('- post bid [' .. status(aux_post_bid) .. ']')
|
||||
print('- tooltip value [' .. status(tooltip_settings.value) .. ']')
|
||||
print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']')
|
||||
print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']')
|
||||
print('- tooltip merchant sell [' .. status(tooltip_settings.merchant_sell) .. ']')
|
||||
print('- tooltip disenchant value [' .. status(tooltip_settings.disenchant_value) .. ']')
|
||||
print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']')
|
||||
print('- clear item cache')
|
||||
print('- populate wdb')
|
||||
aux.print('Usage:')
|
||||
aux.print('- scale [' .. aux.color.blue(aux_scale) .. ']')
|
||||
aux.print('- ignore owner [' .. status(aux_ignore_owner) .. ']')
|
||||
aux.print('- post bid [' .. status(aux_post_bid) .. ']')
|
||||
aux.print('- tooltip value [' .. status(tooltip_settings.value) .. ']')
|
||||
aux.print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']')
|
||||
aux.print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']')
|
||||
aux.print('- tooltip merchant sell [' .. status(tooltip_settings.merchant_sell) .. ']')
|
||||
aux.print('- tooltip disenchant value [' .. status(tooltip_settings.disenchant_value) .. ']')
|
||||
aux.print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']')
|
||||
aux.print('- clear item cache')
|
||||
aux.print('- populate wdb')
|
||||
end
|
||||
end
|
||||
+8
-10
@@ -1,14 +1,12 @@
|
||||
module 'aux.core.stack'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
|
||||
local state
|
||||
|
||||
function handle.CLOSE()
|
||||
function aux.handle.CLOSE()
|
||||
stop()
|
||||
end
|
||||
|
||||
@@ -34,7 +32,7 @@ end
|
||||
|
||||
function find_item_slot(partial)
|
||||
for slot in info.inventory() do
|
||||
if matching_item(slot, partial) and not eq(slot, state.target_slot) then
|
||||
if matching_item(slot, partial) and not aux.eq(slot, state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
@@ -63,7 +61,7 @@ end
|
||||
|
||||
function move_item(from_slot, to_slot, amount, k)
|
||||
if locked(from_slot) or locked(to_slot) then
|
||||
return wait(k)
|
||||
return aux.wait(k)
|
||||
end
|
||||
|
||||
amount = min(max_stack(from_slot) - stack_size(to_slot), stack_size(from_slot), amount)
|
||||
@@ -73,7 +71,7 @@ function move_item(from_slot, to_slot, amount, k)
|
||||
SplitContainerItem(from_slot[1], from_slot[2], amount)
|
||||
PickupContainerItem(unpack(to_slot))
|
||||
|
||||
return when(function() return stack_size(to_slot) == expected_size end, k)
|
||||
return aux.when(function() return stack_size(to_slot) == expected_size end, k)
|
||||
end
|
||||
|
||||
function process()
|
||||
@@ -113,18 +111,18 @@ end
|
||||
|
||||
function M.stop()
|
||||
if state then
|
||||
kill_thread(state.thread_id)
|
||||
aux.kill_thread(state.thread_id)
|
||||
local callback, slot = state.callback, state.target_slot
|
||||
slot = slot and matching_item(slot) and slot or nil
|
||||
state = nil
|
||||
do (callback or nop)(slot) end
|
||||
do (callback or pass)(slot) end
|
||||
end
|
||||
end
|
||||
|
||||
function M.start(item_key, size, callback)
|
||||
stop()
|
||||
state = {
|
||||
thread_id = thread(process),
|
||||
thread_id = aux.thread(process),
|
||||
item_key = item_key,
|
||||
target_size = size,
|
||||
callback = callback,
|
||||
|
||||
+24
-26
@@ -1,9 +1,7 @@
|
||||
module 'aux.core.tooltip'
|
||||
|
||||
include 'aux'
|
||||
|
||||
local T = require 'T'
|
||||
|
||||
local aux = require 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
@@ -14,16 +12,16 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
|
||||
|
||||
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
||||
|
||||
function handle.LOAD()
|
||||
settings = character_data('tooltip', {value=true})
|
||||
function aux.handle.LOAD()
|
||||
settings = aux.character_data('tooltip', {value=true})
|
||||
do
|
||||
local inside_hook = false
|
||||
for name, f in game_tooltip_hooks do
|
||||
local name, f = name, f
|
||||
hook(name, GameTooltip, T.vararg-function(arg)
|
||||
aux.hook(name, GameTooltip, T.vararg-function(arg)
|
||||
game_tooltip_money = 0
|
||||
inside_hook = true
|
||||
local tmp = T.list(orig[GameTooltip][name](unpack(arg)))
|
||||
local tmp = T.list(aux.orig[GameTooltip][name](unpack(arg)))
|
||||
inside_hook = false
|
||||
f(unpack(arg))
|
||||
return T.unpack(tmp)
|
||||
@@ -43,7 +41,7 @@ function handle.LOAD()
|
||||
local name, _, quality = GetItemInfo(arg[1])
|
||||
local tmp = T.list(orig(unpack(arg)))
|
||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||
local color_code = select(4, GetItemQualityColor(quality))
|
||||
local color_code = aux.select(4, GetItemQualityColor(quality))
|
||||
local link = color_code .. '|H' .. arg[1] .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
extend_tooltip(ItemRefTooltip, link, 1)
|
||||
end
|
||||
@@ -59,28 +57,28 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
if getn(distribution) > 0 then
|
||||
if settings.disenchant_distribution then
|
||||
tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution())
|
||||
tooltip:AddLine('Disenchants into:', aux.color.tooltip.disenchant.distribution())
|
||||
sort(distribution, function(a,b) return a.probability > b.probability end)
|
||||
for _, event in ipairs(distribution) do
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.tooltip.disenchant.distribution())
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), aux.color.tooltip.disenchant.distribution())
|
||||
end
|
||||
end
|
||||
if settings.disenchant_value then
|
||||
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
tooltip:AddLine('Disenchant: ' .. (disenchant_value and money.to_string2(disenchant_value) or UNKNOWN), color.tooltip.disenchant.value())
|
||||
tooltip:AddLine('Disenchant: ' .. (disenchant_value and money.to_string2(disenchant_value) or UNKNOWN), aux.color.tooltip.disenchant.value())
|
||||
end
|
||||
end
|
||||
end
|
||||
if settings.merchant_buy then
|
||||
local _, price, limited = info.merchant_info(item_id)
|
||||
if price then
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.tooltip.merchant())
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), aux.color.tooltip.merchant())
|
||||
end
|
||||
end
|
||||
if settings.merchant_sell then
|
||||
local price = info.merchant_info(item_id)
|
||||
if price ~= 0 then
|
||||
tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), color.tooltip.merchant())
|
||||
tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), aux.color.tooltip.merchant())
|
||||
end
|
||||
end
|
||||
local auctionable = not item_info or info.auctionable(T.temp-info.tooltip('link', item_info.itemstring), item_info.quality)
|
||||
@@ -88,11 +86,11 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
local value = history.value(item_key)
|
||||
if auctionable then
|
||||
if settings.value then
|
||||
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or UNKNOWN), color.tooltip.value())
|
||||
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or UNKNOWN), aux.color.tooltip.value())
|
||||
end
|
||||
if settings.daily then
|
||||
local market_value = history.market_value(item_key)
|
||||
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. gui.percentage_historical(round(market_value / value * 100)) .. ')' or UNKNOWN), color.tooltip.value())
|
||||
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. gui.percentage_historical(aux.round(market_value / value * 100)) .. ')' or UNKNOWN), aux.color.tooltip.value())
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,7 +103,7 @@ end
|
||||
function game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
local name, _, quality = GetItemInfo(itemstring)
|
||||
if name then
|
||||
local hex = select(4, GetItemQualityColor(quality))
|
||||
local hex = aux.select(4, GetItemQualityColor(quality))
|
||||
local link = hex .. '|H' .. itemstring .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
@@ -114,35 +112,35 @@ end
|
||||
function game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
local link = GetAuctionItemLink(type, index)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetAuctionItemInfo(type, index)))
|
||||
extend_tooltip(GameTooltip, link, aux.select(3, GetAuctionItemInfo(type, index)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetLootItem(slot)
|
||||
local link = GetLootSlotLink(slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetLootSlotInfo(slot)))
|
||||
extend_tooltip(GameTooltip, link, aux.select(3, GetLootSlotInfo(slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
local link = GetQuestItemLink(qtype, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetQuestItemInfo(qtype, slot)))
|
||||
extend_tooltip(GameTooltip, link, aux.select(3, GetQuestItemInfo(qtype, slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
local link = GetQuestLogItemLink(qtype, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetQuestLogRewardInfo(slot)))
|
||||
extend_tooltip(GameTooltip, link, aux.select(3, GetQuestLogRewardInfo(slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(2, GetContainerItemInfo(bag, slot)))
|
||||
extend_tooltip(GameTooltip, link, aux.select(2, GetContainerItemInfo(bag, slot)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -151,7 +149,7 @@ function game_tooltip_hooks:SetInboxItem(index)
|
||||
local id = name and info.item_id(name)
|
||||
if id then
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local hex = select(4, GetItemQualityColor(tonumber(quality)))
|
||||
local hex = aux.select(4, GetItemQualityColor(tonumber(quality)))
|
||||
local link = hex .. '|H' .. itemstring .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
@@ -167,7 +165,7 @@ end
|
||||
function game_tooltip_hooks:SetMerchantItem(slot)
|
||||
local link = GetMerchantItemLink(slot)
|
||||
if link then
|
||||
local quantity = select(4, GetMerchantItemInfo(slot))
|
||||
local quantity = aux.select(4, GetMerchantItemInfo(slot))
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
@@ -175,7 +173,7 @@ end
|
||||
function game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link, quantity = GetCraftReagentItemLink(skill, slot), select(3, GetCraftReagentInfo(skill, slot))
|
||||
link, quantity = GetCraftReagentItemLink(skill, slot), aux.select(3, GetCraftReagentInfo(skill, slot))
|
||||
else
|
||||
link, quantity = GetCraftItemLink(skill), 1
|
||||
end
|
||||
@@ -194,7 +192,7 @@ end
|
||||
function game_tooltip_hooks:SetTradeSkillItem(skill, slot)
|
||||
local link, quantity
|
||||
if slot then
|
||||
link, quantity = GetTradeSkillReagentItemLink(skill, slot), select(3, GetTradeSkillReagentInfo(skill, slot))
|
||||
link, quantity = GetTradeSkillReagentItemLink(skill, slot), aux.select(3, GetTradeSkillReagentInfo(skill, slot))
|
||||
else
|
||||
link, quantity = GetTradeSkillItemLink(skill), 1
|
||||
end
|
||||
@@ -209,7 +207,7 @@ function game_tooltip_hooks:SetAuctionSellItem()
|
||||
for slot in info.inventory() do
|
||||
T.temp(slot)
|
||||
local link = GetContainerItemLink(unpack(slot))
|
||||
if link and select(5, info.parse_link(link)) == name then
|
||||
if link and aux.select(5, info.parse_link(link)) == name then
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user