feat(scanner): 起動時フリーズ解消(完全非同期化)とステータスバー最下部プログレスバー連携
This commit is contained in:
1 parent
6447fc2635
commit
dc03f5284a
3 files changed
+82
-69
No files matched your search
@@ -229,67 +229,8 @@ namespace GameLauncher.Services
|
||||
item.PluginSettings = new Dictionary<string, bool>(entry.PluginSettings, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
// 既存キャッシュの自動修復: ウディタの誤判定を修正
|
||||
if (item.EngineType is TkoolEngineType.VX or TkoolEngineType.VXAce && HasWolfGame(item.RootDirectory, out var wolfDir))
|
||||
{
|
||||
item.EngineType = TkoolEngineType.Wolf;
|
||||
item.HasRgssArchive = false;
|
||||
item.IsRgssExtracted = false;
|
||||
item.RgssArchivePath = null;
|
||||
item.PluginsJsPath = string.Empty;
|
||||
item.PluginsDirPath = string.Empty;
|
||||
item.HasWolfArchive = File.Exists(Path.Combine(wolfDir, "Data.wolf")) ||
|
||||
(Directory.Exists(wolfDir) && Directory.GetFiles(wolfDir, "*.wolf", SearchOption.TopDirectoryOnly).Length > 0);
|
||||
item.IsWolfExtracted = Directory.Exists(Path.Combine(wolfDir, "Data"));
|
||||
item.WolfProxyDll = File.Exists(Path.Combine(wolfDir, WolfModService.ProxyDllName));
|
||||
item.IsModded = item.WolfProxyDll;
|
||||
}
|
||||
|
||||
// 既存キャッシュの自動修復: SRPG Studio の誤判定 (VX/VXAce) を修正
|
||||
if (item.EngineType is TkoolEngineType.VX or TkoolEngineType.VXAce && HasSrpgStudioGame(item.RootDirectory, out var srpgDir))
|
||||
{
|
||||
item.EngineType = TkoolEngineType.SrpgStudio;
|
||||
item.HasRgssArchive = false;
|
||||
item.IsRgssExtracted = false;
|
||||
item.RgssArchivePath = null;
|
||||
item.PluginsJsPath = string.Empty;
|
||||
item.PluginsDirPath = string.Empty;
|
||||
item.HasSrpgArchive = File.Exists(Path.Combine(srpgDir, "data.dts"));
|
||||
item.IsSrpgExtracted = Directory.Exists(Path.Combine(srpgDir, "data_extracted")) || (Directory.Exists(Path.Combine(srpgDir, "Script")) && Directory.Exists(Path.Combine(srpgDir, "Plugin")));
|
||||
item.SrpgArchivePath = item.HasSrpgArchive ? Path.Combine(srpgDir, "data.dts") : null;
|
||||
item.SrpgProxyDll = File.Exists(Path.Combine(srpgDir, SrpgModService.ProxyDllName));
|
||||
item.IsModded = item.SrpgProxyDll || SrpgModService.IsModScriptApplied(srpgDir);
|
||||
}
|
||||
|
||||
// 既存キャッシュの自動修復: 文字化けタイトルの復元
|
||||
if (item.EngineType is TkoolEngineType.VX or TkoolEngineType.VXAce)
|
||||
{
|
||||
if (item.Title.Contains('\uFFFD') || item.Title.Contains("◆G◆"))
|
||||
{
|
||||
FixRgssTitleFromIni(item);
|
||||
}
|
||||
}
|
||||
|
||||
// 既存キャッシュの自動修復: 実際にEVBで圧縮され解凍可能なもののみ IsEvbPacked を維持
|
||||
if (Directory.Exists(item.RootDirectory))
|
||||
{
|
||||
string? actualEvbOutDir = null;
|
||||
bool actualEvb = EvbDetector.IsEvbGame(item.RootDirectory);
|
||||
bool actualEvbExtracted = actualEvb && EvbUnpackService.IsExtractionComplete(item.RootDirectory, out actualEvbOutDir);
|
||||
item.IsEvbPacked = actualEvb;
|
||||
item.IsEvbExtracted = actualEvbExtracted;
|
||||
if (!actualEvb)
|
||||
{
|
||||
item.EvbExtractedDirPath = null;
|
||||
item.EvbBackupPath = null;
|
||||
item.EvbUnderlyingEngine = string.Empty;
|
||||
}
|
||||
else if (actualEvbExtracted && !string.IsNullOrEmpty(actualEvbOutDir))
|
||||
{
|
||||
item.EvbExtractedDirPath = actualEvbOutDir;
|
||||
}
|
||||
}
|
||||
|
||||
// 起動時のUIブロックを防ぐため、ディスクI/O(実在検証・誤判定修正)はバックグラウンドの
|
||||
// VerifyAndEnrichGamesAsync に任せ、ここではキャッシュJSONから純粋にメモリ復元します。
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
@@ -663,6 +604,7 @@ namespace GameLauncher.Services
|
||||
List<GameItemBase> games,
|
||||
Action<GameItemBase> onGameUpdated,
|
||||
Action<GameItemBase> onGameRemoved,
|
||||
Action<int, int, string>? onProgress = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
@@ -670,8 +612,16 @@ namespace GameLauncher.Services
|
||||
var copyList = games.ToList();
|
||||
bool cacheNeedsSave = false;
|
||||
|
||||
int total = copyList.Count;
|
||||
int processed = 0;
|
||||
|
||||
foreach (var game in copyList)
|
||||
{
|
||||
processed++;
|
||||
if (onProgress != null && (processed % 5 == 0 || processed == total))
|
||||
{
|
||||
onProgress(processed, total, $"実在検証中... ({processed}/{total})");
|
||||
}
|
||||
if (ct.IsCancellationRequested) break;
|
||||
|
||||
// 実在検証
|
||||
@@ -999,6 +949,7 @@ namespace GameLauncher.Services
|
||||
IEnumerable<string> targetPaths,
|
||||
IProgress<GameItemBase> progress,
|
||||
HashSet<string> existingPaths,
|
||||
Action<string>? onStatusUpdated = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
@@ -1013,6 +964,7 @@ namespace GameLauncher.Services
|
||||
{
|
||||
if (ct.IsCancellationRequested) break;
|
||||
if (!Directory.Exists(targetPath)) continue;
|
||||
onStatusUpdated?.Invoke($"新規フォルダ走査中: {Path.GetFileName(targetPath.TrimEnd('\\', '/'))}...");
|
||||
|
||||
List<string> subDirs;
|
||||
try
|
||||
|
||||
Reference in new issue
Block a user