refactoring and bugfix
This commit is contained in:
+3
-5
@@ -63,10 +63,8 @@ aux 'core'
|
||||
|
||||
public.version = '5.0.0'
|
||||
|
||||
function public.log(...) temp=arg
|
||||
local msg = '[aux]'
|
||||
for i = 1, arg.n do msg = msg..' '..tostring(arg[i]) end
|
||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..msg)
|
||||
function public.print(...) temp=arg
|
||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE..'[aux] '..join(map(arg, tostring), ' '))
|
||||
end
|
||||
|
||||
local bids_loaded
|
||||
@@ -97,7 +95,7 @@ do
|
||||
for _, f in handlers do f() end
|
||||
elseif event == 'PLAYER_LOGIN' then
|
||||
for _, f in handlers2 do f() end
|
||||
log('v'..version..' loaded.')
|
||||
print('v'..version..' loaded.')
|
||||
else
|
||||
M[event]()
|
||||
end
|
||||
|
||||
+2
-2
@@ -190,11 +190,11 @@ end
|
||||
function public.populate_wdb(item_id)
|
||||
item_id = item_id or MIN_ITEM_ID
|
||||
if item_id > MAX_ITEM_ID then
|
||||
log 'Cache populated.'
|
||||
print 'Cache populated.'
|
||||
return
|
||||
end
|
||||
if not GetItemInfo('item:'..item_id) then
|
||||
log('Fetching item '..item_id..'.')
|
||||
print('Fetching item '..item_id..'.')
|
||||
AuxTooltip:SetHyperlink('item:'..item_id)
|
||||
end
|
||||
thread(populate_wdb, item_id + 1)
|
||||
|
||||
+19
-19
@@ -6,50 +6,50 @@ function _G.SlashCmdList.AUX(command)
|
||||
local arguments = tokenize(command)
|
||||
if arguments[1] == 'clear' and arguments[2] == 'history' then
|
||||
persistence.dataset = nil
|
||||
log 'History cleared.'
|
||||
print 'History cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'post' then
|
||||
persistence.dataset.post = nil
|
||||
log 'Post settings cleared.'
|
||||
print 'Post settings cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
||||
_G.aux_datasets = {}
|
||||
log 'Datasets cleared.'
|
||||
print 'Datasets cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
_G.aux_merchant_buy = {}
|
||||
log 'Merchant buy prices cleared.'
|
||||
print 'Merchant buy prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
_G.aux_merchant_sell = {}
|
||||
log 'Merchant sell prices cleared.'
|
||||
print 'Merchant sell prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
_G.aux_items = {}
|
||||
_G.aux_item_ids = {}
|
||||
_G.aux_auctionable_items = {}
|
||||
log 'Item cache cleared.'
|
||||
print 'Item cache cleared.'
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
aux.cache.populate_wdb()
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
_G.aux_tooltip_value = not _G.aux_tooltip_value
|
||||
log('Historical value in tooltip '..(_G.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
print('Historical value in tooltip '..(_G.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
_G.aux_tooltip_daily = not _G.aux_tooltip_daily
|
||||
log('Market value in tooltip '..(_G.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
print('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
|
||||
_G.aux_tooltip_vendor_buy = not _G.aux_tooltip_vendor_buy
|
||||
log('Vendor buy price in tooltip '..(_G.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
print('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
|
||||
_G.aux_tooltip_vendor_sell = not _G.aux_tooltip_vendor_sell
|
||||
log('Vendor sell price in tooltip '..(_G.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
print('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
|
||||
_G.aux_tooltip_disenchant_value = not _G.aux_tooltip_disenchant_value
|
||||
log('Disenchant value in tooltip '..(_G.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
print('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
|
||||
_G.aux_tooltip_disenchant_distribution = not _G.aux_tooltip_disenchant_distribution
|
||||
log('Disenchant distribution in tooltip '..(_G.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
print('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
|
||||
_G.aux_tooltip_disenchant_source = not _G.aux_tooltip_disenchant_source
|
||||
log('Disenchant source in tooltip '..(_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
print('Disenchant source in tooltip '..(_G.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||
_G.aux_ignore_owner = not _G.aux_ignore_owner
|
||||
log('Ignoring of owner '..(_G.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
print('Ignoring of owner '..(_G.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
||||
local realm = GetCVar('realmName')
|
||||
_G.aux_characters[realm] = _G.aux_characters[realm] or {}
|
||||
@@ -57,7 +57,7 @@ function _G.SlashCmdList.AUX(command)
|
||||
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if not _G.aux_characters[realm][name] then
|
||||
_G.aux_characters[realm][name] = true
|
||||
log('Character "'..name..'" added.')
|
||||
print('Character "'..name..'" added.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
||||
@@ -69,7 +69,7 @@ function _G.SlashCmdList.AUX(command)
|
||||
local name = gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if _G.aux_characters[realm][name] then
|
||||
_G.aux_characters[realm][name] = nil
|
||||
log('Character "'..name..'" removed.')
|
||||
print('Character "'..name..'" removed.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' then
|
||||
@@ -79,11 +79,11 @@ function _G.SlashCmdList.AUX(command)
|
||||
tinsert(chars, name)
|
||||
end
|
||||
if getn(chars) > 0 then
|
||||
log('Your characters: "'..join(chars, ', ')..'".')
|
||||
print('Your characters: "'..join(chars, ', ')..'".')
|
||||
else
|
||||
log 'You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".'
|
||||
print('You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".')
|
||||
end
|
||||
else
|
||||
log('Unknown command: "'..command..'"')
|
||||
print('Unknown command: "'..command..'"')
|
||||
end
|
||||
end
|
||||
+2
-2
@@ -398,7 +398,7 @@ function public.status_bar(parent)
|
||||
status_bar:SetFrameLevel(level + 2)
|
||||
status_bar:SetScript('OnUpdate', function()
|
||||
if this:GetValue() < 100 then
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*math.pi)+1)/2)/2)
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*PI)+1)/2)/2)
|
||||
else
|
||||
this:SetAlpha(1)
|
||||
end
|
||||
@@ -416,7 +416,7 @@ function public.status_bar(parent)
|
||||
status_bar:SetFrameLevel(level + 3)
|
||||
status_bar:SetScript('OnUpdate', function()
|
||||
if this:GetValue() < 100 then
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*math.pi)+1)/2)/2)
|
||||
this:SetAlpha(1 - ((math.sin(GetTime()*PI)+1)/2)/2)
|
||||
else
|
||||
this:SetAlpha(1)
|
||||
end
|
||||
|
||||
+21
-12
@@ -4,15 +4,24 @@ local type, getmetatable, setmetatable, setfenv, unpack, next, _G = type, getmet
|
||||
local PUBLIC, PRIVATE = 1, 2
|
||||
local CALL, INDEX, NEWINDEX = 1, 2, 3
|
||||
|
||||
local inspect = setmetatable({}, {
|
||||
__call=function(_, ...)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(' ')
|
||||
for i = 1, arg.n do DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE..format('arg%d: %s = %s', i, type(arg[i]), tostring(arg[i]))) end
|
||||
DEFAULT_CHAT_FRAME:AddMessage(' ')
|
||||
return unpack(arg)
|
||||
end,
|
||||
__sub=function(self, v) self(v); return v end, __pow=function(self, v) self(v); return v end,
|
||||
})
|
||||
do
|
||||
local function print(msg) DEFAULT_CHAT_FRAME:AddMessage(RED_FONT_COLOR_CODE..msg) end
|
||||
p = setmetatable({}, {
|
||||
__call=function(_, ...)
|
||||
for i = 1, arg.n do
|
||||
if type(arg[i]) == 'table' then
|
||||
print('arg'..i..' = {')
|
||||
for k, v in arg[i] do print(format(' %s: %s = %s', type(k) == 'string' and k or '['..tostring(k)..']', type(v), tostring(v))) end
|
||||
print('}')
|
||||
else
|
||||
print(format('arg%d: %s = %s', i, type(arg[i]), tostring(arg[i])))
|
||||
end
|
||||
end
|
||||
return unpack(arg)
|
||||
end,
|
||||
__pow=function(self, v) self(v); return v end,
|
||||
})
|
||||
end
|
||||
|
||||
local function error(msg, ...) return _G.error(format(msg or '', unpack(arg))..'\n'..debugstack(), 0) end
|
||||
local function import_error() error('Import error.') end
|
||||
@@ -109,10 +118,10 @@ function module(name)
|
||||
if name and _G[name] then return true end
|
||||
local interface, env, declarator = INTERFACE {}, ENVIRONMENT {}, DECLARATOR {}
|
||||
local self; self = {
|
||||
access = {inspect=PRIVATE, _=PRIVATE, error=PRIVATE, nop=PRIVATE, _G=PRIVATE, M=PRIVATE, I=PRIVATE, public=PRIVATE, private=PRIVATE},
|
||||
[CALL] = {inspect=inspect, import=function(interface) import(self, interface) end, error=error, nop=nop},
|
||||
access = {p=PRIVATE, _=PRIVATE, error=PRIVATE, nop=PRIVATE, _G=PRIVATE, M=PRIVATE, I=PRIVATE, public=PRIVATE, private=PRIVATE},
|
||||
[CALL] = {p=p, import=function(interface) import(self, interface) end, error=error, nop=nop},
|
||||
[INDEX] = {_G=const(_G), M=const(env), I=const(interface), public=function() return declarator.public end, private=function() return declarator.private end},
|
||||
[NEWINDEX] = {inspect=inspect, _=nop},
|
||||
[NEWINDEX] = {p=p, _=nop},
|
||||
declarator = declarator,
|
||||
default_access = PRIVATE,
|
||||
}
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ do
|
||||
elseif state == FOUND and not test(selection.record)(found_index) then
|
||||
buyout_button:Disable()
|
||||
bid_button:Disable()
|
||||
if not bid_in_progress() then state = IDLE end
|
||||
if not bid_in_progress then state = IDLE end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -176,7 +176,7 @@ end
|
||||
|
||||
function import_filter_string()
|
||||
local filter, error = filter_util.parse_filter_string(select(3, strfind(search_box:GetText(), '^([^;]*)')))
|
||||
if filter or log(error) then
|
||||
if filter or print(error) then
|
||||
set_form(filter)
|
||||
end
|
||||
end
|
||||
@@ -277,7 +277,7 @@ function add_post_filter()
|
||||
filter_input:HighlightText()
|
||||
filter_input:SetFocus()
|
||||
elseif error then
|
||||
log(error)
|
||||
print(error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -127,9 +127,9 @@ function update_auto_buy_filter()
|
||||
local queries = aux.filter_util.queries(_G.aux_auto_buy_filter)
|
||||
if queries then
|
||||
if getn(queries) > 1 then
|
||||
log 'Error: The automatic buyout filter does not support multi-queries'
|
||||
print 'Error: The automatic buyout filter does not support multi-queries'
|
||||
elseif size(queries[1].blizzard_query) > 0 then
|
||||
log 'Error: The automatic buyout filter does not support Blizzard filters'
|
||||
print 'Error: The automatic buyout filter does not support Blizzard filters'
|
||||
else
|
||||
auto_buy_validator = queries[1].validator
|
||||
auto_buy_filter_button.prettified = queries[1].prettified
|
||||
@@ -324,10 +324,10 @@ function public.execute(resume, real_time)
|
||||
return
|
||||
elseif real_time then
|
||||
if getn(queries) > 1 then
|
||||
log 'Error: The real time mode does not support multi-queries'
|
||||
print 'Error: The real time mode does not support multi-queries'
|
||||
return
|
||||
elseif queries[1].blizzard_query.first_page or queries[1].blizzard_query.last_page then
|
||||
log 'Error: The real time mode does not support page ranges'
|
||||
print 'Error: The real time mode does not support page ranges'
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -454,7 +454,7 @@ do
|
||||
elseif state == FOUND and not test(selection.record)(found_index) then
|
||||
buyout_button:Disable()
|
||||
bid_button:Disable()
|
||||
if not bid_in_progress() then
|
||||
if not bid_in_progress then
|
||||
state = IDLE
|
||||
end
|
||||
end
|
||||
|
||||
+1
-1
@@ -364,7 +364,7 @@ function public.queries(filter_string)
|
||||
str = trim(str)
|
||||
local query, _, error = query(str)
|
||||
if not query then
|
||||
log('Invalid filter:', error)
|
||||
print('Invalid filter:', error)
|
||||
return
|
||||
else
|
||||
tinsert(queries, query)
|
||||
|
||||
Reference in New Issue
Block a user