根据浮生梦老师前端课程内容,要更新装备框显示内容,可以使用 `GUI:removeAllChildren()` 清空节点后重新创建装备项。参考装备面板的实现方式,可以这样修改:
```lua
function refined:refreshWin(p3, msgData)
refined.eqInfo = SL:JsonDecode(msgData)
-- ... 前面的按钮处理代码保持不变 ...
if refined.eqInfo[12] then
local buttonName = "but_"..p3
if refined.eqInfo[12].hasEquip == false then
if refined.ui[buttonName] then
GUI:Button_setBright(refined.ui[buttonName], false)
end
end
-- 更新装备显示框内容
if refined.ui.EquipShow_1 then
-- 先清空当前显示的内容
GUI:removeAllChildren(refined.ui.EquipShow_1)
-- 如果有装备数据,创建装备项显示
if refined.eqInfo[12].pos then
-- 这里需要根据你的实际需求创建装备显示
-- 例如创建图片或文字显示装备信息
local equipName = refined.eqInfo[12].name or "未知装备"
local textItem = GUI:Text_Create(refined.ui.EquipShow_1,
"Text_EquipName",
0, 0,
14, "#ffffff",
equipName)
-- 设置文字居中
GUI:Text_setTextHorizontalAlignment(textItem, 1) -- 1表示居中
-- 如果有更多装备信息需要显示,可以继续添加其他控件
if refined.eqInfo[12].att_min and refined.eqInfo[12].att_max then
local attText = string.format("属性: %d-%d",
refined.eqInfo[12].att_min,
refined.eqInfo[12].att_max)
local textAtt = GUI:Text_Create(refined.ui.EquipShow_1,
"Text_EquipAtt",
0, -20,
12, "#00ff00",
attText)
GUI:Text_setTextHorizontalAlignment(textAtt, 1)
end
else
-- 没有装备时显示提示
local textEmpty = GUI:Text_Create(refined.ui.EquipShow_1,
"Text_Empty",
0, 0,
14, "#888888",
"暂无装备")
GUI:Text_setTextHorizontalAlignment(textEmpty, 1)
end
end
end
end
```
这样修改后,装备框会根据 `refined.eqInfo[12]` 的数据动态更新显示内容,包括装备名称和属性信息。如果数据中不包含装备信息,会显示"暂无装备"的提示。