tullamods / OmniCC

Cooldown count for everything
https://tullamods.com/omnicc
MIT License
99 stars 21 forks source link

Choose cd frame over parent frame #415

Open XyzKangUI opened 9 months ago

XyzKangUI commented 9 months ago

Is your feature request related to a problem? Please describe. When you create 1 frame which holds multiple cooldown frames it will always display only 1 text because of local newDisplay = Addon.Display:GetOrCreate(self:GetParent() or self)

E.g.

local frame = CreateFrame("Frame", nil, UIParent)
local icon1 = frame:CreateTexture(nil, "ARTWORK")
icon1:SetSize(40, 40)
icon1:SetPoint("LEFT", 10, 0)
local icon2 = frame:CreateTexture(nil, "ARTWORK")
icon2:SetSize(40, 40)
icon2:SetPoint("RIGHT", -10, 0)
local cd1 = CreateFrame("Cooldown", nil, frame, "CooldownFrameTemplate")
cd1:SetAllPoints(icon1)
local cd2 = CreateFrame("Cooldown", nil, frame, "CooldownFrameTemplate")
cd2:SetAllPoints(icon2)

The above code in its current form will always display 1 text because of the self:GetParent() being frame for both cd frames. By turning it around to be self or self:GetParent() we can get each cd frame to use its own timer text. This seems to be in line with the blizzard cooldown count behaviour. I have no idea if this causes any regression.

Tuller commented 9 months ago

Do you have an example of where you’d want to see two timers? The current behavior is there to avoid displaying charge and action cooldowns at the same time

XyzKangUI commented 9 months ago

Do you have an example of where you’d want to see two timers? The current behavior is there to avoid displaying charge and action cooldowns at the same time

I faced this issue because as shown above I created one frame, multiple textures and a cd frame for each texture. The idea for the code was to create a multi (internal) cooldown tracker for trinkets and other proc based spells, which are always visible. Then I noticed that OmniCC was always showing the text only on one icon at the same time while blizz count down did not. I instantly thought of the idea that the addon was somehow always using the main frame instead of the cd frames and stumbled upon your newDisplay line. If your line is absolutely necessary I could opt for a new frame for each new icon, but I thought implementing it this way was easier.