Skip to content

Commit

Permalink
implements option to ignore nicknames in Details
Browse files Browse the repository at this point in the history
close #6
  • Loading branch information
spromicky committed Jul 5, 2021
1 parent 2af5c3e commit 5e6555d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
33 changes: 24 additions & 9 deletions Commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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;
23 changes: 20 additions & 3 deletions Details.lua
Original file line number Diff line number Diff line change
@@ -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 = ""

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Details_Covenants.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand Down

0 comments on commit 5e6555d

Please sign in to comment.