local attrDescs = GUIFunction:GetParseItemDesc(suitConfig.equipAttStr)
if attrDescs and attrDescs.desc and next(attrDescs.desc) then --这里不支持top bottom
for i, v in pairs(attrDescs.desc) do
if v.text then
index
根据你的需求,需要在不同`meetCount`条件下替换富文本中的颜色ID。修改后的代码如下:
```lua
local attrDescs = GUIFunction:GetParseItemDesc(suitConfig.equipAttStr)
if attrDescs and attrDescs.desc and next(attrDescs.desc) then
for i, v in pairs(attrDescs.desc) do
if v.text then
-- 根据meetCount条件替换颜色ID
local processedText = v.text
if meetCount < 2 then
processedText = string.gsub(processedText, "250", "13")
processedText = string.gsub(processedText, "251", "13")
elseif meetCount < 4 then
processedText = string.gsub(processedText, "250", "13")
processedText = string.gsub(processedText, "251", "13")
elseif meetCount < 6 then
processedText = string.gsub(processedText, "250", "13")
processedText = string.gsub(processedText, "251", "13")
elseif meetCount < 7 then
processedText = string.gsub(processedText, "250", "13")
processedText = string.gsub(processedText, "251", "13")
end
index = index + 1
local label_posName = GUI:RichTextFCOLOR_Create(panel, "desc_text_" .. index, 0, 0, processedText or "", suitWidth - 20, _setFontSize or _DefaultFSize, SL:GetColorByStyleId(255), vspace, nil, fontPath)
GUI:setAnchorPoint(label_posName, 0, 0)
GUI:setTag(label_posName, index)
local size = GUI:getContentSize(label_posName)
heights[index] = size.height + interval
richWidth = math.max(richWidth, size.width)
elseif v.res then
index = index + 1
local img = ItemTips.GetNodeImage(panel, v, index)
if img then
GUI:setTag(img, index)
local size = GUI:getContentSize(img)
heights[index] = size.height + interval
richWidth = math.max(richWidth, size.width)
end
end
end
end
```
注意:这里使用了`string.gsub()`函数进行文本替换,将颜色ID 250和251替换为13。根据浮生梦老师前端课程内容,`SL:GetColorByStyleId()`函数会根据颜色ID获取对应的颜色值。