mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
using FairyGUI;
|
||||
using HotMain;
|
||||
using HotMain.SHGame.Procedure;
|
||||
using Launcher;
|
||||
using SHFrame;
|
||||
using YooAsset;
|
||||
|
||||
namespace HotScripts.GameLauncher.FGui.Scripts.Launcher
|
||||
{
|
||||
public class LauncherUI : UIBase
|
||||
{
|
||||
|
||||
public UI_Launcher UIView => View as UI_Launcher;
|
||||
private long totalDownloadBytes = 0;
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnOpen(params object[] param)
|
||||
{
|
||||
|
||||
//显示需要升级的大小
|
||||
ResourcePackage rawFilePackage = YooAssets.GetPackage(ProcedureInitializePackage.RawFilePackageName);
|
||||
totalDownloadBytes += rawFilePackage.CreateResourceDownloader(10, 3, 60).TotalDownloadBytes;
|
||||
ResourcePackage defaultPackage = YooAssets.GetPackage(ProcedureInitializePackage.DefaultPackageName);
|
||||
totalDownloadBytes += defaultPackage.CreateResourceDownloader(10, 3, 60).TotalDownloadBytes;
|
||||
|
||||
if (totalDownloadBytes <= 0)
|
||||
{
|
||||
UIView.m_title.text = "资源已经最新";
|
||||
EventUtil.DispatchEvent(HotMainEvent.StartDownloader);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIView.m_title.text = $"需更新 {totalDownloadBytes} 字节资源";
|
||||
UIView.m_Type.selectedIndex = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void AddListener()
|
||||
{
|
||||
|
||||
UIView.m_downloader.onClick.Add(OnDownloader);
|
||||
|
||||
EventUtil.AddListener(HotMainEvent.DownloaderProgressUpdate,OnDownloaderProgressUpdate);
|
||||
EventUtil.AddListener(HotLauncherEvent.InitSuccess,OnInitSuccess);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void RemoveListener()
|
||||
{
|
||||
UIView.m_downloader.onClick.Add(OnDownloader);
|
||||
|
||||
EventUtil.RemoveListener(HotMainEvent.DownloaderProgressUpdate,OnDownloaderProgressUpdate);
|
||||
EventUtil.RemoveListener(HotLauncherEvent.InitSuccess,OnInitSuccess);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OnDownloader(EventContext context)
|
||||
{
|
||||
if (UIView.m_Type.selectedIndex != 2)
|
||||
{
|
||||
EventUtil.DispatchEvent(HotMainEvent.StartDownloader);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventUtil.DispatchEvent(HotLauncherEvent.GoGameMain);
|
||||
SHFrameModule.UI.Close("Launcher", "Launcher");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化完成 进入游戏
|
||||
/// </summary>
|
||||
/// <param name="eventargs"></param>
|
||||
private void OnInitSuccess(EventArgs eventargs)
|
||||
{
|
||||
UIView.m_Type.selectedIndex = 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源更新进度
|
||||
/// </summary>
|
||||
private void OnDownloaderProgressUpdate(EventArgs eventargs)
|
||||
{
|
||||
int totalCount = (int)eventargs.args[0];
|
||||
int currentCount = (int)eventargs.args[1];
|
||||
long totalBytes = (long)eventargs.args[2];
|
||||
long currentBytes = (long)eventargs.args[3];
|
||||
|
||||
if (currentBytes <= 0)
|
||||
{
|
||||
UIView.m_progress.value = 0;
|
||||
}else
|
||||
{
|
||||
UIView.m_progress.value = (currentBytes*100) / totalBytes;
|
||||
}
|
||||
UIView.m_title.text = $"文件总数:{totalCount}, 已下载文件数:{currentCount}, 下载总大小:{totalBytes}, 已下载大小:{currentBytes}";
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f0dc1f485ca487e8a69893724fdd2bd
|
||||
timeCreated: 1729011198
|
Reference in New Issue
Block a user