-- 恩怨簿 local UIRivalRecord = UIViewClass() local rival_opt_pb = require("Proto/rival_opt_pb") -- 使用枚举维护显示(防止出现 获取不到MapId的情况,需要动态维护添加新功能时需要维护这个dic) local RivalRecordDesc = { DescWorldBoss = rival_opt_pb.DescWorldBoss, DescAddAsCommonRival = rival_opt_pb.DescAddAsCommonRival, DescAddAsSwornRival = rival_opt_pb.DescAddAsSwornRival, DescCountryWorldBoss = rival_opt_pb.DescWarZoneBoss, DescEscort = rival_opt_pb.DescEscort, DescCountryPvp = rival_opt_pb.DescCountryPvp, } local RivalFuncNameIDS = { [RivalRecordDesc.DescWorldBoss] = Const_IDS.IDS_ActivityName_WorldBoss, [RivalRecordDesc.DescCountryWorldBoss] = Const_IDS.IDS_ActivityName_WarZoneBoss, [RivalRecordDesc.DescEscort] = Const_IDS.IDS_Escort_FunctionName, [RivalRecordDesc.DescCountryPvp] = Const_IDS.IDS_CountryPVP_Title,--国战PVP } local RivalRecordDescIDS = { -- 由自己触发的,如:将其添加为仇敌 [true] = { [RivalRecordDesc.DescAddAsCommonRival] = Const_IDS.IDS_Rival_AddRivalDesc1, [RivalRecordDesc.DescAddAsSwornRival] = Const_IDS.IDS_Rival_AddEnemyDesc1, [RivalRecordDesc.DescEscort] = Const_IDS.IDS_Escort_Enemy1, }, -- 由他人触发的,如:将你添加为仇敌 [false] = { [RivalRecordDesc.DescAddAsCommonRival] = Const_IDS.IDS_Rival_AddRivalDesc2, [RivalRecordDesc.DescAddAsSwornRival] = Const_IDS.IDS_Rival_AddEnemyDesc2, [RivalRecordDesc.DescEscort] = Const_IDS.IDS_Escort_Enemy2, }, } -------------------- function UIRivalRecord:OnCreated() self.curToggleTab = 0 self.recordList = {} self.recordBeKilledLimit = DataSheetManager.ConstData:GetDataByID("RivalKilledLogNumLimit").IntValue self.recordKillLLimit = DataSheetManager.ConstData:GetDataByID("RivalKillLogNumLimit").IntValue self.recordAddLimit = DataSheetManager.ConstData:GetDataByID("RivalAddLogNumLimit").IntValue end function UIRivalRecord:OnOpened(context) self:RegistSystemEvent(EventID.UI_Rival_RefreshRecord, self.OnRefreshRecordLoop) self:RegistSystemEvent(EventID.UI_Rival_RequestRecord, self.OnRequestRecord) UTL.Toggle.InitToggleGroupByIDS(self.toggle_TopGroup, "txt", { Const_IDS.IDS_Rival_Killed, Const_IDS.IDS_Rival_Kill, Const_IDS.IDS_Rival_Record }) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_Rival_HistoryLog) self.toggle_TopGroup:SelectIndex(0) end function UIRivalRecord:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIRivalRecord:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIRivalRecord:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Messages then local playerInfo = data.PlayerShowInfo -- 设置头像 CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHeadTempate, playerInfo.PortraitId, playerInfo.FrameId, nil, playerInfo.acid) UIUtils.SetActive(cellTable.server_Info, playerInfo.IsCross) cellTable.txt_ServerID.text = CTL.CrossServer.GetServerShowStr(playerInfo.ShowServerId) -- 设置名字、势力、事件描述、事件时间 UIUtils.SetLabel(cellTable.txt_PlayerName, playerInfo.name) UIUtils.SetLabel(cellTable.txt_GuildName, playerInfo.guildName) UIUtils.SetLabel(cellTable.txt_Time, UTL.Time.FormatTimeCompletely(data.TimeStamp)) -- 是否为新(此版本不处理新老消息) UIUtils.SetActive(cellTable.img_New, false) if data.Identity == MDL.Rival.RivalInfoPageIdentity.Stranger then cellTable.obj_StateSwitch:SetState(0) UIUtils.SetActive(cellTable.img_Enemy, false) UIUtils.SetActive(cellTable.img_EnemyBg, false) elseif data.Identity == MDL.Rival.RivalInfoPageIdentity.CommonEnemy then cellTable.obj_StateSwitch:SetState(1) UIUtils.SetActive(cellTable.img_Enemy, false) UIUtils.SetActive(cellTable.img_EnemyBg, false) UIUtils.SetLabel(cellTable.txt_Hostility, string.FormatByIdsId(Const_IDS.IDS_Rival_ValueOfHatred, data.Hatred)) elseif data.Identity == MDL.Rival.RivalInfoPageIdentity.SwornEnemy then cellTable.obj_StateSwitch:SetState(2) UIUtils.SetActive(cellTable.img_Enemy, true) UIUtils.SetActive(cellTable.img_EnemyBg, true) UIUtils.SetLabel(cellTable.txt_Hostility_High, string.FormatByIdsId(Const_IDS.IDS_Rival_ValueOfHatred, data.Hatred)) end if self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoBeKilled then cellTable.obj_StateContent:SetState(1) local funcName = UIUtils.GetLocalizedTxt(RivalFuncNameIDS[data.Desc]) UIUtils.SetLabel(cellTable.txt_Content, string.FormatByIdsId(Const_IDS.IDS_Rival_KilledDesc, funcName, data.Times)) elseif self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoKill then cellTable.obj_StateContent:SetState(1) local funcName = UIUtils.GetLocalizedTxt(RivalFuncNameIDS[data.Desc]) UIUtils.SetLabel(cellTable.txt_Content, string.FormatByIdsId(Const_IDS.IDS_Rival_KillDesc, funcName, data.Times)) elseif self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoRecord then local descIDS = RivalRecordDescIDS[data.IsOrigin] if data.Desc == RivalRecordDesc.DescAddAsSwornRival then UIUtils.SetLabelText(cellTable.txt_Content_Hight, descIDS[data.Desc]) cellTable.obj_StateContent:SetState(0) else cellTable.obj_StateContent:SetState(1) UIUtils.SetLabelText(cellTable.txt_Content, descIDS[data.Desc]) end end end end function UIRivalRecord:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Messages then if target == cellTable.Btn_Add then MDL.Rival.RivalOperationRequest(data.PlayerShowInfo.acid, MDL.Rival.RivalOperationType.RivalOptCommonEnemy) elseif target == cellTable.UIHeroHeadTempate.img_PlayerAvatarBg then CTL.PlayerInteract.OpenFriendInteractView(data.PlayerShowInfo.acid) end end end function UIRivalRecord:OnValueChanged(comp, index) if comp == self.toggle_TopGroup then self.curToggleTab = index + 1 -- 设置条数上限提示 if self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoBeKilled then UIUtils.SetLabel(self.lab_Remind, string.FormatByIdsId(Const_IDS.IDS_Rival_ShowRecordNum, self.recordBeKilledLimit)) elseif self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoKill then UIUtils.SetLabel(self.lab_Remind, string.FormatByIdsId(Const_IDS.IDS_Rival_ShowRecordNum, self.recordKillLLimit)) elseif self.curToggleTab == MDL.Rival.RivalInfoType.RivalInfoRecord then UIUtils.SetLabel(self.lab_Remind, string.FormatByIdsId(Const_IDS.IDS_Rival_ShowRecordNum, self.recordAddLimit)) end MDL.Rival.GetRivalHistoryInfoRequest(self.curToggleTab) end end -------------------- function UIRivalRecord:OnRefreshRecordLoop() local msgCount = 1 for _, v in MDL.Rival.GetRivalRecordIteratorByType(self.curToggleTab) do self.recordList[msgCount] = v msgCount = msgCount + 1 end for i = #self.recordList, msgCount, -1 do table.remove(self.recordList, i) end if #self.recordList == 0 then UIUtils.SetActive(self.loop_Messages, false) UIUtils.SetActive(self.img_Empty, true) else UIUtils.SetActive(self.loop_Messages, true) UIUtils.SetActive(self.img_Empty, false) self.loop_Messages:MoveBegin() self.loop_Messages:ReloadAll(self.recordList) end end function UIRivalRecord:OnRequestRecord() MDL.Rival.GetRivalHistoryInfoRequest(self.curToggleTab) end return UIRivalRecord