local UIHeroBiographyMainPanel = UIViewClass()
local EventSystem = require('Event/EventSystem')
function UIHeroBiographyMainPanel:OnOpened(context)
self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.RefreshEnterTimes)
self:RegistSystemEvent(EventID.UI_HeroBiography_FinishSweep, self.RefreshOutsidePanel)
self:RegistSystemEvent(EventID.UI_HeroBiography_UpdateInfo, self.RefreshOutsidePanel)
self:RegistSystemEvent(EventID.UI_Activity_Refresh_Single_RedPoint, self.RefreshOutsidePanel)
self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshAutoRefineKey)
self:InitBiographyHeroScroll()
self:RefreshEnterTimes()
-- 一键扫荡
self:RefreshAutoRefineKey(MDL.Unlock.FunctionType.HeroBiographyAutoRefine, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroBiographyAutoRefine))
UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_HeroBiography_Title"])
local index = 0
if context then -- 有的最后一位英雄index
for i, v in DataSheetManager.HeroBiographyData:GetEnumerator() do
if v.ID == context.biographyId then
break
end
index = index + 1
end
else
index = CTL.Biography.GetLatestBiographyIndex() -- 上次进入的英雄index
end
self.scroll_BiographyHero:MoveIndex(index)
end
function UIHeroBiographyMainPanel:RefreshAutoRefineKey(funcID, isUnlock)
if funcID == MDL.Unlock.FunctionType.HeroBiographyAutoRefine then
if isUnlock then
MDL.Biography.GetSweepBiographyConfigReq()
end
UIUtils.SetActive(self.btn_Sweep, isUnlock)
UIUtils.SetActive(self.btn_Set, isUnlock)
end
end
function UIHeroBiographyMainPanel:OnBackButtonPressed()
self:OnButtonClicked(self.UITemplateTitlePanel.btn_close)
end
function UIHeroBiographyMainPanel:OnButtonClicked(comp)
if comp == self.UITemplateTitlePanel.btn_close then
self:CloseView(true)
elseif comp == self.UITemplateTitlePanel.btn_Home then
CTL.HomeMain.CloseViewBackHomeMain()
elseif comp == self.add_Times then
CTL.Biography.ClickAddTimes()
elseif comp == self.UITemplateTitlePanel.btn_Info then
--每日5点
local timeTab = { 1 }
local _, param1 = UTL.Time.GetDateDescAndTime(timeTab)
UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.HeroBiography, params = { param1 } })
elseif comp == self.btn_Sweep then
-- 一键扫荡
MDL.Biography.OneKeySweepBiographyReq()
elseif comp == self.btn_Set then
-- 设置一键扫荡
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroBiographySweepSetPanel)
end
end
function UIHeroBiographyMainPanel:RefreshOutsidePanel()
self.scroll_BiographyHero:RefreshCells()
self:RefreshEnterTimes()
end
function UIHeroBiographyMainPanel:InitBiographyHeroScroll()
self.scroll_BiographyHero:ClearCells()
for i, v in DataSheetManager.HeroBiographyData:GetEnumerator() do
self.scroll_BiographyHero:AddData(v, 0)
end
end
function UIHeroBiographyMainPanel:RefreshEnterTimes()
local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.HeroBiography).DailyRefreshTimes --只显示基础次数
if MDL.Biography.GetEnterNums() <= 0 then
UIUtils.SetLabel(self.txt_Times, string.format("%d/%d",MDL.Biography.GetEnterNums(),totalTimes))
else
UIUtils.SetLabel(self.txt_Times, string.format("%d/%d",MDL.Biography.GetEnterNums(),totalTimes))
end
end
function UIHeroBiographyMainPanel:OnCellInit(scrollRect, index, cellTable, data)
local heroId = data.HeroID
local heroData = DataSheetManager.HeroNum:GetDataByID(heroId)
UTL.Color.SetQualityImageByType(cellTable.img_quality, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyBg)
UTL.Color.SetQualityImageByType(cellTable.img_qualityName, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyCornerBase)
UTL.Color.SetQualityImageByType(cellTable.img_qualityNameLoc, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyCornerBase)
UTL.Color.SetQualityImageByType(cellTable.img_Frame, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyFrame)
UTL.Color.SetQualityImageByType(cellTable.img_GradientCover, heroData.HeroQuality, UTL.Color.QualityType.HeroBiographyGradientCover)
UIUtils.SetImageByAssetBundle(cellTable.img_Hero, data.HeroShow)
CTL.HeroSelect.SetHeroName(heroId, cellTable.loc_Name, cellTable.img_Name, cellTable.txt_Name)
UIUtils.SetLabel(cellTable.txt_DailyLimit, MDL.Biography.GetBiographyDailyCountShowById(data.ID))
if MDL.HeroSelect.IsHasHero(heroId) then
UIUtils.SetActive(cellTable.img_Get, true)
else
UIUtils.SetActive(cellTable.img_Get, false)
end
UIUtils.SetActive(cellTable.group_Lock, not CTL.Biography.IsHeroBiographyUnlock(data.ID))
UIUtils.SetActive(cellTable.img_InBattle, MDL.Player.HeroIsLineUp(heroId))
UIUtils.SetActive(cellTable.img_Help, MDL.AssistanceFight.IsHeroOnAssistancePos(heroId))
if not CTL.Biography.IsHeroBiographyUnlock(data.ID) then
UIUtils.SetActive(cellTable.group_DailyLimit.gameObject, false)
UIUtils.SetActive(cellTable.mask_UnActivation, true)
local unlockText = CTL.Biography.GetHeroBiographyUnlockText(data.ID)
cellTable.lab_Locked.text = unlockText
else
UIUtils.SetActive(cellTable.group_DailyLimit.gameObject, true)
UIUtils.SetActive(cellTable.mask_UnActivation, false)
end
cellTable.cell:SetRedPoint(CTL.Biography.IsRecommendEnterBiography(data.ID))
UTL.Item.SetItemCell(cellTable.item, DataSheetManager.HeroNum:GetDataByID(heroId).PieceItem)
end
function UIHeroBiographyMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data)
if target == cellTable.item.event_Click then
UTL.ItemTips.ShowCommonTipsById(DataSheetManager.HeroNum:GetDataByID(data.HeroID).PieceItem)
return
end
local isUnlock, unlockText = CTL.Biography.IsHeroBiographyUnlock(data.ID)
if isUnlock then
self:ChangeView(data.ID)
else
CTL.Tips.AddTipsMsg(unlockText)
end
end
function UIHeroBiographyMainPanel:ChangeView(id)
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroBiographySubPanel, {biographyId = id})
self:CloseView()
end
function UIHeroBiographyMainPanel:OnClosed()
EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder)
end
return UIHeroBiographyMainPanel