diff --git a/README.md b/README.md index eb3f392..469470c 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,8 @@ The `/tranq check` command allows you to list version or TranqRotate used by oth Here is a list of feature I want to implement at some point, no specific order is decided yet. -- Automatic handling of death and disconnection of hunters on the rotation group (swap with a backup, send an alert about it) -- Use raid symbols to mark hunters that need to tranq, or that need to backup a failed tranqshot - Automatic reset of rotation when raid wipe -- Adds raid markers to tranq announces if target has one +- Customization of the tranq window, size, textures, colors, fonts... ## Download diff --git a/TranqRotate.toc b/TranqRotate.toc index 4fb4613..a48dabf 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -1,8 +1,8 @@ ## Interface: 11307 -## Title: TranqRotate |cff00aa001.7.0|r +## Title: TranqRotate |cff00aa001.8.0|r ## Notes: A tranqshot rotation assistant ## Author: Slivo -## Version: 1.7.0 +## Version: 1.8.0 ## SavedVariables: TranqRotateDb ## OptionalDeps: Ace3 @@ -36,3 +36,4 @@ src\settings.lua src\utils.lua src\debuff.lua src\migration.lua +src\raidIcons.lua diff --git a/changelog.md b/changelog.md index 14bb4de..adf728e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ ## TranqRotate Changelog +#### v1.8.0 + +- Adds different announces messages for boss and trash (Boss announces can call next player, trash announces can call target) +- Adds raid marker symbol to chat tranq announces +- Adds "available update" chat notifications +- Removes server suffix from hunter names on era connected realms + #### v1.7.0 - Adds an icon on hunter not using the addon (You can disable it in the settings) diff --git a/locales/enUS.lua b/locales/enUS.lua index 0e93418..2ab2422 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -68,12 +68,14 @@ local L = { ---- Messages ["ANNOUNCES_MESSAGE_HEADER"] = "Announce messages", - ["SUCCESS_MESSAGE_LABEL"] = "Successful announce message", + ["BOSS_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on boss (%s will be replaced by next hunter name)", + ["TRASH_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on trash (%s will be replaced by target name)", ["FAIL_MESSAGE_LABEL"] = "Fail announce message", ["FAIL_WHISPER_LABEL"] = "Fail whisper message", ["UNABLE_TO_TRANQ_MESSAGE_LABEL"] = "Message whispered when you cannot tranq or call for backup", - ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", + ['DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done, %s is next!", + ['DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TRANQSHOT FAILED ON %s !!!", ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TRANQSHOT MISSED ! TRANQ NOW !", ['DEFAULT_UNABLE_TO_TRANQ_MESSAGE'] = "I'M UNABLE TO TRANQ ! TRANQ NOW !", @@ -103,6 +105,10 @@ local L = { ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0", ["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)", + + --- Available update + ["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features", + ["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.", } TranqRotate.L = L diff --git a/locales/frFR.lua b/locales/frFR.lua index 14290c2..5cb04ad 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -70,12 +70,14 @@ local L = { ---- Messages ["ANNOUNCES_MESSAGE_HEADER"] = "Annonces de tir tranquilisant", - ["SUCCESS_MESSAGE_LABEL"] = "Message de réussite", + ["BOSS_SUCCESS_MESSAGE_LABEL"] = "Message de réussite sur boss (%s est le nom du prochain chasseur)", + ["TRASH_SUCCESS_MESSAGE_LABEL"] = "Message de réussite sur trash (%s est le nom de la cible)", ["FAIL_MESSAGE_LABEL"] = "Message d'échec", ["FAIL_WHISPER_LABEL"] = "Message d'échec chuchoté", ["UNABLE_TO_TRANQ_MESSAGE_LABEL"] = "Message chuchoté quand vous ne pouvez pas tranq ou que vous demandez un backup", - ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait sur %s", + ['DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait, %s est le suivant!", + ['DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE'] = "Tir tranquillisant fait sur %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! TIR TRANQUILLISANT RATE SUR %s !!!", ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "TIR TRANQUILISANT RATE ! TRANQ MAINTENANT !", ['DEFAULT_UNABLE_TO_TRANQ_MESSAGE'] = "JE NE PEUX PAS TRANQ ! TRANQ MAINTENANT !", @@ -105,6 +107,10 @@ local L = { ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Ce joueur n'utilise pas TranqRotate", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Ou possède une version obsolète inférieure à 1.6.0", ["TOOLTIP_DISABLE_SETTINGS"] = "(Il est possible de désactiver l'icone et/ou l'infobulle dans les options)", + + --- Available update + ["UPDATE_AVAILABLE"] = "Une nouvelle version est disponible, faites la mise à jour pour profiter des derniers ajouts", + ["BREAKING_UPDATE_AVAILABLE"] = "Une nouvelle version MAJEURE est disponible, vous DEVEZ faire la mise à jour le plus rapidement possible! Votre version pourrait ne pas fonctionner correctement avec celle des utilisateurs disposant de la mise à jour.", } TranqRotate.L = L diff --git a/locales/ruRU.lua b/locales/ruRU.lua index e838c48..9d7b33e 100644 --- a/locales/ruRU.lua +++ b/locales/ruRU.lua @@ -70,12 +70,14 @@ local L = { ---- Messages ["ANNOUNCES_MESSAGE_HEADER"] = "Сообщения оповещений", - ["SUCCESS_MESSAGE_LABEL"] = "При успехе сообщить", + ["BOSS_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on boss (%s will be replaced by next hunter name)", + ["TRASH_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on trash (%s will be replaced by target name)", ["FAIL_MESSAGE_LABEL"] = "При промахе сообщить", ["FAIL_WHISPER_LABEL"] = "При промахе шепнуть запасным", ["UNABLE_TO_TRANQ_MESSAGE_LABEL"] = "Сообщение шепота, когда вы не можете произвести усирение или оповестить запасных", - ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "Усмиряющий выстрел в %s", + ['DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done, %s is next!", + ['DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! Усмиряющий выстрел промахнулся в %s !!!", ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "!!! Усмиряющий выстрел промахнулся !!! ! УСМИРЯЙ СЕЙЧАС !", ['DEFAULT_UNABLE_TO_TRANQ_MESSAGE'] = "Я НЕ МОГУ УСМИРИТЬ ! УСМИРЯЙ СЕЙЧАС !", @@ -105,6 +107,10 @@ local L = { ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Этот игрок не использует TranqRotate", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Или используется версия ниже 1.6.0", ["TOOLTIP_DISABLE_SETTINGS"] = "(Вы можете отключить этот значок и/или эту подсказку в настройках)", + + --- Available update + ["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features", + ["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.", } TranqRotate.L = L diff --git a/locales/zhCN.lua b/locales/zhCN.lua index bcf5361..95c19de 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -70,12 +70,14 @@ local L = { ---- Messages ["ANNOUNCES_MESSAGE_HEADER"] = "通告信息", - ["SUCCESS_MESSAGE_LABEL"] = "施放成功通告信息", + ["BOSS_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on boss (%s will be replaced by next hunter name)", + ["TRASH_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on trash (%s will be replaced by target name)", ["FAIL_MESSAGE_LABEL"] = "施放失败通告信息", ["FAIL_WHISPER_LABEL"] = "施放失败私聊信息", ["UNABLE_TO_TRANQ_MESSAGE_LABEL"] = "当你无法宁神或呼叫替补时,这条信息就会低声传来", - ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已对 %s 施放了宁神射击!", + ['DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done, %s is next!", + ['DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 对 %s 宁神失败!!!", ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "宁神失败 !! 赶紧补宁神!!", ['DEFAULT_UNABLE_TO_TRANQ_MESSAGE'] = "我无法宁神射击 ! 请现在宁神 !", @@ -105,6 +107,10 @@ local L = { ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "此玩家没有使用TranqRotate插件", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "或者运行低于1.6.0的过时版本", ["TOOLTIP_DISABLE_SETTINGS"] = "(您可以在设置中禁用此图标或此工具提示)", + + --- Available update + ["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features", + ["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.", } TranqRotate.L = L diff --git a/locales/zhTW.lua b/locales/zhTW.lua index c37b83e..973b902 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -70,12 +70,14 @@ local L = { ---- Messages ["ANNOUNCES_MESSAGE_HEADER"] = "通告資訊", - ["SUCCESS_MESSAGE_LABEL"] = "施放成功通告資訊", + ["BOSS_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on boss (%s will be replaced by next hunter name)", + ["TRASH_SUCCESS_MESSAGE_LABEL"] = "Successful announce message on trash (%s will be replaced by target name)", ["FAIL_MESSAGE_LABEL"] = "施放失敗通告資訊", ["FAIL_WHISPER_LABEL"] = "施放失敗私聊資訊", ["UNABLE_TO_TRANQ_MESSAGE_LABEL"] = "Message whispered when you cannot tranq or call for backup", - ['DEFAULT_SUCCESS_ANNOUNCE_MESSAGE'] = "已對 %s 施放了寧神射擊!", + ['DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done, %s is next!", + ['DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE'] = "Tranqshot done on %s", ['DEFAULT_FAIL_ANNOUNCE_MESSAGE'] = "!!! 對 %s 寧神失敗!!!", ['DEFAULT_FAIL_WHISPER_MESSAGE'] = "寧神失敗 !! 趕緊補寧神!!", ['DEFAULT_UNABLE_TO_TRANQ_MESSAGE'] = "I'M UNABLE TO TRANQ ! TRANQ NOW !", @@ -105,6 +107,10 @@ local L = { ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "This player does not use TranqRotate", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Or runs an outdated version below 1.6.0", ["TOOLTIP_DISABLE_SETTINGS"] = "(You can disable this icon and/or this tooltip in the settings)", + + --- Available update + ["UPDATE_AVAILABLE"] = "A new TranqRotate version is available, update to get latest features", + ["BREAKING_UPDATE_AVAILABLE"] = "A new BREAKING TranqRotate update is available, you MUST update AS SOON AS possible! TranqRotate may not work properly with up-to-date version users.", } TranqRotate.L = L diff --git a/src/comms.lua b/src/comms.lua index 562f55c..a311db3 100644 --- a/src/comms.lua +++ b/src/comms.lua @@ -148,7 +148,6 @@ end function TranqRotate:receiveSyncOrder(prefix, message, channel, sender) TranqRotate:updateRaidStatus() - TranqRotate:updatePlayerAddonVersion(sender, message.addonVersion) if (TranqRotate:isVersionEligible(message.version, sender)) then TranqRotate.syncVersion = (message.version) @@ -158,6 +157,8 @@ function TranqRotate:receiveSyncOrder(prefix, message, channel, sender) TranqRotate:printPrefixedMessage('Received new rotation configuration from ' .. sender) TranqRotate:applyRotationConfiguration(message.rotation) end + + TranqRotate:updatePlayerAddonVersion(sender, message.addonVersion) end -- Request to send current roration configuration received diff --git a/src/defaults.lua b/src/defaults.lua index 559ce6c..d69010d 100644 --- a/src/defaults.lua +++ b/src/defaults.lua @@ -7,7 +7,8 @@ function TranqRotate:LoadDefaults() channelType = "YELL", rotationReportChannelType = "RAID", useMultilineRotationReport = false, - announceSuccessMessage = L["DEFAULT_SUCCESS_ANNOUNCE_MESSAGE"], + announceBossSuccessMessage = L["DEFAULT_BOSS_SUCCESS_ANNOUNCE_MESSAGE"], + announceTrashSuccessMessage = L["DEFAULT_TRASH_SUCCESS_ANNOUNCE_MESSAGE"], announceFailMessage = L["DEFAULT_FAIL_ANNOUNCE_MESSAGE"], whisperFailMessage = L["DEFAULT_FAIL_WHISPER_MESSAGE"], unableToTranqMessage = L["DEFAULT_UNABLE_TO_TRANQ_MESSAGE"], diff --git a/src/events.lua b/src/events.lua index 91495ca..764a4e9 100644 --- a/src/events.lua +++ b/src/events.lua @@ -37,19 +37,25 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() local spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand = select(12, CombatLogGetCurrentEventInfo()) if (spellName == tranqShot or (TranqRotate.testMode and spellName == arcaneShot)) then - local hunter = TranqRotate:getHunter(nil, sourceGUID) + local hunter = TranqRotate:getHunter(sourceGUID) if (hunter) then if (event == "SPELL_CAST_SUCCESS") then TranqRotate:sendSyncTranq(hunter, false, timestamp) TranqRotate:rotate(hunter) if (sourceGUID == UnitGUID("player")) then - TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceSuccessMessage, destName) + TranqRotate:sendAnnounceMessage( + TranqRotate:getTranqSuccessMessage( + TranqRotate:isTranqableBoss(destGUID), + destName, + destRaidFlags + ) + ) end elseif (event == "SPELL_MISSED" or event == "SPELL_DISPEL_FAILED") then TranqRotate:sendSyncTranq(hunter, true, timestamp, event) TranqRotate:handleFailTranq(hunter, event) if (sourceGUID == UnitGUID("player")) then - TranqRotate:sendAnnounceMessage(TranqRotate.db.profile.announceFailMessage, destName) + TranqRotate:sendAnnounceMessage(TranqRotate:getTranqFailMessage(destName, destRaidFlags)) end end end diff --git a/src/frames.lua b/src/frames.lua index d6e2ee3..5ecae4c 100644 --- a/src/frames.lua +++ b/src/frames.lua @@ -153,7 +153,7 @@ function TranqRotate:createHunterFrame(hunter, parentFrame) hunter.frame.text = hunter.frame:CreateFontString(nil, "ARTWORK") hunter.frame.text:SetFont(TranqRotate:getPlayerNameFont(), 12) hunter.frame.text:SetPoint("LEFT",5,0) - hunter.frame.text:SetText(hunter.name) + hunter.frame.text:SetText(strsplit("-", hunter.name)) TranqRotate:createCooldownFrame(hunter) TranqRotate:createBlindIconFrame(hunter) diff --git a/src/migration.lua b/src/migration.lua index e78114c..d097d6f 100644 --- a/src/migration.lua +++ b/src/migration.lua @@ -20,4 +20,9 @@ TranqRotate.migrations = { TranqRotate.db.profile.enableTimedBackupAlertValue = nil TranqRotate.db.profile.timedBackupAlertValueDelay = nil end, + -- 1.8.0 + function() + -- This is an old key + TranqRotate.db.profile.announceSuccessMessage = nil + end, } diff --git a/src/raidIcons.lua b/src/raidIcons.lua new file mode 100644 index 0000000..170fde7 --- /dev/null +++ b/src/raidIcons.lua @@ -0,0 +1,21 @@ +TranqRotate.chatIconString = "{rt%d}" + +TranqRotate.raidIconMaskToIndex = { + [COMBATLOG_OBJECT_RAIDTARGET1] = 1, + [COMBATLOG_OBJECT_RAIDTARGET2] = 2, + [COMBATLOG_OBJECT_RAIDTARGET3] = 3, + [COMBATLOG_OBJECT_RAIDTARGET4] = 4, + [COMBATLOG_OBJECT_RAIDTARGET5] = 5, + [COMBATLOG_OBJECT_RAIDTARGET6] = 6, + [COMBATLOG_OBJECT_RAIDTARGET7] = 7, + [COMBATLOG_OBJECT_RAIDTARGET8] = 8, +} + +function TranqRotate:getRaidTargetIcon(flags) + local raidIconMask = bit.band(flags, COMBATLOG_OBJECT_RAIDTARGET_MASK) + if (TranqRotate.raidIconMaskToIndex[raidIconMask]) then + return string.format(TranqRotate.chatIconString, TranqRotate.raidIconMaskToIndex[raidIconMask]) + end + + return "" +end diff --git a/src/rotation.lua b/src/rotation.lua index 88ef101..37e7972 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -145,7 +145,7 @@ function TranqRotate:isPlayerNextTranq() return false end - local player = TranqRotate:getHunter(nil, UnitGUID("player")) + local player = TranqRotate:getHunter(UnitGUID("player")) if (not player.nextTranq) then @@ -250,10 +250,10 @@ function TranqRotate:testRotation() end -- Return our hunter object from name or GUID -function TranqRotate:getHunter(name, GUID) +function TranqRotate:getHunter(searchTerm) - for key,hunter in pairs(TranqRotate.hunterTable) do - if ((GUID ~= nil and hunter.GUID == GUID) or (name ~= nil and hunter.name == name)) then + for _, hunter in pairs(TranqRotate.hunterTable) do + if (searchTerm ~= nil and (hunter.GUID == searchTerm or hunter.name == searchTerm)) then return hunter end end @@ -293,7 +293,7 @@ function TranqRotate:updateRaidStatus() -- Players name might be nil at loading if (name ~= nil) then if(TranqRotate:isHunter(name)) then - local hunter = TranqRotate:getHunter(nil, UnitGUID(name)) + local hunter = TranqRotate:getHunter(UnitGUID(name)) if (hunter == nil and not InCombatLockdown()) then hunter = TranqRotate:registerHunter(name) @@ -447,8 +447,8 @@ function TranqRotate:applyRotationConfiguration(rotationsTables) group = 'BACKUP' end - for index, hunterName in pairs(rotationTable) do - local hunter = TranqRotate:getHunter(hunterName) + for index, GUID in pairs(rotationTable) do + local hunter = TranqRotate:getHunter(GUID) if (hunter) then TranqRotate:moveHunter(hunter, group, index) end @@ -523,3 +523,32 @@ function TranqRotate:getHighlightedHunter() return nil end + +function TranqRotate:getTranqSuccessMessage(isBossTranq, targetName, raidIconFlags) + + local message = "" + if (isBossTranq) then + message = TranqRotate.db.profile.announceBossSuccessMessage + local hunter = TranqRotate:getHighlightedHunter() + message = string.format(message, hunter.name) + else + message = TranqRotate.db.profile.announceTrashSuccessMessage + message = string.format( + message, + TranqRotate:getRaidTargetIcon(raidIconFlags) .. targetName + ) + end + + return message +end + +function TranqRotate:getTranqFailMessage(targetName, raidIconFlags) + + local message = TranqRotate.db.profile.announceFailMessage + message = string.format( + message, + TranqRotate:getRaidTargetIcon(raidIconFlags) .. targetName + ) + + return message +end diff --git a/src/settings.lua b/src/settings.lua index 814ba1b..9a4dbc1 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -214,28 +214,34 @@ function TranqRotate:CreateConfig() width = "normal", order = 22, }, - announceSuccessMessage = { - name = L["SUCCESS_MESSAGE_LABEL"], + announceBossSuccessMessage = { + name = L["BOSS_SUCCESS_MESSAGE_LABEL"], type = "input", order = 23, width = "double", }, + announceTrashSuccessMessage = { + name = L["TRASH_SUCCESS_MESSAGE_LABEL"], + type = "input", + order = 24, + width = "double", + }, announceFailMessage = { name = L["FAIL_MESSAGE_LABEL"], type = "input", - order = 24, + order = 25, width = "double", }, whisperFailMessage = { name = L["FAIL_WHISPER_LABEL"], type = "input", - order = 25, + order = 26, width = "double", }, unableToTranqMessage = { name = L["UNABLE_TO_TRANQ_MESSAGE_LABEL"], type = "input", - order = 26, + order = 27, width = "double", }, setupBroadcastHeader = { diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index 8ba40d7..d8bdbcd 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -69,22 +69,19 @@ function TranqRotate:printPrefixedMessage(msg) end -- Send a tranq announce message to a given channel -function TranqRotate:sendAnnounceMessage(message, targetName) - - -- Prints instead to avoid lua error in open world with say and yell - if ( - not IsInInstance() and ( - TranqRotate.db.profile.channelType == "SAY" or TranqRotate.db.profile.channelType == "YELL" - ) - ) then - TranqRotate:printPrefixedMessage(string.format(message, targetName) .. " " .. L["YELL_SAY_DISABLED_OPEN_WORLD"]) - return - end - +function TranqRotate:sendAnnounceMessage(chatMessage) if TranqRotate.db.profile.enableAnnounces then + -- Prints instead to avoid lua error in open world with say and yell + if ( + not IsInInstance() and + (TranqRotate.db.profile.channelType == "SAY" or TranqRotate.db.profile.channelType == "YELL") + ) then + TranqRotate:printPrefixedMessage(chatMessage .. " " .. L["YELL_SAY_DISABLED_OPEN_WORLD"]) + return + end + TranqRotate:sendMessage( - message, - targetName, + chatMessage, TranqRotate.db.profile.channelType, TranqRotate.db.profile.targetChannel ) @@ -93,23 +90,20 @@ end -- Send a rotation broadcast message function TranqRotate:sendRotationSetupBroadcastMessage(message) - if TranqRotate.db.profile.enableAnnounces then - TranqRotate:sendMessage( - message, - nil, - TranqRotate.db.profile.rotationReportChannelType, - TranqRotate.db.profile.setupBroadcastTargetChannel - ) - end + TranqRotate:sendMessage( + message, + TranqRotate.db.profile.rotationReportChannelType, + TranqRotate.db.profile.setupBroadcastTargetChannel + ) end -- Send a message to a given channel -function TranqRotate:sendMessage(message, targetName, channelType, targetChannel) +function TranqRotate:sendMessage(message, channelType, targetChannel) local channelNumber if channelType == "CHANNEL" then channelNumber = GetChannelName(targetChannel) end - SendChatMessage(string.format(message, targetName), channelType, nil, channelNumber or targetChannel) + SendChatMessage(message, channelType, nil, channelNumber or targetChannel) end SLASH_TRANQROTATE1 = "/tranq" @@ -248,6 +242,11 @@ function TranqRotate:updatePlayerAddonVersion(player, version) if (hunter) then TranqRotate:updateBlindIcon(hunter) end + + local updateRequired, breakingUpdate = TranqRotate:isUpdateRequired(version) + if (updateRequired) then + TranqRotate:notifyUserAboutAvailableUpdate(breakingUpdate) + end end -- Prints to the chat the addon version of every hunter and addon users @@ -310,3 +309,57 @@ function TranqRotate:runDemo() 5 ) end + +-- Parse version string +-- @return major, minor, fix, isStable +function TranqRotate:parseVersionString(versionString) + + local version, type = strsplit("-", versionString) + local major, minor, fix = strsplit( ".", version) + + return tonumber(major), tonumber(minor), tonumber(fix), type == nil +end + +-- Check if the given version would require updating +-- @return requireUpdate, breakingUpdate +function TranqRotate:isUpdateRequired(versionString) + + local remoteMajor, remoteMinor, remoteFix, isRemoteStable = self:parseVersionString(versionString) + local localMajor, localMinor, localFix, isLocalStable = self:parseVersionString(TranqRotate.version) + + if (isRemoteStable) then + + if (remoteMajor > localMajor) then + return true, true + elseif (remoteMajor < localMajor) then + return false, false + end + + if (remoteMinor > localMinor) then + return true, false + elseif (remoteMinor < localMinor) then + return false, false + end + + if (remoteFix > localFix) then + return true, false + end + end + + return false, false +end + +-- Notify user about a new version available +function TranqRotate:notifyUserAboutAvailableUpdate(isBreakingUpdate) + if (isBreakingUpdate) then + if (TranqRotate.notifiedBreakingUpdate ~= true) then + TranqRotate:printPrefixedMessage('|cffff3d3d' .. L['BREAKING_UPDATE_AVAILABLE'] .. '|r') + TranqRotate.notifiedBreakingUpdate = true + end + else + if (TranqRotate.notifiedUpdate ~= true and TranqRotate.notifiedBreakingUpdate ~= true) then + TranqRotate:printPrefixedMessage(L['UPDATE_AVAILABLE']) + TranqRotate.notifiedUpdate = true + end + end +end \ No newline at end of file