Files
florian.berthold 57c603fa8e
release / release (push) Successful in 5s
coa.29: right-size VisibleLines for the taller window (rows were overflowing)
All list rows are 22px; the resize had set VisibleLines=20 uniformly (20x22=440 > the 414px
content frame), so the bottom rows spilled past the frame - visible as the guild list
running into the 'Click a character's AiL' footer. Set 18 rows for all list tabs (18x22=396),
17 for GuildMembers (it has the equipment footer).
2026-05-30 01:09:12 +02:00

169 lines
6.3 KiB
Lua

local addonName = ...
local addon = _G[addonName]
local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local BI = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
local INFO_REALM_LINE = 0
local INFO_CHARACTER_LINE = 1
local INFO_TOTAL_LINE = 2
local WHITE = "|cFFFFFFFF"
local TEAL = "|cFF00FF9A"
local RED = "|cFFFF0000"
local ORANGE = "|cFFFF7F00"
local YELLOW = "|cFFFFFF00"
local GREEN = "|cFF00FF00"
local RECIPE_GREY = "|cFF808080"
local RECIPE_GREEN = "|cFF40C040"
local RECIPE_ORANGE = "|cFFFF8040"
local ICON_FACTION_HORDE = "Interface\\Icons\\INV_BannerPVP_01"
local ICON_FACTION_ALLIANCE = "Interface\\Icons\\INV_BannerPVP_02"
local ns = addon.TradeSkills -- ns = namespace
local Characters = addon.Characters
local size = 22
local inset = 2
function ns:Update()
local VisibleLines = 18
local frame = "AltoholicFrameSkills"
local entry = frame.."Entry"
local DS = DataStore
-- CoA: vertical list. For each visible character a header row, then one row per known
-- profession / secondary skill (icon + name + rank/max), top to bottom (like the other detail views).
local SECONDARY = { 2550, 3273, 7733 } -- Cooking, First Aid, Fishing (spell id -> icon + GetSpellInfo name)
local items = {}
for _, viewLine in pairs(Characters:GetView()) do
if Characters:GetLineType(viewLine) == INFO_CHARACTER_LINE then
local character = DS:GetCharacter( Characters:GetInfo(viewLine) )
items[#items + 1] = { kind = "header", viewLine = viewLine, character = character }
local profs = Characters:GetField(viewLine, "professions")
if profs then
for _, p in ipairs(profs) do
items[#items + 1] = { kind = "skill", viewLine = viewLine, character = character,
spellID = p.spellID, name = p.name, rank = p.rank or 0, maxRank = p.maxRank or 0 }
end
end
for _, sid in ipairs(SECONDARY) do
local sName = GetSpellInfo(sid)
if sName then
local cur, max = DS:GetSkillInfo(character, sName)
if cur and cur > 0 then
items[#items + 1] = { kind = "skill", viewLine = viewLine, character = character,
spellID = sid, name = sName, rank = cur, maxRank = max or 0 }
end
end
end
local riding = Characters:GetField(viewLine, "riding") or 0
if riding > 0 then
items[#items + 1] = { kind = "skill", viewLine = viewLine, character = character,
spellID = 33388, name = (L and L["Riding"]) or "Riding", rank = riding, maxRank = 300 }
end
items[#items + 1] = { kind = "spacer" } -- blank row between characters
end
end
local offset = FauxScrollFrame_GetOffset( _G[ frame.."ScrollFrame" ] )
for i = 1, VisibleLines do
local e = entry..i
local btn = _G[e]
local item = items[i + offset]
if item then
_G[e.."Collapse"]:Hide()
_G[e.."Skill1NormalText"]:SetText("")
_G[e.."CookingNormalText"]:SetText("")
_G[e.."FirstAidNormalText"]:SetText("")
_G[e.."FishingNormalText"]:SetText("")
_G[e.."RidingNormalText"]:SetText("")
if item.kind == "spacer" then
-- blank separator row between characters
_G[e.."Name"]:SetPoint("TOPLEFT", 15, 0)
_G[e.."NameNormalText"]:SetText("")
_G[e.."Level"]:SetText("")
elseif item.kind == "header" then
-- character header: gold "Name (Class)" across the row, no rank column
_G[e.."Name"]:SetPoint("TOPLEFT", 12, 0)
_G[e.."Name"]:SetWidth(420)
_G[e.."NameNormalText"]:SetWidth(420)
local cname = Characters:GetInfo(item.viewLine) or "?" -- name from the key, always present (scanned char.name can be nil)
local locClass, engClass = DS:GetCharacterClass(item.character)
local className = Altoholic:GetCoAClassName(engClass) or locClass or "" -- CoA: PROPHET->Venomancer, MONK->Templar, …
local classColor = DS:GetClassColor(item.character) or WHITE
_G[e.."NameNormalText"]:SetText( classColor .. cname .. "|r " .. WHITE .. "(" .. className .. ")" )
_G[e.."Level"]:SetText("")
else
-- profession row: [icon] name in the Name cell (indented), rank/max in its own column
local iconEsc = ""
if item.spellID then
iconEsc = addon:TextureToFontstring2(addon:GetSpellIcon(item.spellID), size, size, inset, inset, inset, inset) .. " "
end
_G[e.."Name"]:SetPoint("TOPLEFT", 34, 0)
_G[e.."Name"]:SetWidth(170)
_G[e.."NameNormalText"]:SetWidth(170)
_G[e.."NameNormalText"]:SetText( iconEsc .. WHITE .. item.name )
local cap = (item.maxRank > 0) and item.maxRank or 450
_G[e.."Level"]:SetPoint("TOPLEFT", 195, 0)
_G[e.."Level"]:SetWidth(120)
_G[e.."Level"]:SetJustifyH("LEFT")
_G[e.."Level"]:SetText( ns:GetColor(item.rank, cap) .. item.rank .. " / " .. item.maxRank )
end
btn.coaItem = item
btn:SetID(item.viewLine or 0)
btn:Show()
else
btn.coaItem = nil
btn:SetID(0)
btn:Hide()
end
end
FauxScrollFrame_Update( _G[ frame.."ScrollFrame" ], #items, VisibleLines, 18 )
end
function ns:OnEnter(frame)
local item = frame:GetParent() and frame:GetParent().coaItem
if not item or item.kind ~= "skill" then return end
AltoTooltip:ClearLines()
AltoTooltip:SetOwner(frame, "ANCHOR_RIGHT")
AltoTooltip:AddLine(WHITE .. item.name, 1, 1, 1)
local cap = (item.maxRank > 0) and item.maxRank or 450
AltoTooltip:AddLine( ns:GetColor(item.rank, cap) .. item.rank .. " / " .. item.maxRank, 1, 1, 1 )
AltoTooltip:Show()
end
function ns:OnClick(frame, button)
-- CoA: clicking a profession row opens that character's profession recipe list, if available.
local item = frame:GetParent() and frame:GetParent().coaItem
if not item or item.kind ~= "skill" or not item.character then return end
if addon.Tabs and addon.Tabs.Characters and addon.Tabs.Characters.ViewCharInfo then
local name, realm, account = Characters:GetInfo(item.viewLine)
addon:SetCurrentCharacter(name, realm, account)
addon.Tabs.Characters:SetCurrent(name, realm, account)
addon.Tabs:OnClick(2)
end
end
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
-- 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