savedvariables refactoring
This commit is contained in:
+48
-8
@@ -13,9 +13,12 @@ local search_tab = require 'aux.tabs.search'
|
|||||||
|
|
||||||
_G.aux_scale = 1
|
_G.aux_scale = 1
|
||||||
|
|
||||||
function M.set_p(v)
|
_G.aux = {
|
||||||
inspect(nil, v)
|
character = {},
|
||||||
end
|
faction = {},
|
||||||
|
realm = {},
|
||||||
|
account = {},
|
||||||
|
}
|
||||||
|
|
||||||
function M.print(...)
|
function M.print(...)
|
||||||
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), ' '))
|
||||||
@@ -32,7 +35,6 @@ for event in temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION
|
|||||||
event_frame:RegisterEvent(event)
|
event_frame:RegisterEvent(event)
|
||||||
end
|
end
|
||||||
|
|
||||||
ADDON_LOADED = {}
|
|
||||||
do
|
do
|
||||||
local handlers, handlers2 = {}, {}
|
local handlers, handlers2 = {}, {}
|
||||||
function M.set_LOAD(f)
|
function M.set_LOAD(f)
|
||||||
@@ -43,7 +45,13 @@ do
|
|||||||
end
|
end
|
||||||
event_frame:SetScript('OnEvent', function()
|
event_frame:SetScript('OnEvent', function()
|
||||||
if event == 'ADDON_LOADED' then
|
if event == 'ADDON_LOADED' then
|
||||||
(ADDON_LOADED[arg1] or nop)()
|
if arg1 == 'Blizzard_AuctionUI' then
|
||||||
|
Blizzard_AuctionUI()
|
||||||
|
elseif arg1 == 'Blizzard_CraftUI' then
|
||||||
|
Blizzard_CraftUI()
|
||||||
|
elseif arg1 == 'Blizzard_TradeSkillUI' then
|
||||||
|
Blizzard_TradeSkillUI()
|
||||||
|
end
|
||||||
elseif event == 'VARIABLES_LOADED' then
|
elseif event == 'VARIABLES_LOADED' then
|
||||||
for _, f in handlers do f() end
|
for _, f in handlers do f() end
|
||||||
elseif event == 'PLAYER_LOGIN' then
|
elseif event == 'PLAYER_LOGIN' then
|
||||||
@@ -55,6 +63,38 @@ do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local cache = {}
|
||||||
|
function LOAD()
|
||||||
|
cache.account = aux.account
|
||||||
|
do
|
||||||
|
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
|
||||||
|
aux.character[key] = aux.character[key] or {}
|
||||||
|
cache.character = aux.character[key]
|
||||||
|
end
|
||||||
|
do
|
||||||
|
local key = GetCVar'realmName'
|
||||||
|
aux.realm[key] = aux.realm[key] or {}
|
||||||
|
cache.realm = aux.realm[key]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function LOAD2()
|
||||||
|
do
|
||||||
|
local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
|
||||||
|
aux.faction[key] = aux.faction[key] or {}
|
||||||
|
cache.faction = aux.faction[key]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for scope in temp-S('character', 'faction', 'realm', 'account') do
|
||||||
|
local scope = scope
|
||||||
|
M[scope .. '_data'] = function(k, v)
|
||||||
|
if not cache[scope] then error('Cache not ready', 2) end
|
||||||
|
cache[scope][k] = cache[scope][k] or v or {}
|
||||||
|
return cache[scope][k]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
tab_info = {}
|
tab_info = {}
|
||||||
function M.TAB(name)
|
function M.TAB(name)
|
||||||
local tab = O('name', name)
|
local tab = O('name', name)
|
||||||
@@ -198,7 +238,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ADDON_LOADED.Blizzard_AuctionUI()
|
function Blizzard_AuctionUI()
|
||||||
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW')
|
||||||
AuctionFrame:SetScript('OnHide', nil)
|
AuctionFrame:SetScript('OnHide', nil)
|
||||||
hook('ShowUIPanel', function(...)
|
hook('ShowUIPanel', function(...)
|
||||||
@@ -227,7 +267,7 @@ do
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
function ADDON_LOADED.Blizzard_CraftUI()
|
function Blizzard_CraftUI()
|
||||||
hook('CraftFrame_SetSelection', function(...)
|
hook('CraftFrame_SetSelection', function(...)
|
||||||
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg)))
|
||||||
local id = GetCraftSelectionIndex()
|
local id = GetCraftSelectionIndex()
|
||||||
@@ -257,7 +297,7 @@ do
|
|||||||
hook_quest_item(_G['CraftReagent' .. i])
|
hook_quest_item(_G['CraftReagent' .. i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function ADDON_LOADED.Blizzard_TradeSkillUI()
|
function Blizzard_TradeSkillUI()
|
||||||
hook('TradeSkillFrame_SetSelection', function(...)
|
hook('TradeSkillFrame_SetSelection', function(...)
|
||||||
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg)))
|
||||||
local id = GetTradeSkillSelectionIndex()
|
local id = GetTradeSkillSelectionIndex()
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
module 'aux'
|
module 'aux'
|
||||||
|
|
||||||
local event_frame = CreateFrame('Frame')
|
local event_frame = CreateFrame'Frame'
|
||||||
|
|
||||||
local listeners, threads = T, T
|
local listeners, threads = T, T
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ do
|
|||||||
return characters[name] and true or false
|
return characters[name] and true or false
|
||||||
end
|
end
|
||||||
function LOAD2()
|
function LOAD2()
|
||||||
characters = persistence.realm'characters'
|
characters = realm_data'characters'
|
||||||
for k, v in characters do
|
for k, v in characters do
|
||||||
if GetTime() > v + 60 * 60 * 24 * 30 then
|
if GetTime() > v + 60 * 60 * 24 * 30 then
|
||||||
characters[k] = nil
|
characters[k] = nil
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='n
|
|||||||
local value_cache = {}
|
local value_cache = {}
|
||||||
|
|
||||||
function LOAD2()
|
function LOAD2()
|
||||||
data = persistence.faction'history'
|
data = faction_data'history'
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
+1
-2
@@ -3,10 +3,9 @@ module 'aux.core.slash'
|
|||||||
include 'aux'
|
include 'aux'
|
||||||
|
|
||||||
local cache = require 'aux.core.cache'
|
local cache = require 'aux.core.cache'
|
||||||
local persistence = require 'aux.util.persistence'
|
|
||||||
|
|
||||||
function LOAD2()
|
function LOAD2()
|
||||||
tooltip_settings = persistence.character'tooltip'
|
tooltip_settings = character_data'tooltip'
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.aux_ignore_owner = true
|
_G.aux_ignore_owner = true
|
||||||
|
|||||||
+1
-2
@@ -6,7 +6,6 @@ include 'aux'
|
|||||||
local info = require 'aux.util.info'
|
local info = require 'aux.util.info'
|
||||||
local money = require 'aux.util.money'
|
local money = require 'aux.util.money'
|
||||||
local cache = require 'aux.core.cache'
|
local cache = require 'aux.core.cache'
|
||||||
local persistence = require 'aux.util.persistence'
|
|
||||||
local disenchant = require 'aux.core.disenchant'
|
local disenchant = require 'aux.core.disenchant'
|
||||||
local history = require 'aux.core.history'
|
local history = require 'aux.core.history'
|
||||||
local auction_listing = require 'aux.gui.auction_listing'
|
local auction_listing = require 'aux.gui.auction_listing'
|
||||||
@@ -16,7 +15,7 @@ local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
|
|||||||
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
||||||
|
|
||||||
function LOAD()
|
function LOAD()
|
||||||
settings = persistence.character('tooltip', {value=true})
|
settings = character_data('tooltip', {value=true})
|
||||||
do
|
do
|
||||||
local inside_hook = false
|
local inside_hook = false
|
||||||
for name, f in game_tooltip_hooks do
|
for name, f in game_tooltip_hooks do
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ function get_default_settings()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function LOAD2()
|
function LOAD2()
|
||||||
data = persistence.faction'post'
|
data = faction_data'post'
|
||||||
end
|
end
|
||||||
|
|
||||||
function read_settings(item_key)
|
function read_settings(item_key)
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ module 'aux.tabs.search'
|
|||||||
|
|
||||||
local filter_util = require 'aux.util.filter'
|
local filter_util = require 'aux.util.filter'
|
||||||
local gui = require 'aux.gui'
|
local gui = require 'aux.gui'
|
||||||
local persistence = require 'aux.util.persistence'
|
|
||||||
|
|
||||||
function LOAD2()
|
function LOAD2()
|
||||||
recent_searches, favorite_searches = persistence.realm'recent_searches', persistence.realm'favorite_searches'
|
recent_searches, favorite_searches = realm_data'recent_searches', realm_data'favorite_searches'
|
||||||
end
|
end
|
||||||
|
|
||||||
function update_search_listings()
|
function update_search_listings()
|
||||||
|
|||||||
@@ -3,45 +3,6 @@ module 'aux.util.persistence'
|
|||||||
include 'T'
|
include 'T'
|
||||||
include 'aux'
|
include 'aux'
|
||||||
|
|
||||||
_G.aux = {
|
|
||||||
character = {},
|
|
||||||
faction = {},
|
|
||||||
realm = {},
|
|
||||||
account = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
local cache = {}
|
|
||||||
function LOAD()
|
|
||||||
cache.account = aux.account
|
|
||||||
do
|
|
||||||
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
|
|
||||||
aux.character[key] = aux.character[key] or {}
|
|
||||||
cache.character = aux.character[key]
|
|
||||||
end
|
|
||||||
do
|
|
||||||
local key = GetCVar'realmName'
|
|
||||||
aux.realm[key] = aux.realm[key] or {}
|
|
||||||
cache.realm = aux.realm[key]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function LOAD2()
|
|
||||||
do
|
|
||||||
local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
|
|
||||||
aux.faction[key] = aux.faction[key] or {}
|
|
||||||
cache.faction = aux.faction[key]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for scope in temp-S('character', 'faction', 'realm', 'account') do
|
|
||||||
local scope = scope
|
|
||||||
M[scope] = function(k, v)
|
|
||||||
if not cache[scope] then error('Cache not ready', 2) end
|
|
||||||
cache[scope][k] = cache[scope][k] or v or {}
|
|
||||||
return cache[scope][k]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.read(schema, str)
|
function M.read(schema, str)
|
||||||
if schema == 'string' then
|
if schema == 'string' then
|
||||||
return str
|
return str
|
||||||
|
|||||||
Reference in New Issue
Block a user