local UIPetReproductionShoutPopUp = UIViewClass() local ChannelIDS = { [MDL.ChannelChat.ChannelCfgId.World] = Const_IDS.IDS_Chat_WorldChannelBtn, [MDL.ChannelChat.ChannelCfgId.Legion] = Const_IDS.IDS_Shout_Guild, [MDL.ChannelChat.ChannelCfgId.WarZone] = Const_IDS.IDS_WarZone_FuncInfo_Part1_1, } function UIPetReproductionShoutPopUp:OnOpened(context) self:InitCurrentChannel() self:InitPetInfo(context.petUniqId) self:UpdateBtnCD() end function UIPetReproductionShoutPopUp:InitCurrentChannel() if CTL.WarZone.IsWarZoneOpen() then self.channelList = { MDL.ChannelChat.ChannelCfgId.World, MDL.ChannelChat.ChannelCfgId.Legion, MDL.ChannelChat.ChannelCfgId.WarZone, } else self.channelList = { MDL.ChannelChat.ChannelCfgId.World, MDL.ChannelChat.ChannelCfgId.Legion, } end UIUtils.SetLabelText(self.Placeholder, Const_IDS.IDS_Pet_LookForMate) self.loop_Tab:ReloadAll(self.channelList) self.loop_Tab:SelectIndex(0) end function UIPetReproductionShoutPopUp:InitPetInfo(petUniqId) local petData = MDL.Pet.GetActiveInfo(petUniqId) self.lab_MyPetInfo.text = string.FormatByIdsId(Const_IDS.IDS_Pet_MyPet, petData.Info.petPedigree, UIUtils.GetLocalizedTxt(Const_IDS[petData.Config.PetName])) .. ":" end function UIPetReproductionShoutPopUp:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetActive(cellTable.img_Selected, self.selectChannel == data) UIUtils.SetLabelText(cellTable.txt_Name, ChannelIDS[data]) end function UIPetReproductionShoutPopUp:OnCellClicked(scrollRect, index, cellTable, target, data) self.selectChannel = data self:OnFoldMenu(false) end function UIPetReproductionShoutPopUp:OnFoldMenu(isOut) if isOut then UIUtils.SetActive(self.group_RecastSecondTab, true) self.state_Arrow:SetState(1) self.loop_Tab:RefreshCells(false) else UIUtils.SetActive(self.group_RecastSecondTab, false) self.state_Arrow:SetState(0) UIUtils.SetLabelText(self.txt_Name, ChannelIDS[self.selectChannel]) end end function UIPetReproductionShoutPopUp:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIPetReproductionShoutPopUp:OnButtonClicked(comp) if comp == self.btn_Close or comp == self.btn_2 then self:CloseView() elseif comp == self.img_Selected then self:OnFoldMenu(true) elseif comp == self.btn_CloseTab then self:OnFoldMenu(false) elseif comp == self.btn_1 then local cdTime = CTL.Pet.GetShutTimeCD() if cdTime > 0 then return end if self.selectChannel == MDL.ChannelChat.ChannelCfgId.Legion then if MDL.Guild.IsHasGuild() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_ConditionLegion) return end end if self.selectChannel == MDL.ChannelChat.ChannelCfgId.WarZone then if CTL.WarZone.IsWarZoneOpen() == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarZoneBoss_ZhanQuWeiKaiQi) return end end local content = self.obj_InputField.text if string.isNilOrEmpty(content) or content == UIUtils.GetLocalizedTxt(Const_IDS.IDS_Pet_LookForMate) then --如果是默认文本,考虑到本地化,传IDS content = "IDS_Pet_LookForMate" end local petData = MDL.Pet.GetActiveInfo(self.context.petUniqId) if CTL.Pet.ShutBreedMsg(self.selectChannel, content, petData.Info.petPedigree, petData.Config.ID) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Team_CallInfoSendToChannel"]) end self:UpdateBtnCD() end end function UIPetReproductionShoutPopUp:UpdateBtnCD() local cdTime = CTL.Pet.GetShutTimeCD() if cdTime > 0 then self.btn_1:SetGray(true) self.timer_Refresh:ResetAndBeginCustomTimer(false, cdTime, 0, "({0}s)", 1) self:StartRepeatFunc(self.UpdateBtnCD, cdTime, 1) else self.btn_1:SetGray(false) self.timer_Refresh:EndTimer() self:StopRepeatFunc(self.UpdateBtnCD) end end return UIPetReproductionShoutPopUp