working on module refactoring
This commit is contained in:
+20
-12
@@ -2,6 +2,14 @@ module 'aux'
|
||||
|
||||
include 'green_t'
|
||||
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local history = require 'aux.core.history'
|
||||
local stack = require 'aux.core.stack'
|
||||
local post = require 'aux.core.post'
|
||||
local scan = require 'aux.core.scan'
|
||||
|
||||
--aux_account_settings = {} -- TODO clean up the mess of savedvariables
|
||||
--aux_character_settings = {}
|
||||
|
||||
@@ -76,7 +84,7 @@ function private.SetItemRef(...) auto[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
|
||||
for item_info in present(aux_info.item(tonumber(select(3, strfind(arg[1], '^item:(%d+)'))))) do
|
||||
for item_info in present(info.item(tonumber(select(3, strfind(arg[1], '^item:(%d+)'))))) do
|
||||
return active_tab.CLICK_LINK(item_info)
|
||||
end
|
||||
end
|
||||
@@ -85,7 +93,7 @@ function private.UseContainerItem(...) auto[arg] = true
|
||||
if modified or not index(active_tab, 'USE_ITEM') then
|
||||
return orig.UseContainerItem(unpack(arg))
|
||||
end
|
||||
for item_info in present(aux_info.container_item(arg[1], arg[2])) do
|
||||
for item_info in present(info.container_item(arg[1], arg[2])) do
|
||||
return active_tab.USE_ITEM(item_info)
|
||||
end
|
||||
end
|
||||
@@ -164,9 +172,9 @@ end
|
||||
function private.AUCTION_HOUSE_CLOSED()
|
||||
bids_loaded = false
|
||||
current_owner_page = nil
|
||||
aux_post.stop()
|
||||
aux_stack.stop()
|
||||
aux_scan.abort()
|
||||
post.stop()
|
||||
stack.stop()
|
||||
scan.abort()
|
||||
tab = nil
|
||||
AuxFrame:Hide()
|
||||
end
|
||||
@@ -200,7 +208,7 @@ end
|
||||
do
|
||||
local function cost_label(cost)
|
||||
local label = LIGHTYELLOW_FONT_COLOR_CODE .. '(Total Cost: ' .. FONT_COLOR_CODE_CLOSE
|
||||
label = label .. (cost and aux_money.to_string2(cost, nil, LIGHTYELLOW_FONT_COLOR_CODE) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE)
|
||||
label = label .. (cost and money.to_string2(cost, nil, LIGHTYELLOW_FONT_COLOR_CODE) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE)
|
||||
label = label .. LIGHTYELLOW_FONT_COLOR_CODE .. ')' .. FONT_COLOR_CODE_CLOSE
|
||||
return label
|
||||
end
|
||||
@@ -216,10 +224,10 @@ do
|
||||
total_cost = nil
|
||||
break
|
||||
end
|
||||
local item_id, suffix_id = aux_info.parse_link(link)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetCraftReagentInfo(id, i))
|
||||
local _, price, limited = aux_cache.merchant_info(item_id)
|
||||
local value = price and not limited and price or aux_history.value(item_id .. ':' .. suffix_id)
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id)
|
||||
if not value then
|
||||
total_cost = nil
|
||||
break
|
||||
@@ -243,10 +251,10 @@ do
|
||||
total_cost = nil
|
||||
break
|
||||
end
|
||||
local item_id, suffix_id = aux_info.parse_link(link)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
local count = select(3, GetTradeSkillReagentInfo(id, i))
|
||||
local _, price, limited = aux_cache.merchant_info(item_id)
|
||||
local value = price and not limited and price or aux_history.value(item_id .. ':' .. suffix_id)
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
local value = price and not limited and price or history.value(item_id .. ':' .. suffix_id)
|
||||
if not value then
|
||||
total_cost = nil
|
||||
break
|
||||
|
||||
+7
-6
@@ -15,9 +15,12 @@ local function proxy_mt(fields, mutators)
|
||||
return { __metatable=false, __index=fields, __newindex=function(_, k, v) return mutators[k](v) end }
|
||||
end
|
||||
|
||||
local nop_default_mt, definition_helper_mt, require, include, create_module
|
||||
local loaded, _interface, _environment, _access, _name = {}, {}, {}, {}, {}
|
||||
|
||||
local definition_helper_mt = { __metatable=false }
|
||||
nop_default_mt = { __index=function() return nop end }
|
||||
|
||||
definition_helper_mt = { __metatable=false }
|
||||
function definition_helper_mt:__index(k)
|
||||
_name[self] = _name[self] and error('Invalid modifier "%s".', k) or k
|
||||
return self
|
||||
@@ -32,9 +35,9 @@ function definition_helper_mt:__newindex(k, v)
|
||||
_access[self], _name[self] = nil, nil
|
||||
end
|
||||
|
||||
local function require(name) return _interface[name] end
|
||||
function require(name) if not loaded[name] then create_module(name) end return _interface[name] end
|
||||
|
||||
local function include(self, name)
|
||||
function include(self, name)
|
||||
local module = name and loaded[name] or error('No module "%s".', name)
|
||||
for _, mode in MODES do
|
||||
for k, v in module[PUBLIC + mode] do
|
||||
@@ -45,9 +48,7 @@ local function include(self, name)
|
||||
end
|
||||
end
|
||||
|
||||
local nop_default_mt = { __index=function() return nop end }
|
||||
|
||||
local function create_module(name)
|
||||
function create_module(name)
|
||||
local P, environment, interface, definition_helper, modifiers, accessors, mutators, fields, public_accessors, public_mutators, public_fields
|
||||
environment, interface, definition_helper = {}, {}, setmetatable({}, definition_helper_mt)
|
||||
accessors = { private=function() _access[definition_helper] = PRIVATE; return definition_helper end, public=function() _access[definition_helper] = PUBLIC; return definition_helper end }
|
||||
|
||||
Reference in New Issue
Block a user