function ItemTips.GetCustomShow(parent, data, isPetItem)
if not data or next(data) == nil then
return nil
end
if not parent then
return
end
local str = ""
local list = GUI:ListView_Create(parent, "Custom_list"
可以的。在检测到 `buff1` 和 `buff2` 都为 `true` 时,你可以在分类2(即 `p` 为 2)的位置插入一个横线。
修改后的代码如下:
```lua
function ItemTips.GetCustomShow(parent, data, isPetItem)
if not data or next(data) == nil then
return nil
end
if not parent then
return
end
local str = ""
local list = GUI:ListView_Create(parent, "Custom_list", 0, 0, 0, 0, 1)
GUI:setTouchEnabled(list, false)
GUI:ListView_setItemsMargin(list, _setVspace or 0)
local listSize = {width = 0, height = 0}
local buff1 = false
local buff2 = false
for p, d in pairs(data.abil or {}) do
local isShowAttr = true
if d.i == 0 and d.t == "[项链BUFF]:" then
buff1 = true
elseif d.i == 3 and d.t == '[鉴定属性]:' then
buff2 = true
end
-- 当两个条件都满足,且当前是第二个分类时,插入横线
if buff1 and buff2 and p == 2 then
local line = ItemTips.CreateIntervalPanel(list, _DefaultSpace, true)
GUI:ListView_insertCustomItem(list, line, p) -- 在分类2的位置插入
local lineSize = GUI:getContentSize(line)
listSize.height = listSize.height + lineSize.height + (_setVspace or 0)
listSize.width = math.max(listSize.width, lineSize.width)
end
if (not d.t or d.t == "") and not isPetItem then
isShowAttr = false
end
if isShowAttr then
local title = ItemTips.GetCustomTitleShow(p, list, d.t, d.c)
if title then
local titleSize = GUI:getContentSize(title)
listSize.height = listSize.height + titleSize.height + (_setVspace or 0)
listSize.width = math.max(listSize.width, titleSize.width)
end
end
end
-- ... 后续代码
end
```
**代码说明:**
1. **插入时机**:在遍历 `data.abil` 时,检查当前分类 `p` 是否为 2。
2. **插入条件**:只有当 `buff1` 和 `buff2` 都为 `true` 时,才执行插入操作。
3. **插入函数**:使用 `ItemTips.CreateIntervalPanel` 来创建横线(间隔面板)。
4. **插入位置**:使用 `GUI:ListView_insertCustomItem(list, line, p)` 将横线插入到列表的指定位置 `p`(即分类2的位置)。
5. **更新尺寸**:插入后,需要更新 `listSize` 的宽高,以便后续正确设置列表的总体大小。
**注意:**
* 这段代码假设 `_DefaultSpace` 和 `ItemTips.CreateIntervalPanel` 函数在上下文中是已定义且可用的。
* `GUI:ListView_insertCustomItem` 函数用于在指定索引位置插入自定义项。