local UIGuildWarRewardIntroduction = UIViewClass() local LeftTabTypes = { {IDS = "IDS_GuildWar_GuildReward", TipIDS = "IDS_GuildWar_GuildRewardIntro"}, {IDS = "IDS_GuildWar_ResultReward", DesIDS = "IDS_GuildWar_ResultRewardIntroTip", TipIDS = "IDS_GuildWar_ResultRewardIntro"}, {IDS = "IDS_GuildWar_BattleReward", DesIDS = "IDS_GuildWar_BattleRewardIntroTip", TipIDS = "IDS_GuildWar_BattleRewardIntro"}, {IDS = "IDS_GuildWar_ContributionReward", TipIDS = "IDS_GuildWar_ContributionRewardIntro"}, } -------------------------------- 系统函数 ------------------------------- function UIGuildWarRewardIntroduction:OnOpened() self.selectLeftTab = 1 self.selectRightTab = 0 self.isGuildWarCrossServer = CTL.GuildWar.IsCrossServerSettled() for i = 1, #LeftTabTypes do self.Loop_Introduction_RewardTypes:AddData(LeftTabTypes[i], 0) end self.toggle_TopGroup:SelectIndex(self.selectRightTab) self:RefreshPanel() end function UIGuildWarRewardIntroduction:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildWarRewardIntroduction:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.group_Search then local leftTabCfg = LeftTabTypes[self.selectLeftTab] if leftTabCfg.DesIDS then if self.selectLeftTab == 2 or self.selectLeftTab == 3 then local str = string.FormatByIdsId(Const_IDS[leftTabCfg.DesIDS], DataSheetManager.ConstData:GetDataByID("GuildWarPlayerRewardScoreLimit").IntValue) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{target = self.group_Search, posType = LuaConst.DescriptionPanelType.Center, text = str}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{target = self.group_Search, posType = LuaConst.DescriptionPanelType.Center, text = UIUtils.GetLocalizedTxt(Const_IDS[leftTabCfg.DesIDS])}) end end end end function UIGuildWarRewardIntroduction:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Loop_Introduction_RewardTypes then UIUtils.SetLabelText(cellTable.txt_RewardName, Const_IDS[data.IDS]) local isSelected = self.selectLeftTab == index + 1 UIUtils.SetActive(cellTable.img_BackgroundFrame_Selected, isSelected) cellTable.UIState_Title:SetState(isSelected and 1 or 0) elseif scrollRect == self.loop_Introduction_RewardRank then UIUtils.SetActive(cellTable.img_RewardBackground_Bright, index % 2 == 0) UIUtils.SetActive(cellTable.img_RewardBackground_Dark, index % 2 ~= 0) if self.selectLeftTab == 1 then self:SetGuildRewardCell(cellTable, data, index) elseif self.selectLeftTab == 2 then self:SetBattleGoalRewardCell(cellTable, data, index) elseif self.selectLeftTab == 3 then self:SetParticipationRewardCell(cellTable, data, index) elseif self.selectLeftTab == 4 then self:SetContributionRewardCell(cellTable, data, index) end end end function UIGuildWarRewardIntroduction:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.Loop_Introduction_RewardTypes then if self.selectLeftTab ~= index + 1 then local formerLeftTab = self.selectLeftTab self.selectLeftTab = index + 1 self.Loop_Introduction_RewardTypes:UpdateIndex(formerLeftTab - 1) self.Loop_Introduction_RewardTypes:UpdateIndex(self.selectLeftTab - 1) self.toggle_TopGroup:SelectIndex(self.selectRightTab) self:RefreshPanel() end elseif scrollRect == self.loop_Introduction_RewardRank then for i, v in ipairs (cellTable.ItemContent) do if target == cellTable.ItemContent[i].item.event_Click then UTL.ItemTips.ShowCommonTipsById(CTL.GuildAuction.LvBuItemToSuperGoldenHeroItem(data[i].ItemID)) break end end end end function UIGuildWarRewardIntroduction:OnValueChanged(comp, value) if comp == self.toggle_TopGroup then if self.selectRightTab ~= value then self.selectRightTab = value self:RefreshPanel() end end end -------------------------------------------------------------------------- function UIGuildWarRewardIntroduction:RefreshPanel() local leftTabCfg = LeftTabTypes[self.selectLeftTab] UIUtils.SetActive(self.group_Search, leftTabCfg.DesIDS ~= nil) if not string.isNilOrEmpty(leftTabCfg.TipIDS) then if self.selectLeftTab == 4 then local str = string.FormatByIdsId(Const_IDS[leftTabCfg.TipIDS], DataSheetManager.ConstData:GetDataByID("GuildWarPlayerRewardScoreLimit").IntValue) UIUtils.SetLabel(self.txt_SystemIntroduction, str) else UIUtils.SetLabelText(self.txt_SystemIntroduction, Const_IDS[leftTabCfg.TipIDS]) end else UIUtils.SetLabel(self.txt_SystemIntroduction, nil) end self.loop_Introduction_RewardRank:ClearCells() if self.selectLeftTab == 1 then self:ShowGuildReward(self.loop_Introduction_RewardRank, self.section_Empty) elseif self.selectLeftTab == 2 then self:ShowBattleGoalReward(self.loop_Introduction_RewardRank, self.section_Empty) elseif self.selectLeftTab == 3 then self:ShowParticipationReward(self.loop_Introduction_RewardRank) elseif self.selectLeftTab == 4 then self:ShowContributionReward(self.loop_Introduction_RewardRank) end UIUtils.SetActive(self.section_Empty, self.loop_Introduction_RewardRank.Count == 0) end -- 显示势力奖 function UIGuildWarRewardIntroduction:ShowGuildReward(rewardLoopScroll) for i = 1, 4 do local rankRewardCfg = nil local success = false if self.isGuildWarCrossServer then success, rankRewardCfg = DataSheetManager.GuildWarRankRewardCrossServer:TryGetDataByID_Rank(self.selectRightTab + 1, i) else success, rankRewardCfg = DataSheetManager.GuildWarRankReward:TryGetDataByID_Rank(self.selectRightTab + 1, i) end if rankRewardCfg then -- 名望 local itemTable = {{ItemID = 8, ItemNum = rankRewardCfg.GuildReputation, isAuction = false}} if rankRewardCfg.RewardPoolID then local poolList = MDL.GuildAuction.GetAuctionRewardsShowList(rankRewardCfg.RewardPoolID, LuaConst.ActivityType.GuildWar) for _, v in ipairs(poolList) do table.insert(itemTable, v) end end rewardLoopScroll:AddData(itemTable, 0) end end end function UIGuildWarRewardIntroduction:SetGuildRewardCell(cellTable, data, index) self:HandleRewardTitle(cellTable, index) self:HandleItemTable(cellTable, data) end -- 显示战绩奖 function UIGuildWarRewardIntroduction:ShowBattleGoalReward(rewardLoopScroll) for i = 1, 4 do local rankRewardCfg if self.isGuildWarCrossServer then local _, data = DataSheetManager.GuildWarRankRewardCrossServer:TryGetDataByID_Rank(self.selectRightTab + 1, i) rankRewardCfg = data else local _, data = DataSheetManager.GuildWarRankReward:TryGetDataByID_Rank(self.selectRightTab + 1, i) rankRewardCfg = data end if rankRewardCfg then local rewardCfg = DataSheetManager.GuildWarMilitaryExploitsReward:GetDataByID(rankRewardCfg.MilitaryExploitsReward) if rewardCfg then rewardLoopScroll:AddData(rewardCfg.Item_Table, 0) else break end end end end function UIGuildWarRewardIntroduction:SetBattleGoalRewardCell(cellTable, data, index) self:HandleRewardTitle(cellTable, index) self:HandleItemTable(cellTable, data) end function UIGuildWarRewardIntroduction:HandleRewardTitle(cellTable, index) if self.selectRightTab ~= 4 then UIUtils.SetLabel(cellTable.txt_Rank, nil) UIUtils.SetActive(cellTable.img_trophy, true) if index == 0 then UTL.Item.SetAtlasSprite(cellTable.img_trophy, "UI_GuildWar", "slz_1_icon") elseif index == 1 then UTL.Item.SetAtlasSprite(cellTable.img_trophy, "UI_GuildWar", "slz_2_icon") elseif index == 2 then UTL.Item.SetAtlasSprite(cellTable.img_trophy, "UI_GuildWar", "slz_3_icon") elseif index == 3 then UTL.Item.SetAtlasSprite(cellTable.img_trophy, "UI_GuildWar", "slz_4_icon") end else UIUtils.SetActive(cellTable.img_trophy, false) if index == 0 then UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS["IDS_GuildWar_Win2"]) elseif index == 1 then UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS["IDS_GuildWar_Win1"]) elseif index == 2 then UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS["IDS_GuildWar_Win0"]) end end end -- 显示参与奖 function UIGuildWarRewardIntroduction:ShowParticipationReward(rewardLoopScroll) local cfg = self.isGuildWarCrossServer and DataSheetManager.GuildWarGroupCrossServer:GetDataByID(self.selectRightTab + 1) or DataSheetManager.GuildWarGroup:GetDataByID(self.selectRightTab + 1) if not cfg then return end for i = 1, 2 do if i == 1 then local rewardCfg = DataSheetManager.GuildWarSigleVictoryReward:GetDataByID(cfg.AttendVictoryReward) rewardLoopScroll:AddData(rewardCfg.Item_Table, 0) else local rewardCfg = DataSheetManager.GuildWarSigleFailedReward:GetDataByID(cfg.AttendFailedReward) rewardLoopScroll:AddData(rewardCfg.Item_Table, 0) end end end function UIGuildWarRewardIntroduction:SetParticipationRewardCell(cellTable, data, index) UIUtils.SetActive(cellTable.img_trophy, false) UIUtils.SetLabelText(cellTable.txt_Rank, index == 0 and Const_IDS["IDS_GuildWar_Win"] or Const_IDS["IDS_GuildWar_Lose"]) self:HandleItemTable(cellTable, data) end -- 显示贡献奖 function UIGuildWarRewardIntroduction:ShowContributionReward(rewardLoopScroll) local cfg = self.isGuildWarCrossServer and DataSheetManager.GuildWarGroupCrossServer:GetDataByID(self.selectRightTab + 1) or DataSheetManager.GuildWarGroup:GetDataByID(self.selectRightTab + 1) if not cfg then return end for i = 1, #cfg.AttributionReward do local rewardId = cfg.AttributionReward[i] self.attributionRewardIDS = cfg.AttributionRewardIDS local rewardCfg = DataSheetManager.GuildWarAttributionReward:GetDataByID(rewardId) if rewardCfg and rewardCfg.Item_Table and #rewardCfg.Item_Table > 0 then rewardLoopScroll:AddData(rewardCfg.Item_Table, 0) end end end function UIGuildWarRewardIntroduction:SetContributionRewardCell(cellTable, data, index) UIUtils.SetActive(cellTable.img_trophy, false) UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS[self.attributionRewardIDS[index+1]]) self:HandleItemTable(cellTable, data) end function UIGuildWarRewardIntroduction:HandleItemTable(cellTable, itemTable) for i, itemData in ipairs(itemTable) do local contentItem = cellTable.ItemContent[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.ItemContent, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(contentItem.item, CTL.GuildAuction.LvBuItemToSuperGoldenHeroItem(itemData.ItemID), itemData.ItemNum) UIUtils.SetActive(contentItem.gameObject, true) if itemData.isAuction == nil then UIUtils.SetActive(contentItem.img_Auction, false) else UIUtils.SetActive(contentItem.img_Auction, itemData.isAuction) end end for i = #itemTable + 1, #cellTable.ItemContent do UIUtils.SetActive(cellTable.ItemContent[i].gameObject, false) end UIUtils.SetRectPosition(cellTable.ItemContent.gameObject, 0, 0) end return UIGuildWarRewardIntroduction