local UIGuildActivityEntrance = UIViewClass()
local Image_Path = ConstAssetPathConfig.ImagePath
function UIGuildActivityEntrance:OnOpened(context)
self.timeIntervals = {}
local list = CTL.Guild.GetActivityList()
for i,v in ipairs(list) do
self.scroll_GuildActivity:AddData(v,0)
end
self:RegistSystemEvent(EventID.UI_Guild_ActivityRefresh, self.Refresh)
self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild_Activity, self.Refresh)
self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE, self.Refresh)
end
function UIGuildActivityEntrance:Refresh()
self.scroll_GuildActivity:RefreshCells(false)
end
function UIGuildActivityEntrance:OnCellClicked(scrollRect, index, cellTable, target, data)
if target == cellTable.event_Attr then
local activityData = DataSheetManager.ActivityData:GetDataByID(data.ActivityId)
local date, time, extra = CTL.Activities.GetDetailsTimeDesc(activityData)
UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, {target = target, posType = LuaConst.DescriptionPanelType.RightLower, text = extra})
else
--暂未开放,显示敬请期待(合纵连横和助饷特殊处理,活动界面需要不显示,只在势力活动显示)
if data.ActivityId ~= LuaConst.ActivityType.GuildAllies
and data.ActivityId ~= LuaConst.ActivityType.GuildDonate
and not CTL.Activities.IsShowUI(data.ActivityId) then
CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_NowNotOpen"])
return
end
local activityData = DataSheetManager.ActivityData:GetDataByID(data.ActivityId)
if MDL.Unlock.IsUnlock(activityData.FuctionUnlockID) then
CTL.Activities.OpenActivityWindowByID(data.ActivityId)
else
CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_3013_InfoCode_FunctionLock)
end
end
end
function UIGuildActivityEntrance:OnCellInit(scrollRect, index, cellTable, data)
UIUtils.SetImageByAssetBundle(cellTable.img_Activity, data.Image)
UIUtils.SetActive(cellTable.group_ActivityFameTag, not string.isNilOrEmpty(data.Label))
if not string.isNilOrEmpty(data.Label) then UIUtils.SetLabelText(cellTable.txt_ActivitiesFame, Const_IDS[data.Label]) end
-- 战区跨服标签
local isCrossTag, crossType = CTL.Activities.GetGuildActivityCrossStateAndType(data.ActivityId)
if isCrossTag then
UIUtils.SetActive(cellTable.group_Mode, true)
cellTable.tag_State:SetState(crossType)
else
UIUtils.SetActive(cellTable.group_Mode, false)
end
local activityData = DataSheetManager.ActivityData:GetDataByID(data.ActivityId)
UIUtils.SetLabelText(cellTable.txt_ActivityTitle,Const_IDS[activityData.Activity])
UIUtils.SetActive(cellTable.event_Attr, false)
--暂未开放,显示敬请期待(合纵连横和助饷特殊处理,活动界面需要不显示,只在势力活动显示)
if data.ActivityId ~= LuaConst.ActivityType.GuildAllies
and data.ActivityId ~= LuaConst.ActivityType.GuildDonate
and not CTL.Activities.IsShowUI(data.ActivityId) then
cellTable.state_Lock:SetState(0)
cellTable.group_Locked.gameObject:SetActive(true)
UIUtils.SetGray(cellTable.img_Activity,true)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
cellTable.group_ActivityPlaying.gameObject:SetActive(false)
cellTable.group_ActivityEnd.gameObject:SetActive(false)
cellTable.state_ActivityTime:SetState(1)
else
cellTable.state_Lock:SetState(1)
if MDL.Unlock.IsUnlock(activityData.FuctionUnlockID) then
cellTable.group_Locked.gameObject:SetActive(false)
UIUtils.SetGray(cellTable.img_Activity,false)
UIUtils.SetGray(cellTable.img_TxtBG,false)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
local state,time = CTL.Activities.GetState(data.ActivityId)
if state == CTL.Activities.ActivityState.Opening then -- 进行中
cellTable.group_ActivityPlaying.gameObject:SetActive(true)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
cellTable.group_ActivityEnd.gameObject:SetActive(false)
if not time or data.ActivityId == LuaConst.ActivityType.GuildDonate then
cellTable.state_ActivityTime:SetState(1)
self:CloseThailandText(cellTable)
else
cellTable.state_ActivityTime:SetState(0)
self:OpenThailandText(cellTable)
self:SetTimeStr(time, cellTable.txt_Time, cellTable.cdTime, index, true)
end
if data.ActivityId == LuaConst.ActivityType.SlgGvE then
UIUtils.SetLabelText(cellTable.playing_txt_Title, Const_IDS.IDS_SlgGve_Season_Hint_6)
else
UIUtils.SetLabelText(cellTable.playing_txt_Title, Const_IDS.IDS_GuildActivity_Opening)
end
elseif state == CTL.Activities.ActivityState.End then -- 已结束
cellTable.state_ActivityTime:SetState(0)
self:OpenThailandText(cellTable)
cellTable.group_ActivityPlaying.gameObject:SetActive(false)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
cellTable.group_ActivityEnd.gameObject:SetActive(true)
if data.ActivityId == LuaConst.ActivityType.SlgGvE then
if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End then
UIUtils.SetLabelText(cellTable.end_txt_Title, Const_IDS.IDS_SlgGve_Season_Hint_5)
else
UIUtils.SetLabelText(cellTable.end_txt_Title, Const_IDS.IDS_SlgGve_Season_Hint_9)
end
else
UIUtils.SetLabelText(cellTable.end_txt_Title, Const_IDS.IDS_GuildBoss_AlreadyClosed)
end
else -- 未开启
cellTable.state_ActivityTime:SetState(0)
self:OpenThailandText(cellTable)
cellTable.group_ActivityPlaying.gameObject:SetActive(false)
cellTable.group_ActivityLastTime.gameObject:SetActive(true)
cellTable.group_ActivityEnd.gameObject:SetActive(false)
if data.ActivityId == LuaConst.ActivityType.GuildWar and MDL.GuildWar.GuildWarIsFirstSign() then
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
else
cellTable.group_ActivityLastTime.gameObject:SetActive(true)
self:SetTimeStr(time, cellTable.txt_Time, cellTable.cdTime, index )
end
end
else
cellTable.group_ActivityPlaying.gameObject:SetActive(false)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
cellTable.group_ActivityEnd.gameObject:SetActive(false)
cellTable.group_Locked.gameObject:SetActive(true)
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
local unlockInfo = DataSheetManager.FuctionUnlock:GetDataByFucID(activityData.FuctionUnlockID).Unlock_Table
local tmpIsUnlock, tmpContent = MDL.Unlock.IsComplete(unlockInfo[1].UnlockCondition, unlockInfo[1].UnlockConditionParam, "IDS_GuildActivity_ReptUnlock")
UIUtils.SetActive(cellTable.txt_LevelUnlock, not tmpIsUnlock)
cellTable.txt_FameUnlock.text = tmpIsUnlock and "" or tmpContent
if unlockInfo[2] then
local tmpIsUnlock, tmpContent = MDL.Unlock.IsComplete(unlockInfo[2].UnlockCondition, unlockInfo[2].UnlockConditionParam,"IDS_GuildActivity_PersonalUnlock")
UIUtils.SetActive(cellTable.txt_LevelUnlock, not tmpIsUnlock)
cellTable.txt_LevelUnlock.text = tmpIsUnlock and "" or tmpContent
else
UIUtils.SetActive(cellTable.txt_LevelUnlock, false)
end
UIUtils.SetGray(cellTable.img_Activity,true)
UIUtils.SetGray(cellTable.img_TxtBG,true)
cellTable.state_ActivityTime:SetState(0)
end
if activityData.Time_Table and #activityData.Time_Table > 0 then
local date, time, extra = CTL.Activities.GetDetailsTimeDesc(activityData)
--local date,time = UTL.Time.GetDateDescAndTime(activityData.Time_Table)
UIUtils.SetActive(cellTable.event_Attr, extra ~= nil)
if Localization.IsThailand() then
cellTable.txt_ActivityTime_Progress:SetText(date)
if time then
cellTable.txt_ActivityTimeTH.text = ""..time..""
end
else
if time then
cellTable.txt_ActivityTime.text = date .. "\n" .. ""..time..""
else
cellTable.txt_ActivityTime.text = date
end
end
else
cellTable.group_ActivityLastTime.gameObject:SetActive(false)
cellTable.state_ActivityTime:SetState(1)
end
end
cellTable.cell:SetRedPoint(CTL.Guild.GetRedPointById(data.ActivityId))
end
function UIGuildActivityEntrance:SetTimeStr(value, label, cdTime,index, isEnd)
if value > 0 then
local timeInterval = 0
if isEnd then
timeInterval = value + 1
else
if value > UTL.Time.TotalSecondsOneDay then
local day = math.floor(value / UTL.Time.TotalSecondsOneDay)
local str = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Item_Time_Day))
label.text = string.format(str,day)
timeInterval = value % UTL.Time.TotalSecondsOneDay
elseif value > UTL.Time.TotalSecondsOneHour then
local hour = math.floor(value/UTL.Time.TotalSecondsOneHour)
local str = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Item_Time_Hour))
label.text = string.format(str,hour)
timeInterval = value % UTL.Time.TotalSecondsOneHour
elseif value > UTL.Time.TotalSecondsOneMinute then
local min = math.floor(value / UTL.Time.TotalSecondsOneMinute)
local str = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeMinute))
label.text = string.format(str,min)
timeInterval = value % UTL.Time.TotalSecondsOneMinute
elseif value > 0 then
cdTime:ResetAndBeginCustomTimer(false,value,0,UIUtils.GetLocalizedTxt(Const_IDS.IDS_CountDown_Second),1)
timeInterval = value
end
end
self.index = index
self:StartRepeatFunc(self.DelayUpdateIndex, timeInterval, 1)
return
end
end
function UIGuildActivityEntrance:DelayUpdateIndex()
self.scroll_GuildActivity:UpdateIndex(self.index)
end
-- region 泰语改滑动文本
function UIGuildActivityEntrance:OpenThailandText(cellTable)
if Localization.IsThailand() then
cellTable.loc_ActivityTimeProgress:SetState(1)
end
end
function UIGuildActivityEntrance:CloseThailandText(cellTable)
if Localization.IsThailand() then
cellTable.loc_ActivityTimeProgress:SetState(0)
end
end
-- end region 泰语改滑动文本
return UIGuildActivityEntrance