chore: bundle evbunpack tool and add EVB control/launch fixes
- Add Enigma Virtual Box (EVB) engine support: detection, badge, unpack/restore UI - Bundle evbunpack.exe under Engines/Evb/Tools/evbunpack (Apache-2.0, with LICENSE/README) - Copy Engines\\**\\Tools\\** to build output via csproj (publish already covered by publish.ps1) - Throttle evbunpack progress reporting and shorten timeout to stop UI freeze - Rename original packed exe to .glbak and write a completion marker; make Restore reverse it - Launch the unpacked exe from _evb_extracted so script mods apply - Replace EVB MessageBox dialogs with readable log summaries - Remove obsolete boxed/7zip extraction code (NwjsPackageUnpacker, TkoolPackagedExtractionService)
This commit is contained in:
1 parent
8cea2a147d
commit
05e7bdb3c0
23 files changed
+1542
-1288
No files matched your search
+80
-130
@@ -23,6 +23,8 @@ using GameLauncher.Engines.Tyrano;
|
||||
using GameLauncher.Engines.Wolf;
|
||||
using GameLauncher.Engines.Unity;
|
||||
using GameLauncher.Engines.Nwjs;
|
||||
using GameLauncher.Engines.Common;
|
||||
using GameLauncher.Engines.Evb;
|
||||
|
||||
namespace GameLauncher
|
||||
{
|
||||
@@ -42,7 +44,6 @@ namespace GameLauncher
|
||||
private readonly WolfModService _wolfModService = new();
|
||||
private readonly SrpgArchiveService _srpgArchiveService = new();
|
||||
private readonly SrpgModService _srpgModService = new();
|
||||
private readonly TkoolPackagedExtractionService _extractionService = new();
|
||||
private readonly TkoolInjectionService _injectionService = new();
|
||||
private readonly WindowResizeService _windowResizeService = new();
|
||||
|
||||
@@ -683,10 +684,12 @@ namespace GameLauncher
|
||||
return;
|
||||
}
|
||||
|
||||
// 単体exe梱包ゲーム(FOSSIL / boxed)の場合の起動処理
|
||||
// 単体exe梱包ゲーム(FOSSIL / boxed)の場合の起動処理(起動のみ対応)。
|
||||
// EVB 解凍済みなら解凍後の exe を起動対象に切り替えます。
|
||||
if (tg.IsStandaloneExePackage)
|
||||
{
|
||||
await LaunchStandaloneExeGameAsync(tg);
|
||||
AppendLog($"[単体exe起動] {tg.Title}: 起動のみ対応(埋め込み展開機能は廃止)。");
|
||||
StartGameProcess(tg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -762,93 +765,6 @@ namespace GameLauncher
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 単体exe梱包ゲーム(FOSSIL / boxed)の起動処理。
|
||||
/// ディスク上に js 実体が無い形態は、改造適用ON時に _extracted へ展開してから注入し、
|
||||
/// 展開先が無い/展開不可の場合はそのままexeを起動する(起動対応のみ)。
|
||||
/// </summary>
|
||||
private async Task LaunchStandaloneExeGameAsync(TkoolGameItem tg)
|
||||
{
|
||||
// 1. 改造適用ON時は埋め込みコンテナを _extracted へ展開を試行(冪等)
|
||||
// 展開戦略: 組み込みZIP展開 → 外部アンパッカー委譲(未配置なら自動取得)の順で試行。
|
||||
if (tg.ApplyMod)
|
||||
{
|
||||
var progress = new Progress<string>(m => AppendLog($"[単体exe展開] {m}"));
|
||||
var relPlugins = _extractionService.ExtractPackageNw(tg.ExecutablePath, tg.RootDirectory, out var extractedDir, progress);
|
||||
|
||||
if (relPlugins != null)
|
||||
{
|
||||
tg.IsStandaloneExeExtracted = true;
|
||||
tg.StandaloneExtractedDirPath = extractedDir;
|
||||
}
|
||||
else if (tg.IsBoxedExe)
|
||||
{
|
||||
AppendLog($"[単体exe展開] {tg.Title}: 埋め込み/外部いずれの展開も不可でした(起動のみ対応)。");
|
||||
}
|
||||
|
||||
// 2. 注入可能な plugins.js が得られた場合のみ注入を適用(可逆)
|
||||
var injectable = ResolveInjectablePluginsJs(tg.RootDirectory);
|
||||
if (injectable != null)
|
||||
{
|
||||
var modPluginPath = Path.Combine(TkoolModService.GetPluginsDirectory(), TkoolInjectionService.ModPluginFileName);
|
||||
var pluginsDir = Path.GetDirectoryName(injectable)!;
|
||||
var ok = _injectionService.Apply(injectable, Path.Combine(pluginsDir, "plugins"), modPluginPath);
|
||||
AppendLog($"[単体exe改造] {tg.Title}: {(ok ? "注入しました(可逆)" : "注入に失敗しました")}");
|
||||
if (ok)
|
||||
{
|
||||
tg.IsModded = true;
|
||||
tg.StandaloneBackupPath = injectable + TkoolInjectionService.ExeBackupSuffix;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendLog($"[単体exe改造] {tg.Title}: exe内にJSが埋め込まれているため注入不可(起動のみ)。");
|
||||
}
|
||||
|
||||
_scannerService.SaveCache(_games);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 改造OFF時は復元を試行
|
||||
var injectable = ResolveInjectablePluginsJs(tg.RootDirectory);
|
||||
if (injectable != null)
|
||||
{
|
||||
var pluginsDir = Path.Combine(Path.GetDirectoryName(injectable)!, "plugins");
|
||||
var ok = _injectionService.Restore(injectable, pluginsDir);
|
||||
AppendLog($"[単体exe復元] {tg.Title}: {(ok ? "オリジナルへ復元しました" : "復元に失敗しました")}");
|
||||
}
|
||||
tg.IsModded = false;
|
||||
_scannerService.SaveCache(_games);
|
||||
}
|
||||
|
||||
AppendLog($"[単体exe起動] {tg.Title} を起動します...");
|
||||
StartGameProcess(tg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 単体exe梱包ゲームで注入/復元の対象となる plugins.js を解決します。
|
||||
/// 優先順: `_extracted` 内 → ディスク上(js / www/js)。無ければ null。
|
||||
/// </summary>
|
||||
private static string? ResolveInjectablePluginsJs(string gameRootDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
var candidates = new[]
|
||||
{
|
||||
Path.Combine(gameRootDir, TkoolPackagedExtractionService.ExtractedDirName, "js", "plugins.js"),
|
||||
Path.Combine(gameRootDir, TkoolPackagedExtractionService.ExtractedDirName, "js", "plugins", "plugins.js"),
|
||||
Path.Combine(gameRootDir, TkoolPackagedExtractionService.ExtractedDirName, "www", "js", "plugins.js"),
|
||||
Path.Combine(gameRootDir, "js", "plugins.js"),
|
||||
Path.Combine(gameRootDir, "www", "js", "plugins.js"),
|
||||
};
|
||||
return candidates.FirstOrDefault(File.Exists);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchUnityGame(UnityGameItem ug)
|
||||
{
|
||||
AppendLog($"[Unity起動] {ug.Title} (Backend: {ug.BackendBadgeText}) を起動します...");
|
||||
@@ -857,11 +773,21 @@ namespace GameLauncher
|
||||
|
||||
private void StartGameProcess(GameItemBase game)
|
||||
{
|
||||
var workingDir = Path.GetDirectoryName(game.ExecutablePath) ?? game.RootDirectory;
|
||||
// EVB 解凍済みのゲームは、解凍後の exe を起動対象に切り替えます
|
||||
// (元 exe は .glbak に退避済み。他ゲームには影響しません)。
|
||||
var launchExe = game is TkoolGameItem evbItem
|
||||
? evbItem.ResolveLaunchExecutable()
|
||||
: game.ExecutablePath;
|
||||
if (game is TkoolGameItem && launchExe != game.ExecutablePath)
|
||||
{
|
||||
AppendLog($"[EVB起動] 解凍後の実行ファイルを使用: {Path.GetFileName(launchExe)}");
|
||||
}
|
||||
|
||||
var workingDir = Path.GetDirectoryName(launchExe) ?? game.RootDirectory;
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = game.ExecutablePath,
|
||||
FileName = launchExe,
|
||||
WorkingDirectory = workingDir,
|
||||
UseShellExecute = true
|
||||
};
|
||||
@@ -1060,70 +986,94 @@ namespace GameLauncher
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 単体exe梱包ゲーム(FOSSIL / boxed)の埋め込みコンテナを _extracted へ展開します。
|
||||
/// Enigma Virtual Box (EVB) でパックされたゲームを evbunpack で解凍し、
|
||||
/// 本来のエンジンを再判定します。元の exe は .glbak としてバックアップされます。
|
||||
/// </summary>
|
||||
private async void btnExtractStandalone_Click(object sender, RoutedEventArgs e)
|
||||
private async void btnEvbUnpack_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsStandaloneExePackage) return;
|
||||
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsEvbPacked) return;
|
||||
|
||||
btnExtractStandalone.IsEnabled = false;
|
||||
AppendLog($"[単体exe展開開始] {tg.Title}");
|
||||
btnEvbUnpack.IsEnabled = false;
|
||||
AppendLog($"[EVB解凍開始] {tg.Title}");
|
||||
try
|
||||
{
|
||||
var progress = new Progress<string>(m => AppendLog($"[単体exe展開] {m}"));
|
||||
var relPlugins = await Task.Run(() =>
|
||||
_extractionService.ExtractPackageNw(tg.ExecutablePath, tg.RootDirectory, out var dir, progress));
|
||||
var progress = new Progress<string>(m => AppendLog($"[EVB解凍] {m}"));
|
||||
var result = await Task.Run(() =>
|
||||
new EvbUnpackService().Unpack(tg.RootDirectory, progress));
|
||||
|
||||
if (relPlugins != null)
|
||||
if (result.Success)
|
||||
{
|
||||
tg.IsStandaloneExeExtracted = true;
|
||||
tg.StandaloneExtractedDirPath = TkoolPackagedExtractionService.GetExtractedDir(tg.RootDirectory);
|
||||
tg.IsEvbExtracted = true;
|
||||
tg.EvbExtractedDirPath = result.OutputDirectory;
|
||||
tg.EvbBackupPath = result.BackupExePath;
|
||||
tg.EvbUnderlyingEngine = result.UnderlyingEngine == EngineDetectionHelper.EngineUnknown
|
||||
? string.Empty
|
||||
: result.UnderlyingEngine;
|
||||
_scannerService.SaveCache(_games);
|
||||
AppendLog($"[単体exe展開成功] {tg.Title}: {relPlugins}");
|
||||
MessageBox.Show("埋め込みコンテナを _extracted へ展開しました。", "埋め込み展開",
|
||||
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
AppendLog("[EVB解凍完了] ==============================");
|
||||
AppendLog($" ・対象 : {tg.Title}");
|
||||
AppendLog($" ・出力先 : {result.OutputDirectory}");
|
||||
if (!string.IsNullOrEmpty(result.BackupExePath))
|
||||
{
|
||||
AppendLog($" ・元exe : {Path.GetFileName(result.BackupExePath)}(.glbak に退避済み)");
|
||||
}
|
||||
AppendLog($" ・本来のエンジン: {(string.IsNullOrEmpty(tg.EvbUnderlyingEngine) ? "未判定" : tg.EvbUnderlyingEngine)}");
|
||||
AppendLog(" ・次の操作: 再スキャンすると解凍後の内容で起動できます。");
|
||||
AppendLog("[EVB解凍完了] ==============================");
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendLog($"[単体exe展開失敗] {tg.Title}: exe内に展開可能なZIPコンテナを検出できませんでした。");
|
||||
MessageBox.Show("exe内に展開可能なZIPコンテナを検出できませんでした。起動対応のみ可能です。",
|
||||
"埋め込み展開", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
AppendLog("[EVB解凍失敗] ==============================");
|
||||
AppendLog($" ・対象 : {tg.Title}");
|
||||
AppendLog($" ・原因 : {result.Message}");
|
||||
AppendLog(" ・対処 : evbunpack.exe の配置確認、または -pe 10_70 / 7_80 を変えて再試行してください。");
|
||||
AppendLog("[EVB解凍失敗] ==============================");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
btnExtractStandalone.IsEnabled = true;
|
||||
btnEvbUnpack.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 単体exe梱包ゲームの改造プラグイン注入を除去し、オリジナル状態へ復元します(可逆)。
|
||||
/// EVB 解凍の出力フォルダを削除して元の状態へ戻します(元 exe のバックアップは保持)。
|
||||
/// </summary>
|
||||
private void btnRestoreStandalone_Click(object sender, RoutedEventArgs e)
|
||||
private void btnEvbRestore_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsStandaloneExePackage) return;
|
||||
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsEvbPacked) return;
|
||||
|
||||
var injectable = ResolveInjectablePluginsJs(tg.RootDirectory);
|
||||
if (injectable == null)
|
||||
{
|
||||
AppendLog($"[単体exe復元] {tg.Title}: 復元対象の plugins.js が見つかりません。");
|
||||
MessageBox.Show("復元対象の plugins.js が見つかりません。", "改造の復元",
|
||||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
var progress = new Progress<string>(m => AppendLog($"[EVB復元] {m}"));
|
||||
var restored = EvbUnpackService.Restore(tg.RootDirectory, progress);
|
||||
|
||||
var pluginsDir = Path.Combine(Path.GetDirectoryName(injectable)!, "plugins");
|
||||
var ok = _injectionService.Restore(injectable, pluginsDir);
|
||||
if (ok)
|
||||
if (restored)
|
||||
{
|
||||
tg.IsModded = false;
|
||||
tg.StandaloneBackupPath = null;
|
||||
tg.IsEvbExtracted = false;
|
||||
tg.EvbExtractedDirPath = null;
|
||||
tg.EvbUnderlyingEngine = string.Empty;
|
||||
_scannerService.SaveCache(_games);
|
||||
AppendLog("[EVB復元完了] ==============================");
|
||||
AppendLog($" ・対象 : {tg.Title}");
|
||||
AppendLog(" ・内容 : 解凍フォルダを削除し、元 exe(.glbak)を復元しました。");
|
||||
AppendLog("[EVB復元完了] ==============================");
|
||||
}
|
||||
AppendLog($"[単体exe復元{(ok ? "成功" : "失敗")}] {tg.Title}");
|
||||
MessageBox.Show(ok ? "ゲームを改造前のオリジナル状態へ復元しました。" : "復元に失敗しました。",
|
||||
"改造の復元", MessageBoxButton.OK,
|
||||
ok ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
||||
else
|
||||
{
|
||||
AppendLog("[EVB復元] ==============================");
|
||||
AppendLog($" ・対象 : {tg.Title}");
|
||||
AppendLog(" ・内容 : 復元対象(解凍フォルダ / .glbak)がありません。");
|
||||
AppendLog("[EVB復元] ==============================");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右側の詳細パネルを折りたたみ/展開し、横幅の狭い表示でも一覧を見やすくします。
|
||||
/// </summary>
|
||||
private void btnToggleDetails_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool collapse = scvDetails.Visibility == Visibility.Visible;
|
||||
scvDetails.Visibility = collapse ? Visibility.Collapsed : Visibility.Visible;
|
||||
btnToggleDetails.Content = collapse ? "▸ 詳細を表示" : "▾ 詳細を折りたたむ";
|
||||
}
|
||||
|
||||
private async Task RestoreAsarForGame(TkoolGameItem tg)
|
||||
|
||||
Reference in new issue
Block a user