機能追加: Bakin・NW.jsエンジンおよびセーブ編集対応、ES3パスワード解決機能とRPGツクールMZ修正サービスの追加
This commit is contained in:
1 parent
f50976a6c0
commit
152abae1f8
33 files changed
+11356
-175
No files matched your search
+407
-80
@@ -22,6 +22,7 @@ using GameLauncher.Engines.Tyrano;
|
||||
using GameLauncher.Engines.Wolf;
|
||||
using GameLauncher.Engines.Unity;
|
||||
using GameLauncher.Engines.Nwjs;
|
||||
using GameLauncher.Engines.Bakin;
|
||||
using GameLauncher.Engines.Common;
|
||||
using GameLauncher.Engines.Evb;
|
||||
|
||||
@@ -66,6 +67,8 @@ namespace GameLauncher.Services
|
||||
public string? RgssArchivePath { get; set; }
|
||||
public bool HasWolfArchive { get; set; }
|
||||
public bool IsWolfExtracted { get; set; }
|
||||
public bool MzPixiErrorFix { get; set; } = true;
|
||||
public bool MzSpineErrorFix { get; set; } = true;
|
||||
public bool WolfProxyDll { get; set; }
|
||||
public double WolfSpeedMultiplier { get; set; } = 3.0;
|
||||
public bool HasSrpgArchive { get; set; }
|
||||
@@ -118,8 +121,10 @@ namespace GameLauncher.Services
|
||||
/// <summary>
|
||||
/// エンジン判定ロジックのバージョン。判定条件を変更したらこの値をインクリメントすると、
|
||||
/// 既存キャッシュは自動的に無効化され、次回起動時に再スキャンされます。
|
||||
/// v3: Unity製ゲームが「その他」として誤分類されたままキャッシュに残る問題を解消するため、
|
||||
/// Unity証拠(UnityPlayer.dll / *_Data / UnityCrashHandler*.exe)を再評価して再分類します。
|
||||
/// </summary>
|
||||
private const int CurrentEngineLogicVersion = 2;
|
||||
private const int CurrentEngineLogicVersion = 3;
|
||||
|
||||
static GameScannerService()
|
||||
{
|
||||
@@ -162,42 +167,63 @@ namespace GameLauncher.Services
|
||||
}
|
||||
if (entries != null)
|
||||
{
|
||||
bool cacheRepaired = false;
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry.EngineKind == (int)GameEngineKind.Unity)
|
||||
{
|
||||
var exePath = entry.ExecutablePath;
|
||||
if (!string.IsNullOrEmpty(exePath) && IsExcludedExe(exePath))
|
||||
{
|
||||
exePath = FindGameExecutable(entry.RootDirectory) ?? string.Empty;
|
||||
if (exePath != entry.ExecutablePath)
|
||||
{
|
||||
cacheRepaired = true;
|
||||
}
|
||||
}
|
||||
|
||||
list.Add(new UnityGameItem
|
||||
{
|
||||
Title = entry.Title,
|
||||
FolderName = entry.FolderName,
|
||||
RootDirectory = entry.RootDirectory,
|
||||
ExecutablePath = entry.ExecutablePath,
|
||||
ExecutablePath = exePath,
|
||||
DataDirectoryPath = entry.DataDirectoryPath,
|
||||
CompanyName = entry.CompanyName,
|
||||
ProductName = entry.ProductName,
|
||||
BackendType = (UnityBackendType)entry.UnityBackendType,
|
||||
UnityVersion = entry.UnityVersion,
|
||||
LastLaunched = entry.LastLaunched,
|
||||
FolderLastModified = entry.FolderLastModified,
|
||||
FolderLastModified = exePath != entry.ExecutablePath ? null : entry.FolderLastModified,
|
||||
IsBookmarked = entry.IsBookmarked,
|
||||
HasSaveData = entry.HasSaveData
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var exePath = entry.ExecutablePath;
|
||||
if (!string.IsNullOrEmpty(exePath) && IsExcludedExe(exePath))
|
||||
{
|
||||
exePath = FindGameExecutable(entry.RootDirectory) ?? string.Empty;
|
||||
if (exePath != entry.ExecutablePath)
|
||||
{
|
||||
cacheRepaired = true;
|
||||
}
|
||||
}
|
||||
|
||||
var item = new TkoolGameItem
|
||||
{
|
||||
Title = entry.Title,
|
||||
FolderName = entry.FolderName,
|
||||
RootDirectory = entry.RootDirectory,
|
||||
ExecutablePath = entry.ExecutablePath,
|
||||
ExecutablePath = exePath,
|
||||
PluginsJsPath = entry.PluginsJsPath,
|
||||
PluginsDirPath = entry.PluginsDirPath,
|
||||
EngineType = (TkoolEngineType)entry.TkoolEngineType,
|
||||
HasCustomApplyMod = entry.HasCustomApplyMod,
|
||||
ApplyMod = entry.ApplyMod,
|
||||
LastLaunched = entry.LastLaunched,
|
||||
FolderLastModified = entry.FolderLastModified,
|
||||
FolderLastModified = exePath != entry.ExecutablePath ? null : entry.FolderLastModified,
|
||||
IsBookmarked = entry.IsBookmarked,
|
||||
IsModded = entry.IsModded,
|
||||
IsAsar = entry.IsAsar,
|
||||
@@ -210,6 +236,8 @@ namespace GameLauncher.Services
|
||||
RgssArchivePath = entry.RgssArchivePath,
|
||||
HasWolfArchive = entry.HasWolfArchive,
|
||||
IsWolfExtracted = entry.IsWolfExtracted,
|
||||
MzPixiErrorFix = entry.MzPixiErrorFix,
|
||||
MzSpineErrorFix = entry.MzSpineErrorFix,
|
||||
WolfProxyDll = entry.WolfProxyDll,
|
||||
WolfSpeedMultiplier = entry.WolfSpeedMultiplier > 0 ? entry.WolfSpeedMultiplier : 3.0,
|
||||
HasSrpgArchive = entry.HasSrpgArchive,
|
||||
@@ -223,18 +251,53 @@ namespace GameLauncher.Services
|
||||
IsEvbExtracted = entry.IsEvbExtracted,
|
||||
EvbExtractedDirPath = entry.EvbExtractedDirPath,
|
||||
EvbBackupPath = entry.EvbBackupPath,
|
||||
EvbUnderlyingEngine = entry.EvbUnderlyingEngine
|
||||
EvbUnderlyingEngine = entry.EvbUnderlyingEngine,
|
||||
HasSaveData = entry.HasSaveData
|
||||
};
|
||||
if (entry.PluginSettings != null)
|
||||
{
|
||||
item.PluginSettings = new Dictionary<string, bool>(entry.PluginSettings, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
if (item.IsOther && BakinDetector.IsBakinGame(item.RootDirectory))
|
||||
{
|
||||
item.EngineType = TkoolEngineType.Bakin;
|
||||
item.HasSaveData = BakinSaveService.HasAnySaveData(item.RootDirectory);
|
||||
var bakinExe = BakinDetector.FindBakinExecutable(item.RootDirectory, item.FolderName);
|
||||
if (!string.IsNullOrEmpty(bakinExe))
|
||||
{
|
||||
item.ExecutablePath = bakinExe;
|
||||
}
|
||||
cacheRepaired = true;
|
||||
}
|
||||
else if (item.IsBakin)
|
||||
{
|
||||
bool bakinHasSave = BakinSaveService.HasAnySaveData(item.RootDirectory);
|
||||
if (item.HasSaveData != bakinHasSave)
|
||||
{
|
||||
item.HasSaveData = bakinHasSave;
|
||||
cacheRepaired = true;
|
||||
}
|
||||
}
|
||||
if (item.IsNwjs && string.IsNullOrEmpty(item.PluginsJsPath))
|
||||
{
|
||||
item.PluginsJsPath = NwjsDetector.ResolveEntryHtmlPath(item.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(item.PluginsJsPath))
|
||||
{
|
||||
item.PluginsDirPath = Path.GetDirectoryName(item.PluginsJsPath) ?? item.RootDirectory;
|
||||
item.IsModded = NwjsModService.CheckIsModded(item.PluginsJsPath);
|
||||
cacheRepaired = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 起動時のUIブロックを防ぐため、ディスクI/O(実在検証・誤判定修正)はバックグラウンドの
|
||||
// VerifyAndEnrichGamesAsync に任せ、ここではキャッシュJSONから純粋にメモリ復元します。
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
if (cacheRepaired)
|
||||
{
|
||||
this.SaveCache(list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -484,6 +547,8 @@ namespace GameLauncher.Services
|
||||
RgssArchivePath = tg.RgssArchivePath,
|
||||
HasWolfArchive = tg.HasWolfArchive,
|
||||
IsWolfExtracted = tg.IsWolfExtracted,
|
||||
MzPixiErrorFix = tg.MzPixiErrorFix,
|
||||
MzSpineErrorFix = tg.MzSpineErrorFix,
|
||||
WolfProxyDll = tg.WolfProxyDll,
|
||||
WolfSpeedMultiplier = tg.WolfSpeedMultiplier,
|
||||
HasSrpgArchive = tg.HasSrpgArchive,
|
||||
@@ -500,7 +565,8 @@ namespace GameLauncher.Services
|
||||
IsEvbExtracted = tg.IsEvbExtracted,
|
||||
EvbExtractedDirPath = tg.EvbExtractedDirPath,
|
||||
EvbBackupPath = tg.EvbBackupPath,
|
||||
EvbUnderlyingEngine = tg.EvbUnderlyingEngine
|
||||
EvbUnderlyingEngine = tg.EvbUnderlyingEngine,
|
||||
HasSaveData = tg.HasSaveData
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -521,6 +587,27 @@ namespace GameLauncher.Services
|
||||
/// ブックマーク対象ゲームの識別キーを正規化します。
|
||||
/// タイトル変動に耐えるため、RootDirectory をフルパス化し末尾セパレータを除去した文字列をキーとします。
|
||||
/// </summary>
|
||||
private static bool NwjsEnsureMeta(TkoolGameItem tg, ref int cacheNeedsSave)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tg.PluginsJsPath) || !File.Exists(tg.PluginsJsPath))
|
||||
{
|
||||
tg.PluginsJsPath = NwjsDetector.ResolveEntryHtmlPath(tg.RootDirectory);
|
||||
tg.PluginsDirPath = !string.IsNullOrEmpty(tg.PluginsJsPath)
|
||||
? (Path.GetDirectoryName(tg.PluginsJsPath) ?? tg.RootDirectory)
|
||||
: tg.RootDirectory;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
|
||||
bool nwjsHasSave = NwjsSaveService.HasAnySaveData(tg.RootDirectory, tg.FolderName);
|
||||
if (tg.HasSaveData != nwjsHasSave)
|
||||
{
|
||||
tg.HasSaveData = nwjsHasSave;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string NormalizeBookmarkKey(string rootDirectory)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rootDirectory))
|
||||
@@ -656,9 +743,14 @@ namespace GameLauncher.Services
|
||||
return;
|
||||
}
|
||||
|
||||
// キャッシュのフォルダ更新日時と完全一致している場合、内部構成(exe/plugins/アーカイブ/EVB等)は不変のため
|
||||
// 重いディスクI/O(EVBバイナリ解析、plugins.js読み取り、wolf走査等)を完全にスキップして超高速化
|
||||
bool isUnchanged = game.FolderLastModified.HasValue && game.FolderLastModified.Value == currentLastWrite;
|
||||
// キャッシュのフォルダ更新日時と完全一致しており、かつ実行ファイルが有効(除外対象でない)な場合、
|
||||
// 内部構成(exe/plugins/アーカイブ/EVB等)は不変のため重いディスクI/Oをスキップして超高速化
|
||||
bool hasInvalidExe = string.IsNullOrEmpty(game.ExecutablePath) ||
|
||||
!File.Exists(game.ExecutablePath) ||
|
||||
IsExcludedExe(game.ExecutablePath);
|
||||
bool isUnchanged = !hasInvalidExe &&
|
||||
game.FolderLastModified.HasValue &&
|
||||
game.FolderLastModified.Value == currentLastWrite;
|
||||
if (isUnchanged)
|
||||
{
|
||||
// 未ロードのアイコンのみ必要に応じてロード
|
||||
@@ -674,18 +766,19 @@ namespace GameLauncher.Services
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新があった、または初回検証の場合は更新日時を最新化
|
||||
// 更新があった、または初回検証・実行ファイル修復が必要な場合は更新日時を最新化
|
||||
game.FolderLastModified = currentLastWrite;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
|
||||
if (game is UnityGameItem ug)
|
||||
{
|
||||
if (!File.Exists(ug.ExecutablePath))
|
||||
if (!File.Exists(ug.ExecutablePath) || IsExcludedExe(ug.ExecutablePath))
|
||||
{
|
||||
var recovered = FindGameExecutable(ug.RootDirectory);
|
||||
var recovered = this.FindUnityExecutable(ug.RootDirectory, ug.DataDirectoryPath);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
ug.ExecutablePath = recovered;
|
||||
ug.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else
|
||||
@@ -777,15 +870,16 @@ namespace GameLauncher.Services
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
|
||||
// 実在検証
|
||||
// 実在検証および除外対象exe(notification_helper.exe等)からの自動修復
|
||||
if (tg.IsWolf)
|
||||
{
|
||||
if (!File.Exists(tg.ExecutablePath))
|
||||
if (!File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else
|
||||
@@ -814,12 +908,13 @@ namespace GameLauncher.Services
|
||||
}
|
||||
else if (tg.IsSrpgStudio)
|
||||
{
|
||||
if (!File.Exists(tg.ExecutablePath))
|
||||
if (!File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else
|
||||
@@ -874,6 +969,17 @@ namespace GameLauncher.Services
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
if (string.IsNullOrEmpty(tg.ExecutablePath) || !File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = this.FindTkoolExecutable(tg.RootDirectory, tg.AsarExtractedDirPath ?? tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tg.IsRgss)
|
||||
{
|
||||
@@ -887,6 +993,18 @@ namespace GameLauncher.Services
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tg.ExecutablePath) || !File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = FindRgssExecutable(tg.RootDirectory, tg.RootDirectory) ?? FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
}
|
||||
|
||||
if (tg.IsRgssExtracted != scriptExists)
|
||||
{
|
||||
tg.IsRgssExtracted = scriptExists;
|
||||
@@ -894,23 +1012,77 @@ namespace GameLauncher.Services
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
}
|
||||
else if (tg.IsNwjs)
|
||||
else if (tg.IsNwjs && NwjsEnsureMeta(tg, ref cacheNeedsSave))
|
||||
{
|
||||
if (!File.Exists(tg.ExecutablePath) && !File.Exists(Path.Combine(tg.RootDirectory, "package.json")))
|
||||
{
|
||||
onGameRemoved(tg);
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (tg.IsEvbPacked || tg.IsStandaloneExePackage || tg.IsOther)
|
||||
{
|
||||
if (!File.Exists(tg.ExecutablePath))
|
||||
if (!File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else if (!File.Exists(Path.Combine(tg.RootDirectory, "package.json")))
|
||||
{
|
||||
onGameRemoved(tg);
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tg.IsBakin)
|
||||
{
|
||||
if (!File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = BakinDetector.FindBakinExecutable(tg.RootDirectory, tg.FolderName) ?? FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else if (!BakinDetector.IsBakinGame(tg.RootDirectory))
|
||||
{
|
||||
onGameRemoved(tg);
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool bakinSave = BakinSaveService.HasAnySaveData(tg.RootDirectory);
|
||||
if (tg.HasSaveData != bakinSave)
|
||||
{
|
||||
tg.HasSaveData = bakinSave;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
}
|
||||
else if (tg.IsEvbPacked || tg.IsStandaloneExePackage || tg.IsOther)
|
||||
{
|
||||
// 「その他」としてキャッシュされていても、Unityの強い証拠があれば Unity として再分類する。
|
||||
// (旧バージョンの判定でその他扱いになったまま残った項目の自己修復用)
|
||||
if (tg.IsOther && HasStrongUnityEvidence(tg.RootDirectory))
|
||||
{
|
||||
var promoted = this.DetectUnityGameInDirectory(tg.RootDirectory);
|
||||
if (promoted != null)
|
||||
{
|
||||
// ユーザー設定(ブックマーク・ラベル等)は従来の項目から引き継ぐ
|
||||
promoted.IsBookmarked = tg.IsBookmarked;
|
||||
promoted.LastLaunched = tg.LastLaunched;
|
||||
promoted.FolderLastModified = tg.FolderLastModified;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(promoted);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var recovered = FindGameExecutable(tg.RootDirectory);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
}
|
||||
else
|
||||
@@ -929,6 +1101,19 @@ namespace GameLauncher.Services
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(tg.ExecutablePath) || !File.Exists(tg.ExecutablePath) || IsExcludedExe(tg.ExecutablePath))
|
||||
{
|
||||
var jsDir = Path.GetDirectoryName(tg.PluginsJsPath) ?? tg.RootDirectory;
|
||||
var recovered = this.FindTkoolExecutable(tg.RootDirectory, jsDir);
|
||||
if (!string.IsNullOrEmpty(recovered))
|
||||
{
|
||||
tg.ExecutablePath = recovered;
|
||||
tg.IconImage = null;
|
||||
Interlocked.Exchange(ref cacheNeedsSave, 1);
|
||||
onGameUpdated(tg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// フォルダ更新日時
|
||||
@@ -944,7 +1129,7 @@ namespace GameLauncher.Services
|
||||
}
|
||||
|
||||
// 改造状態の確認
|
||||
if (tg.IsWolf || tg.IsNwjs)
|
||||
if (tg.IsWolf)
|
||||
{
|
||||
tg.IsModded = false;
|
||||
}
|
||||
@@ -958,7 +1143,11 @@ namespace GameLauncher.Services
|
||||
}
|
||||
else if (File.Exists(tg.PluginsJsPath))
|
||||
{
|
||||
if (tg.EngineType == TkoolEngineType.Tyrano)
|
||||
if (tg.IsNwjs)
|
||||
{
|
||||
tg.IsModded = NwjsModService.CheckIsModded(tg.PluginsJsPath);
|
||||
}
|
||||
else if (tg.EngineType == TkoolEngineType.Tyrano)
|
||||
{
|
||||
tg.IsModded = TyranoModService.CheckIsModded(tg.PluginsJsPath);
|
||||
}
|
||||
@@ -1604,6 +1793,12 @@ namespace GameLauncher.Services
|
||||
}
|
||||
|
||||
// 8. 汎用 NW.js ゲームの検出
|
||||
// 8. 汎用 NW.js ゲームの検出 / 9. RPG Developer Bakin ゲームの検出
|
||||
var bakinGame = BakinDetector.DetectBakinGame(dirPath, folderName, folderModified, (exe, dir) => LoadIcon(exe, dir));
|
||||
if (bakinGame != null)
|
||||
{
|
||||
return bakinGame;
|
||||
}
|
||||
var nwjsGame = NwjsDetector.DetectNwjsGame(dirPath, folderName, folderModified, (exe, dir) => LoadIcon(exe, dir));
|
||||
if (nwjsGame != null)
|
||||
{
|
||||
@@ -1738,11 +1933,10 @@ namespace GameLauncher.Services
|
||||
}
|
||||
}
|
||||
|
||||
// unins* を除外した最初のexe
|
||||
// 除外対象以外の最初のexe
|
||||
foreach (var exe in exes)
|
||||
{
|
||||
var name = Path.GetFileName(exe);
|
||||
if (name.StartsWith("unins", StringComparison.OrdinalIgnoreCase))
|
||||
if (IsExcludedExe(exe))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1993,11 +2187,7 @@ namespace GameLauncher.Services
|
||||
var exes = Directory.GetFiles(targetDir, "*.exe", SearchOption.TopDirectoryOnly);
|
||||
foreach (var exe in exes)
|
||||
{
|
||||
var name = Path.GetFileName(exe);
|
||||
if (!name.Contains("unins", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("config", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("setup", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("patch", StringComparison.OrdinalIgnoreCase))
|
||||
if (!IsExcludedExe(exe))
|
||||
{
|
||||
exePath = exe;
|
||||
break;
|
||||
@@ -2185,11 +2375,7 @@ namespace GameLauncher.Services
|
||||
var exes = Directory.GetFiles(targetDir, "*.exe", SearchOption.TopDirectoryOnly);
|
||||
foreach (var exe in exes)
|
||||
{
|
||||
var name = Path.GetFileName(exe);
|
||||
if (!name.Contains("unins", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("config", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("setup", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("patch", StringComparison.OrdinalIgnoreCase))
|
||||
if (!IsExcludedExe(exe))
|
||||
{
|
||||
exePath = exe;
|
||||
break;
|
||||
@@ -2576,10 +2762,7 @@ namespace GameLauncher.Services
|
||||
var exes = Directory.GetFiles(searchDir, "*.exe", SearchOption.TopDirectoryOnly);
|
||||
foreach (var exe in exes)
|
||||
{
|
||||
var name = Path.GetFileName(exe);
|
||||
if (!name.Contains("unins", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("extractor", StringComparison.OrdinalIgnoreCase) &&
|
||||
!name.Contains("patch", StringComparison.OrdinalIgnoreCase))
|
||||
if (!IsExcludedExe(exe))
|
||||
{
|
||||
return exe;
|
||||
}
|
||||
@@ -2814,8 +2997,15 @@ namespace GameLauncher.Services
|
||||
if (File.Exists(p)) return p;
|
||||
}
|
||||
|
||||
var folderName = Path.GetFileName(rootDir.TrimEnd('\\', '/'));
|
||||
if (!string.IsNullOrEmpty(folderName))
|
||||
{
|
||||
var namedExe = Path.Combine(rootDir, folderName + ".exe");
|
||||
if (File.Exists(namedExe) && !IsExcludedExe(namedExe)) return namedExe;
|
||||
}
|
||||
|
||||
var exes = Directory.GetFiles(rootDir, "*.exe", SearchOption.TopDirectoryOnly)
|
||||
.Where(f => !Path.GetFileName(f).StartsWith("unins", StringComparison.OrdinalIgnoreCase))
|
||||
.Where(f => !IsExcludedExe(f))
|
||||
.ToList();
|
||||
|
||||
if (exes.Count > 0) return exes[0];
|
||||
@@ -2823,8 +3013,14 @@ namespace GameLauncher.Services
|
||||
var parent = Path.GetDirectoryName(jsDir);
|
||||
if (parent != null && parent != rootDir)
|
||||
{
|
||||
foreach (var cand in candidates)
|
||||
{
|
||||
var p = Path.Combine(parent, cand);
|
||||
if (File.Exists(p)) return p;
|
||||
}
|
||||
|
||||
var pExes = Directory.GetFiles(parent, "*.exe", SearchOption.TopDirectoryOnly)
|
||||
.Where(f => !Path.GetFileName(f).StartsWith("unins", StringComparison.OrdinalIgnoreCase))
|
||||
.Where(f => !IsExcludedExe(f))
|
||||
.ToList();
|
||||
if (pExes.Count > 0) return pExes[0];
|
||||
}
|
||||
@@ -2950,7 +3146,7 @@ namespace GameLauncher.Services
|
||||
if (File.Exists(standardGameExe)) return standardGameExe;
|
||||
|
||||
var exeFiles = Directory.GetFiles(gameRoot, "*.exe", SearchOption.TopDirectoryOnly)
|
||||
.Where(f => !Regex.IsMatch(Path.GetFileName(f), @"(unins|setup|crash|handler|UnityCrash|設定|アンインストール)", RegexOptions.IgnoreCase))
|
||||
.Where(f => !IsExcludedExe(f))
|
||||
.ToList();
|
||||
|
||||
if (exeFiles.Count > 0)
|
||||
@@ -3122,6 +3318,11 @@ namespace GameLauncher.Services
|
||||
/// </summary>
|
||||
public static ImageSource? LoadCachedThumbnailFast(string? exePath, string? fallbackDir = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(exePath) && IsExcludedExe(exePath) && !string.IsNullOrEmpty(fallbackDir))
|
||||
{
|
||||
exePath = FindGameExecutable(fallbackDir);
|
||||
}
|
||||
|
||||
var keyPath = !string.IsNullOrEmpty(exePath) ? exePath : fallbackDir;
|
||||
if (string.IsNullOrEmpty(keyPath))
|
||||
{
|
||||
@@ -3138,6 +3339,13 @@ namespace GameLauncher.Services
|
||||
|
||||
if (File.Exists(thumbPath))
|
||||
{
|
||||
// 過去に汎用白紙アイコン(<=600 bytes)がキャッシュされており、かつフォルダ内に公式アイコン画像がある場合は再生成させる
|
||||
var fi = new FileInfo(thumbPath);
|
||||
if (fi.Length <= 600 && TryFindGameIconPng(fallbackDir, exePath) != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var bmp = new BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri(thumbPath);
|
||||
@@ -3155,12 +3363,26 @@ namespace GameLauncher.Services
|
||||
|
||||
public static ImageSource? LoadIcon(string? exePath, string? fallbackDir = null)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(exePath) && IsExcludedExe(exePath)) || (string.IsNullOrEmpty(exePath) && !string.IsNullOrEmpty(fallbackDir)))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fallbackDir))
|
||||
{
|
||||
var resolved = FindGameExecutable(fallbackDir);
|
||||
if (!string.IsNullOrEmpty(resolved))
|
||||
{
|
||||
exePath = resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var keyPath = !string.IsNullOrEmpty(exePath) ? exePath : fallbackDir;
|
||||
if (string.IsNullOrEmpty(keyPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var gameIconPng = TryFindGameIconPng(fallbackDir, exePath);
|
||||
|
||||
// 1. サムネイルキャッシュフォルダから即座にロードを試行
|
||||
string? thumbPath = null;
|
||||
try
|
||||
@@ -3173,22 +3395,45 @@ namespace GameLauncher.Services
|
||||
|
||||
if (File.Exists(thumbPath))
|
||||
{
|
||||
var bmp = new BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri(thumbPath);
|
||||
bmp.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bmp.DecodePixelWidth = 88;
|
||||
bmp.EndInit();
|
||||
bmp.Freeze();
|
||||
return bmp;
|
||||
var fi = new FileInfo(thumbPath);
|
||||
// キャッシュが600バイト超、または代替アイコンPNGが存在しない場合はキャッシュを使用
|
||||
if (fi.Length > 600 || gameIconPng == null)
|
||||
{
|
||||
var bmp = new BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri(thumbPath);
|
||||
bmp.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bmp.DecodePixelWidth = 88;
|
||||
bmp.EndInit();
|
||||
bmp.Freeze();
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
// 2. キャッシュに存在しない場合はアイコンまたは画像を抽出
|
||||
// 2. キャッシュに存在しない(または白紙キャッシュ更新)場合はアプリアイコンPNGまたはexeアイコンを抽出
|
||||
BitmapSource? bitmapSource = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(exePath) && File.Exists(exePath))
|
||||
// 2-1. ゲームフォルダ内の高解像度アイコンPNG (www/icon/icon.png, icon/icon.png, package.json指定等) を優先試行
|
||||
if (!string.IsNullOrEmpty(gameIconPng) && File.Exists(gameIconPng))
|
||||
{
|
||||
try
|
||||
{
|
||||
var bmp = new BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri(gameIconPng);
|
||||
bmp.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bmp.DecodePixelWidth = 88;
|
||||
bmp.EndInit();
|
||||
bmp.Freeze();
|
||||
bitmapSource = bmp;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// 2-2. 実行ファイルから関連付けアイコンを抽出
|
||||
if (bitmapSource == null && !string.IsNullOrEmpty(exePath) && File.Exists(exePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3205,25 +3450,6 @@ namespace GameLauncher.Services
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (bitmapSource == null && !string.IsNullOrEmpty(fallbackDir) && Directory.Exists(fallbackDir))
|
||||
{
|
||||
var png = Path.Combine(fallbackDir, "icon.png");
|
||||
if (File.Exists(png))
|
||||
{
|
||||
try
|
||||
{
|
||||
var bmp = new BitmapImage();
|
||||
bmp.BeginInit();
|
||||
bmp.UriSource = new Uri(png);
|
||||
bmp.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bmp.EndInit();
|
||||
bmp.Freeze();
|
||||
bitmapSource = bmp;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 取得できたアイコンをサムネイルキャッシュフォルダへ保存
|
||||
if (bitmapSource != null && !string.IsNullOrEmpty(thumbPath))
|
||||
{
|
||||
@@ -3237,6 +3463,91 @@ namespace GameLauncher.Services
|
||||
return bitmapSource;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ゲームディレクトリ内からアプリアイコン画像(package.jsonのicon指定、www/icon/icon.png、icon/icon.png、icon.png等)を探索します。
|
||||
/// </summary>
|
||||
private static string? TryFindGameIconPng(string? fallbackDir, string? exePath)
|
||||
{
|
||||
var searchDirs = new List<string>();
|
||||
if (!string.IsNullOrEmpty(fallbackDir) && Directory.Exists(fallbackDir))
|
||||
{
|
||||
searchDirs.Add(fallbackDir);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(exePath))
|
||||
{
|
||||
var exeDir = Path.GetDirectoryName(exePath);
|
||||
if (!string.IsNullOrEmpty(exeDir) && Directory.Exists(exeDir) &&
|
||||
!searchDirs.Contains(exeDir, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
searchDirs.Add(exeDir);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var baseDir in searchDirs)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. package.json の window.icon 指定を確認
|
||||
var pkgPaths = new[]
|
||||
{
|
||||
Path.Combine(baseDir, "package.json"),
|
||||
Path.Combine(baseDir, "www", "package.json")
|
||||
};
|
||||
foreach (var pkgPath in pkgPaths)
|
||||
{
|
||||
if (File.Exists(pkgPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(File.ReadAllText(pkgPath));
|
||||
if (doc.RootElement.TryGetProperty("window", out var win) &&
|
||||
win.ValueKind == JsonValueKind.Object &&
|
||||
win.TryGetProperty("icon", out var iconProp) &&
|
||||
iconProp.ValueKind == JsonValueKind.String)
|
||||
{
|
||||
var relIcon = iconProp.GetString();
|
||||
if (!string.IsNullOrWhiteSpace(relIcon))
|
||||
{
|
||||
var pkgDir = Path.GetDirectoryName(pkgPath)!;
|
||||
var resolvedFromPkg = Path.Combine(pkgDir, relIcon.Replace('/', Path.DirectorySeparatorChar));
|
||||
if (File.Exists(resolvedFromPkg))
|
||||
{
|
||||
return resolvedFromPkg;
|
||||
}
|
||||
var resolvedFromBase = Path.Combine(baseDir, relIcon.Replace('/', Path.DirectorySeparatorChar));
|
||||
if (File.Exists(resolvedFromBase))
|
||||
{
|
||||
return resolvedFromBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 定型のアイコン配置パスを確認
|
||||
var candidates = new[]
|
||||
{
|
||||
Path.Combine(baseDir, "www", "icon", "icon.png"),
|
||||
Path.Combine(baseDir, "icon", "icon.png"),
|
||||
Path.Combine(baseDir, "www", "icon.png"),
|
||||
Path.Combine(baseDir, "icon.png")
|
||||
};
|
||||
foreach (var cand in candidates)
|
||||
{
|
||||
if (File.Exists(cand))
|
||||
{
|
||||
return cand;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void SaveBitmapSourceToPng(BitmapSource source, string filePath)
|
||||
{
|
||||
try
|
||||
@@ -3353,10 +3664,26 @@ namespace GameLauncher.Services
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool IsExcludedExe(string filePath)
|
||||
/// <summary>
|
||||
/// ゲーム本体ではない補助ツール・インストーラ・通知ヘルパー・設定用実行ファイルかどうかを判定します。
|
||||
/// </summary>
|
||||
public static bool IsExcludedExe(string? filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
return Regex.IsMatch(fileName, @"^(unins|setup|install|crash|handler|UnityCrash|設定|Config|updater|patch)", RegexOptions.IgnoreCase);
|
||||
if (string.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Regex.IsMatch(
|
||||
fileName,
|
||||
@"^(unins|setup|install|crash|handler|UnityCrash|notification_helper|crashpad_handler|elevate|nacl64|nwjc|payload|minidump_stackwalk|extractor|設定|環境設定|エンジン設定|Config|updater|patch|アンインストール)|((設定|環境設定|エンジン設定|Config|Setup|Installer|Updater)\.exe$)",
|
||||
RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user