some progress on historical scanning
This commit is contained in:
+2
-2
@@ -2,10 +2,10 @@
|
||||
## Title: Aux
|
||||
## Notes: A lightweight addon designed to help manage auctions
|
||||
## SavedVariablesPerCharacter: AUX_SELL_SHORTCUT, AUX_BUY_SHORTCUT, AUX_OPEN_SELL, AUX_OPEN_BUY, AUX_INSTANT_BUYOUT, AUX_AUCTION_DURATION
|
||||
## SavedVariables: aux_history, aux_snapshot, aux_post_parameters
|
||||
## SavedVariables: aux_database
|
||||
core.xml
|
||||
control.xml
|
||||
store.lua
|
||||
persistence.lua
|
||||
util.lua
|
||||
|
||||
scan.lua
|
||||
|
||||
@@ -164,6 +164,8 @@ function Aux.on_tab_click(index)
|
||||
|
||||
Aux.buy.on_close()
|
||||
Aux.sell.on_close()
|
||||
Aux.manage_frame.on_close()
|
||||
Aux.history.on_close()
|
||||
|
||||
for i=1,5 do
|
||||
getglobal('AuxTab'..i):SetAlpha(i == index and 1 or 0.5)
|
||||
@@ -179,11 +181,12 @@ function Aux.on_tab_click(index)
|
||||
elseif index == 2 then
|
||||
AuxSellFrame:Show()
|
||||
Aux.sell.on_open()
|
||||
elseif index == 5 then
|
||||
elseif index == 3 then
|
||||
Aux.manage_frame.on_open()
|
||||
elseif index == 4 then
|
||||
AuxHistoryFrame:Show()
|
||||
Aux.history.on_open()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function Aux_Round(v)
|
||||
|
||||
@@ -250,12 +250,12 @@
|
||||
</Layers>
|
||||
<Scripts>
|
||||
<OnEnter>
|
||||
if this:GetParent().tooltip then
|
||||
Aux.info.set_game_tooltip(this, this:GetParent().tooltip, 'ANCHOR_LEFT', this:GetParent().EnhTooltip_info)
|
||||
if this.tooltip then
|
||||
Aux.info.set_game_tooltip(this, this.tooltip, 'ANCHOR_LEFT', this.EnhTooltip_info)
|
||||
end
|
||||
</OnEnter>
|
||||
<OnLeave>
|
||||
if this:GetParent().tooltip then
|
||||
if this.tooltip then
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
</OnLeave>
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
local on_open, on_close
|
||||
|
||||
local bid_records, auctions_records, create_bid_record, create_auction_record
|
||||
|
||||
local bid_listing_config = {
|
||||
on_cell_click = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
set_auction(sheet.data[data_index])
|
||||
end,
|
||||
|
||||
on_cell_enter = function (sheet, row_index, column_index)
|
||||
sheet.rows[row_index].highlight:SetAlpha(.5)
|
||||
end,
|
||||
|
||||
on_cell_leave = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
if not (current_auction and sheet.data[data_index] == current_auction) then
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
row_setter = function(row, datum)
|
||||
if current_auction and datum == current_auction then
|
||||
row.highlight:SetAlpha(.5)
|
||||
else
|
||||
row.highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
columns = {
|
||||
{
|
||||
title = 'Qty',
|
||||
width = 23,
|
||||
comparator = function(datum1, datum2) return Aux.util.compare(datum1.aux_quantity, datum2.aux_quantity, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, datum)
|
||||
cell.text:SetText(datum.aux_quantity)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Item',
|
||||
width = 186,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.name, row2.name, Aux.util.GT) end,
|
||||
cell_initializer = function(cell)
|
||||
local icon = CreateFrame('Button', nil, cell)
|
||||
local icon_texture = icon:CreateTexture(nil, 'BORDER')
|
||||
icon_texture:SetAllPoints(icon)
|
||||
icon.icon_texture = icon_texture
|
||||
local normal_texture = icon:CreateTexture(nil)
|
||||
normal_texture:SetPoint('CENTER', 0, 0)
|
||||
normal_texture:SetWidth(22)
|
||||
normal_texture:SetHeight(22)
|
||||
normal_texture:SetTexture('Interface\\Buttons\\UI-Quickslot2')
|
||||
icon:SetNormalTexture(normal_texture)
|
||||
icon:SetPoint('LEFT', cell)
|
||||
icon:SetWidth(12)
|
||||
icon:SetHeight(12)
|
||||
icon:SetNormalTexture('Interface\\Buttons\\UI-Quickslot2')
|
||||
icon:SetPushedTexture('Interface\\Buttons\\UI-Quickslot-Depress')
|
||||
icon:SetHighlightTexture('Interface\\Buttons\\ButtonHilight-Square')
|
||||
local text = cell:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmall')
|
||||
text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
|
||||
text:SetPoint('TOPRIGHT', cell)
|
||||
text:SetPoint('BOTTOMRIGHT', cell)
|
||||
text:SetJustifyV('TOP')
|
||||
text:SetJustifyH('LEFT')
|
||||
text:SetTextColor(0.8, 0.8, 0.8)
|
||||
cell.text = text
|
||||
cell.icon = icon
|
||||
end,
|
||||
cell_setter = function(cell, datum)
|
||||
cell.icon.icon_texture:SetTexture(datum.texture)
|
||||
cell.text:SetText('['..datum.name..']')
|
||||
local color = ITEM_QUALITY_COLORS[datum.quality]
|
||||
cell.text:SetTextColor(color.r, color.g, color.b)
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {{column = 2, order = 'ascending' }},
|
||||
}
|
||||
|
||||
local auction_listing_config = {
|
||||
on_cell_click = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
AuxSellEntry_OnClick(sheet.data[data_index])
|
||||
end,
|
||||
|
||||
on_cell_enter = function (sheet, row_index, column_index)
|
||||
sheet.rows[row_index].highlight:SetAlpha(.5)
|
||||
end,
|
||||
|
||||
on_cell_leave = function (sheet, row_index, column_index)
|
||||
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
|
||||
local datum = sheet.data[data_index]
|
||||
if not (datum and current_auction and Aux.util.safe_index{auxSellEntries, current_auction.name, 'selected', 'key'} == datum.key) then
|
||||
sheet.rows[row_index].highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
row_setter = function(row, datum)
|
||||
if datum and current_auction and Aux.util.safe_index{auxSellEntries, current_auction.name, 'selected', 'key'} == datum.key then
|
||||
row.highlight:SetAlpha(.5)
|
||||
else
|
||||
row.highlight:SetAlpha(0)
|
||||
end
|
||||
end,
|
||||
|
||||
columns = {
|
||||
{
|
||||
title = 'Avail',
|
||||
width = 40,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.count, row2.count, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.count)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Yours',
|
||||
width = 40,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.yours, row2.yours, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.yours)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Max Left',
|
||||
width = 55,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.max_time_left, row2.max_time_left, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('CENTER'),
|
||||
cell_setter = function(cell, datum)
|
||||
local text
|
||||
if datum.max_time_left == 1 then
|
||||
text = '30m'
|
||||
elseif datum.max_time_left == 2 then
|
||||
text = '2h'
|
||||
elseif datum.max_time_left == 3 then
|
||||
text = '8h'
|
||||
elseif datum.max_time_left == 4 then
|
||||
text = '24h'
|
||||
end
|
||||
cell.text:SetText(text)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Buy/ea',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.unit_buyout_price, row2.unit_buyout_price, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(Aux.util.money_string(row.unit_buyout_price))
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Qty',
|
||||
width = 23,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.stack_size, row2.stack_size, Aux.util.LT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(row.stack_size)
|
||||
end,
|
||||
},
|
||||
{
|
||||
title = 'Buy',
|
||||
width = 70,
|
||||
comparator = function(row1, row2) return Aux.util.compare(row1.buyout_price, row2.buyout_price, Aux.util.GT) end,
|
||||
cell_initializer = Aux.sheet.default_cell_initializer('RIGHT'),
|
||||
cell_setter = function(cell, row)
|
||||
cell.text:SetText(Aux.util.money_string(row.buyout_price))
|
||||
end,
|
||||
},
|
||||
},
|
||||
sort_order = {{column = 4, order = 'ascending' }, {column = 4, order = 'ascending'}},
|
||||
}
|
||||
|
||||
function on_open()
|
||||
|
||||
if not bid_records then
|
||||
GetBidderAuctionItems()
|
||||
bid_records = {}
|
||||
end
|
||||
AuctionFrameBid.page = 0;
|
||||
AuctionFrameBid_Update();
|
||||
|
||||
if not auctions_records then
|
||||
GetOwnerAuctionItems()
|
||||
auction_records = {}
|
||||
end
|
||||
AuctionFrameAuctions.page = 0;
|
||||
AuctionFrameAuctions_Update();
|
||||
end
|
||||
|
||||
function on_close()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Aux.manage_frame = {
|
||||
on_open = on_open,
|
||||
on_close = on_close,
|
||||
bid_listing_config = bid_listing_config,
|
||||
auction_listing_config = auction_listing_config,
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -32,8 +32,9 @@
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[1].sort_order, function(column_order) return { column = Aux.buy.modes[1].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].row_setter, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave)
|
||||
local config = Aux.manage_frame.bid_listing_config
|
||||
local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_cell_click, config.on_cell_enter, config.on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
@@ -123,8 +124,9 @@
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[1].sort_order, function(column_order) return { column = Aux.buy.modes[1].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].row_setter, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave)
|
||||
local config = Aux.manage_frame.auction_listing_config
|
||||
local sort_order = Aux.util.map(config.sort_order, function(column_order) return { column = config.columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, config.columns, sort_order, config.row_setter, config.on_cell_click, config.on_cell_enter, config.on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
local on_load, load_dataset, new_dataset, get_dataset_key, get_snapshot, save_snapshot, get_item_record, save_item_record
|
||||
local encode_median_list, decode_median_list, serialize, deserialize, deserializing_iterator
|
||||
|
||||
local DATABASE_VERSION = 0
|
||||
|
||||
aux_database = {}
|
||||
|
||||
function on_load()
|
||||
perform_migration(aux_database)
|
||||
aux_database.version = DATABASE_VERSION
|
||||
end
|
||||
|
||||
function get_dataset_key()
|
||||
local realm = GetCVar('realmName')
|
||||
local zone = GetMinimapZoneText()
|
||||
local faction
|
||||
if zone == 'Gadgetzan' or zone == 'Everlook' or zone == 'Booty Bay' then
|
||||
faction = 'Neutral'
|
||||
else
|
||||
faction = UnitFactionGroup('player')
|
||||
end
|
||||
return realm..'|'..faction
|
||||
end
|
||||
|
||||
function new_dataset()
|
||||
return {
|
||||
snapshot = '',
|
||||
scan_data = '',
|
||||
item_data = {},
|
||||
}
|
||||
end
|
||||
|
||||
function load_dataset()
|
||||
local dataset_key = get_dataset_key()
|
||||
aux_database[dataset_key] = aux_database[dataset_key] or new_dataset()
|
||||
return aux_database[dataset_key]
|
||||
end
|
||||
|
||||
function get_snapshot()
|
||||
local dataset = load_dataset()
|
||||
local signatures = deserialize(dataset.snapshot, '#')
|
||||
local snapshot = Aux.util.set()
|
||||
snapshot.add_all(signatures)
|
||||
return snapshot
|
||||
end
|
||||
|
||||
function save_snapshot(snapshot)
|
||||
local dataset = load_dataset()
|
||||
dataset.snapshot = serialize(snapshot.values(), '#')
|
||||
end
|
||||
|
||||
--function load_scan_data()
|
||||
--
|
||||
--end
|
||||
--
|
||||
--function store_scan_data()
|
||||
--
|
||||
--end
|
||||
|
||||
function get_item_record(item_key)
|
||||
local dataset = load_dataset()
|
||||
|
||||
if dataset.item_data[item_key] then
|
||||
local serialized_record = dataset.item_data[item_key]
|
||||
local count, accumulated_price, encoded_price_list = unpack(deserialize(serialized_record, '|'))
|
||||
local price_list = decode_median_list(encoded_price_list)
|
||||
|
||||
return {
|
||||
count = count,
|
||||
accumulated_price = accumulated_price,
|
||||
price_list = price_list
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function save_item_record(item_key, record)
|
||||
local dataset = load_dataset()
|
||||
|
||||
local encoded_price_list = encode_median_list(record.price_list)
|
||||
local serialized_record = serialize({record.count, record.acumulated_price, encoded_price_list}, '|')
|
||||
|
||||
dataset.item_data[item_key] = serialized_record
|
||||
end
|
||||
|
||||
-- AuctionConfig.data[auctKey][itemKey] = string.format("%s|%s", iData.data, hist);
|
||||
-- AuctionConfig.info[itemKey] = string.format("%s|%s", iData.category, iData.name);
|
||||
-- Auctioneer.Storage.SetHistMed(auctKey, itemKey, Auctioneer.Statistic.GetMedian(iData.buyoutPricesHistoryList))
|
||||
|
||||
function encode_median_list(list)
|
||||
local encoded_list = ''
|
||||
local function extend(last, n)
|
||||
if n == 1 then
|
||||
encoded_list = encoded_list == '' and last or string.format('%s:%d', encoded_list, last)
|
||||
elseif n > 1 then
|
||||
encoded_list = encoded_list == '' and string.format('%dx%d', last, n) or string.format('%s:%dx%d', encoded_list, last, n)
|
||||
end
|
||||
end
|
||||
local n = 0
|
||||
local last = 0
|
||||
for i, price in pairs(list) do
|
||||
if i == 1 then
|
||||
last = price
|
||||
elseif price ~= last then
|
||||
extend(last, n)
|
||||
last = price
|
||||
n = 0
|
||||
end
|
||||
n = n + 1
|
||||
end
|
||||
extend(last, n)
|
||||
return encoded_list
|
||||
end
|
||||
|
||||
function decode_median_list(str)
|
||||
local array = {}
|
||||
for x, c in string.gfind(str, '([^%:]*)(%:?)') do
|
||||
local _, _, y, n = strfind(x, '(%d*)x(%d*)')
|
||||
if y == nil then
|
||||
tinsert(array, tonumber(x))
|
||||
else
|
||||
for i = 1,n do
|
||||
tinsert(array, tonumber(y))
|
||||
end
|
||||
end
|
||||
if c == '' then break end
|
||||
end
|
||||
return array
|
||||
end
|
||||
|
||||
function serialize(data, separator)
|
||||
local data_string = ''
|
||||
for i, datum in ipairs(data) do
|
||||
data_string = data_string..(i == 1 and separator or '')..datum
|
||||
end
|
||||
return data_string
|
||||
end
|
||||
|
||||
function deserialize(data_string, separator)
|
||||
local data = {}
|
||||
while true do
|
||||
local start_index, _ = strfind(data_string, separator, 1, true)
|
||||
if start_index then
|
||||
local datum = string.sub(data_string, 1, start_index - 1)
|
||||
tinsert(data, datum)
|
||||
data_string = string.sub(data_string, start_index + 1, strlen(data_string))
|
||||
else
|
||||
return data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function deserializing_iterator(data_string, separator)
|
||||
return function()
|
||||
local start_index, _ = strfind(data_string, separator, 1, true)
|
||||
if start_index then
|
||||
local datum = string.sub(data_string, 1, start_index - 1)
|
||||
data_string = string.sub(data_string, start_index, strlen(data_string))
|
||||
return datum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Aux.persistence = {
|
||||
get_item_record = get_item_record,
|
||||
save_item_record = save_item_record,
|
||||
get_snapshot = get_snapshot,
|
||||
save_snapshot = save_snapshot,
|
||||
}
|
||||
+42
-88
@@ -4,15 +4,11 @@ local UNDERCUT_FACTOR = 0.2
|
||||
|
||||
Aux.history = {}
|
||||
|
||||
aux_snapshot = {}
|
||||
|
||||
aux_history = {}
|
||||
|
||||
local cache
|
||||
|
||||
local get_history, process_auction, create_balanced_list
|
||||
local process_auction, balanced_list, update_snapshot
|
||||
local get_market_price, get_usable_median, get_historical_median, get_median, get_percentile
|
||||
|
||||
local signature_cache
|
||||
|
||||
function Aux.history.on_close()
|
||||
|
||||
end
|
||||
@@ -30,7 +26,7 @@ function Aux.history.start_scan()
|
||||
AuxHistoryScanButton:Hide()
|
||||
AuxHistoryStopButton:Show()
|
||||
|
||||
cache = {}
|
||||
signature_cache = Aux.util.set()
|
||||
|
||||
Aux.log('Scanning auctions ...')
|
||||
Aux.scan.start{
|
||||
@@ -43,13 +39,13 @@ function Aux.history.start_scan()
|
||||
process_auction(i)
|
||||
end,
|
||||
on_complete = function()
|
||||
remove_old_signatures()
|
||||
update_snapshot()
|
||||
|
||||
AuxHistoryStopButton:Hide()
|
||||
AuxHistoryScanButton:Show()
|
||||
end,
|
||||
on_abort = function()
|
||||
remove_old_signatures()
|
||||
update_snapshot()
|
||||
|
||||
AuxHistoryStopButton:Hide()
|
||||
AuxHistoryScanButton:Show()
|
||||
@@ -65,97 +61,54 @@ function Aux.history.start_scan()
|
||||
}
|
||||
end
|
||||
|
||||
function remove_old_signatures()
|
||||
for sig, _ in ipairs(aux_snapshot) do
|
||||
if not cache[sig] then
|
||||
Aux.util.set_remove(aux_snapshot, sig)
|
||||
end
|
||||
end
|
||||
function update_snapshot()
|
||||
local snapshot = Aux.persistence.get_snapshot()
|
||||
snapshot.remove_all(signature_cache.values())
|
||||
Aux.persistence.save_snapshot(snapshot)
|
||||
end
|
||||
|
||||
function Aux.history.stop_scan()
|
||||
Aux.scan.abort()
|
||||
end
|
||||
|
||||
function get_history()
|
||||
local history_key = GetCVar('realmName')
|
||||
aux_history[history_key] = aux_history[history_key] or {}
|
||||
return aux_history[history_key]
|
||||
end
|
||||
|
||||
function process_auction(index)
|
||||
local auction_info = Aux.info.auction_item(index)
|
||||
local buyout_price = Aux.util.safe_index{auction_info, 'buyout_price'}
|
||||
if buyout_price and buyout_price > 0 then
|
||||
local aux_quantity = auction_info.charges or auction_info.count
|
||||
local price = ceil(buyout_price / aux_quantity)
|
||||
local key = auction_info.item_signature
|
||||
local item_key = auction_info.item_signature
|
||||
|
||||
local signature = Aux.info.auction_signature(index)
|
||||
Aux.util.set_add(cache, signature)
|
||||
signature_cache.add(signature)
|
||||
|
||||
if not Aux.util.set_contains(aux_snapshot, signature) then
|
||||
|
||||
Aux.util.set_add(aux_snapshot, signature)
|
||||
|
||||
local history = get_history()
|
||||
history[key] = history[key] or {
|
||||
name = auction_info.name,
|
||||
count = 0,
|
||||
records = {},
|
||||
}
|
||||
|
||||
local records = create_balanced_list(MAX_HISTORY_SIZE)
|
||||
records.add_all(history[key].records)
|
||||
records.add(price)
|
||||
|
||||
history[key].records = records.values()
|
||||
history[key].count = history[key].count + 1
|
||||
local snapshot = Aux.persistence.get_snapshot()
|
||||
if not snapshot.contains(signature) then
|
||||
snapshot.add(signature)
|
||||
Aux.persistence.save_snapshot(snapshot)
|
||||
--
|
||||
-- local item_record = Aux.persistence.get_item_record(item_key)
|
||||
--
|
||||
-- item_record = item_record or {
|
||||
-- count = 0,
|
||||
-- accumulated_price = 0,
|
||||
-- price_list = {},
|
||||
-- }
|
||||
--
|
||||
-- local price_list = balanced_list(MAX_HISTORY_SIZE)
|
||||
-- price_list.add_all(item_record.price_list)
|
||||
-- price_list.add(price)
|
||||
--
|
||||
-- Aux.persistence.save_item_record(item_key, {
|
||||
-- count = item_record.count + 1,
|
||||
-- accumulated_price = item_record.accumulated_price + price,
|
||||
-- price_list = price_list.values(),
|
||||
-- })
|
||||
--
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--function store_median_list(list)
|
||||
-- local hist = ''
|
||||
-- local function grow_list(last, n)
|
||||
-- if n == 1 then
|
||||
-- hist = hist == '' and last or string.format('%s:%d', hist, last)
|
||||
-- elseif n > 1 then
|
||||
-- hist = hist == '' and string.format('%dx%d', last, n) or string.format('%s:%dx%d', hist, last, n)
|
||||
-- end
|
||||
-- end
|
||||
-- local n = 0
|
||||
-- local last = 0
|
||||
-- for i, price in pairs(list) do
|
||||
-- if i == 1 then
|
||||
-- last = price
|
||||
-- elseif price ~= last then
|
||||
-- grow_list(last, n)
|
||||
-- last = price
|
||||
-- n = 0
|
||||
-- end
|
||||
-- n = n + 1
|
||||
-- end
|
||||
-- grow_list(last, n)
|
||||
-- return hist
|
||||
--end
|
||||
--
|
||||
--function load_median_list(str)
|
||||
-- local splut = {}
|
||||
-- for x, c in string.gfind(str, '([^%:]*)(%:?)') do
|
||||
-- local _, _, y, n = string.find(x, '(%d*)x(%d*)')
|
||||
-- if y == nil then
|
||||
-- table.insert(splut, tonumber(x))
|
||||
-- else
|
||||
-- for i = 1,n do
|
||||
-- table.insert(splut, tonumber(y))
|
||||
-- end
|
||||
-- end
|
||||
-- if c == '' then break end
|
||||
-- end
|
||||
-- return splut
|
||||
--end
|
||||
|
||||
function Aux.history.get_market_price(key)
|
||||
local price
|
||||
|
||||
@@ -173,18 +126,19 @@ function Aux.history.get_market_price(key)
|
||||
return price
|
||||
end
|
||||
|
||||
function get_usable_median(key)
|
||||
function get_usable_median(item_key)
|
||||
|
||||
local historical_median, historical_count = get_historical_median(key)
|
||||
local historical_median, historical_count = get_historical_median(item_key)
|
||||
|
||||
if historical_count >= MIN_SEEN then
|
||||
return historical_median, historical_count
|
||||
end
|
||||
end
|
||||
|
||||
function get_historical_median(key)
|
||||
local historical_prices = Aux.util.safe_index{get_history()[key], 'records'}
|
||||
return get_median(historical_prices or {})
|
||||
function get_historical_median(item_key)
|
||||
local price_list = Aux.util.safe_index{Aux.persistence.get_item_record(item_key), 'price_list'}
|
||||
|
||||
return get_median(price_list or {})
|
||||
end
|
||||
|
||||
function get_median(values)
|
||||
@@ -244,7 +198,7 @@ function get_percentile(values, pct)
|
||||
return _percentile(values, pct, first, last), last - first + 1
|
||||
end
|
||||
|
||||
function create_balanced_list(max_size, cmp)
|
||||
function balanced_list(max_size, cmp)
|
||||
local self = {}
|
||||
|
||||
local values = {}
|
||||
|
||||
+18
-18
@@ -571,31 +571,31 @@ function Aux.buy.SearchButton_onclick()
|
||||
end
|
||||
|
||||
function show_dialog(buyout_mode, entry, amount)
|
||||
AuxBuyConfirmation.tooltip = entry.tooltip
|
||||
AuxBuyConfirmation.EnhTooltip_info = entry.EnhTooltip_info
|
||||
AuxBuyConfirmationContentItem.tooltip = entry.tooltip
|
||||
AuxBuyConfirmationContentItem.EnhTooltip_info = entry.EnhTooltip_info
|
||||
|
||||
AuxBuyConfirmationActionButton:Disable()
|
||||
AuxBuyConfirmationItemIconTexture:SetTexture(entry.texture)
|
||||
AuxBuyConfirmationItemName:SetText(entry.tooltip[1][1].text)
|
||||
AuxBuyConfirmationContentActionButton:Disable()
|
||||
AuxBuyConfirmationContentItemIconTexture:SetTexture(entry.texture)
|
||||
AuxBuyConfirmationContentItemName:SetText(entry.tooltip[1][1].text)
|
||||
local color = ITEM_QUALITY_COLORS[entry.quality]
|
||||
AuxBuyConfirmationItemName:SetTextColor(color.r, color.g, color.b)
|
||||
AuxBuyConfirmationContentItemName:SetTextColor(color.r, color.g, color.b)
|
||||
|
||||
if entry.stack_size > 1 then
|
||||
AuxBuyConfirmationItemCount:SetText(entry.stack_size);
|
||||
AuxBuyConfirmationItemCount:Show()
|
||||
AuxBuyConfirmationContentItemCount:SetText(entry.stack_size);
|
||||
AuxBuyConfirmationContentItemCount:Show()
|
||||
else
|
||||
AuxBuyConfirmationItemCount:Hide()
|
||||
AuxBuyConfirmationContentItemCount:Hide()
|
||||
end
|
||||
if buyout_mode then
|
||||
AuxBuyConfirmationActionButton:SetText('Buy')
|
||||
MoneyFrame_Update('AuxBuyConfirmationBuyoutPrice', amount)
|
||||
AuxBuyConfirmationBid:Hide()
|
||||
AuxBuyConfirmationBuyoutPrice:Show()
|
||||
AuxBuyConfirmationContentActionButton:SetText('Buy')
|
||||
MoneyFrame_Update('AuxBuyConfirmationContentBuyoutPrice', amount)
|
||||
AuxBuyConfirmationContentBid:Hide()
|
||||
AuxBuyConfirmationContentBuyoutPrice:Show()
|
||||
else
|
||||
AuxBuyConfirmationActionButton:SetText('Bid')
|
||||
MoneyInputFrame_SetCopper(AuxBuyConfirmationBid, amount)
|
||||
AuxBuyConfirmationBuyoutPrice:Hide()
|
||||
AuxBuyConfirmationBid:Show()
|
||||
AuxBuyConfirmationContentActionButton:SetText('Bid')
|
||||
MoneyInputFrame_SetCopper(AuxBuyConfirmationContentBid, amount)
|
||||
AuxBuyConfirmationContentBuyoutPrice:Hide()
|
||||
AuxBuyConfirmationContentBid:Show()
|
||||
end
|
||||
AuxBuyConfirmation:Show()
|
||||
end
|
||||
@@ -681,7 +681,7 @@ function find_auction(entry, buyout_mode, express_mode)
|
||||
AuxBuyConfirmation:Hide()
|
||||
update_sheet()
|
||||
end
|
||||
AuxBuyConfirmationActionButton:Enable()
|
||||
AuxBuyConfirmationContentActionButton:Enable()
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
+108
-109
@@ -280,121 +280,120 @@
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</CheckButton>
|
||||
|
||||
<Frame name="AuxBuySheetFrame" inherits="AuxFrameBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="655" y="326"/>
|
||||
</Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="AuxBuyFilters"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
</Frames>
|
||||
</Frame>
|
||||
<Frame name="AuxBuySheetFrame" inherits="AuxFrameBoxTemplate">
|
||||
<Size>
|
||||
<AbsDimension x="655" y="326"/>
|
||||
</Size>
|
||||
<Anchors><Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="AuxBuyFilters"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
this:SetBackdropColor(0.15, 0.15, 0.15)
|
||||
getglobal(this:GetName().."Title"):SetText('Search Results')
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="AuxBuyBuyList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:SetBackdropBorderColor(0.4, 0.4, 0.4)
|
||||
this:SetBackdropColor(0.15, 0.15, 0.15)
|
||||
getglobal(this:GetName().."Title"):SetText('Search Results')
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[1].sort_order, function(column_order) return { column = Aux.buy.modes[1].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].row_setter, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyBidList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[2].sort_order, function(column_order) return { column = Aux.buy.modes[2].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[2].columns, sort_order, Aux.buy.modes[2].row_setter, Aux.buy.modes[2].on_cell_click, Aux.buy.modes[2].on_cell_enter, Aux.buy.modes[2].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyFullList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[3].sort_order, function(column_order) return { column = Aux.buy.modes[3].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[3].columns, sort_order, Aux.buy.modes[3].row_setter, Aux.buy.modes[3].on_cell_click, Aux.buy.modes[3].on_cell_enter, Aux.buy.modes[3].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyConfirmation" frameStrata="FULLSCREEN_DIALOG" inherits="OptionFrameBoxTemplate" enableMouse="true" enableMouseWheel="true" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnMouseWheel></OnMouseWheel>
|
||||
</Scripts>
|
||||
<Frames>
|
||||
<Frame name="AuxBuyBuyList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[1].sort_order, function(column_order) return { column = Aux.buy.modes[1].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[1].columns, sort_order, Aux.buy.modes[1].row_setter, Aux.buy.modes[1].on_cell_click, Aux.buy.modes[1].on_cell_enter, Aux.buy.modes[1].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyBidList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[2].sort_order, function(column_order) return { column = Aux.buy.modes[2].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[2].columns, sort_order, Aux.buy.modes[2].row_setter, Aux.buy.modes[2].on_cell_click, Aux.buy.modes[2].on_cell_enter, Aux.buy.modes[2].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyFullList" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-40" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
local sort_order = Aux.util.map(Aux.buy.modes[3].sort_order, function(column_order) return { column = Aux.buy.modes[3].columns[column_order.column], sort_ascending = column_order.order == 'ascending' } end)
|
||||
this.sheet = Aux.sheet.create(this, Aux.buy.modes[3].columns, sort_order, Aux.buy.modes[3].row_setter, Aux.buy.modes[3].on_cell_click, Aux.buy.modes[3].on_cell_enter, Aux.buy.modes[3].on_cell_leave)
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
</Frame>
|
||||
<Frame name="AuxBuyConfirmation" frameStrata="FULLSCREEN_DIALOG" inherits="OptionFrameBoxTemplate" enableMouse="true" enableMouseWheel="true" hidden="true">
|
||||
<Anchors>
|
||||
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
|
||||
</Anchors>
|
||||
<Scripts>
|
||||
<OnMouseWheel></OnMouseWheel>
|
||||
</Scripts>
|
||||
<Frame name="$parentContent">
|
||||
<Anchors><Anchor point="CENTER"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Size><AbsDimension x="193" y="140"/></Size>
|
||||
<Frames>
|
||||
<Frame name="$parentContent">
|
||||
<Anchors><Anchor point="CENTER"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Size><AbsDimension x="193" y="300"/></Size>
|
||||
<Frames>
|
||||
<Frame name="$parentItem" inherits="AuxItemTemplate">
|
||||
<Anchors><Anchor point="TOP"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentBid" inherits="MoneyInputFrameTemplate">
|
||||
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="148"/></Offset></Anchor></Anchors>
|
||||
<Layers>
|
||||
<Layer level="OVERLAY">
|
||||
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-10" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</Frame>
|
||||
<Frame name="$parentBuyoutPrice" inherits="SmallMoneyFrameTemplate">
|
||||
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="150"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
SmallMoneyFrame_OnLoad()
|
||||
MoneyFrame_SetType("STATIC")
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
<Layers>
|
||||
<Layer level="OVERLAY">
|
||||
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-5" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</Frame>
|
||||
<Button name="$parentActionButton" inherits="UIPanelButtonTemplate" text="Buy" disabled="true">
|
||||
<Size><AbsDimension x="90" y="26"/> </Size>
|
||||
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="229" y="110"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.dialog_action()
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="$parentCancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-229" y="110"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.dialog_cancel()
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames
|
||||
<Frame name="$parentItem" inherits="AuxItemTemplate">
|
||||
<Anchors><Anchor point="TOP"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
</Frame>
|
||||
<Frame name="$parentBid" inherits="MoneyInputFrameTemplate">
|
||||
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="48"/></Offset></Anchor></Anchors>
|
||||
<Layers>
|
||||
<Layer level="OVERLAY">
|
||||
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-10" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</Frame>
|
||||
<Frame name="$parentBuyoutPrice" inherits="SmallMoneyFrameTemplate">
|
||||
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="50"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
SmallMoneyFrame_OnLoad()
|
||||
MoneyFrame_SetType("STATIC")
|
||||
</OnLoad>
|
||||
</Scripts>
|
||||
<Layers>
|
||||
<Layer level="OVERLAY">
|
||||
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
|
||||
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-5" y="0"/></Offset></Anchor></Anchors>
|
||||
</FontString>
|
||||
</Layer>
|
||||
</Layers>
|
||||
</Frame>
|
||||
<Button name="$parentActionButton" inherits="UIPanelButtonTemplate" text="Buy" disabled="true">
|
||||
<Size><AbsDimension x="90" y="26"/> </Size>
|
||||
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.dialog_action()
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
<Button name="$parentCancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
|
||||
<Size><AbsDimension x="90" y="26"/></Size>
|
||||
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
|
||||
<Scripts>
|
||||
<OnClick>
|
||||
Aux.buy.dialog_cancel()
|
||||
</OnClick>
|
||||
</Scripts>
|
||||
</Button>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
</Frames>
|
||||
</Frame>
|
||||
|
||||
@@ -308,3 +308,51 @@ function Aux.util.group_by(tables, equal)
|
||||
end
|
||||
return groups
|
||||
end
|
||||
|
||||
function Aux.util.set()
|
||||
local self = {}
|
||||
|
||||
local data = {}
|
||||
|
||||
function self.set_data(new_data)
|
||||
data = new_data
|
||||
end
|
||||
|
||||
function self.get_data()
|
||||
return data
|
||||
end
|
||||
|
||||
function self.add(value)
|
||||
data[value] = true
|
||||
end
|
||||
|
||||
function self.add_all(values)
|
||||
for _, value in ipairs(values) do
|
||||
self.add(value)
|
||||
end
|
||||
end
|
||||
|
||||
function self.remove(value)
|
||||
data[value] = nil
|
||||
end
|
||||
|
||||
function self.remove_all(values)
|
||||
for _, value in ipairs(values) do
|
||||
self.remove(value)
|
||||
end
|
||||
end
|
||||
|
||||
function self.contains(value)
|
||||
return data[value] ~= nil
|
||||
end
|
||||
|
||||
function self.values()
|
||||
local values = {}
|
||||
for value, _ in pairs(data) do
|
||||
tinsert(values, value)
|
||||
end
|
||||
return values
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user