refactoring
This commit is contained in:
+9
-9
@@ -19,7 +19,7 @@ function M.set_p(v)
|
|||||||
inspect(nil, v)
|
inspect(nil, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.print(...) auto[arg] = true
|
function M.print(...) auto_release(arg, true)
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '[aux] ' .. join(map(arg, tostring), ' '))
|
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '[aux] ' .. join(map(arg, tostring), ' '))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetItemRef(...) auto[arg] = true
|
function SetItemRef(...) auto_release(arg, true)
|
||||||
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
|
||||||
return orig.SetItemRef(unpack(arg))
|
return orig.SetItemRef(unpack(arg))
|
||||||
end
|
end
|
||||||
@@ -89,7 +89,7 @@ function SetItemRef(...) auto[arg] = true
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UseContainerItem(...) auto[arg] = true
|
function UseContainerItem(...) auto_release(arg, true)
|
||||||
if modified or not index(active_tab, 'USE_ITEM') then
|
if modified or not index(active_tab, 'USE_ITEM') then
|
||||||
return orig.UseContainerItem(unpack(arg))
|
return orig.UseContainerItem(unpack(arg))
|
||||||
end
|
end
|
||||||
@@ -99,7 +99,7 @@ function UseContainerItem(...) auto[arg] = true
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.orig = setmetatable({[_G]=t}, {__index=function(self, key) return self[_G][key] end})
|
M.orig = setmetatable({[_G]=t}, {__index=function(self, key) return self[_G][key] end})
|
||||||
function M.hook(...) auto[arg] = true
|
function M.hook(...) auto_release(arg, true)
|
||||||
local name, object, handler
|
local name, object, handler
|
||||||
if arg.n == 3 then
|
if arg.n == 3 then
|
||||||
name, object, handler = unpack(arg)
|
name, object, handler = unpack(arg)
|
||||||
@@ -185,7 +185,7 @@ end
|
|||||||
|
|
||||||
do
|
do
|
||||||
local last_owner_page_requested
|
local last_owner_page_requested
|
||||||
function GetOwnerAuctionItems(...) auto[arg] = true
|
function GetOwnerAuctionItems(...) auto_release(arg, true)
|
||||||
local page = arg[1]
|
local page = arg[1]
|
||||||
last_owner_page_requested = page
|
last_owner_page_requested = page
|
||||||
return orig.GetOwnerAuctionItems(unpack(arg))
|
return orig.GetOwnerAuctionItems(unpack(arg))
|
||||||
@@ -198,7 +198,7 @@ end
|
|||||||
function 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)
|
||||||
hook('ShowUIPanel', function(...) auto[arg] = true
|
hook('ShowUIPanel', function(...) auto_release(arg, true)
|
||||||
if arg[1] == AuctionFrame then return AuctionFrame:Show() end
|
if arg[1] == AuctionFrame then return AuctionFrame:Show() end
|
||||||
return orig.ShowUIPanel(unpack(arg))
|
return orig.ShowUIPanel(unpack(arg))
|
||||||
end)
|
end)
|
||||||
@@ -213,7 +213,7 @@ do
|
|||||||
return label
|
return label
|
||||||
end
|
end
|
||||||
function ADDON_LOADED.Blizzard_CraftUI()
|
function ADDON_LOADED.Blizzard_CraftUI()
|
||||||
hook('CraftFrame_SetSelection', function(...) auto[arg] = true
|
hook('CraftFrame_SetSelection', function(...) auto_release(arg, true)
|
||||||
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||||
local id = GetCraftSelectionIndex()
|
local id = GetCraftSelectionIndex()
|
||||||
local reagent_count = GetCraftNumReagents(id)
|
local reagent_count = GetCraftNumReagents(id)
|
||||||
@@ -240,7 +240,7 @@ do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
||||||
hook('TradeSkillFrame_SetSelection', function(...) auto[arg] = true
|
hook('TradeSkillFrame_SetSelection', function(...) auto_release(arg, true)
|
||||||
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||||
local id = GetTradeSkillSelectionIndex()
|
local id = GetTradeSkillSelectionIndex()
|
||||||
local reagent_count = GetTradeSkillNumReagents(id)
|
local reagent_count = GetTradeSkillNumReagents(id)
|
||||||
@@ -268,7 +268,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AuctionFrameAuctions_OnEvent(...) auto[arg] = true
|
function AuctionFrameAuctions_OnEvent(...) auto_release(arg, true)
|
||||||
if AuctionFrameAuctions:IsVisible() then
|
if AuctionFrameAuctions:IsVisible() then
|
||||||
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -146,7 +146,7 @@ function merchant_buy_scan()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function merchant_sell_scan()
|
function merchant_sell_scan()
|
||||||
for slot in info.inventory do auto[slot] = true
|
for slot in info.inventory do auto_release(slot, true)
|
||||||
local item_info = temp-info.container_item(unpack(slot))
|
local item_info = temp-info.container_item(unpack(slot))
|
||||||
if item_info then
|
if item_info then
|
||||||
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||||
|
|||||||
+4
-4
@@ -19,7 +19,7 @@ function LOAD()
|
|||||||
local inside_hook = false
|
local inside_hook = false
|
||||||
for name, f in game_tooltip_hooks do
|
for name, f in game_tooltip_hooks do
|
||||||
local name, f = name, f
|
local name, f = name, f
|
||||||
hook(name, GameTooltip, function(...) auto[arg] = true
|
hook(name, GameTooltip, function(...) auto_release(arg, true)
|
||||||
inside_hook = true
|
inside_hook = true
|
||||||
game_tooltip_money = 0
|
game_tooltip_money = 0
|
||||||
local ret = temp-A(orig[GameTooltip][name](unpack(arg)))
|
local ret = temp-A(orig[GameTooltip][name](unpack(arg)))
|
||||||
@@ -29,7 +29,7 @@ function LOAD()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
||||||
GameTooltip:SetScript('OnTooltipAddMoney', function(...) auto[arg] = true
|
GameTooltip:SetScript('OnTooltipAddMoney', function(...) auto_release(arg, true)
|
||||||
if inside_hook then
|
if inside_hook then
|
||||||
game_tooltip_money = arg1
|
game_tooltip_money = arg1
|
||||||
else
|
else
|
||||||
@@ -38,7 +38,7 @@ function LOAD()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local orig = SetItemRef
|
local orig = SetItemRef
|
||||||
setglobal('SetItemRef', function(...) auto[arg] = true
|
setglobal('SetItemRef', function(...) auto_release(arg, true)
|
||||||
local name, _, quality = GetItemInfo(arg[1])
|
local name, _, quality = GetItemInfo(arg[1])
|
||||||
local ret = A(orig(unpack(arg)))
|
local ret = A(orig(unpack(arg)))
|
||||||
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
if not IsShiftKeyDown() and not IsControlKeyDown() and name then
|
||||||
@@ -216,7 +216,7 @@ end
|
|||||||
function game_tooltip_hooks:SetAuctionSellItem()
|
function game_tooltip_hooks:SetAuctionSellItem()
|
||||||
local name, _, quantity = GetAuctionSellItemInfo()
|
local name, _, quantity = GetAuctionSellItemInfo()
|
||||||
if name then
|
if name then
|
||||||
for slot in info.inventory do auto[slot] = true
|
for slot in info.inventory do auto_release(slot, true)
|
||||||
local link = GetContainerItemLink(unpack(slot))
|
local link = GetContainerItemLink(unpack(slot))
|
||||||
if link and select(5, info.parse_link(link)) == name then
|
if link and select(5, info.parse_link(link)) == name then
|
||||||
extend_tooltip(GameTooltip, link, quantity)
|
extend_tooltip(GameTooltip, link, quantity)
|
||||||
|
|||||||
@@ -912,7 +912,7 @@ local methods = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
SetSort = function(self, ...) auto[arg] = true
|
SetSort = function(self, ...) auto_release(arg, true)
|
||||||
for k = 1, arg.n do
|
for k = 1, arg.n do
|
||||||
for i, sort in self.sorts do
|
for i, sort in self.sorts do
|
||||||
if sort.index == abs(arg[k]) then
|
if sort.index == abs(arg[k]) then
|
||||||
|
|||||||
+2
-2
@@ -24,7 +24,7 @@ function LOAD()
|
|||||||
aux_background:SetTexture(color.content.background())
|
aux_background:SetTexture(color.content.background())
|
||||||
aux_background:SetAllPoints(DropDownList1Backdrop)
|
aux_background:SetAllPoints(DropDownList1Backdrop)
|
||||||
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
|
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
|
||||||
hook('ToggleDropDownMenu', function(...) auto[arg] = true
|
hook('ToggleDropDownMenu', function(...) auto_release(arg, true)
|
||||||
local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
|
local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg)))
|
||||||
local dropdown = _G[arg[4] or ''] or this:GetParent()
|
local dropdown = _G[arg[4] or ''] or this:GetParent()
|
||||||
if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
|
if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then
|
||||||
@@ -109,7 +109,7 @@ do
|
|||||||
return orig()
|
return orig()
|
||||||
end)
|
end)
|
||||||
M.menu = vararg-function(arg)
|
M.menu = vararg-function(arg)
|
||||||
structure = perm-arg
|
structure = static-arg
|
||||||
local x, y = GetCursorPosition()
|
local x, y = GetCursorPosition()
|
||||||
menu:ClearAllPoints()
|
menu:ClearAllPoints()
|
||||||
menu:SetPoint('BOTTOMLEFT', x + 75, y)
|
menu:SetPoint('BOTTOMLEFT', x + 75, y)
|
||||||
|
|||||||
+18
-20
@@ -2,9 +2,9 @@ library 'green_t'
|
|||||||
|
|
||||||
local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable
|
local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable
|
||||||
|
|
||||||
local wipe, acquire, release, set_auto_release
|
local wipe, acquire, release, auto_release
|
||||||
do
|
do
|
||||||
local pool, pool_size, overflow_pool, auto_release = {}, 0, setmetatable({}, {__mode='k'}), {}
|
local pool, pool_size, overflow_pool, auto_release_queue = {}, 0, setmetatable({}, {__mode='k'}), {}
|
||||||
|
|
||||||
function wipe(t)
|
function wipe(t)
|
||||||
setmetatable(t, nil)
|
setmetatable(t, nil)
|
||||||
@@ -15,8 +15,8 @@ do
|
|||||||
M.wipe = wipe
|
M.wipe = wipe
|
||||||
|
|
||||||
CreateFrame'Frame':SetScript('OnUpdate', function()
|
CreateFrame'Frame':SetScript('OnUpdate', function()
|
||||||
for t in auto_release do release(t) end
|
for t in auto_release_queue do release(t) end
|
||||||
wipe(auto_release)
|
wipe(auto_release_queue)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function acquire()
|
function acquire()
|
||||||
@@ -35,7 +35,7 @@ do
|
|||||||
|
|
||||||
function release(t)
|
function release(t)
|
||||||
wipe(t)
|
wipe(t)
|
||||||
auto_release[t] = nil
|
auto_release_queue[t] = nil
|
||||||
if pool_size < 50 then
|
if pool_size < 50 then
|
||||||
pool_size = pool_size + 1
|
pool_size = pool_size + 1
|
||||||
pool[pool_size] = t
|
pool[pool_size] = t
|
||||||
@@ -45,32 +45,30 @@ do
|
|||||||
end
|
end
|
||||||
M.release = release
|
M.release = release
|
||||||
|
|
||||||
function set_auto_release(v, enable)
|
function auto_release(v, enable)
|
||||||
if type(v) ~= 'table' then return end
|
if type(v) ~= 'table' then return end
|
||||||
auto_release[v] = enable and true or nil
|
auto_release_queue[v] = enable and true or nil
|
||||||
end
|
end
|
||||||
M.set_auto_release = set_auto_release
|
M.auto_release = auto_release
|
||||||
end
|
end
|
||||||
|
|
||||||
M.get_t = acquire
|
M.get_t = acquire
|
||||||
|
|
||||||
function M.get_tt()
|
function M.get_tt()
|
||||||
local t = acquire()
|
local t = acquire()
|
||||||
set_auto_release(t, true)
|
auto_release(t, true)
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
M.auto = setmetatable({}, {
|
|
||||||
__metatable = false,
|
|
||||||
__newindex = function(_, k, v) set_auto_release(k, v) end,
|
|
||||||
})
|
|
||||||
M.temp = setmetatable({}, {
|
M.temp = setmetatable({}, {
|
||||||
__metatable = false,
|
__metatable = false,
|
||||||
__sub = function(_, v) set_auto_release(v, true); return v end,
|
__newindex = nop,
|
||||||
|
__sub = function(_, v) auto_release(v, true); return v end,
|
||||||
})
|
})
|
||||||
M.perm = setmetatable({}, {
|
M.static = setmetatable({}, {
|
||||||
__metatable = false,
|
__metatable = false,
|
||||||
__sub = function(_, v) set_auto_release(v, false); return v end,
|
__newindex = nop,
|
||||||
|
__sub = function(_, v) auto_release(v, false); return v end,
|
||||||
})
|
})
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -91,7 +89,7 @@ do
|
|||||||
local MAXPARAMS = 100
|
local MAXPARAMS = 100
|
||||||
|
|
||||||
local code = [[
|
local code = [[
|
||||||
local f, setn, acquire, set_auto_release = f, setn, acquire, set_auto_release
|
local f, setn, acquire, auto_release = f, setn, acquire, auto_release
|
||||||
return function(
|
return function(
|
||||||
]]
|
]]
|
||||||
for i = 1, MAXPARAMS - 1 do
|
for i = 1, MAXPARAMS - 1 do
|
||||||
@@ -109,7 +107,7 @@ do
|
|||||||
code = code .. [[
|
code = code .. [[
|
||||||
until true
|
until true
|
||||||
local t = acquire()
|
local t = acquire()
|
||||||
set_auto_release(t, true)
|
auto_release(t, true)
|
||||||
setn(t, n)
|
setn(t, n)
|
||||||
repeat
|
repeat
|
||||||
]]
|
]]
|
||||||
@@ -124,7 +122,7 @@ do
|
|||||||
|
|
||||||
function vararg(f)
|
function vararg(f)
|
||||||
local chunk = loadstring(code)
|
local chunk = loadstring(code)
|
||||||
setfenv(chunk, {f=f, setn=setn, acquire=acquire, set_auto_release=set_auto_release})
|
setfenv(chunk, {f=f, setn=setn, acquire=acquire, auto_release=auto_release})
|
||||||
return chunk()
|
return chunk()
|
||||||
end
|
end
|
||||||
M.vararg = setmetatable({}, {
|
M.vararg = setmetatable({}, {
|
||||||
@@ -134,7 +132,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.A = vararg(function(arg)
|
M.A = vararg(function(arg)
|
||||||
set_auto_release(arg, false)
|
auto_release(arg, false)
|
||||||
return arg
|
return arg
|
||||||
end)
|
end)
|
||||||
M.S = vararg(function(arg)
|
M.S = vararg(function(arg)
|
||||||
|
|||||||
+2
-2
@@ -343,7 +343,7 @@ function quantity_update(max_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function unit_vendor_price(item_key)
|
function unit_vendor_price(item_key)
|
||||||
for slot in info.inventory do auto[slot] = true
|
for slot in info.inventory do auto_release(slot, true)
|
||||||
local item_info = info.container_item(unpack(slot))
|
local item_info = info.container_item(unpack(slot))
|
||||||
if item_info and item_info.item_key == item_key then
|
if item_info and item_info.item_key == item_key then
|
||||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||||
@@ -407,7 +407,7 @@ end
|
|||||||
|
|
||||||
function update_inventory_records()
|
function update_inventory_records()
|
||||||
local auctionable_map = tt
|
local auctionable_map = tt
|
||||||
for slot in info.inventory do auto[slot] = true
|
for slot in info.inventory do auto_release(slot, true)
|
||||||
for item_info in present(info.container_item(unpack(slot))) do
|
for item_info in present(info.container_item(unpack(slot))) do
|
||||||
local charge_class = item_info.charges or 0
|
local charge_class = item_info.charges or 0
|
||||||
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
if info.auctionable(item_info.tooltip, nil, item_info.lootable) then
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.papply = vararg-function(arg)
|
M.papply = vararg-function(arg)
|
||||||
local f, arg1 = tremove(arg, 1), perm-arg
|
local f, arg1 = tremove(arg, 1), static-arg
|
||||||
return vararg-function(arg)
|
return vararg-function(arg)
|
||||||
for i = 1, getn(arg) do
|
for i = 1, getn(arg) do
|
||||||
tinsert(arg1, arg[i])
|
tinsert(arg1, arg[i])
|
||||||
|
|||||||
Reference in New Issue
Block a user