The raid icon is correctly recognized if present, but another problem appeared.
Once recognized, the raid icon is added to the destName string which is then processed into a message to be shown in a variety of ways depending on the user settings. The problem is that I can't find a way to insert the raid icon in a manner that works for both
SendChatMessage() and
ChatFrame:AddMessage().
Thus the question is: can raid icons be added in a format that works for both types of messages?
The following way works for
ChatFrame:AddMessage() but results in a LUA error stating
SendChatMessage(): Invalid escape code in chat message
|
LUA Code:
RaidIconMaskToIcon = {
[COMBATLOG_OBJECT_RAIDTARGET1] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET1, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t"),
-- etc
}
While the following way works with
SendChatMessage(), it doesn't work with ChatFrame:AddMessage() (the {rt1} will not be replaced by the actual icon texture).
LUA Code:
RaidIconMaskToIcon = {
[COMBATLOG_OBJECT_RAIDTARGET1] = "{rt1}",
-- etc
}
Relevant code for review:
LUA Code:
local bit_and = bit.band
local RaidIconMaskToIcon = {
[COMBATLOG_OBJECT_RAIDTARGET1] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET1, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET2] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET2, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET3] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET3, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET4] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET4, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET5] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET5, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET6] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET6, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET7] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET7, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7.blp:0|t"),
[COMBATLOG_OBJECT_RAIDTARGET8] = format(TEXT_MODE_A_STRING_DEST_ICON, COMBATLOG_OBJECT_RAIDTARGET8, "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8.blp:0|t")
}
local msgTags = {}
function ezInterrupt:COMBAT_LOG_EVENT_UNFILTERED(_,_,event,sourceGUID,_,sourceFlags,_,destName,destFlags,spellID,_,_,extraID, ...)
if event == "SPELL_INTERRUPT" and bit_and(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) ~= 0 then
local raidIcon = RaidIconMaskToIcon[bit_and(destFlags, COMBATLOG_OBJECT_RAIDTARGET_MASK)]
if raidIcon then destName = string.format("%s%s", raidIcon, destName) end
msgTags["[spell]"] = GetSpellLink(extraID)
msgTags["[target]"] = destName
msgTags["[interrupt]"] = GetSpellLink(spellID)
local msg = string.gsub(self.db.profile.customMessage, "%[%a+%]", msgTags)
if self.db.profile.enableWhispering and self.db.profile.whisperTarget ~= nil then SendChatMessage(msg, "WHISPER", nil, self.db.profile.whisperTarget ) end
if self.db.profile.enableCustomChannel and self.db.profile.customChannel ~= nil then SendChatMessage(msg, "CHANNEL", nil, self.db.profile.customChannel ) end
if self.db.profile.enableSystemMessage then LAST_ACTIVE_CHAT_EDIT_BOX:GetParent():AddMessage(msg) end
if outputChannel then SendChatMessage(msg, outputChannel) end
end
end
For clarity
self.db.profile.customMessage = "Interrupted [target]'s [spell] with [interrupt]"
outputChannel is either "SAY" "PARTY" "RAID" or false