From 0ca3d51dbef367ae79774bfa5d498c20f6596f7e Mon Sep 17 00:00:00 2001 From: oskar3123 Date: Wed, 12 Aug 2020 06:10:02 +0200 Subject: [PATCH] Updated to 8.3 and added Smart Message Mode to fix API change to SendChatMessage in 8.2.5 --- Core.lua | 22 ++++++++++++++++++++-- LevelUpAnnouncer.toc | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Core.lua b/Core.lua index f12e7c3..ae38718 100644 --- a/Core.lua +++ b/Core.lua @@ -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 diff --git a/LevelUpAnnouncer.toc b/LevelUpAnnouncer.toc index 3e2616a..b16d5bc 100644 --- a/LevelUpAnnouncer.toc +++ b/LevelUpAnnouncer.toc @@ -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: