added price labels to the craft/tradeskill frames, changed some colors

This commit is contained in:
Manuel Simon Hirsig
2016-03-19 15:09:57 +01:00
parent 4eb4538a3f
commit 99ee2dac6c
4 changed files with 107 additions and 42 deletions
+62 -1
View File
@@ -74,9 +74,70 @@ function Aux.on_event()
end
function Aux.on_addon_loaded()
if string.lower(arg1) == 'blizzard_auctionui' then
if arg1 == 'Blizzard_AuctionUI' then
Aux.setup_hooks()
end
do
local function cost_label(cost)
local label = LIGHTYELLOW_FONT_COLOR_CODE..'(Total cost: '..FONT_COLOR_CODE_CLOSE
label = label..(cost and Aux.util.format_money(cost, nil, LIGHTYELLOW_FONT_COLOR_CODE) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE)
label = label..LIGHTYELLOW_FONT_COLOR_CODE..')'..FONT_COLOR_CODE_CLOSE
return label
end
if arg1 == 'Blizzard_CraftUI' then
Aux.hook('CraftFrame_SetSelection', function(...)
local results = {Aux.orig.CraftFrame_SetSelection(unpack(arg)) }
local id = GetCraftSelectionIndex()
local reagent_count = GetCraftNumReagents(id)
local total_cost = 0
for i=1,reagent_count do
local item_id, suffix_id = Aux.info.parse_hyperlink(GetCraftReagentItemLink(id, i))
local count = ({GetCraftReagentInfo(id, i)})[3]
local value = Aux.history.value(item_id..':'..suffix_id)
if not value then
total_cost = nil
break
else
total_cost = total_cost + value * count
end
end
CraftReagentLabel:SetText(SPELL_REAGENTS..' '..cost_label(total_cost))
return unpack(results)
end)
end
if arg1 == 'Blizzard_TradeSkillUI' then
Aux.hook('TradeSkillFrame_SetSelection', function(...)
local results = {Aux.orig.TradeSkillFrame_SetSelection(unpack(arg)) }
local id = GetTradeSkillSelectionIndex()
local reagent_count = GetTradeSkillNumReagents(id)
local total_cost = 0
for i=1,reagent_count do
local item_id, suffix_id = Aux.info.parse_hyperlink(GetTradeSkillReagentItemLink(id, i))
local count = ({GetTradeSkillReagentInfo(id, i)})[3]
local value = Aux.history.value(item_id..':'..suffix_id)
if not value then
total_cost = nil
break
else
total_cost = total_cost + value * count
end
end
TradeSkillReagentLabel:SetText(SPELL_REAGENTS..' '..cost_label(total_cost))
return unpack(results)
end)
end
end
end
do
+1 -1
View File
@@ -63,7 +63,7 @@ function private.update_search_listings()
local recent_search_rows = {}
for i, recent_search in ipairs(aux_recent_searches) do
local name = recent_search.name or recent_search.prettified
local name = recent_search.name and LIGHTYELLOW_FONT_COLOR_CODE..recent_search.name..FONT_COLOR_CODE_CLOSE or recent_search.prettified
tinsert(recent_search_rows, {
cols = {{value=name}},
search = recent_search,
+6 -40
View File
@@ -29,42 +29,6 @@ function public.on_load()
end
end
function private.format_money(money, exact)
local TEXT_NONE = '0'
local GSC_GOLD = 'ffd100'
local GSC_SILVER = 'e6e6e6'
local GSC_COPPER = 'c8602c'
local GSC_START = '|cff%s%d|r'
local GSC_PART = '.|cff%s%02d|r'
local GSC_NONE = '|cffa0a0a0'..TEXT_NONE..'|r'
if not exact and money >= 10000 then
-- Round to nearest silver
money = math.floor(money / 100 + 0.5) * 100
end
local g, s, c = Aux.money.to_GSC(money)
local gsc = ''
local fmt = GSC_START
if g > 0 then
gsc = gsc..string.format(fmt, GSC_GOLD, g)
fmt = GSC_PART
end
if s > 0 or c > 0 then
gsc = gsc..string.format(fmt, GSC_SILVER, s)
fmt = GSC_PART
end
if c > 0 then
gsc = gsc..string.format(fmt, GSC_COPPER, c)
end
if gsc == '' then
gsc = GSC_NONE
end
return gsc
end
function private.extend_tooltip(tooltip, hyperlink, quantity)
local item_id, suffix_id = Aux.info.parse_hyperlink(hyperlink)
@@ -78,17 +42,19 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
local value_line = 'Value: '
value_line = value_line..(value and private.format_money(value) or '---')
value_line = value_line..(value and Aux.util.format_money(value) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(value_line, 0.1, 0.8, 0.5)
local color = {r=1.0, g=1.0, b=0.6}
tooltip:AddLine(value_line, color.r, color.g, color.b)
if aux_tooltip_daily then
local market_value = Aux.history.market_value(item_key)
local market_value_line = 'Today: '
market_value_line = market_value_line..(market_value and private.format_money(market_value)..' ('..Aux.auction_listing.percentage_historical(Aux.round(market_value / value * 100))..')' or '---')
market_value_line = market_value_line..(market_value and Aux.util.format_money(market_value)..' ('..Aux.auction_listing.percentage_historical(Aux.round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(market_value_line, 0.1, 0.8, 0.5)
tooltip:AddLine(market_value_line, color.r, color.g, color.b)
end
tooltip:Show()
+38
View File
@@ -320,4 +320,42 @@ function public.split(str, separator)
return array
end
end
end
function public.format_money(money, exact, color)
color = color or '|r'
local TEXT_NONE = '0'
local GSC_GOLD = 'ffd100'
local GSC_SILVER = 'e6e6e6'
local GSC_COPPER = 'c8602c'
local GSC_START = '|cff%s%d|r'
local GSC_PART = color..'.|cff%s%02d|r'
local GSC_NONE = '|cffa0a0a0'..TEXT_NONE..'|r'
if not exact and money >= 10000 then
-- Round to nearest silver
money = math.floor(money / 100 + 0.5) * 100
end
local g, s, c = Aux.money.to_GSC(money)
local gsc = ''
local fmt = GSC_START
if g > 0 then
gsc = gsc..string.format(fmt, GSC_GOLD, g)
fmt = GSC_PART
end
if s > 0 or c > 0 then
gsc = gsc..string.format(fmt, GSC_SILVER, s)
fmt = GSC_PART
end
if c > 0 then
gsc = gsc..string.format(fmt, GSC_COPPER, c)
end
if gsc == '' then
gsc = GSC_NONE
end
return gsc
end