local UIHeroIllustratedBase = UIViewClass() local CountryTabEnum = { Init = -1, Shu = 0, Wei = 1, Wu = 2, Qun = 3 } local CountryName = { [CountryTabEnum.Shu] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_Country_ShuGuo"]), [CountryTabEnum.Wei] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_Country_WeiGuo"]), [CountryTabEnum.Wu] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_Country_WuGuo"]), [CountryTabEnum.Qun] = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_Country_QunXiong"]) } local ProgressStr = "%d/%d" local GRAY_COLOR = "93969c" local PrefabScoreTipPath = "Common/UICommonInfoTipsNew" ---------------------------------------------- 系统函数 ---------------------------------------------------------- function UIHeroIllustratedBase:OnOpened() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_Handbook_Hero_Title"]) UIUtils.SetActive(self.loop_HeroCard,true) UIUtils.SetActive(self.loop_TreasureHorse,false) 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_HeroLibrary_RefreshBase, self.RefreshPanel) self.selectedCountryTab = CountryTabEnum.Init self.heroAttrCount = 0 self.group_Toggles:SelectIndex(CountryTabEnum.Shu) end function UIHeroIllustratedBase:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIHeroIllustratedBase:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.HeroPictorial}) 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.UIHeroIllustratedLevelTip, nil, PrefabScoreTipPath) elseif comp == self.btn_Picture then -- 画卷 elseif comp == self.btn_Pandect then -- 属性总览 UIUtils.SetActive(self.group_Attributes, true) self:RefreshAttrs() elseif comp == self.btn_OneKey then MDL.HeroLibrary.OneKeyPictorialLevelUpReq(LuaConst.PictorialType.Hero) elseif comp == self.btn_CloseAttr then UIUtils.SetActive(self.group_Attributes, false) end end function UIHeroIllustratedBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_HeroCard then local isCanUpdate = MDL.HeroLibrary.IsHeroCanUpdate(data.ID) local isUnlock = MDL.HeroLibrary.GetHeroLevel(data.ID) > -1 local quality = CTL.HeroAwaken.GetHeroQuality(data.ID, MDL.HeroAwaken.GetIsHeroAwaken(data.ID)) UTL.Color.SetQualityImageByType(cellTable.img_Quality, quality, UTL.Color.QualityType.Pictorial) local isAwaken = MDL.HeroAwaken.GetIsHeroAwaken(data.ID) local heroName if isAwaken then CTL.HeroAwaken.SetHeroHalfCardImageByHeroId(cellTable.img_Hero, data.ID) heroName = string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_Awaken, UIUtils.GetLocalizedTxt(Const_IDS[data.NameIDS])) else UTL.Item.SetHeroHalfCardImageByHeroId(cellTable.img_Hero, data.ID) heroName = UIUtils.GetLocalizedTxt(Const_IDS[data.NameIDS]) end --local pos = string.split(data.HeroPictorialPos, ",") --cellTable.img_Hero:SetPivotCenter(tonumber(pos[1]), tonumber(pos[2])) UIUtils.SetLabel(cellTable.txt_Name, not isUnlock and UTL.Color.FormatTextByColor(GRAY_COLOR, heroName) or UTL.Color.FormatQualityText(heroName, quality)) UIUtils.SetActive(cellTable.group_Light, isCanUpdate) UIUtils.SetGray(cellTable.img_Quality, not isUnlock) UIUtils.SetGray(cellTable.img_Hero, 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.HeroLibrary.GetHeroLevel(data.ID))) if isCanUpdate then cellTable.effect_Light:PlayUIEffect() UIUtils.SetLabelText(cellTable.txt_Tip, MDL.HeroLibrary.GetHeroLevel(data.ID) == - 1 and Const_IDS["IDS_Handbook_Hero_AbleToActivate"] or Const_IDS["IDS_Handbook_Hero_AbleToLevelUp"]) end elseif scrollRect == self.loop_Pandect then if type(data) == "number" then local attrData = DataSheetManager.AttrData:GetDataByID(data) local attrValue = MDL.HeroLibrary.GetAttrValue(data, self.heroAttrCount - 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 UIHeroIllustratedBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_HeroCard then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroIllustratedPopUp, data) end end function UIHeroIllustratedBase:OnValueChanged(comp, state) if comp == self.group_Toggles then if self.selectedCountryTab ~= state then self.selectedCountryTab = state self:RefreshPanel(true) end end end ------------------------------------------------------------------------------------------------------------------- function UIHeroIllustratedBase:RefreshPanel(isRebuild) self:RefreshAttrs() local heroList = MDL.HeroLibrary.GetHeroList(self.selectedCountryTab) local moveIndex = -1 if self.loop_HeroCard.Count == 0 or isRebuild then self.count = 0 self.loop_HeroCard:ClearCells() for i, v in ipairs (heroList) do if MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Hero, v.ID) and CTL.WeaponLibrary.CheckIsHeroOpen(v.ID) then -- 屏蔽金将判断 self.loop_HeroCard:AddData(v, 0) self.count = self.count + 1 if moveIndex == -1 and MDL.HeroLibrary.IsHeroCanUpdate(v.ID) then moveIndex = i - 1 end end end else self.loop_HeroCard:RefreshCells(false) for i, v in ipairs (heroList) do if moveIndex == -1 and MDL.HeroLibrary.IsHeroCanUpdate(v.ID) then moveIndex = i - 1 end end end local red_1 = MDL.HeroLibrary.IsShowRPByTab(CountryTabEnum.Shu) local red_2 = MDL.HeroLibrary.IsShowRPByTab(CountryTabEnum.Wei) local red_3 = MDL.HeroLibrary.IsShowRPByTab(CountryTabEnum.Wu) local red_4 = MDL.HeroLibrary.IsShowRPByTab(CountryTabEnum.Qun) self.group_Toggles:SetRedPoint(0, red_1) self.group_Toggles:SetRedPoint(1, red_2) self.group_Toggles:SetRedPoint(2, red_3) self.group_Toggles:SetRedPoint(3, red_4) local isUpgrade = red_1 or red_2 or red_3 or red_4 UIUtils.SetActive(self.btn_OneKey, isUpgrade) -- 跳转到最近可解锁或可升级 if moveIndex ~= -1 then self.loop_HeroCard:MoveIndex(moveIndex) end -- 积分 local level, score = MDL.HeroLibrary.GetLibraryLevelAndScore() local pictorialCfg = DataSheetManager.HeroPictorialScore:GetDataByLevelID(level + 1) if not pictorialCfg then pictorialCfg = DataSheetManager.HeroPictorialScore:GetDataByLevelID(level) end -- 满级 if level == DataSheetManager.HeroPictorialScore: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_Handbook_Hero_HeroScore_Tips"]), level)) self.slider_Score.value = score / pictorialCfg.NeedScore -- 解锁说明 local unlock, amount = MDL.HeroLibrary.GetUnlockAndAmountHeroCount(self.selectedCountryTab) UIUtils.SetLabel(self.txt_HeroUnlockTitle, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_ActivatedHeroNum"], CountryName[self.selectedCountryTab])) UIUtils.SetLabel(self.txt_HeroUnlockValue, string.format(ProgressStr, unlock, self.count)) end function UIHeroIllustratedBase:RefreshAttrs() if self.group_Attributes.gameObject.activeSelf then if self.loop_Pandect.Count == 0 then self.heroAttrCount = 1 self.loop_Pandect:ClearCells() -- 属性总览 self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_AttrPreview"]), 0) for k, _ in pairs (MDL.HeroLibrary.GetAttrs()) do self.heroAttrCount = self.heroAttrCount + 1 self.loop_Pandect:AddData(k, 1) end -- 积分属性 self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_HeroScoreUp"]), 0) for k, _ in pairs (MDL.HeroLibrary.GetAttrs(true)) do self.loop_Pandect:AddData(k, 1) end else self.loop_Pandect:RefreshCells(false) end end end return UIHeroIllustratedBase