mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
chore: LoadResource添加onlyReloadOTA
This commit is contained in:
@@ -70,7 +70,7 @@ namespace MaaWpfGui.Main
|
||||
[DllImport("MaaCore.dll")]
|
||||
private static extern unsafe bool AsstLoadResource(byte* dirname);
|
||||
|
||||
public static unsafe bool AsstLoadResource(string dirname)
|
||||
private static unsafe bool AsstLoadResource(string dirname)
|
||||
{
|
||||
fixed (byte* ptr = EncodeNullTerminatedUTF8(dirname))
|
||||
{
|
||||
@@ -199,10 +199,11 @@ namespace MaaWpfGui.Main
|
||||
/// <summary>
|
||||
/// 加载全局资源。
|
||||
/// </summary>
|
||||
/// <param name="onlyReloadOTA">是否强制加载ota资源。</param>
|
||||
/// <returns>是否成功。</returns>
|
||||
public bool LoadResource()
|
||||
public bool LoadResource(bool onlyReloadOTA = false)
|
||||
{
|
||||
if (!ForcedReloadResource && _settingsViewModel.ClientType == _curResource)
|
||||
if (!ForcedReloadResource && !onlyReloadOTA && _settingsViewModel.ClientType == _curResource)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -212,12 +213,15 @@ namespace MaaWpfGui.Main
|
||||
|| _settingsViewModel.ClientType == "Official" || _settingsViewModel.ClientType == "Bilibili")
|
||||
{
|
||||
// The resources of Official and Bilibili are the same
|
||||
if (!ForcedReloadResource && (_curResource == "Official" || _curResource == "Bilibili"))
|
||||
if (!ForcedReloadResource && !onlyReloadOTA && (_curResource == "Official" || _curResource == "Bilibili"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory());
|
||||
if (!onlyReloadOTA)
|
||||
{
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory());
|
||||
}
|
||||
|
||||
// Load the cached incremental resources
|
||||
loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache");
|
||||
@@ -226,17 +230,24 @@ namespace MaaWpfGui.Main
|
||||
{
|
||||
// Load basic resources for CN client first
|
||||
// Then load global incremental resources
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory() + "\\resource\\global\\" + _settingsViewModel.ClientType);
|
||||
if (!onlyReloadOTA)
|
||||
{
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory() + "\\resource\\global\\" + _settingsViewModel.ClientType);
|
||||
}
|
||||
|
||||
// Load the cached incremental resources
|
||||
loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache\\resource\\global\\" + _settingsViewModel.ClientType);
|
||||
loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache")
|
||||
&& AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache\\resource\\global\\" + _settingsViewModel.ClientType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load basic resources for CN client first
|
||||
// Then load global incremental resources
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory())
|
||||
if (!onlyReloadOTA)
|
||||
{
|
||||
loaded = AsstLoadResource(Directory.GetCurrentDirectory())
|
||||
&& AsstLoadResource(Directory.GetCurrentDirectory() + "\\resource\\global\\" + _settingsViewModel.ClientType);
|
||||
}
|
||||
|
||||
// Load the cached incremental resources
|
||||
loaded = loaded && AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache")
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace MaaWpfGui.Services
|
||||
|
||||
// model references
|
||||
private readonly TaskQueueViewModel _taskQueueViewModel;
|
||||
private readonly AsstProxy _asstProxy;
|
||||
private readonly IMaaApiService _maaApiService;
|
||||
|
||||
private static readonly ILogger _logger = Log.ForContext<StageManager>();
|
||||
@@ -63,6 +64,7 @@ namespace MaaWpfGui.Services
|
||||
public StageManager(IContainer container)
|
||||
{
|
||||
_taskQueueViewModel = container.Get<TaskQueueViewModel>();
|
||||
_asstProxy = container.Get<AsstProxy>();
|
||||
_maaApiService = container.Get<IMaaApiService>();
|
||||
UpdateStageLocal();
|
||||
|
||||
@@ -154,8 +156,6 @@ namespace MaaWpfGui.Services
|
||||
|
||||
JObject activity = await _maaApiService.RequestMaaApiWithCache(StageApi);
|
||||
JObject tasksJson = await _maaApiService.RequestMaaApiWithCache(TasksApi);
|
||||
AsstProxy.AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache");
|
||||
|
||||
if (clientType != "Official" && tasksJson != null)
|
||||
{
|
||||
var tasksPath = "resource/global/" + clientType + '/' + TasksApi;
|
||||
@@ -164,9 +164,10 @@ namespace MaaWpfGui.Services
|
||||
// TODO: There may be an issue when the CN resource is loaded from cache (e.g. network down) while global resource is downloaded (e.g. network up again)
|
||||
// var tasksJsonClient = fromWeb ? WebService.RequestMaaApiWithCache(tasksPath) : WebService.RequestMaaApiWithCache(tasksPath);
|
||||
await _maaApiService.RequestMaaApiWithCache(tasksPath);
|
||||
AsstProxy.AsstLoadResource(Directory.GetCurrentDirectory() + "\\cache\\resource\\global\\" + clientType);
|
||||
}
|
||||
|
||||
_asstProxy.LoadResource(true);
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user