local UIGachaSummary = UIViewClass() local FirstTabType = { Probability = 1, Detail = 2, Record = 3 } local SecondTabType = { Hero = 21, Item = 22 } local ProbabilityCellType = { SheetTitle = 1, ProbabilityTitle = 2, ProbabilityContent = 3, Detail = 4, } local ProbabilityIndex = { [1] = "First", [2] = "Second", [3] = "Third", [4] = "Fourth", [5] = "Fifth", [6] = "Sixth", } local EternalTabs = { [FirstTabType.Probability] = "IDS_DrawCard_Button_Probability", [FirstTabType.Detail] = "IDS_DrawCard_Button_Detail", [FirstTabType.Record] = "IDS_DrawCard_Button_History" } local EternalSecondTabs = { [FirstTabType.Detail] = {count = 2, tabs = {[SecondTabType.Hero] = "IDS_Type_Hero", [SecondTabType.Item] = "IDS_DrawCard_PageTitle_Item"}} } local LimitTabs = { [FirstTabType.Probability] = "IDS_DrawCard_Button_Probability", [FirstTabType.Detail] = "IDS_DrawCard_Button_Detail", [FirstTabType.Record] = "IDS_DrawCard_Button_History" } local DrawCardShowHistoryNum = DataSheetManager.ConstData:GetDataByID("DrawCardShowHistoryNum").IntValue -- 主页签ID转换子页签系数 local FirstToSecondChangeNum = 10 local SignificantNumber = 3 local DOWN_ARROW_IMAGE = "cjdw_icon_03" local UP_ARROW_IMAGE = "cjdw_icon_04" -------------------------- 系统函数 ----------------------------- function UIGachaSummary:OnOpened(context) self:RegistSystemEvent(EventID.UI_GachaShop_RefreshSummaryRecords, self.RefreshRecords) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.isRequestRecords = false self.drawCardType = context.drawCardType self.activityId = context.activityId self.activityType = context.activityType self.drawCardPoolId = context.drawCardPoolId self.firstGoldHeroReprintCellIndex = 0 UIUtils.SetLabel(self.group_Record.txt_RecentHistory, string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_DrawCard_Tip_RecentHistory"]), DrawCardShowHistoryNum)) UIUtils.SetLabel(self.UICommonPopUpTab.txt_Title, CTL.ActivityGacha.GetGachatTitleName(self.drawCardPoolId)) if GameAppInfo.IsJapanesePackage() and not (self.activityType and self.activityType == MDL.OperationActivity.ActivityType.SuperGold) then self:InitJapanProbability() else self.group_Probability:ClearCells() self.group_Probability:AddData({type = ProbabilityCellType.Detail}, 3) end self.showTabs = self.drawCardType == CTL.DrawCard.DrawCardType.Eternal and EternalTabs or LimitTabs self.showSecondTabs = EternalSecondTabs self.selectedFirstTab = context.selectedFirstTab or FirstTabType.Probability self.selectedSecondTab = context.selectedSecondTab or ((self.showSecondTabs and self.showSecondTabs[self.selectedFirstTab]) and self.selectedFirstTab * FirstToSecondChangeNum + 1 or -1) self.tabExtendState = {} for i, firstTab in ipairs (self.showTabs) do self.UICommonPopUpTab.loop_Tab:AddData(i, 0) if self.showSecondTabs and self.showSecondTabs[i] then self.tabExtendState[i] = false if context.selectedFirstTab and context.selectedFirstTab == i then self.tabExtendState[i] = true for i = i * FirstToSecondChangeNum + 1, i * FirstToSecondChangeNum + self.showSecondTabs[i].count do self.UICommonPopUpTab.loop_Tab:AddData(i, 1) end end end end self:RefreshShowInfo(true) end function UIGachaSummary:InitJapanProbability() self.group_Probability:AddData({type = ProbabilityCellType.Detail}, 3) --普通抽卡列少和金将抽卡用不一样的cell local titleCellIndex = self.activityType and 1 or 4 local dataCellIndex = self.activityType and 2 or 5 self.group_Probability:AddData({title = "IDS_JP_Probability_Probability1", type = ProbabilityCellType.SheetTitle}, 0) self.group_Probability:AddData({type = ProbabilityCellType.ProbabilityTitle}, titleCellIndex) for i, v in DataSheetManager.GoldHeroAllProbabilityShow:GetDataByID_RowID(self.drawCardPoolId) do self.group_Probability:AddData({data = v, type = ProbabilityCellType.ProbabilityContent, isHeroShow = false}, dataCellIndex) end self.group_Probability:AddData({title = "IDS_JP_Probability_Probability2", type = ProbabilityCellType.SheetTitle}, 0) self.group_Probability:AddData({type = ProbabilityCellType.ProbabilityTitle}, titleCellIndex) for i, v in DataSheetManager.GoldHeroShow:GetDataByID_RowID(self.drawCardPoolId) do self.group_Probability:AddData({data = v, type = ProbabilityCellType.ProbabilityContent, isHeroShow = true}, dataCellIndex) end end function UIGachaSummary:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGachaSummary:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end function UIGachaSummary:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() end end function UIGachaSummary:OnClosed() self.context.selectedFirstTab = self.selectedFirstTab self.context.selectedSecondTab = self.selectedSecondTab end function UIGachaSummary:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then if self.showTabs[data] then UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS[self.showTabs[data]]) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS[self.showTabs[data]]) UIUtils.SetActive(cellTable.img_Selected, self.selectedFirstTab == data) UIUtils.SetActive(cellTable.img_UnSelected, self.selectedFirstTab ~= data) UIUtils.SetActive(cellTable.img_RedDot, false) UIUtils.SetActive(cellTable.group_SignState, false) UIUtils.SetActive(cellTable.group_SignStateS, false) local isShowArrow = self.showSecondTabs and self.showSecondTabs[data] ~= nil or false UIUtils.SetActive(cellTable.img_Arrow, isShowArrow) UIUtils.SetActive(cellTable.img_ArrowS, isShowArrow) UTL.Item.SetAtlasSprite(cellTable.img_Arrow, "UI_CommonNew", self.tabExtendState[data] and UP_ARROW_IMAGE or DOWN_ARROW_IMAGE) UTL.Item.SetAtlasSprite(cellTable.img_ArrowS, "UI_CommonNew", self.tabExtendState[data] and UP_ARROW_IMAGE or DOWN_ARROW_IMAGE) else local tabs = self.showSecondTabs[math.floor(data / FirstToSecondChangeNum)].tabs UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS[tabs[data]]) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS[tabs[data]]) UIUtils.SetActive(cellTable.img_Selected, self.selectedSecondTab == data) UIUtils.SetActive(cellTable.img_UnSelected, self.selectedSecondTab ~= data) UIUtils.SetActive(cellTable.img_RedDot, false) end elseif scrollRect == self.group_Record.loop_Record then UIUtils.SetLabel(cellTable.txt_Time, data.timeStr) local itemData = DataSheetManager.ItemData:GetDataByID(data.itemData.id) local name = UTL.Item.GetItemDataSpliceByType(data.itemData.id).Name if itemData.FirstType == LuaConst.ItemType.HeroFragment and itemData.SecondType == LuaConst.ItemHeroType.Hero then UIUtils.SetLabel(cellTable.txt_Name, UTL.Color.FormatQualityText(name, itemData.Color)) else UIUtils.SetLabel(cellTable.txt_Name, name) end UTL.Item.SetItemCell(cellTable.item, data.itemData.id, data.itemData.nums) elseif scrollRect == self.group_Hero.loop_Hero then local kingdomData = DataSheetManager.HeroCountry:GetDataByID(data[1].Kingdom) UIUtils.SetLabelText(cellTable.lab, Const_IDS[kingdomData.Name]) for i, heroData in ipairs (data) do local contentItem = cellTable.Content[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.group_Hero.cell_Hero.gameObject) end UTL.Color.SetQualityImageByType(contentItem.img_Qua, heroData.HeroQuality, UTL.Color.QualityType.HeroSelectBg) UTL.Item.SetHeroIconByHeroId(contentItem.img_Hero, heroData.ID) UIUtils.SetLabel(contentItem.txt_Name, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]), heroData.HeroQuality)) UIUtils.SetActive(contentItem.gameObject, true) UIUtils.SetLabel(contentItem.txt_Num, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Equip_Talent) .. heroData.HeroIntelligence) UTL.Color.SetQualityImageByType(contentItem.img_QuaDec, heroData.HeroQuality, UTL.Color.QualityType.CharacterUIFrame) end elseif scrollRect == self.group_Item.loop_Item then local qualityData = DataSheetManager.QualityColor:GetDataByID(data[1].Quality ~= 0 and data[1].Quality or data[1].Color) local qualityStr = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[qualityData.ColorText]), qualityData.ID) UIUtils.SetLabel(cellTable.lab, qualityStr) for i, itemData in ipairs (data) do local contentItem = cellTable.Content[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.group_Item.cell_Item.gameObject) end UTL.Item.SetItemCell(contentItem, itemData.ID) end for i = #data + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end elseif scrollRect == self.group_Probability then if data.type == ProbabilityCellType.SheetTitle then UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[data.title]) elseif data.type == ProbabilityCellType.ProbabilityTitle then local drawCardData = DataSheetManager.DrawCardData:GetDataByID(self.drawCardPoolId) for i, v in ipairs(cellTable.group_Title) do local columnData = DataSheetManager.ProbabilityShowColumn:GetDataByColumnTypeID_ID(drawCardData.ShowColumnType, i) if columnData then UIUtils.SetLabelText(v, Const_IDS[columnData.ColumnDes]) UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end elseif data.type == ProbabilityCellType.ProbabilityContent then cellTable.state_Bg:SetState(index % 2) local sheetData = data.data if data.isHeroShow then if self.activityType == MDL.OperationActivity.ActivityType.GoldHeroReprint then if self.firstGoldHeroReprintCellIndex == 0 then self.firstGoldHeroReprintCellIndex = index end local heroCount = MDL.OperationActivity.GoldHeroReprintShowHero:GetDataLengthByActivityID(self.activityId) if index < heroCount + self.firstGoldHeroReprintCellIndex then local heroID = MDL.OperationActivity.GoldHeroReprintShowHero:GetDataByActivityID_OrderID(self.activityId, index - self.firstGoldHeroReprintCellIndex + 1).HeroShowID UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS["IDS_Probability_GoldHero_"..heroID]) else UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[sheetData.ProbabilityShowDes]) end else UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[sheetData.ProbabilityShowDes]) end else UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[sheetData.ProbabilityShowDes]) end local probabilityTable = sheetData.Column_Table for i, v in ipairs(cellTable.group_Title) do if probabilityTable[i] then v.text = UTL.Attr.FormatNumberToPercentage(probabilityTable[i].ColumnShow, SignificantNumber) UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end elseif data.type == ProbabilityCellType.Detail then if self.activityType == MDL.OperationActivity.ActivityType.GoldHeroReprint then cellTable.txt_GachaDetail.text = CTL.GoldHeroReprint.GetGachaDetailInfo(self.drawCardPoolId) else cellTable.txt_GachaDetail.text = CTL.ActivityGacha.GetGachaDetailInfo(self.drawCardPoolId) end end end end function UIGachaSummary:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then if self.showTabs[data] then local isRefresh = self.selectedFirstTab ~= data if isRefresh then if self.showSecondTabs and self.showSecondTabs[self.selectedFirstTab] and self.tabExtendState[self.selectedFirstTab] then local formerIndex = 0 for i, firstTab in ipairs (self.showTabs) do if i == self.selectedFirstTab then formerIndex = i - 1 break end end local removeIndex = formerIndex + self.showSecondTabs[self.selectedFirstTab].count while (removeIndex > formerIndex) do self.UICommonPopUpTab.loop_Tab:RemoveIndex(removeIndex) removeIndex = removeIndex - 1 end self.tabExtendState[self.selectedFirstTab] = false CTL.Sound.PlayGameSound("UI_fold") end self.selectedFirstTab = data self.selectedSecondTab = -1 end if self.showSecondTabs and self.showSecondTabs[data] then self.selectedSecondTab = self.selectedSecondTab == -1 and data * FirstToSecondChangeNum + 1 or self.selectedSecondTab if self.tabExtendState[data] then local removeIndex = index + self.showSecondTabs[data].count while (removeIndex > index) do self.UICommonPopUpTab.loop_Tab:RemoveIndex(removeIndex) removeIndex = removeIndex - 1 end CTL.Sound.PlayGameSound("UI_fold") else local insertIndex = index + 1 for i = data * FirstToSecondChangeNum + 1, data * FirstToSecondChangeNum + self.showSecondTabs[data].count do self.UICommonPopUpTab.loop_Tab:InsertData(insertIndex, i, 1) insertIndex = insertIndex + 1 end CTL.Sound.PlayGameSound("UI_expand") end self.tabExtendState[data] = not self.tabExtendState[data] end self.UICommonPopUpTab.loop_Tab:RefreshCells(false) self:RefreshShowInfo(isRefresh) else if self.selectedSecondTab ~= data then self.selectedFirstTab = math.floor(data / FirstToSecondChangeNum) self.selectedSecondTab = data self:RefreshShowInfo(true) end self.UICommonPopUpTab.loop_Tab:RefreshCells(false) end elseif scrollRect == self.group_Record.loop_Record then if cellTable.item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.itemData.id) end elseif scrollRect == self.group_Hero.loop_Hero then elseif scrollRect == self.group_Item.loop_Item then for i = 1, #cellTable.Content do if cellTable.Content[i].event_Click == target then UTL.ItemTips.ShowCommonTipsById(data[i].ID) self.context.selectedItemID = data[i].ID break end end end end ---------------------------------------------------------------- function UIGachaSummary:RefreshShowInfo(isRefresh) if not isRefresh then return end local isHasSecondTabs = self.showSecondTabs ~= nil UIUtils.SetActive(self.group_Probability, self.selectedFirstTab == FirstTabType.Probability) UIUtils.SetActive(self.group_Record.gameObject, self.selectedFirstTab == FirstTabType.Record) UIUtils.SetActive(self.group_Item.gameObject, (isHasSecondTabs and self.selectedSecondTab == SecondTabType.Item) or (not isHasSecondTabs and self.selectedFirstTab == FirstTabType.Detail)) UIUtils.SetActive(self.group_Hero.gameObject, isHasSecondTabs and self.selectedSecondTab == SecondTabType.Hero) if self.selectedFirstTab == FirstTabType.Record then if self.group_Record.loop_Record.Count == 0 then if self.drawCardType == CTL.DrawCard.DrawCardType.Eternal then local recordCount = 0 local historyDatas = MDL.DrawCard.GetHistoryData(self.drawCardPoolId) for i = #historyDatas, 1, -1 do local hData = historyDatas[i] local timeStr = os.date(UTL.Time.FormatDateEnum.YMDHMS, hData.time) for _, itemData in ipairs(hData.drawRewardInfo) do if recordCount > DrawCardShowHistoryNum then break end self.group_Record.loop_Record:AddData({timeStr = timeStr, itemData = itemData}, 0) recordCount = recordCount + 1 end if recordCount > DrawCardShowHistoryNum then break end end UIUtils.SetActive(self.group_Record.group_Empty, self.group_Record.loop_Record.Count == 0) else if not self.isRequestRecords then self.isRequestRecords = true MDL.ActivityGacha.RequestActivityGetDrawHistory(self.activityId, self.activityType) else self:RefreshRecords() end end end else if self.selectedSecondTab == SecondTabType.Hero then if self.group_Hero.loop_Hero.Count == 0 then for _, v in DataSheetManager.HeroCountry:GetEnumerator() do local heroDatas = {} if self.activityType == MDL.OperationActivity.ActivityType.GoldHeroReprint then heroDatas = CTL.GoldHeroReprint.GetReprintHeroDatas(self.drawCardPoolId, v.ID) else heroDatas = CTL.ActivityGacha.GetHeroDatas(self.drawCardPoolId, v.ID) end if #heroDatas > 0 then self.group_Hero.loop_Hero:AddData(heroDatas, 0) end end end elseif self.selectedSecondTab == SecondTabType.Item or self.selectedFirstTab == FirstTabType.Detail then if self.group_Item.loop_Item.Count == 0 then local itemData = self.context.selectedItemID and DataSheetManager.ItemData:GetDataByID(self.context.selectedItemID) or nil local quality = nil if itemData then quality = itemData.Color end local index = 0 for i = DataSheetManager.QualityColor:GetDataCount(), 1, -1 do local itemDatas = {} if self.activityType == MDL.OperationActivity.ActivityType.GoldHeroReprint then itemDatas = CTL.GoldHeroReprint.GetReprintItemDatas(self.drawCardPoolId, i) else itemDatas = CTL.ActivityGacha.GetItemDatas(self.drawCardPoolId, i) end if itemDatas and #itemDatas > 0 then self.group_Item.loop_Item:AddData(itemDatas, 0) if quality and quality == i then self.group_Item.loop_Item:MoveIndex(index) end index = index + 1 end end if self.context.selectedItemID then UTL.ItemTips.ShowCommonTipsById(self.context.selectedItemID) self.context.selectedItemID = nil end end end end end function UIGachaSummary:RefreshRecords() if self.group_Record.gameObject.activeSelf then local recordCount = 0 for _, v in ipairs (MDL.ActivityGacha.GetActivityDrawHistory(self.activityId)) do local timeStr = os.date(UTL.Time.FormatDateEnum.YMDHMS, v.time) for _, rewardInfo in ipairs(v.drawRewardInfo) do if recordCount > DrawCardShowHistoryNum then break end self.group_Record.loop_Record:AddData({timeStr = timeStr, itemData = rewardInfo}, 0) recordCount = recordCount + 1 end if recordCount > DrawCardShowHistoryNum then break end end UIUtils.SetActive(self.group_Record.group_Empty, self.group_Record.loop_Record.Count == 0) end end return UIGachaSummary