From 5e6555d964e2b8d3f5c1b191867bac418651e7df Mon Sep 17 00:00:00 2001 From: spromicky Date: Tue, 6 Jul 2021 01:23:38 +0300 Subject: [PATCH] implements option to ignore nicknames in Details close #6 --- CHANGELOG.md | 4 ++++ Commands.lua | 33 ++++++++++++++++++++++++--------- Details.lua | 23 ++++++++++++++++++++--- Details_Covenants.toc | 2 +- README.md | 5 ++++- 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc79098..c7bbd92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +##### v1.2.0 Ignore nickmames in Details! + +- now you can ignore nicknames from Details. Use command `/dc ignore on` [#6](https://github.com/spromicky/Details_Covenants/issues/6) + ##### v1.1.0 - add option to align covenant icon [#8](https://github.com/spromicky/Details_Covenants/issues/8). Now you can choose on which side of name covenant icon will be show. diff --git a/Commands.lua b/Commands.lua index f5ff401..7a8858a 100644 --- a/Commands.lua +++ b/Commands.lua @@ -2,6 +2,11 @@ local _, dc = ... local coloredName = "|CFFe5a472Details_Covenants|r" SLASH_DETAILSCOVENANT1, SLASH_DETAILSCOVENANT2 = '/dc', '/dcovenants'; + +local function colorOption(value) + return value == true and "|CFF9fd78aon|r" or "|CFFd77c7aoff|r" +end + local function commandLineHandler(msg, editBox) if string.match(msg, "icon ") then local _, numberValue = dc.utils:splitCommand(msg) @@ -18,10 +23,10 @@ local function commandLineHandler(msg, editBox) end elseif msg == "chat on" then DCovenantLog = true - print(coloredName.." chat logs is |CFF9fd78aon|r") + print(coloredName.." chat logs is "..colorOption(true)) elseif msg == "chat off" then DCovenantLog = false - print(coloredName.." chat logs is |CFFd77c7aoff|r") + print(coloredName.." chat logs is "..colorOption(false)) elseif msg == "log all" then dc.oribos:log() elseif msg == "log group" or msg == "log" then @@ -34,21 +39,31 @@ local function commandLineHandler(msg, editBox) else print("|CFFd77c7aError:|r Please enter one of value |CFF9fd78aleft|r or |CFF9fd78aright|r") end + elseif string.match(msg, "ignore") then + local _, ignoreValue = dc.utils:splitCommand(msg) + if ignoreValue == "on" or ignoreValue == "off" then + if ignoreValue == "on" then + _G._detalhes.ignore_nicktag = false + DCovenant["detailsIgnoreNickname"] = true + else + DCovenant["detailsIgnoreNickname"] = false + end + + print(coloredName.." Details! nicknames ignore is "..colorOption(DCovenant["detailsIgnoreNickname"])) + else + print("|CFFd77c7aError:|r Please enter one of value "..colorOption(true).." or "..colorOption(false)) + end else local coloredCommand = " |CFFc0a7c7/dc|r |CFFf3ce87" - local currentChatOption = "" + local currentChatOption = colorOption(DCovenantLog) local currentAlignOption = DCovenant["iconAlign"] + local currentNicknameOption = colorOption(DCovenant["detailsIgnoreNickname"]) if not currentAlignOption then currentAlignOption = "left" end - if DCovenantLog == true then - currentChatOption = "|CFF9fd78aon|r" - else - currentChatOption = "|CFFd77c7aoff|r" - end - print(coloredName.." usage info:\n"..coloredCommand.."icon [number]:|r change size of icons (currently: |CFF9fd78a"..DCovenant["iconSize"].."|r)\n"..coloredCommand.."chat [on | off]:|r log a new character's covenant to chat (currently: "..currentChatOption..")\n"..coloredCommand.."log [all | group]:|r prints all collected data or just for your party/raid".."\n"..coloredCommand.."align [left | right]:|r change align of covenant icon (currently: |CFF9fd78a"..currentAlignOption.."|r)") + print(coloredName.." usage info:\n"..coloredCommand.."icon [number]:|r change size of icons (currently: |CFF9fd78a"..DCovenant["iconSize"].."|r)\n"..coloredCommand.."chat [on | off]:|r log a new character's covenant to chat (currently: "..currentChatOption..")\n"..coloredCommand.."log [all | group]:|r prints all collected data or just for your party/raid".."\n"..coloredCommand.."align [left | right]:|r change align of covenant icon (currently: |CFF9fd78a"..currentAlignOption.."|r)".."\n"..coloredCommand.."ignore [on | off]:|r ignore Details! nicknames (currently: "..currentNicknameOption..")") end end SlashCmdList["DETAILSCOVENANT"] = commandLineHandler; \ No newline at end of file diff --git a/Details.lua b/Details.lua index 70075c1..0e68ab6 100644 --- a/Details.lua +++ b/Details.lua @@ -1,9 +1,16 @@ local _, dc = ... local oribos = _G.Oribos +local detalhes = _G._detalhes +local old_ignore_nicktag = detalhes.ignore_nicktag function dc:replaceDetailsImplmentation() - if _G.NickTag and _G._detalhes then - _G._detalhes.GetNickname = function(self, playerName, default, silent) + if DCovenant["detailsIgnoreNickname"] == true then + detalhes.ignore_nicktag = false + end + + + if _G.NickTag and detalhes then + detalhes.GetNickname = function(self, playerName, default, silent) local covenantPrefix = "" local covenantSuffix = "" @@ -15,13 +22,23 @@ function dc:replaceDetailsImplmentation() end end + if DCovenant["detailsIgnoreNickname"] == true then + local name_without_nicktag = playerName + + if (detalhes.remove_realm_from_name) then + name_without_nicktag = name_without_nicktag:gsub (("%-.*"), "") + end + + return covenantPrefix..name_without_nicktag..covenantSuffix + end + if (not silent) then assert (type (playerName) == "string", "NickTag 'GetNickname' expects a string or string on #1 argument.") end local _table = NickTag:GetNicknameTable (playerName) if (not _table) then - if (_G._detalhes.remove_realm_from_name) then + if (detalhes.remove_realm_from_name) then playerName = playerName:gsub (("%-.*"), "") end diff --git a/Details_Covenants.toc b/Details_Covenants.toc index e76dcaa..2cc4b91 100644 --- a/Details_Covenants.toc +++ b/Details_Covenants.toc @@ -2,7 +2,7 @@ ## Title: Details!|Skada Covenants ## Notes: Show covenant icon ## Author: Toenak -## Version: 1.1.0 +## Version: 1.2.0 ## X-License: MIT ## X-Curse-Project-ID: 431558 ## SavedVariablesPerCharacter: DCovenant, DCovenantLog diff --git a/README.md b/README.md index 184a082..3ed76bc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ Blizzard don't allow to inspect in which covenant is other players. Only yours o In version `1.0.0` players with this addon share they covenant by addon messaging. So covenants will be detected immidiatly for players with this addon. -**Important for Details!**: Its based on nickname feature of Details. You shouldn't disable nicknames, for correct work. +> **Important for Details!:** Its based on nickname feature of Details. You shouldn't disable nicknames, for correct work. +> **New:** From version `1.2.0` you can ignore nicknames from Details. Use command `/dc ignore on`. This addon still require nickname feature, so this command force turn on nickname feature in Details!, but addon will ignore any nickname returned by this feature. Only add a covenant icon. +> If you wanna return nicknames in Details! use command `/dc ignore off`. After that Details! returns to usual behaviour. ### Commands: @@ -20,6 +22,7 @@ You can call help in game `/dc` or `/dcovenants`. And also subcommands: - `chat [on | off]` log a new character's covenant to chat - `log [all | group]` prints all collected data or just for your party/raid - `align [left | right]` change align of covenant icon + - `ignore [on | off]` ignore Details! nicknames ### Developers: