local UIStagePackageTip = UIViewClass() function UIStagePackageTip:OnOpened(context) self.progressDesc = UIUtils.GetLocalizedTxt(Const_IDS.IDS_DownloadSpeedAndProgress) self:RegistSystemEvent(EventID.UpdateDownloadState, self.UpdateDownloadState) self:RegistSystemEvent(EventID.UI_Loading_UpdateDownloadProgress, self.UpdateProgress) self.hasDownloadSize = 0 self.lastStage = CTL.HotFix.GetGroupMinStage(CTL.HotFix.GetStageNum(LoginProxy.GetCurStage())) self.tarStage = context.tarStage local totalSize = CTL.HotFix.GetSeriesStageSize(self.lastStage, self.tarStage) self.maxSize = UTL.String.TransferKiloBytesSize(totalSize) if LoginProxy.Get_IsDownloading() then self:OnDownloading() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UILoadingPanel) then UIUtils.SetActive(self.btn_Close, false) end else self:WarnDownload() end self:ShowReward() end function UIStagePackageTip:OnDownloading() self.obj_state:SetState(1) self:UpdateProgress(0,0,0) end function UIStagePackageTip:WarnDownload() self.obj_state:SetState(0) local content = string.FormatByIdsId(Const_IDS.IDS_FlowDownloadPackageSizeNotice, self.maxSize) self.txt_DownLoadResource.text = content end function UIStagePackageTip:UpdateDownloadParam() local curStage = LoginProxy.GetCurStage() if curStage == self.tarStage then self:UnregistSystemEvent() self.obj_state:SetState(2) local progress = self.maxSize .. "/" .. self.maxSize self.txt_DownloadProgress.text = string.FormatByIdsId(Const_IDS.IDS_DownloadProgress, progress) -- 关闭奖励显示 否则会重叠 UIUtils.SetActive(self.group_Reward, false) elseif curStage >= self.lastStage then self.hasDownloadSize = CTL.HotFix.GetSeriesStageSize(self.lastStage, LoginProxy.GetCurStage()) end end function UIStagePackageTip:UpdateProgress(curSize, maxSize, speed) local speedDesc = UTL.String.TransferKiloBytesSize(speed) .. '/S' local progressDesc = UTL.Color.FormatGreenColor(UTL.String.TransferKiloBytesSize(curSize + self.hasDownloadSize)) .. "/" .. self.maxSize local desc = string.format(self.progressDesc, speedDesc, progressDesc) self.txt_DownloadingProgress.text = desc end function UIStagePackageTip:UpdateDownloadState(isPause) if isPause == false then self:UpdateDownloadParam() else --暂停下载,切换成一类弹窗 self:WarnDownload() end end function UIStagePackageTip:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIStagePackageTip:OnButtonClicked(comp) if comp == self.btn_Close or comp == self.event_NotNow then self:CloseView() elseif comp == self.event_DownloadNow then self:OnDownloading() if UNITY_IOS and GameAppInfo.IsVietnamPackage() then CTL.HotFix.Set_IsDownloadAnyway(true, false) else CTL.HotFix.Set_IsAllowCarrier(true) end end end function UIStagePackageTip:ShowReward() local curStage = LoginProxy.GetCurStage() local nextStage = CTL.HotFix.GetNextStage() if CTL.HotFix.IsFinishPack1_3() and nextStage < 300 then UIUtils.SetActive(self.group_Reward, true) local id = DataSheetManager.ConstData:GetDataByID("ResourceDownloadGift").IntListValue[1] local awardData = DataSheetManager.StagePackageReward:GetDataByID(id) self.group_reward:ReloadAll(awardData.Item_Table) end end function UIStagePackageTip:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) end function UIStagePackageTip:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.ItemID) end return UIStagePackageTip