local UISlgGvESearchTips = UIViewClass() local EventSystem = require('Event/EventSystem') function UISlgGvESearchTips:OnOpened(context) self.searchLevelList = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } self.searchList = {} self.curIndex = nil self:OnButtonClicked(self.mask) self:UpdateLeftInfo(MDL.SlgGvE.GridType.Normal_1) self:UpdateRightInfo(MDL.SlgGvE.GetMyOccupyGridMaxLevel()) self:SearchTarget() end function UISlgGvESearchTips:UpdateLeftInfo(gridType) local itemId = CTL.SlgGvE.MaterialsItemId[gridType] UTL.Item.ItemSquareIcon(self.icon_material, nil, itemId) self.lab_name_left.text = UTL.Item.GetItemDataSpliceByType(itemId).Name self.searchGridType = gridType end function UISlgGvESearchTips:UpdateRightInfo(level) self.lab_name_right.text = string.FormatByIdsId(Const_IDS.IDS_BreakThrough_Lv, level) self.searchGridLevel = level end function UISlgGvESearchTips:SearchTarget() MDL.SlgGvE.CollectTargetGrid(self.searchGridType, self.searchGridLevel, self.searchList) end function UISlgGvESearchTips:OnBackButtonPressed() self:OnButtonClicked(self.btn_close) end function UISlgGvESearchTips:OnButtonClicked(comp) if comp == self.btn_close then self:CloseView() elseif comp == self.btn_confirm then self:UpdateSearchList() if #self.searchList == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_SlgGve_Search_Hint_3) else if self.curIndex then for i, index in ipairs(self.searchList) do if self.curIndex == index then if #self.searchList > i + 1 then self:OnSearchIndex(self.searchList[i + 1]) else self:OnSearchIndex(self.searchList[1]) end break end end else self:OnSearchIndex(self.searchList[1]) end end elseif comp == self.mask then self.state_arrowLeft:SetState(0) self.state_arrowRight:SetState(0) self.scroll_Left:ClearCells() self.scroll_Right:ClearCells() UIUtils.SetActive(self.mask, false) elseif comp == self.btn_Left then UIUtils.SetActive(self.mask, true) self.scroll_Right:ClearCells() self.state_arrowRight:SetState(0) if self.scroll_Left.Count > 0 then self.scroll_Left:ClearCells() self.state_arrowLeft:SetState(0) else self.scroll_Left:ReloadAll(CTL.SlgGvE.MaterialsItemId) self.state_arrowLeft:SetState(1) end elseif comp == self.btn_Right then UIUtils.SetActive(self.mask, true) self.scroll_Left:ClearCells() self.state_arrowLeft:SetState(0) if self.scroll_Right.Count > 0 then self.scroll_Right:ClearCells() self.state_arrowRight:SetState(0) else self.scroll_Right:ReloadAll(self.searchLevelList) self.state_arrowRight:SetState(1) end end end function UISlgGvESearchTips:UpdateSearchList() for i = #self.searchList, 1, -1 do local type, info = MDL.SlgGvE.GetGridInfo(self.searchList[i]) if info.hasOccupy == true then table.remove(self.searchList, i) end end end function UISlgGvESearchTips:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_Left then UTL.Item.ItemSquareIcon(cellTable.icon_material, nil, data) cellTable.lab_name.text = UTL.Item.GetItemDataSpliceByType(data).Name UIUtils.SetActive(cellTable.img_checked, index + 1 == self.searchGridType) else cellTable.lv_name.text = string.FormatByIdsId(Const_IDS.IDS_BreakThrough_Lv, data) UIUtils.SetActive(cellTable.img_checked, data == self.searchGridLevel) end end function UISlgGvESearchTips:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.scroll_Left then self.state_arrowLeft:SetState(0) self:UpdateLeftInfo(index + 1) else self.state_arrowRight:SetState(0) self:UpdateRightInfo(data) end scrollRect:ClearCells() self:SearchTarget() self.curIndex = nil UIUtils.SetActive(self.mask, false) end function UISlgGvESearchTips:OnSearchIndex(index) EventSystem.Dispatch(EventID.UI_SlgGve_SelectGridIndex, index) EventSystem.Dispatch(EventID.UI_SlgGve_OpenGridTips, index) self.curIndex = index self.root:SetLocalPosition(500) end return UISlgGvESearchTips