Hello.
I would like to change the width of each class icon when the max number of the resource changes.
Lua Code:
local ClassIconsPostUpdate = function(element, cur, max, maxchange)
for i = 1, 5 do
if cur == max then
element[i]:SetStatusBarColor(unpack(classicon_colors[cur]))
else
element[i]:SetStatusBarColor(unpack(classicon_colors[i]))
end
if maxchange then
element[i]:SetWidth((oUF_MlightDB.width+3)/max-3)
end
end
end
Lua Code:
local _, class = UnitClass("player")
-- Runes, Shards, HolyPower and so on --
if multicheck(class, "DEATHKNIGHT", "WARLOCK", "PALADIN", "MONK", "SHAMAN", "PRIEST", "MAGE", "ROGUE", "DRUID") then
local count
if class == "DEATHKNIGHT" then
count = 6
elseif class == "WARLOCK" then
count = 4
elseif class == "PALADIN" or class == "PRIEST" or class == "MONK" then
count = 5
elseif class == "SHAMAN" then
count = 4
elseif class == "MAGE" then
count = 6
elseif class == "ROGUE" or class == "DRUID" then
count = 5 -- combopoints
end
local bars = CreateFrame("Frame", nil, self)
bars:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 3)
bars:SetSize(oUF_MlightDB.width, 10)
for i = 1, count do
bars[i] = createStatusbar(bars, texture, nil, oUF_MlightDB.height*-(oUF_MlightDB.hpheight-1), (oUF_MlightDB.width+2)/count-3, 1, 1, 1, 1)
if i == 1 then
bars[i]:SetPoint("BOTTOMLEFT", bars, "BOTTOMLEFT")
else
bars[i]:SetPoint("LEFT", bars[i-1], "RIGHT", 3, 0)
end
bars[i].bd = createBackdrop(bars[i], bars[i], 1)
end
if class == "DEATHKNIGHT" then
self.Runes = bars
elseif class == "WARLOCK" then
self.WarlockSpecBars = bars
elseif class == "PALADIN" or class == "PRIEST" or class == "MONK" then
self.ClassIcons = bars
self.ClassIcons.UpdateTexture = function() end
self.ClassIcons.PostUpdate = ClassIconsPostUpdate
elseif class == "SHAMAN" then
self.TotemBar = bars
elseif class == "MAGE" then
self.ArcaneCharge = bars
elseif class == "ROGUE" or class == "DRUID" then
self.CPoints = bars
self.CPoints.PostUpdate = CpointsPostUpdate
end
end
When the max number of power changes, it works properly. But there's a problem when log-in.
If the player is shadow priest. The width of each element is
1/5 of the width of player frame.
I would like it to be
1/3. A paladin under lvl 85 ,a warlock with 3 soul shards and a monk with 4 chis got the same problem.
The solution I found is to change element.__max to
5 in oUF\elements\classicons.lua(because I can't find a right place to make it in my layout).
This means: when I create the frames/textures for the element, I set the width of each icon suppose the player got
5 class icons. When PLAYER_TALENT_UPDATE fires, oUF update the element and
oldMax ~= max is
true in element:PostUpdate(cur, max, oldMax ~= max). So the layout can change the width of each icon when log-in.
Haste, I really appreciate if you could set element.__max to 5 in oUF\elements\classicons.lua or make it easier to change element.__max in layout.