local UIGoldenHeroBossFilter = UIViewClass() local LuaBit = require 'bit' local EventSystem = require('Event/EventSystem') function UIGoldenHeroBossFilter:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Button8) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.starList, self.sourceByte = CTL.GoldenHeroBoss.LoadFilterSetting(self.activityId) self.starDataList = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).SynergyBossScreenStar self:InitToggleSetup() end function UIGoldenHeroBossFilter:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGoldenHeroBossFilter:InitToggleSetup() --星级筛选初始化 for i = 1, #self.group_StarFilter do local starNum = self.starDataList[i] local toggle = self.group_StarFilter[i] UIUtils.SetActive(toggle, starNum and true or false) local starState = toggle:GetToggleComponent("group_Star") starState:SetState(starNum) toggle.isOn = table.containValue(self.starList, starNum) end --来源筛选初始化 self.toggle_Friend.isOn = CTL.GoldenHeroBoss.IsShareTypeInclude(self.sourceByte, MDL.GoldenHeroBoss.BossShare.ShareFriend) self.toggle_Guild.isOn = CTL.GoldenHeroBoss.IsShareTypeInclude(self.sourceByte, MDL.GoldenHeroBoss.BossShare.ShareGuild) self.toggle_World.isOn = CTL.GoldenHeroBoss.IsShareTypeInclude(self.sourceByte, MDL.GoldenHeroBoss.BossShare.ShareWorld) end function UIGoldenHeroBossFilter:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGoldenHeroBossFilter:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then if self:IsFilterSetupHasValue() then self:CloseView() end elseif comp == self.btn_Confirm then if self:IsFilterSetupHasValue() then CTL.GoldenHeroBoss.SaveFilterSettingByActivityId(self.activityId, self.starList, self.sourceByte) EventSystem.Dispatch(EventID.UI_GoldenHeroBoss_RefreshFilter) self:CloseView() end end end function UIGoldenHeroBossFilter:IsFilterSetupHasValue() if #self.starList == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Screen_Hint8) return false end if self.sourceByte == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Screen_Hint9) return false end return true end function UIGoldenHeroBossFilter:OnValueChanged(comp, value) if comp == self.toggle_Friend then self:DealSourceFilter(value, MDL.GoldenHeroBoss.BossShare.ShareFriend) elseif comp == self.toggle_Guild then self:DealSourceFilter(value, MDL.GoldenHeroBoss.BossShare.ShareGuild) elseif comp == self.toggle_World then self:DealSourceFilter(value, MDL.GoldenHeroBoss.BossShare.ShareWorld) else for i, v in ipairs(self.group_StarFilter) do if comp == v then local starNum = self.starDataList[i] if comp.isOn then if not table.containValue(self.starList, starNum) then table.insert(self.starList, starNum) end else table.removebyvalue(self.starList, starNum) end end end end end function UIGoldenHeroBossFilter:DealSourceFilter(value, type) if value then self.sourceByte = LuaBit.bor(self.sourceByte, type) else self.sourceByte = LuaBit.bxor(self.sourceByte, type) end end return UIGoldenHeroBossFilter