local UIGuildAuctionBase = UIViewClass() local EventSystem = require('Event/EventSystem') local auction_base = require 'Proto.auction_base_pb' -------------------- 系統函數 ---------------------------------- function UIGuildAuctionBase:OnCreated() self.auctionListParams = { auctionType = 0, worldAuctionType = 0, } self.curPageType = -1 self.curWorldPageType = -1 self.nodeList = nil MDL.GuildAuction.InitShowAuctionTabs() UIUtils.SetActive(self.group_Bonus, false) end function UIGuildAuctionBase:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildAuctionBase_RefreshPanel, self.RefreshPanel) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.GuildAuction_ShareBonus, self.UpdateAllTabCells) -- 副本退出打开拍卖 if context and context.paramTabType then self:RefreshPanel(context.paramTabType) return end local curTyp, curWorldTyp = MDL.GuildAuction.GetEnterGuildAuctionBaseType() self:RefreshPanel(curTyp, curWorldTyp) UIUtils.SetLabelText(self.lab_Title, Const_IDS["IDS_Auction_FunctionName"]) end function UIGuildAuctionBase:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGuildAuctionBase:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(true) elseif comp == self.btn_myAuction then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildAuctionMy) elseif comp == self.btn_AuctionRecord then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildAuctionRecord,{recordReqTyp = MDL.GuildAuction.GetAuctionRecordReqTyp.Common}) elseif comp == self.btn_Info then local ID = CTL.GuildWar.IsCrossServerSettled() and LuaConst.NoteID.AuctionCross or LuaConst.NoteID.AuctionWorld UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = ID}) end end function UIGuildAuctionBase:SetTabRed(nodeData, cell) if nodeData.params == MDL.GuildAuction.AllAuctionType.GuildAuctionShare then cell.event_Main:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.GuildAuction_ShareBonus)) else cell.event_Main:SetRedPoint(false) end end function UIGuildAuctionBase:UpdateAllTabCells() self.loop_Auction:RefreshCells(false) end function UIGuildAuctionBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Auction then local nodeData = self.nodeList[index + 1] if not nodeData then return end if nodeData.isParent then -- 选中子页签保持父页签点亮 local isParentCheck = false for _, v in ipairs(nodeData.childNodes) do if v.params[1] == self.curPageType then if nodeData.params == v.parent then isParentCheck = true break end end end -- 更新红点 self:SetTabRed(nodeData, cellTable) UIUtils.SetActive(cellTable.UnCheck, not isParentCheck) UIUtils.SetActive(cellTable.Check, isParentCheck) UIUtils.SetLabelText(cellTable.lab_UnCheck, nodeData.showNameIDS) UIUtils.SetLabelText(cellTable.lab_Check, nodeData.showNameIDS) else if nodeData.params[1] == self.curPageType then UIUtils.SetActive(cellTable.UnCheck, self.curPageType ~= nodeData.params[1]) UIUtils.SetActive(cellTable.Check, self.curPageType == nodeData.params[1]) if self.curWorldPageType ~= -1 then UIUtils.SetActive(cellTable.UnCheck, self.curPageType ~= nodeData.params[1] or self.curWorldPageType ~= nodeData.params[2]) UIUtils.SetActive(cellTable.Check, self.curPageType == nodeData.params[1] and self.curWorldPageType == nodeData.params[2]) end else UIUtils.SetActive(cellTable.UnCheck, self.curPageType ~= nodeData.params[1] or self.curWorldPageType ~= nodeData.params[2]) UIUtils.SetActive(cellTable.Check, self.curPageType == nodeData.params[1] and self.curWorldPageType == nodeData.params[2]) end UIUtils.SetLabelText(cellTable.lab_UnCheck, nodeData.showNameIDS) UIUtils.SetLabelText(cellTable.lab_Check, nodeData.showNameIDS) end end end function UIGuildAuctionBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Auction then local nodeData = self.nodeList[index + 1] if not nodeData then return end if nodeData.isParent then self.curPageType = nodeData.params if self.curPageType == auction_base.GuildWar then for i, typ in ipairs(MDL.GuildAuction.AuctionTypeOfGuild) do if MDL.GuildAuction.IsOpenAuctionByType(typ) then self.curPageType = typ break end end end if (nodeData.params == auction_base.World and MDL.GuildAuction.IsOpenAuctionByType(auction_base.World)) or (nodeData.params == auction_base.Cross and MDL.GuildAuction.IsOpenAuctionByType(auction_base.Cross)) then self.curWorldPageType = nodeData.childNodes[1].params[2] else self.curWorldPageType = -1 end else self.curPageType = nodeData.params[1] self.curWorldPageType = nodeData.params[2] end -- 刷新显示面板 self:RefreshPanel() -- 刷新滚动列表 self:UpdateScrollMain() end end ------------------------------------------------------------------- function UIGuildAuctionBase:RefreshPanel(pageType, worldPageType, isForceReBuildScrollMain) self.curPageType = pageType and pageType or self.curPageType self.curWorldPageType = worldPageType and worldPageType or self.curWorldPageType self.auctionListParams.auctionType = self.curPageType self.auctionListParams.worldAuctionType = self.curWorldPageType UIUtils.SetActive(self.group_Bottom, true) if MDL.GuildAuction.IsOpenAuctionByType(self.curPageType) then self.group_Details:CloseView(Const_UI_Lua.UIEnum.UIGuildAuctionInfo) self.group_Details:CloseView(Const_UI_Lua.UIEnum.UIGuildAuctionShareOutBonus) if not self.group_Details:IsViewOpened(Const_UI_Lua.UIEnum.UIGuildAuctionList) then self.group_Details:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildAuctionList), self.auctionListParams) else EventSystem.Dispatch(EventID.UI_GuildAuctionList_RefreshPanel, self.auctionListParams) end else self.group_Details:CloseAll() if self.curPageType == MDL.GuildAuction.AllAuctionType.GuildAuctionShare and not self.group_Details:IsViewOpened(Const_UI_Lua.UIEnum.UIGuildAuctionShareOutBonus) then self.group_Details:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildAuctionShareOutBonus)) UIUtils.SetActive(self.group_Bottom, false) elseif not self.group_Details:IsViewOpened(Const_UI_Lua.UIEnum.UIGuildAuctionInfo) then self.group_Details:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildAuctionInfo), self.auctionListParams) else EventSystem.Dispatch(EventID.UI_GuildAuctionInfo_RefreshPanel, self.auctionListParams) end end self:RefreshScrollMain(isForceReBuildScrollMain) self:RefreshBonus() end function UIGuildAuctionBase:RefreshScrollMain(isForceReBuild) if self.loop_Auction.Count == 0 or isForceReBuild then self.loop_Auction:ClearCells() local index = 1 self.nodeList = {} for _, v in ipairs(MDL.GuildAuction.GetAuctionTabs()) do local parentIndex = index - 1 self.nodeList[index] = v index = index + 1 v.isExtend = false v.showNodeCount = 0 self.loop_Auction:AddData(nil, 0) if v.childNodes and #v.childNodes > 0 then for _, node in ipairs (v.childNodes) do if MDL.GuildAuction.IsOpenAuctionByType(node.params[1]) then self.nodeList[index] = node self.loop_Auction:AddData(nil, 1) v.showNodeCount = v.showNodeCount + 1 index = index + 1 v.isExtend = true end end end self.loop_Auction:UpdateIndex(parentIndex) end end end function UIGuildAuctionBase:RefreshBonus() if self.curPageType == MDL.GuildAuction.AllAuctionType.GuildAuctionShare then UIUtils.SetActive(self.group_Bonus, true) UIUtils.SetActive(self.group_Bonus1, false) UIUtils.SetActive(self.group_Bonus2, true) UIUtils.SetActive(self.group_Forbid, false) UIUtils.SetLabel(self.txt_Bonus2, UIUtils.GetLocalizedTxt(Const_IDS["IDS_GuildAuction_Intro"])) return end if not MDL.GuildAuction.IsOpenAuctionByType(self.curPageType) or self.curPageType == auction_base.World or self.curPageType == auction_base.Cross then UIUtils.SetActive(self.group_Bonus, false) UIUtils.SetActive(self.group_Forbid, false) return end local isForbid, isJoin = MDL.GuildAuction.GetAuctionLimit() UIUtils.SetActive(self.group_Bonus, isForbid == false) UIUtils.SetActive(self.group_Forbid, isForbid == true) if not isForbid then local bonusList = MDL.GuildAuction.GetBonus() if bonusList == nil or #bonusList == 0 then UIUtils.SetActive(self.group_Bonus1, false) UIUtils.SetActive(self.group_Bonus2, true) UIUtils.SetLabel(self.txt_Bonus2, UIUtils.GetLocalizedTxt(Const_IDS["IDS_Auction_NoOneBidding"])) else UIUtils.SetActive(self.group_Bonus1, true) UIUtils.SetActive(self.group_Bonus2, false) if isJoin then -- 参与活动 for i, v in ipairs(self.bonus_Layout) do local info = bonusList[i] if info then UIUtils.SetActive(v.gameObject, true) UTL.Item.MoneyIcon(v.icon_Currency, info.itemType) UIUtils.SetLabel(v.txt_Number, info.itemCount) else UIUtils.SetActive(v.gameObject, false) end end else -- 未参与活动 UIUtils.SetActive(self.group_Bonus2, true) for i, v in ipairs(self.bonus_Layout) do local info = bonusList[i] if info then UIUtils.SetActive(v.gameObject, true) UTL.Item.MoneyIcon(v.icon_Currency, info.itemType) local redStr = UTL.Color.FormatRedColor(info.itemCount) UIUtils.SetLabel(v.txt_Number, redStr) else UIUtils.SetActive(v.gameObject, false) end end local addPer = 100 * FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GuildAuctionBonusNormalPlayerRatio").FloatValue) local BonusTipStr = string.FormatByIdsKey("IDS_Auction_LowBonusIntro", addPer) UIUtils.SetLabel(self.txt_Bonus2, BonusTipStr) end end end end function UIGuildAuctionBase:UpdateScrollMain() for i = 0, self.loop_Auction.Count - 1 do self.loop_Auction:UpdateIndex(i) end end return UIGuildAuctionBase