Let me apologize that I'm writing multiple threads within a short term
So, here's my new questions.
I was trying to create "ClassIcon Bar" with "ClassIcon" element.
However, there was few problems with this.
Have a look at the code first:
Lua Code:
A.CreateClassIcons = function(f, unit)
local _, Class = UnitClass(unit);
local MaxPower;
local ClassIcons = {};
local ClassIconName = {
Monk = "ChiOrb",
Paladin = "HolyPower",
Priest = "ShadowOrb",
Warlock = "SoulShard",
};
local ClassIconColor = {
Monk = {
r = 0.52,
g = 0.90,
b = 0.50,
},
Paladin = {
r = 1.00,
g = 0.70,
b = 0.85,
},
Priest = {
r = 1.00,
g = 1.00,
b = 1.00,
},
Warlock = {
r = 0.65,
g = 0.40,
b = 1.00,
},
};
if (Class == "MONK") then
MaxPower = UnitPowerMax(unit, SPELL_POWER_CHI);
end
local lowerClass = A.FirstToUpper(Class);
for i = 1, 6 do
local ClassIcon = CreateFrame("Frame", ("YUI_" .. ClassIconName[lowerClass] .. i), f);
ClassIcon:SetBackdrop({
bgFile = BACKDROP,
tile = true,
tileSize = 16,
});
ClassIcon:SetBackdropColor(0.1, 0.1, 0.1, 1);
ClassIcon:SetWidth((G[unit]["width"] - (MaxPower - 1)) / MaxPower);
ClassIcon:SetHeight(16);
if i == 1 then
ClassIcon:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 0, -2);
else
ClassIcon:SetPoint("LEFT", ClassIcons[i - 1], "RIGHT", 1, 0);
end
local texture = ClassIcon:CreateTexture(nil, "OVERLAY");
texture:SetTexture(COMBO_POINT);
texture:SetVertexColor(ClassIconColor[lowerClass]["r"], ClassIconColor[lowerClass]["g"], ClassIconColor[lowerClass]["b"], 1);
texture:SetWidth(ClassIcon:GetWidth() - 4);
texture:SetHeight(ClassIcon:GetHeight() - 4);
texture:SetPoint("CENTER");
ClassIcon.texture = texture;
ClassIcons[i] = ClassIcon;
end
f.ClassIcons = ClassIcons;
end
The first issue with this code is that when I enter the game, "UnitPowerMax(unit, SPELL_POWER_CHI)" returns 0 and only returns the proper value when I reload the game.
The next issue is that since I'm using my own textures for Chi, I have to update the size and position of icon if I select "Ascension (Monk Talent: 3/2)" which increases max number of chi by 1. However, it seems not working as I expected
...
Lastly, instead of utilizing default "ClassIcons" element, I was trying to create my own element module for each classes, Monk, Warlock, Priest and Paladin. So, I've attempted to interpret the original "ClassIcons" module, but as a newbie, it was pretty complex to understand what each function performs.
Could anyone please help me with interpreting this module