-- 仇敌界面 local UIRivalBase = UIViewClass() local rival_opt_pb = require("Proto/rival_opt_pb") local SettingOptType = { SetRival = MDL.Rival.RivalOperationType.RivalOptSwornEnemy, -- 设置死敌 RelieveRival = MDL.Rival.RivalOperationType.RivalOptCommonEnemy, -- 解除死敌(就是设置为仇敌) DelRival = MDL.Rival.RivalOperationType.RivalOptRemoveList, -- 删除仇敌 } local SettingOptIds = { [SettingOptType.SetRival] = Const_IDS.IDS_Rival_AddEnemy, [SettingOptType.RelieveRival] = Const_IDS.IDS_Rival_DeleteEnemy, [SettingOptType.DelRival] = Const_IDS.IDS_Rival_DeleteRival, } -------------------- function UIRivalBase:OnCreated() self.highlightRivalValue = DataSheetManager.ConstData:GetDataByID("HighlightRivalValue").IntValue end function UIRivalBase:OnOpened(context) -- 仇人列表也算好友一环 self:RegistSystemEvent(EventID.UI_UpdateFriendInfo, self.OnRefreshRivalLoop) MDL.Friend.SendRefreshRivalInfos() end function UIRivalBase:OnButtonClicked(comp) if comp == self.event_Record then UIManager.OpenView(Const_UI_Lua.UIEnum.UIRivalRecord) elseif comp == self.event_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UIRivalSetting) elseif comp == self.event_LoopSettingClick then UIUtils.SetActive(self.event_LoopSettingClick, false) end end function UIRivalBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Enemies then -- 设置玩家头像、名字、军团 CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHeadTempate, data.portraitId, data.frameId, nil, data.acid) UIUtils.SetLabel(cellTable.txt_EnemyName, data.name) UIUtils.SetLabel(cellTable.txt_GuildName, data.guildName) -- 玩家区服 UIUtils.SetActive(cellTable.server_Info, data.isCross) cellTable.txt_ServerID.text = CTL.CrossServer.GetServerShowStr(data.showServerId) -- 是否是死敌 UIUtils.SetActive(cellTable.img_EnemyBg, data.isSwornEnemy) -- 仇恨关系 死敌配置高亮显示 if data.isSwornEnemy then cellTable.obj_RivalState:SetState(1) UIUtils.SetLabel(cellTable.txt_Hostility_High, string.FormatByIdsId(Const_IDS.IDS_Rival_ValueOfHatred, data.hatred)) else cellTable.obj_RivalState:SetState(0) UIUtils.SetLabel(cellTable.txt_Hostility, string.FormatByIdsId(Const_IDS.IDS_Rival_ValueOfHatred, data.hatred)) end -- 获取国战状态 local curStage = MDL.Country.GetCurStage() local countryInfo = MDL.Country.GetMyGuildInfo() -- 显示当前状态 if not data.isOnline then -- 不在线 UIUtils.SetLabelText(cellTable.txt_Line, Const_IDS.IDS_Achievement_Share_FriendOffline) cellTable.obj_PlayerState:SetState(1) elseif MDL.Guild.IsSameGuild(data.guildID) then -- 属于同一势力 UIUtils.SetLabelText(cellTable.txt_Line, Const_IDS.IDS_Rival_SameGuildDesc) cellTable.obj_PlayerState:SetState(1) elseif MDL.Guild.IsHasGuild() and countryInfo and countryInfo.country > 0 and -- 自身有势力 and 自身势力所属拥有所属国家 curStage ~= nil and curStage >= MDL.Country.Stage.CountryBuild and -- 当前阶段不为空 and 处于开启阶段 MDL.Country.GetMyCountryId() == data.CountryId then -- 自身所属国家与对方相同 UIUtils.SetLabelText(cellTable.txt_Line, Const_IDS.IDS_Rival_SameCountryDesc) cellTable.obj_PlayerState:SetState(1) else cellTable.obj_PlayerState:SetState(0) local locationDesc, canTracking = CTL.Rival.GetLocationDescByBattleInfo(data) UIUtils.SetLabel(cellTable.txt_Line, locationDesc) cellTable.btn_Tracking:SetGray(not canTracking, true) UIUtils.SetGray(cellTable.img_Tracking, not canTracking) cellTable.obj_TrackingState:SetState(canTracking and 0 or 1) end elseif scrollRect == self.loop_Setting then UIUtils.SetLabelText(cellTable.txt_Button, SettingOptIds[data.optType]) local state = data.optType == SettingOptType.SetRival and 0 or 1 cellTable.obj_State:SetState(state) end end function UIRivalBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Enemies then if target == cellTable.btn_Chat then -- 是黑名单 跳转 黑名单 if MDL.Friend.IsPlayerBlack(data.acid) then CTL.Friend.OpenFriendPanel(CTL.Friend.MainIndex.Main, MDL.Friend.ListType.Black, data.acid) else -- 不是则跳转私聊 CTL.Friend.PrivateTalkToAcid(data.acid) end elseif target == cellTable.btn_Tracking then local _, canTracking = CTL.Rival.GetLocationDescByBattleInfo(data) if canTracking then MDL.WorldBoss.SendGotoRivalMsg(data.syncBattleSubID, data.syncBattleGRoomID, data.acid) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Rival_IncorrectTeleMap) end elseif target == cellTable.btn_Setting then -- 显示位置调整 local tfp = cellTable.obj_posTag.transform.position self.loop_Setting.transform:SetPosition(tfp.x, tfp.y, nil) UIUtils.SetActive(self.event_LoopSettingClick, true) -- 操作调整 if data.isSwornEnemy then local opt = { { optType = SettingOptType.RelieveRival, acid = data.acid, name = data.name }, { optType = SettingOptType.DelRival, acid = data.acid, name = data.name }, } self.loop_Setting:ReloadAll(opt) else local opt = { { optType = SettingOptType.SetRival, acid = data.acid, name = data.name }, { optType = SettingOptType.DelRival, acid = data.acid, name = data.name }, } self.loop_Setting:ReloadAll(opt) end elseif target == cellTable.UIHeroHeadTempate.img_PlayerAvatarBg then CTL.PlayerInteract.OpenFriendInteractView(data.acid) end elseif scrollRect == self.loop_Setting then if target == cellTable.cell.transform then self:ConfirmRivalOperation(data.name, data.acid, data.optType) UIUtils.SetActive(self.event_LoopSettingClick, false) end end end -------------------- function UIRivalBase:OnRefreshRivalLoop() local rivalList = MDL.Friend.GetSortedList(MDL.Friend.ListType.Rival) if #rivalList == 0 then UIUtils.SetActive(self.img_Empty, true) UIUtils.SetActive(self.loop_Enemies, false) else UIUtils.SetActive(self.img_Empty, false) UIUtils.SetActive(self.loop_Enemies, true) self.loop_Enemies:ReloadAll(rivalList) end end function UIRivalBase:ConfirmRivalOperation(name, acid, optType) local contextStr = "" if optType == SettingOptType.SetRival then contextStr = string.FormatByIdsId(Const_IDS.IDS_Rival_AddEnemyConfirmDesc, name) elseif optType == SettingOptType.RelieveRival then contextStr = string.FormatByIdsId(Const_IDS.IDS_Rival_DeleteEnemyConfirmDesc, name) elseif optType == SettingOptType.DelRival then contextStr = string.FormatByIdsId(Const_IDS.IDS_Rival_DeleteRivalConfirmDesc, name) end UTL.MessageBox.ShowOKCancelBox( "", contextStr, function() MDL.Rival.RivalOperationRequest(acid, optType) end ) end return UIRivalBase