[FEATURE REQUEST] prettified chat messages
BelegCufea opened this issue ยท 4 comments
Hi.
Very nice addon you have here :-)
I would like to have option to print reputation gains in chat. And in nicer way with more info than standard WoW.
(BTW I am not a lua programmer neither a native English speaker so I am sorry for any mistakes in either)
I have put some crude code that suits my needs (but I recon, you can print same info as is in broker text/broker tooltip) . I reused GetBarMainRepInfo
with parameter (GetRepInfo(factionId)
) but it can be easily changed to suit both calls (the one in UpdateBar
-> GetRepInfo(barFaction)
) if u choose to implement it. I have put it in CHAT_MSG_COMBAT_FACTION_CHANGE
as I want to see multiple gains if there are any instead of just the header one (and UpdateBar
does not have actual rep gain, just session one as far as I understand it).
function f:CHAT_MSG_COMBAT_FACTION_CHANGE(msg)
...
local switch = not neg and config.autoSwitch and (faction ~= GUILD or not config.exceptGuild)
if faction == GUILD then faction = GetGuildInfo"player" end
-- START
local function GetRepInfo(factionId)
local name, standingId, bottomValue, topValue, barValue, atWarWith, _
if (factionId and factionId ~= 0) then
name, _, standingId, bottomValue, topValue, barValue, atWarWith = GetFactionInfoByID(factionId)
else
name, standingId, bottomValue, topValue, barValue, factionId = GetWatchedFactionInfo()
if (factionId) then
atWarWith = select(7, GetFactionInfoByID(factionId))
end
end
return {
name = name,
standingId = standingId,
bottomValue = bottomValue,
topValue = topValue,
barValue = barValue,
factionId = factionId,
atWarWith = atWarWith
}
end
local factionId = factionIdtable[faction]
local info = GetRepInfo(factionId)
if info and info.name then
local repColors = config.blizzColorsInsteadBroker and config.blizzardColors or config.asciiColors
local currentValue, max, color, standingText, hasRewardPending, balance, texture = GetFactionValues(
info.standingId, info.barValue, info.bottomValue, info.topValue, info.factionId, repColors
)
local standingColor = ("|cff%.2x%.2x%.2x"):format(color.r*255, color.g*255, color.b*255)
local percent = currentValue * 100 / max
if (max == 0) then
percent = 100
end
local bar = "||||||||||||||||||||||||||||||||||||||||";
local GREY_COLOR = '|cff666666';
local GREEN_COLOR = '|cff00ff00';
local CYAN_COLOR = '|cff00ffff';
local percentBar = math.floor(percent / 5); -- for 20 "||" to avoid split escape string
local percentBarText = GREEN_COLOR .. string.sub(bar, 0, percentBar * 2) .. GREY_COLOR .. string.sub(bar, percentBar * 2 + 1);
print(("|cffbbbbff%s|r (%s%s|r): %s%d (%.1f%%) " .. CYAN_COLOR .. "[%s" .. CYAN_COLOR .. "]"):format(
faction,
standingColor,
standingText,
neg and "-" or "+",
value,
percent,
percentBarText
))
end
-- END
barFactionHidden = false
local scannedFactions = false
...
end
I have not played with it much, so there may be some edge cases (paragon, max rep ...), but it seems to work just fine for now.
Thank you for your great work.
What precisely are you trying to get it to look like? Can you provide a screen shot?
Not saying it's not something that can't be accomplished but putting a lot of code in that function may cause performance issues if it fires multiple times on several rep gains at once.
Are you trying to just display it for you, or like spam it to chat for everyone to see?
The code I provided above just use ordinary lua print
function so it's just for the player (like standard Exp messages from Blizz are).
If you want to see it in action you can try it by posting the code from --START
to --END
into Ara_Broker_Reputations.lua
(as I am not sure how to include image, sorry).
As for the performance issues I didn't observed any (yet). I don't know if it can be optimized (as I just copied part of your code a reused it for something it was clearly not designed to do).
I thought it can be toggled on/off, so if someone don't want to see it or there are any performance hits, it can be disabled.
But if you don't want to have such functionality in your addon (for whatever reason as it is outside of scope of 'broker'), it is perfectly fine. I still love your addon.
Have a nice day and thanks for your reply.
Apologies, but at the moment, I'm not inclined to add this unless there are more people that are looking for it. You're of course free to update the code on your end.
Essentially, I'm concerned about it adding in lag to the process by firing this code every time rep increases.