big refactoring
This commit is contained in:
+31
-31
@@ -1,6 +1,6 @@
|
||||
aux.module 'auction_listing'
|
||||
|
||||
g.aux_price_per_unit = false
|
||||
_g.aux_price_per_unit = false
|
||||
|
||||
local RT_COUNT = 1
|
||||
local HEAD_HEIGHT = 27
|
||||
@@ -166,24 +166,24 @@ public.search_config = {
|
||||
end
|
||||
local price
|
||||
if record.high_bidder then
|
||||
price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
else
|
||||
price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
|
||||
price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
|
||||
end
|
||||
cell:SetText(money.to_string(price, true, false, nil, color))
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a
|
||||
if record_a.high_bidder then
|
||||
price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
else
|
||||
price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
|
||||
price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
|
||||
end
|
||||
local price_b
|
||||
if record_b.high_bidder then
|
||||
price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
else
|
||||
price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
|
||||
price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
|
||||
end
|
||||
return sorting.compare(price_a, price_b, desc)
|
||||
end,
|
||||
@@ -194,12 +194,12 @@ public.search_config = {
|
||||
align = 'RIGHT',
|
||||
isPrice = true,
|
||||
fill = function(cell, record)
|
||||
local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
|
||||
local price = _g.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 '---')
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||
|
||||
@@ -308,24 +308,24 @@ public.auctions_config = {
|
||||
fill = function(cell, record)
|
||||
local price
|
||||
if record.high_bidder then
|
||||
price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
else
|
||||
price = g.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
|
||||
price = _g.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))
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a
|
||||
if record_a.high_bidder then
|
||||
price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
else
|
||||
price_a = g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
|
||||
price_a = _g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
|
||||
end
|
||||
local price_b
|
||||
if record_b.high_bidder then
|
||||
price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
else
|
||||
price_b = g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
|
||||
price_b = _g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
|
||||
end
|
||||
return sorting.compare(price_a, price_b, desc)
|
||||
end,
|
||||
@@ -336,12 +336,12 @@ public.auctions_config = {
|
||||
align = 'RIGHT',
|
||||
isPrice = true,
|
||||
fill = function(cell, record)
|
||||
local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
|
||||
local price = _g.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 '---')
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||
|
||||
@@ -461,24 +461,24 @@ public.bids_config = {
|
||||
fill = function(cell, record)
|
||||
local price
|
||||
if record.high_bidder then
|
||||
price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
|
||||
else
|
||||
price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
|
||||
price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
|
||||
end
|
||||
cell:SetText(money.to_string(price))
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a
|
||||
if record_a.high_bidder then
|
||||
price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
|
||||
else
|
||||
price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
|
||||
price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
|
||||
end
|
||||
local price_b
|
||||
if record_b.high_bidder then
|
||||
price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
|
||||
else
|
||||
price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
|
||||
price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
|
||||
end
|
||||
return sorting.compare(price_a, price_b, desc)
|
||||
end,
|
||||
@@ -489,12 +489,12 @@ public.bids_config = {
|
||||
align = 'RIGHT',
|
||||
isPrice = true,
|
||||
fill = function(cell, record)
|
||||
local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
|
||||
local price = _g.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 '---')
|
||||
end,
|
||||
cmp = function(record_a, record_b, desc)
|
||||
local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
|
||||
local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
|
||||
price_a = price_a > 0 and price_a or (desc and -huge or huge)
|
||||
price_b = price_b > 0 and price_b or (desc and -huge or huge)
|
||||
|
||||
@@ -567,10 +567,10 @@ local methods = {
|
||||
if rt.disabled then return end
|
||||
|
||||
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
|
||||
g.aux_price_per_unit = not g.aux_price_per_unit
|
||||
_g.aux_price_per_unit = not _g.aux_price_per_unit
|
||||
for _, cell in rt.headCells do
|
||||
if cell.info.isPrice then
|
||||
cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2])
|
||||
cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2])
|
||||
end
|
||||
end
|
||||
rt:SetSort()
|
||||
@@ -1009,7 +1009,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
||||
rt:SetScript('OnShow', function()
|
||||
for _, cell in this.headCells do
|
||||
if cell.info.isPrice then
|
||||
cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2])
|
||||
cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2])
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
+5
-15
@@ -37,21 +37,13 @@ function public.render(item_listing)
|
||||
end
|
||||
|
||||
function public.create(parent, on_click, selected)
|
||||
local name = 'g.aux_item_list'
|
||||
|
||||
local id = 1
|
||||
while getglobal(name..id) do
|
||||
id = id + 1
|
||||
end
|
||||
name = name..id
|
||||
|
||||
local content = CreateFrame('Frame', nil, parent)
|
||||
content:SetPoint('TOPLEFT', 0, -51)
|
||||
content:SetPoint('BOTTOMRIGHT', -15, 0)
|
||||
|
||||
local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', parent, 'FauxScrollFrameTemplate')
|
||||
local scroll_frame = CreateFrame('ScrollFrame', gui.name..'ScrollFrame', parent, 'FauxScrollFrameTemplate')
|
||||
scroll_frame:SetScript('OnVerticalScroll', function(self, offset)
|
||||
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() m.render(this.item_listing) end)
|
||||
FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end)
|
||||
end)
|
||||
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
|
||||
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
|
||||
@@ -60,7 +52,7 @@ function public.create(parent, on_click, selected)
|
||||
scrollBar:SetWidth(12)
|
||||
local thumbTex = scrollBar:GetThumbTexture()
|
||||
thumbTex:SetPoint('CENTER', 0, 0)
|
||||
thumbTex:SetTexture(unpack(gui.color.content.background))
|
||||
thumbTex:SetTexture(gui.color.content.background())
|
||||
thumbTex:SetHeight(50)
|
||||
thumbTex:SetWidth(12)
|
||||
getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide()
|
||||
@@ -93,9 +85,7 @@ function public.create(parent, on_click, selected)
|
||||
row.item.button:SetScript('OnEnter', function()
|
||||
info.set_tooltip(row.item_record.itemstring, this, 'ANCHOR_RIGHT')
|
||||
end)
|
||||
row.item.button:SetScript('OnLeave', function()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
row.item.button:SetScript('OnLeave', function() GameTooltip:Hide() end)
|
||||
|
||||
local highlight = row:CreateTexture()
|
||||
highlight:SetAllPoints(row)
|
||||
@@ -120,5 +110,5 @@ end
|
||||
|
||||
function public.populate(item_listing, item_records)
|
||||
item_listing.item_records = item_records
|
||||
m.render(item_listing)
|
||||
render(item_listing)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user