local UIHorseSoulGachaHeartWish = UIViewClass() function UIHorseSoulGachaHeartWish:OnOpened(context) self.curWishType = context.wishType self.selectedFirstTab = -1 self.selectCell = {} self.curWishInfo = MDL.HorseSoul.GetSelectWishInfo(self.curWishType) self.curSoulID = self.curWishInfo and self.curWishInfo.wishSoulID or 0 self.wishData = DataSheetManager.HorseSoulDrawWish:GetDataByWishID(self.curWishType) UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS[self.wishData.WishTitle]) for i, suitID in ipairs(self.wishData.WishSoulSuit) do self.UICommonPopUpTab.loop_Tab:AddData(suitID, 0) end self.UICommonPopUpTab.loop_Tab:SelectIndex(0) local colorName if self.curWishType == 1 then colorName = UIUtils.GetLocalizedTxt(Const_IDS.IDS_QualityColor_Red) else colorName = UIUtils.GetLocalizedTxt(Const_IDS.IDS_QualityColor_Gold) end UIUtils.SetLabel(self.txt_Tips, string.FormatByIdsId(Const_IDS.IDS_HorseSoul_DrawHint15, colorName, colorName)) end function UIHorseSoulGachaHeartWish:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() else for i, soulCell in ipairs(self.group_HorseSoul) do if comp == soulCell.event_Click then if self.selectCell then UIUtils.SetActive(self.selectCell.img_Select, false) end if self.soulList[i].ID == self.curSoulID then UIUtils.SetActive(self.selectCell.img_Select, false) UIUtils.SetActive(soulCell.img_Select, false) self.curSoulID = 0 self.selectCell = nil MDL.HorseSoul.SoulDrawWishOptReq(MDL.HorseSoul.HorseSoulWishOpt.Cancel, self.curWishType, 0) else -- 选择心愿魂珠 UIUtils.SetActive(soulCell.img_Select, true) self.curSoulID = self.soulList[i].ID self.selectCell = soulCell MDL.HorseSoul.SoulDrawWishOptReq(MDL.HorseSoul.HorseSoulWishOpt.Wish, self.curWishType, self.soulList[i].ID) end end end end end function UIHorseSoulGachaHeartWish:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then UIUtils.SetActive(cellTable.img_Selected, self.selectedFirstTab == data) UIUtils.SetActive(cellTable.img_UnSelected, self.selectedFirstTab ~= data) UIUtils.SetActive(cellTable.group_HorseSoulSuit_Normal, true) UIUtils.SetActive(cellTable.group_HorseSoulSuit_Selected, true) local suitData = DataSheetManager.HorseSoulSuitData:GetDataByHorseSoulSuitID_HorseSoulSkillLevel(data, 1) UIUtils.SetLabelText(cellTable.txt_HorseSoulSuit_Normal, Const_IDS[suitData.HorseSoulSuitName]) UIUtils.SetLabelText(cellTable.txt_HorseSoulSuit_Selected, Const_IDS[suitData.HorseSoulSuitName]) UTL.Item.SetAtlasSprite(cellTable.img_HorseSoulSuit_Normal, "UI_Horse", suitData.HorseSoulSuitIcon) UTL.Item.SetAtlasSprite(cellTable.img_HorseSoulSuit_Selected, "UI_Horse", suitData.HorseSoulSuitIcon) UIUtils.SetActive(cellTable.img_Arrow, false) UIUtils.SetActive(cellTable.img_ArrowS, false) UIUtils.SetActive(cellTable.img_RedDot, false) UIUtils.SetActive(cellTable.group_SignState, false) UIUtils.SetActive(cellTable.group_SignStateS, false) end end function UIHorseSoulGachaHeartWish:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then local isRefresh = self.selectedFirstTab ~= index if isRefresh then self:ShowSuit(data) end end end function UIHorseSoulGachaHeartWish:ShowSuit(suitID) self.selectedFirstTab = -1 self.selectCell = {} self.soulList = {} for _,v in DataSheetManager.HorseSoulData:GetEnumerator() do if v.HorseSoulSuitID == suitID then local itemData = DataSheetManager.ItemData:GetDataByID(v.HorseSoulID) if itemData.Color == self.wishData.WishSoulQuality then table.insert(self.soulList, itemData) end end end for i, soulCell in ipairs(self.group_HorseSoul) do local itemID = self.soulList[i].ID UTL.Item.SetItemIcon(soulCell.ico_item, itemID) UIUtils.SetLabel(soulCell.txt_Name, UTL.Item.GetItemColorName(itemID)) local horseSoulData = DataSheetManager.HorseSoulData:GetDataByHorseSoulID(itemID) CTL.HorseSoul.SetPositionImage(soulCell.img_Pos, horseSoulData.HorseSoulPositionID) local itemData = DataSheetManager.ItemData:GetDataByID(itemID) UTL.Color.SetQualityImageByType(soulCell.img_BG, itemData.Color, UTL.Color.QualityType.FormationHorseTreasureEquipBg) UIUtils.SetActive(soulCell.img_Select, self.curSoulID == itemID) if self.curSoulID == itemID then self.selectCell = soulCell end UIUtils.SetActive(soulCell.group_Star.gameObject, itemData.Color >= LuaConst.QualityColor.Gold) if itemData.Color >= LuaConst.QualityColor.Gold then CTL.HorseSoul.SetStarLevel(soulCell.group_Star, 0) end end end return UIHorseSoulGachaHeartWish