local UISlgGvETalentMain = UIViewClass() function UISlgGvETalentMain:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_SlgGve_Talent_Title) self:RegistSystemEvent(EventID.UI_SlgGvE_Talent_Update_Info, self.RefreshData) self:RegistSystemEvent(EventID.UI_SlgGvE_Material_Update_Info, self.RefreshData) self.curOfficalLv = MDL.SlgGvE.GetCurOfficalLv() self:RefreshUI() end function UISlgGvETalentMain:RefreshUI() local maxOfficalLv = CTL.SlgGvE.GetMaxOfficalLv() for i = 1, maxOfficalLv do self.loopScroll:AddData(i, 0) end local index = self.curOfficalLv - 2 < 0 and 0 or self.curOfficalLv - 2 self.loopScroll:MoveIndex(index) end function UISlgGvETalentMain:RefreshData() self.loopScroll:RefreshCells() end function UISlgGvETalentMain:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISlgGvETalentMain:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UISlgGvETalentMain:OnCellClicked(scrollRect, index, cellTable, target, data) for i, collection in ipairs(cellTable.talentGroup) do if target == collection.item_btn then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvETalentLvUp,{talentIndex = i, officailLv = data}) end end end function UISlgGvETalentMain:OnCellInit(scrollRect, index, cellTable, data) self:RefreshOfficialInfo(cellTable, data) local talentInfoList = MDL.SlgGvE.GetTalentInfoList(data) local talentInfoListCount = #talentInfoList for i = 1, 4 do if i > talentInfoListCount then UIUtils.SetActive(cellTable.talentGroup[i].gameObject, false) else UIUtils.SetActive(cellTable.talentGroup[i].gameObject, true) self:RefreshTalentInfo(cellTable.talentGroup[i], talentInfoList[i]) end end end function UISlgGvETalentMain:RefreshOfficialInfo(cellTable, officialLv) local config = DataSheetManager.SlgGvEOfficialLevel:GetDataByOfficialTitleLevel(officialLv) UIUtils.SetImageByAssetBundle(cellTable.curofficial_Icon, config.OfficialTitleIcon) local OfficialTitleName = UIUtils.GetLocalizedTxt(Const_IDS[config.OfficialTitleName]) if self.curOfficalLv >= officialLv then UIUtils.SetActive(cellTable.icon_mask, false) cellTable.txt_name.text = UTL.Color.FormatTextByColor("FFFFFF", OfficialTitleName) else UIUtils.SetActive(cellTable.icon_mask, true) cellTable.txt_name.text = UTL.Color.FormatTextByColor("B5B5B5", OfficialTitleName) end end function UISlgGvETalentMain:RefreshTalentInfo(collection, talentInfo) if talentInfo.talentCfg.GveTalentLevel > 0 then --已激活 if talentInfo.talentCfg.IsSpeTalentType == 1 then collection.txt_name.text = UIUtils.GetLocalizedTxt(Const_IDS[talentInfo.talentCfg.GveTalentName]) else collection.txt_name.text = UIUtils.GetLocalizedTxt(Const_IDS[talentInfo.talentCfg.GveTalentName]) end collection.state_bg:SetState(0) UIUtils.SetGray(collection.talent_Icon, false) else --未激活 collection.state_bg:SetState(1) UIUtils.SetGray(collection.talent_Icon, true) collection.txt_name.text = UIUtils.GetLocalizedTxt(Const_IDS[talentInfo.talentCfg.GveTalentName]) end local maxLv = CTL.SlgGvE.GetTalentGroupMaxLv(talentInfo.talentCfg.GveTalentGroupID) local str = string.FormatByIdsKey("IDS_BreakThrough_Lv", talentInfo.talentCfg.GveTalentLevel.."/"..maxLv) collection.txt_level.text = str UIUtils.SetImageByAssetBundle(collection.Icon_talent_bg, talentInfo.talentCfg.GveTalentColorBG) collection.item_btn:SetRedPoint(CTL.SlgGvE.IsCanUpTalent(talentInfo.talentCfg)) UIUtils.SetImageByAssetBundle(collection.talent_Icon, talentInfo.talentCfg.GveTalentIcon) end return UISlgGvETalentMain