From c8f5dfddda60b90ae2aa460c1124db45a626b1b8 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Wed, 11 Sep 2024 16:48:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=A7=BB=E9=99=A4Ca?= =?UTF-8?q?che=E5=92=8CRom=E6=96=87=E4=BB=B6=E7=9A=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/Manager/CacheManager.cs | 8 ++++++++ .../Assets/Script/Manager/RomLib/RomLib.cs | 16 ++++++++++++++++ .../Assets/Script/UI/LaunchUI.cs | 2 -- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/CacheManager.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/CacheManager.cs index aed9c9cf..659d7344 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/CacheManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/CacheManager.cs @@ -18,6 +18,13 @@ namespace AxibugEmuOnline.Client GetCacheData(url, TextureCacheDirPath, callback); } + /// ÒƳýÎļþ»º´æ + public void ClearCaches() + { + if (Directory.Exists(CacheDirPath)) + Directory.Delete(CacheDirPath, true); + } + IEnumerator DownloadFromURL(string url, string path, Action callback) { var request = UnityWebRequest.Get($"{AppAxibugEmuOnline.httpAPI.DownSite}/{url}"); @@ -39,6 +46,7 @@ namespace AxibugEmuOnline.Client if (cachesInMemory.TryGetValue(url, out var cacheObj) && cacheObj is T obj) { callback.Invoke(obj, url); + return; } var fileName = $"{url.GetHashCode()}"; diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs index ebc5a6db..6703fada 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/RomLib/RomLib.cs @@ -1,6 +1,8 @@ using AxibugEmuOnline.Client.ClientCore; +using Codice.Client.Common; using System; using System.Collections.Generic; +using System.IO; using static AxibugEmuOnline.Client.HttpAPI; namespace AxibugEmuOnline.Client @@ -36,6 +38,20 @@ namespace AxibugEmuOnline.Client return romFile; } + /// 清除所有下载的Rom文件 + public void ClearRomFile() + { + var path = $"{AppAxibugEmuOnline.PersistentDataPath}/RemoteRoms/{m_platform}"; + if (Directory.Exists(path)) Directory.Delete(path, true); + } + + /// 移除一个已下载的Rom + public void RemoveOneRomFile(RomFile romFile) + { + if (romFile.RomReady) + File.Delete(romFile.LocalFilePath); + } + /// /// 获得所有Rom文件 /// diff --git a/AxibugEmuOnline.Client/Assets/Script/UI/LaunchUI.cs b/AxibugEmuOnline.Client/Assets/Script/UI/LaunchUI.cs index 808e9bb6..051c0154 100644 --- a/AxibugEmuOnline.Client/Assets/Script/UI/LaunchUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/UI/LaunchUI.cs @@ -2,8 +2,6 @@ using AxibugEmuOnline.Client.UI; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; -using System.Collections; -using System.Collections.Generic; using UnityEngine; namespace AxibugEmuOnline.Client