refactoring
This commit is contained in:
@@ -49,6 +49,7 @@ do
|
|||||||
for _, f in handlers do f() end
|
for _, f in handlers do f() end
|
||||||
elseif event == 'PLAYER_LOGIN' then
|
elseif event == 'PLAYER_LOGIN' then
|
||||||
for _, f in handlers2 do f() end
|
for _, f in handlers2 do f() end
|
||||||
|
print('aux loaded - /aux')
|
||||||
else
|
else
|
||||||
_M[event]()
|
_M[event]()
|
||||||
end
|
end
|
||||||
|
|||||||
+16
-16
@@ -72,7 +72,7 @@ function item_column_fill(cell, record, _, _, _, indented)
|
|||||||
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
|
cell.text:SetText(gsub(record.link, '[%[%]]', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
M.search_config = {
|
M.search_columns = {
|
||||||
{
|
{
|
||||||
title = 'Item',
|
title = 'Item',
|
||||||
width = .35,
|
width = .35,
|
||||||
@@ -242,7 +242,7 @@ M.search_config = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
M.auctions_config = {
|
M.auctions_columns = {
|
||||||
{
|
{
|
||||||
title = 'Item',
|
title = 'Item',
|
||||||
width = .35,
|
width = .35,
|
||||||
@@ -377,7 +377,7 @@ M.auctions_config = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
M.bids_config = {
|
M.bids_columns = {
|
||||||
{
|
{
|
||||||
title = 'Item',
|
title = 'Item',
|
||||||
width = .35,
|
width = .35,
|
||||||
@@ -744,7 +744,7 @@ local methods = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, sort in self.sorts do
|
for _, sort in self.sorts do
|
||||||
local ordering = self.config[sort.index].cmp and self.config[sort.index].cmp(record_a, record_b, sort.descending) or sort_util.EQ
|
local ordering = self.columns[sort.index].cmp and self.columns[sort.index].cmp(record_a, record_b, sort.descending) or sort_util.EQ
|
||||||
|
|
||||||
if ordering == sort_util.LT then
|
if ordering == sort_util.LT then
|
||||||
return true
|
return true
|
||||||
@@ -791,8 +791,8 @@ local methods = {
|
|||||||
end
|
end
|
||||||
row.data = {record=record, expandable=expandable, indented=indented, numAuctions=numAuctions, expandKey=expandKey}
|
row.data = {record=record, expandable=expandable, indented=indented, numAuctions=numAuctions, expandKey=expandKey}
|
||||||
|
|
||||||
for i, column_config in self.config do
|
for i, column in self.columns do
|
||||||
column_config.fill(row.cells[i], record, displayNumAuctions, numPlayerAuctions, expandable, indented)
|
column.fill(row.cells[i], record, displayNumAuctions, numPlayerAuctions, expandable, indented)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -903,9 +903,9 @@ local methods = {
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.new(parent, rows, config)
|
function M.new(parent, rows, columns)
|
||||||
local rt = CreateFrame('Frame', nil, parent)
|
local rt = CreateFrame('Frame', nil, parent)
|
||||||
rt.config = config
|
rt.columns = columns
|
||||||
rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / rows
|
rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / rows
|
||||||
rt.expanded = {}
|
rt.expanded = {}
|
||||||
rt.handlers = {}
|
rt.handlers = {}
|
||||||
@@ -952,8 +952,8 @@ function M.new(parent, rows, config)
|
|||||||
_G[scrollBar:GetName() .. 'ScrollDownButton']:Hide()
|
_G[scrollBar:GetName() .. 'ScrollDownButton']:Hide()
|
||||||
|
|
||||||
rt.headCells = {}
|
rt.headCells = {}
|
||||||
for i = 1, getn(rt.config) do
|
for i = 1, getn(rt.columns) do
|
||||||
local column_config = rt.config[i]
|
local column = rt.columns[i]
|
||||||
local cell = CreateFrame('Button', nil, rt.contentFrame)
|
local cell = CreateFrame('Button', nil, rt.contentFrame)
|
||||||
cell:SetHeight(HEAD_HEIGHT)
|
cell:SetHeight(HEAD_HEIGHT)
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
@@ -961,7 +961,7 @@ function M.new(parent, rows, config)
|
|||||||
else
|
else
|
||||||
cell:SetPoint('TOPLEFT', rt.headCells[i - 1], 'TOPRIGHT')
|
cell:SetPoint('TOPLEFT', rt.headCells[i - 1], 'TOPRIGHT')
|
||||||
end
|
end
|
||||||
cell.info = column_config
|
cell.info = column
|
||||||
cell.rt = rt
|
cell.rt = rt
|
||||||
cell.columnIndex = i
|
cell.columnIndex = i
|
||||||
cell:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
cell:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
|
||||||
@@ -973,7 +973,7 @@ function M.new(parent, rows, config)
|
|||||||
text:SetFont(gui.font, 12)
|
text:SetFont(gui.font, 12)
|
||||||
text:SetTextColor(color.label.enabled())
|
text:SetTextColor(color.label.enabled())
|
||||||
cell:SetFontString(text)
|
cell:SetFontString(text)
|
||||||
if not column_config.isPrice then cell:SetText(column_config.title or '') end -- TODO
|
if not column.isPrice then cell:SetText(column.title or '') end -- TODO
|
||||||
text:SetAllPoints()
|
text:SetAllPoints()
|
||||||
|
|
||||||
local tex = cell:CreateTexture()
|
local tex = cell:CreateTexture()
|
||||||
@@ -1017,12 +1017,12 @@ function M.new(parent, rows, config)
|
|||||||
row.rt = rt
|
row.rt = rt
|
||||||
|
|
||||||
row.cells = {}
|
row.cells = {}
|
||||||
for j = 1, getn(rt.config) do
|
for j = 1, getn(rt.columns) do
|
||||||
local cell = CreateFrame('Frame', nil, row)
|
local cell = CreateFrame('Frame', nil, row)
|
||||||
local text = cell:CreateFontString()
|
local text = cell:CreateFontString()
|
||||||
cell.text = text
|
cell.text = text
|
||||||
text:SetFont(gui.font, min(14, rt.ROW_HEIGHT))
|
text:SetFont(gui.font, min(14, rt.ROW_HEIGHT))
|
||||||
text:SetJustifyH(rt.config[j].align or 'LEFT')
|
text:SetJustifyH(rt.columns[j].align or 'LEFT')
|
||||||
text:SetJustifyV('CENTER')
|
text:SetJustifyV('CENTER')
|
||||||
text:SetPoint('TOPLEFT', 1, -1)
|
text:SetPoint('TOPLEFT', 1, -1)
|
||||||
text:SetPoint('BOTTOMRIGHT', -1, 1)
|
text:SetPoint('BOTTOMRIGHT', -1, 1)
|
||||||
@@ -1042,8 +1042,8 @@ function M.new(parent, rows, config)
|
|||||||
tex:SetTexture(.3, .3, .3, .2)
|
tex:SetTexture(.3, .3, .3, .2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if rt.config[j].init then
|
if rt.columns[j].init then
|
||||||
rt.config[j].init(rt, cell)
|
rt.columns[j].init(rt, cell)
|
||||||
end
|
end
|
||||||
|
|
||||||
tinsert(row.cells, cell)
|
tinsert(row.cells, cell)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
|
|||||||
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
|
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
|
||||||
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
|
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
|
||||||
|
|
||||||
listing = auction_listing.new(frame.listing, 20, auction_listing.auctions_config)
|
listing = auction_listing.new(frame.listing, 20, auction_listing.auctions_columns)
|
||||||
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
||||||
listing:Reset()
|
listing:Reset()
|
||||||
listing:SetHandler('OnCellClick', function(cell, button)
|
listing:SetHandler('OnCellClick', function(cell, button)
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ frame.listing:SetPoint('TOP', frame, 'TOP', 0, -8)
|
|||||||
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
|
frame.listing:SetPoint('BOTTOMLEFT', AuxFrame.content, 'BOTTOMLEFT', 0, 0)
|
||||||
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
|
frame.listing:SetPoint('BOTTOMRIGHT', AuxFrame.content, 'BOTTOMRIGHT', 0, 0)
|
||||||
|
|
||||||
listing = auction_listing.new(frame.listing, 20, auction_listing.bids_config)
|
listing = auction_listing.new(frame.listing, 20, auction_listing.bids_columns)
|
||||||
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
listing:SetSort(1, 2, 3, 4, 5, 6, 7, 8)
|
||||||
listing:Reset()
|
listing:Reset()
|
||||||
listing:SetHandler('OnCellClick', function(cell, button)
|
listing:SetHandler('OnCellClick', function(cell, button)
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ for _ = 1, 5 do
|
|||||||
status_bar:Hide()
|
status_bar:Hide()
|
||||||
tinsert(status_bars, status_bar)
|
tinsert(status_bars, status_bar)
|
||||||
|
|
||||||
local table = auction_listing.new(frame.results, 16, auction_listing.search_config)
|
local table = auction_listing.new(frame.results, 16, auction_listing.search_columns)
|
||||||
table:SetHandler('OnCellClick', function(cell, button)
|
table:SetHandler('OnCellClick', function(cell, button)
|
||||||
if IsAltKeyDown() and current_search.table:GetSelection().record == cell.row.data.record then
|
if IsAltKeyDown() and current_search.table:GetSelection().record == cell.row.data.record then
|
||||||
if button == 'LeftButton' then
|
if button == 'LeftButton' then
|
||||||
|
|||||||
Reference in New Issue
Block a user