機能追加: 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
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
// Engines/Nwjs/NwjsDetector.cs — 汎用 NW.js ゲーム検出およびメタデータ解決ヘルパー
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Media;
|
||||
using GameLauncher.Engines.Common;
|
||||
using GameLauncher.Engines.Tkool;
|
||||
using GameLauncher.Engines.Unity;
|
||||
using GameLauncher.Models;
|
||||
@@ -14,10 +13,12 @@ using GameLauncher.Models;
|
||||
namespace GameLauncher.Engines.Nwjs
|
||||
{
|
||||
/// <summary>
|
||||
/// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス
|
||||
/// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス。
|
||||
/// </summary>
|
||||
public static class NwjsDetector
|
||||
{
|
||||
#region □変数(Private)
|
||||
|
||||
private static readonly HashSet<string> ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"notification_helper.exe",
|
||||
@@ -25,6 +26,10 @@ namespace GameLauncher.Engines.Nwjs
|
||||
"elevate.exe"
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region □メソッド(Public)
|
||||
|
||||
/// <summary>
|
||||
/// 指定されたディレクトリが汎用 NW.js ゲームであるかを判定します。
|
||||
/// ツクール(MV/MZ/RGSS)、ティラノスクリプト、ウディタ、SRPG Studio など既存エンジン形式は除外します。
|
||||
@@ -69,7 +74,7 @@ namespace GameLauncher.Engines.Nwjs
|
||||
}
|
||||
|
||||
// package.json に main や window 記述があるか確認
|
||||
if (TryReadPackageJson(dirPath, out _, out _, out var main, out _))
|
||||
if (NwjsDetector.TryReadPackageJson(dirPath, out _, out _, out var main, out _))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(main) && File.Exists(Path.Combine(dirPath, main)))
|
||||
{
|
||||
@@ -101,12 +106,12 @@ namespace GameLauncher.Engines.Nwjs
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsNwjsGame(dirPath))
|
||||
if (!NwjsDetector.IsNwjsGame(dirPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
TryReadPackageJson(dirPath, out var windowTitle, out var packageName, out var mainFile, out var iconRelPath);
|
||||
NwjsDetector.TryReadPackageJson(dirPath, out var windowTitle, out var packageName, out var mainFile, out var iconRelPath);
|
||||
|
||||
// タイトルの決定: window.title > index.html の <title> > package.json の name > フォルダ名
|
||||
string title = string.Empty;
|
||||
@@ -121,7 +126,7 @@ namespace GameLauncher.Engines.Nwjs
|
||||
? Path.Combine(dirPath, mainFile)
|
||||
: Path.Combine(dirPath, "index.html");
|
||||
|
||||
title = ExtractHtmlTitle(htmlPath);
|
||||
title = NwjsDetector.ExtractHtmlTitle(htmlPath);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(packageName))
|
||||
@@ -135,7 +140,7 @@ namespace GameLauncher.Engines.Nwjs
|
||||
}
|
||||
|
||||
// 実行ファイルの探索
|
||||
var exePath = FindNwjsExecutable(dirPath, title, packageName);
|
||||
var exePath = NwjsDetector.FindNwjsExecutable(dirPath, title, packageName);
|
||||
|
||||
// アイコンの取得
|
||||
ImageSource? icon = null;
|
||||
@@ -144,17 +149,29 @@ namespace GameLauncher.Engines.Nwjs
|
||||
icon = iconLoader(exePath, dirPath);
|
||||
}
|
||||
|
||||
string entryHtmlPath = NwjsDetector.ResolveEntryHtmlPath(dirPath, mainFile);
|
||||
string entryDirPath = !string.IsNullOrEmpty(entryHtmlPath)
|
||||
? (Path.GetDirectoryName(entryHtmlPath) ?? dirPath)
|
||||
: dirPath;
|
||||
bool isModded = !string.IsNullOrEmpty(entryHtmlPath) && NwjsModService.CheckIsModded(entryHtmlPath);
|
||||
var saveFiles = NwjsSaveService.FindSaveFiles(dirPath, folderName);
|
||||
string saveDirPath = saveFiles.Count > 0
|
||||
? (Path.GetDirectoryName(saveFiles[0].FilePath) ?? dirPath)
|
||||
: string.Empty;
|
||||
|
||||
return new TkoolGameItem
|
||||
{
|
||||
Title = title,
|
||||
FolderName = folderName,
|
||||
RootDirectory = dirPath,
|
||||
ExecutablePath = exePath ?? string.Empty,
|
||||
PluginsJsPath = string.Empty,
|
||||
PluginsDirPath = string.Empty,
|
||||
PluginsJsPath = entryHtmlPath,
|
||||
PluginsDirPath = entryDirPath,
|
||||
EngineType = TkoolEngineType.Nwjs,
|
||||
IsModded = false,
|
||||
ApplyMod = false,
|
||||
IsModded = isModded,
|
||||
ApplyMod = isModded,
|
||||
HasSaveData = saveFiles.Count > 0,
|
||||
// セーブデータ有無
|
||||
IconImage = icon,
|
||||
FolderLastModified = folderModified
|
||||
};
|
||||
@@ -165,6 +182,50 @@ namespace GameLauncher.Engines.Nwjs
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NW.js ゲームのエントリ HTML ファイル(index.html 等)の絶対パスを解決します。
|
||||
/// </summary>
|
||||
/// <param name="dirPath">ゲームルートディレクトリ</param>
|
||||
/// <param name="mainFromPackage">package.json の main フィールド(省略可)</param>
|
||||
/// <returns>存在する HTML ファイルのフルパス。見つからない場合は空文字列</returns>
|
||||
public static string ResolveEntryHtmlPath(string dirPath, string? mainFromPackage = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(mainFromPackage))
|
||||
{
|
||||
NwjsDetector.TryReadPackageJson(dirPath, out _, out _, out mainFromPackage, out _);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mainFromPackage))
|
||||
{
|
||||
string candidate = Path.Combine(dirPath, mainFromPackage.TrimStart('/', '\\'));
|
||||
string ext = Path.GetExtension(candidate);
|
||||
if ((ext.Equals(".html", StringComparison.OrdinalIgnoreCase) || ext.Equals(".htm", StringComparison.OrdinalIgnoreCase)) &&
|
||||
File.Exists(candidate))
|
||||
{
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
string rootIndex = Path.Combine(dirPath, "index.html");
|
||||
if (File.Exists(rootIndex))
|
||||
{
|
||||
return rootIndex;
|
||||
}
|
||||
|
||||
string wwwIndex = Path.Combine(dirPath, "www", "index.html");
|
||||
if (File.Exists(wwwIndex))
|
||||
{
|
||||
return wwwIndex;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NW.js ゲーム用の実行可能ファイル(.exe)を探索します。
|
||||
/// notification_helper.exe などの Chromium 内部ユーティリティを除外し、ゲーム本体の exe を特定します。
|
||||
@@ -185,10 +246,12 @@ namespace GameLauncher.Engines.Nwjs
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ExcludedExeNames.Contains(fileName))
|
||||
|
||||
if (NwjsDetector.ExcludedExeNames.Contains(fileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.ToList();
|
||||
@@ -244,6 +307,10 @@ namespace GameLauncher.Engines.Nwjs
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region □メソッド(Private)
|
||||
|
||||
/// <summary>
|
||||
/// package.json を読み込み、主要な設定値を抽出します。
|
||||
/// </summary>
|
||||
@@ -328,5 +395,7 @@ namespace GameLauncher.Engines.Nwjs
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user