Skip to content

Commit

Permalink
Retail: Revised use of Colors since in some cases it could result in …
Browse files Browse the repository at this point in the history
…an infinite metatable recursive reference to itself (fixes #1720) (fixes #1668)
  • Loading branch information
ImUnicke committed Aug 16, 2024
1 parent fa566f6 commit 3c060c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions lib/Colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local _, app = ...;
-- Encapsulates the raw Color strings used throughout ATT

-- Color |cAARRGGBB values used throughout ATT
app.Colors = {
app.DefaultColors = {
ATT = "ffb4b4ff",
Raid = "ffFF7D01", -- Raid chat color
SourceIgnored = "ffd15517",
Expand Down Expand Up @@ -39,8 +39,14 @@ app.Colors = {
White = "ffFFFFFF",
};

app.SetCustomColors = function(colorTable)
app.Colors = setmetatable(colorTable or {}, {__index = app.DefaultColors})
end

app.SetCustomColors()

app.ccColors = {};
for k,v in pairs (app.Colors) do
for k,v in pairs (app.DefaultColors) do
app.ccColors[k] = "|c"..v;
end;

Expand Down
5 changes: 2 additions & 3 deletions src/Settings/Retail Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ settings.Initialize = function(self)
local colors = settings:Get("Window:CustomColors") or {}
-- make sure the table reference is actually assigned back to be saved
settings:Set("Window:CustomColors",colors)
setmetatable(colors, { __index = app.Colors });
-- replace the direct table with a metatable of the original colors
app.Colors = colors;
-- replace the direct table with a metatable of the user's colors & Default fallbacks
app.SetCustomColors(colors)

-- Assign the preset filters for your character class as the default states
if not AllTheThingsSettingsPerCharacter then AllTheThingsSettingsPerCharacter = {} end
Expand Down

0 comments on commit 3c060c3

Please sign in to comment.