local UITitleTips = UIViewClass() local HEIGHT_WITH_BTN = 864 local HEIGHT_NOT_BTN = 710 local EventSystem = require('Event/EventSystem') function UITitleTips:OnOpened(context) self:RegistSystemEvent(EventID.UI_ItemTips_Closed_Child, self.OnCloseChildItemTips) local titleConfig = context.titleConfig self.tipsData = context.bagTipsInfo --state 0是背包tips 1是预览tips if self.tipsData then self.bottom_state:SetState(0) self.group_Tip:SetSizeDelta(nil, HEIGHT_WITH_BTN) self.btn_Use:SetText(UIUtils.GetLocalizedTxt(self.tipsData.btnList[1].textIDS)); local buttonCount = self.tipsData.btnList and table.getn(self.tipsData.btnList) or 0; for i = 1, buttonCount do self.loop_Tab:AddData(self.tipsData.btnList[i], 0); end UIUtils.SetActive(self.loop_Tab, false); else self.bottom_state:SetState(1) self.group_Tip:SetSizeDelta(nil, HEIGHT_NOT_BTN) end --称号资源 CTL.Title.SetTitleShow(self.titleTemplate, titleConfig) --时间 if titleConfig.Time == -1 then UIUtils.SetLabelText(self.txt_TimeLeft, Const_IDS.IDS_Title_Forever) else local time = UTL.Time.FormatTimeForTitle(titleConfig.Time) self.txt_TimeLeft.text = time end --属性 local attr = titleConfig.Attr_Table local length = #attr for i = 1, length do local comp = self.group_Attrs[i] UIUtils.SetActive(comp.gameObject, true) UTL.Attr.SetAttrItemByCompName(comp, attr[i].AttrType, attr[i].AttrNum, true, true) end for i = length + 1, 4 do UIUtils.SetActive(self.group_Attrs[i].gameObject, false) end --途径 self.txt_ApproachOfAchieveing.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Title_Get) .. UIUtils.GetLocalizedTxt(Const_IDS[titleConfig.Describe]), titleConfig.parm1, titleConfig.parm2) if context.isOffset then self.group_Tip:SetLocalPosition(316, nil, nil) end UIUtils.SetActive(self.img_BlackCover, not context.isChildTips) if self.tipsData then local excelData = DataSheetManager.ItemData:GetDataByID(self.tipsData.itemData.CfgId) UIUtils.SetActive(self.btn_Use, excelData.SecondType ==1) UIUtils.SetActive(self.btn_More, excelData.SecondType ==1) end end function UITitleTips:OnButtonClicked(comp) if comp == self.img_BlackCover then self:CloseView() elseif comp == self.btn_Use then if UTL.ItemTips.IsCanOperateItem(self.tipsData.btnList[1].operType, self.tipsData.itemData.CfgId, self.tipsData.itemData, self.tipsData.btnList[1].funtionModule) then self:CloseView(); if self.tipsData.btnList[1].callbackFunc then self.tipsData.btnList[1].callbackFunc(self.tipsData.itemData.CfgId, self.tipsData.itemData); end end elseif comp == self.btn_More then UIUtils.SetActive(self.loop_Tab, not self.loop_Tab.gameObject.activeSelf) end end function UITitleTips:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Tab then UIUtils.SetLabel(cellTable.lab_More, UIUtils.GetLocalizedTxt(data.textIDS)); end end function UITitleTips:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Tab then if UTL.ItemTips.IsCanOperateItem(data.operType, self.tipsData.itemData.CfgId, self.tipsData.itemData, data.funtionModule) then self:CloseView(); if data.callbackFunc then data.callbackFunc(self.tipsData.itemData.CfgId, self.tipsData.itemData); end end end end function UITitleTips:OnCloseChildItemTips(isClosedByParent) if self.context.isChildTips then self.isClosedByParent = isClosedByParent self:CloseView() end end function UITitleTips:OnClosed() if self.context.isChildTips and not self.isClosedByParent then EventSystem.Dispatch(EventID.UI_ItemTips_Closed) end end return UITitleTips