diff --git a/AnnounceReset.lua b/AnnounceReset.lua new file mode 100644 index 0000000..4e37154 --- /dev/null +++ b/AnnounceReset.lua @@ -0,0 +1,50 @@ +local addonName, addon = ... +local GroupieAnnounceReset = addon:NewModule("GroupieAnnounceReset", "AceEvent-3.0") + +local locale = GetLocale() +if not addon.tableContains(addon.validLocales, locale) then + return +end +local L = LibStub('AceLocale-3.0'):GetLocale('Groupie') + + +local failedreset = "There are players still inside the instance." --This is actually a success, the message is a lie +local successreset = "has been reset." +local function AnnounceInstanceReset(_, msg, ...) + if addon.db.global.announceInstanceReset then + if strmatch(msg, successreset) then + if (UnitIsGroupLeader("player")) then + if (IsInRaid()) then + SendChatMessage(addon.instanceResetString, "RAID") + elseif (IsInGroup()) then + SendChatMessage(addon.instanceResetString, "PARTY") + end + end + elseif strmatch(msg, failedreset) then + local playersStillInside = " Any players still inside will need to exit and then re-enter." + if (UnitIsGroupLeader("player")) then + if (IsInRaid()) then + SendChatMessage(addon.instanceResetString .. playersStillInside, "RAID") + elseif (IsInGroup()) then + SendChatMessage(addon.instanceResetString .. playersStillInside, "PARTY") + end + end + end + end +end + +--filter the incorrect 'failed reset' message +function addon.resetChatFilter(self, event, msg, author, ...) + if strmatch(msg, failedreset) then + return true + end +end + +function GroupieAnnounceReset:OnEnable() + self:RegisterEvent("CHAT_MSG_SYSTEM", function(...) + AnnounceInstanceReset(...) + end) + if addon.db.global.announceInstanceReset then + ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", addon.resetChatFilter) + end +end diff --git a/Core.lua b/Core.lua index dae5195..4d3949b 100644 --- a/Core.lua +++ b/Core.lua @@ -1947,6 +1947,7 @@ function addon:OnInitialize() talentTooltips = true, gearSummaryTooltips = true, charSheetGear = true, + announceInstanceReset = true, } } @@ -2762,18 +2763,33 @@ function addon.SetupConfig() end end, }, - spacerdesc4 = { type = "description", name = " ", width = "full", order = 11 }, + announceResetToggle = { + type = "toggle", + name = "Announce Instance Reset in Party/Raid Chat", + order = 11, + width = "full", + get = function(info) return addon.db.global.announceInstanceReset end, + set = function(info, val) + addon.db.global.announceInstanceReset = val + if addon.db.global.announceInstanceReset then + ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", addon.resetChatFilter) + else + ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", addon.resetChatFilter) + end + end, + }, + spacerdesc4 = { type = "description", name = " ", width = "full", order = 12 }, header2 = { type = "description", name = "|cff" .. addon.groupieSystemColor .. L["GlobalOptions"].LFGData, - order = 12, + order = 13, fontSize = "medium" }, preserveDurationDropdown = { type = "select", style = "dropdown", name = "", - order = 13, + order = 14, width = 1.4, values = { [1] = L["GlobalOptions"].DurationDropdown["1"], [2] = L["GlobalOptions"].DurationDropdown["2"], @@ -2783,11 +2799,11 @@ function addon.SetupConfig() set = function(info, val) addon.db.global.minsToPreserve = val end, get = function(info) return addon.db.global.minsToPreserve end, }, - spacerdesc5 = { type = "description", name = " ", width = "full", order = 14 }, + spacerdesc5 = { type = "description", name = " ", width = "full", order = 15 }, header3 = { type = "description", name = "|cff" .. addon.groupieSystemColor .. L["GlobalOptions"].UIScale, - order = 15, + order = 16, fontSize = "medium" }, scaleSlider = { @@ -2796,7 +2812,7 @@ function addon.SetupConfig() min = 0.5, max = 2.0, step = 0.1, - order = 16, + order = 17, set = function(info, val) addon.db.global.UIScale = val GroupieFrame:SetScale(val) diff --git a/Globals.lua b/Globals.lua index 2244f6e..1cec27f 100644 --- a/Globals.lua +++ b/Globals.lua @@ -27,6 +27,7 @@ addon.askForPlayerInfo = format("{rt3} %s : What Role are you?", addonName) addon.askForInstance = format("{rt3} %s : What are you inviting me to?", addonName) addon.autoRejectRequestString = "FYI, I have Auto-Reject enabled. Message me back and if it's a good fit I'll send you an invite. Thanks!" addon.autoRejectInviteString = "FYI, I have Auto-Reject enabled. Message me back and if it's a good fit I'll come. Thanks!" +addon.instanceResetString = format("{rt3} %s : All Instances Have Been Reset!", addonName) addon.PROTECTED_TOKENS = { [1] = "%s*{rt3}%s*groupie%s*:", [2] = "%s*groupie%s*{rt3}%s*:", diff --git a/Groupie.toc b/Groupie.toc index 8ef7ed0..a591c88 100644 --- a/Groupie.toc +++ b/Groupie.toc @@ -19,4 +19,5 @@ Core.lua GroupBrowser.lua RightClick.lua Listener.lua -AutoResponse.lua \ No newline at end of file +AutoResponse.lua +AnnounceReset.lua \ No newline at end of file