greent refactoring
This commit is contained in:
+25
-16
@@ -1,6 +1,6 @@
|
||||
module 'aux'
|
||||
|
||||
include 'green_t'
|
||||
include 'green_T'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
@@ -19,7 +19,8 @@ function M.set_p(v)
|
||||
inspect(nil, v)
|
||||
end
|
||||
|
||||
function M.print(...) auto_release(arg, true)
|
||||
function M.print(...)
|
||||
auto_release(arg, true)
|
||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '[aux] ' .. join(map(arg, tostring), ' '))
|
||||
end
|
||||
|
||||
@@ -35,9 +36,9 @@ for event in temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION
|
||||
event_frame:RegisterEvent(event)
|
||||
end
|
||||
|
||||
ADDON_LOADED = t
|
||||
ADDON_LOADED = T
|
||||
do
|
||||
local handlers, handlers2 = t, t
|
||||
local handlers, handlers2 = T, T
|
||||
function M.set_LOAD(f)
|
||||
tinsert(handlers, f)
|
||||
end
|
||||
@@ -58,9 +59,9 @@ do
|
||||
end)
|
||||
end
|
||||
|
||||
tab_info = t
|
||||
tab_info = T
|
||||
function M.TAB(name)
|
||||
local tab = T('name', name)
|
||||
local tab = O('name', name)
|
||||
local env = getfenv(2)
|
||||
function env.set_OPEN(f) tab.OPEN = f end
|
||||
function env.set_CLOSE(f) tab.CLOSE = f end
|
||||
@@ -80,7 +81,8 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function SetItemRef(...) auto_release(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
|
||||
return orig.SetItemRef(unpack(arg))
|
||||
end
|
||||
@@ -89,7 +91,8 @@ function SetItemRef(...) auto_release(arg, true)
|
||||
end
|
||||
end
|
||||
|
||||
function UseContainerItem(...) auto_release(arg, true)
|
||||
function UseContainerItem(...)
|
||||
auto_release(arg, true)
|
||||
if modified or not index(active_tab, 'USE_ITEM') then
|
||||
return orig.UseContainerItem(unpack(arg))
|
||||
end
|
||||
@@ -98,8 +101,9 @@ function UseContainerItem(...) auto_release(arg, true)
|
||||
end
|
||||
end
|
||||
|
||||
M.orig = setmetatable({[_G]=t}, {__index=function(self, key) return self[_G][key] end})
|
||||
function M.hook(...) auto_release(arg, true)
|
||||
M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end})
|
||||
function M.hook(...)
|
||||
auto_release(arg, true)
|
||||
local name, object, handler
|
||||
if arg.n == 3 then
|
||||
name, object, handler = unpack(arg)
|
||||
@@ -107,7 +111,7 @@ function M.hook(...) auto_release(arg, true)
|
||||
object, name, handler = _G, unpack(arg)
|
||||
end
|
||||
handler = handler or getfenv(2)[name]
|
||||
orig[object] = orig[object] or t
|
||||
orig[object] = orig[object] or T
|
||||
assert(not orig[object][name], '"' .. name .. '" is already hooked into.')
|
||||
orig[object][name], object[name] = object[name], handler
|
||||
return hook
|
||||
@@ -195,7 +199,8 @@ end
|
||||
|
||||
do
|
||||
local last_owner_page_requested
|
||||
function GetOwnerAuctionItems(...) auto_release(arg, true)
|
||||
function GetOwnerAuctionItems(...)
|
||||
auto_release(arg, true)
|
||||
local page = arg[1]
|
||||
last_owner_page_requested = page
|
||||
return orig.GetOwnerAuctionItems(unpack(arg))
|
||||
@@ -208,7 +213,8 @@ end
|
||||
function ADDON_LOADED.Blizzard_AuctionUI()
|
||||
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
||||
AuctionFrame:SetScript('OnHide', nil)
|
||||
hook('ShowUIPanel', function(...) auto_release(arg, true)
|
||||
hook('ShowUIPanel', function(...)
|
||||
auto_release(arg, true)
|
||||
if arg[1] == AuctionFrame then return AuctionFrame:Show() end
|
||||
return orig.ShowUIPanel(unpack(arg))
|
||||
end)
|
||||
@@ -223,7 +229,8 @@ do
|
||||
return label
|
||||
end
|
||||
function ADDON_LOADED.Blizzard_CraftUI()
|
||||
hook('CraftFrame_SetSelection', function(...) auto_release(arg, true)
|
||||
hook('CraftFrame_SetSelection', function(...)
|
||||
auto_release(arg, true)
|
||||
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||
local id = GetCraftSelectionIndex()
|
||||
local reagent_count = GetCraftNumReagents(id)
|
||||
@@ -250,7 +257,8 @@ do
|
||||
end)
|
||||
end
|
||||
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
||||
hook('TradeSkillFrame_SetSelection', function(...) auto_release(arg, true)
|
||||
hook('TradeSkillFrame_SetSelection', function(...)
|
||||
auto_release(arg, true)
|
||||
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||
local id = GetTradeSkillSelectionIndex()
|
||||
local reagent_count = GetTradeSkillNumReagents(id)
|
||||
@@ -278,7 +286,8 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function AuctionFrameAuctions_OnEvent(...) auto_release(arg, true)
|
||||
function AuctionFrameAuctions_OnEvent(...)
|
||||
auto_release(arg, true)
|
||||
if AuctionFrameAuctions:IsVisible() then
|
||||
return orig.AuctionFrameAuctions_OnEvent(unpack(arg))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user