savedvariables refactoring
This commit is contained in:
+8
-15
@@ -11,6 +11,7 @@ local scan_util = require 'aux.util.scan'
|
||||
local post = require 'aux.core.post'
|
||||
local scan = require 'aux.core.scan'
|
||||
local history = require 'aux.core.history'
|
||||
local cache = require 'aux.core.cache'
|
||||
local item_listing = require 'aux.gui.item_listing'
|
||||
local al = require 'aux.gui.auction_listing'
|
||||
|
||||
@@ -25,16 +26,8 @@ function get_default_settings()
|
||||
return O('duration', DURATION_8, 'start_price', 0, 'buyout_price', 0, 'hidden', false)
|
||||
end
|
||||
|
||||
do
|
||||
local data
|
||||
function get_data()
|
||||
if not data then
|
||||
local dataset = persistence.dataset
|
||||
data = dataset.post or T
|
||||
dataset.post = data
|
||||
end
|
||||
return data
|
||||
end
|
||||
function LOAD2()
|
||||
data = persistence.faction'post'
|
||||
end
|
||||
|
||||
function read_settings(item_key)
|
||||
@@ -333,7 +326,7 @@ function update_item_configuration()
|
||||
stack_count_slider.editbox:SetNumber(stack_count_slider:GetValue())
|
||||
|
||||
do
|
||||
local deposit_factor = neutral_faction() and .25 or .05
|
||||
local deposit_factor = UnitFactionGroup'npc' and .25 or .05
|
||||
local stack_size, stack_count = stack_size_slider:GetValue(), stack_count_slider:GetValue()
|
||||
local amount = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(duration_dropdown) / 120
|
||||
deposit:SetText('Deposit: ' .. money.to_string(amount, nil, nil, nil, color.text.enabled))
|
||||
@@ -518,12 +511,12 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
|
||||
do
|
||||
local entry
|
||||
for _, record in bid_records[key] do
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and is_player(owner) == record.own then
|
||||
if unit_blizzard_bid == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', is_player(owner), 'count', 0)
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_blizzard_bid, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
tinsert(bid_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
@@ -533,12 +526,12 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price,
|
||||
do
|
||||
local entry
|
||||
for _, record in buyout_records[key] do
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and is_player(owner) == record.own then
|
||||
if unit_buyout_price == record.unit_price and aux_quantity == record.stack_size and duration == record.duration and cache.is_player(owner) == record.own then
|
||||
entry = record
|
||||
end
|
||||
end
|
||||
if not entry then
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', is_player(owner), 'count', 0)
|
||||
entry = O('stack_size', aux_quantity, 'unit_price', unit_buyout_price, 'duration', duration, 'own', cache.is_player(owner), 'count', 0)
|
||||
tinsert(buyout_records[key], entry)
|
||||
end
|
||||
entry.count = entry.count + 1
|
||||
|
||||
@@ -4,6 +4,7 @@ local info = require 'aux.util.info'
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local scan_util = require 'aux.util.scan'
|
||||
local scan = require 'aux.core.scan'
|
||||
local cache = require 'aux.core.cache'
|
||||
|
||||
function LOAD()
|
||||
new_search()
|
||||
@@ -368,7 +369,7 @@ do
|
||||
function find_auction(record)
|
||||
local search = current_search
|
||||
|
||||
if not search.table:ContainsRecord(record) or is_player(record.owner) then
|
||||
if not search.table:ContainsRecord(record) or cache.is_player(record.owner) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
+17
-15
@@ -2,14 +2,16 @@ module 'aux.tabs.search'
|
||||
|
||||
local filter_util = require 'aux.util.filter'
|
||||
local gui = require 'aux.gui'
|
||||
local persistence = require 'aux.util.persistence'
|
||||
|
||||
_G.aux_favorite_searches = {}
|
||||
_G.aux_recent_searches = {}
|
||||
function LOAD2()
|
||||
recent_searches, favorite_searches = persistence.realm'recent_searches', persistence.realm'favorite_searches'
|
||||
end
|
||||
|
||||
function update_search_listings()
|
||||
local favorite_search_rows = T
|
||||
for i = 1, getn(aux_favorite_searches) do
|
||||
local search = aux_favorite_searches[i]
|
||||
for i = 1, getn(favorite_searches) do
|
||||
local search = favorite_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(favorite_search_rows, O(
|
||||
'cols', A(O('value', search.auto_buy and color.red'X' or ''), O('value', name)),
|
||||
@@ -20,8 +22,8 @@ function update_search_listings()
|
||||
favorite_searches_listing:SetData(favorite_search_rows)
|
||||
|
||||
local recent_search_rows = T
|
||||
for i = 1, getn(aux_recent_searches) do
|
||||
local search = aux_recent_searches[i]
|
||||
for i = 1, getn(recent_searches) do
|
||||
local search = recent_searches[i]
|
||||
local name = strsub(search.prettified, 1, 250)
|
||||
tinsert(recent_search_rows, O(
|
||||
'cols', A(O('value', name)),
|
||||
@@ -33,12 +35,12 @@ function update_search_listings()
|
||||
end
|
||||
|
||||
function new_recent_search(filter_string, prettified)
|
||||
tinsert(aux_recent_searches, 1, O(
|
||||
tinsert(recent_searches, 1, O(
|
||||
'filter_string', filter_string,
|
||||
'prettified', prettified
|
||||
))
|
||||
while getn(aux_recent_searches) > 50 do
|
||||
tremove(aux_recent_searches)
|
||||
while getn(recent_searches) > 50 do
|
||||
tremove(recent_searches)
|
||||
end
|
||||
update_search_listings()
|
||||
end
|
||||
@@ -56,15 +58,15 @@ handlers = {
|
||||
elseif button == 'RightButton' then
|
||||
local u = update_search_listings
|
||||
if st == recent_searches_listing then
|
||||
tinsert(aux_favorite_searches, 1, data.search)
|
||||
tinsert(favorite_searches, 1, data.search)
|
||||
u(d)
|
||||
elseif st == favorite_searches_listing then
|
||||
local auto_buy = data.search.auto_buy
|
||||
gui.menu(
|
||||
(auto_buy and 'Disable' or 'Enable') .. ' Auto Buy', function() if auto_buy then data.search.auto_buy = nil else enable_auto_buy(data.search) end u() end,
|
||||
'Move Up', function() move_up(aux_favorite_searches, data.index); u() end,
|
||||
'Move Down', function() move_down(aux_favorite_searches, data.index); u() end,
|
||||
'Delete', function() tremove(aux_favorite_searches, data.index); u() end
|
||||
'Move Up', function() move_up(favorite_searches, data.index); u() end,
|
||||
'Move Down', function() move_down(favorite_searches, data.index); u() end,
|
||||
'Delete', function() tremove(favorite_searches, data.index); u() end
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -83,7 +85,7 @@ handlers = {
|
||||
|
||||
function get_auto_buy_validator()
|
||||
local validators = T
|
||||
for _, search in aux_favorite_searches do
|
||||
for _, search in favorite_searches do
|
||||
if search.auto_buy then
|
||||
local queries, error = filter_util.queries(search.filter_string)
|
||||
if queries then
|
||||
@@ -101,7 +103,7 @@ end
|
||||
function add_favorite(filter_string)
|
||||
local queries, error = filter_util.queries(filter_string)
|
||||
if queries then
|
||||
tinsert(aux_favorite_searches, 1, O(
|
||||
tinsert(favorite_searches, 1, O(
|
||||
'filter_string', filter_string,
|
||||
'prettified', join(map(queries, function(query) return query.prettified end), ';')
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user