color and module refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-08 03:23:55 +01:00
parent a93fc5d8ec
commit e4cb599969
3 changed files with 27 additions and 26 deletions
+10 -1
View File
@@ -28,6 +28,16 @@ M.color = W-{
content = W-{background = C(42, 42, 42, 1), border = C(0, 0, 0, 0)},
state = W-{enabled = C(70, 140, 70, 1), disabled = C(140, 70, 70, 1)},
tooltip = W-{
value = C(255, 255, 154, 1),
merchant = C(204, 127, 25, 1),
disenchant = W-{
value = C(25, 153, 153, 1),
distribution = C(204, 204, 51, 1),
source = C(178, 178, 178, 1),
}
},
blue = C(41, 146, 255, 1),
green = C(22, 255, 22, 1),
yellow = C(255, 255, 0, 1),
@@ -36,5 +46,4 @@ M.color = W-{
gray = C(187, 187, 187, 1),
blizzard = C(0, 180, 255, 1),
aux = C(255, 255, 154, 1),
}
+13 -21
View File
@@ -10,14 +10,6 @@ local disenchant = require 'aux.core.disenchant'
local history = require 'aux.core.history'
local auction_listing = require 'aux.gui.auction_listing'
local color = {
value = {1, 1, .6},
merchant = {.8, .5, .1},
disenchant_source = {.7, .7, .7},
disenchant_distribution = {.8, .8, .2},
disenchant_value = {.1, .6, .6},
}
_G.aux_tooltip_value = true
local game_tooltip_hooks, game_tooltip_money = T, 0
@@ -62,16 +54,16 @@ function extend_tooltip(tooltip, link, quantity)
local item_id, suffix_id = info.parse_link(link)
quantity = IsShiftKeyDown() and quantity or 1
if aux_tooltip_disenchant_source then
local color = color.disenchant_source
local r, g, b = color.tooltip.disenchant.source()
local type, range = disenchant.source(item_id)
if type == 'CRYSTAL' then
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color[1], color[2], color[3], true)
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), r, g, b, true)
elseif type == 'SHARD' then
tooltip:AddLine(format('Can disenchant from level %s |cff0070ddRare|r and |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
tooltip:AddLine(format('Can disenchant from level %s |cff0070ddRare|r and |cff1eff00Uncommon|r items.', range), r, g, b, true)
elseif type == 'ESSENCE' then
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), r, g, b, true)
elseif type == 'DUST' then
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), color[1], color[2], color[3], true)
tooltip:AddLine(format('Can disenchant from level %s |cff1eff00Uncommon|r items.', range), r, g, b, true)
end
end
local item_info = temp-info.item(item_id)
@@ -79,28 +71,28 @@ function extend_tooltip(tooltip, link, quantity)
local distribution = temp-disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
if getn(distribution) > 0 then
if aux_tooltip_disenchant_distribution then
tooltip:AddLine('Disenchants into:', unpack(color.disenchant_distribution))
tooltip:AddLine('Disenchants into:', color.tooltip.disenchant.distribution())
sort(distribution, function(a,b) return a.probability > b.probability end)
for _, event in distribution do
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), unpack(color.disenchant_distribution))
for _, event in ipairs(distribution) do
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, info.display_name(event.item_id, true) or 'item:' .. event.item_id, event.min_quantity, event.max_quantity), color.tooltip.disenchant.distribution())
end
end
if aux_tooltip_disenchant_value then
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.disenchant_value))
tooltip:AddLine('Disenchant Value: ' .. (disenchant_value and money.to_string2(disenchant_value) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.tooltip.disenchant.value())
end
end
end
if aux_tooltip_vendor_buy then
local _, price, limited = cache.merchant_info(item_id)
if price then
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), unpack(color.merchant))
tooltip:AddLine('Vendor Buy ' .. (limited and '(limited): ' or ': ') .. money.to_string2(price * quantity), color.tooltip.merchant())
end
end
if aux_tooltip_vendor_sell then
local price = cache.merchant_info(item_id)
if price ~= 0 then
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.merchant))
tooltip:AddLine('Vendor Sell: ' .. (price and money.to_string2(price * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.tooltip.merchant())
end
end
local auctionable = not item_info or info.auctionable(temp-info.tooltip('link', item_info.itemstring), item_info.quality)
@@ -108,11 +100,11 @@ function extend_tooltip(tooltip, link, quantity)
local value = history.value(item_key)
if auctionable then
if aux_tooltip_value then
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.value))
tooltip:AddLine('Value: ' .. (value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.tooltip.value())
end
if aux_tooltip_daily then
local market_value = history.market_value(item_key)
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), unpack(color.value))
tooltip:AddLine('Today: ' .. (market_value and money.to_string2(market_value * quantity) .. ' (' .. auction_listing.percentage_historical(round(market_value / value * 100)) .. ')' or GRAY_FONT_COLOR_CODE .. '---' .. FONT_COLOR_CODE_CLOSE), color.tooltip.value())
end
end
+4 -4
View File
@@ -166,11 +166,11 @@ M.search_config = {
align = 'RIGHT',
isPrice = true,
fill = function(cell, record)
local color
local price_color
if record.high_bidder then
color = color.green
price_color = color.green
elseif record.high_bid ~= 0 then
color = color.orange
price_color = color.orange
end
local price
if record.high_bidder then
@@ -178,7 +178,7 @@ M.search_config = {
else
price = 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))
cell:SetText(money.to_string(price, true, false, nil, price_color))
end,
cmp = function(record_a, record_b, desc)
local price_a