slash refactoring, usage printout

This commit is contained in:
Manuel Simon Hirsig
2016-12-11 11:10:59 +01:00
parent 49591f7fb0
commit 3f563ead76
5 changed files with 56 additions and 42 deletions
+31 -31
View File
@@ -10,7 +10,7 @@ local history = require 'aux.core.history'
local gui = require 'aux.gui'
local search_tab = require 'aux.tabs.search'
_G.aux_price_per_unit = false
local price_per_unit = false
local HEAD_HEIGHT = 27
local HEAD_SPACE = 2
@@ -174,24 +174,24 @@ M.search_config = {
end
local price
if record.high_bidder then
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell.text:SetText(money.to_string(price, true, false, nil, price_color))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = 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 = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
if record_a.high_bidder and not record_b.high_bidder then
return sort_util.GT
@@ -214,12 +214,12 @@ M.search_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
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
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = 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)
@@ -316,24 +316,24 @@ M.auctions_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
price = price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price
end
cell.text: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 = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price
price_a = 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 = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
price_b = price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price
end
return sort_util.compare(price_a, price_b, desc)
end,
@@ -344,12 +344,12 @@ M.auctions_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
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
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = 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)
@@ -457,24 +457,24 @@ M.bids_config = {
fill = function(cell, record)
local price
if record.high_bidder then
price = aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
price = price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid
else
price = aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price
price = price_per_unit and ceil(record.unit_bid_price) or record.bid_price
end
cell.text:SetText(money.to_string(price))
end,
cmp = function(record_a, record_b, desc)
local price_a
if record_a.high_bidder then
price_a = aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
price_a = price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid
else
price_a = aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price
price_a = 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 = aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
price_b = price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid
else
price_b = aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price
price_b = price_per_unit and record_b.unit_bid_price or record_b.bid_price
end
return sort_util.compare(price_a, price_b, desc)
end,
@@ -485,12 +485,12 @@ M.bids_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local price = aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
local price = price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price
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
local price_b = aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price
local price_a = price_per_unit and record_a.unit_buyout_price or record_a.buyout_price
local price_b = 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)
@@ -563,10 +563,10 @@ local methods = {
local rt = this.rt
if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then
_G.aux_price_per_unit = not aux_price_per_unit
price_per_unit = not price_per_unit
for _, cell in rt.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[price_per_unit and 1 or 2])
end
end
rt:SetSort()
@@ -920,7 +920,7 @@ function M.new(parent, rows, config)
rt:SetScript('OnShow', function()
for _, cell in this.headCells do
if cell.info.isPrice then
cell:SetText(cell.info.title[aux_price_per_unit and 1 or 2])
cell:SetText(cell.info.title[price_per_unit and 1 or 2])
end
end
end)