local UIEquipmentCommon = require "View/Equipment/UIEquipmentCommon" local UIEquipmentBase = UIViewClass(UIEquipmentCommon) local resonance_info = require 'Proto/resonance_info_pb' --已穿戴>未穿戴,已穿戴的装备按照战力从高到低排序,未穿戴的装备按照可更换-可洗练-可替换洗练的排序,同级按照装备战力排序 local function SortRule(a, b) if a.ActionFlag == b.ActionFlag then local fight_1 = a.ClientEquipmentFight local fight_2 = b.ClientEquipmentFight if fight_1 == fight_2 then return a.ItemData.Color > b.ItemData.Color else return fight_1 > fight_2 end else return a.ActionFlag < b.ActionFlag end end function UIEquipmentBase:OnOpened() self.cancelSelect = false self.sortedEquipInfos = {} self:RegistSystemEvent(EventID.UI_CloseEquipBagTips, self.OnCloseEquipBagTips) -- 一键洗炼显示 UIUtils.SetActive(self.group_RefineSet.gameObject, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.EquipmentQuickRefine)) end function UIEquipmentBase:UpdateEquipShow() CTL.Equipment.UpdateSpecificTypeEquipList(self.equipInfo, self.equipType, self.sortedEquipInfos) table.sort(self.sortedEquipInfos, SortRule) local isOn = MDL.Player.Get_TypeState(MDL.Player.WearViewToggleStateType.EquipWear) if isOn == self.toggle_Hide.isOn then self:LoadCellData(isOn) else self.toggle_Hide.isOn = isOn end local isEquipRed = false for _, v in ipairs(self.sortedEquipInfos) do if v.ActionFlag == CTL.Equipment.EquipActionFlag.Replace or v.ActionFlag == CTL.Equipment.EquipActionFlag.Equip then isEquipRed = true break end end if isEquipRed == false then isEquipRed = CTL.Equipment.CheckEquipIfWear(self.heroId) end self.btn_OneKeyEquip:SetRedPoint(isEquipRed) end --选中装备的逻辑 function UIEquipmentBase:RefreshEquipInfo(equipInfo, heroId, equipType) self.heroId = heroId self.equipType = equipType self.equipInfo = equipInfo UIUtils.SetLabelText(self.txt_Title, MDL.Equipment.EquipTypeNameIDS[self.equipType]) self:UpdateEquipShow() end function UIEquipmentBase:OnCloseEquipBagTips() self.cancelSelect = true if self.selectIndex ~= nil then self.loopScroll_Equip:UpdateIndex(self.selectIndex) end self.selectIndex = nil self.selectCell = nil self.cancelSelect = false end function UIEquipmentBase:OnValueChanged(comp, state) if comp == self.toggle_Hide then self:LoadCellData(state) MDL.Player.Set_TypeState(MDL.Player.WearViewToggleStateType.EquipWear, state) end end function UIEquipmentBase:LoadCellData(isShowEquipped) CTL.Equipment.SetEquipmentIteratorData(self.sortedEquipInfos, isShowEquipped) CSExt.CSFunc_ReloadAll(self.loopScroll_Equip, CTL.Equipment.EnumEquipmentIterator) local index = CTL.Equipment.GetEnumIndex() UIUtils.SetActive(self.group_Empty, index == 0) end function UIEquipmentBase:OnCellInit(scrollRect, index, cellTable, data) CTL.Equipment.SetEquipShow(cellTable.img_Equip, cellTable.img_quality, data.ItemData) UIUtils.SetActive(cellTable.bg_Head, false) UIUtils.SetActive(cellTable.btn_Locked, MDL.HeroSelect.GetTeamLevel() < data.EquipData.EquipLevel) if self.cancelSelect then UIUtils.SetActive(cellTable.sprite_Select,false) end if data.ActionFlag == CTL.Equipment.EquipActionFlag.HasEquipped then local heroId = MDL.Equipment.GetEquipHeroId(data.ID) UIUtils.SetActive(cellTable.bg_Head, true) UTL.Item.SetHeroIconByHeroId(cellTable.img_PlayerHead, heroId, MDL.HeroAwaken.GetIsHeroAwaken(heroId)) UIUtils.SetActive(cellTable.group_Warning, false) else if data.ActionFlag == CTL.Equipment.EquipActionFlag.ReplaceRefine or data.ActionFlag == CTL.Equipment.EquipActionFlag.None then UIUtils.SetActive(cellTable.group_Warning, false) else UIUtils.SetActive(cellTable.group_Warning, true) if data.ActionFlag == CTL.Equipment.EquipActionFlag.Replace then cellTable.group_Warning:SetState(1) elseif data.ActionFlag == CTL.Equipment.EquipActionFlag.Equip then cellTable.group_Warning:SetState(2) elseif data.ActionFlag == CTL.Equipment.EquipActionFlag.Refine then cellTable.group_Warning:SetState(0) end end end CTL.Equipment.SetEquipmentStage(cellTable.txt_EquipStageNum, data.ItemData.ID, false) end function UIEquipmentBase:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Click then if self.selectCell ~= nil then UIUtils.SetActive(self.selectCell.sprite_Select,false) end UIUtils.SetActive(cellTable.sprite_Select,true) self.selectCell = cellTable self.selectIndex = index CTL.Equipment.OpenBagTips(self.heroId, self.equipType, data, self.equipInfo) end end --设置共鸣类型 function UIEquipmentBase:SetResonanceLvType() self.resonanceLvType = resonance_info.Equip_Quality end function UIEquipmentBase:OnButtonClicked(comp) if comp == self.btn_Resonance then self:OnResonanceLvClick() elseif comp == self.btn_OneKeyEquip then MDL.Equipment.EquipQuickWearReq() elseif comp == self.btn_Reborn then CTL.Reborn.OpenRebornView() elseif comp == self.btn_RefineSet then UIManager.OpenView(Const_UI_Lua.UIEnum.UIEquipmentRefineSetting) elseif comp == self.btn_OneKeyRefine then if MDL.Equipment.GetQuickRefineConfirmFlag() then UTL.MessageBox.ShowOKCancelToggleBox( nil, Const_IDS["IDS_EquipRefine_QuickTips1"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_EquipRefine_QuickTips2"]), -- 确认回调 MDL.Equipment.EquipQuickRefineReq, -- 勾选回调 MDL.Equipment.SetQuickRefineConfirmFlag ) else MDL.Equipment.EquipQuickRefineReq() end end end return UIEquipmentBase