coa.10: CoA reputation factions (data-driven) + custom-class icons + all-professions Skills
release / release (push) Successful in 5s

- Reputation view rebuilt data-driven from each char's scanned factions grouped
  by in-game category; CoA custom factions (and future ones) appear automatically.
  Old hardcoded tree kept only as an icon lookup.
- CoA custom-class icons (classes 12-32) render from bundled atlas
  Altoholic/images/coa-classes.blp (texcoords from coa-details) instead of the
  Warrior glue-icon fallback in ShowClassIcons.
- Skills tab shows ALL known professions (dynamic list incl Woodcutting/Woodworking),
  not 2 fixed slots; DataStore_Skills scans on PLAYER_ENTERING_WORLD/SKILL_LINES_CHANGED
  (fixes 'no profession data' that only scanned on ghost-release).
This commit is contained in:
2026-05-29 15:55:25 +02:00
parent ec868716ed
commit 0565051302
15 changed files with 428 additions and 177 deletions
+74 -65
View File
@@ -81,13 +81,10 @@ function ns:Update()
end
_G[entry..i.."Level"]:SetText("")
_G[entry..i.."Skill1NormalText"]:SetText("")
_G[entry..i.."Skill2NormalText"]:SetText("")
_G[entry..i.."CookingNormalText"]:SetText("")
_G[entry..i.."FirstAidNormalText"]:SetText("")
_G[entry..i.."FishingNormalText"]:SetText("")
_G[entry..i.."RidingNormalText"]:SetText("")
_G[entry..i.."WoodcuttingNormalText"]:SetText("")
_G[entry..i.."WoodworkingNormalText"]:SetText("")
_G[ entry..i ]:SetID(line)
_G[ entry..i ]:Show()
@@ -113,28 +110,26 @@ function ns:Update()
_G[entry..i.."NameNormalText"]:SetWidth(170)
addon:SetCharacterRowNameLevel(entry, i, icon, character)
-- profession 1
local field = Characters:GetField(line, "spellID1")
if field then
-- icon = addon:TextureToFontstring(addon:GetSpellIcon(field), size, size) .. " "
icon = addon:TextureToFontstring2(addon:GetSpellIcon(field), size, size, inset, inset, inset, inset) .. " "
else
icon = ""
-- CoA: render ALL primary professions the character knows into the
-- single wide Professions cell, as a row of icon+rank segments.
-- The list is precomputed in Characters.lua (field "professions")
-- and may be empty (unscanned char) -> cell renders blank. Every
-- value is guarded with "or 0" before GetColor/concat.
local professions = Characters:GetField(line, "professions")
local profText = ""
if professions then
for _, p in ipairs(professions) do
local rank = p.rank or 0
local profIcon = ""
if p.spellID then
profIcon = addon:TextureToFontstring2(addon:GetSpellIcon(p.spellID), size, size, inset, inset, inset, inset) .. " "
end
profText = profText .. profIcon .. ns:GetColor(rank) .. rank .. "|r "
end
end
field = Characters:GetField(line, "skillRank1") or 0
_G[entry..i.."Skill1NormalText"]:SetText(icon .. ns:GetColor(field) .. field)
-- profession 2
field = Characters:GetField(line, "spellID2")
if field then
-- icon = addon:TextureToFontstring(addon:GetSpellIcon(field), size, size) .. " "
icon = addon:TextureToFontstring2(addon:GetSpellIcon(field), size, size, inset, inset, inset, inset) .. " "
else
icon = ""
end
field = Characters:GetField(line, "skillRank2") or 0
_G[entry..i.."Skill2NormalText"]:SetText(icon .. ns:GetColor(field) .. field)
_G[entry..i.."Skill1NormalText"]:SetText(profText)
local field
-- cooking
-- icon = addon:TextureToFontstring(addon:GetSpellIcon(2550), size, size) .. " "
icon = addon:TextureToFontstring2(addon:GetSpellIcon(2550), size, size, inset, inset, inset, inset) .. " "
@@ -193,20 +188,6 @@ function ns:Update()
end
_G[entry..i.."RidingNormalText"]:SetText(icon .. ns:GetColor(field, 300) .. field)
-- CoA custom professions: Woodcutting (spell 13977860) + Woodworking (spell 1005008).
-- Ranks are read live from DataStore_Skills' name-based getters (not from a
-- precomputed Characters field) so this stays self-contained. The getters return
-- 0 on non-CoA chars or chars not yet scanned; still guarded with "or 0" before
-- GetColor/concat. DataStore methods may be absent if DataStore_Skills is an older
-- build, so guard each call with an existence check.
field = (DS.GetWoodcuttingRank and (DS:GetWoodcuttingRank(character)) or 0) or 0
icon = addon:TextureToFontstring2(addon:GetSpellIcon(13977860), size, size, inset, inset, inset, inset) .. " "
_G[entry..i.."WoodcuttingNormalText"]:SetText(icon .. ns:GetColor(field) .. field)
field = (DS.GetWoodworkingRank and (DS:GetWoodworkingRank(character)) or 0) or 0
icon = addon:TextureToFontstring2(addon:GetSpellIcon(1005008), size, size, inset, inset, inset, inset) .. " "
_G[entry..i.."WoodworkingNormalText"]:SetText(icon .. ns:GetColor(field) .. field)
elseif (lineType == INFO_TOTAL_LINE) then
_G[entry..i.."Collapse"]:Hide()
_G[entry..i.."Name"]:SetWidth(200)
@@ -215,13 +196,10 @@ function ns:Update()
_G[entry..i.."NameNormalText"]:SetText(L["Totals"])
_G[entry..i.."Level"]:SetText(Characters:GetField(line, "level"))
_G[entry..i.."Skill1NormalText"]:SetText("")
_G[entry..i.."Skill2NormalText"]:SetText("")
_G[entry..i.."CookingNormalText"]:SetText("")
_G[entry..i.."FirstAidNormalText"]:SetText("")
_G[entry..i.."FishingNormalText"]:SetText("")
_G[entry..i.."RidingNormalText"]:SetText("")
_G[entry..i.."WoodcuttingNormalText"]:SetText("")
_G[entry..i.."WoodworkingNormalText"]:SetText("")
end
_G[ entry..i ]:SetID(line)
_G[ entry..i ]:Show()
@@ -250,12 +228,46 @@ function ns:OnEnter(frame)
local id = frame:GetID()
local skillName, rank, suggestion
local DS = DataStore
local character = DS:GetCharacter(Characters:GetInfo(line))
-- CoA: id 1 is now the combined "Professions" cell -> list every known primary
-- profession with rank/max and recipe counts in a single tooltip.
if id == 1 then
skillName = Characters:GetField(line, "skillName1")
elseif id == 2 then
skillName = Characters:GetField(line, "skillName2")
elseif id == 3 then
local professions = Characters:GetField(line, "professions")
AltoTooltip:ClearLines()
AltoTooltip:SetOwner(frame, "ANCHOR_RIGHT")
AltoTooltip:AddLine(L["Professions"] or "Professions", 1, 1, 1)
if not professions or #professions == 0 then
AltoTooltip:AddLine(L["No data"])
AltoTooltip:Show()
return
end
for _, p in ipairs(professions) do
local pName = p.name
local curRank, maxRank = DS:GetSkillInfo(character, pName)
curRank, maxRank = curRank or 0, maxRank or 0
local rankText = ns:GetColor(curRank) .. curRank .. "/" .. maxRank
local recipeText = ""
local prof = DS:GetProfession(character, pName)
if prof and DS:GetNumCraftLines(prof) > 0 then
local orange, yellow, green, grey = DS:GetNumRecipesByColor(prof)
recipeText = WHITE .. " (" .. (orange + yellow + green + grey) .. " " .. TRADESKILL_SERVICE_LEARN .. ")"
end
-- localized display name where possible
local displayName = pName
local spellID = DS:GetProfessionSpellID(pName)
if spellID then
displayName = GetSpellInfo(spellID) or pName
end
AltoTooltip:AddDoubleLine(WHITE .. displayName, rankText .. recipeText)
end
AltoTooltip:Show()
return
end
if id == 3 then
skillName = GetSpellInfo(2550) -- cooking
elseif id == 4 then
skillName = GetSpellInfo(3273) -- First Aid
@@ -263,22 +275,13 @@ function ns:OnEnter(frame)
skillName = GetSpellInfo(24303) -- Fishing
elseif id == 6 then
skillName = L["Riding"]
elseif id == 8 then
skillName = GetSpellInfo(13977860) or "Woodcutting" -- CoA custom: Woodcutting
elseif id == 9 then
skillName = GetSpellInfo(1005008) or "Woodworking" -- CoA custom: Woodworking
end
local DS = DataStore
local character = DS:GetCharacter(Characters:GetInfo(line))
local curRank, maxRank = DS:GetSkillInfo(character, skillName)
curRank, maxRank = curRank or 0, maxRank or 0 -- CoA: getter returns no value for skills DataStore_Skills hasn't scanned
local profession = DS:GetProfession(character, skillName)
if (id == 8) or (id == 9) then -- CoA custom professions: show rank + recipe summary like the primary professions
rank = ns:GetColor(curRank) .. curRank .. "/" .. maxRank
suggestion = addon:GetSuggestion(skillName, curRank)
elseif (id >= 1) and (id <= 6) then
if (id >= 3) and (id <= 6) then
if id == 6 then -- riding
rank = ns:GetColor(curRank, 300) .. curRank .. "/" .. maxRank
else
@@ -303,7 +306,7 @@ function ns:OnEnter(frame)
AltoTooltip:AddLine(skillName,1,1,1);
AltoTooltip:AddLine(GREEN..rank,1,1,1);
if (id <= 4) or (id == 9) then -- crafting skills (incl. CoA Woodworking, id 9); skips fishing/riding/Woodcutting
if (id == 3) or (id == 4) then -- crafting secondary skills (Cooking, First Aid); skips fishing/riding
if skillName ~= GetSpellInfo(13614) and skillName ~= GetSpellInfo(8613) then -- no display for herbalism & skinning
AltoTooltip:AddLine(" ");
@@ -381,17 +384,17 @@ function ns:OnClick(frame, button)
local skillName
if id == 1 then
skillName = Characters:GetField(line, "skillName1")
elseif id == 2 then
skillName = Characters:GetField(line, "skillName2")
-- CoA: id 1 is the combined Professions cell. A single click can't pick one
-- of several professions, so default to the first known primary profession
-- (opens its recipes / supplies its trade link on shift-click).
local professions = Characters:GetField(line, "professions")
if professions and professions[1] then
skillName = professions[1].name
end
elseif id == 3 then
skillName = GetSpellInfo(2550) -- cooking
elseif id == 4 then
skillName = GetSpellInfo(3273) -- First Aid
elseif id == 8 then
skillName = GetSpellInfo(13977860) or "Woodcutting" -- CoA custom (gathering, no recipes)
elseif id == 9 then
skillName = GetSpellInfo(1005008) or "Woodworking" -- CoA custom (crafting)
end
local DS = DataStore
@@ -431,5 +434,11 @@ local skillColors = { RECIPE_GREY, RED, ORANGE, YELLOW, GREEN }
function ns:GetColor(rank, skillCap)
rank = rank or 0 -- CoA: skill fields are nil for chars DataStore_Characters hasn't scanned
skillCap = skillCap or 450
return skillColors[ floor(rank / (skillCap/4)) + 1 ]
-- CoA: custom professions can exceed skillCap (e.g. ranks > 450), which would
-- push the index past the 5-colour table and return nil -> crash on concat.
-- Clamp into [1, #skillColors].
local index = floor(rank / (skillCap / 4)) + 1
if index < 1 then index = 1 end
if index > #skillColors then index = #skillColors end
return skillColors[index]
end