refactoring
This commit is contained in:
+34
-34
@@ -1,6 +1,6 @@
|
||||
module 'auction_listing' import 'gui' 'sorting' 'history' 'money' 'info'
|
||||
|
||||
_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)
|
||||
@@ -1031,7 +1031,7 @@ function public.CreateAuctionResultsTable(parent, config)
|
||||
rt.scrollFrame = scrollFrame
|
||||
FauxScrollFrame_Update(rt.scrollFrame, 0, numRows, rt.ROW_HEIGHT)
|
||||
|
||||
local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
|
||||
local scrollBar = _G[scrollFrame:GetName()..'ScrollBar']
|
||||
scrollBar:ClearAllPoints()
|
||||
scrollBar:SetPoint('BOTTOMRIGHT', rt, -4, 4)
|
||||
scrollBar:SetPoint('TOPRIGHT', rt, -4, -HEAD_HEIGHT)
|
||||
@@ -1041,8 +1041,8 @@ function public.CreateAuctionResultsTable(parent, config)
|
||||
thumbTex:SetTexture(color.content.background())
|
||||
thumbTex:SetHeight(150)
|
||||
thumbTex:SetWidth(scrollBar:GetWidth())
|
||||
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
|
||||
-- create the header cells
|
||||
rt.headCells = {}
|
||||
|
||||
+14
-14
@@ -15,7 +15,7 @@ function LOAD()
|
||||
blizzard_backdrop = DropDownList1Backdrop:GetBackdrop()
|
||||
hook('ToggleDropDownMenu', function(...) temp=arg
|
||||
local ret = {orig.ToggleDropDownMenu(unpack(arg)) }
|
||||
local dropdown = _g[arg[4] or ''] or this:GetParent()
|
||||
local dropdown = _G[arg[4] or ''] or this:GetParent()
|
||||
if strfind(dropdown:GetName() or '', '^aux_frame%d+$') then
|
||||
set_aux_dropdown_style(dropdown)
|
||||
else
|
||||
@@ -33,20 +33,20 @@ function LOAD()
|
||||
DropDownList1:ClearAllPoints()
|
||||
DropDownList1:SetPoint('TOPLEFT', dropdown, 'BOTTOMLEFT', -2, -2)
|
||||
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
||||
local button = _g['DropDownList1Button'..i]
|
||||
local button = _G['DropDownList1Button'..i]
|
||||
button:SetPoint('TOPLEFT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
||||
button:SetPoint('TOPRIGHT', 0, -((button:GetID() - 1) * UIDROPDOWNMENU_BUTTON_HEIGHT) - 7)
|
||||
local text = button:GetFontString()
|
||||
text:SetFont(font, font_size.small2)
|
||||
text:SetPoint('TOPLEFT', 18, 0)
|
||||
text:SetPoint('BOTTOMRIGHT', -8, 0)
|
||||
local highlight = _g['DropDownList1Button'..i..'Highlight']
|
||||
local highlight = _G['DropDownList1Button'..i..'Highlight']
|
||||
highlight:ClearAllPoints()
|
||||
highlight:SetDrawLayer 'OVERLAY'
|
||||
highlight:SetHeight(14)
|
||||
highlight:SetPoint('LEFT', 5, 0)
|
||||
highlight:SetPoint('RIGHT', -3, 0)
|
||||
local check = _g['DropDownList1Button'..i..'Check']
|
||||
local check = _G['DropDownList1Button'..i..'Check']
|
||||
check:SetWidth(16)
|
||||
check:SetHeight(16)
|
||||
check:SetPoint('LEFT', 3, -1)
|
||||
@@ -58,14 +58,14 @@ function LOAD()
|
||||
aux_border:Hide()
|
||||
aux_background:Hide()
|
||||
for i=1,UIDROPDOWNMENU_MAXBUTTONS do
|
||||
local button = _g['DropDownList1Button'..i]
|
||||
local button = _G['DropDownList1Button'..i]
|
||||
local text = button:GetFontString()
|
||||
text:SetFont([[Fonts\FRIZQT__.ttf]], 10)
|
||||
text:SetShadowOffset(1, -1)
|
||||
local highlight = _g['DropDownList1Button'..i..'Highlight']
|
||||
local highlight = _G['DropDownList1Button'..i..'Highlight']
|
||||
highlight:SetAllPoints()
|
||||
highlight:SetDrawLayer 'BACKGROUND'
|
||||
local check = _g['DropDownList1Button'..i..'Check']
|
||||
local check = _G['DropDownList1Button'..i..'Check']
|
||||
check:SetWidth(24)
|
||||
check:SetHeight(24)
|
||||
check:SetPoint('LEFT', 0, 0)
|
||||
@@ -453,13 +453,13 @@ function public.item(parent)
|
||||
btn:SetPoint('LEFT', 2, .5)
|
||||
btn:SetHighlightTexture(nil)
|
||||
btn:RegisterForClicks()
|
||||
item.texture = _g[btn:GetName()..'Icon']
|
||||
item.texture = _G[btn:GetName()..'Icon']
|
||||
item.texture:SetTexCoord(.06, .94, .06, .94)
|
||||
item.name = label(btn, 15)
|
||||
item.name:SetJustifyH 'LEFT'
|
||||
item.name:SetPoint('LEFT', btn, 'RIGHT', 10, 0)
|
||||
item.name:SetPoint('RIGHT', item, 'RIGHT', -10, .5)
|
||||
item.count = _g[btn:GetName()..'Count']
|
||||
item.count = _G[btn:GetName()..'Count']
|
||||
item.count:SetTextHeight(17)
|
||||
return item
|
||||
end
|
||||
@@ -501,17 +501,17 @@ function public.dropdown(parent)
|
||||
local dropdown = CreateFrame('Frame', name, parent, 'UIDropDownMenuTemplate')
|
||||
set_content_style(dropdown, 0, 0, 4, 4)
|
||||
|
||||
_g[dropdown:GetName()..'Left']:Hide()
|
||||
_g[dropdown:GetName()..'Middle']:Hide()
|
||||
_g[dropdown:GetName()..'Right']:Hide()
|
||||
_G[dropdown:GetName()..'Left']:Hide()
|
||||
_G[dropdown:GetName()..'Middle']:Hide()
|
||||
_G[dropdown:GetName()..'Right']:Hide()
|
||||
|
||||
local button = _g[dropdown:GetName()..'Button']
|
||||
local button = _G[dropdown:GetName()..'Button']
|
||||
button:ClearAllPoints()
|
||||
button:SetScale(0.9)
|
||||
button:SetPoint('RIGHT', dropdown, 0, 0)
|
||||
dropdown.button = button
|
||||
|
||||
local text = _g[dropdown:GetName()..'Text']
|
||||
local text = _G[dropdown:GetName()..'Text']
|
||||
text:ClearAllPoints()
|
||||
text:SetPoint('RIGHT', button, 'LEFT', -2, 0)
|
||||
text:SetPoint('LEFT', 8, 0)
|
||||
|
||||
@@ -48,15 +48,15 @@ function public.create(parent, on_click, selected)
|
||||
scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15)
|
||||
scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15)
|
||||
|
||||
local scrollBar = _g[scroll_frame:GetName()..'ScrollBar']
|
||||
local scrollBar = _G[scroll_frame:GetName()..'ScrollBar']
|
||||
scrollBar:SetWidth(12)
|
||||
local thumbTex = scrollBar:GetThumbTexture()
|
||||
thumbTex:SetPoint('CENTER', 0, 0)
|
||||
thumbTex:SetTexture(color.content.background())
|
||||
thumbTex:SetHeight(50)
|
||||
thumbTex:SetWidth(12)
|
||||
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
|
||||
local rows = t
|
||||
local row_index = 1
|
||||
|
||||
+3
-3
@@ -424,7 +424,7 @@ function public.CreateScrollingTable(parent)
|
||||
scrollFrame:SetAllPoints(contentFrame)
|
||||
st.scrollFrame = scrollFrame
|
||||
|
||||
local scrollBar = _g[scrollFrame:GetName()..'ScrollBar']
|
||||
local scrollBar = _G[scrollFrame:GetName()..'ScrollBar']
|
||||
scrollBar:SetWidth(12)
|
||||
st.scrollBar = scrollBar
|
||||
local thumbTex = scrollBar:GetThumbTexture()
|
||||
@@ -432,8 +432,8 @@ function public.CreateScrollingTable(parent)
|
||||
thumbTex:SetTexture(color.content.background())
|
||||
thumbTex:SetHeight(50)
|
||||
thumbTex:SetWidth(12)
|
||||
_g[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_g[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollUpButton']:Hide()
|
||||
_G[scrollBar:GetName()..'ScrollDownButton']:Hide()
|
||||
|
||||
-- create head line at default position
|
||||
st.headLine = gui.horizontal_line(st, 0)
|
||||
|
||||
Reference in New Issue
Block a user