some auction listing changes

This commit is contained in:
Manuel Simon Hirsig
2016-11-28 21:47:01 +01:00
parent efef235430
commit 4ed688379b
5 changed files with 34 additions and 103 deletions
+31 -51
View File
@@ -53,10 +53,9 @@ function item_column_init(rt, cell)
cell.iconBtn = iconBtn
cell.icon = icon
local text = cell:GetFontString()
text:ClearAllPoints()
text:SetPoint('TOPLEFT', iconBtn, 'TOPRIGHT', 2, 0)
text:SetPoint('BOTTOMRIGHT', 0, 0)
cell.text:ClearAllPoints()
cell.text:SetPoint('TOPLEFT', iconBtn, 'TOPRIGHT', 2, 0)
cell.text:SetPoint('BOTTOMRIGHT', 0, 0)
end
M.search_config = {
@@ -69,13 +68,13 @@ M.search_config = {
if indented then
cell.spacer:SetWidth(10)
cell.icon:SetAlpha(.5)
cell:GetFontString():SetAlpha(.7)
cell.text:SetAlpha(.7)
else
cell.spacer:SetWidth(1)
cell.icon:SetAlpha(1)
cell:GetFontString():SetAlpha(1)
cell.text:SetAlpha(1)
end
cell:SetText(gsub(record.link, '[%[%]]', ''))
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
@@ -88,7 +87,7 @@ M.search_config = {
fill = function(cell, record)
local display_level = max(record.level, 1)
display_level = UnitLevel'player' < record.level and color.red(display_level) or display_level
cell:SetText(display_level)
cell.text:SetText(display_level)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.level, record_b.level, desc)
@@ -103,7 +102,7 @@ M.search_config = {
if own > 0 then
numAuctionsText = numAuctionsText .. (' ' .. color.yellow('(' .. own .. ')'))
end
cell:SetText(numAuctionsText)
cell.text:SetText(numAuctionsText)
end,
cmp = function(record_a, record_b, desc)
return sort_util.EQ
@@ -123,7 +122,7 @@ M.search_config = {
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
cell.text:SetText(record.aux_quantity)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.aux_quantity, record_b.aux_quantity, desc)
@@ -134,7 +133,7 @@ M.search_config = {
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
cell.text:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.duration, record_b.duration, desc)
@@ -145,7 +144,7 @@ M.search_config = {
width = .13,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
cell.text:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
end,
cmp = function(record_a, record_b, desc)
if not record_a.owner and not record_b.owner then
@@ -177,7 +176,7 @@ M.search_config = {
else
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price, true, false, nil, price_color))
cell.text:SetText(money.to_string(price, true, false, nil, price_color))
end,
cmp = function(record_a, record_b, desc)
local price_a
@@ -202,7 +201,7 @@ M.search_config = {
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
cell.text:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
@@ -219,7 +218,7 @@ M.search_config = {
align = 'CENTER',
fill = function(cell, record)
local pct, bidPct = record_percentage(record)
cell:SetText((pct or bidPct) and percentage_historical(pct or bidPct, not pct) or '---')
cell.text:SetText((pct or bidPct) and percentage_historical(pct or bidPct, not pct) or '---')
end,
cmp = function(record_a, record_b, desc)
local pct_a = record_percentage(record_a) or (desc and -huge or huge)
@@ -245,7 +244,7 @@ M.auctions_config = {
cell.icon:SetAlpha(1)
cell:GetFontString():SetAlpha(1)
end
cell:SetText(gsub(record.link, '[%[%]]', ''))
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
@@ -258,7 +257,7 @@ M.auctions_config = {
fill = function(cell, record)
local display_level = max(record.level, 1)
display_level = UnitLevel('player') < record.level and color.red(display_level) or display_level
cell:SetText(display_level)
cell.text:SetText(display_level)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.level, record_b.level, desc)
@@ -270,7 +269,7 @@ M.auctions_config = {
align = 'CENTER',
fill = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and color.link(count) or count
cell:SetText(numAuctionsText)
cell.text:SetText(numAuctionsText)
end,
cmp = function(record_a, record_b, desc)
return sort_util.EQ
@@ -290,7 +289,7 @@ M.auctions_config = {
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
cell.text:SetText(record.aux_quantity)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.aux_quantity, record_b.aux_quantity, desc)
@@ -301,7 +300,7 @@ M.auctions_config = {
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
cell.text:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.duration, record_b.duration, desc)
@@ -319,7 +318,7 @@ M.auctions_config = {
else
price = aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
end
cell:SetText(money.to_string(price, true, false))
cell.text:SetText(money.to_string(price, true, false))
end,
cmp = function(record_a, record_b, desc)
local price_a
@@ -344,7 +343,7 @@ M.auctions_config = {
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
cell.text:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
@@ -360,7 +359,7 @@ M.auctions_config = {
width = .21,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.high_bidder or color.red 'No Bids')
cell.text:SetText(record.high_bidder or color.red 'No Bids')
end,
cmp = function(record_a, record_b, desc)
if not record_a.high_bidder and not record_b.high_bidder then
@@ -392,7 +391,7 @@ M.bids_config = {
cell.icon:SetAlpha(1)
cell:GetFontString():SetAlpha(1)
end
cell:SetText(gsub(record.link, '[%[%]]', ''))
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.name, record_b.name, desc)
@@ -404,7 +403,7 @@ M.bids_config = {
align = 'CENTER',
fill = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and color.link(count) or count
cell:SetText(numAuctionsText)
cell.text:SetText(numAuctionsText)
end,
cmp = function(record_a, record_b, desc)
return sort_util.EQ
@@ -424,7 +423,7 @@ M.bids_config = {
width = .055,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(record.aux_quantity)
cell.text:SetText(record.aux_quantity)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.aux_quantity, record_b.aux_quantity, desc)
@@ -435,7 +434,7 @@ M.bids_config = {
width = .04,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
cell.text:SetText(TIME_LEFT_STRINGS[record.duration or 0] or '---')
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.duration, record_b.duration, desc)
@@ -446,7 +445,7 @@ M.bids_config = {
width = .13,
align = 'CENTER',
fill = function(cell, record)
cell:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
cell.text:SetText(is_player(record.owner) and (color.yellow(record.owner)) or (record.owner or '---'))
end,
cmp = function(record_a, record_b, desc)
if not record_a.owner and not record_b.owner then
@@ -472,7 +471,7 @@ M.bids_config = {
else
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell:SetText(money.to_string(price))
cell.text:SetText(money.to_string(price))
end,
cmp = function(record_a, record_b, desc)
local price_a
@@ -497,7 +496,7 @@ M.bids_config = {
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
cell:SetText(price > 0 and money.to_string(price, true, false) or '---')
cell.text:SetText(price > 0 and money.to_string(price, true, false) or '---')
end,
cmp = function(record_a, record_b, desc)
local price_a = aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
@@ -519,7 +518,7 @@ M.bids_config = {
else
status = color.red'Outbid'
end
cell:SetText(status)
cell.text:SetText(status)
end,
cmp = function(record_a, record_b, desc)
return sort_util.compare(record_a.high_bidder and 1 or 0, record_b.high_bidder and 1 or 0, desc)
@@ -622,13 +621,11 @@ local methods = {
end
end
-- show highlight for this row
this.row.highlight:Show()
end,
OnCellLeave = function()
GameTooltip:Hide()
-- hide highlight if it's not selected
if not this.rt.selected or this.rt.selected.search_signature ~= this.row.data.record.search_signature then
this.row.highlight:Hide()
end
@@ -664,7 +661,6 @@ local methods = {
rt.expanded[rowData.expandKey] = expand
rt:UpdateRowInfo()
rt:UpdateRows()
-- select this row if it's not indented
if not rowData.indented then
rt:SetSelectedRecord(this.row.data.record)
end
@@ -687,8 +683,6 @@ local methods = {
if getn(records) == 0 then return end
sort(records, function(a, b) return a.search_signature < b.search_signature or a.search_signature == b.search_signature and tostring(a) < tostring(b) end)
-- Populate the row info from the database by combining identical auctions and auctions
-- of the same base item. Also, get the number of rows which will be shown.
for i = 1, getn(records) do
local record = records[i]
local prevRecord = records[i - 1]
@@ -723,10 +717,8 @@ local methods = {
end,
UpdateRows = function(self)
-- hide all the rows
for _, row in self.rows do row:Hide() end
-- update sort_util highlights
for _, cell in self.headCells do
local tex = cell:GetNormalTexture()
tex:SetTexture[[Interface\AddOns\aux-AddOn\WorldStateFinalScore-Highlight]]
@@ -745,7 +737,6 @@ local methods = {
FauxScrollFrame_Update(self.scrollFrame, self.rowInfo.numDisplayRows, getn(self.rows), self.ROW_HEIGHT)
-- make sure the offset is not too high
local maxOffset = max(self.rowInfo.numDisplayRows - getn(self.rows), 0)
if FauxScrollFrame_GetOffset(self.scrollFrame) > maxOffset then
FauxScrollFrame_SetOffset(self.scrollFrame, maxOffset)
@@ -783,19 +774,16 @@ local methods = {
self.isSorted = true
end
-- update all the rows
local rowIndex = 1 - FauxScrollFrame_GetOffset(self.scrollFrame)
for i = 1, getn(self.rowInfo) do
local info = self.rowInfo[i]
if self.expanded[info.expandKey] then
-- show each of the rows for this base item since it's expanded
for j = 1, getn(info.children) do
local childInfo = info.children[j]
self:SetRowInfo(rowIndex, childInfo.record, childInfo.numAuctions, 0, j > 1, false, info.expandKey, childInfo.numAuctions)
rowIndex = rowIndex + 1
end
else
-- just show one row for this base item since it's not expanded
self:SetRowInfo(rowIndex, info.children[1].record, info.totalAuctions, getn(info.children) > 1 and info.totalPlayerAuctions or 0, false, getn(info.children) > 1, info.expandKey, info.children[1].numAuctions)
rowIndex = rowIndex + 1
end
@@ -805,7 +793,6 @@ local methods = {
SetRowInfo = function(self, rowIndex, record, displayNumAuctions, numPlayerAuctions, indented, expandable, expandKey, numAuctions)
if rowIndex <= 0 or rowIndex > getn(self.rows) then return end
local row = self.rows[rowIndex]
-- show this row
row:Show()
if self.selected and record.search_signature == self.selected.search_signature then
row.highlight:Show()
@@ -822,12 +809,10 @@ local methods = {
SetSelectedRecord = function(self, record, silent)
if self.disabled then return end
-- make sure the selected record still exists and get the data for the callback
self.selected = record
local selectedData = self:GetSelection()
self.selected = selectedData and self.selected or nil
-- show / hide highlight accordingly
for _, row in self.rows do
if self.selected and row.data and row.data.record.search_signature == self.selected.search_signature then
row.highlight:Show()
@@ -1007,7 +992,6 @@ function M.CreateAuctionResultsTable(parent, config)
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
rt.contentFrame = contentFrame
-- frame to hold the header columns and the rows
local scrollFrame = CreateFrame('ScrollFrame', gui.unique_name, rt, 'FauxScrollFrameTemplate')
scrollFrame:SetScript('OnVerticalScroll', function()
if not rt.scrollDisabled then
@@ -1031,7 +1015,6 @@ function M.CreateAuctionResultsTable(parent, config)
_G[scrollBar:GetName() .. 'ScrollUpButton']:Hide()
_G[scrollBar:GetName() .. 'ScrollDownButton']:Hide()
-- create the header cells
rt.headCells = T
for i = 1, getn(rt.config) do
local column_config = rt.config[i]
@@ -1075,7 +1058,6 @@ function M.CreateAuctionResultsTable(parent, config)
tinsert(rt.headCells, cell)
end
-- create the rows
rt.rows = T
for i = 1, numRows do
local row = CreateFrame('Frame', nil, rt.contentFrame)
@@ -1098,12 +1080,12 @@ function M.CreateAuctionResultsTable(parent, config)
for j = 1, getn(rt.config) do
local cell = CreateFrame('Button', nil, row)
local text = cell:CreateFontString()
cell.text = text
text:SetFont(gui.font, min(14, rt.ROW_HEIGHT))
text:SetJustifyH(rt.config[j].align or 'LEFT')
text:SetJustifyV('CENTER')
text:SetPoint('TOPLEFT', 1, -1)
text:SetPoint('BOTTOMRIGHT', -1, 1)
cell:SetFontString(text)
cell:SetHeight(rt.ROW_HEIGHT)
cell:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
cell:SetScript('OnEnter', rt.OnCellEnter)
@@ -1119,7 +1101,6 @@ function M.CreateAuctionResultsTable(parent, config)
cell:SetPoint('TOPLEFT', row.cells[j-1], 'TOPRIGHT')
end
-- slightly different color for every alternating column
if mod(j, 2) == 1 then
local tex = cell:CreateTexture()
tex:SetAllPoints()
@@ -1134,7 +1115,6 @@ function M.CreateAuctionResultsTable(parent, config)
tinsert(row.cells, cell)
end
-- slightly different color for every alternating
if mod(i, 2) == 0 then
local tex = row:CreateTexture()
tex:SetAllPoints()
+3 -1
View File
@@ -20,7 +20,7 @@ function M.render(item_listing)
if item_record then
row.item_record = item_record
if item_listing.selected and item_listing.selected(item_record) then
if item_listing.selected and item_listing.selected(item_record) or row.mouseover then
row.highlight:Show()
elseif not row.mouse_over then
row.highlight:Hide()
@@ -75,9 +75,11 @@ function M.create(parent, on_click, selected)
row:EnableMouse(true)
row:SetScript('OnMouseDown', on_click)
row:SetScript('OnEnter', function()
row.mouseover = true
row.highlight:Show()
end)
row:SetScript('OnLeave', function()
row.mouseover = false
if not selected(row.item_record) then
row.highlight:Hide()
end
-48
View File
@@ -60,22 +60,6 @@ local methods = {
local offset = FauxScrollFrame_GetOffset(st.scrollFrame)
st.offset = offset
-- do sorting if enabled
if st.sortInfo.enabled and st.sortInfo.col and st.updateSort then
local function SortHelper(rowA, rowB)
local sortArgA = rowA.cols[st.sortInfo.col].sortArg
local sortArgB = rowB.cols[st.sortInfo.col].sortArg
if st.sortInfo.ascending then
return sortArgA < sortArgB
else
return sortArgA > sortArgB
end
end
sort(st.rowData, SortHelper)
st.updateSort = nil
end
for i = 1, st.sizes.numRows do
st.rows[i].data = nil
if i > getn(st.rowData) then
@@ -144,21 +128,6 @@ local methods = {
st.selectionDisabled = value
end,
EnableSorting = function(st, value, defaultCol)
st.sortInfo.enabled = value
st.sortInfo.col = abs(defaultCol or 1)
st.sortInfo.ascending = not defaultCol or defaultCol > 0
st.updateSort = true
for _, headCol in st.headCols do
if value then
headCol:EnableMouse(true)
else
headCol:EnableMouse(false)
end
end
st:RefreshRows()
end,
DisableHighlight = function(st, value)
st.highlightDisabled = value
end,
@@ -177,15 +146,12 @@ local methods = {
local height = st:GetHeight()
if getn(st.colInfo) > 1 or st.colInfo[1].name then
-- there is a header row
st.sizes.headHeight = st.sizes.headFontSize and (st.sizes.headFontSize + 4) or ST_HEAD_HEIGHT
else
-- no header row
st.sizes.headHeight = 0
end
st.sizes.numRows = max(floor((st:GetParent():GetHeight() - st.sizes.headHeight - ST_HEAD_SPACE) / ST_ROW_HEIGHT), 0)
-- update the frame
st.scrollBar:ClearAllPoints()
st.scrollBar:SetPoint('BOTTOMRIGHT', st, -1, 1)
st.scrollBar:SetPoint('TOPRIGHT', st, -1, -st.sizes.headHeight - ST_HEAD_SPACE - 1)
@@ -199,18 +165,15 @@ local methods = {
st.headLine:Hide()
end
-- update the first row
if st.rows and st.rows[1] then
st.rows[1]:SetPoint('TOPLEFT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE))
st.rows[1]:SetPoint('TOPRIGHT', 0, -(st.sizes.headHeight + ST_HEAD_SPACE))
end
-- add header columns if necessary
while getn(st.headCols) < getn(st.colInfo) do
st:AddColumn()
end
-- adjust head col widths
for i, col in st.headCols do
if st.colInfo[i] then
col:Show()
@@ -223,19 +186,16 @@ local methods = {
end
end
-- add more rows if necessary
while getn(st.rows) < st.sizes.numRows do
st:AddRow()
end
-- adjust rows widths
for i, row in st.rows do
if i > st.sizes.numRows then
row.data = nil
row:Hide()
else
row:Show()
-- add any missing cols
while getn(row.cols) < getn(st.colInfo) do
st:AddRowCol(i)
end
@@ -340,7 +300,6 @@ local methods = {
SetHeadFontSize = function(st, size)
st.sizes.headFontSize = size
-- update the text size of the head cols
for _, col in st.headCols do
if st.sizes.headFontSize then
col.text:SetFont(gui.font, st.sizes.headFontSize)
@@ -359,18 +318,15 @@ local methods = {
}
function M.CreateScrollingTable(parent)
-- create the base frame
ST_COUNT = ST_COUNT + 1
local st = CreateFrame('Frame', 'TSMScrollingTable' .. ST_COUNT, parent)
st:SetAllPoints()
-- st:SetScript('OnSizeChanged', function() st:Redraw() end)
local contentFrame = CreateFrame('Frame', nil, st)
contentFrame:SetPoint('TOPLEFT', 0, 0)
contentFrame:SetPoint('BOTTOMRIGHT', -15, 0)
st.contentFrame = contentFrame
-- frame to hold the header columns and the rows
local scrollFrame = CreateFrame('ScrollFrame', st:GetName() .. 'ScrollFrame', st, 'FauxScrollFrameTemplate')
scrollFrame:SetScript('OnVerticalScroll', function(self, offset)
FauxScrollFrame_OnVerticalScroll(ST_ROW_HEIGHT, function() st:RefreshRows() end)
@@ -389,21 +345,17 @@ function M.CreateScrollingTable(parent)
_G[scrollBar:GetName() .. 'ScrollUpButton']:Hide()
_G[scrollBar:GetName() .. 'ScrollDownButton']:Hide()
-- create head line at default position
st.headLine = gui.horizontal_line(st, 0)
-- add all the methods
for name, func in methods do
st[name] = func
end
-- setup default values
st.isTSMScrollingTable = true
st.sizes = T
st.headCols = T
st.rows = T
st.handlers = T
st.sortInfo = T
st.colInfo = DEFAULT_COL_INFO
return st
-2
View File
@@ -75,7 +75,6 @@ bid_listing:SetColInfo{
{name='Bid/ea', width=.4, align='RIGHT'},
{name='Pct', width=.23, align='CENTER'},
}
bid_listing:EnableSorting(false)
bid_listing:DisableSelection(true)
bid_listing:SetHandler('OnClick', function(table, row_data, column, button)
unit_start_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton')
@@ -89,7 +88,6 @@ buyout_listing:SetColInfo{
{name='Buy/ea', width=.4, align='RIGHT'},
{name='Pct', width=.23, align='CENTER'},
}
buyout_listing:EnableSorting(false)
buyout_listing:DisableSelection(true)
buyout_listing:SetHandler('OnClick', function(table, row_data, column, button)
unit_buyout_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton')
-1
View File
@@ -541,7 +541,6 @@ recent_searches_listing = listing.CreateScrollingTable(frame.saved.recent)
recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}}
for listing in temp-S(favorite_searches_listing, recent_searches_listing) do
listing:EnableSorting(false)
listing:DisableSelection(true)
for k, v in handlers do
listing:SetHandler(k, v)