local UITreasureInfoView = UIViewClass() function UITreasureInfoView:OnOpened(context) local activeInfo = MDL.Treasure.GetTreasureInfo(context.treasureId) local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(context.treasureId) local baseAttrTable = treasureData.Attr_Table --图标和名字 UIUtils.SetLabelText(self.txt_ItemName, Const_IDS[treasureData.TreasureName]) UIUtils.SetImageByAssetBundle(self.img_TreasureIcon, treasureData.TreasureIcon) if self.loop_TreasureInfoAttr.Count > 0 then self.loop_TreasureInfoAttr:ClearCells() end if activeInfo then --战力 self.txt_CE.text = activeInfo.TreasureInfo.gs --属性 self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_8"}, 0) for i = 1, #activeInfo.TreasureInfo.attr.attrs do local attrNum = activeInfo.TreasureInfo.attr.attrs[i] if attrNum > 0 then self.loop_TreasureInfoAttr:AddData({AttrType = i, AttrNum = attrNum}, 1) end end --突破属性 local isHasBreak = false for i = 1, #activeInfo.TreasureInfo.attr.attrs do local num = baseAttrTable[i] and activeInfo.TreasureInfo.attr.attrs[i] - baseAttrTable[i].AttrNum or activeInfo.TreasureInfo.attr.attrs[i] if num > 0 then if not isHasBreak then self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_9"}, 0) isHasBreak = true end self.loop_TreasureInfoAttr:AddData({AttrType = i, AttrNum = num}, 1) end end --基础属性 self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_10"}, 0) for i = 1, #baseAttrTable do self.loop_TreasureInfoAttr:AddData({AttrType = baseAttrTable[i].AttrType, AttrNum = baseAttrTable[i].AttrNum}, 1) end else --战力 local fight = UTL.Attr.CalculateFight(baseAttrTable) self.txt_CE.text = fight self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_10"}, 0) --属性 for i = 1, #baseAttrTable do self.loop_TreasureInfoAttr:AddData({AttrType = baseAttrTable[i].AttrType, AttrNum = baseAttrTable[i].AttrNum}, 1) end end end function UITreasureInfoView:OnButtonClicked(comp) if comp == self.btn_Bottom or comp == self.btn_Close then self:CloseView() end end function UITreasureInfoView:OnCellInit(scrollRect, index, cellTable, data) if data.IDS then UIUtils.SetLabelText(cellTable.txt_CellTitle, Const_IDS[data.IDS]) else UTL.Attr.SetAttrItemByCompName(cellTable, data.AttrType, data.AttrNum, true) end end return UITreasureInfoView