Skip to content

Commit

Permalink
Add anonymization options to the event tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamanis committed Jul 7, 2024
1 parent a731f66 commit 74607b2
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 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,24 @@ 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

local guid_table = {string.split('-', guid)}

return guid_table[#guid_table]
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 +517,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 +534,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 +603,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 74607b2

Please sign in to comment.