diff --git a/.gitignore b/.gitignore index 3064ddc..3deccff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea libs -copy.sh \ No newline at end of file +copy.sh +package.sh \ No newline at end of file diff --git a/README.md b/README.md index 469470c..456516c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Please report any issue on github : https://github.com/Slivo-fr/TranqRotate/issu - Display the frenzy cooldown of each boss - Optional automatic backup call when incapacitated - Optional automatic timed backup call -- Prints to chat name and reason of a tranq fail (miss or resist) +- Prints to chat the reason of a tranq fail (miss or resist) - Show an indicator on hunters that does not use the addon ## Usage @@ -49,13 +49,12 @@ You can now just pull the boss and start shooting your tranqshots, TranqRotate w **Warning** : if all of your hunters does not use the addon, make sure someone with the addon stay within 45m range of hunters without the addon or you won't be able to register their tranqshot. MC and AQ40 tranq encounters might lead to range issues. However, I didn't had any complain about this yet :) -You can use the reset button in the top bar to reset the rotation state if it do not clear itself. -The reset button is also able to resync raid hunters and rotation setup if you need. +You can use the reset button in the top bar to reset the rotation status You may adds the `/tranq backup` command to a macro that you can use when you are unable to tranq and you need some help, It will whisper all backup hunters the fail message. -The `/tranq check` command allows you to list version or TranqRotate used by others hunters and others non-hunters players +The `/tranq check` command allows you to list TranqRotate versions used by others players ## Roadmap diff --git a/TranqRotate.toc b/TranqRotate.toc index fada350..0e263bc 100644 --- a/TranqRotate.toc +++ b/TranqRotate.toc @@ -1,8 +1,8 @@ ## Interface: 11307 -## Title: TranqRotate |cff00aa002.0.0|r +## Title: TranqRotate |cff00aa002.1.0|r ## Notes: A tranqshot rotation assistant ## Author: Slivo -## Version: 2.0.0 +## Version: 2.1.0 ## SavedVariables: TranqRotateDb ## OptionalDeps: Ace3 diff --git a/changelog.md b/changelog.md index 1ca0a8b..40ab276 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ ## TranqRotate Changelog +#### v2.1.0 + +- Removes server suffixes from player names everywhere (connected realms) +- Adds an option to re-add shortened or full server suffixes to player names (in case of unlikely namesake) +- Adds rotation reset sync +- Removes the ability to re-sync tranq order from the reset button +- Adds highlighted "next" hunter to the tranq rotation sync + #### v2.0.0 - Fix connected realms sync issues - **BREAKING CHANGES** diff --git a/locales/enUS.lua b/locales/enUS.lua index 2ab2422..742ba39 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -21,6 +21,13 @@ local L = { ["WINDOW_LOCKED"] = "TranqRotate: Window locked", ["WINDOW_UNLOCKED"] = "TranqRotate: Window unlocked", + --- Player names formatting options + ["PLAYER_NAME_FORMAT"] = "Player names format", + ["PLAYER_NAME_FORMAT_DESC"] = "On connected realms, players from other servers will have a the server suffix hidden by default. If you ever get two hunter with the exact same name, adjust this setting to your needs", + ["PLAYER_NAME_ONLY_OPTION_LABEL"] = "Playername", + ["SHORTENED_SUFFIX_OPTION_LABEL"] = "Playername-Ser", + ["FULL_NAME_OPTION_LABEL"] = "Playername-Server", + ["TEST_MODE_HEADER"] = "Test mode", ["ENABLE_ARCANE_SHOT_TESTING"] = "Toggle testing mode", ["ENABLE_ARCANE_SHOT_TESTING_DESC"] = @@ -101,14 +108,17 @@ local L = { ["BROADCAST_ROTATION_PREFIX"] = "Rotation", ["BROADCAST_BACKUP_PREFIX"] = "Backup", - --- Blind icon tooltip + -- Blind icon tooltip ["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 + -- 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.", + + -- Rotation reset + ["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation", } TranqRotate.L = L diff --git a/locales/frFR.lua b/locales/frFR.lua index 5cb04ad..fa15c7a 100644 --- a/locales/frFR.lua +++ b/locales/frFR.lua @@ -23,6 +23,13 @@ local L = { ["WINDOW_LOCKED"] = "TranqRotate: Fenêtre verrouillée", ["WINDOW_UNLOCKED"] = "TranqRotate: Fenêtre déverrouillée", + --- Player names formatting options + ["PLAYER_NAME_FORMAT"] = "Format des noms des joueurs", + ["PLAYER_NAME_FORMAT_DESC"] = "Le suffixe serveur des joueurs appartement à d'autre serveurs sont masqué par défaut. Si par malchance deux chasseur ont exactement le même nom, vous pouvez ajuster ce paramètre", + ["PLAYER_NAME_ONLY_OPTION_LABEL"] = "Nomdujoueur", + ["SHORTENED_SUFFIX_OPTION_LABEL"] = "Nomdujoueur-Ser", + ["FULL_NAME_OPTION_LABEL"] = "Nomdujoueur-Serveur", + ["TEST_MODE_HEADER"] = "Test mode", ["ENABLE_ARCANE_SHOT_TESTING"] = "Activer/désactiver le mode test", ["ENABLE_ARCANE_SHOT_TESTING_DESC"] = @@ -103,14 +110,17 @@ local L = { ["BROADCAST_ROTATION_PREFIX"] = "Rotation", ["BROADCAST_BACKUP_PREFIX"] = "Backup", - --- Blind icon tooltip + -- Blind icon tooltip ["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 + -- 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.", + + -- Rotation reset + ["RESET_UNAUTHORIZED"] = "Vous devez être assistant raid pour réinitialiser la rotation", } TranqRotate.L = L diff --git a/locales/ruRU.lua b/locales/ruRU.lua index 9d7b33e..6fb6ac5 100644 --- a/locales/ruRU.lua +++ b/locales/ruRU.lua @@ -23,6 +23,13 @@ local L = { ["WINDOW_LOCKED"] = "TranqRotate: Окно закреплено", ["WINDOW_UNLOCKED"] = "TranqRotate: Окно откреплено", + --- Player names formatting options + ["PLAYER_NAME_FORMAT"] = "Player names format", + ["PLAYER_NAME_FORMAT_DESC"] = "On connected realms, players from other servers will have a the server suffix hidden by default. If you ever get two hunter with the exact same name, adjust this setting to your needs", + ["PLAYER_NAME_ONLY_OPTION_LABEL"] = "Playername", + ["SHORTENED_SUFFIX_OPTION_LABEL"] = "Playername-Ser", + ["FULL_NAME_OPTION_LABEL"] = "Playername-Server", + ["TEST_MODE_HEADER"] = "Тестовый режим", ["ENABLE_ARCANE_SHOT_TESTING"] = "Тестовый режим", ["ENABLE_ARCANE_SHOT_TESTING_DESC"] = @@ -103,14 +110,17 @@ local L = { ["BROADCAST_ROTATION_PREFIX"] = "Очередность", ["BROADCAST_BACKUP_PREFIX"] = "Запасные", - --- Blind icon tooltip + -- Blind icon tooltip ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "Этот игрок не использует TranqRotate", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "Или используется версия ниже 1.6.0", ["TOOLTIP_DISABLE_SETTINGS"] = "(Вы можете отключить этот значок и/или эту подсказку в настройках)", - --- Available update + -- 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.", + + -- Rotation reset + ["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation", } TranqRotate.L = L diff --git a/locales/zhCN.lua b/locales/zhCN.lua index 95c19de..80bf595 100644 --- a/locales/zhCN.lua +++ b/locales/zhCN.lua @@ -23,6 +23,13 @@ local L = { ["WINDOW_LOCKED"] = "TranqRotate: 窗口已隐藏", ["WINDOW_UNLOCKED"] = "TranqRotate: 窗口已锁定", + --- Player names formatting options + ["PLAYER_NAME_FORMAT"] = "Player names format", + ["PLAYER_NAME_FORMAT_DESC"] = "On connected realms, players from other servers will have a the server suffix hidden by default. If you ever get two hunter with the exact same name, adjust this setting to your needs", + ["PLAYER_NAME_ONLY_OPTION_LABEL"] = "Playername", + ["SHORTENED_SUFFIX_OPTION_LABEL"] = "Playername-Ser", + ["FULL_NAME_OPTION_LABEL"] = "Playername-Server", + ["TEST_MODE_HEADER"] = "测试模式", ["ENABLE_ARCANE_SHOT_TESTING"] = "切换测试模式", ["ENABLE_ARCANE_SHOT_TESTING_DESC"] = @@ -103,14 +110,17 @@ local L = { ["BROADCAST_ROTATION_PREFIX"] = "循环", ["BROADCAST_BACKUP_PREFIX"] = "替补", - --- Blind icon tooltip + -- Blind icon tooltip ["TOOLTIP_PLAYER_WITHOUT_ADDON"] = "此玩家没有使用TranqRotate插件", ["TOOLTIP_MAY_RUN_OUDATED_VERSION"] = "或者运行低于1.6.0的过时版本", ["TOOLTIP_DISABLE_SETTINGS"] = "(您可以在设置中禁用此图标或此工具提示)", - --- Available update + -- 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.", + + -- Rotation reset + ["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation", } TranqRotate.L = L diff --git a/locales/zhTW.lua b/locales/zhTW.lua index 973b902..2814ab5 100644 --- a/locales/zhTW.lua +++ b/locales/zhTW.lua @@ -23,6 +23,13 @@ local L = { ["WINDOW_LOCKED"] = "TranqRotate: 窗口已隱藏", ["WINDOW_UNLOCKED"] = "TranqRotate: 窗口已鎖定", + --- Player names formatting options + ["PLAYER_NAME_FORMAT"] = "Player names format", + ["PLAYER_NAME_FORMAT_DESC"] = "On connected realms, players from other servers will have a the server suffix hidden by default. If you ever get two hunter with the exact same name, adjust this setting to your needs", + ["PLAYER_NAME_ONLY_OPTION_LABEL"] = "Playername", + ["SHORTENED_SUFFIX_OPTION_LABEL"] = "Playername-Ser", + ["FULL_NAME_OPTION_LABEL"] = "Playername-Server", + ["TEST_MODE_HEADER"] = "測試模式", ["ENABLE_ARCANE_SHOT_TESTING"] = "切換測試模式", ["ENABLE_ARCANE_SHOT_TESTING_DESC"] = @@ -103,14 +110,17 @@ local L = { ["BROADCAST_ROTATION_PREFIX"] = "循環", ["BROADCAST_BACKUP_PREFIX"] = "替補", - --- Blind icon tooltip + -- Blind icon tooltip ["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 + -- 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.", + + -- Rotation reset + ["RESET_UNAUTHORIZED"] = "You must be raid assist to reset the rotation", } TranqRotate.L = L diff --git a/src/comms.lua b/src/comms.lua index c08b54a..32741c3 100644 --- a/src/comms.lua +++ b/src/comms.lua @@ -26,6 +26,8 @@ function TranqRotate.OnCommReceived(prefix, data, channel, sender) TranqRotate:receiveSyncRequest(prefix, message, channel, sender) elseif (message.type == TranqRotate.constants.commsTypes.backupRequest) then TranqRotate:receiveBackupRequest(prefix, message, channel, sender) + elseif (message.type == TranqRotate.constants.commsTypes.reset) then + TranqRotate:receiveResetRequest(prefix, message, channel, sender) end end end @@ -90,6 +92,11 @@ function TranqRotate:sendSyncOrder(whisper, name) ['addonVersion'] = TranqRotate.version, } + local nextHunter = TranqRotate:getHighlightedHunter() + if (nil ~= nextHunter) then + message.nextHunter = nextHunter.GUID + end + if (whisper) then TranqRotate:sendWhisperAddonMessage(message, name) else @@ -112,7 +119,7 @@ end function TranqRotate:sendBackupRequest(name) -- todo: translation - TranqRotate:printPrefixedMessage('Sending backup request to ' .. name) + TranqRotate:printPrefixedMessage('Sending backup request to ' .. TranqRotate:formatPlayerName(name)) local message = { ['type'] = TranqRotate.constants.commsTypes.backupRequest, @@ -121,6 +128,16 @@ function TranqRotate:sendBackupRequest(name) TranqRotate:sendWhisperAddonMessage(message, name) end +-- Broadcast a reset of the rotation to other players +function TranqRotate:sendResetBroadcast() + + local message = { + ['type'] = TranqRotate.constants.commsTypes.reset, + } + + TranqRotate:sendRaidAddonMessage(message) +end + ----------------------------------------------------------------------------------------------------------------------- -- INPUT ----------------------------------------------------------------------------------------------------------------------- @@ -154,8 +171,13 @@ function TranqRotate:receiveSyncOrder(prefix, message, channel, sender) TranqRotate.syncLastSender = sender -- todo : translation - TranqRotate:printPrefixedMessage('Received new rotation configuration from ' .. sender) + TranqRotate:printPrefixedMessage('Received new rotation configuration from ' .. TranqRotate:formatPlayerName(sender)) TranqRotate:applyRotationConfiguration(message.rotation) + + local nextHunter = TranqRotate:getHunter(message.nextHunter) + if (nil ~= nextHunter) then + TranqRotate:setNextTranq(nextHunter) + end end TranqRotate:updatePlayerAddonVersion(sender, message.addonVersion) @@ -170,6 +192,20 @@ end -- Received a backup request function TranqRotate:receiveBackupRequest(prefix, message, channel, sender) -- todo: translations - TranqRotate:printPrefixedMessage(sender .. ' asked for backup !') + TranqRotate:printPrefixedMessage(TranqRotate:formatPlayerName(sender) .. ' asked for backup !') TranqRotate:throwTranqAlert() end + +-- Received a rotation reset request +function TranqRotate:receiveResetRequest(prefix, message, channel, sender) + + if (not TranqRotate:isUnitAllowedToManageRotation(sender)) then + return + end + + if (TranqRotate.lastRotationReset < GetTime() - 2) then + -- todo: translations + TranqRotate:printPrefixedMessage(TranqRotate:formatPlayerName(sender) .. ' has reset the rotation.') + TranqRotate:resetRotation() + end +end diff --git a/src/constants.lua b/src/constants.lua index ef603c9..573d230 100644 --- a/src/constants.lua +++ b/src/constants.lua @@ -23,6 +23,7 @@ TranqRotate.constants = { ['syncOrder'] = 'sync-order', ['syncRequest'] = 'sync-request', ['backupRequest'] = 'backup-request', + ['reset'] = 'reset', }, ['printPrefix'] = 'TranqRotate - ', @@ -79,4 +80,10 @@ TranqRotate.constants = { 23311, -- Chromaggus Time lapse 29685, -- Gluth fear }, + + ["playerNameFormats"] = { + ["SHORT"] = "SHORT", + ["PLAYER_NAME_ONLY"] = "PLAYER_NAME", + ["FULL_NAME"] = "FULL_NAME", + } } diff --git a/src/defaults.lua b/src/defaults.lua index d69010d..fa33674 100644 --- a/src/defaults.lua +++ b/src/defaults.lua @@ -26,6 +26,7 @@ function TranqRotate:LoadDefaults() timedBackupAlertDelay = 3, showIconOnHunterWithoutTranqRotate = true, showBlindIconTooltip = true, + playerNameFormatting = TranqRotate.constants.playerNameFormats.PLAYER_NAME_ONLY, }, } end diff --git a/src/dragdrop.lua b/src/dragdrop.lua index 4f9a19e..128ff52 100644 --- a/src/dragdrop.lua +++ b/src/dragdrop.lua @@ -185,5 +185,5 @@ end -- Update drag and drop status to match player status function TranqRotate:updateDragAndDrop() - TranqRotate:toggleListSorting(TranqRotate:isPlayerAllowedToSortHunterList()) + TranqRotate:toggleListSorting(TranqRotate:isPlayerAllowedToManageRotation()) end diff --git a/src/events.lua b/src/events.lua index 764a4e9..21bb0da 100644 --- a/src/events.lua +++ b/src/events.lua @@ -76,7 +76,10 @@ function TranqRotate:COMBAT_LOG_EVENT_UNFILTERED() elseif (event == "SPELL_AURA_REMOVED" and TranqRotate:isBossFrenzy(spellName, sourceGUID)) then TranqRotate.frenzy = false elseif (event == "UNIT_DIED" and TranqRotate:isTranqableBoss(destGUID)) then - TranqRotate:resetRotation() + if (TranqRotate:isPlayerAllowedToManageRotation()) then + TranqRotate:resetRotation() + TranqRotate:sendResetBroadcast() + end TranqRotate.mainFrame.frenzyFrame:Hide() end end diff --git a/src/frames.lua b/src/frames.lua index 5ecae4c..138a652 100644 --- a/src/frames.lua +++ b/src/frames.lua @@ -59,11 +59,7 @@ function TranqRotate:createButtons() }, { ['texture'] = 'Interface/Buttons/UI-RefreshButton', - ['callback'] = function() - TranqRotate:updateRaidStatus() - TranqRotate:resetRotation() - TranqRotate:sendSyncOrderRequest() - end + ['callback'] = TranqRotate.handleResetButton }, { ['texture'] = 'Interface/Buttons/UI-GuildButton-MOTD-Up', @@ -153,13 +149,13 @@ 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(strsplit("-", hunter.name)) + hunter.frame.text:SetText(TranqRotate:formatPlayerName(hunter.name)) TranqRotate:createCooldownFrame(hunter) TranqRotate:createBlindIconFrame(hunter) TranqRotate:configureHunterFrameDrag(hunter) - TranqRotate:toggleHunterFrameDragging(hunter, TranqRotate:isPlayerAllowedToSortHunterList()) + TranqRotate:toggleHunterFrameDragging(hunter, TranqRotate:isPlayerAllowedToManageRotation()) end -- Create the cooldown frame diff --git a/src/gui.lua b/src/gui.lua index 622eba5..87a987b 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -67,6 +67,7 @@ function TranqRotate:drawList(hunterList, parentFrame) TranqRotate:createHunterFrame(hunter, parentFrame) else hunter.frame:SetParent(parentFrame) + hunter.frame.text:SetText(TranqRotate:formatPlayerName(hunter.name)) end hunter.frame:ClearAllPoints() diff --git a/src/rotation.lua b/src/rotation.lua index 52907fd..9cb73bc 100644 --- a/src/rotation.lua +++ b/src/rotation.lua @@ -224,6 +224,9 @@ end -- Init/Reset rotation status, next tranq is the first hunter on the list function TranqRotate:resetRotation() + + TranqRotate.lastRotationReset = GetTime() + for key, hunter in pairs(TranqRotate.rotationTables.rotation) do hunter.nextTranq = false TranqRotate:refreshHunterFrame(hunter) @@ -252,8 +255,12 @@ end -- Return our hunter object from name or GUID function TranqRotate:getHunter(searchTerm) + if (searchTerm == nil) then + return nil + end + for _, hunter in pairs(TranqRotate.hunterTable) do - if (searchTerm ~= nil and (hunter.GUID == searchTerm or hunter.name == searchTerm)) then + if (hunter.GUID == searchTerm or hunter.name == searchTerm) then return hunter end end @@ -528,7 +535,7 @@ function TranqRotate:getTranqSuccessMessage(isBossTranq, targetName, raidIconFla if (isBossTranq) then message = TranqRotate.db.profile.announceBossSuccessMessage local hunter = TranqRotate:getHighlightedHunter() - message = string.format(message, hunter.name) + message = string.format(message, TranqRotate:formatPlayerName(hunter.name)) else message = TranqRotate.db.profile.announceTrashSuccessMessage message = string.format( @@ -550,3 +557,13 @@ function TranqRotate:getTranqFailMessage(targetName, raidIconFlags) return message end + +function TranqRotate:handleResetButton() + TranqRotate:updateRaidStatus() + if (TranqRotate:isPlayerAllowedToManageRotation()) then + TranqRotate:resetRotation() + TranqRotate:sendResetBroadcast() + else + TranqRotate:printPrefixedMessage(L["RESET_UNAUTHORIZED"]) + end +end diff --git a/src/settings.lua b/src/settings.lua index 9a4dbc1..cba232e 100644 --- a/src/settings.lua +++ b/src/settings.lua @@ -88,6 +88,18 @@ function TranqRotate:CreateConfig() order = 9, width = "full", }, + playerNameFormatting = { + name = L["PLAYER_NAME_FORMAT"], + desc = L["PLAYER_NAME_FORMAT_DESC"], + type = "select", + order = 12, + values = { + [TranqRotate.constants.playerNameFormats.PLAYER_NAME_ONLY] = L["PLAYER_NAME_ONLY_OPTION_LABEL"], + [TranqRotate.constants.playerNameFormats.SHORT] = L["SHORTENED_SUFFIX_OPTION_LABEL"], + [TranqRotate.constants.playerNameFormats.FULL_NAME] = L["FULL_NAME_OPTION_LABEL"], + }, + set = function(info, value) set(info,value) TranqRotate:drawHunterFrames() end + }, testHeader = { name = L["TEST_MODE_HEADER"], type = "header", diff --git a/src/tranqRotate.lua b/src/tranqRotate.lua index d8bdbcd..d375b8a 100644 --- a/src/tranqRotate.lua +++ b/src/tranqRotate.lua @@ -24,6 +24,7 @@ function TranqRotate:init() TranqRotate.raidInitialized = false TranqRotate.testMode = false TranqRotate.frenzy = false + TranqRotate.lastRotationReset = 0 TranqRotate:initGui() TranqRotate:updateRaidStatus() @@ -192,7 +193,7 @@ function TranqRotate:buildGroupMessage(prefix, rotationTable) local hunters = {} for key, hunt in pairs(rotationTable) do - table.insert(hunters, hunt.name) + table.insert(hunters, TranqRotate:formatPlayerName(hunt.name)) end return prefix .. table.concat(hunters, ', ') @@ -256,7 +257,7 @@ function TranqRotate:checkVersions() for player, version in pairs(TranqRotate.addonVersions) do if (player ~= UnitName("player")) then - TranqRotate:printPrefixedMessage(player .. " - " .. TranqRotate:formatAddonVersion(version)) + TranqRotate:printPrefixedMessage(TranqRotate:formatPlayerName(player) .. " - " .. TranqRotate:formatAddonVersion(version)) end end end @@ -283,13 +284,15 @@ end -- @todo translations -- Prints in the chat the reason a tranqshot has failed function TranqRotate:printFail(hunter, event) + + local name = TranqRotate:formatPlayerName(hunter.name) if (event == "SPELL_MISSED") then - TranqRotate:printPrefixedMessage(hunter.name .. " missed his tranqshot!") + TranqRotate:printPrefixedMessage(name .. " missed his tranqshot!") elseif(event == "SPELL_DISPEL_FAILED") then - TranqRotate:printPrefixedMessage(hunter.name .. "'s tranqshot was resisted!") + TranqRotate:printPrefixedMessage(name .. "'s tranqshot was resisted!") else -- v1.5.1 and older do not send the event type - TranqRotate:printPrefixedMessage(hunter.name .. "'s tranqshot was missed or resisted!") + TranqRotate:printPrefixedMessage(name .. "'s tranqshot was missed or resisted!") end end diff --git a/src/utils.lua b/src/utils.lua index dd6053c..267aec2 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -136,8 +136,30 @@ function TranqRotate:isPlayerRaidAssist(name) return false end --- Checks if condition to enable drag and drop are met -function TranqRotate:isPlayerAllowedToSortHunterList() +-- Checks if player is allowed to manage rotation +function TranqRotate:isPlayerAllowedToManageRotation() local playerName = UnitName("player") - return TranqRotate:isHunter(playerName) or TranqRotate:isPlayerRaidAssist(playerName) + return TranqRotate:isUnitAllowedToManageRotation(playerName) +end + +-- Checks if unit is allowed to manage rotation +function TranqRotate:isUnitAllowedToManageRotation(unitName) + return TranqRotate:isHunter(unitName) or TranqRotate:isPlayerRaidAssist(unitName) +end + +-- Format the player name and server suffix +function TranqRotate:formatPlayerName(fullName) + + local displayName = fullName + + if (TranqRotate.constants.playerNameFormats.SHORT == TranqRotate.db.profile.playerNameFormatting) then + local dashIndex = strfind(fullName, "-") + if (nil ~= dashIndex) then + displayName = strsub(fullName, 1, dashIndex + 3) + end + elseif (TranqRotate.constants.playerNameFormats.PLAYER_NAME_ONLY == TranqRotate.db.profile.playerNameFormatting) then + displayName = strsplit("-", fullName) + end + + return displayName end