local UITownBuffTips = UIViewClass() function UITownBuffTips:OnOpened(context) UIUtils.SetActive(self.rect_Close, true) self:RegistSystemEvent(EventID.UI_UpdateBuff_Town, self.UpdateTownBuff) self:UpdateTownBuff() end function UITownBuffTips:UpdateTownBuff() local buffList = MDL.HomeMain.GetBuffList() if buffList and #buffList > 0 then self.loop_BuffInfo:ReloadAll(buffList) else self:CloseView() end end function UITownBuffTips:OnCellInit(scrollRect, index, cellTable, data) local capitalBuffData = DataSheetManager.CapitalBuffData:GetDataByRelateID(data.caBuffId) local buffData = DataSheetManager.BuffData:GetDataByBuffID(capitalBuffData.BuffID) UIUtils.SetImageByAssetBundle(cellTable.img_Buff, buffData.BuffIcon) UIUtils.SetLabelText(cellTable.txt_BuffName, Const_IDS[buffData.BuffName]) if string.isNilOrEmpty(data.optName) then cellTable.txt_Source.text = nil else --增益绿色,否则为红色 local playerName if buffData.GainType == LuaConst.EBuffGainType.BAD then playerName = UTL.Color.FormatRedColor(data.optName) elseif buffData.GainType == LuaConst.EBuffGainType.GOOD then playerName = UTL.Color.FormatGreenColor(data.optName) end cellTable.txt_Source.text = string.FormatByIdsId(Const_IDS.IDS_OfficialPrivilege_UseForYou, playerName) end local offset = data.endTime - UTL.Time.GetServerTimestamp() if offset > 0 then if buffData.GainType == LuaConst.EBuffGainType.BAD then local dayStr = UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)) local hourStr = UTL.Color.FormatRedColor("{0}:{1}:{2}") local minStr = UTL.Color.FormatRedColor("{0}:{1}") cellTable.timer_Buff:SetDHMSStr(dayStr, hourStr, minStr, minStr) elseif buffData.GainType == LuaConst.EBuffGainType.GOOD then local dayStr = UTL.Color.FormatGreenColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)) local hourStr = UTL.Color.FormatGreenColor("{0}:{1}:{2}") local minStr = UTL.Color.FormatGreenColor("{0}:{1}") cellTable.timer_Buff:SetDHMSStr(dayStr, hourStr, minStr, minStr) end cellTable.timer_Buff:ResetAndBeginCustomTimer(false, offset, 0, nil) else cellTable.timer_Buff:EndTimer() end cellTable.sprite_CDMask:ResetCDMask() cellTable.sprite_CDMask:EndTimer() cellTable.lab_FloorNum.text = nil UIUtils.SetLabel(cellTable.txt_BuffInfo, UTL.String.FormatCombineTextByID(buffData.BuffDescribe)) end function UITownBuffTips:OnButtonClicked(comp) if comp == self.rect_Close then self:CloseView() end end return UITownBuffTips