Updated to 8.3 and added Smart Message Mode to fix API change to SendChatMessage in 8.2.5

This commit is contained in:
Oskar Nordling 2020-08-12 06:10:02 +02:00
parent bea1277dcd
commit 0ca3d51dbe
2 changed files with 22 additions and 4 deletions

View File

@ -9,6 +9,7 @@ local defaults = {
chatAnnounce = true,
chatPercAnnounce = false,
reversePerc = false,
replaceWithEmote = true,
dingFormat = "DING! LEVEL {LEVEL}!",
percFormat = "{PERCENTAGE}% INTO LEVEL {LEVEL}!",
reversePercFormat = "{PERCENTAGE}% UNTIL LEVEL {NEXTLEVEL}!",
@ -60,6 +61,14 @@ local options = {
type = "toggle",
set = function(_, value) LevelUpAnnouncer.db.profile.reversePerc = value end,
get = function() return LevelUpAnnouncer.db.profile.reversePerc end
},
replaceWithEmote = {
order = 5,
name = "Smart Message Mode",
desc = "Replace \"Message Mode\" with EMOTE if using SAY or YELL when not in an instance",
type = "toggle",
set = function(_, value) LevelUpAnnouncer.db.profile.replaceWithEmote = value end,
get = function() return LevelUpAnnouncer.db.profile.replaceWithEmote end
}
}
},
@ -118,7 +127,7 @@ local options = {
messageMode = {
order = 2,
name = "Message Mode",
desc = "Modes:\nSAY\nYELL\nPARTY\nINSTANCE_CHAT\nRAID\nRAID_WARNING\nGUILD\nOFFICER\nEMOTE\nCHANNEL.X (So for channel 1 type: \"CHANNEL.1\")",
desc = "Modes:\nSAY (Only works in instances)\nYELL(Only works in instances)\nPARTY\nINSTANCE_CHAT\nRAID\nRAID_WARNING\nGUILD\nOFFICER\nEMOTE\nCHANNEL.X (So for channel 1 type: \"CHANNEL.1\", only works in instances)",
type = "input",
set = function(_, value) LevelUpAnnouncer.db.profile.messageModeString = value end,
get = function() return LevelUpAnnouncer.db.profile.messageModeString end
@ -153,7 +162,16 @@ local sendToChat = function(message)
local t = split(str, ".")
local channel
if #t > 1 then channel = t[2] end
local mode = t[1]
local mode = string.upper(t[1])
local replaceWithEmote = LevelUpAnnouncer.db.profile.replaceWithEmote
-- SendChatMessage is hardware event protected for modes "SAY", "YELL" and "CHANNEL" when player is "outdoors"
if not IsInInstance() and (mode == "SAY" or mode == "YELL" or mode == "CHANNEL") then
if replaceWithEmote and mode ~= "CHANNEL" then
mode = "EMOTE"
else
return
end
end
SendChatMessage(message, mode, nil, channel)
end

View File

@ -1,6 +1,6 @@
## Interface: 80200
## Interface: 80300
## Title: Level Up |cff2D8D0BAnnouncer|r
## Version: 2.0.5
## Version: 2.0.6
## Author: oskar3123
## Notes: A simple addon to play a sound and/or yell in chat when you level up
## Dependencies: