local UIAppearanceIllustratedBase = UIViewClass() local ProgressStr = "%d/%d" local GRAY_COLOR = "93969c" local PrefabScoreTipPath = "Common/UICommonInfoTipsNew" ---------------------------------------------- 系统函数 ---------------------------------------------------------- function UIAppearanceIllustratedBase:OnOpened() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_CollectionHandbook_Tip1"]) UIUtils.SetActive(self.loop_HeroCard,false) UIUtils.SetActive(self.loop_TreasureHorse,true) UIUtils.SetActive(self.loop_WeaponCard,false) UIUtils.SetActive(self.loop_Stratagem,false) UIUtils.SetActive(self.loop_lightEffectPictorial, false) UIUtils.SetActive(self.loop_lightEffectPictorialSuit, false) self:RegistSystemEvent(EventID.UI_Illustration_AppearanceLibrary_RefreshBase, self.RefreshPanel) self.attrCount = 0 UIUtils.SetActive(self.group_Toggles,false) self:RefreshPanel(true) end function UIAppearanceIllustratedBase:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIAppearanceIllustratedBase:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.AppearanceLibrary}) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Info then -- 积分说明 UIManager.OpenView(Const_UI_Lua.UIEnum.UIAppearanceIllustratedLevelTip, nil, PrefabScoreTipPath) elseif comp == self.btn_Pandect then -- 属性总览 UIUtils.SetActive(self.group_Attributes, true) self:RefreshAttrs() elseif comp == self.btn_CloseAttr then UIUtils.SetActive(self.group_Attributes, false) end end function UIAppearanceIllustratedBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_TreasureHorse then UIUtils.SetActive(cellTable.Treasure, false) if data == 0 then UIUtils.SetActive(cellTable.Horse, false) UIUtils.SetActive(cellTable.Empty, true) UIUtils.SetActive(cellTable.group_Lv, false) UIUtils.SetActive(cellTable.img_Quality, false) UIUtils.SetActive(cellTable.group_Name, false) UIUtils.SetActive(cellTable.group_Light, false) UIUtils.SetActive(cellTable.img_Gray, false) else UIUtils.SetActive(cellTable.Horse, true) UIUtils.SetActive(cellTable.Empty, false) UIUtils.SetActive(cellTable.group_Name, true) local isCanUpdate = MDL.AppearanceLibrary.CanUnlockOrUpdate(data.ID) local isUnlock = MDL.AppearanceLibrary.GetAppearanceLevel(data.ID) > -1 local appearanceCfg = DataSheetManager.HeroAppearance:GetDataByID(data.ID) UTL.Color.SetQualityImageByType(cellTable.img_Quality, appearanceCfg.HeroQuality, UTL.Color.QualityType.Pictorial) UIUtils.SetImageByAssetBundle(cellTable.Horse, appearanceCfg.PreviewCardImage) UIUtils.SetLabel(cellTable.txt_Name, not isUnlock and UTL.Color.FormatTextByColor(GRAY_COLOR, UIUtils.GetLocalizedTxt(Const_IDS[appearanceCfg.AppearanceName])) or UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[appearanceCfg.AppearanceName]), appearanceCfg.HeroQuality)) UIUtils.SetActive(cellTable.group_Light, isCanUpdate) UIUtils.SetGray(cellTable.img_Quality, not isUnlock) UIUtils.SetActive(cellTable.img_Gray, not isUnlock) UIUtils.SetActive(cellTable.group_Lv, isUnlock) UIUtils.SetLabel(cellTable.txt_LibraryLv, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], MDL.AppearanceLibrary.GetAppearanceLevel(data.ID))) if isCanUpdate then cellTable.effect_Light:PlayUIEffect() UIUtils.SetLabelText(cellTable.txt_Tip, MDL.AppearanceLibrary.GetAppearanceLevel(data.ID) == - 1 and Const_IDS["IDS_Handbook_Hero_AbleToActivate"] or Const_IDS["IDS_Handbook_Hero_AbleToLevelUp"]) end end elseif scrollRect == self.loop_Pandect then if type(data) == "number" then local attrData = DataSheetManager.AttrData:GetDataByID(data) local attrValue = MDL.AppearanceLibrary.GetAttrValue(data, self.attrCount - 1 < index) UIUtils.SetLabelText(cellTable.txt_Attr, Const_IDS[attrData.Name]) UTL.Item.SetAtlasSprite(cellTable.img_AttrIcon,"UI_Common", attrData.Icon) UIUtils.SetLabel(cellTable.txt_NumBefore, attrValue) else UIUtils.SetLabel(cellTable.txt_Title, data) end end end function UIAppearanceIllustratedBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_TreasureHorse then if data ~= 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIAppearanceIllustratedPopUp, data, Const_UI_Lua.UIEnum.UIHeroIllustratedPopUp) end end end ------------------------------------------------------------------------------------------------------------------- function UIAppearanceIllustratedBase:RefreshPanel(isRebuild) self:RefreshAttrs() local sortedList = CTL.AppearanceLibrary.GetEntryList() local moveIndex = -1 if self.loop_TreasureHorse.Count == 0 or isRebuild then self.loop_TreasureHorse:ClearCells() for i, v in ipairs (sortedList) do self.loop_TreasureHorse:AddData(v, 0) if moveIndex == -1 and v ~= 0 and MDL.AppearanceLibrary.CanUnlockOrUpdate(v.ID) then moveIndex = i - 1 end end else self.loop_TreasureHorse:RefreshCells(false) for i, v in ipairs (sortedList) do if moveIndex == -1 and v ~= 0 and MDL.AppearanceLibrary.CanUnlockOrUpdate(v.ID) then moveIndex = i - 1 end end end -- 跳转到最近可解锁或可升级 if moveIndex ~= -1 then self.loop_TreasureHorse:MoveIndex(moveIndex) end -- 积分 local level, score = MDL.AppearanceLibrary.GetLibraryLevelAndScore() local _, pictorialCfg = DataSheetManager.CollectorPictorialScore:TryGetDataByLevelID(level + 1) if not pictorialCfg then pictorialCfg = DataSheetManager.CollectorPictorialScore:GetDataByLevelID(level) end -- 满级 if level == DataSheetManager.CollectorPictorialScore:GetDataCount() then UIUtils.SetLabel(self.txt_Num, score) else UIUtils.SetLabel(self.txt_Num, string.format(ProgressStr, score, pictorialCfg.NeedScore)) end UIUtils.SetLabel(self.lab_Score, string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_CollectionHandbook_Tip23"]), level)) self.slider_Score.value = score / pictorialCfg.NeedScore -- 解锁说明 local unlock = MDL.AppearanceLibrary.GetUnlockAmount() UIUtils.SetLabelText(self.txt_HeroUnlockTitle, Const_IDS["IDS_CollectionHandbook_Tip2"]) UIUtils.SetLabel(self.txt_HeroUnlockValue, string.format(ProgressStr, unlock, CTL.AppearanceLibrary.GetTotalCount())) end function UIAppearanceIllustratedBase:RefreshAttrs() if self.group_Attributes.gameObject.activeSelf then if self.loop_Pandect.Count == 0 then self.attrCount = 1 self.loop_Pandect:ClearCells() -- 属性总览 self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_AttrPreview"]), 0) for k, _ in pairs (MDL.AppearanceLibrary.GetAttrs()) do self.attrCount = self.attrCount + 1 self.loop_Pandect:AddData(k, 1) end -- 积分属性 self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_CollectionHandbook_Tip8"]), 0) for k, _ in pairs (MDL.AppearanceLibrary.GetAttrs(true)) do self.loop_Pandect:AddData(k, 1) end else self.loop_Pandect:RefreshCells(false) end end end return UIAppearanceIllustratedBase