From bf4078afaed9e88e87f9e80e7a7d014a873d1993 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sun, 5 Mar 2017 02:48:29 +0100 Subject: [PATCH] refactoring, removed tooltip source --- README.md | 3 +-- core/cache.lua | 10 +++++----- core/disenchant.lua | 36 ------------------------------------ core/history.lua | 2 +- core/scan.lua | 2 +- core/slash.lua | 11 +++-------- core/tooltip.lua | 15 +-------------- gui/core.lua | 2 +- libs/T.lua | 2 +- libs/module.lua | 9 ++++----- tabs/bids/core.lua | 2 +- tabs/search/filter.lua | 2 +- tabs/search/frame.lua | 4 ++-- tabs/search/results.lua | 4 ++-- tabs/search/saved.lua | 4 ++-- util/persistence.lua | 2 +- 16 files changed, 27 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 76af837..9b78a01 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,8 @@ The most advanced auction house addOn for the 1.12 client with some features mor ### Tooltip **/aux tooltip value**
**/aux tooltip daily**
-**/aux tooltip disenchant distribution**
**/aux tooltip disenchant value**
-**/aux tooltip disenchant source**
+**/aux tooltip disenchant distribution**
**/aux tooltip vendor buy**
**/aux tooltip vendor sell**
diff --git a/core/cache.lua b/core/cache.lua index 26d7a0d..af9a116 100644 --- a/core/cache.lua +++ b/core/cache.lua @@ -12,11 +12,11 @@ local MAX_ITEM_ID = 30000 local items_schema = {'tuple', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}} local merchant_buy_schema = {'tuple', '#', {unit_price='number'}, {limited='boolean'}} -_G.aux_items = T -_G.aux_item_ids = T -_G.aux_auctionable_items = T -_G.aux_merchant_buy = T -_G.aux_merchant_sell = T +_G.aux_items = {} +_G.aux_item_ids = {} +_G.aux_auctionable_items = {} +_G.aux_merchant_buy = {} +_G.aux_merchant_sell = {} function LOAD() scan_wdb() diff --git a/core/disenchant.lua b/core/disenchant.lua index 10e5724..7536512 100644 --- a/core/disenchant.lua +++ b/core/disenchant.lua @@ -7,42 +7,6 @@ local history = require 'aux.core.history' local UNCOMMON, RARE, EPIC = 2, 3, 4 -do - local data = O( - 10940, A('DUST', '1-20'), - 11083, A('DUST', '21-30'), - 11137, A('DUST', '31-40'), - 11176, A('DUST', '41-50'), - 16204, A('DUST', '51-60'), - - 10938, A('ESSENCE', '1-10'), - 10939, A('ESSENCE', '11-15'), - 10998, A('ESSENCE', '16-20'), - 11082, A('ESSENCE', '21-25'), - 11134, A('ESSENCE', '26-30'), - 11135, A('ESSENCE', '31-35'), - 11174, A('ESSENCE', '36-40'), - 11175, A('ESSENCE', '41-45'), - 16202, A('ESSENCE', '46-50'), - 16203, A('ESSENCE', '51-60'), - - 10978, A('SHARD', '1-20'), - 11084, A('SHARD', '21-25'), - 11138, A('SHARD', '26-30'), - 11139, A('SHARD', '31-35'), - 11177, A('SHARD', '36-40'), - 11178, A('SHARD', '41-45'), - 14343, A('SHARD', '46-50'), - 14344, A('SHARD', '51-60'), - - 20725, A('CRYSTAL', '51+') - ) - - function M.source(item_id) - return unpack(data[item_id] or empty) - end -end - local ARMOR = S( 'INVTYPE_HEAD', 'INVTYPE_NECK', diff --git a/core/history.lua b/core/history.lua index ff4a1ef..fcef5ad 100644 --- a/core/history.lua +++ b/core/history.lua @@ -7,7 +7,7 @@ local persistence = require 'aux.util.persistence' local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='number'}, {data_points={'list', ';', {'tuple', '@', {value='number'}, {time='number'}}}}} -local value_cache = T +local value_cache = {} do local cache diff --git a/core/scan.lua b/core/scan.lua index 2affea0..68d265f 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -9,7 +9,7 @@ local history = require 'aux.core.history' local PAGE_SIZE = 50 do - local scan_states = T + local scan_states = {} function M.start(params) local old_state = scan_states[params.type] diff --git a/core/slash.lua b/core/slash.lua index 5571423..6e07568 100644 --- a/core/slash.lua +++ b/core/slash.lua @@ -1,6 +1,5 @@ module 'aux.core.slash' -include 'T' include 'aux' local cache = require 'aux.core.cache' @@ -44,13 +43,10 @@ function SlashCmdList.AUX(command) elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then _G.aux_tooltip_disenchant_distribution = not aux_tooltip_disenchant_distribution print('tooltip disenchant distribution ' .. status(aux_tooltip_disenchant_distribution)) - elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then - _G.aux_tooltip_disenchant_source = not aux_tooltip_disenchant_source - print('tooltip disenchant source ' .. status(aux_tooltip_disenchant_source)) elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then - _G.aux_items = T - _G.aux_item_ids = T - _G.aux_auctionable_items = T + _G.aux_items = {} + _G.aux_item_ids = {} + _G.aux_auctionable_items = {} print('Item cache cleared.') elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then cache.populate_wdb() @@ -65,7 +61,6 @@ function SlashCmdList.AUX(command) print('- tooltip vendor sell [' .. status(aux_tooltip_merchant_sell) .. ']') print('- tooltip disenchant value [' .. status(aux_tooltip_disenchant_value) .. ']') print('- tooltip disenchant distribution [' .. status(aux_tooltip_disenchant_distribution) .. ']') - print('- tooltip disenchant source [' .. status(aux_tooltip_disenchant_source) .. ']') print('- clear item cache') print('- populate wdb') end diff --git a/core/tooltip.lua b/core/tooltip.lua index aa0041a..67fb3a8 100644 --- a/core/tooltip.lua +++ b/core/tooltip.lua @@ -14,7 +14,7 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE _G.aux_tooltip_value = true -local game_tooltip_hooks, game_tooltip_money = T, 0 +local game_tooltip_hooks, game_tooltip_money = {}, 0 function LOAD() do @@ -55,19 +55,6 @@ end function M.extend_tooltip(tooltip, link, quantity) local item_id, suffix_id = info.parse_link(link) quantity = IsShiftKeyDown() and quantity or 1 - if aux_tooltip_disenchant_source then - local r, g, b = color.tooltip.disenchant.source() - local type, range = disenchant.source(item_id) - if type == 'CRYSTAL' then - tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), r, g, b, true) - elseif type == 'SHARD' then - tooltip:AddLine(format('Can disenchant from level %s |cff0070ddRare|r and |cff1eff00Uncommon|r items.', range), r, g, b, true) - elseif type == 'ESSENCE' then - tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), r, g, b, true) - elseif type == 'DUST' then - tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), r, g, b, true) - end - end local item_info = temp-info.item(item_id) if item_info then local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level) diff --git a/gui/core.lua b/gui/core.lua index a72c7fd..f91f724 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -315,7 +315,7 @@ function M.editbox(parent) do (this.focus_loss or nop)() end end) editbox:SetScript('OnTextChanged', function() - this.overlay:SetText((this.formatter or id)(this:GetText())) + this.overlay:SetText(this.formatter and this.formatter(this:GetText()) or this:GetText()) do (this.change or nop)() end end) editbox:SetScript('OnChar', function() (this.char or nop)() end) diff --git a/libs/T.lua b/libs/T.lua index 13f212c..abf66f6 100644 --- a/libs/T.lua +++ b/libs/T.lua @@ -84,7 +84,7 @@ do end code = code .. [[ overflow) - if overflow ~= nil then error("Vararg overflow.") end + if overflow ~= nil then error("T-vararg overflow.", 2) end local n = 0 repeat ]] diff --git a/libs/module.lua b/libs/module.lua index 793410a..3360ceb 100644 --- a/libs/module.lua +++ b/libs/module.lua @@ -1,12 +1,11 @@ if module then return end local strfind, type, setmetatable, setfenv, _G = strfind, type, setmetatable, setfenv, getfenv(0) -local error, nop, id, define, include, create_module, nop_default_mt, public_modifier_mt, proxy_mt +local error, nop, define, include, create_module, nop_default_mt, public_modifier_mt, proxy_mt local loaded, defined, interfaces, environments = {}, {}, {}, {} +function nop() end function error(msg, ...) return _G.error(format(msg or '', unpack(arg)) .. '\n' .. debugstack(), 0) end -nop, id = function() end, function(v) return v end - function define(self, k, v, private) if type(k) ~= 'string' or not strfind(k, '^[_%a][_%w]*') then error('Invalid identifier "%s".', k) end local _, _, prefix, suffix = strfind(k, '^(.?.?.?.?)([_%a].*)') @@ -43,7 +42,7 @@ function create_module(name) accessors = {M=function() return public_modifier end} mutators = setmetatable({_=nop}, {__index=function(_, k) return function(v) define(name, k, v, true) end end}) fields = setmetatable( - {_M=environment, _G=_G, include=function(interface) include(name, interface) end, error=error, nop=nop, id=id}, + {_M=environment, _G=_G, include=function(interface) include(name, interface) end, nop=nop}, {__index=function(_, k) local accessor = accessors[k]; if accessor then return accessor() else return _G[k] end end} ) public_accessors = setmetatable({}, nop_default_mt) @@ -52,7 +51,7 @@ function create_module(name) setmetatable(environment, proxy_mt(fields, mutators)) setmetatable(interface, proxy_mt(public_fields, public_mutators)) P = { - defined = {['-_M']=true, ['-_G']=true, ['-include']=true, ['-error']=true, ['-nop']=true, ['-id']=true, ['-M']=true, ['-set__']=true, ['-require']=true}, + defined = {['-_M']=true, ['-_G']=true, ['-include']=true, ['-nop']=true, ['-M']=true, ['-set__']=true, ['-require']=true}, fields = fields, accessors = accessors, mutators = mutators, public_fields = public_fields, public_accessors = public_accessors, public_mutators = public_mutators, } diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index 051a6a4..675c277 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -9,7 +9,7 @@ local scan = require 'aux.core.scan' TAB 'Bids' -auction_records = T +auction_records = {} function OPEN() frame:Show() diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index f003d9f..445b462 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -5,7 +5,7 @@ local money = require 'aux.util.money' local cache = require 'aux.core.cache' local filter_util = require 'aux.util.filter' -local post_filter = T +local post_filter = {} local post_filter_index = 0 function valid_level(str) diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 6db7003..ee63d95 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -509,8 +509,8 @@ do filter_display = scroll_child end -status_bars = T -tables = T +status_bars = {} +tables = {} for _ = 1, 5 do local status_bar = gui.status_bar(frame) status_bar:SetAllPoints(status_bar_frame) diff --git a/tabs/search/results.lua b/tabs/search/results.lua index e94dba2..c63f26f 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -32,7 +32,7 @@ function update_real_time(enable) end do - local searches = T + local searches = {} local search_index = 1 function get_current_search() @@ -361,7 +361,7 @@ end do local scan_id = 0 - local IDLE, SEARCHING, FOUND = T, T, T + local IDLE, SEARCHING, FOUND = 1, 2, 3 local state = IDLE local found_index diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index 8e4e014..5564d3c 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -3,8 +3,8 @@ module 'aux.tabs.search' local filter_util = require 'aux.util.filter' local gui = require 'aux.gui' -_G.aux_favorite_searches = T -_G.aux_recent_searches = T +_G.aux_favorite_searches = {} +_G.aux_recent_searches = {} function update_search_listings() local favorite_search_rows = T diff --git a/util/persistence.lua b/util/persistence.lua index d4dc0b9..16ccf27 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -3,7 +3,7 @@ module 'aux.util.persistence' include 'T' include 'aux' -_G.aux_datasets = T +_G.aux_datasets = {} do local dataset