From 77e1a9b8e0f375dd53ee3edadc509dc2b470a9dc Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 22 Aug 2016 21:46:00 +0200 Subject: [PATCH] big refactoring --- aux-addon.lua | 58 ++++++++++++++++++++------------------------------- aux-addon.toc | 8 +++---- 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/aux-addon.lua b/aux-addon.lua index fbab392..b60c097 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -1,13 +1,13 @@ function INIT() import :_ 'aux' :_ 'util' - function LOAD() - import :_ 'aux' :_ 'util' - end end module 'aux' public.version = '5.0.0' +public.bids_loaded = false +public.current_owner_page = nil + do local table_pool, temporary = {}, {} @@ -20,10 +20,10 @@ do end) function public.wipe(t) -- like with a cloth or something - for k in t do - t[k] = nil - end - table.setn(t, 0) + for k in t do + t[k] = nil + end + table.setn(t, 0) end function public.recycle(t) @@ -54,27 +54,11 @@ do end end - public.tmp = modifier(function(t) + public.temp = modifier(function(t) temporary[t] = true return t end) - do - local mt = { - __call=function(self, arg1, arg2) - tinsert(self, arg2 or arg1) - return self - end, - __index=function(self, key) - tinsert(self, key) - return self - end, - } - function public.accessor.from() - return setmetatable(tt, mt) - end - end - do local mt = {__call = function(self, key) return self[key] end} public.set = modifier(function(table) @@ -84,19 +68,26 @@ do return setmetatable(self, mt) end) end + + do + local mt = { + __call=function(self, value) + tinsert(self, value) + return self + end, + } + function public.accessor.from() + return setmetatable(t, mt) + end + end + - public.array = modifier(function(table) - local self = t - for _, v in table do tinsert(self, v) end - recycle(table) - return self - end) -- TODO map end local event_frame = CreateFrame 'Frame' -for event in tmp-set-from . ADDON_LOADED . VARIABLES_LOADED . PLAYER_LOGIN . AUCTION_HOUSE_SHOW . AUCTION_HOUSE_CLOSED . AUCTION_BIDDER_LIST_UPDATE . AUCTION_OWNED_LIST_UPDATE do +for event in temp-set-from 'ADDON_LOADED' 'VARIABLES_LOADED' 'PLAYER_LOGIN' 'AUCTION_HOUSE_SHOW' 'AUCTION_HOUSE_CLOSED' 'AUCTION_BIDDER_LIST_UPDATE' 'AUCTION_OWNED_LIST_UPDATE' do event_frame:RegisterEvent(event) end @@ -119,9 +110,6 @@ do end) end -public.bids_loaded = false -public.current_owner_page = nil - function LOAD() import :_ 'util' 'gui' do @@ -181,7 +169,7 @@ function public.tab(index, name) local module_env = getfenv(2) local tab = {name=name, env=module_env} function module_env.public.accessor.ACTIVE() return tab == active_tab end - for handler in tmp-set-from . OPEN . CLOSE . CLICK_LINK . USE_ITEM do module_env.mutable[handler] = nil end + for handler in temp-set-from 'OPEN' 'CLOSE' 'CLICK_LINK' 'USE_ITEM' do module_env.mutable[handler] = nil end tabs[index] = tab end do diff --git a/aux-addon.toc b/aux-addon.toc index 03ca9eb..10af703 100644 --- a/aux-addon.toc +++ b/aux-addon.toc @@ -1,5 +1,6 @@ ## Interface: 11200 ## Title: aux +## Title: Auction House AddOn ## SavedVariablesPerCharacter: aux_auto_buy_filter, aux_tooltip_value, aux_tooltip_daily, aux_tooltip_vendor_buy, aux_tooltip_vendor_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution, aux_tooltip_disenchant_source ## SavedVariables: aux_datasets, aux_items, aux_item_ids, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell, aux_characters, aux_recent_searches, aux_favorite_searches, aux_ignore_owner, aux_price_per_unit @@ -7,18 +8,17 @@ module.lua aux-addon.lua util\core.lua control.lua +util\color.lua gui\core.lua frame.lua - util\completion.lua util\persistence.lua util\sort.lua util\money.lua util\info.lua util\filter.lua -util\scan_util.lua - +util\scan.lua core\cache.lua core\disenchant.lua @@ -29,12 +29,10 @@ core\post.lua core\history.lua core\tooltip.lua - gui\listing.lua gui\auction_listing.lua gui\item_listing.lua - tabs\search\core.lua tabs\search\results.lua tabs\search\saved.lua