Skip to content

Commit

Permalink
Merge pull request #764 from Flamanis/event_tracker_anonymization
Browse files Browse the repository at this point in the history
Add anonymization options to the event tracker
  • Loading branch information
Tercioo authored Jul 7, 2024
2 parents a731f66 + 5b5b203 commit 2c44e72
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions frames/window_eventtracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local Details = _G.Details
local C_Timer = _G.C_Timer
local GetSpellInfo = Details.GetSpellInfo
local libwindow = LibStub("LibWindow-1.1")
local playerGUID = UnitGUID('player')

function Details:OpenEventTrackerOptions(bFromOptionsPanel)
if (not _G.DetailsEventTrackerOptions) then
Expand Down Expand Up @@ -130,6 +131,30 @@ function Details:OpenEventTrackerOptions(bFromOptionsPanel)
values = function() return strataTable end,
name = "Frame Strata"
},
--anonymize names
{
type = "toggle",
get = function() return Details.event_tracker.anonymize_names end,
set = function(self, fixedparam, value)
Details.event_tracker.anonymize_names = not Details.event_tracker.anonymize_names
Details:UpdateEventTrackerFrame()
end,
desc = "Sets all player names as the last digits of their GUID when displaying in the event tracker.",
name = "Anonymize Player Names",
text_template = options_text_template,
},
--anonymize self
{
type = "toggle",
get = function() return Details.event_tracker.anonymize_self end,
set = function(self, fixedparam, value)
Details.event_tracker.anonymize_self = not Details.event_tracker.anonymize_self
Details:UpdateEventTrackerFrame()
end,
desc = "Anonymize the current player's name from the event tracker.",
name = "Anonymize Self",
text_template = options_text_template,
},
{type = "breakline"},
{type = "label", get = function() return "Line Settings:" end, text_template = DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE")},
--line height
Expand Down Expand Up @@ -461,6 +486,26 @@ function Details:CreateEventTrackerFrame(parentObject, name)
end
end

local anonymize_name = function(name, guid)
if not Details.event_tracker.anonymize_names then
return name
end

if guid:sub(1,6) ~= 'Player' then
return name
end

if not Details.event_tracker.anonymize_self and guid == playerGUID then
return name
end

-- Example GUID: Player-0301-0D23FC41
-- We only care about the last part
local _,_, guid_end = string.split('-', guid)

return guid_end
end

local add_role_and_class_color = function(unitName, unitSerial)
--get the actor object
local actor = Details.tabela_vigente[1]:GetActor(unitName)
Expand All @@ -474,6 +519,8 @@ function Details:CreateEventTrackerFrame(parentObject, name)
spec, class = get_spec_or_class (unitSerial, unitName)
end

unitName = anonymize_name(unitName, unitSerial)

--add the class color
if (Details.player_class [class]) then
--is a player, add the class color
Expand All @@ -489,6 +536,8 @@ function Details:CreateEventTrackerFrame(parentObject, name)
else
local spec, class = get_spec_or_class (unitSerial, unitName)
unitName = Details:GetOnlyName(unitName)

unitName = anonymize_name(unitName, unitSerial)

if (class) then
--add the class color
Expand Down Expand Up @@ -556,6 +605,8 @@ function Details:CreateEventTrackerFrame(parentObject, name)

local sourceNameNoRealm = Details:GetOnlyName(sourceName)

sourceNameNoRealm = anonymize_name(sourceNameNoRealm, ability[ABILITYTABLE_CASTERSERIAL])

--need to use the language system from details framework to detect which language is being used
local languageId = DF.Language.DetectLanguageId(sourceNameNoRealm)
--print("lenaguage detected:", languageId, sourceNameNoRealm)
Expand Down

0 comments on commit 2c44e72

Please sign in to comment.