diff --git a/Engines/Common/EngineDetectionHelper.cs b/Engines/Common/EngineDetectionHelper.cs
index 2f44e31..4d1a666 100644
--- a/Engines/Common/EngineDetectionHelper.cs
+++ b/Engines/Common/EngineDetectionHelper.cs
@@ -136,8 +136,7 @@ namespace GameLauncher.Engines.Common
return EngineTkool;
}
- var packageJson = Path.Combine(gameDirectory, "package.json");
- if (File.Exists(packageJson) && Directory.Exists(Path.Combine(gameDirectory, "nwjs")))
+ if (Engines.Nwjs.NwjsDetector.IsNwjsGame(gameDirectory))
{
return EngineNwjs;
}
diff --git a/Engines/Nwjs/NwjsDetector.cs b/Engines/Nwjs/NwjsDetector.cs
new file mode 100644
index 0000000..f057ab3
--- /dev/null
+++ b/Engines/Nwjs/NwjsDetector.cs
@@ -0,0 +1,332 @@
+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;
+
+namespace GameLauncher.Engines.Nwjs
+{
+ ///
+ /// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス
+ ///
+ public static class NwjsDetector
+ {
+ private static readonly HashSet ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
+ {
+ "notification_helper.exe",
+ "crashpad_handler.exe",
+ "elevate.exe"
+ };
+
+ ///
+ /// 指定されたディレクトリが汎用 NW.js ゲームであるかを判定します。
+ /// ツクール(MV/MZ/RGSS)、ティラノスクリプト、ウディタ、SRPG Studio など既存エンジン形式は除外します。
+ ///
+ /// 対象ディレクトリパス
+ /// NW.js ゲームであれば true
+ public static bool IsNwjsGame(string dirPath)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
+ {
+ return false;
+ }
+
+ var packageJsonPath = Path.Combine(dirPath, "package.json");
+ if (!File.Exists(packageJsonPath))
+ {
+ return false;
+ }
+
+ // 既存の他エンジン判定(ツクール・ティラノ・ウディタ・SRPG)を最優先で除外
+ if (Directory.Exists(Path.Combine(dirPath, "www")) ||
+ File.Exists(Path.Combine(dirPath, "data", "System.json")) ||
+ File.Exists(Path.Combine(dirPath, "Game.ini")) ||
+ Directory.Exists(Path.Combine(dirPath, "tyrano")) ||
+ Directory.GetFiles(dirPath, "*.tjs", SearchOption.TopDirectoryOnly).Length > 0 ||
+ Directory.GetFiles(dirPath, "*.wolf", SearchOption.TopDirectoryOnly).Length > 0 ||
+ File.Exists(Path.Combine(dirPath, "data.dts")))
+ {
+ return false;
+ }
+
+ // NW.js の痕跡を確認
+ if (File.Exists(Path.Combine(dirPath, "nw.dll")) ||
+ File.Exists(Path.Combine(dirPath, "nw.exe")) ||
+ File.Exists(Path.Combine(dirPath, "resources.pak")) ||
+ File.Exists(Path.Combine(dirPath, "node.dll")) ||
+ Directory.Exists(Path.Combine(dirPath, "nwjs")))
+ {
+ return true;
+ }
+
+ // package.json に main や window 記述があるか確認
+ if (TryReadPackageJson(dirPath, out _, out _, out var main, out _))
+ {
+ if (!string.IsNullOrWhiteSpace(main) && File.Exists(Path.Combine(dirPath, main)))
+ {
+ return true;
+ }
+ }
+ }
+ catch
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ ///
+ /// 指定ディレクトリ内の NW.js ゲームを検出し、TkoolGameItem を生成します。
+ ///
+ /// ゲームフォルダの絶対パス
+ /// フォルダ名
+ /// フォルダ更新日時
+ /// アイコン読み込み関数
+ /// 検出されたゲームアイテム。該当しない場合は null
+ public static TkoolGameItem? DetectNwjsGame(
+ string dirPath,
+ string folderName,
+ DateTime? folderModified,
+ Func iconLoader)
+ {
+ try
+ {
+ if (!IsNwjsGame(dirPath))
+ {
+ return null;
+ }
+
+ TryReadPackageJson(dirPath, out var windowTitle, out var packageName, out var mainFile, out var iconRelPath);
+
+ // タイトルの決定: window.title > index.html の > package.json の name > フォルダ名
+ string title = string.Empty;
+ if (!string.IsNullOrWhiteSpace(windowTitle))
+ {
+ title = windowTitle.Trim();
+ }
+
+ if (string.IsNullOrWhiteSpace(title))
+ {
+ var htmlPath = !string.IsNullOrWhiteSpace(mainFile)
+ ? Path.Combine(dirPath, mainFile)
+ : Path.Combine(dirPath, "index.html");
+
+ title = ExtractHtmlTitle(htmlPath);
+ }
+
+ if (string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(packageName))
+ {
+ title = packageName.Trim();
+ }
+
+ if (string.IsNullOrWhiteSpace(title))
+ {
+ title = folderName;
+ }
+
+ // 実行ファイルの探索
+ var exePath = FindNwjsExecutable(dirPath, title, packageName);
+
+ // アイコンの取得
+ ImageSource? icon = null;
+ if (iconLoader != null)
+ {
+ icon = iconLoader(exePath, dirPath);
+ }
+
+ return new TkoolGameItem
+ {
+ Title = title,
+ FolderName = folderName,
+ RootDirectory = dirPath,
+ ExecutablePath = exePath ?? string.Empty,
+ PluginsJsPath = string.Empty,
+ PluginsDirPath = string.Empty,
+ EngineType = TkoolEngineType.Nwjs,
+ IsModded = false,
+ ApplyMod = false,
+ IconImage = icon,
+ FolderLastModified = folderModified
+ };
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// NW.js ゲーム用の実行可能ファイル(.exe)を探索します。
+ /// notification_helper.exe などの Chromium 内部ユーティリティを除外し、ゲーム本体の exe を特定します。
+ ///
+ /// ディレクトリパス
+ /// ゲームタイトル
+ /// package.json の name
+ /// 実行ファイルのパス。見つからない場合は null
+ public static string? FindNwjsExecutable(string dirPath, string? title, string? packageName)
+ {
+ try
+ {
+ var exes = Directory.GetFiles(dirPath, "*.exe", SearchOption.TopDirectoryOnly)
+ .Where(f =>
+ {
+ var fileName = Path.GetFileName(f);
+ if (fileName.StartsWith("unins", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (ExcludedExeNames.Contains(fileName))
+ {
+ return false;
+ }
+ return true;
+ })
+ .ToList();
+
+ if (exes.Count == 0)
+ {
+ return null;
+ }
+
+ if (exes.Count == 1)
+ {
+ return exes[0];
+ }
+
+ // 優先度1: タイトル名またはパッケージ名が含まれる実行ファイル
+ if (!string.IsNullOrWhiteSpace(title))
+ {
+ var match = exes.FirstOrDefault(f => Path.GetFileNameWithoutExtension(f).Contains(title, StringComparison.OrdinalIgnoreCase));
+ if (match != null)
+ {
+ return match;
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(packageName))
+ {
+ var match = exes.FirstOrDefault(f => Path.GetFileNameWithoutExtension(f).Contains(packageName, StringComparison.OrdinalIgnoreCase));
+ if (match != null)
+ {
+ return match;
+ }
+ }
+
+ // 優先度2: Game.exe または nw.exe
+ var gameExe = exes.FirstOrDefault(f => string.Equals(Path.GetFileName(f), "Game.exe", StringComparison.OrdinalIgnoreCase));
+ if (gameExe != null)
+ {
+ return gameExe;
+ }
+
+ var nwExe = exes.FirstOrDefault(f => string.Equals(Path.GetFileName(f), "nw.exe", StringComparison.OrdinalIgnoreCase));
+ if (nwExe != null)
+ {
+ return nwExe;
+ }
+
+ // 優先度3: 候補の先頭
+ return exes[0];
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// package.json を読み込み、主要な設定値を抽出します。
+ ///
+ private static bool TryReadPackageJson(
+ string dirPath,
+ out string? windowTitle,
+ out string? name,
+ out string? main,
+ out string? iconRelPath)
+ {
+ windowTitle = null;
+ name = null;
+ main = null;
+ iconRelPath = null;
+
+ try
+ {
+ var packageJsonPath = Path.Combine(dirPath, "package.json");
+ if (!File.Exists(packageJsonPath))
+ {
+ return false;
+ }
+
+ var json = File.ReadAllText(packageJsonPath);
+ using var doc = JsonDocument.Parse(json);
+ var root = doc.RootElement;
+
+ if (root.TryGetProperty("name", out var nameProp) && nameProp.ValueKind == JsonValueKind.String)
+ {
+ name = nameProp.GetString();
+ }
+
+ if (root.TryGetProperty("main", out var mainProp) && mainProp.ValueKind == JsonValueKind.String)
+ {
+ main = mainProp.GetString();
+ }
+
+ if (root.TryGetProperty("window", out var winProp) && winProp.ValueKind == JsonValueKind.Object)
+ {
+ if (winProp.TryGetProperty("title", out var titleProp) && titleProp.ValueKind == JsonValueKind.String)
+ {
+ windowTitle = titleProp.GetString();
+ }
+
+ if (winProp.TryGetProperty("icon", out var iconProp) && iconProp.ValueKind == JsonValueKind.String)
+ {
+ iconRelPath = iconProp.GetString();
+ }
+ }
+
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// HTML ファイルから title タグのテキストを抽出します。
+ ///
+ private static string ExtractHtmlTitle(string htmlPath)
+ {
+ try
+ {
+ if (!File.Exists(htmlPath))
+ {
+ return string.Empty;
+ }
+
+ var html = File.ReadAllText(htmlPath);
+ var match = Regex.Match(html, @"]*>(.*?)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
+ if (match.Success)
+ {
+ var title = match.Groups[1].Value.Trim();
+ return System.Net.WebUtility.HtmlDecode(title);
+ }
+ }
+ catch
+ {
+ }
+
+ return string.Empty;
+ }
+ }
+}
diff --git a/Engines/Tkool/TkoolGameItem.cs b/Engines/Tkool/TkoolGameItem.cs
index 61e3a41..e1e59b2 100644
--- a/Engines/Tkool/TkoolGameItem.cs
+++ b/Engines/Tkool/TkoolGameItem.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@@ -733,7 +733,7 @@ namespace GameLauncher.Engines.Tkool
public void SyncPluginOptions(IEnumerable availablePlugins, Dictionary? defaultSettings = null)
{
_pluginOptions.Clear();
- if (EngineType == TkoolEngineType.Wolf)
+ if (EngineType is TkoolEngineType.Wolf or TkoolEngineType.Nwjs)
{
return;
}
@@ -790,6 +790,7 @@ namespace GameLauncher.Engines.Tkool
TkoolEngineType.VXAce => "RPGツクールVX Ace",
TkoolEngineType.Wolf => "WOLF RPGエディター",
TkoolEngineType.SrpgStudio => "SRPG Studio",
+ TkoolEngineType.Nwjs => "NW.js",
_ => "ツクール/ティラノ"
};
}
diff --git a/Engines/Unity/UnityEnums.cs b/Engines/Unity/UnityEnums.cs
index 9e9f01d..0d00ff2 100644
--- a/Engines/Unity/UnityEnums.cs
+++ b/Engines/Unity/UnityEnums.cs
@@ -1,4 +1,4 @@
-namespace GameLauncher.Engines.Unity
+namespace GameLauncher.Engines.Unity
{
///
/// ゲームエンジンの大分類
@@ -10,7 +10,8 @@
Unity,
Wolf,
SrpgStudio,
- Evb
+ Evb,
+ Nwjs
}
///
@@ -25,6 +26,7 @@
VXAce,
Wolf,
SrpgStudio,
+ Nwjs,
Unknown
}
diff --git a/MainWindow.xaml b/MainWindow.xaml
index f8bccb1..dc1bfdd 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -42,6 +42,7 @@
+
@@ -377,6 +378,7 @@
+
@@ -630,6 +632,22 @@
+
+
+
+
+
+
+
+
@@ -911,6 +929,21 @@
+
+
+
+
+
+
+
+
@@ -954,6 +987,9 @@
+
+
+
@@ -1089,6 +1125,9 @@
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 8383f09..0f0e015 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -137,6 +137,7 @@ namespace GameLauncher
case 6: tabUnity.IsChecked = true; break;
case 7: tabWolf.IsChecked = true; break;
case 8: tabSrpg.IsChecked = true; break;
+ case 9: tabNwjs.IsChecked = true; break;
default: tabAll.IsChecked = true; break;
}
@@ -173,6 +174,7 @@ namespace GameLauncher
else if (tabUnity.IsChecked == true) tabIndex = 6;
else if (tabWolf.IsChecked == true) tabIndex = 7;
else if (tabSrpg.IsChecked == true) tabIndex = 8;
+ else if (tabNwjs.IsChecked == true) tabIndex = 9;
_config.SelectedTab = tabIndex;
_config.UnityBackendFilter = rbUnityIL2CPP.IsChecked == true ? "IL2CPP" : (rbUnityMono.IsChecked == true ? "Mono" : "All");
@@ -281,13 +283,15 @@ namespace GameLauncher
if (_games.Count > 0)
{
- int tkoolCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType != TkoolEngineType.Tyrano && !tg.IsRgss && !tg.IsWolf);
+ int tkoolCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType != TkoolEngineType.Tyrano && !tg.IsRgss && !tg.IsWolf && !tg.IsSrpgStudio && !tg.IsNwjs);
int rgssCount = _games.Count(g => g is TkoolGameItem tg && tg.IsRgss);
int tyranoCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType == TkoolEngineType.Tyrano);
int wolfCount = _games.Count(g => g is TkoolGameItem tg && tg.IsWolf);
+ int srpgCount = _games.Count(g => g is TkoolGameItem tg && tg.IsSrpgStudio);
+ int nwjsCount = _games.Count(g => g is TkoolGameItem tg && tg.IsNwjs);
int unityCount = _games.Count(g => g is UnityGameItem);
- AppendLog($"キャッシュから計 {_games.Count} 件(ツクールMV/MZ: {tkoolCount}, ツクールVX系: {rgssCount}, ティラノ: {tyranoCount}, ウディタ: {wolfCount}, Unity: {unityCount})を即時表示しました。(待たずに即起動可能です)");
+ AppendLog($"キャッシュから計 {_games.Count} 件(ツクールMV/MZ: {tkoolCount}, ツクールVX系: {rgssCount}, ティラノ: {tyranoCount}, ウディタ: {wolfCount}, SRPG Studio: {srpgCount}, NW.js: {nwjsCount}, Unity: {unityCount})を即時表示しました。(待たずに即起動可能です)");
lblStatusEngine.Text = "裏で更新・実在検証を実行中...";
}
else
@@ -472,6 +476,10 @@ namespace GameLauncher
if (rbUnityIL2CPP.IsChecked == true && ug.BackendType != UnityBackendType.IL2CPP) return false;
if (rbUnityMono.IsChecked == true && ug.BackendType != UnityBackendType.Mono) return false;
}
+ else if (tabNwjs.IsChecked == true)
+ {
+ if (game is not TkoolGameItem tg || tg.EngineType != TkoolEngineType.Nwjs) return false;
+ }
// 3. 追加属性フィルター(全タブ共通)
if (chkFilterModdedOnly.IsChecked == true && !game.IsModded) return false;
@@ -536,15 +544,16 @@ namespace GameLauncher
int total = _games.Count;
int visible = _gamesView?.Count ?? 0;
- int tkoolCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType != TkoolEngineType.Tyrano && !tg.IsRgss && !tg.IsWolf && !tg.IsSrpgStudio);
+ int tkoolCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType != TkoolEngineType.Tyrano && !tg.IsRgss && !tg.IsWolf && !tg.IsSrpgStudio && !tg.IsNwjs);
int rgssCount = _games.Count(g => g is TkoolGameItem tg && tg.IsRgss);
int tyranoCount = _games.Count(g => g is TkoolGameItem tg && tg.EngineType == TkoolEngineType.Tyrano);
int wolfCount = _games.Count(g => g is TkoolGameItem tg && tg.IsWolf);
int srpgCount = _games.Count(g => g is TkoolGameItem tg && tg.IsSrpgStudio);
+ int nwjsCount = _games.Count(g => g is TkoolGameItem tg && tg.IsNwjs);
int unityCount = _games.Count(g => g is UnityGameItem);
lblStatusSummary.Text = $"総ゲーム数: {total} 件 | 表示: {visible} 件";
- lblStatusBreakdown.Text = $"(ツクールMV/MZ: {tkoolCount}, ツクールVX系: {rgssCount}, ティラノ: {tyranoCount}, ウディタ: {wolfCount}, SRPG Studio: {srpgCount}, Unity: {unityCount})";
+ lblStatusBreakdown.Text = $"(ツクールMV/MZ: {tkoolCount}, ツクールVX系: {rgssCount}, ティラノ: {tyranoCount}, ウディタ: {wolfCount}, SRPG Studio: {srpgCount}, NW.js: {nwjsCount}, Unity: {unityCount})";
}
#endregion
diff --git a/Models/GameItemBase.cs b/Models/GameItemBase.cs
index d6d359b..417943b 100644
--- a/Models/GameItemBase.cs
+++ b/Models/GameItemBase.cs
@@ -157,6 +157,9 @@ namespace GameLauncher.Models
/// SRPG Studioか
public virtual bool IsSrpgStudio => false;
+ /// NW.js汎用ゲームか
+ public virtual bool IsNwjs => false;
+
/// プリンセスシナジー(専用改造対象のMZゲーム)か
public virtual bool IsPrincessSynergy => false;
@@ -226,6 +229,18 @@ namespace GameLauncher.Models
/// SRPG Studio詳細状態テキスト
public virtual string SrpgDetailStatusText => string.Empty;
+ /// NW.jsバッジのテキスト
+ public virtual string NwjsBadgeText => string.Empty;
+
+ /// NW.jsバッジの背景色
+ public virtual Brush NwjsBadgeBackground => Brushes.Transparent;
+
+ /// NW.jsバッジの可視性
+ public virtual Visibility NwjsBadgeVisibility => Visibility.Collapsed;
+
+ /// NW.js詳細状態テキスト
+ public virtual string NwjsDetailStatusText => string.Empty;
+
/// Unity IL2CPPか
public virtual bool IsIL2CPP => false;
diff --git a/Services/GameScannerService.cs b/Services/GameScannerService.cs
index 25bb71d..40368cb 100644
--- a/Services/GameScannerService.cs
+++ b/Services/GameScannerService.cs
@@ -692,6 +692,24 @@ namespace GameLauncher.Services
onGameUpdated(tg);
}
}
+ else if (tg.IsNwjs)
+ {
+ if (!File.Exists(tg.ExecutablePath) && !File.Exists(Path.Combine(tg.RootDirectory, "package.json")))
+ {
+ onGameRemoved(tg);
+ cacheNeedsSave = true;
+ continue;
+ }
+ }
+ else if (tg.IsEvbPacked || tg.IsStandaloneExePackage)
+ {
+ if (!File.Exists(tg.ExecutablePath))
+ {
+ onGameRemoved(tg);
+ cacheNeedsSave = true;
+ continue;
+ }
+ }
else
{
if (!File.Exists(tg.PluginsJsPath))
@@ -715,7 +733,7 @@ namespace GameLauncher.Services
}
// 改造状態の確認
- if (tg.IsWolf)
+ if (tg.IsWolf || tg.IsNwjs)
{
tg.IsModded = false;
}
@@ -1138,6 +1156,13 @@ namespace GameLauncher.Services
{
return rgssGame;
}
+
+ // 8. 汎用 NW.js ゲームの検出
+ var nwjsGame = Engines.Nwjs.NwjsDetector.DetectNwjsGame(dirPath, folderName, folderModified, (exe, dir) => LoadIcon(exe, dir));
+ if (nwjsGame != null)
+ {
+ return nwjsGame;
+ }
}
catch { }