local UIHeroDetailProperties = UIViewClass() local CellType = { Title = 0, Attr = 1, } local BaseAttrIndex = 3 local ShowAttrIndex = 13 --[[ context参数 showHeroId 武将ID ]] function UIHeroDetailProperties:OnOpened(context) local heroId = context.showHeroId local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) local heroGS = MDL.HeroSelect.GetHeroGs(heroId) local heroName = heroData.NameIDS UTL.Item.ItemSquareIconByHeroId(heroId, self.sprite_Player, self.sprite_border, self.labLocal_Name, MDL.HeroAwaken.GetIsHeroAwaken(heroId)) UIUtils.SetLabel(self.Txt_Gs, heroGS) self:SetHeroProperties(heroId) end function UIHeroDetailProperties:OnButtonClicked(comp) if comp == self.Close or comp == self.Bottom then self:CloseView() end end function UIHeroDetailProperties:SetHeroProperties(id) local totalAttrList = MDL.HeroDetail.GetAttrDataFromSheet(MDL.HeroDetail.GetTotalAttr(id)) local teamAttrList = MDL.HeroDetail.GetTeamAttr() -- 基础属性 self.LoopScroll_Properties:AddData({cellType = CellType.Title, label = "IDS_BaseAttr"}, 0) self.LoopScroll_Properties:AddData({cellType = CellType.Attr, totalAttrList = totalAttrList, attrType = "HeroAttrShowBasic"}, 1) -- 高级属性 self.LoopScroll_Properties:AddData({cellType = CellType.Title, label = "IDS_AdvanceAttr"}, 0) self.LoopScroll_Properties:AddData({cellType = CellType.Attr, totalAttrList = totalAttrList, attrType = "HeroAttrShowAdvanced"}, 1) -- 特殊属性 self.LoopScroll_Properties:AddData({cellType = CellType.Title, label = "IDS_BreakThrough_SpecialAttr"}, 0) self.LoopScroll_Properties:AddData({cellType = CellType.Attr, totalAttrList = totalAttrList, attrType = "HeroAttrShowSpecial"}, 1) end function UIHeroDetailProperties:OnCellInit(scrollRect, index, cellTable, data) if data.cellType == CellType.Title then UIUtils.SetLabel(cellTable.lab_Title, UIUtils.GetLocalizedTxt(Const_IDS[data.label])) return else local attrIDList = DataSheetManager.ConstData:GetDataByID(data.attrType).IntListValue for k,v in ipairs(attrIDList) do local contentItem = cellTable.Content[k] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.group_Attr.gameObject) end UIUtils.SetLabel(contentItem.lab_Name, UIUtils.GetLocalizedTxt(Const_IDS[data.totalAttrList[v].Name])) UIUtils.SetLabel(contentItem.txt_Present, UTL.Attr.GetAttrStrById(v,data.totalAttrList[v].Value)) UIUtils.SetActive(contentItem.gameObject, true) end if #attrIDList < #cellTable.Content then for i = #attrIDList + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end end end UIUtils.SetActive(cellTable.Content.gameObject, true) end function UIHeroDetailProperties:OnCellClicked(scrollRect, index, cellTable, target, data) if data.cellType == CellType.Attr then local attrIDList = DataSheetManager.ConstData:GetDataByID(data.attrType).IntListValue for i, v in ipairs(cellTable.Content) do if target == v.btn_Clicked then if GameAppInfo.IsVietnamPackage() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = v.btn_Clicked, posType = LuaConst.DescriptionPanelType.Cebter, offsetX = -220, text = Const_IDS[data.totalAttrList[attrIDList[i]].AttrDesc] }) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = v.btn_Clicked, posType = LuaConst.DescriptionPanelType.RightLower, offsetX = -220, text = Const_IDS[data.totalAttrList[attrIDList[i]].AttrDesc] }) end break end end end end return UIHeroDetailProperties