local UITreasureSoulCrystalAdvancedSuccess = UIViewClass() -------------------- --[[ 参数说明 id ——> 表示当前选中的魂晶id beforeData = { beforeCfgId ——> 升阶前魂晶CfgId beforeBaseAttrList ——> 升阶前魂晶基础属性 } --]] function UITreasureSoulCrystalAdvancedSuccess:OnOpened(context) self:RegistSystemEvent(EventID.TreasureSoulCrystal_RefreshAdvancedSuccess, self.InitPanel) UIUtils.SetLabelText(self.UITemplatePopUpZero.txt_Title, Const_IDS.IDS_TreasureSoul_ShengJieChengGong) self.beforeSoulData = DataSheetManager.TreasureSoulCrystalData:GetDataByCrystalID(self.context.beforeData.beforeCfgId) self.soulInfo = MDL.Treasure.GetSoulCrystalById(context.id) self:InitPanel(context) end function UITreasureSoulCrystalAdvancedSuccess:OnButtonClicked(comp) if comp == self.UITemplatePopUpZero.Bottom then self:CloseView() end end function UITreasureSoulCrystalAdvancedSuccess:OnCellInit(scrollRect, index, cellTable, data) -- 设置属性名字 local attrData = DataSheetManager.AttrData:GetDataByID(data.AttrType) local str = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) -- 定义一个str变量 用于字符串的记录 UIUtils.SetLabel(cellTable.lab_Attr, CTL.Treasure.GetQualityStrByPercentBlockId(str, data.PercentBlockId)) -- 设置属性值 和 百分比 local basicAttrWeight if scrollRect == self.Loop_SCTipsAfter then if self:IsNewAttr(index, data.AttrType) then cellTable.effect_Attr:PlayUIEffect() else cellTable.effect_Attr:StopUIEffect() end basicAttrWeight = CTL.Treasure.GetBasicAttrWeight(self.soulInfo.soulData.SoulID, self.soulInfo.soulData.Color, data.AttrType) elseif scrollRect == self.Loop_SCTipsBefore then basicAttrWeight = CTL.Treasure.GetBasicAttrWeight(self.beforeSoulData.SoulID, self.beforeSoulData.Color, data.AttrType) end -- 设置属性值 和 百分比 if basicAttrWeight then UIUtils.SetLabel(cellTable.txt_Attr, CTL.Treasure.GetQualityStrByPercentBlockId(data.AttrNum, data.PercentBlockId)) -- 百分比保留小数点后一位,保留方式 四舍五入 local percentage = (data.AttrNum / basicAttrWeight.AttrMaxNum) * 1000 percentage = math.floor(percentage + 0.5) / 10 str = string.format("(%s%%)", percentage) UIUtils.SetLabel(cellTable.txt_Percentage, CTL.Treasure.GetQualityStrByPercentBlockId(str, data.PercentBlockId)) end end -------------------- function UITreasureSoulCrystalAdvancedSuccess:InitPanel(context) self.context = context -- 设置升阶之前的魂晶状态 UTL.Item.ItemSquareIcon(self.img_AvatarBefore, nil, self.context.beforeData.beforeCfgId) UTL.Color.SetQualityImageByType(self.img_AvatarBeforeBg, self.beforeSoulData.Color, UTL.Color.QualityType.Square) -- 设置升阶之前的属性 self.Loop_SCTipsBefore:ReloadAll(self.context.beforeData.beforeBaseAttrList) -- 设置升阶之后的魂晶状态 UTL.Item.ItemSquareIcon(self.img_AvatarAfter, nil, self.soulInfo.cfgId) UTL.Color.SetQualityImageByType(self.img_AvatarAfterBg, self.soulInfo.soulData.Color, UTL.Color.QualityType.Square) -- 设置升阶之后的属性 self.Loop_SCTipsAfter:ReloadAll(self.soulInfo.baseAttrList) end function UITreasureSoulCrystalAdvancedSuccess:IsNewAttr(index, attrType) -- C#中从0开始 local attrData = self.context.beforeData.beforeBaseAttrList[index + 1] -- C#中从0开始 if attrData and attrData.AttrType == attrType then return false else return true end end return UITreasureSoulCrystalAdvancedSuccess