local UIGuildDiary = UIViewClass() local EverydayID = 1 local LevelUp = 202 local levelDown = 203 local guildWar = 302 function UIGuildDiary:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title,Const_IDS.IDS_GuildLog) local options ={UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildEvent_All)} for i,v in DataSheetManager.GuildEventType:GetEnumerator() do table.insert(options,UIUtils.GetLocalizedTxt(Const_IDS[v.GuildEventType])) end UIUtils.DropdownAddOptions(self.Dropdown,options) MDL.Guild.GuildDynamicReq() self:RegistSystemEvent(EventID.UI_Guild_DiaryRefresh, self.OnDiaryRefresh) end local function TableSort(a,b) return a.createTime > b.createTime end function UIGuildDiary:OnDiaryRefresh(list) table.sort(list,TableSort) self.dataList = list for i,v in ipairs(list) do self.LoopScroll_Diary:AddData(v,0) end end function UIGuildDiary:ShowDiaryList(index) local list = {} if index == 0 then list = self.dataList else for i,v in ipairs(self.dataList) do local excelData = DataSheetManager.GuildEvent:GetDataByID(v.eventId) if excelData.EventType == index then table.insert(list,v) end end end self.LoopScroll_Diary:ClearCells() for i,v in ipairs(list) do self.LoopScroll_Diary:AddData(v,0) end end function UIGuildDiary:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGuildDiary:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIGuildDiary:OnValueChanged(comp, value) if comp == self.Dropdown then self:ShowDiaryList(value) end end function UIGuildDiary:OnCellInit(scrollRect, index, cellTable, data) if GameAppInfo.IsVietnamPackage() then cellTable.txt_Team.text = os.date(UTL.Time.FormatDateEnum.YMD, data.createTime) cellTable.txt_Date.text = os.date(UTL.Time.FormatDateEnum.HM, data.createTime) else cellTable.txt_Date.text = os.date(UTL.Time.FormatDateEnum.YMD, data.createTime) cellTable.txt_Team.text = os.date(UTL.Time.FormatDateEnum.HM, data.createTime) end local excelData = DataSheetManager.GuildEvent:GetDataByID(data.eventId) if data.eventId == EverydayID then cellTable.txt_Diary.text = self:GetDiaryStr(excelData.EventText,data.params) cellTable.img_Choose.gameObject:SetActive(true) elseif data.eventId == LevelUp or data.eventId == levelDown then local levelStr = CTL.Guild.GetGuildLevelStr(tonumber(data.params[1])) cellTable.txt_Diary.text = string.FormatByIdsId(Const_IDS[excelData.EventText], levelStr) cellTable.img_Choose.gameObject:SetActive(false) elseif data.eventId == guildWar then local guildWarData = DataSheetManager.GuildWarGroup:GetDataByID(tonumber(data.params[1])) local name = UTL.Color.FormatTextByColor(guildWarData.Color,UIUtils.GetLocalizedTxt(Const_IDS[guildWarData.GroupName])) local rank = UIUtils.GetLocalizedTxt(Const_IDS[data.params[2]]) cellTable.txt_Diary.text = string.FormatByIdsId(Const_IDS[excelData.EventText], name, rank , data.params[3]) cellTable.img_Choose.gameObject:SetActive(false) else local strs = {} for i, v in ipairs(data.params) do if string.match(v,"^IDS") and Const_IDS[v] then table.insert(strs, UIUtils.GetLocalizedTxt(Const_IDS[v])) else table.insert(strs, v) end end cellTable.txt_Diary.text = string.FormatByIdsId(Const_IDS[excelData.EventText], unpack(strs)) cellTable.img_Choose.gameObject:SetActive(false) end if index%2 == 0 then cellTable.img_Bg.gameObject:SetActive(false) cellTable.img_Bg01.gameObject:SetActive(true) else cellTable.img_Bg.gameObject:SetActive(true) cellTable.img_Bg01.gameObject:SetActive(false) end end function UIGuildDiary:GetDiaryStr(ids,params) --IDS_GuildEvent_DailyReport=每日简报:出勤人数%d,势力活跃%d,名望%d,物资%d,资金%d --这里需要减少增加颜色不一样 需要根据服务器发送的数据进行判断 return string.FormatByIdsId(Const_IDS[ids], params[1],params[2],self:GetColorStr(params[3]), self:GetColorStr(params[4]),self:GetColorStr(params[5])) end function UIGuildDiary:GetColorStr(param) local value = tonumber(param) if value >= 0 then return UTL.Color.FormatGreenColor("+"..value) else return UTL.Color.FormatRedColor(value) end end return UIGuildDiary