187 lines
6.0 KiB
Lua
187 lines
6.0 KiB
Lua
local UIWidgetBase = require_ex('Common/Core/UIWidgetBase')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ActivityCommonInfo = HL.Class('ActivityCommonInfo', UIWidgetBase)
|
|
|
|
|
|
ActivityCommonInfo.m_tagCells = HL.Field(HL.Any)
|
|
|
|
|
|
ActivityCommonInfo.m_activityId = HL.Field(HL.String) << ""
|
|
|
|
|
|
ActivityCommonInfo.m_rewardCells = HL.Field(HL.Any)
|
|
|
|
|
|
|
|
|
|
ActivityCommonInfo._OnFirstTimeInit = HL.Override() << function(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ActivityCommonInfo.InitActivityCommonInfo = HL.Method(HL.Table) << function(self, args)
|
|
self:_FirstTimeInit()
|
|
self.m_activityId = args.activityId
|
|
local activitySystem = GameInstance.player.activitySystem
|
|
|
|
local _, activityData = Tables.activityTable:TryGetValue(self.m_activityId)
|
|
local activity = activitySystem:GetActivity(self.m_activityId)
|
|
if not activityData or not activity then
|
|
logger.error('Activity not found: %s', self.m_activityId)
|
|
self.view.gameObject:SetActive(false)
|
|
return
|
|
end
|
|
|
|
|
|
self.view.infoNode.txtName.text = activityData.name
|
|
self.view.infoNode.detailsTxt.text = activityData.desc
|
|
if activity.endTime == 0 then
|
|
self.view.infoNode.countDownText.text = Language.LUA_ACTIVITY_PERMANENT_TEXT
|
|
else
|
|
self.view.infoNode.countDownWidget:InitCountDownText(activity.endTime)
|
|
end
|
|
|
|
|
|
local tagIds = activityData.tagIds
|
|
self.m_tagCells = UIUtils.genCellCache(self.view.tagCell)
|
|
self.m_tagCells:Refresh(#tagIds, function(cell, index)
|
|
local csIndex = CSIndex(index)
|
|
local _,tagInfo = Tables.activityTagTable:TryGetValue(tagIds[csIndex])
|
|
cell.tagTxt.text = tagInfo.name
|
|
end)
|
|
|
|
|
|
if self.view.config.SHOW_REWARDS then
|
|
local rewardId = activityData.rewardId
|
|
if not string.isEmpty(rewardId) then
|
|
local rewardBundles = UIUtils.getRewardItems(rewardId)
|
|
self.m_rewardCells = UIUtils.genCellCache(self.view.rewardItem)
|
|
self.m_rewardCells:Refresh(#rewardBundles, function(cell, index)
|
|
cell:InitItem(rewardBundles[index], function()
|
|
cell:ShowTips()
|
|
end)
|
|
cell:SetExtraInfo({
|
|
tipsPosType = UIConst.UI_TIPS_POS_TYPE.LeftMid,
|
|
tipsPosTransform = self.view.scrollViewRewards,
|
|
isSideTips = true,
|
|
})
|
|
end)
|
|
end
|
|
|
|
self:UpdateRewardInfo("")
|
|
end
|
|
|
|
|
|
self.view.infoNode.descriptionBtn.onClick:AddListener(function()
|
|
ActivityUtils.GameEventLogActivityVisit(self.m_activityId, "descriptionButton", "visit_description")
|
|
local instructionId = activityData.instructionId
|
|
UIManager:Open(PanelId.InstructionBook, instructionId)
|
|
end)
|
|
|
|
|
|
|
|
local state
|
|
if not self.view.config.SHOW_BUTTONS then
|
|
state = "None"
|
|
elseif not activity.isUnlocked then
|
|
state = "Reminder"
|
|
elseif activity.status == GEnums.ActivityStatus.IntroMission then
|
|
state = "IntroMission"
|
|
else
|
|
state = "Detail"
|
|
end
|
|
self.view.gotoNode.stateController:SetState(state)
|
|
if state == "Reminder" then
|
|
self.view.gotoNode.reminderJumpBtn.onClick:AddListener(function()
|
|
ActivityUtils.GameEventLogActivityVisit(self.m_activityId, "unlockReminderButton", "visit_unlock_reminder")
|
|
UIManager:Open(PanelId.ActivityStartReminderPopup,{
|
|
activityId = self.m_activityId,
|
|
})
|
|
end)
|
|
elseif state == "Detail" then
|
|
if activityData.detailJumpId then
|
|
self.view.gotoNode.btnDetail.onClick:AddListener(function()
|
|
ActivityUtils.GameEventLogActivityVisit(self.m_activityId, "gotoActivityHudButton", "visit_activity")
|
|
local success = Tables.systemJumpTable:TryGetValue(activityData.detailJumpId)
|
|
if success then
|
|
Utils.jumpToSystem(activityData.detailJumpId)
|
|
else
|
|
logger.error("no such jumpId")
|
|
end
|
|
end)
|
|
end
|
|
elseif state == "IntroMission" then
|
|
self.view.gotoNode.btnIntroMissionlRedDot:InitRedDot("ActivityIntroMission", self.m_activityId)
|
|
self.view.gotoNode.btnIntroMission.onClick:AddListener(function()
|
|
ActivityUtils.GameEventLogActivityVisit(self.m_activityId, "IntroMissionButton", "visit_intro_mission")
|
|
local success = Tables.systemJumpTable:TryGetValue(activityData.introMissionJumpId)
|
|
if success then
|
|
Utils.jumpToSystem(activityData.introMissionJumpId)
|
|
ActivityUtils.setFalseIntroMissionActivity(self.m_activityId)
|
|
else
|
|
logger.error("no such jumpId")
|
|
end
|
|
end)
|
|
end
|
|
|
|
|
|
if DeviceInfo.usingController then
|
|
self.view.gotoNode.scrollViewRewards.onIsFocusedChange:AddListener(function(isFocused)
|
|
if not isFocused then
|
|
Notify(MessageConst.HIDE_ITEM_TIPS)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
ActivityCommonInfo.UpdateRewardInfo = HL.Method(HL.String) << function(self, rewardId)
|
|
if not string.isEmpty(rewardId) then
|
|
local rewardBundles = UIUtils.getRewardItems(rewardId)
|
|
self.m_rewardCells:Refresh(#rewardBundles, function(cell, index)
|
|
cell:InitItem(rewardBundles[index], function()
|
|
cell:ShowTips()
|
|
end)
|
|
|
|
cell:SetExtraInfo({
|
|
tipsPosType = UIConst.UI_TIPS_POS_TYPE.LeftMid,
|
|
tipsPosTransform = self.view.scrollViewRewards,
|
|
isSideTips = true,
|
|
})
|
|
end)
|
|
end
|
|
|
|
|
|
local activity = GameInstance.player.activitySystem:GetActivity(self.m_activityId)
|
|
local isGet = activity and activity.receiveAllReward
|
|
if isGet then
|
|
self.view.gotoNode.rewardsReceiveTextLayout.gameObject:SetActive(true)
|
|
else
|
|
self.view.gotoNode.rewardsReceiveTextLayout.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
ActivityCommonInfo.UpdateDescTxt = HL.Method(HL.String) << function(self, desc)
|
|
self.view.infoNode.detailsTxt.text = desc
|
|
end
|
|
|
|
|
|
HL.Commit(ActivityCommonInfo)
|
|
return ActivityCommonInfo
|
|
|