color refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-09 07:16:06 +02:00
parent d4bdd3b1d0
commit 03a4970301
5 changed files with 45 additions and 36 deletions
+28 -19
View File
@@ -3,18 +3,27 @@ local m, public, private = aux.module'auction_listing'
local RT_COUNT = 1
local HEAD_HEIGHT = 27
local HEAD_SPACE = 2
public.COLORS = {
BLUE = '|cff2992ff',
GREEN = '|cff16ff16',
YELLOW = '|cffffff00',
ORANGE = '|cffff9218',
RED = '|cffff0000',
}
local AUCTION_PCT_COLORS = {
{color='|cff2992ff', value=50}, -- blue
{color='|cff16ff16', value=80}, -- green
{color='|cffffff00', value=110}, -- yellow
{color='|cffff9218', value=135}, -- orange
{color='|cffff0000', value=aux.huge}, -- red
{color=m.COLORS.BLUE, value=50},
{color=m.COLORS.GREEN, value=80},
{color=m.COLORS.YELLOW, value=110},
{color=m.COLORS.ORANGE, value=135},
{color=m.COLORS.RED, value=aux.huge},
}
local TIME_LEFT_STRINGS = {
'|cffff000030m|r', -- Short
'|cffff92182h|r', -- Medium
'|cffffff008h|r', -- Long
'|cff2992ff24h|r', -- Very Long
m.COLORS.RED..'30m'..FONT_COLOR_CODE_CLOSE, -- Short
m.COLORS.ORANGE..'2h'..FONT_COLOR_CODE_CLOSE, -- Medium
m.COLORS.YELLOW..'8h'..FONT_COLOR_CODE_CLOSE, -- Long
m.COLORS.BLUE..'24h'..FONT_COLOR_CODE_CLOSE, -- Very Long
}
function private.item_column_init(rt, cell)
@@ -74,7 +83,7 @@ public.search_config = {
align = 'CENTER',
set = function(cell, record)
local display_level = max(record.level, 1)
display_level = UnitLevel('player') < record.level and RED_FONT_COLOR_CODE..display_level..FONT_COLOR_CODE_CLOSE or display_level
display_level = UnitLevel('player') < record.level and m.COLORS.RED..display_level..FONT_COLOR_CODE_CLOSE or display_level
cell:SetText(display_level)
end,
cmp = function(record_a, record_b, desc)
@@ -88,7 +97,7 @@ public.search_config = {
set = function(cell, record, count, own, expandable)
local numAuctionsText = expandable and aux.gui.inline_color.link..count..FONT_COLOR_CODE_CLOSE or count
if own > 0 then
numAuctionsText = numAuctionsText..(' |cffffff00('..own..')|r')
numAuctionsText = numAuctionsText..(' '..m.COLORS.YELLOW..'('..own..')'..FONT_COLOR_CODE_CLOSE)
end
cell:SetText(numAuctionsText)
end,
@@ -132,7 +141,7 @@ public.search_config = {
width = 0.13,
align = 'CENTER',
set = function(cell, record)
cell:SetText(aux.is_player(record.owner) and ('|cffffff00'..record.owner..FONT_COLOR_CODE_CLOSE) or (record.owner or '---'))
cell:SetText(aux.is_player(record.owner) and (m.COLORS.YELLOW..record.owner..FONT_COLOR_CODE_CLOSE) or (record.owner or '---'))
end,
cmp = function(record_a, record_b, desc)
if not record_a.owner and not record_b.owner then
@@ -154,9 +163,9 @@ public.search_config = {
set = function(cell, record)
local color
if record.high_bidder then
color = '|cff16ff16'
color = AUCTION_PCT_COLORS[2].color
elseif record.high_bid ~= 0 then
color = '|cffff9218'
color = AUCTION_PCT_COLORS[4].color
end
local price
if record.high_bidder then
@@ -244,7 +253,7 @@ public.auctions_config = {
align = 'CENTER',
set = function(cell, record)
local display_level = max(record.level, 1)
display_level = UnitLevel('player') < record.level and RED_FONT_COLOR_CODE..display_level..FONT_COLOR_CODE_CLOSE or display_level
display_level = UnitLevel('player') < record.level and m.COLORS.RED..display_level..FONT_COLOR_CODE_CLOSE or display_level
cell:SetText(display_level)
end,
cmp = function(record_a, record_b, desc)
@@ -347,7 +356,7 @@ public.auctions_config = {
width = 0.21,
align = 'CENTER',
set = function(cell, record)
cell:SetText(record.high_bidder or RED_FONT_COLOR_CODE..'No Bids'..FONT_COLOR_CODE_CLOSE)
cell:SetText(record.high_bidder or m.COLORS.RED..'No Bids'..FONT_COLOR_CODE_CLOSE)
end,
cmp = function(record_a, record_b, desc)
if not record_a.high_bidder and not record_b.high_bidder then
@@ -433,7 +442,7 @@ public.bids_config = {
width = 0.13,
align = 'CENTER',
set = function(cell, record)
cell:SetText(aux.is_player(record.owner) and ('|cffffff00'..record.owner..FONT_COLOR_CODE_CLOSE) or (record.owner or '---'))
cell:SetText(aux.is_player(record.owner) and (m.COLORS.YELLOW..record.owner..FONT_COLOR_CODE_CLOSE) or (record.owner or '---'))
end,
cmp = function(record_a, record_b, desc)
if not record_a.owner and not record_b.owner then
@@ -502,9 +511,9 @@ public.bids_config = {
set = function(cell, record)
local status
if record.high_bidder then
status = GREEN_FONT_COLOR_CODE..'High Bidder'..FONT_COLOR_CODE_CLOSE
status = m.COLORS.YELLOW..'High Bidder'..FONT_COLOR_CODE_CLOSE
else
status = RED_FONT_COLOR_CODE..'Outbid'..FONT_COLOR_CODE_CLOSE
status = m.COLORS.RED..'Outbid'..FONT_COLOR_CODE_CLOSE
end
cell:SetText(status)
end,
+8 -8
View File
@@ -122,27 +122,27 @@ function private.update_auction_listing()
local bid_color
if blizzard_bid_undercut < unit_start_price and stack_blizzard_bid_undercut < unit_start_price then
bid_color = '|cffff0000'
bid_color = aux.auction_listing.COLORS.RED
elseif blizzard_bid_undercut < unit_start_price then
bid_color = '|cffff9218'
bid_color = aux.auction_listing.COLORS.ORANGE
elseif stack_blizzard_bid_undercut < unit_start_price then
bid_color = '|cffffff00'
bid_color = aux.auction_listing.COLORS.YELLOW
end
local buyout_color
if buyout_price_undercut < unit_buyout_price and stack_buyout_price_undercut < unit_buyout_price then
buyout_color = '|cffff0000'
buyout_color = aux.auction_listing.COLORS.RED
elseif buyout_price_undercut < unit_buyout_price then
buyout_color = '|cffff9218'
buyout_color = aux.auction_listing.COLORS.ORANGE
elseif stack_buyout_price_undercut < unit_buyout_price then
buyout_color = '|cffffff00'
buyout_color = aux.auction_listing.COLORS.YELLOW
end
tinsert(auction_rows, {
cols = {
{ value=auction_record.own and GREEN_FONT_COLOR_CODE..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
{ value=auction_record.own and aux.auction_listing.COLORS.GREEN..auction_record.count..FONT_COLOR_CODE_CLOSE or auction_record.count },
{ value=aux.auction_listing.time_left(auction_record.duration) },
{ value=auction_record.stack_size == stack_size and GREEN_FONT_COLOR_CODE..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
{ value=auction_record.stack_size == stack_size and aux.auction_listing.COLORS.GREEN..auction_record.stack_size..FONT_COLOR_CODE_CLOSE or auction_record.stack_size },
{ value=aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
{ value=historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---' },
{ value=auction_record.unit_buyout_price > 0 and aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---' },
+1 -1
View File
@@ -225,7 +225,7 @@ function private.create_frames()
btn:SetPoint('RIGHT', m.start_button, 'LEFT', -4, 0)
btn:SetWidth(70)
btn:SetHeight(25)
btn:SetText(GREEN_FONT_COLOR_CODE..'Resume'..FONT_COLOR_CODE_CLOSE)
btn:SetText(aux.auction_listing.COLORS.GREEN..'Resume'..FONT_COLOR_CODE_CLOSE)
btn:SetScript('OnClick', function()
m.execute(true)
end)
+7 -7
View File
@@ -547,12 +547,12 @@ function public.indented_post_query_string(components)
end
no_line_break = component[1] == 'operator' and component[2] == 'not'
if component[1] == 'operator' and component[2] then
str = str..'|cffffff00'..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE
str = str..aux.auction_listing.COLORS.YELLOW..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE
tinsert(stack, component[3] or '*')
elseif component[1] == 'filter' then
str = str..'|cffffff00'..component[2]..FONT_COLOR_CODE_CLOSE
str = str..aux.auction_listing.COLORS.YELLOW..component[2]..FONT_COLOR_CODE_CLOSE
if component[3] then
str = str..': '..'|cffff9218'..component[3]..FONT_COLOR_CODE_CLOSE
str = str..': '..aux.auction_listing.COLORS.ORANGE..component[3]..FONT_COLOR_CODE_CLOSE
end
while getn(stack) > 0 and stack[getn(stack)] ~= '*' do
local top = tremove(stack)
@@ -582,7 +582,7 @@ function private.prettified_query_string(components)
if blizzard_filters.name and not blizzard_filters.exact then
if m.unquote(blizzard_filters.name) == '' then
prettified.prepend(RED_FONT_COLOR_CODE..'No Filter'..FONT_COLOR_CODE_CLOSE)
prettified.prepend(aux.auction_listing.COLORS.RED..'No Filter'..FONT_COLOR_CODE_CLOSE)
else
prettified.prepend(aux.gui.inline_color.label.enabled..m.unquote(blizzard_filters.name)..FONT_COLOR_CODE_CLOSE)
end
@@ -590,13 +590,13 @@ function private.prettified_query_string(components)
for _, component in components.post do
if component[1] == 'operator' then
prettified.append('|cffffff00'..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE)
prettified.append(aux.auction_listing.COLORS.YELLOW..component[2]..(component[2] ~= 'not' and tonumber(component[3]) or '')..FONT_COLOR_CODE_CLOSE)
elseif component[1] == 'filter' then
if component[2] ~= 'tooltip' then
prettified.append('|cffffff00'..component[2]..FONT_COLOR_CODE_CLOSE)
prettified.append(aux.auction_listing.COLORS.YELLOW..component[2]..FONT_COLOR_CODE_CLOSE)
end
if component[3] then
prettified.append('|cffff9218'..component[3]..FONT_COLOR_CODE_CLOSE)
prettified.append(aux.auction_listing.COLORS.ORANGE..component[3]..FONT_COLOR_CODE_CLOSE)
end
end
end
+1 -1
View File
@@ -77,7 +77,7 @@ function public.from_string(value)
end
-- remove any colors
value = gsub(gsub(strlower(value), '|c%x%x%x%x%x%x%x%x', ''), '|r', '')
value = gsub(gsub(strlower(value), '|c%x%x%x%x%x%x%x%x', ''), FONT_COLOR_CODE_CLOSE, '')
-- extract gold/silver/copper values
local gold = tonumber(({strfind(value, '(%d*%.?%d+)g')})[3])