more refactoring
This commit is contained in:
@@ -195,12 +195,12 @@ function public.populate_wdb(item_id)
|
|||||||
item_id = item_id or MIN_ITEM_ID
|
item_id = item_id or MIN_ITEM_ID
|
||||||
|
|
||||||
if item_id > MAX_ITEM_ID then
|
if item_id > MAX_ITEM_ID then
|
||||||
aux.log('Cache populated.')
|
log('Cache populated.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not GetItemInfo('item:'..item_id) then
|
if not GetItemInfo('item:'..item_id) then
|
||||||
aux.log('Fetching item '..item_id..'.')
|
log('Fetching item '..item_id..'.')
|
||||||
AuxTooltip:SetHyperlink('item:'..item_id)
|
AuxTooltip:SetHyperlink('item:'..item_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -27,14 +27,14 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, state in aborted do
|
for _, state in aborted do
|
||||||
aux.call(state.params.on_abort)
|
call(state.params.on_abort)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function complete()
|
function complete()
|
||||||
local on_complete = state.params.on_complete
|
local on_complete = state.params.on_complete
|
||||||
scan_states[state.params.type] = nil
|
scan_states[state.params.type] = nil
|
||||||
aux.call(on_complete)
|
call(on_complete)
|
||||||
end
|
end
|
||||||
|
|
||||||
function accessor.state()
|
function accessor.state()
|
||||||
@@ -81,7 +81,7 @@ end
|
|||||||
|
|
||||||
function scan()
|
function scan()
|
||||||
state.query_index = state.query_index and state.query_index + 1 or 1
|
state.query_index = state.query_index and state.query_index + 1 or 1
|
||||||
if query and (aux.index(query.blizzard_query, 'first_page') or 0) <= (aux.index(query.blizzard_query, 'last_page') or aux.huge) then
|
if query and (index(query.blizzard_query, 'first_page') or 0) <= (index(query.blizzard_query, 'last_page') or huge) then
|
||||||
if query.blizzard_query then
|
if query.blizzard_query then
|
||||||
state.page = query.blizzard_query.first_page or 0
|
state.page = query.blizzard_query.first_page or 0
|
||||||
else
|
else
|
||||||
@@ -103,7 +103,7 @@ end
|
|||||||
|
|
||||||
function submit_query()
|
function submit_query()
|
||||||
aux.control.when(function() return state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
|
aux.control.when(function() return state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
|
||||||
aux.call(state.params.on_submit_query)
|
call(state.params.on_submit_query)
|
||||||
state.last_query_time = GetTime()
|
state.last_query_time = GetTime()
|
||||||
if state.params.type == 'bidder' then
|
if state.params.type == 'bidder' then
|
||||||
GetBidderAuctionItems(state.page)
|
GetBidderAuctionItems(state.page)
|
||||||
@@ -153,7 +153,7 @@ function scan_page(i)
|
|||||||
|
|
||||||
aux.history.process_auction(auction_info)
|
aux.history.process_auction(auction_info)
|
||||||
|
|
||||||
if aux.call(state.params.auto_buy_validator, auction_info) then
|
if call(state.params.auto_buy_validator, auction_info) then
|
||||||
local send_signal, signal_received = signal()
|
local send_signal, signal_received = signal()
|
||||||
aux.control.when(signal_received, recurse)
|
aux.control.when(signal_received, recurse)
|
||||||
aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, aux.C(send_signal, true))
|
aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, aux.C(send_signal, true))
|
||||||
|
|||||||
+19
-19
@@ -4,50 +4,50 @@ function SlashCmdList.AUX(command)
|
|||||||
local arguments = tokenize(command)
|
local arguments = tokenize(command)
|
||||||
if arguments[1] == 'clear' and arguments[2] == 'history' then
|
if arguments[1] == 'clear' and arguments[2] == 'history' then
|
||||||
aux.persistence.load_dataset().history = nil
|
aux.persistence.load_dataset().history = nil
|
||||||
aux.log 'History cleared.'
|
log 'History cleared.'
|
||||||
elseif arguments[1] == 'clear' and arguments[2] == 'post' then
|
elseif arguments[1] == 'clear' and arguments[2] == 'post' then
|
||||||
aux.persistence.load_dataset().post = nil
|
aux.persistence.load_dataset().post = nil
|
||||||
aux.log 'Post settings cleared.'
|
log 'Post settings cleared.'
|
||||||
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
||||||
g.aux_datasets = {}
|
g.aux_datasets = {}
|
||||||
aux.log 'Datasets cleared.'
|
log 'Datasets cleared.'
|
||||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||||
g.aux_merchant_buy = {}
|
g.aux_merchant_buy = {}
|
||||||
aux.log 'Merchant buy prices cleared.'
|
log 'Merchant buy prices cleared.'
|
||||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||||
g.aux_merchant_sell = {}
|
g.aux_merchant_sell = {}
|
||||||
aux.log 'Merchant sell prices cleared.'
|
log 'Merchant sell prices cleared.'
|
||||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||||
g.aux_items = {}
|
g.aux_items = {}
|
||||||
g.aux_item_ids = {}
|
g.aux_item_ids = {}
|
||||||
g.aux_auctionable_items = {}
|
g.aux_auctionable_items = {}
|
||||||
aux.log 'Item cache cleared.'
|
log 'Item cache cleared.'
|
||||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||||
aux.cache.populate_wdb()
|
aux.cache.populate_wdb()
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||||
g.aux_tooltip_value = not g.aux_tooltip_value
|
g.aux_tooltip_value = not g.aux_tooltip_value
|
||||||
aux.log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||||
g.aux_tooltip_daily = not g.aux_tooltip_daily
|
g.aux_tooltip_daily = not g.aux_tooltip_daily
|
||||||
aux.log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
|
||||||
g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy
|
g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy
|
||||||
aux.log('Vendor buy price in tooltip '..(g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
log('Vendor buy price in tooltip '..(g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
|
||||||
g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell
|
g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell
|
||||||
aux.log('Vendor sell price in tooltip '..(g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
log('Vendor sell price in tooltip '..(g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
||||||
g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value
|
g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value
|
||||||
aux.log('Disenchant value in tooltip '..(g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
log('Disenchant value in tooltip '..(g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
|
||||||
g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution
|
g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution
|
||||||
aux.log('Disenchant distribution in tooltip '..(g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
log('Disenchant distribution in tooltip '..(g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
|
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
|
||||||
g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source
|
g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source
|
||||||
aux.log('Disenchant source in tooltip '..(g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
log('Disenchant source in tooltip '..(g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||||
g.aux_ignore_owner = not g.aux_ignore_owner
|
g.aux_ignore_owner = not g.aux_ignore_owner
|
||||||
aux.log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||||
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
||||||
local realm = GetCVar 'realmName'
|
local realm = GetCVar 'realmName'
|
||||||
g.aux_characters[realm] = g.aux_characters[realm] or {}
|
g.aux_characters[realm] = g.aux_characters[realm] or {}
|
||||||
@@ -55,7 +55,7 @@ function SlashCmdList.AUX(command)
|
|||||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||||
if not g.aux_characters[realm][name] then
|
if not g.aux_characters[realm][name] then
|
||||||
g.aux_characters[realm][name] = true
|
g.aux_characters[realm][name] = true
|
||||||
aux.log('Character "'..name..'" added.')
|
log('Character "'..name..'" added.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
||||||
@@ -67,7 +67,7 @@ function SlashCmdList.AUX(command)
|
|||||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||||
if g.aux_characters[realm][name] then
|
if g.aux_characters[realm][name] then
|
||||||
g.aux_characters[realm][name] = nil
|
g.aux_characters[realm][name] = nil
|
||||||
aux.log('Character "'..name..'" removed.')
|
log('Character "'..name..'" removed.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif arguments[1] == 'chars' then
|
elseif arguments[1] == 'chars' then
|
||||||
@@ -77,11 +77,11 @@ function SlashCmdList.AUX(command)
|
|||||||
tinsert(chars, name)
|
tinsert(chars, name)
|
||||||
end
|
end
|
||||||
if getn(chars) > 0 then
|
if getn(chars) > 0 then
|
||||||
aux.log('Your characters: "'..table.concat(chars, ', ')..'".')
|
log('Your characters: "'..table.concat(chars, ', ')..'".')
|
||||||
else
|
else
|
||||||
aux.log 'You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".'
|
log 'You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
aux.log('Unknown command: "'..command..'"')
|
log('Unknown command: "'..command..'"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -111,7 +111,7 @@ function public.stop()
|
|||||||
slot = nil
|
slot = nil
|
||||||
end
|
end
|
||||||
m.state = nil
|
m.state = nil
|
||||||
aux.call(callback, slot)
|
call(callback, slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,44 +4,6 @@ public.bids_loaded = false
|
|||||||
public.current_owner_page = nil
|
public.current_owner_page = nil
|
||||||
public.last_owner_page_requested = nil
|
public.last_owner_page_requested = nil
|
||||||
|
|
||||||
do
|
|
||||||
local data = {}
|
|
||||||
local mt = {
|
|
||||||
__newindex = function(self, key, value)
|
|
||||||
data[self].getter{public=self, private=data[self].state}[key] = value
|
|
||||||
end,
|
|
||||||
__index = function(self, key)
|
|
||||||
return data[self].getter{public=self, private=data[self].state}[key]
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
function public.dynamic_table(state, getter)
|
|
||||||
local self = {}
|
|
||||||
data[self] = {getter=getter, state=state}
|
|
||||||
return setmetatable(self, mt)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
local _state = setmetatable({}, {__mode='kv'})
|
|
||||||
local __index = function(self, key)
|
|
||||||
return _state[self].handler({public=self, private=_state[self].state}, key)
|
|
||||||
end
|
|
||||||
function public.index_function(state, handler)
|
|
||||||
local state, self = {handler=handler, state=state}, {}
|
|
||||||
_state[self] = state
|
|
||||||
return setmetatable(self, {__metatable=false, __index=__index, state=state})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function public.temp(object)
|
|
||||||
getfenv(2).__ = object
|
|
||||||
return object
|
|
||||||
end
|
|
||||||
|
|
||||||
function public.L(body_string)
|
|
||||||
return loadstring 'function()'
|
|
||||||
end
|
|
||||||
|
|
||||||
tabs = {}
|
tabs = {}
|
||||||
function public.tab(index, name)
|
function public.tab(index, name)
|
||||||
local module_env = getfenv(2)
|
local module_env = getfenv(2)
|
||||||
@@ -61,16 +23,16 @@ do
|
|||||||
end
|
end
|
||||||
function on_tab_click(index)
|
function on_tab_click(index)
|
||||||
if active_tab_index then
|
if active_tab_index then
|
||||||
m.call(active_tab.env.CLOSE)
|
call(active_tab.env.CLOSE)
|
||||||
end
|
end
|
||||||
active_tab_index = index
|
active_tab_index = index
|
||||||
if active_tab_index then
|
if active_tab_index then
|
||||||
m.call(active_tab.env.OPEN)
|
call(active_tab.env.OPEN)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.VARIABLES_LOADED()
|
function VARIABLES_LOADED()
|
||||||
do
|
do
|
||||||
local frame = CreateFrame('Frame', aux.gui.name, UIParent)
|
local frame = CreateFrame('Frame', aux.gui.name, UIParent)
|
||||||
tinsert(UISpecialFrames, 'aux_frame1')
|
tinsert(UISpecialFrames, 'aux_frame1')
|
||||||
@@ -103,8 +65,8 @@ function public.VARIABLES_LOADED()
|
|||||||
public.frame = frame
|
public.frame = frame
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local tabs = m.gui.tabs(m.frame, 'DOWN')
|
local tabs = gui.tabs(frame, 'DOWN')
|
||||||
tabs._on_select = m.on_tab_click
|
tabs._on_select = on_tab_click
|
||||||
for _, tab in m.tabs do
|
for _, tab in m.tabs do
|
||||||
tabs:create_tab(tab.name)
|
tabs:create_tab(tab.name)
|
||||||
end
|
end
|
||||||
@@ -113,17 +75,17 @@ function public.VARIABLES_LOADED()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local btn = m.gui.button(m.frame, 16)
|
local btn = gui.button(frame, 16)
|
||||||
btn:SetPoint('BOTTOMRIGHT', -6, 6)
|
btn:SetPoint('BOTTOMRIGHT', -6, 6)
|
||||||
btn:SetWidth(65)
|
btn:SetWidth(65)
|
||||||
btn:SetHeight(24)
|
btn:SetHeight(24)
|
||||||
btn:SetText 'Close'
|
btn:SetText 'Close'
|
||||||
btn:SetScript('OnClick', m.C(m.frame.Hide, m.frame))
|
btn:SetScript('OnClick', C(frame.Hide, frame))
|
||||||
public.close_button = btn
|
public.close_button = btn
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local btn = m.gui.button(m.frame, 16)
|
local btn = gui.button(frame, 16)
|
||||||
btn:SetPoint('RIGHT', m.close_button, 'LEFT' , -5, 0)
|
btn:SetPoint('RIGHT', close_button, 'LEFT' , -5, 0)
|
||||||
btn:SetWidth(65)
|
btn:SetWidth(65)
|
||||||
btn:SetHeight(24)
|
btn:SetHeight(24)
|
||||||
btn:SetText 'Default UI'
|
btn:SetText 'Default UI'
|
||||||
@@ -139,43 +101,43 @@ end
|
|||||||
|
|
||||||
function AUCTION_HOUSE_SHOW()
|
function AUCTION_HOUSE_SHOW()
|
||||||
AuctionFrame:Hide()
|
AuctionFrame:Hide()
|
||||||
m.frame:Show()
|
frame:Show()
|
||||||
m.set_tab(1)
|
set_tab(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function AUCTION_HOUSE_CLOSED()
|
function AUCTION_HOUSE_CLOSED()
|
||||||
m.bids_loaded = false
|
bids_loaded = false
|
||||||
m.current_owner_page = nil
|
current_owner_page = nil
|
||||||
m.post.stop()
|
post.stop()
|
||||||
m.stack.stop()
|
stack.stop()
|
||||||
m.scan.abort()
|
scan.abort()
|
||||||
m.set_tab()
|
set_tab()
|
||||||
m.frame:Hide()
|
frame:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
function AUCTION_BIDDER_LIST_UPDATE()
|
function AUCTION_BIDDER_LIST_UPDATE()
|
||||||
m.bids_loaded = true
|
bids_loaded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function AUCTION_OWNED_LIST_UPDATE()
|
function AUCTION_OWNED_LIST_UPDATE()
|
||||||
m.current_owner_page = m.last_owner_page_requested or 0
|
current_owner_page = last_owner_page_requested or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function m.ADDON_LOADED.Blizzard_AuctionUI()
|
function ADDON_LOADED.Blizzard_AuctionUI()
|
||||||
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
||||||
AuctionFrame:SetScript('OnHide', nil)
|
AuctionFrame:SetScript('OnHide', nil)
|
||||||
|
|
||||||
m.hook('ShowUIPanel', function(...)
|
hook('ShowUIPanel', function(...)
|
||||||
if arg[1] == AuctionFrame then
|
if arg[1] == AuctionFrame then
|
||||||
return AuctionFrame:Show()
|
return AuctionFrame:Show()
|
||||||
end
|
end
|
||||||
return m.orig.ShowUIPanel(unpack(arg))
|
return orig.ShowUIPanel(unpack(arg))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
m.hook('GetOwnerAuctionItems', m.GetOwnerAuctionItems)
|
hook('GetOwnerAuctionItems', GetOwnerAuctionItems)
|
||||||
m.hook('SetItemRef', m.SetItemRef)
|
hook('SetItemRef', SetItemRef)
|
||||||
m.hook('UseContainerItem', m.UseContainerItem)
|
hook('UseContainerItem', UseContainerItem)
|
||||||
m.hook('AuctionFrameAuctions_OnEvent', m.AuctionFrameAuctions_OnEvent)
|
hook('AuctionFrameAuctions_OnEvent', AuctionFrameAuctions_OnEvent)
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -186,9 +148,9 @@ do
|
|||||||
return label
|
return label
|
||||||
end
|
end
|
||||||
|
|
||||||
function m.ADDON_LOADED.Blizzard_CraftUI()
|
function ADDON_LOADED.Blizzard_CraftUI()
|
||||||
m.hook('CraftFrame_SetSelection', function(...)
|
hook('CraftFrame_SetSelection', function(...)
|
||||||
local results = {m.orig.CraftFrame_SetSelection(unpack(arg)) }
|
local results = {orig.CraftFrame_SetSelection(unpack(arg))}
|
||||||
|
|
||||||
local id = GetCraftSelectionIndex()
|
local id = GetCraftSelectionIndex()
|
||||||
local reagent_count = GetCraftNumReagents(id)
|
local reagent_count = GetCraftNumReagents(id)
|
||||||
@@ -200,10 +162,10 @@ do
|
|||||||
total_cost = nil
|
total_cost = nil
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local item_id, suffix_id = m.info.parse_link(link)
|
local item_id, suffix_id = info.parse_link(link)
|
||||||
local count = select(3, GetCraftReagentInfo(id, i))
|
local count = select(3, GetCraftReagentInfo(id, i))
|
||||||
local _, price, limited = m.cache.merchant_info(item_id)
|
local _, price, limited = cache.merchant_info(item_id)
|
||||||
local value = price and not limited and price or m.history.value(item_id..':'..suffix_id)
|
local value = price and not limited and price or history.value(item_id..':'..suffix_id)
|
||||||
if not value then
|
if not value then
|
||||||
total_cost = nil
|
total_cost = nil
|
||||||
break
|
break
|
||||||
@@ -218,9 +180,9 @@ do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function m.ADDON_LOADED.Blizzard_TradeSkillUI()
|
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
||||||
m.hook('TradeSkillFrame_SetSelection', function(...)
|
hook('TradeSkillFrame_SetSelection', function(...)
|
||||||
local results = {m.orig.TradeSkillFrame_SetSelection(unpack(arg)) }
|
local results = {orig.TradeSkillFrame_SetSelection(unpack(arg))}
|
||||||
|
|
||||||
local id = GetTradeSkillSelectionIndex()
|
local id = GetTradeSkillSelectionIndex()
|
||||||
local reagent_count = GetTradeSkillNumReagents(id)
|
local reagent_count = GetTradeSkillNumReagents(id)
|
||||||
@@ -232,10 +194,10 @@ do
|
|||||||
total_cost = nil
|
total_cost = nil
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local item_id, suffix_id = m.info.parse_link(link)
|
local item_id, suffix_id = info.parse_link(link)
|
||||||
local count = select(3, GetTradeSkillReagentInfo(id, i))
|
local count = select(3, GetTradeSkillReagentInfo(id, i))
|
||||||
local _, price, limited = m.cache.merchant_info(item_id)
|
local _, price, limited = cache.merchant_info(item_id)
|
||||||
local value = price and not limited and price or m.history.value(item_id..':'..suffix_id)
|
local value = price and not limited and price or history.value(item_id..':'..suffix_id)
|
||||||
if not value then
|
if not value then
|
||||||
total_cost = nil
|
total_cost = nil
|
||||||
break
|
break
|
||||||
@@ -270,55 +232,50 @@ end
|
|||||||
|
|
||||||
function GetOwnerAuctionItems(...)
|
function GetOwnerAuctionItems(...)
|
||||||
local page = arg[1]
|
local page = arg[1]
|
||||||
m.last_owner_page_requested = page
|
last_owner_page_requested = page
|
||||||
return m.orig.GetOwnerAuctionItems(unpack(arg))
|
return orig.GetOwnerAuctionItems(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|
||||||
function AuctionFrameAuctions_OnEvent(...)
|
function AuctionFrameAuctions_OnEvent(...)
|
||||||
if AuctionFrameAuctions:IsVisible() then
|
if AuctionFrameAuctions:IsVisible() then
|
||||||
return m.orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetItemRef(...)
|
function SetItemRef(...)
|
||||||
if arg[3] ~= 'RightButton' or not m.index(active_tab, 'env', 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
if arg[3] ~= 'RightButton' or not index(active_tab, 'env', 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
||||||
return m.orig.SetItemRef(unpack(arg))
|
return orig.SetItemRef(unpack(arg))
|
||||||
end
|
end
|
||||||
for item_info in present(m.info.item(tonumber(({strfind(arg[1], '^item:(%d+)')})[3]))) do
|
for item_info in present(info.item(tonumber(({strfind(arg[1], '^item:(%d+)')})[3]))) do
|
||||||
return m.active_tab.env.CLICK_LINK(item_info)
|
return active_tab.env.CLICK_LINK(item_info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UseContainerItem(...)
|
function UseContainerItem(...)
|
||||||
if m.modified() or not m.index(active_tab, 'env', 'USE_ITEM') then
|
if modified or not index(active_tab, 'env', 'USE_ITEM') then
|
||||||
return m.orig.UseContainerItem(unpack(arg))
|
return orig.UseContainerItem(unpack(arg))
|
||||||
end
|
end
|
||||||
for item_info in present(m.info.container_item(arg[1], arg[2])) do
|
for item_info in present(info.container_item(arg[1], arg[2])) do
|
||||||
return m.active_tab.env.USE_ITEM(item_info)
|
return active_tab.env.USE_ITEM(item_info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local locked
|
local locked
|
||||||
|
|
||||||
function public.bid_in_progress()
|
function public.bid_in_progress()
|
||||||
return locked
|
return locked
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.place_bid(type, index, amount, on_success)
|
function public.place_bid(type, index, amount, on_success)
|
||||||
|
|
||||||
if locked then
|
if locked then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local money = GetMoney()
|
local money = GetMoney()
|
||||||
PlaceAuctionBid(type, index, amount)
|
PlaceAuctionBid(type, index, amount)
|
||||||
if money >= amount then
|
if money >= amount then
|
||||||
locked = true
|
locked = true
|
||||||
|
control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||||
m.control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
|
||||||
if arg1 == ERR_AUCTION_BID_PLACED then
|
if arg1 == ERR_AUCTION_BID_PLACED then
|
||||||
m.call(on_success)
|
call(on_success)
|
||||||
locked = false
|
locked = false
|
||||||
kill()
|
kill()
|
||||||
end
|
end
|
||||||
@@ -329,23 +286,18 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local locked
|
local locked
|
||||||
|
|
||||||
function public.cancel_in_progress()
|
function public.cancel_in_progress()
|
||||||
return locked
|
return locked
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.cancel_auction(index, on_success)
|
function public.cancel_auction(index, on_success)
|
||||||
|
|
||||||
if locked then
|
if locked then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
locked = true
|
locked = true
|
||||||
|
|
||||||
CancelAuction(index)
|
CancelAuction(index)
|
||||||
m.control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||||
if arg1 == ERR_AUCTION_REMOVED then
|
if arg1 == ERR_AUCTION_REMOVED then
|
||||||
aux.call(on_success)
|
call(on_success)
|
||||||
locked = false
|
locked = false
|
||||||
kill()
|
kill()
|
||||||
end
|
end
|
||||||
@@ -364,7 +316,7 @@ do
|
|||||||
local function call(f, arg1, arg2)
|
local function call(f, arg1, arg2)
|
||||||
local params = {}
|
local params = {}
|
||||||
for i=1,arg1.n do
|
for i=1,arg1.n do
|
||||||
if arg1[i] == m._this then
|
if arg1[i] == _this then
|
||||||
tinsert(params, this)
|
tinsert(params, this)
|
||||||
elseif formal_parameters[arg1[i]] then
|
elseif formal_parameters[arg1[i]] then
|
||||||
tinsert(params, arg2[formal_parameters[arg1[i]]])
|
tinsert(params, arg2[formal_parameters[arg1[i]]])
|
||||||
@@ -382,36 +334,9 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.call(f, ...)
|
|
||||||
if f then
|
|
||||||
return f(unpack(arg))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function public.index(t, ...)
|
|
||||||
for i=1,arg.n do
|
|
||||||
t = t and t[arg[i]]
|
|
||||||
end
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
public.huge = 1.8*10^308
|
|
||||||
|
|
||||||
function public.log(...)
|
|
||||||
local msg = '[aux]'
|
|
||||||
for i=1,arg.n do
|
|
||||||
msg = msg..' '..tostring(arg[i])
|
|
||||||
end
|
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
|
||||||
end
|
|
||||||
|
|
||||||
function public.is_player(name, current)
|
function public.is_player(name, current)
|
||||||
local realm = GetCVar 'realmName'
|
local realm = GetCVar 'realmName'
|
||||||
return not current and m.index(g.aux_characters, realm, name) or UnitName 'player' == name
|
return not current and index(g.aux_characters, realm, name) or UnitName 'player' == name
|
||||||
end
|
|
||||||
|
|
||||||
function public.modified()
|
|
||||||
return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.neutral_faction()
|
function public.neutral_faction()
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ do
|
|||||||
end
|
end
|
||||||
function color_accessor(callback)
|
function color_accessor(callback)
|
||||||
return function()
|
return function()
|
||||||
return aux.index_function({callback=callback, table=config.colors}, index_handler)
|
return index_function({callback=callback, table=config.colors}, index_handler)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -336,7 +336,7 @@ do
|
|||||||
function mt.__index:select(id)
|
function mt.__index:select(id)
|
||||||
self._selected = id
|
self._selected = id
|
||||||
self:update()
|
self:update()
|
||||||
aux.call(self._on_select, id)
|
call(self._on_select, id)
|
||||||
end
|
end
|
||||||
function mt.__index:update()
|
function mt.__index:update()
|
||||||
for _, tab in self._tabs do
|
for _, tab in self._tabs do
|
||||||
@@ -389,7 +389,7 @@ function public.editbox(parent)
|
|||||||
end)
|
end)
|
||||||
editbox:SetScript('OnTextChanged', function()
|
editbox:SetScript('OnTextChanged', function()
|
||||||
this.last_change = GetTime()
|
this.last_change = GetTime()
|
||||||
this.text:SetText(aux.call(this.formatter, this:GetText()) or this:GetText())
|
this.text:SetText(call(this.formatter, this:GetText()) or this:GetText())
|
||||||
this.cursor:SetPoint('LEFT', this.text, 'LEFT', max(0, this.text:GetStringWidth() - 2), 1)
|
this.cursor:SetPoint('LEFT', this.text, 'LEFT', max(0, this.text:GetStringWidth() - 2), 1)
|
||||||
end)
|
end)
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
setglobal('aux', aux_module('core'))
|
setglobal('aux', aux_module('core'))
|
||||||
|
import 'util'
|
||||||
|
|
||||||
public.version = '4.0.0'
|
public.version = '4.0.0'
|
||||||
|
|
||||||
@@ -40,8 +41,8 @@ event_frame:SetScript('OnEvent', function()
|
|||||||
m[event]()
|
m[event]()
|
||||||
if event == 'VARIABLES_LOADED' then
|
if event == 'VARIABLES_LOADED' then
|
||||||
for _, env in module_envs do
|
for _, env in module_envs do
|
||||||
if env.m.LOAD then
|
if env.LOAD then
|
||||||
env.m.LOAD()
|
env.LOAD()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
log('v'..version..' loaded.')
|
log('v'..version..' loaded.')
|
||||||
|
|||||||
+10
-10
@@ -11,7 +11,7 @@ local AUCTION_PCT_COLORS = {
|
|||||||
{color=aux.gui.inline_color.green, value=80},
|
{color=aux.gui.inline_color.green, value=80},
|
||||||
{color=aux.gui.inline_color.yellow, value=110},
|
{color=aux.gui.inline_color.yellow, value=110},
|
||||||
{color=aux.gui.inline_color.orange, value=135},
|
{color=aux.gui.inline_color.orange, value=135},
|
||||||
{color=aux.gui.inline_color.red, value=aux.huge},
|
{color=aux.gui.inline_color.red, value=huge},
|
||||||
}
|
}
|
||||||
|
|
||||||
local TIME_LEFT_STRINGS = {
|
local TIME_LEFT_STRINGS = {
|
||||||
@@ -198,8 +198,8 @@ public.search_config = {
|
|||||||
cmp = function(record_a, record_b, desc)
|
cmp = function(record_a, record_b, desc)
|
||||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||||
price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge)
|
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||||
price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge)
|
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||||
|
|
||||||
return aux.sorting.compare(price_a, price_b, desc)
|
return aux.sorting.compare(price_a, price_b, desc)
|
||||||
end,
|
end,
|
||||||
@@ -213,8 +213,8 @@ public.search_config = {
|
|||||||
cell:SetText((pct or bidPct) and percentage_historical(pct or bidPct, not pct) or '---')
|
cell:SetText((pct or bidPct) and percentage_historical(pct or bidPct, not pct) or '---')
|
||||||
end,
|
end,
|
||||||
cmp = function(record_a, record_b, desc)
|
cmp = function(record_a, record_b, desc)
|
||||||
local pct_a = record_percentage(record_a) or (desc and -aux.huge or aux.huge)
|
local pct_a = record_percentage(record_a) or (desc and -huge or huge)
|
||||||
local pct_b = record_percentage(record_b) or (desc and -aux.huge or aux.huge)
|
local pct_b = record_percentage(record_b) or (desc and -huge or huge)
|
||||||
return aux.sorting.compare(pct_a, pct_b, desc)
|
return aux.sorting.compare(pct_a, pct_b, desc)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -340,8 +340,8 @@ public.auctions_config = {
|
|||||||
cmp = function(record_a, record_b, desc)
|
cmp = function(record_a, record_b, desc)
|
||||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||||
price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge)
|
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||||
price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge)
|
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||||
|
|
||||||
return aux.sorting.compare(price_a, price_b, desc)
|
return aux.sorting.compare(price_a, price_b, desc)
|
||||||
end,
|
end,
|
||||||
@@ -493,8 +493,8 @@ public.bids_config = {
|
|||||||
cmp = function(record_a, record_b, desc)
|
cmp = function(record_a, record_b, desc)
|
||||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||||
price_a = price_a > 0 and price_a or (desc and -aux.huge or aux.huge)
|
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||||
price_b = price_b > 0 and price_b or (desc and -aux.huge or aux.huge)
|
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||||
|
|
||||||
return aux.sorting.compare(price_a, price_b, desc)
|
return aux.sorting.compare(price_a, price_b, desc)
|
||||||
end,
|
end,
|
||||||
@@ -644,7 +644,7 @@ local methods = {
|
|||||||
DressUpItemLink(this.row.data.record.link)
|
DressUpItemLink(this.row.data.record.link)
|
||||||
elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then
|
elseif IsShiftKeyDown() and ChatFrameEditBox:IsVisible() then
|
||||||
ChatFrameEditBox:Insert(this.row.data.record.link)
|
ChatFrameEditBox:Insert(this.row.data.record.link)
|
||||||
elseif not aux.modified() and button == 'RightButton' then -- TODO not when alt (how?)
|
elseif not modified and button == 'RightButton' then -- TODO not when alt (how?)
|
||||||
aux.set_tab(1)
|
aux.set_tab(1)
|
||||||
aux.search_tab.set_filter(strlower(aux.info.item(this.row.data.record.item_id).name)..'/exact')
|
aux.search_tab.set_filter(strlower(aux.info.item(this.row.data.record.item_id).name)..'/exact')
|
||||||
aux.search_tab.execute(nil, false)
|
aux.search_tab.execute(nil, false)
|
||||||
|
|||||||
+2
-2
@@ -155,14 +155,14 @@ function update_auction_listing()
|
|||||||
sort(auction_rows, function(a, b)
|
sort(auction_rows, function(a, b)
|
||||||
return aux.sorting.multi_lt(
|
return aux.sorting.multi_lt(
|
||||||
{
|
{
|
||||||
a.record.unit_buyout_price == 0 and aux.huge or a.record.unit_buyout_price,
|
a.record.unit_buyout_price == 0 and huge or a.record.unit_buyout_price,
|
||||||
a.record.unit_blizzard_bid,
|
a.record.unit_blizzard_bid,
|
||||||
a.record.stack_size,
|
a.record.stack_size,
|
||||||
b.record.own and 1 or 0,
|
b.record.own and 1 or 0,
|
||||||
a.record.duration,
|
a.record.duration,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
b.record.unit_buyout_price == 0 and aux.huge or b.record.unit_buyout_price,
|
b.record.unit_buyout_price == 0 and huge or b.record.unit_buyout_price,
|
||||||
b.record.unit_blizzard_bid,
|
b.record.unit_blizzard_bid,
|
||||||
b.record.stack_size,
|
b.record.stack_size,
|
||||||
a.record.own and 1 or 0,
|
a.record.own and 1 or 0,
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ function get_filter_builder_query()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local name = m.blizzard_query.name
|
local name = m.blizzard_query.name
|
||||||
if not aux.index(aux.filter.parse_query_string(name), 'blizzard', 'name') then
|
if not index(aux.filter.parse_query_string(name), 'blizzard', 'name') then
|
||||||
name = aux.filter.quote(name)
|
name = aux.filter.quote(name)
|
||||||
end
|
end
|
||||||
add((name ~= '' or m.blizzard_query.exact) and name)
|
add((name ~= '' or m.blizzard_query.exact) and name)
|
||||||
@@ -175,7 +175,7 @@ function import_query_string()
|
|||||||
if components then
|
if components then
|
||||||
m.set_form(components)
|
m.set_form(components)
|
||||||
else
|
else
|
||||||
aux.log(error)
|
log(error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ function add_post_filter()
|
|||||||
m.filter_input:HighlightText()
|
m.filter_input:HighlightText()
|
||||||
m.filter_input:SetFocus()
|
m.filter_input:SetFocus()
|
||||||
elseif error then
|
elseif error then
|
||||||
aux.log(error)
|
log(error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -325,7 +325,7 @@ function initialize_filter_dropdown()
|
|||||||
value = filter,
|
value = filter,
|
||||||
func = function()
|
func = function()
|
||||||
m.filter_input:SetText(this.value)
|
m.filter_input:SetText(this.value)
|
||||||
if aux.index(aux.filter.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
if index(aux.filter.filters[this.value], 'input_type') == '' or this.value == 'not' then
|
||||||
m.add_post_filter()
|
m.add_post_filter()
|
||||||
elseif aux.filter.filters[this.value] then
|
elseif aux.filter.filters[this.value] then
|
||||||
m.filter_parameter_input:Show()
|
m.filter_parameter_input:Show()
|
||||||
|
|||||||
@@ -118,9 +118,9 @@ function update_auto_buy_filter()
|
|||||||
local queries = aux.filter.queries(g.aux_auto_buy_filter)
|
local queries = aux.filter.queries(g.aux_auto_buy_filter)
|
||||||
if queries then
|
if queries then
|
||||||
if getn(queries) > 1 then
|
if getn(queries) > 1 then
|
||||||
aux.log('Error: The automatic buyout filter may contain only one query')
|
log('Error: The automatic buyout filter may contain only one query')
|
||||||
elseif size(queries[1].blizzard_query) > 0 then
|
elseif size(queries[1].blizzard_query) > 0 then
|
||||||
aux.log('Error: The automatic buyout filter does not support Blizzard filters')
|
log('Error: The automatic buyout filter does not support Blizzard filters')
|
||||||
else
|
else
|
||||||
m.auto_buy_validator = queries[1].validator
|
m.auto_buy_validator = queries[1].validator
|
||||||
m.auto_buy_filter_button.prettified = queries[1].prettified
|
m.auto_buy_filter_button.prettified = queries[1].prettified
|
||||||
@@ -315,10 +315,10 @@ function public.execute(resume, real_time)
|
|||||||
return
|
return
|
||||||
elseif real_time then
|
elseif real_time then
|
||||||
if getn(queries) > 1 then
|
if getn(queries) > 1 then
|
||||||
aux.log('Invalid filter: The real time mode does not support multiple queries')
|
log('Invalid filter: The real time mode does not support multiple queries')
|
||||||
return
|
return
|
||||||
elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
||||||
aux.log('Invalid filter: The real time mode does not support page range filters')
|
log('Invalid filter: The real time mode does not support page range filters')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+49
-1
@@ -1,5 +1,53 @@
|
|||||||
aux.module 'util'
|
aux.module 'util'
|
||||||
|
|
||||||
|
function public.call(f, ...)
|
||||||
|
if f then
|
||||||
|
return f(unpack(arg))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function public.index(t, ...)
|
||||||
|
for i=1,arg.n do
|
||||||
|
t = t and t[arg[i]]
|
||||||
|
end
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
public.huge = 1.8*10^308
|
||||||
|
|
||||||
|
function public.log(...)
|
||||||
|
local msg = '[aux]'
|
||||||
|
for i=1,arg.n do
|
||||||
|
msg = msg..' '..tostring(arg[i])
|
||||||
|
end
|
||||||
|
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
function public.accessor.modified()
|
||||||
|
return IsShiftKeyDown() or IsControlKeyDown() or IsAltKeyDown()
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local _state = setmetatable({}, {__mode='kv'})
|
||||||
|
local __index = function(self, key)
|
||||||
|
return _state[self].handler({public=self, private=_state[self].state}, key)
|
||||||
|
end
|
||||||
|
function public.index_function(state, handler)
|
||||||
|
local state, self = {handler=handler, state=state}, {}
|
||||||
|
_state[self] = state
|
||||||
|
return setmetatable(self, {__metatable=false, __index=__index, state=state})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function public.temp(object)
|
||||||
|
getfenv(2).__ = object
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function public.L(body_string)
|
||||||
|
return loadstring 'function()'
|
||||||
|
end
|
||||||
|
|
||||||
function public.present(...)
|
function public.present(...)
|
||||||
local called
|
local called
|
||||||
return function()
|
return function()
|
||||||
@@ -211,7 +259,7 @@ function public.accessor.inventory()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if bag <= 4 then
|
if bag <= 4 then
|
||||||
return {bag, slot}, m.bag_type(bag)
|
return {bag, slot}, bag_type(bag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+9
-9
@@ -235,8 +235,8 @@ do
|
|||||||
end
|
end
|
||||||
for _, parser in {
|
for _, parser in {
|
||||||
{'class', aux.info.item_class_index},
|
{'class', aux.info.item_class_index},
|
||||||
{'subclass', aux.C(aux.info.item_subclass_index, aux.index(self.class, 2) or 0, aux._1)},
|
{'subclass', aux.C(aux.info.item_subclass_index, index(self.class, 2) or 0, aux._1)},
|
||||||
{'slot', aux.C(aux.info.item_slot_index, aux.index(self.class, 2) or 0, aux.index(self.subclass, 2) or 0, aux._1)},
|
{'slot', aux.C(aux.info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, aux._1)},
|
||||||
{'quality', aux.info.item_quality_index},
|
{'quality', aux.info.item_quality_index},
|
||||||
} do
|
} do
|
||||||
if not self[parser[1]] then
|
if not self[parser[1]] then
|
||||||
@@ -285,9 +285,9 @@ function public.parse_query_string(str)
|
|||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while parts[i] do
|
while parts[i] do
|
||||||
if aux.temp(m.operator(parts[i])) then
|
if temp(m.operator(parts[i])) then
|
||||||
tinsert(post_filter, __)
|
tinsert(post_filter, __)
|
||||||
elseif aux.temp(m.filters[parts[i]]) then
|
elseif temp(m.filters[parts[i]]) then
|
||||||
local input_type = __.input_type
|
local input_type = __.input_type
|
||||||
if input_type ~= '' then
|
if input_type ~= '' then
|
||||||
if not parts[i + 1] or not m.parse_parameter(input_type, parts[i + 1]) then
|
if not parts[i + 1] or not m.parse_parameter(input_type, parts[i + 1]) then
|
||||||
@@ -362,7 +362,7 @@ function public.queries(query_string)
|
|||||||
local query, _, error = m.query(str)
|
local query, _, error = m.query(str)
|
||||||
|
|
||||||
if not query then
|
if not query then
|
||||||
aux.log('Invalid filter:', error)
|
log('Invalid filter:', error)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
tinsert(queries, query)
|
tinsert(queries, query)
|
||||||
@@ -397,14 +397,14 @@ function suggestions(components)
|
|||||||
|
|
||||||
-- subclasses
|
-- subclasses
|
||||||
if not components.blizzard.subclass then
|
if not components.blizzard.subclass then
|
||||||
for _, subclass in {GetAuctionItemSubClasses(aux.index(components.blizzard.class, 2) or 0)} do
|
for _, subclass in {GetAuctionItemSubClasses(index(components.blizzard.class, 2) or 0)} do
|
||||||
tinsert(suggestions, subclass)
|
tinsert(suggestions, subclass)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- slots
|
-- slots
|
||||||
if not components.blizzard.slot then
|
if not components.blizzard.slot then
|
||||||
for _, invtype in {GetAuctionInvTypes(aux.index(components.blizzard.class, 2) or 0, aux.index(components.blizzard.subclass, 2) or 0)} do
|
for _, invtype in {GetAuctionInvTypes(index(components.blizzard.class, 2) or 0, index(components.blizzard.subclass, 2) or 0)} do
|
||||||
tinsert(suggestions, getglobal(invtype))
|
tinsert(suggestions, getglobal(invtype))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -511,7 +511,7 @@ function blizzard_query(components)
|
|||||||
local query = {name=filters.name and filters.name[2]}
|
local query = {name=filters.name and filters.name[2]}
|
||||||
|
|
||||||
local item_info, class_index, subclass_index, slot_index
|
local item_info, class_index, subclass_index, slot_index
|
||||||
if filters.exact and aux.temp(aux.cache.item_id(filters.name[2])) and aux.temp(aux.info.item(__)) then
|
if filters.exact and temp(aux.cache.item_id(filters.name[2])) and temp(aux.info.item(__)) then
|
||||||
item_info = __
|
item_info = __
|
||||||
class_index = aux.info.item_class_index(item_info.class)
|
class_index = aux.info.item_class_index(item_info.class)
|
||||||
subclass_index = aux.info.item_subclass_index(class_index or 0, item_info.subclass)
|
subclass_index = aux.info.item_subclass_index(class_index or 0, item_info.subclass)
|
||||||
@@ -528,7 +528,7 @@ function blizzard_query(components)
|
|||||||
query.quality = item_info.quality
|
query.quality = item_info.quality
|
||||||
else
|
else
|
||||||
for _, key in {'min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality'} do
|
for _, key in {'min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality'} do
|
||||||
query[key] = aux.index(filters[key], 2)
|
query[key] = index(filters[key], 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return query
|
return query
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.from_string(value)
|
function public.from_string(value)
|
||||||
if aux.temp(tonumber(value)) and __ >= 0 then
|
if temp(tonumber(value)) and __ >= 0 then
|
||||||
return __ * COPPER_PER_GOLD
|
return __ * COPPER_PER_GOLD
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user