savedvariables refactoring
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
## Author: shirsig
|
||||
## Title: aux
|
||||
## Notes: Auction House replacement
|
||||
## SavedVariablesPerCharacter: aux_tooltip_value, aux_tooltip_daily, aux_tooltip_merchant_buy, aux_tooltip_merchant_sell, aux_tooltip_disenchant_value, aux_tooltip_disenchant_distribution
|
||||
## SavedVariables: aux, aux_scale, aux_post_bid, aux_ignore_owner, aux_items, aux_item_ids, aux_auctionable_items, aux_merchant_buy, aux_merchant_sell
|
||||
|
||||
libs\inspect.lua
|
||||
|
||||
+25
-20
@@ -3,6 +3,11 @@ module 'aux.core.slash'
|
||||
include 'aux'
|
||||
|
||||
local cache = require 'aux.core.cache'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
function LOAD2()
|
||||
tooltip_settings = persistence.player'tooltip'
|
||||
end
|
||||
|
||||
_G.aux_ignore_owner = true
|
||||
|
||||
@@ -26,23 +31,23 @@ function SlashCmdList.AUX(command)
|
||||
_G.aux_post_bid = not aux_post_bid
|
||||
print('post bid ' .. status(aux_post_bid))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
_G.aux_tooltip_value = not aux_tooltip_value
|
||||
print('tooltip value ' .. status(aux_tooltip_value))
|
||||
tooltip_settings.value = not tooltip_settings.value
|
||||
print('tooltip value ' .. status(tooltip_settings.value))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
_G.aux_tooltip_daily = not aux_tooltip_daily
|
||||
print('tooltip daily ' .. status(aux_tooltip_daily))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
|
||||
_G.aux_tooltip_merchant_buy = not aux_tooltip_merchant_buy
|
||||
print('tooltip vendor buy ' .. status(aux_tooltip_merchant_buy))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
|
||||
_G.aux_tooltip_merchant_sell = not aux_tooltip_merchant_sell
|
||||
print('tooltip vendor sell ' .. status(aux_tooltip_merchant_sell))
|
||||
tooltip_settings.daily = not tooltip_settings.daily
|
||||
print('tooltip daily ' .. status(tooltip_settings.daily))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
tooltip_settings.merchant_buy = not tooltip_settings.merchant_buy
|
||||
print('tooltip merchant buy ' .. status(tooltip_settings.merchant_buy))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
tooltip_settings.merchant_sell = not tooltip_settings.merchant_sell
|
||||
print('tooltip merchant sell ' .. status(tooltip_settings.merchant_sell))
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
||||
_G.aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
|
||||
print('tooltip disenchant value ' .. status(aux_tooltip_disenchant_value))
|
||||
tooltip_settings.disenchant_value = not tooltip_settings.disenchant_value
|
||||
print('tooltip disenchant value ' .. status(tooltip_settings.disenchant_value))
|
||||
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))
|
||||
tooltip_settings.disenchant_distribution = not tooltip_settings.disenchant_distribution
|
||||
print('tooltip disenchant distribution ' .. status(tooltip_settings.disenchant_distribution))
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
_G.aux_items = {}
|
||||
_G.aux_item_ids = {}
|
||||
@@ -55,12 +60,12 @@ function SlashCmdList.AUX(command)
|
||||
print('- scale [' .. color.blue(aux_scale) .. ']')
|
||||
print('- ignore owner [' .. status(aux_ignore_owner) .. ']')
|
||||
print('- post bid [' .. status(aux_post_bid) .. ']')
|
||||
print('- tooltip value [' .. status(aux_tooltip_value) .. ']')
|
||||
print('- tooltip daily [' .. status(aux_tooltip_daily) .. ']')
|
||||
print('- tooltip vendor buy [' .. status(aux_tooltip_merchant_buy) .. ']')
|
||||
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 value [' .. status(tooltip_settings.value) .. ']')
|
||||
print('- tooltip daily [' .. status(tooltip_settings.daily) .. ']')
|
||||
print('- tooltip merchant buy [' .. status(tooltip_settings.merchant_buy) .. ']')
|
||||
print('- tooltip merchant sell [' .. status(tooltip_settings.merchant_sell) .. ']')
|
||||
print('- tooltip disenchant value [' .. status(tooltip_settings.disenchant_value) .. ']')
|
||||
print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']')
|
||||
print('- clear item cache')
|
||||
print('- populate wdb')
|
||||
end
|
||||
|
||||
+9
-9
@@ -6,17 +6,17 @@ include 'aux'
|
||||
local info = require 'aux.util.info'
|
||||
local money = require 'aux.util.money'
|
||||
local cache = require 'aux.core.cache'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
local disenchant = require 'aux.core.disenchant'
|
||||
local history = require 'aux.core.history'
|
||||
local auction_listing = require 'aux.gui.auction_listing'
|
||||
|
||||
local UNKNOWN = GRAY_FONT_COLOR_CODE .. '?' .. FONT_COLOR_CODE_CLOSE
|
||||
|
||||
_G.aux_tooltip_value = true
|
||||
|
||||
local game_tooltip_hooks, game_tooltip_money = {}, 0
|
||||
|
||||
function LOAD()
|
||||
settings = persistence.player('tooltip', {value=true})
|
||||
do
|
||||
local inside_hook = false
|
||||
for name, f in game_tooltip_hooks do
|
||||
@@ -30,7 +30,7 @@ function LOAD()
|
||||
return ret(tmp)
|
||||
end)
|
||||
end
|
||||
local orig = GameTooltip:GetScript('OnTooltipAddMoney')
|
||||
local orig = GameTooltip:GetScript'OnTooltipAddMoney'
|
||||
GameTooltip:SetScript('OnTooltipAddMoney', vararg-function(arg)
|
||||
if inside_hook then
|
||||
game_tooltip_money = arg1
|
||||
@@ -59,7 +59,7 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
if item_info then
|
||||
local distribution = disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
if getn(distribution) > 0 then
|
||||
if aux_tooltip_disenchant_distribution then
|
||||
if settings.disenchant_distribution then
|
||||
tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution())
|
||||
sort(distribution, function(a,b) return a.probability > b.probability end)
|
||||
for i = 1, getn(distribution) do
|
||||
@@ -67,19 +67,19 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.tooltip.disenchant.distribution())
|
||||
end
|
||||
end
|
||||
if aux_tooltip_disenchant_value then
|
||||
if settings.disenchant_value then
|
||||
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
tooltip:AddLine('Disenchant: ' .. (disenchant_value and money.to_string2(disenchant_value) or UNKNOWN), color.tooltip.disenchant.value())
|
||||
end
|
||||
end
|
||||
end
|
||||
if aux_tooltip_merchant_buy then
|
||||
if settings.merchant_buy then
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
if price then
|
||||
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.tooltip.merchant())
|
||||
end
|
||||
end
|
||||
if aux_tooltip_merchant_sell then
|
||||
if settings.merchant_sell then
|
||||
local price = cache.merchant_info(item_id)
|
||||
if price ~= 0 then
|
||||
tooltip:AddLine('Vendor: ' .. (price and money.to_string2(price * quantity) or UNKNOWN), color.tooltip.merchant())
|
||||
@@ -89,10 +89,10 @@ function M.extend_tooltip(tooltip, link, quantity)
|
||||
local item_key = (item_id or 0) .. ':' .. (suffix_id or 0)
|
||||
local value = history.value(item_key)
|
||||
if auctionable then
|
||||
if aux_tooltip_value then
|
||||
if settings.value then
|
||||
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or UNKNOWN), color.tooltip.value())
|
||||
end
|
||||
if aux_tooltip_daily then
|
||||
if settings.daily then
|
||||
local market_value = history.market_value(item_key)
|
||||
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or UNKNOWN), color.tooltip.value())
|
||||
end
|
||||
|
||||
@@ -34,9 +34,9 @@ do
|
||||
end
|
||||
for scope in temp-S('player', 'faction', 'realm', 'account') do
|
||||
local scope = scope
|
||||
M[scope] = function(k)
|
||||
M[scope] = function(k, v)
|
||||
if not cache[scope] then error('Cache not ready', 2) end
|
||||
cache[scope][k] = cache[scope][k] or {}
|
||||
cache[scope][k] = cache[scope][k] or v or {}
|
||||
return cache[scope][k]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user