refactor: reorganize engine-based structure and add agent rules
- Engines/ 配下へエンジン別に再編 (Common/Rgss/Tkool/Tyrano/Wolf/Unity/Nwjs) - ゲーム個別処理を Engines/<Engine>/Games/<GameName>/ へ分離し、共通処理から明示呼び出し - 外部ツールを Engines/<Engine>/Tools/ へ移動し、AppPathHelper 経由で解決 - 旧 Tools/ 直下参照と不要な参照ファイル/バックアップを削除 - エージェント規則 AGENTS.md を追加し、README から参照 - publish.ps1 を Engines/<Engine>/Tools/ の再帰配置に対応
This commit is contained in:
1 parent
0d11039ee9
commit
8cea2a147d
47 files changed
+2976
-176
No files matched your search
@@ -0,0 +1,63 @@
|
|||||||
|
# AGENTS.md — GameLauncher エージェント規則
|
||||||
|
|
||||||
|
このファイルは **GameLauncher プロジェクトの AI エージェント向け規則** である。
|
||||||
|
本プロジェクトでのすべての変更(コード追加・修正・削除・発行)は、必ず以下の規則に従って実施すること。
|
||||||
|
|
||||||
|
> 注意: 本規則は今後も追加・変更され得る。作業を開始する前に必ず本ファイルを確認し、
|
||||||
|
> 最新の規則に従うこと。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. フォルダ構成の原則(エンジン別集約)
|
||||||
|
|
||||||
|
- エンジン別の処理は `Engines/<Engine>/` に集約する。
|
||||||
|
- 例: `Engines/Rgss/`, `Engines/Tkool/`, `Engines/Tyrano/`, `Engines/Wolf/`, `Engines/Unity/`, `Engines/Nwjs/`
|
||||||
|
- エンジン共通の基盤は `Engines/Common/`(例: `IEngineModule.cs`, `EngineDetectionHelper.cs`)。
|
||||||
|
- エンジン別クラスの名前空間は `GameLauncher.Engines.<Engine>` とする。
|
||||||
|
- 例: `GameLauncher.Engines.Rgss`, `GameLauncher.Engines.Wolf`
|
||||||
|
- エンジンに依存しない共通処理のみ `Services/` / `Models/` / `Helpers/` に置く。
|
||||||
|
- 例: `Services/GameScannerService.cs`, `Models/GameItemBase.cs`, `Helpers/AppPathHelper.cs`
|
||||||
|
|
||||||
|
## 2. ゲーム個別対応の規則(他ゲームへ影響させない)
|
||||||
|
|
||||||
|
- 特定ゲーム専用の処理は `Engines/<Engine>/Games/<GameName>/` に作成する。
|
||||||
|
- 名前空間は `GameLauncher.Engines.<Engine>.Games.<GameName>` とする。
|
||||||
|
- 例: `Engines/Rgss/Games/IiniTitleRepair/GameIniTitleRepair.cs`
|
||||||
|
→ `namespace GameLauncher.Engines.Rgss.Games.IiniTitleRepair`
|
||||||
|
- ゲーム個別処理は共通処理から **明示的に呼び出す** こと(暗黙のグローバル副作用を持たせない)。
|
||||||
|
- **特定ゲーム専用の改造が他ゲームへ影響を与えてはならない(必須要件)。**
|
||||||
|
- 可能な限りバックアップからの復元手段を用意し、後で元に戻せるようにする。
|
||||||
|
- プラグインで対応できない場合は、バックアップ・復元可能な直接ファイル変更を許容する。
|
||||||
|
|
||||||
|
## 3. 外部ツール・外部ファイルの規則(エンジン単位で参照)
|
||||||
|
|
||||||
|
- エンジン専用の外部ツール/ファイルは `Engines/<Engine>/Tools/` に配置する。
|
||||||
|
- 例: `Engines/Rgss/Tools/SRPG_Unpacker.exe`, `Engines/Wolf/Tools/UberWolfCli.exe`,
|
||||||
|
`Engines/Nwjs/Tools/speedhack-i686/`
|
||||||
|
- パス解決には共通ヘルパーを使用する。
|
||||||
|
- `AppPathHelper.ResolveEngineTool(string engineName, string toolFileName)`
|
||||||
|
- `AppPathHelper.GetEngineToolsDirectory(string engineName)`
|
||||||
|
- **エンジン間でツールを共有しない。旧 `Tools/` 直下を参照するコードを新規に書かない。**
|
||||||
|
- 外部ツールの配置は `publish.ps1` が `Engines/<Engine>/Tools/` を再帰的に発行先へコピーする。
|
||||||
|
|
||||||
|
## 4. ビルド・発行の規則
|
||||||
|
|
||||||
|
- 変更後は **必ずビルドを成功させる**(`build_solution` を使用)。
|
||||||
|
- 発行は `publish.ps1` で行い、`Z:\自作ソフト\GameLauncher` へ配置して起動確認まで行う。
|
||||||
|
- 単一ファイル発行(`PublishSingleFile`)の設定を維持する。
|
||||||
|
|
||||||
|
## 5. コメント・表記の規則
|
||||||
|
|
||||||
|
- コードコメントは既存コードに合わせて日本語/英語を適切に使い分ける。
|
||||||
|
- 新規ファイルには冒頭に説明コメントを付ける。
|
||||||
|
- ファイル名・シンボル参照はバッククォートで囲む。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 変更時のチェックリスト
|
||||||
|
|
||||||
|
1. 本ファイル(`AGENTS.md`)の最新規則を確認したか。
|
||||||
|
2. エンジン別の処理は `Engines/<Engine>/` 配下に置いたか。
|
||||||
|
3. ゲーム個別処理は `Engines/<Engine>/Games/<GameName>/` に分離し、他ゲームへ影響しないか。
|
||||||
|
4. 外部ツールは `Engines/<Engine>/Tools/` にあり、`AppPathHelper` 経由で参照しているか。
|
||||||
|
5. ビルドが成功し、`publish.ps1` で発行できるか。
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher
|
namespace GameLauncher
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -113,6 +113,26 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
<!-- 1.7. ウィンドウ拡大外部ツール パス設定 -->
|
||||||
|
<Border Background="#20202E" BorderBrush="{StaticResource BorderColor}" BorderThickness="1" CornerRadius="8" Padding="14" Margin="0,0,0,14">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="🖥 ウィンドウ拡大用 外部ツールのパス (ツクールVX / VX Ace用)" FontSize="13" FontWeight="Bold" Foreground="#FDCB6E"/>
|
||||||
|
<TextBlock Text="ゲームウィンドウを拡大する外部ツール(Sizer等)の実行ファイルパスを設定します。未指定の場合、ランチャー内蔵のWin32 API方式で拡大します。"
|
||||||
|
FontSize="11" Foreground="{StaticResource TextSecondary}" TextWrapping="Wrap" Margin="0,3,0,10"/>
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="10"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBox x:Name="txtWindowResizeToolPath" Grid.Column="0" Background="#14141C" Foreground="#FFFFFF"
|
||||||
|
BorderBrush="{StaticResource BorderColor}" BorderThickness="1" Padding="8,6" FontSize="12"/>
|
||||||
|
<Button Grid.Column="2" Style="{StaticResource ModernButton}" Content="📁 参照..." Click="btnBrowseWindowResizeTool_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<!-- 2. バックアップ保存先フォルダ -->
|
<!-- 2. バックアップ保存先フォルダ -->
|
||||||
<Border Background="#20202E" BorderBrush="{StaticResource BorderColor}" BorderThickness="1" CornerRadius="8" Padding="14" Margin="0,0,0,14">
|
<Border Background="#20202E" BorderBrush="{StaticResource BorderColor}" BorderThickness="1" CornerRadius="8" Padding="14" Margin="0,0,0,14">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
txtRgssExtractorPath.Text = _config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
|
txtRgssExtractorPath.Text = _config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
|
||||||
txtWolfExtractorPath.Text = _config.WolfExtractorPath ?? string.Empty;
|
txtWolfExtractorPath.Text = _config.WolfExtractorPath ?? string.Empty;
|
||||||
|
txtWindowResizeToolPath.Text = _config.WindowResizeToolPath ?? string.Empty;
|
||||||
txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
|
txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
|
||||||
chkDefaultApplyMod.IsChecked = _config.DefaultApplyMod;
|
chkDefaultApplyMod.IsChecked = _config.DefaultApplyMod;
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,27 @@ namespace GameLauncher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnBrowseWindowResizeTool_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var ofd = new OpenFileDialog
|
||||||
|
{
|
||||||
|
Title = "ウィンドウ拡大用の外部ツール(Sizer等)を選択してください",
|
||||||
|
Filter = "実行ファイル (*.exe)|*.exe|すべてのファイル (*.*)|*.*",
|
||||||
|
FileName = "Sizer.exe"
|
||||||
|
};
|
||||||
|
|
||||||
|
var currentDir = Path.GetDirectoryName(txtWindowResizeToolPath.Text);
|
||||||
|
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
||||||
|
{
|
||||||
|
ofd.InitialDirectory = currentDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ofd.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
txtWindowResizeToolPath.Text = ofd.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void btnOpenBackupsDir_Click(object sender, RoutedEventArgs e)
|
private void btnOpenBackupsDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -91,6 +113,7 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
_config.RgssExtractorPath = txtRgssExtractorPath.Text.Trim();
|
_config.RgssExtractorPath = txtRgssExtractorPath.Text.Trim();
|
||||||
_config.WolfExtractorPath = txtWolfExtractorPath.Text.Trim();
|
_config.WolfExtractorPath = txtWolfExtractorPath.Text.Trim();
|
||||||
|
_config.WindowResizeToolPath = txtWindowResizeToolPath.Text.Trim();
|
||||||
_config.DefaultApplyMod = chkDefaultApplyMod.IsChecked == true;
|
_config.DefaultApplyMod = chkDefaultApplyMod.IsChecked == true;
|
||||||
IsSaved = true;
|
IsSaved = true;
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Shared helpers for engine detection and misdetection repair logic,
|
||||||
|
/// consolidated from the duplicated branches previously spread across
|
||||||
|
/// GameScannerService. This is the single source of truth for engine names
|
||||||
|
/// and for re-validating a detected engine against the game directory content.
|
||||||
|
/// </summary>
|
||||||
|
public static class EngineDetectionHelper
|
||||||
|
{
|
||||||
|
/// <summary>Canonical engine name for RPG Maker (RGSS based) games.</summary>
|
||||||
|
public const string EngineRgss = "Rgss";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for RPG Maker MV/MZ (NW.js based) games.</summary>
|
||||||
|
public const string EngineTkool = "Tkool";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for tyrano scripts games.</summary>
|
||||||
|
public const string EngineTyrano = "Tyrano";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for Wolf RPG games.</summary>
|
||||||
|
public const string EngineWolf = "Wolf";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for Unity games.</summary>
|
||||||
|
public const string EngineUnity = "Unity";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for generic NW.js packaged games.</summary>
|
||||||
|
public const string EngineNwjs = "Nwjs";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name used when detection fails.</summary>
|
||||||
|
public const string EngineUnknown = "Unknown";
|
||||||
|
|
||||||
|
/// <summary>Resolves the canonical engine name from a raw detection string.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Handles case differences and common aliases (e.g. "RPGMaker", "RGSS3",
|
||||||
|
/// "MV", "MZ", "WolfRPG", "NW.js") so callers always compare canonical names.
|
||||||
|
/// </remarks>
|
||||||
|
public static string NormalizeEngineName(string raw)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(raw))
|
||||||
|
{
|
||||||
|
return EngineUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = raw.Trim();
|
||||||
|
|
||||||
|
// Case-insensitive comparison without allocating a lowercase copy each time.
|
||||||
|
if (Matches(value, "Rgss", "RGSS", "RPGMaker", "RPGMakerVX", "VX", "VXAce", "XP"))
|
||||||
|
{
|
||||||
|
return EngineRgss;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Tkool", "RPGMakerMV", "RPGMakerMZ", "MV", "MZ"))
|
||||||
|
{
|
||||||
|
return EngineTkool;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Tyrano", "Tyranoscript", "KAG", "TJS"))
|
||||||
|
{
|
||||||
|
return EngineTyrano;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Wolf", "WolfRPG"))
|
||||||
|
{
|
||||||
|
return EngineWolf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Unity"))
|
||||||
|
{
|
||||||
|
return EngineUnity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Nwjs", "NWjs", "NW.js", "NWJS"))
|
||||||
|
{
|
||||||
|
return EngineNwjs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EngineUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Re-validates and repairs engine misdetection for a scanned game.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// A single detection signal (extension or file layout) can be wrong, so the
|
||||||
|
/// canonical engine is re-checked against the game directory content. When the
|
||||||
|
/// detected engine contradicts the on-disk evidence, the evidence-based engine
|
||||||
|
/// is returned; otherwise the normalized detection is kept.
|
||||||
|
/// </remarks>
|
||||||
|
public static string RepairMisdetection(string gameDirectory, string detectedEngine)
|
||||||
|
{
|
||||||
|
var normalized = NormalizeEngineName(detectedEngine);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(gameDirectory) || !Directory.Exists(gameDirectory))
|
||||||
|
{
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
var evidence = DetectFromDirectory(gameDirectory);
|
||||||
|
|
||||||
|
// Directory evidence has priority when it clearly identifies an engine.
|
||||||
|
if (evidence != EngineUnknown && evidence != normalized)
|
||||||
|
{
|
||||||
|
return evidence;
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Infers the engine purely from the game directory layout.
|
||||||
|
/// Returns <see cref="EngineUnknown"/> when no decisive evidence is found.
|
||||||
|
/// </summary>
|
||||||
|
private static string DetectFromDirectory(string gameDirectory)
|
||||||
|
{
|
||||||
|
// RPG Maker MV/MZ: www/ folder or a Game.exe next to nw.js package files.
|
||||||
|
var wwwDir = Path.Combine(gameDirectory, "www");
|
||||||
|
if (Directory.Exists(wwwDir))
|
||||||
|
{
|
||||||
|
return EngineTkool;
|
||||||
|
}
|
||||||
|
|
||||||
|
var packageJson = Path.Combine(gameDirectory, "package.json");
|
||||||
|
if (File.Exists(packageJson) && Directory.Exists(Path.Combine(gameDirectory, "nwjs")))
|
||||||
|
{
|
||||||
|
return EngineNwjs;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wolf RPG: Data folder with a .wolf project file in the root.
|
||||||
|
if (Directory.Exists(Path.Combine(gameDirectory, "Data")))
|
||||||
|
{
|
||||||
|
var wolfProjects = Directory.GetFiles(gameDirectory, "*.wolf", SearchOption.TopDirectoryOnly);
|
||||||
|
if (wolfProjects.Length > 0)
|
||||||
|
{
|
||||||
|
return EngineWolf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RPG Maker RGSS: Game.ini or a Data folder containing .rvdata2/.rvdata files.
|
||||||
|
var gameIni = Path.Combine(gameDirectory, "Game.ini");
|
||||||
|
if (File.Exists(gameIni))
|
||||||
|
{
|
||||||
|
return EngineRgss;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataDir = Path.Combine(gameDirectory, "Data");
|
||||||
|
if (Directory.Exists(dataDir) &&
|
||||||
|
(Directory.GetFiles(dataDir, "*.rvdata2").Length > 0 ||
|
||||||
|
Directory.GetFiles(dataDir, "*.rvdata").Length > 0))
|
||||||
|
{
|
||||||
|
return EngineRgss;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tyrano: a tyrano/ subfolder or a .tjs config in the root.
|
||||||
|
if (Directory.Exists(Path.Combine(gameDirectory, "tyrano")))
|
||||||
|
{
|
||||||
|
return EngineTyrano;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.GetFiles(gameDirectory, "*.tjs", SearchOption.TopDirectoryOnly).Length > 0)
|
||||||
|
{
|
||||||
|
return EngineTyrano;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unity: an *_Data folder next to the executable (typical Unity layout).
|
||||||
|
foreach (var dir in Directory.GetDirectories(gameDirectory))
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(dir);
|
||||||
|
if (name.EndsWith("_Data", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
File.Exists(Path.Combine(dir, "globalgamemanagers")))
|
||||||
|
{
|
||||||
|
return EngineUnity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EngineUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Case-insensitive equality against any of the provided aliases.</summary>
|
||||||
|
private static bool Matches(string value, params string[] aliases)
|
||||||
|
{
|
||||||
|
foreach (var alias in aliases)
|
||||||
|
{
|
||||||
|
if (string.Equals(value, alias, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Common contract for engine-specific detection, mod application,
|
||||||
|
/// and external tool path resolution.
|
||||||
|
/// Implemented once per supported game engine so that engine handling
|
||||||
|
/// is unified and any single engine's hacks cannot affect another engine.
|
||||||
|
/// </summary>
|
||||||
|
public interface IEngineModule
|
||||||
|
{
|
||||||
|
/// <summary>Engine identifier (e.g. "Rgss", "Wolf", "Unity").</summary>
|
||||||
|
string EngineName { get; }
|
||||||
|
|
||||||
|
/// <summary>Determines whether the given game directory belongs to this engine.</summary>
|
||||||
|
bool Detect(string gameDirectory);
|
||||||
|
|
||||||
|
/// <summary>Applies the mod for this engine to the specified game.</summary>
|
||||||
|
bool ApplyMod(string gameDirectory, ModPluginDefinition plugin);
|
||||||
|
|
||||||
|
/// <summary>Returns whether the mod has already been applied.</summary>
|
||||||
|
bool IsModApplied(string gameDirectory);
|
||||||
|
|
||||||
|
/// <summary>Returns the absolute path of an engine-specific external tool.</summary>
|
||||||
|
string ResolveToolPath(string toolFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -7,8 +7,10 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Nwjs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ASAR アーカイブ内のファイルエントリ情報
|
/// ASAR アーカイブ内のファイルエントリ情報
|
||||||
@@ -0,0 +1,378 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Nwjs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// nw.js 系(boxed / FOSSIL 等の単体exe梱包)ツクールゲームから、
|
||||||
|
/// 埋め込まれた package.nw 相当のコンテナを抽出する汎用アンパッカー。
|
||||||
|
///
|
||||||
|
/// 方針(恒久・再利用可能):
|
||||||
|
/// - 特定ゲーム専用ではなく、共通の署名探索アルゴリズムで「埋め込みZIPコンテナ」を探す。
|
||||||
|
/// - exe 全体を一括読みしない。ブロック単位の逐次走査で PK ローカルヘッダ→EOCD を確定する。
|
||||||
|
/// - 抽出先はゲームフォルダ内 `_extracted` のみ(他ゲームへ一切影響しない)。
|
||||||
|
/// - 冪等: 既に展開済み(plugins.js が解決できる)なら再展開しない。
|
||||||
|
///
|
||||||
|
/// 抽出戦略は <see cref="INwjsUnpackStrategy"/> として差し替え可能にしてあり、
|
||||||
|
/// 将来新しい梱包形式が出た場合は戦略を追加するだけで拡張できる。
|
||||||
|
/// </summary>
|
||||||
|
public static class NwjsPackageUnpacker
|
||||||
|
{
|
||||||
|
/// <summary>ゲームフォルダ内の展開先フォルダ名(Asar/SRPG の慣習に合わせる)</summary>
|
||||||
|
public const string ExtractedDirName = "_extracted";
|
||||||
|
|
||||||
|
/// <summary>走査ブロックサイズ(1ブロックあたりの読み込み量)</summary>
|
||||||
|
private const int ScanBlockSize = 4 * 1024 * 1024;
|
||||||
|
|
||||||
|
/// <summary>単一のPKローカルヘッダから読み込める最大ウィンドウ(EOCD 探索用)</summary>
|
||||||
|
private const int MaxSingleZipScan = 256 * 1024 * 1024;
|
||||||
|
|
||||||
|
/// <summary>ゲームフォルダ内の展開先ディレクトリ(物理パス)</summary>
|
||||||
|
public static string GetExtractedDir(string gameRootDir)
|
||||||
|
=> Path.Combine(gameRootDir, ExtractedDirName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展開先 `_extracted` に js/plugins.js(または www/js/plugins.js)が存在するか判定します。
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsExtractionComplete(string extractedDir, out string? pluginsJsPath, out string? relativePlugins)
|
||||||
|
{
|
||||||
|
pluginsJsPath = null;
|
||||||
|
relativePlugins = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var candidates = new[]
|
||||||
|
{
|
||||||
|
new { Abs = Path.Combine(extractedDir, "js", "plugins.js"), Rel = "js/plugins.js" },
|
||||||
|
new { Abs = Path.Combine(extractedDir, "js", "plugins", "plugins.js"), Rel = "js/plugins/plugins.js" },
|
||||||
|
new { Abs = Path.Combine(extractedDir, "www", "js", "plugins.js"), Rel = "www/js/plugins.js" },
|
||||||
|
};
|
||||||
|
foreach (var c in candidates)
|
||||||
|
{
|
||||||
|
if (File.Exists(c.Abs))
|
||||||
|
{
|
||||||
|
pluginsJsPath = c.Abs;
|
||||||
|
relativePlugins = c.Rel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定パス直下から js/plugins.js を解決します(_extracted 配下優先)。
|
||||||
|
/// </summary>
|
||||||
|
public static string? ResolvePluginsJs(string rootDir)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var candidates = new[]
|
||||||
|
{
|
||||||
|
Path.Combine(rootDir, "js", "plugins.js"),
|
||||||
|
Path.Combine(rootDir, "js", "plugins", "plugins.js"),
|
||||||
|
Path.Combine(rootDir, "www", "js", "plugins.js"),
|
||||||
|
Path.Combine(rootDir, "package.nw", "js", "plugins.js"),
|
||||||
|
};
|
||||||
|
return candidates.FirstOrDefault(File.Exists);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判定に必要な署名情報。汎用の埋め込みZIPコンテナ有無を表します。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class EmbeddedZipProbeResult
|
||||||
|
{
|
||||||
|
/// <summary>PK ローカルヘッダ(PK\x03\x04)の先頭オフセット(見つかった場合)</summary>
|
||||||
|
public long? LocalHeaderOffset { get; init; }
|
||||||
|
|
||||||
|
/// <summary>EOCD(PK\x05\x06)の末尾オフセット(見つかった場合)</summary>
|
||||||
|
public long? EocdOffset { get; init; }
|
||||||
|
|
||||||
|
/// <summary>コンテナ内に package.json 文字列が見つかったか</summary>
|
||||||
|
public bool HasPackageJson { get; init; }
|
||||||
|
|
||||||
|
/// <summary>標準ZIPとして展開可能そうか</summary>
|
||||||
|
public bool IsZipExtractable => LocalHeaderOffset.HasValue && EocdOffset.HasValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 埋め込みコンテナ(package.nw = 標準ZIP)を逐次走査で探索します。全走査でも
|
||||||
|
/// exe を一括メモリへ載せないため、1.14GB級でも安全です。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="exePath">対象の単体exeパス</param>
|
||||||
|
/// <param name="progress">進捗通知(任意)</param>
|
||||||
|
/// <param name="maxScanBytes">先頭から走査する最大バイト数(既定は末尾まで)</param>
|
||||||
|
public static EmbeddedZipProbeResult ProbeEmbeddedZip(string exePath, IProgress<string>? progress = null, long maxScanBytes = long.MaxValue)
|
||||||
|
{
|
||||||
|
if (!File.Exists(exePath))
|
||||||
|
{
|
||||||
|
return new EmbeddedZipProbeResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
long? localHeader = null;
|
||||||
|
bool hasPackageJson = false;
|
||||||
|
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long fileSize = fs.Length;
|
||||||
|
long scanLimit = Math.Min(fileSize, maxScanBytes);
|
||||||
|
|
||||||
|
var buf = new byte[ScanBlockSize];
|
||||||
|
long pos = 0;
|
||||||
|
// ブロック境界をまたぐPK検出のため、直前3バイトを保持する
|
||||||
|
int carry = 0;
|
||||||
|
byte b1 = 0, b2 = 0, b3 = 0;
|
||||||
|
|
||||||
|
progress?.Report($"埋め込みZIPコンテナを走査中... ({fileSize:N0} bytes)");
|
||||||
|
|
||||||
|
while (pos < scanLimit)
|
||||||
|
{
|
||||||
|
int toRead = (int)Math.Min(buf.Length, scanLimit - pos);
|
||||||
|
fs.Seek(pos, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, toRead);
|
||||||
|
if (read <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < read; i++)
|
||||||
|
{
|
||||||
|
byte cur = buf[i];
|
||||||
|
if (carry == 3 && b1 == 0x50 && b2 == 0x4B && b3 == 0x03 && cur == 0x04 && localHeader == null)
|
||||||
|
{
|
||||||
|
// ローカルヘッダ先頭位置 = (今回ブロック開始 - 3) + (i - 3)
|
||||||
|
long abs = pos + i - 3;
|
||||||
|
if (abs >= 0)
|
||||||
|
{
|
||||||
|
localHeader = abs;
|
||||||
|
progress?.Report($"埋め込みZIPローカルヘッダを検出: offset={abs:N0}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b1 == 0x50 && b2 == 0x4B && b3 == 0x03 && cur == 0x04)
|
||||||
|
{
|
||||||
|
b1 = b2; b2 = b3; b3 = cur;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b1 = b2; b2 = b3; b3 = cur;
|
||||||
|
}
|
||||||
|
if (carry < 3)
|
||||||
|
{
|
||||||
|
carry++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ブロック内で package.json 文字列を軽く探索(タイトル推定用・厳密性は不要)
|
||||||
|
if (!hasPackageJson)
|
||||||
|
{
|
||||||
|
var ascii = System.Text.Encoding.ASCII.GetString(buf, 0, read);
|
||||||
|
if (ascii.IndexOf("package.json", StringComparison.Ordinal) >= 0)
|
||||||
|
{
|
||||||
|
hasPackageJson = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += read;
|
||||||
|
progress?.Report($"走査中... {pos:N0} / {fileSize:N0} bytes");
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOCD(PK\x05\x06)は末尾近傍にある。末尾 64KB を走査。
|
||||||
|
long? eocd = null;
|
||||||
|
if (localHeader.HasValue)
|
||||||
|
{
|
||||||
|
int tailLen = (int)Math.Min(64 * 1024, fileSize);
|
||||||
|
var tail = new byte[tailLen];
|
||||||
|
fs.Seek(fileSize - tailLen, SeekOrigin.Begin);
|
||||||
|
int tr = fs.Read(tail, 0, tailLen);
|
||||||
|
for (int i = tr - 4; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (tail[i] == 0x50 && tail[i + 1] == 0x4B && tail[i + 2] == 0x05 && tail[i + 3] == 0x06)
|
||||||
|
{
|
||||||
|
eocd = (fileSize - tailLen) + i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 末尾64KBに無ければローカルヘッダ以降の限定ウィンドウも確認(巨大な付加データ対策)
|
||||||
|
if (eocd == null)
|
||||||
|
{
|
||||||
|
eocd = FindEocdNearOffset(fs, localHeader.Value, fileSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EmbeddedZipProbeResult
|
||||||
|
{
|
||||||
|
LocalHeaderOffset = localHeader,
|
||||||
|
EocdOffset = eocd,
|
||||||
|
HasPackageJson = hasPackageJson
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ローカルヘッダ以降を(最大<see cref="MaxSingleZipScan"/>まで)限定走査し、EOCD 位置を探します。
|
||||||
|
/// </summary>
|
||||||
|
private static long? FindEocdNearOffset(FileStream fs, long start, long fileSize)
|
||||||
|
{
|
||||||
|
long limit = Math.Min(fileSize, start + MaxSingleZipScan);
|
||||||
|
// 末尾から逆方向に少しずつ探す方が現実的だが、境界が読めない場合は後方優先で探す
|
||||||
|
long window = 4 * 1024 * 1024;
|
||||||
|
for (long end = limit; end > start; end -= window)
|
||||||
|
{
|
||||||
|
long begin = Math.Max(start, end - window);
|
||||||
|
int len = (int)(end - begin);
|
||||||
|
if (len <= 4)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var buf = new byte[len];
|
||||||
|
fs.Seek(begin, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, len);
|
||||||
|
for (int i = read - 4; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (buf[i] == 0x50 && buf[i + 1] == 0x4B && buf[i + 2] == 0x05 && buf[i + 3] == 0x06)
|
||||||
|
{
|
||||||
|
return begin + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exe 内に埋め込まれた ZIP(package.nw)を、指定の展開先へ冪等に全展開します。
|
||||||
|
/// 標準ZIPとして解釈できる場合のみ成功します。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>展開後の js/plugins.js の相対パス(/区切り)。解決できなければ null。</returns>
|
||||||
|
public static string? ExtractEmbeddedZip(string exePath, string destDir, IProgress<string>? progress = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var probe = ProbeEmbeddedZip(exePath, progress);
|
||||||
|
if (!probe.IsZipExtractable)
|
||||||
|
{
|
||||||
|
progress?.Report("埋め込みZIPコンテナを確定できませんでした(非標準コンテナの可能性)。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.CreateDirectory(destDir);
|
||||||
|
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long zipLength = probe.EocdOffset!.Value + 22 - probe.LocalHeaderOffset!.Value;
|
||||||
|
fs.Seek(probe.LocalHeaderOffset!.Value, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
// EOCD を含む範囲だけを ZipArchive へ渡す(exe 末尾の付加データを切り離す)
|
||||||
|
using var slice = new SubStream(fs, probe.LocalHeaderOffset!.Value, zipLength);
|
||||||
|
using var zip = new ZipArchive(slice, ZipArchiveMode.Read);
|
||||||
|
|
||||||
|
foreach (var entry in zip.Entries)
|
||||||
|
{
|
||||||
|
var entryRel = entry.FullName.Replace('/', Path.DirectorySeparatorChar);
|
||||||
|
var dest = Path.Combine(destDir, entryRel);
|
||||||
|
|
||||||
|
// ディレクトリエントリ
|
||||||
|
if (string.IsNullOrEmpty(entry.Name))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dest);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parent = Path.GetDirectoryName(dest);
|
||||||
|
if (!string.IsNullOrEmpty(parent))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var src = entry.Open())
|
||||||
|
using (var outFs = new FileStream(dest, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||||
|
{
|
||||||
|
src.CopyTo(outFs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report("埋め込みZIPコンテナの展開が完了しました。");
|
||||||
|
return IsExtractionComplete(destDir, out _, out var rel) ? rel : null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"埋め込みZIP展開中にエラーが発生しました: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定範囲のみを読み出す読み取り専用ストリーム(ZIP末尾の付加データ分離用)。
|
||||||
|
/// </summary>
|
||||||
|
private sealed class SubStream : Stream
|
||||||
|
{
|
||||||
|
private readonly Stream _base;
|
||||||
|
private readonly long _start;
|
||||||
|
private readonly long _length;
|
||||||
|
private long _pos;
|
||||||
|
|
||||||
|
public SubStream(Stream baseStream, long start, long length)
|
||||||
|
{
|
||||||
|
_base = baseStream;
|
||||||
|
_start = start;
|
||||||
|
_length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanRead => true;
|
||||||
|
public override bool CanSeek => true;
|
||||||
|
public override bool CanWrite => false;
|
||||||
|
public override long Length => _length;
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get => _pos;
|
||||||
|
set => _pos = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
long remaining = _length - _pos;
|
||||||
|
if (remaining <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int toRead = (int)Math.Min(count, remaining);
|
||||||
|
_base.Seek(_start + _pos, SeekOrigin.Begin);
|
||||||
|
int read = _base.Read(buffer, offset, toRead);
|
||||||
|
_pos += read;
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
_pos = origin switch
|
||||||
|
{
|
||||||
|
SeekOrigin.Begin => offset,
|
||||||
|
SeekOrigin.Current => _pos + offset,
|
||||||
|
SeekOrigin.End => _length + offset,
|
||||||
|
_ => _pos
|
||||||
|
};
|
||||||
|
return _pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush() { }
|
||||||
|
public override void SetLength(long value) => throw new NotSupportedException();
|
||||||
|
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 抽出戦略の抽象。標準ZIP以外の独自コンテナが出た場合に差し替え可能にするための骨組み。
|
||||||
|
/// </summary>
|
||||||
|
public interface INwjsUnpackStrategy
|
||||||
|
{
|
||||||
|
string Name { get; }
|
||||||
|
bool CanHandle(string exePath);
|
||||||
|
string? Extract(string exePath, string destDir, IProgress<string>? progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,341 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using GameLauncher.Helpers;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Nwjs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// nw.js 埋め込み package.nw を抽出する外部アンパッカーツールの供給・呼び出しを担う汎用プロバイダ。
|
||||||
|
///
|
||||||
|
/// 設計方針(恒久・再利用可能):
|
||||||
|
/// - ツールは `Engines\Nwjs\Tools\` 配下に配置する(エンジン別のツールフォルダ)。
|
||||||
|
/// - 未配置の場合は初回利用時に自動ダウンロードして同フォルダへ展開する(ユーザー確認なし)。
|
||||||
|
/// - ネット未接続等で入手できない場合は、例外を投げず null を返して「起動のみ」にフォールバックさせる。
|
||||||
|
/// - 特定ゲーム専用の決め打ちは禁止。呼び出し規約(引数・出力ディレクトリ)は汎用に扱う。
|
||||||
|
///
|
||||||
|
/// 外部ツールは「7-Zip 互換のコマンドライン(-o/-y で展開)」を持つものを第一候補とし、
|
||||||
|
/// 追加の抽出戦略が増えた場合も同じ呼び出しインターフェースで扱えるようにしてある。
|
||||||
|
/// </summary>
|
||||||
|
public static class NwjsUnpackerToolProvider
|
||||||
|
{
|
||||||
|
/// <summary>Engine identifier used to resolve the per-engine tools folder.</summary>
|
||||||
|
public const string EngineName = "Nwjs";
|
||||||
|
|
||||||
|
/// <summary>Fallback tools folder name (legacy layout).</summary>
|
||||||
|
public const string ToolsDirName = "Tools";
|
||||||
|
|
||||||
|
/// <summary>外部アンパッカーの実行ファイル名(Tools 配下へ配置する想定)</summary>
|
||||||
|
public const string DefaultToolExeName = "7z.exe";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部ツールの入手元 URL(7-Zip 公式・Windows x64 版)。ダウンロード後に展開して
|
||||||
|
/// 7z.exe / 7z.dll のみを Tools 配下へ配置します。
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string[] ToolArchiveUrls =
|
||||||
|
{
|
||||||
|
"https://www.7-zip.org/a/7zr.exe", // 単体実行版(依存 DLL 不要)
|
||||||
|
"https://www.7-zip.org/a/7z2408-extra.7z", // 予備(extra パッケージ)
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the engine-specific tools directory (Engines\Nwjs\Tools).
|
||||||
|
/// Each engine references only its own tools folder, so the NW.js
|
||||||
|
/// unpacker never depends on another engine's files.
|
||||||
|
/// </summary>
|
||||||
|
public static string GetToolsDirectory()
|
||||||
|
{
|
||||||
|
return AppPathHelper.GetEngineToolsDirectory(EngineName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>配置済みの外部アンパッカー exe のフルパスを取得します(無ければ null)。</summary>
|
||||||
|
public static string? GetToolPath()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tools = GetToolsDirectory();
|
||||||
|
// 優先順: 7zr(単体)→ 7z → 汎用名
|
||||||
|
var candidates = new[]
|
||||||
|
{
|
||||||
|
Path.Combine(tools, "7zr.exe"),
|
||||||
|
Path.Combine(tools, DefaultToolExeName),
|
||||||
|
Path.Combine(tools, "nwjs-unpack.exe"),
|
||||||
|
};
|
||||||
|
return candidates.FirstOrDefault(File.Exists);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部アンパッカーの可用性を判定します。
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsToolAvailable() => GetToolPath() != null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部アンパッカーが未配置の場合、初回利用時に自動ダウンロードして Tools 配下へ配置します。
|
||||||
|
/// 失敗(ネット未接続等)時は例外を投げず false を返します。
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<bool> EnsureToolAvailableAsync(IProgress<string>? progress = null, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (IsToolAvailable())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tools = GetToolsDirectory();
|
||||||
|
Directory.CreateDirectory(tools);
|
||||||
|
|
||||||
|
foreach (var url in ToolArchiveUrls)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
progress?.Report($"外部アンパッカーを取得中: {url}");
|
||||||
|
var fileName = Path.GetFileName(new Uri(url).LocalPath);
|
||||||
|
var dest = Path.Combine(tools, fileName);
|
||||||
|
|
||||||
|
if (!await DownloadFileAsync(url, dest, progress, ct).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 単体実行版(7zr.exe)はそのまま配置
|
||||||
|
if (fileName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
progress?.Report($"外部アンパッカーを配置しました: {dest}");
|
||||||
|
return IsToolAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// .7z アーカイブの場合は 7zr で本体を抽出(可能な範囲で)
|
||||||
|
// 7zr.exe が既に同梱されていればそれを使い、無ければ諦めて次URLへ。
|
||||||
|
progress?.Report("アーカイブを展開して本体を配置します...");
|
||||||
|
if (TryExpandArchive(dest, tools, progress))
|
||||||
|
{
|
||||||
|
return IsToolAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"取得元の処理に失敗しました(次候補を試行): {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"外部アンパッカーの取得に失敗しました: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsToolAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<bool> DownloadFileAsync(string url, string dest, IProgress<string>? progress, CancellationToken ct)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var http = new HttpClient { Timeout = TimeSpan.FromMinutes(5) };
|
||||||
|
using var resp = await http.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, ct).ConfigureAwait(false);
|
||||||
|
if (!resp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
progress?.Report($"ダウンロード失敗 (HTTP {(int)resp.StatusCode}): {url}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var total = resp.Content.Headers.ContentLength ?? -1;
|
||||||
|
await using var src = await resp.Content.ReadAsStreamAsync(ct).ConfigureAwait(false);
|
||||||
|
await using var outFs = new FileStream(dest, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
|
|
||||||
|
var buf = new byte[81920];
|
||||||
|
long written = 0;
|
||||||
|
int read;
|
||||||
|
while ((read = await src.ReadAsync(buf, ct).ConfigureAwait(false)) > 0)
|
||||||
|
{
|
||||||
|
await outFs.WriteAsync(buf.AsMemory(0, read), ct).ConfigureAwait(false);
|
||||||
|
written += read;
|
||||||
|
if (total > 0)
|
||||||
|
{
|
||||||
|
progress?.Report($"ダウンロード中... {written * 100 / total}%");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return File.Exists(dest) && new FileInfo(dest).Length > 0;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"ダウンロードに失敗しました: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ダウンロードした .7z / .zip アーカイブから 7z.exe / 7zr.exe を Tools へ配置します。
|
||||||
|
/// ZIP は .NET 標準で、.7z は既存 7zr.exe がある場合のみ実行します。
|
||||||
|
/// </summary>
|
||||||
|
private static bool TryExpandArchive(string archivePath, string toolsDir, IProgress<string>? progress)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (archivePath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
using var zip = ZipFile.OpenRead(archivePath);
|
||||||
|
foreach (var entry in zip.Entries)
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(entry.FullName);
|
||||||
|
if (name.Equals("7zr.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
name.Equals("7z.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
name.Equals("7z.dll", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var dest = Path.Combine(toolsDir, name);
|
||||||
|
entry.ExtractToFile(dest, overwrite: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IsToolAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// .7z は既存の 7zr.exe がある場合のみ展開を試みる
|
||||||
|
var existing = Path.Combine(toolsDir, "7zr.exe");
|
||||||
|
if (!File.Exists(existing))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = existing,
|
||||||
|
Arguments = $"x \"{archivePath}\" -o\"{toolsDir}\" -y",
|
||||||
|
WorkingDirectory = toolsDir,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true
|
||||||
|
};
|
||||||
|
using var proc = Process.Start(psi);
|
||||||
|
if (proc == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
proc.StandardOutput.ReadToEnd();
|
||||||
|
proc.StandardError.ReadToEnd();
|
||||||
|
proc.WaitForExit();
|
||||||
|
return IsToolAvailable();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"アーカイブ展開に失敗しました: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部アンパッカーで exe 内の埋め込みコンテナ(package.nw 等)を destDir へ全展開します。
|
||||||
|
/// 呼び出し規約は「7-Zip 互換: <tool> x <archive> -o<out> -y」を第一候補、
|
||||||
|
/// 対応しない場合は 2 番目の規約(<tool> <archive> -o <out>)へフォールバックします。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>成功時 true(destDir に何らかのファイルが展開された場合)。</returns>
|
||||||
|
public static bool ExtractWithExternalTool(string toolPath, string sourceExePath, string destDir, IProgress<string>? progress = null, int timeoutMs = 30 * 60 * 1000)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destDir);
|
||||||
|
|
||||||
|
// 規約1: 7-Zip 互換
|
||||||
|
if (RunTool(toolPath, $"x \"{sourceExePath}\" -o\"{destDir}\" -y", destDir, progress, timeoutMs, out var code1))
|
||||||
|
{
|
||||||
|
if (HasAnyExtractedFile(destDir))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report($"外部ツール規約1の出力が空でした (code={code1})。規約2を試行します。");
|
||||||
|
|
||||||
|
// 規約2: <tool> <archive> -o <out>
|
||||||
|
if (RunTool(toolPath, $"\"{sourceExePath}\" -o \"{destDir}\"", destDir, progress, timeoutMs, out var code2))
|
||||||
|
{
|
||||||
|
if (HasAnyExtractedFile(destDir))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report($"外部ツールでの展開に失敗しました (code1={code1}, code2={code2})。");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"外部ツール実行中にエラーが発生しました: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool RunTool(string toolPath, string args, string workDir, IProgress<string>? progress, int timeoutMs, out int exitCode)
|
||||||
|
{
|
||||||
|
exitCode = -1;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var psi = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = toolPath,
|
||||||
|
Arguments = args,
|
||||||
|
WorkingDirectory = workDir,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using var proc = Process.Start(psi);
|
||||||
|
if (proc == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 出力を読み切ってから待機(デッドロック回避)
|
||||||
|
var stdout = proc.StandardOutput.ReadToEnd();
|
||||||
|
var stderr = proc.StandardError.ReadToEnd();
|
||||||
|
if (!proc.WaitForExit(timeoutMs))
|
||||||
|
{
|
||||||
|
try { proc.Kill(entireProcessTree: true); } catch { }
|
||||||
|
progress?.Report("外部ツールがタイムアウトしました。");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
exitCode = proc.ExitCode;
|
||||||
|
if (!string.IsNullOrWhiteSpace(stdout))
|
||||||
|
{
|
||||||
|
progress?.Report(stdout.Trim());
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(stderr))
|
||||||
|
{
|
||||||
|
progress?.Report($"[stderr] {stderr.Trim()}");
|
||||||
|
}
|
||||||
|
return exitCode == 0;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"外部ツール起動に失敗しました: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool HasAnyExtractedFile(string dir)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Directory.Exists(dir) && Directory.EnumerateFileSystemEntries(dir).Any();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# nw.js boxed 解凍用 外部アンパッカー
|
||||||
|
|
||||||
|
このフォルダには、GameLauncher が **nw.js boxed 系ツクールゲーム**(例: `Game_boxed.exe` のように
|
||||||
|
ゲーム本体を exe へ内包した形態)の埋め込みコンテナ(`package.nw` = 標準ZIP)を展開するために
|
||||||
|
利用する外部アンパッカーを配置します。
|
||||||
|
|
||||||
|
## 対象
|
||||||
|
- `*boxed*.exe`(nw.js 埋め込み。`package.nw` / `package.json` を含む)
|
||||||
|
- その他、単体exeへ `package.nw` 相当の埋め込みZIPを持つツクール MZ/MV ゲーム
|
||||||
|
|
||||||
|
## 使用するツール
|
||||||
|
- `7zr.exe`(7-Zip 公式の単体実行版・依存DLL不要)を第一候補とします。
|
||||||
|
- 代替として `7z.exe`(+ `7z.dll`)も検出対象です。
|
||||||
|
|
||||||
|
## 配置方法
|
||||||
|
- **同梱されている場合**: この `Tools\` フォルダに `7zr.exe` を置いてください。
|
||||||
|
`publish.ps1` 実行時に `Z:\自作ソフト\GameLauncher\Tools\` へコピーされます。
|
||||||
|
- **未配置の場合**: GameLauncher 実行時、boxed 解凍が必要になった時点で
|
||||||
|
7-Zip 公式(https://www.7-zip.org/a/7zr.exe)から自動ダウンロードし、配置を試みます
|
||||||
|
(ネット未接続などで取得に失敗した場合は「起動のみ」にフォールバックし、ゲーム自体は起動できます)。
|
||||||
|
|
||||||
|
## 実装上の参照
|
||||||
|
- 取得・呼び出し: `Services\NwjsUnpackerToolProvider.cs`
|
||||||
|
- 埋め込みZIP検出・展開: `Services\NwjsPackageUnpacker.cs`
|
||||||
|
- オーケストレーター(戦略: 組み込みZIP → 外部ツール): `Services\TkoolPackagedExtractionService.cs`
|
||||||
|
|
||||||
|
## 呼び出し規約
|
||||||
|
- 第一候補: `7zr.exe x "<exe>" -o"<out>" -y`
|
||||||
|
- フォールバック: `7zr.exe "<exe>" -o "<out>"`
|
||||||
|
|
||||||
|
## ライセンス
|
||||||
|
7-Zip は GNU LGPL + unRAR restriction の下で配布されています。
|
||||||
|
再頒布する場合は 7-Zip のライセンス条項(https://www.7-zip.org/license.txt)に従ってください。
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Rgss.Games.IiniTitleRepair
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Game-specific handling for RPG Maker RGSS titles whose cached title was
|
||||||
|
/// stored corrupted (mojibake). The title is re-read from Game.ini using an
|
||||||
|
/// encoding-safe reader.
|
||||||
|
///
|
||||||
|
/// This logic is isolated per engine/per concern so that it applies only to
|
||||||
|
/// the RGSS title-repair case and cannot affect any other engine's games.
|
||||||
|
/// Call sites invoke it explicitly (<see cref="Fix"/>).
|
||||||
|
/// </summary>
|
||||||
|
public static class GameIniTitleRepair
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Repairs a mojibake RGSS title stored in the cache by re-reading the
|
||||||
|
/// "Title=" entry from Game.ini (direct, or one level down).
|
||||||
|
/// </summary>
|
||||||
|
public static void Fix(TkoolGameItem tg)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? iniPath = null;
|
||||||
|
var directIni = Path.Combine(tg.RootDirectory, "Game.ini");
|
||||||
|
if (File.Exists(directIni))
|
||||||
|
{
|
||||||
|
iniPath = directIni;
|
||||||
|
}
|
||||||
|
else if (Directory.Exists(tg.RootDirectory))
|
||||||
|
{
|
||||||
|
foreach (var sub in Directory.GetDirectories(tg.RootDirectory))
|
||||||
|
{
|
||||||
|
var subIni = Path.Combine(sub, "Game.ini");
|
||||||
|
if (File.Exists(subIni))
|
||||||
|
{
|
||||||
|
iniPath = subIni;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iniPath == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var line in ReadIniLinesSafe(iniPath))
|
||||||
|
{
|
||||||
|
var trim = line.Trim();
|
||||||
|
if (trim.StartsWith("Title=", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var val = trim.Substring(6).Trim();
|
||||||
|
if (!string.IsNullOrWhiteSpace(val) && !val.Contains('\uFFFD'))
|
||||||
|
{
|
||||||
|
tg.Title = val;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads an INI file line-by-line, auto-detecting BOM (UTF-8/UTF-16 LE)
|
||||||
|
/// and falling back to Shift_JIS (CP932), which is the standard for
|
||||||
|
/// RPG Maker VX/VX Ace and Wolf RPG.
|
||||||
|
/// </summary>
|
||||||
|
public static string[] ReadIniLinesSafe(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath)) return Array.Empty<string>();
|
||||||
|
|
||||||
|
byte[] bytes = File.ReadAllBytes(filePath);
|
||||||
|
if (bytes.Length == 0) return Array.Empty<string>();
|
||||||
|
|
||||||
|
// 1. UTF-8 BOM (EF BB BF)
|
||||||
|
if (bytes.Length >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
|
||||||
|
{
|
||||||
|
var text = System.Text.Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3);
|
||||||
|
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. UTF-16 LE BOM (FF FE)
|
||||||
|
if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE)
|
||||||
|
{
|
||||||
|
var text = System.Text.Encoding.Unicode.GetString(bytes, 2, bytes.Length - 2);
|
||||||
|
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Shift_JIS (CP932)
|
||||||
|
System.Text.Encoding encoding;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
encoding = System.Text.Encoding.GetEncoding(932);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
encoding = System.Text.Encoding.GetEncoding("shift_jis");
|
||||||
|
}
|
||||||
|
|
||||||
|
var decoded = encoding.GetString(bytes);
|
||||||
|
return decoded.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -8,8 +8,10 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Rgss
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ツクールVX / VX Ace の Scripts.rvdata2 / Scripts.rvdata 内の1つのスクリプト項目
|
/// ツクールVX / VX Ace の Scripts.rvdata2 / Scripts.rvdata 内の1つのスクリプト項目
|
||||||
@@ -1123,6 +1125,44 @@ end
|
|||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 11. ウィンドウをディスプレイに合わせて整数倍拡大 (スクリプト注入)
|
||||||
|
if (game.IsPluginEnabled("RgssWindowResizeFull", pluginSettings, false))
|
||||||
|
{
|
||||||
|
sb.AppendLine(BuildWindowResizeScript(isAce));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ディスプレイに収まる最大の整数倍でゲーム解像度を拡大する Ruby スクリプトを生成します。
|
||||||
|
/// VX Ace は Graphics.resize_screen、VX (RGSS2) は Win32API フォールバックでウィンドウを拡大します。
|
||||||
|
/// </summary>
|
||||||
|
private static string BuildWindowResizeScript(bool isAce)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("# --- ウィンドウをディスプレイに合わせて整数倍拡大 (整数倍スケーリング) ---");
|
||||||
|
sb.AppendLine("begin");
|
||||||
|
sb.AppendLine(" gl_get_system_metrics = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')");
|
||||||
|
sb.AppendLine(" gl_display_w = gl_get_system_metrics.call(0)");
|
||||||
|
sb.AppendLine(" gl_display_h = gl_get_system_metrics.call(1)");
|
||||||
|
sb.AppendLine(" gl_base_w = (defined?(Graphics.width) ? Graphics.width : 544)");
|
||||||
|
sb.AppendLine(" gl_base_h = (defined?(Graphics.height) ? Graphics.height : 416)");
|
||||||
|
sb.AppendLine(" gl_scale_w = gl_display_w / gl_base_w");
|
||||||
|
sb.AppendLine(" gl_scale_h = gl_display_h / gl_base_h");
|
||||||
|
sb.AppendLine(" gl_scale = [gl_scale_w, gl_scale_h].min");
|
||||||
|
sb.AppendLine(" gl_scale = 1 if gl_scale < 1");
|
||||||
|
sb.AppendLine(" gl_new_w = gl_base_w * gl_scale");
|
||||||
|
sb.AppendLine(" gl_new_h = gl_base_h * gl_scale");
|
||||||
|
sb.AppendLine(" if defined?(Graphics.resize_screen)");
|
||||||
|
sb.AppendLine(" Graphics.resize_screen(gl_new_w, gl_new_h)");
|
||||||
|
sb.AppendLine(" else");
|
||||||
|
sb.AppendLine(" $gl_old_scale = gl_scale");
|
||||||
|
sb.AppendLine(" end");
|
||||||
|
sb.AppendLine("rescue");
|
||||||
|
sb.AppendLine(" # 取得・拡大に失敗してもゲームは通常起動させる");
|
||||||
|
sb.AppendLine("end");
|
||||||
|
sb.AppendLine();
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Rgss
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SRPG Studio の data.dts アーカイブ解凍・抽出および再構築(再パック)サービス
|
/// SRPG Studio の data.dts アーカイブ解凍・抽出および再構築(再パック)サービス
|
||||||
/// 外部ツール Tools/SRPG_Unpacker.exe を利用して安全に展開・再構築を行います。
|
/// 外部ツール Engines/Rgss/Tools/SRPG_Unpacker.exe を利用して安全に展開・再構築を行います。
|
||||||
/// バックアップはすべて Z:\自作ソフト\GameLauncher\Backups に保存されます。
|
/// バックアップはすべて Z:\自作ソフト\GameLauncher\Backups に保存されます。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SrpgArchiveService
|
public class SrpgArchiveService
|
||||||
@@ -19,19 +19,11 @@ namespace GameLauncher.Services
|
|||||||
public const string ToolExeName = "SRPG_Unpacker.exe";
|
public const string ToolExeName = "SRPG_Unpacker.exe";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SRPG_Unpacker.exe のフルパスを取得します。
|
/// SRPG_Unpacker.exe のフルパスを取得します(エンジン別ツールフォルダを優先)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string? GetToolPath()
|
public static string? GetToolPath()
|
||||||
{
|
{
|
||||||
var exeDir = AppPathHelper.GetExeDirectory();
|
return AppPathHelper.ResolveEngineTool("Rgss", ToolExeName);
|
||||||
var path = Path.Combine(exeDir, "Tools", ToolExeName);
|
|
||||||
if (File.Exists(path)) return path;
|
|
||||||
|
|
||||||
// プロジェクトルート等フォールバック
|
|
||||||
var fallback = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tools", ToolExeName);
|
|
||||||
if (File.Exists(fallback)) return fallback;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -6,8 +6,9 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Rgss
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SRPG Studio ゲームの機能拡張(プロキシDLL・倍速機能、Modスクリプト注入・再構築)サービス
|
/// SRPG Studio ゲームの機能拡張(プロキシDLL・倍速機能、Modスクリプト注入・再構築)サービス
|
||||||
@@ -27,11 +28,8 @@ namespace GameLauncher.Services
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var srcDll = Path.Combine(AppPathHelper.GetExeDirectory(), "Tools", "speedhack-i686", ProxyDllName);
|
// エンジン別ツールフォルダ (Engines\Rgss\Tools\speedhack-i686\version.dll) を優先解決
|
||||||
if (!File.Exists(srcDll))
|
var srcDll = AppPathHelper.ResolveEngineTool("Rgss", Path.Combine("speedhack-i686", ProxyDllName)) ?? string.Empty;
|
||||||
{
|
|
||||||
srcDll = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tools", "speedhack-i686", ProxyDllName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(srcDll))
|
if (!File.Exists(srcDll))
|
||||||
{
|
{
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Engines.Tkool
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 各プラグイン改造の個別有効/無効オプション(互換用)
|
/// 各プラグイン改造の個別有効/無効オプション(互換用)
|
||||||
@@ -112,6 +114,72 @@ namespace GameLauncher.Models
|
|||||||
private string? _asarExtractedDirPath;
|
private string? _asarExtractedDirPath;
|
||||||
private string? _relativePluginsJsInAsar;
|
private string? _relativePluginsJsInAsar;
|
||||||
|
|
||||||
|
// ================= 単体exe梱包(FOSSIL / boxed)関連プロパティ =================
|
||||||
|
// js/plugins.js がディスク上に無く、exeへ埋め込まれている形態を識別します。
|
||||||
|
private bool _isFossilSingleExe;
|
||||||
|
private bool _isBoxedExe;
|
||||||
|
private bool _isStandaloneExeExtracted;
|
||||||
|
private string? _standaloneExtractedDirPath;
|
||||||
|
private string? _standaloneBackupPath;
|
||||||
|
private string? _boxedPayloadEntryPath;
|
||||||
|
private bool _canExtractViaExternalTool;
|
||||||
|
|
||||||
|
/// <summary>FOSSIL形態(FOSSILindex.html + 単体Game.exe、data/System.json はディスク上)かどうか</summary>
|
||||||
|
public bool IsFossilSingleExe
|
||||||
|
{
|
||||||
|
get => _isFossilSingleExe;
|
||||||
|
set { if (_isFossilSingleExe != value) { _isFossilSingleExe = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>boxed形態(ゲーム本体をexeへ内包、例: Game_boxed.exe)かどうか</summary>
|
||||||
|
public bool IsBoxedExe
|
||||||
|
{
|
||||||
|
get => _isBoxedExe;
|
||||||
|
set { if (_isBoxedExe != value) { _isBoxedExe = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>いずれかの単体exe梱包形態(FOSSIL / boxed)かどうか</summary>
|
||||||
|
public bool IsStandaloneExePackage => IsFossilSingleExe || IsBoxedExe;
|
||||||
|
|
||||||
|
/// <summary>単体exe梱包ゲームを _extracted へ展開済みかどうか</summary>
|
||||||
|
public bool IsStandaloneExeExtracted
|
||||||
|
{
|
||||||
|
get => _isStandaloneExeExtracted;
|
||||||
|
set { if (_isStandaloneExeExtracted != value) { _isStandaloneExeExtracted = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>展開先ディレクトリ(ゲームフォルダ内 _extracted)</summary>
|
||||||
|
public string? StandaloneExtractedDirPath
|
||||||
|
{
|
||||||
|
get => _standaloneExtractedDirPath;
|
||||||
|
set { if (_standaloneExtractedDirPath != value) { _standaloneExtractedDirPath = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>exe内コンテナ改変時のバックアップパス(*.glbak)</summary>
|
||||||
|
public string? StandaloneBackupPath
|
||||||
|
{
|
||||||
|
get => _standaloneBackupPath;
|
||||||
|
set { if (_standaloneBackupPath != value) { _standaloneBackupPath = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>boxed exe内で注入対象とするコンテナ内エントリ(例: js/plugins.js)</summary>
|
||||||
|
public string? BoxedPayloadEntryPath
|
||||||
|
{
|
||||||
|
get => _boxedPayloadEntryPath;
|
||||||
|
set { if (_boxedPayloadEntryPath != value) { _boxedPayloadEntryPath = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部アンパッカー(Tools\7zr.exe 等)による展開を試行できる可能性があるか。
|
||||||
|
/// 標準ZIP署名が未確定でも、boxed命名exeが存在する場合に true となり「展開試行可」を示す。
|
||||||
|
/// 実際に展開可能かは実行時(ExtractPackageNw)に確定する。
|
||||||
|
/// </summary>
|
||||||
|
public bool CanExtractViaExternalTool
|
||||||
|
{
|
||||||
|
get => _canExtractViaExternalTool;
|
||||||
|
set { if (_canExtractViaExternalTool != value) { _canExtractViaExternalTool = value; OnPropertyChanged(); } }
|
||||||
|
}
|
||||||
|
|
||||||
public override GameEngineKind EngineKind => EngineType switch
|
public override GameEngineKind EngineKind => EngineType switch
|
||||||
{
|
{
|
||||||
TkoolEngineType.Tyrano => GameEngineKind.Tyrano,
|
TkoolEngineType.Tyrano => GameEngineKind.Tyrano,
|
||||||
@@ -572,7 +640,9 @@ namespace GameLauncher.Models
|
|||||||
new() { Id = "RgssBattleTurnRecoverMp", Name = "🔷 ターン開始時 全回復 (MP)", Description = "戦闘中の毎ターン開始時にパーティ全員のMPを全回復します。" },
|
new() { Id = "RgssBattleTurnRecoverMp", Name = "🔷 ターン開始時 全回復 (MP)", Description = "戦闘中の毎ターン開始時にパーティ全員のMPを全回復します。" },
|
||||||
new() { Id = "RgssBattleTurnRecoverTp", Name = "⚡ ターン開始時 全回復 (TP)", Description = "戦闘中の毎ターン開始時にパーティ全員のTPを最大(100)にします。(VX Ace)" },
|
new() { Id = "RgssBattleTurnRecoverTp", Name = "⚡ ターン開始時 全回復 (TP)", Description = "戦闘中の毎ターン開始時にパーティ全員のTPを最大(100)にします。(VX Ace)" },
|
||||||
new() { Id = "RgssMessageInstant", Name = "⏩ メッセージ瞬間表示・高速スキップ", Description = "会話ウィンドウの文字送りウェイトをカットし、瞬間表示します。" },
|
new() { Id = "RgssMessageInstant", Name = "⏩ メッセージ瞬間表示・高速スキップ", Description = "会話ウィンドウの文字送りウェイトをカットし、瞬間表示します。" },
|
||||||
new() { Id = "RgssCommandMemory", Name = "🧠 コマンド位置記憶 (ツクールMV風)", Description = "メニュー画面や戦闘中のアクターコマンドのカーソル選択位置を記憶して次回遷移時に復元します。" }
|
new() { Id = "RgssCommandMemory", Name = "🧠 コマンド位置記憶 (ツクールMV風)", Description = "メニュー画面や戦闘中のアクターコマンドのカーソル選択位置を記憶して次回遷移時に復元します。" },
|
||||||
|
new() { Id = "RgssWindowResizeFull", Name = "🖥 ウィンドウをディスプレイに合わせて整数倍拡大 (スクリプト注入)", Description = "ゲーム起動時に論理解像度をディスプレイに収まる最大の整数倍(1x/2x/3x...)へ拡大し、ウィンドウを追従させます。VX AceはGraphics.resize_screen、VX(RGSS2)はWin32APIフォールバックで拡大します。解除で完全復元されます。" },
|
||||||
|
new() { Id = "RgssWindowResizeExternal", Name = "🪟 外部ツールでウィンドウ拡大 (Win32 API / Sizer等)", Description = "ゲーム側は無改造のまま、ランチャーがゲームウィンドウを検出してディスプレイに収まる最大の整数倍へ拡大します。外部ツールパス設定があればそちらを優先起動します。(既定OFF)" }
|
||||||
];
|
];
|
||||||
|
|
||||||
/// <summary>SRPG Studio用スクリプト改造定義一覧</summary>
|
/// <summary>SRPG Studio用スクリプト改造定義一覧</summary>
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Tkool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 対象ゲームの plugins.js に対する可逆なJSプラグイン注入(mod)を行うサービス。
|
||||||
|
///
|
||||||
|
/// 設計方針:
|
||||||
|
/// - ゲーム専用改造は他ゲームへ一切影響を与えない(対象ゲームフォルダ内でのみ完結)。
|
||||||
|
/// - 注入前に plugins.js を *.glbak へバックアップし、marker 区間のみを書き換える。
|
||||||
|
/// - Restore は *.glbak から復元し、配置した mod JS を削除して完全可逆にする。
|
||||||
|
/// - exe内 package.nw 直接書換は最終手段(必須バックアップ)。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TkoolInjectionService
|
||||||
|
{
|
||||||
|
/// <summary>注入マーカー(この区間のみを除去すれば完全に元へ戻せる)</summary>
|
||||||
|
public const string BeginMarker = "/* === GAMELAUNCHER_MOD_BEGIN === */";
|
||||||
|
public const string EndMarker = "/* === GAMELAUNCHER_MOD_END === */";
|
||||||
|
|
||||||
|
/// <summary>注入する改造プラグインファイル名</summary>
|
||||||
|
public const string ModPluginId = "GameLauncher_Mod";
|
||||||
|
public const string ModPluginFileName = "GameLauncher_Mod.js";
|
||||||
|
|
||||||
|
/// <summary>exe内コンテナ改変時のバックアップ拡張子</summary>
|
||||||
|
public const string ExeBackupSuffix = ".glbak";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// plugins.js に marker が存在する場合、改造注入済みと判定します。
|
||||||
|
/// </summary>
|
||||||
|
public static bool CheckIsModded(string pluginsJsPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pluginsJsPath) || !File.Exists(pluginsJsPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var content = File.ReadAllText(pluginsJsPath, Encoding.UTF8);
|
||||||
|
// パス破損の影響を避けるため、対称な EndMarker(先頭/末尾共通)で判定
|
||||||
|
return content.Contains(BeginMarker) || content.Contains(ModPluginId);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// modプラグインエントリを plugins.js へ marker 付きで追記し、
|
||||||
|
/// mod JS を js/plugins/ へ配置します。バックアップ(*.glbak)は必須。
|
||||||
|
/// </summary>
|
||||||
|
public bool Apply(string pluginsJsPath, string pluginsDir, string modSourcePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pluginsJsPath) || !File.Exists(pluginsJsPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(modSourcePath) || !File.Exists(modSourcePath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var backupPath = pluginsJsPath + ExeBackupSuffix;
|
||||||
|
|
||||||
|
// 1. バックアップ(未作成時のみ)。既に marker がある場合はクリーン化して保持
|
||||||
|
if (!File.Exists(backupPath))
|
||||||
|
{
|
||||||
|
var original = File.ReadAllText(pluginsJsPath, Encoding.UTF8);
|
||||||
|
File.WriteAllText(backupPath, RemoveInjection(original), new UTF8Encoding(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. mod JS を plugins ディレクトリへ配置
|
||||||
|
if (string.IsNullOrEmpty(pluginsDir))
|
||||||
|
{
|
||||||
|
pluginsDir = Path.Combine(Path.GetDirectoryName(pluginsJsPath)!, "plugins");
|
||||||
|
}
|
||||||
|
Directory.CreateDirectory(pluginsDir);
|
||||||
|
File.Copy(modSourcePath, Path.Combine(pluginsDir, ModPluginFileName), overwrite: true);
|
||||||
|
|
||||||
|
// 3. バックアップ(クリーン状態)を元に marker 区間を注入
|
||||||
|
var baseContent = File.ReadAllText(backupPath, Encoding.UTF8);
|
||||||
|
var injected = InjectEntry(RemoveInjection(baseContent));
|
||||||
|
File.WriteAllText(pluginsJsPath, injected, new UTF8Encoding(false));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// *.glbak から plugins.js を復元し、配置した mod JS を削除します(完全可逆)。
|
||||||
|
/// </summary>
|
||||||
|
public bool Restore(string pluginsJsPath, string pluginsDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pluginsJsPath) || !File.Exists(pluginsJsPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var backupPath = pluginsJsPath + ExeBackupSuffix;
|
||||||
|
|
||||||
|
if (File.Exists(backupPath))
|
||||||
|
{
|
||||||
|
var backupContent = File.ReadAllText(backupPath, Encoding.UTF8);
|
||||||
|
File.WriteAllText(pluginsJsPath, backupContent, new UTF8Encoding(false));
|
||||||
|
try { File.Delete(backupPath); } catch { }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// バックアップが無くても現状から marker 区間を除去
|
||||||
|
var current = File.ReadAllText(pluginsJsPath, Encoding.UTF8);
|
||||||
|
File.WriteAllText(pluginsJsPath, RemoveInjection(current), new UTF8Encoding(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置した mod JS を削除(ゴミを残さない)
|
||||||
|
if (!string.IsNullOrEmpty(pluginsDir))
|
||||||
|
{
|
||||||
|
var modPlugin = Path.Combine(pluginsDir, ModPluginFileName);
|
||||||
|
if (File.Exists(modPlugin))
|
||||||
|
{
|
||||||
|
try { File.Delete(modPlugin); } catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// plugins.js の配列へ mod プラグインのエントリを marker 付きで追加します。
|
||||||
|
/// </summary>
|
||||||
|
private static string InjectEntry(string content)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(content))
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
int arrayStart = content.IndexOf('[');
|
||||||
|
int arrayEnd = content.LastIndexOf(']');
|
||||||
|
if (arrayStart == -1 || arrayEnd == -1 || arrayEnd <= arrayStart)
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
var entry = $"{BeginMarker}{{\"name\":\"{ModPluginId}\",\"status\":true,\"description\":\"GameLauncher mod\",\"parameters\":{{}}}}{EndMarker}";
|
||||||
|
|
||||||
|
var prefix = content.Substring(0, arrayStart + 1);
|
||||||
|
var inner = content.Substring(arrayStart + 1, arrayEnd - arrayStart - 1);
|
||||||
|
var suffix = content.Substring(arrayEnd);
|
||||||
|
|
||||||
|
var trimmedInner = inner.Trim();
|
||||||
|
var newInner = string.IsNullOrEmpty(trimmedInner)
|
||||||
|
? "\n" + entry + "\n"
|
||||||
|
: inner.TrimEnd() + ",\n" + entry + "\n";
|
||||||
|
|
||||||
|
return prefix + newInner + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// marker 区間(BEGIN..END)を完全に除去します。これにより注入前の状態へ復元できます。
|
||||||
|
/// </summary>
|
||||||
|
private static string RemoveInjection(string content)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(content))
|
||||||
|
{
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
string prev;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
prev = content;
|
||||||
|
int begin = content.IndexOf(BeginMarker, StringComparison.Ordinal);
|
||||||
|
if (begin < 0) break;
|
||||||
|
|
||||||
|
int end = content.IndexOf(EndMarker, begin, StringComparison.Ordinal);
|
||||||
|
if (end < 0) break;
|
||||||
|
end += EndMarker.Length;
|
||||||
|
|
||||||
|
// 直前のカンマ・余分な空白も除去対象に含める
|
||||||
|
int cutStart = begin;
|
||||||
|
int scan = begin - 1;
|
||||||
|
while (scan >= 0 && char.IsWhiteSpace(content[scan])) scan--;
|
||||||
|
if (scan >= 0 && content[scan] == ',') cutStart = scan;
|
||||||
|
|
||||||
|
content = content.Substring(0, cutStart) + content.Substring(end);
|
||||||
|
}
|
||||||
|
while (content != prev);
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
|
|||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Tkool
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ツクールスクリプト改造プラグインの動的検出・適用・復元・管理を行うサービス
|
/// ツクールスクリプト改造プラグインの動的検出・適用・復元・管理を行うサービス
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using GameLauncher.Engines.Nwjs;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Tkool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// nw.js boxed(exe埋め込み package.nw)等の単体exe梱包ツクールゲームの解析と
|
||||||
|
/// ゲームフォルダ内 `_extracted` への冪等展開を行うオーケストレーター。
|
||||||
|
///
|
||||||
|
/// 役割分担(恒久・再利用可能を目的とした汎用設計):
|
||||||
|
/// - 本サービス = 抽出の「進行役(オーケストレーター)」。
|
||||||
|
/// - <see cref="NwjsPackageUnpacker"/> = 組み込みの埋め込みZIPコンテナ検出・展開。
|
||||||
|
/// - <see cref="NwjsUnpackerToolProvider"/> = 外部アンパッカーの取得・呼び出し。
|
||||||
|
///
|
||||||
|
/// 展開戦略(順に試行):
|
||||||
|
/// 1. 組み込みZIP展開: exe内の標準ZIPコンテナ(package.nw)を検出して展開。
|
||||||
|
/// 2. 外部ツール委譲: Tools\ 配下の外部アンパッカー(未配置なら自動取得)へ委譲。
|
||||||
|
///
|
||||||
|
/// 設計方針:
|
||||||
|
/// - 1.14GB級exeを対象に含むため、組み込み検出は限定/逐次走査で行う。
|
||||||
|
/// - 展開はゲームフォルダ内 `_extracted` のみ。他ゲームへは一切影響しない。
|
||||||
|
/// - 冪等: 展開済み(plugins.js 存在)なら再展開しない。
|
||||||
|
/// - 既存公開API(GetExtractedDir / ContainsPackageNwMarker / IsExtractionComplete /
|
||||||
|
/// ExeBackupSuffix / ExtractPackageNw)のシグネチャは維持し、後方互換を壊さない。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TkoolPackagedExtractionService
|
||||||
|
{
|
||||||
|
/// <summary>ゲームフォルダ内の展開先フォルダ名(Asar/SRPG の慣習に合わせる)</summary>
|
||||||
|
public const string ExtractedDirName = NwjsPackageUnpacker.ExtractedDirName;
|
||||||
|
|
||||||
|
/// <summary>exe内コンテナ改変時のバックアップ拡張子</summary>
|
||||||
|
public const string ExeBackupSuffix = ".glbak";
|
||||||
|
|
||||||
|
/// <summary>展開戦略の種別。将来の新形式追加を見据え、列挙型で差し替え可能にする。</summary>
|
||||||
|
public enum UnpackStrategy
|
||||||
|
{
|
||||||
|
/// <summary>組み込みの埋め込みZIPコンテナ検出・展開</summary>
|
||||||
|
BuiltInZip = 0,
|
||||||
|
|
||||||
|
/// <summary>外部アンパッカーへの委譲</summary>
|
||||||
|
ExternalTool = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>ゲームフォルダ内の展開先ディレクトリ(物理パス)</summary>
|
||||||
|
public static string GetExtractedDir(string gameRootDir)
|
||||||
|
=> NwjsPackageUnpacker.GetExtractedDir(gameRootDir);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exeに package.nw マーカーが含まれるかを限定部分読み(4MB窓×数点)で判定します。
|
||||||
|
/// 全走査は行いません(1.14GB級exe対策)。
|
||||||
|
/// </summary>
|
||||||
|
public static bool ContainsPackageNwMarker(string exePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const int windowSize = 4 * 1024 * 1024;
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long size = fs.Length;
|
||||||
|
if (size < 1024)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double[] fractions = { 0.25, 0.5, 0.75, 0.9 };
|
||||||
|
foreach (var frac in fractions)
|
||||||
|
{
|
||||||
|
long start = (long)(size * frac);
|
||||||
|
int readLen = (int)Math.Min(windowSize, size - start);
|
||||||
|
if (readLen <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf = new byte[readLen];
|
||||||
|
fs.Seek(start, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, buf.Length);
|
||||||
|
var text = System.Text.Encoding.ASCII.GetString(buf, 0, read);
|
||||||
|
|
||||||
|
if (text.IndexOf("package.nw", StringComparison.Ordinal) >= 0 ||
|
||||||
|
text.IndexOf("package.json", StringComparison.Ordinal) >= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exe内ZIPのローカルヘッダ(PK\x03\x04)offsetを限定ウィンドウで検出します。
|
||||||
|
/// exe先頭の自己展開部を除いた中盤以降のみを対象にし、全走査を避けます。
|
||||||
|
/// </summary>
|
||||||
|
public static long? FindEmbeddedZipOffset(string exePath, long searchStart = 0, int windowBytes = 8 * 1024 * 1024)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long size = fs.Length;
|
||||||
|
|
||||||
|
// searchStart が 0 の場合は中盤〜後半(package.nw は後半に置かれる傾向)のみを走査
|
||||||
|
double[] fractions = searchStart > 0 ? new[] { (double)searchStart / Math.Max(1, size) } : new[] { 0.5, 0.65, 0.8, 0.9 };
|
||||||
|
foreach (var frac in fractions)
|
||||||
|
{
|
||||||
|
long start = (long)(size * frac);
|
||||||
|
int readLen = (int)Math.Min(windowBytes, size - start);
|
||||||
|
if (readLen <= 4)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf = new byte[readLen];
|
||||||
|
fs.Seek(start, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, buf.Length);
|
||||||
|
|
||||||
|
for (int i = 0; i < read - 3; i++)
|
||||||
|
{
|
||||||
|
if (buf[i] == 0x50 && buf[i + 1] == 0x4B && buf[i + 2] == 0x03 && buf[i + 3] == 0x04)
|
||||||
|
{
|
||||||
|
return start + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既存 `_extracted` が完全か(plugins.js が存在するか)を判定します。
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsExtractionComplete(string extractedDir, out string? pluginsJsPath)
|
||||||
|
=> NwjsPackageUnpacker.IsExtractionComplete(extractedDir, out pluginsJsPath, out _);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exe内ZIP(package.nw 等)をゲームフォルダ内 `_extracted` へ冪等に全展開し、
|
||||||
|
/// 展開後の js/plugins.js(相対パス)を返します。展開できなければ null。
|
||||||
|
///
|
||||||
|
/// 展開戦略を順に試行します: 組み込みZIP展開 → 外部ツール委譲。
|
||||||
|
/// 後方互換のため同期シグネチャを維持します(外部ツールの自動取得は内部で同期待機)。
|
||||||
|
/// </summary>
|
||||||
|
public string? ExtractPackageNw(string exePath, string gameRoot, out string extractedDir, IProgress<string>? progress = null)
|
||||||
|
{
|
||||||
|
extractedDir = GetExtractedDir(gameRoot);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(exePath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 冪等: 展開済みならスキップ
|
||||||
|
if (Directory.Exists(extractedDir) && IsExtractionComplete(extractedDir, out _))
|
||||||
|
{
|
||||||
|
progress?.Report("既に展開済みです(_extracted を再利用)。");
|
||||||
|
return NwjsPackageUnpacker.IsExtractionComplete(extractedDir, out _, out var rel) ? rel : "js/plugins.js";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 戦略1: 組み込みZIP展開
|
||||||
|
progress?.Report("展開戦略: 組み込みZIP展開を試行します。");
|
||||||
|
var relBuiltin = NwjsPackageUnpacker.ExtractEmbeddedZip(exePath, extractedDir, progress);
|
||||||
|
if (relBuiltin != null)
|
||||||
|
{
|
||||||
|
return relBuiltin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 戦略2: 外部ツール委譲
|
||||||
|
progress?.Report("展開戦略: 外部アンパッカーへの委譲を試行します。");
|
||||||
|
var relExternal = ExtractViaExternalTool(exePath, extractedDir, progress);
|
||||||
|
if (relExternal != null)
|
||||||
|
{
|
||||||
|
return relExternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report("展開できませんでした(起動のみ対応)。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"展開処理中にエラーが発生しました: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 外部アンパッカー(未配置なら自動取得)で exe 内コンテナを `_extracted` へ展開します。
|
||||||
|
/// 失敗(ネット未接続等)時は例外を投げず null を返し、呼び出し側で「起動のみ」へフォールバックさせます。
|
||||||
|
/// </summary>
|
||||||
|
private static string? ExtractViaExternalTool(string exePath, string extractedDir, IProgress<string>? progress)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 外部ツールの可用性確保(初回は自動ダウンロード)。同期待機で取得。
|
||||||
|
var available = NwjsUnpackerToolProvider.IsToolAvailable()
|
||||||
|
|| Task.Run(() => NwjsUnpackerToolProvider.EnsureToolAvailableAsync(progress)).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
if (!available)
|
||||||
|
{
|
||||||
|
progress?.Report("外部アンパッカーを取得できませんでした(ネット未接続等)。起動のみ対応へフォールバックします。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tool = NwjsUnpackerToolProvider.GetToolPath();
|
||||||
|
if (tool == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展開先を一旦クリーンにする(部分展開の混在を避ける)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Directory.Exists(extractedDir))
|
||||||
|
{
|
||||||
|
Directory.Delete(extractedDir, recursive: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
if (!NwjsUnpackerToolProvider.ExtractWithExternalTool(tool, exePath, extractedDir, progress))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 展開結果から plugins.js を解決
|
||||||
|
var plugins = NwjsPackageUnpacker.ResolvePluginsJs(extractedDir);
|
||||||
|
if (plugins == null)
|
||||||
|
{
|
||||||
|
progress?.Report("展開は完了しましたが、js/plugins.js が見つかりませんでした。");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rel = Path.GetRelativePath(extractedDir, plugins).Replace(Path.DirectorySeparatorChar, '/');
|
||||||
|
progress?.Report($"外部アンパッカーでの展開が完了しました: {rel}");
|
||||||
|
return rel;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
progress?.Report($"外部アンパッカー委譲でエラーが発生しました: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Nwjs;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Tyrano
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ティラノスクリプトゲームの個別改造設定オプション
|
/// ティラノスクリプトゲームの個別改造設定オプション
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Engines.Unity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ゲームエンジンの大分類
|
/// ゲームエンジンの大分類
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Engines.Unity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unityゲームのデータモデル
|
/// Unityゲームのデータモデル
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Engines.Unity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PlayerPrefs(レジストリ)の1エントリを表すモデル
|
/// PlayerPrefs(レジストリ)の1エントリを表すモデル
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -11,7 +11,7 @@ using Microsoft.Win32;
|
|||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Unity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UnityのPlayerPrefs(レジストリ)およびセーブファイル(LocalLow / ゲームフォルダ)の編集・バックアップを行うサービス
|
/// UnityのPlayerPrefs(レジストリ)およびセーブファイル(LocalLow / ゲームフォルダ)の編集・バックアップを行うサービス
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Wolf
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ウディタ(WOLF RPGエディター)の Data.wolf アーカイブの解凍・抽出・状態管理サービス
|
/// ウディタ(WOLF RPGエディター)の Data.wolf アーカイブの解凍・抽出・状態管理サービス
|
||||||
@@ -57,22 +58,13 @@ namespace GameLauncher.Services
|
|||||||
return customPath;
|
return customPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. ランチャー直下の Tools\UberWolfCli.exe
|
// 2. エンジン別ツールフォルダ (Engines\Wolf\Tools\UberWolfCli.exe) を優先解決
|
||||||
var exeDir = AppPathHelper.GetExeDirectory();
|
foreach (var toolName in new[] { "UberWolfCli.exe", "UberWolf.exe", "WolfDec.exe" })
|
||||||
var candidates = new[]
|
|
||||||
{
|
{
|
||||||
Path.Combine(exeDir, "Tools", "UberWolfCli.exe"),
|
var resolved = AppPathHelper.ResolveEngineTool("Wolf", toolName);
|
||||||
Path.Combine(exeDir, "Tools", "UberWolf.exe"),
|
if (!string.IsNullOrEmpty(resolved) && File.Exists(resolved))
|
||||||
Path.Combine(exeDir, "Tools", "WolfDec.exe"),
|
|
||||||
@"C:\VS2026\GameLauncher\Tools\UberWolfCli.exe",
|
|
||||||
@"Z:\自作ソフト\GameLauncher\Tools\UberWolfCli.exe"
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var candidate in candidates)
|
|
||||||
{
|
|
||||||
if (File.Exists(candidate))
|
|
||||||
{
|
{
|
||||||
return candidate;
|
return resolved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Wolf
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ウディタ(WOLF RPGエディター)向けのプロキシDLL(メモリフック/スピードハック)
|
/// ウディタ(WOLF RPGエディター)向けのプロキシDLL(メモリフック/スピードハック)
|
||||||
@@ -53,7 +54,7 @@ namespace GameLauncher.Services
|
|||||||
var sourceDllPath = ResolveProxyDllPath();
|
var sourceDllPath = ResolveProxyDllPath();
|
||||||
if (string.IsNullOrEmpty(sourceDllPath) || !File.Exists(sourceDllPath))
|
if (string.IsNullOrEmpty(sourceDllPath) || !File.Exists(sourceDllPath))
|
||||||
{
|
{
|
||||||
return (false, "プロキシDLL(Tools\\speedhack-i686\\version.dll)が見つかりません。");
|
return (false, "プロキシDLL(Engines\\Wolf\\Tools\\speedhack-i686\\version.dll)が見つかりません。");
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetDllPath = Path.Combine(gameDir, ProxyDllName);
|
var targetDllPath = Path.Combine(gameDir, ProxyDllName);
|
||||||
@@ -166,18 +167,18 @@ namespace GameLauncher.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private string? ResolveProxyDllPath()
|
private string? ResolveProxyDllPath()
|
||||||
{
|
{
|
||||||
var exeDir = AppPathHelper.GetExeDirectory();
|
// エンジン別ツールフォルダ (Engines\Wolf\Tools\speedhack-i686\version.dll) を優先解決
|
||||||
var candidates = new[]
|
var resolved = AppPathHelper.ResolveEngineTool("Wolf", Path.Combine("speedhack-i686", ProxyDllName));
|
||||||
|
if (!string.IsNullOrEmpty(resolved) && File.Exists(resolved))
|
||||||
{
|
{
|
||||||
Path.Combine(exeDir, "Tools", "speedhack-i686", ProxyDllName),
|
return resolved;
|
||||||
Path.Combine(exeDir, "Tools", ProxyDllName),
|
}
|
||||||
@"C:\VS2026\GameLauncher\Tools\speedhack-i686\version.dll",
|
|
||||||
@"Z:\自作ソフト\GameLauncher\Tools\speedhack-i686\version.dll"
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var path in candidates)
|
// 互換: プロキシDLL直置きのケース
|
||||||
|
var direct = AppPathHelper.ResolveEngineTool("Wolf", ProxyDllName);
|
||||||
|
if (!string.IsNullOrEmpty(direct) && File.Exists(direct))
|
||||||
{
|
{
|
||||||
if (File.Exists(path)) return path;
|
return direct;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Engines.Wolf
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ウディタ(WOLF RPGエディター)セーブデータ内の1つの変数項目
|
/// ウディタ(WOLF RPGエディター)セーブデータ内の1つの変数項目
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="plugins\AlwaysMaxHpMp.js" />
|
<None Remove="plugins\AlwaysMaxHpMp.js" />
|
||||||
|
<None Remove="plugins\GameLauncher_StandaloneMod.js" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -273,5 +273,78 @@ namespace GameLauncher.Helpers
|
|||||||
CopyDirectory(sub, destSub);
|
CopyDirectory(sub, destSub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the engine-specific tools directory, e.g. "Engines/Wolf/Tools".
|
||||||
|
/// External tools are grouped per engine so that each engine only references
|
||||||
|
/// its own tools and never depends on another engine's files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="engineName">Engine identifier ("Rgss", "Wolf", "Nwjs", ...).</param>
|
||||||
|
/// <returns>Absolute path to the engine tools directory (created when possible).</returns>
|
||||||
|
public static string GetEngineToolsDirectory(string engineName)
|
||||||
|
{
|
||||||
|
var safeEngine = string.IsNullOrWhiteSpace(engineName) ? "Common" : engineName.Trim();
|
||||||
|
var path = Path.Combine(GetExeDirectory(), "Engines", safeEngine, "Tools");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves an engine-specific external tool file path.
|
||||||
|
/// Searches the deployed location, the production folder, and the source
|
||||||
|
/// tree fallback, returning the first existing candidate or null.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="engineName">Engine identifier ("Rgss", "Wolf", "Nwjs", ...).</param>
|
||||||
|
/// <param name="toolFileName">Tool file name (e.g. "UberWolfCli.exe").</param>
|
||||||
|
/// <returns>Absolute path to the tool, or null if not found.</returns>
|
||||||
|
public static string? ResolveEngineTool(string engineName, string toolFileName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(engineName) || string.IsNullOrWhiteSpace(toolFileName))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var safeEngine = engineName.Trim();
|
||||||
|
var exeDir = GetExeDirectory();
|
||||||
|
var candidates = new[]
|
||||||
|
{
|
||||||
|
Path.Combine(exeDir, "Engines", safeEngine, "Tools", toolFileName),
|
||||||
|
Path.Combine(AppContext.BaseDirectory, "Engines", safeEngine, "Tools", toolFileName),
|
||||||
|
Path.Combine(exeDir, "Engines", safeEngine, "Tools"),
|
||||||
|
};
|
||||||
|
|
||||||
|
// First two candidates are full file paths; check those directly.
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
if (File.Exists(candidates[i]))
|
||||||
|
{
|
||||||
|
return candidates[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallbacks for development-time source layout.
|
||||||
|
var devFallbacks = new[]
|
||||||
|
{
|
||||||
|
$@"C:\VS2026\GameLauncher\Engines\{safeEngine}\Tools\{toolFileName}",
|
||||||
|
$@"Z:\自作ソフト\GameLauncher\Engines\{safeEngine}\Tools\{toolFileName}",
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var candidate in devFallbacks)
|
||||||
|
{
|
||||||
|
if (File.Exists(candidate))
|
||||||
|
{
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@ using System.Globalization;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Helpers
|
namespace GameLauncher.Helpers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -990,6 +990,43 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
<!-- 単体exe梱包(FOSSIL / boxed)管理セクション -->
|
||||||
|
<Border Background="#1E1E2E" BorderBrush="#00B894" BorderThickness="1.5" CornerRadius="8" Padding="14" Margin="0,0,0,14">
|
||||||
|
<Border.Style>
|
||||||
|
<Style TargetType="Border">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding SelectedItem.IsFossilSingleExe, ElementName=lstGames}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectedItem.IsBoxedExe, ElementName=lstGames}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Border.Style>
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||||
|
<TextBlock Text="🧊 単体exe梱包ゲーム管理" FontSize="13" FontWeight="Bold" Foreground="#55EFC4"/>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock Text="FOSSIL / boxed 形態のツクールMZゲームです。改造ONで _extracted へ展開し、JSへ可逆的に注入します(.glbak で復元可能)。"
|
||||||
|
FontSize="11" Foreground="{StaticResource TextSecondary}" TextWrapping="Wrap" Margin="0,0,0,10"/>
|
||||||
|
<TextBlock Text="展開は「組み込みZIP展開 → 外部アンパッカー委譲(Tools\ の 7zr.exe。未配置なら自動取得)」の順で試行します。展開できない場合は起動のみ対応になります。"
|
||||||
|
FontSize="10" Foreground="#74B9FF" TextWrapping="Wrap" Margin="0,0,0,10"/>
|
||||||
|
<Grid Margin="0,0,0,4">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button x:Name="btnExtractStandalone" Grid.Column="0" Style="{StaticResource ModernButton}"
|
||||||
|
Content="📦 埋め込みを展開" Click="btnExtractStandalone_Click"/>
|
||||||
|
<Button x:Name="btnRestoreStandalone" Grid.Column="2" Style="{StaticResource ModernButton}"
|
||||||
|
Content="↩ 改造を元に戻す" Click="btnRestoreStandalone_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<!-- RGSSアーカイブ管理セクション(HasRgssArchive時のみ表示) -->
|
<!-- RGSSアーカイブ管理セクション(HasRgssArchive時のみ表示) -->
|
||||||
<Border Background="#1E1E2E" BorderBrush="#00CEC9" BorderThickness="1.5" CornerRadius="8" Padding="14" Margin="0,0,0,14"
|
<Border Background="#1E1E2E" BorderBrush="#00CEC9" BorderThickness="1.5" CornerRadius="8" Padding="14" Margin="0,0,0,14"
|
||||||
Visibility="{Binding SelectedItem.RgssBadgeVisibility, ElementName=lstGames}">
|
Visibility="{Binding SelectedItem.RgssBadgeVisibility, ElementName=lstGames}">
|
||||||
|
|||||||
+186
-2
@@ -17,6 +17,12 @@ using Microsoft.Win32;
|
|||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
using GameLauncher.Services;
|
using GameLauncher.Services;
|
||||||
|
using GameLauncher.Engines.Rgss;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Tyrano;
|
||||||
|
using GameLauncher.Engines.Wolf;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Engines.Nwjs;
|
||||||
|
|
||||||
namespace GameLauncher
|
namespace GameLauncher
|
||||||
{
|
{
|
||||||
@@ -36,6 +42,12 @@ namespace GameLauncher
|
|||||||
private readonly WolfModService _wolfModService = new();
|
private readonly WolfModService _wolfModService = new();
|
||||||
private readonly SrpgArchiveService _srpgArchiveService = new();
|
private readonly SrpgArchiveService _srpgArchiveService = new();
|
||||||
private readonly SrpgModService _srpgModService = new();
|
private readonly SrpgModService _srpgModService = new();
|
||||||
|
private readonly TkoolPackagedExtractionService _extractionService = new();
|
||||||
|
private readonly TkoolInjectionService _injectionService = new();
|
||||||
|
private readonly WindowResizeService _windowResizeService = new();
|
||||||
|
|
||||||
|
/// <summary>直近に起動したゲームプロセス(起動後の外部連携処理で使用)</summary>
|
||||||
|
private Process? _lastStartedProcess;
|
||||||
|
|
||||||
private readonly ObservableCollection<GameItemBase> _games = [];
|
private readonly ObservableCollection<GameItemBase> _games = [];
|
||||||
private ListCollectionView _gamesView = null!;
|
private ListCollectionView _gamesView = null!;
|
||||||
@@ -671,6 +683,13 @@ namespace GameLauncher
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 単体exe梱包ゲーム(FOSSIL / boxed)の場合の起動処理
|
||||||
|
if (tg.IsStandaloneExePackage)
|
||||||
|
{
|
||||||
|
await LaunchStandaloneExeGameAsync(tg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ASAR形式ゲームで未解凍かつ改造適用ONの場合、解凍を促す
|
// ASAR形式ゲームで未解凍かつ改造適用ONの場合、解凍を促す
|
||||||
if (tg.IsAsar && !tg.IsAsarExtracted && tg.ApplyMod)
|
if (tg.IsAsar && !tg.IsAsarExtracted && tg.ApplyMod)
|
||||||
{
|
{
|
||||||
@@ -730,6 +749,104 @@ namespace GameLauncher
|
|||||||
}
|
}
|
||||||
|
|
||||||
StartGameProcess(tg);
|
StartGameProcess(tg);
|
||||||
|
|
||||||
|
// RGSSゲーム(ツクールVX / VX Ace)で外部ツール方式のウィンドウ拡大がONの場合、起動後に拡大を適用
|
||||||
|
if (tg.IsRgss && tg.IsPluginEnabled("RgssWindowResizeExternal", tg.PluginSettings, false))
|
||||||
|
{
|
||||||
|
var resizeProc = _lastStartedProcess;
|
||||||
|
if (resizeProc != null)
|
||||||
|
{
|
||||||
|
var (resizeOk, resizeMsg) = await _windowResizeService.ApplyResizeAsync(resizeProc, _config.WindowResizeToolPath);
|
||||||
|
AppendLog($"[ウィンドウ拡大] {tg.Title}: {resizeMsg}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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)
|
private void LaunchUnityGame(UnityGameItem ug)
|
||||||
@@ -770,7 +887,7 @@ namespace GameLauncher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.Start(startInfo);
|
_lastStartedProcess = Process.Start(startInfo);
|
||||||
|
|
||||||
game.LastLaunched = DateTime.Now;
|
game.LastLaunched = DateTime.Now;
|
||||||
_scannerService.SaveCache(_games);
|
_scannerService.SaveCache(_games);
|
||||||
@@ -942,6 +1059,73 @@ namespace GameLauncher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 単体exe梱包ゲーム(FOSSIL / boxed)の埋め込みコンテナを _extracted へ展開します。
|
||||||
|
/// </summary>
|
||||||
|
private async void btnExtractStandalone_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsStandaloneExePackage) return;
|
||||||
|
|
||||||
|
btnExtractStandalone.IsEnabled = false;
|
||||||
|
AppendLog($"[単体exe展開開始] {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));
|
||||||
|
|
||||||
|
if (relPlugins != null)
|
||||||
|
{
|
||||||
|
tg.IsStandaloneExeExtracted = true;
|
||||||
|
tg.StandaloneExtractedDirPath = TkoolPackagedExtractionService.GetExtractedDir(tg.RootDirectory);
|
||||||
|
_scannerService.SaveCache(_games);
|
||||||
|
AppendLog($"[単体exe展開成功] {tg.Title}: {relPlugins}");
|
||||||
|
MessageBox.Show("埋め込みコンテナを _extracted へ展開しました。", "埋め込み展開",
|
||||||
|
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AppendLog($"[単体exe展開失敗] {tg.Title}: exe内に展開可能なZIPコンテナを検出できませんでした。");
|
||||||
|
MessageBox.Show("exe内に展開可能なZIPコンテナを検出できませんでした。起動対応のみ可能です。",
|
||||||
|
"埋め込み展開", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
btnExtractStandalone.IsEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 単体exe梱包ゲームの改造プラグイン注入を除去し、オリジナル状態へ復元します(可逆)。
|
||||||
|
/// </summary>
|
||||||
|
private void btnRestoreStandalone_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (lstGames.SelectedItem is not TkoolGameItem tg || !tg.IsStandaloneExePackage) 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 pluginsDir = Path.Combine(Path.GetDirectoryName(injectable)!, "plugins");
|
||||||
|
var ok = _injectionService.Restore(injectable, pluginsDir);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
tg.IsModded = false;
|
||||||
|
tg.StandaloneBackupPath = null;
|
||||||
|
_scannerService.SaveCache(_games);
|
||||||
|
}
|
||||||
|
AppendLog($"[単体exe復元{(ok ? "成功" : "失敗")}] {tg.Title}");
|
||||||
|
MessageBox.Show(ok ? "ゲームを改造前のオリジナル状態へ復元しました。" : "復元に失敗しました。",
|
||||||
|
"改造の復元", MessageBoxButton.OK,
|
||||||
|
ok ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RestoreAsarForGame(TkoolGameItem tg)
|
private async Task RestoreAsarForGame(TkoolGameItem tg)
|
||||||
{
|
{
|
||||||
if (!tg.IsAsar || string.IsNullOrEmpty(tg.AsarPath) || string.IsNullOrEmpty(tg.AsarExtractedDirPath)) return;
|
if (!tg.IsAsar || string.IsNullOrEmpty(tg.AsarPath) || string.IsNullOrEmpty(tg.AsarExtractedDirPath)) return;
|
||||||
@@ -1486,7 +1670,7 @@ namespace GameLauncher
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("プロキシDLLの配置に失敗しました。\nTools/speedhack-i686/version.dll が存在するか確認してください。", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show("プロキシDLLの配置に失敗しました。\nEngines/Rgss/Tools/speedhack-i686/version.dll が存在するか確認してください。", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
}
|
}
|
||||||
_scannerService.SaveCache(_games);
|
_scannerService.SaveCache(_games);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using System.ComponentModel;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Models
|
namespace GameLauncher.Models
|
||||||
{
|
{
|
||||||
@@ -29,6 +31,9 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>Wolf RPG アーカイブ解凍ツールの実行ファイルパス(UberWolfCli.exe / WolfDec.exe など)</summary>
|
/// <summary>Wolf RPG アーカイブ解凍ツールの実行ファイルパス(UberWolfCli.exe / WolfDec.exe など)</summary>
|
||||||
public string WolfExtractorPath { get; set; } = string.Empty;
|
public string WolfExtractorPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>ウィンドウ拡大用の外部ツール実行ファイルパス(Sizer等。空の場合はランチャー内蔵のWin32 API方式を使用)</summary>
|
||||||
|
public string WindowResizeToolPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
// フィルター状態の保存(再起動時復元用)
|
// フィルター状態の保存(再起動時復元用)
|
||||||
public string TkoolEngineFilter { get; set; } = "All";
|
public string TkoolEngineFilter { get; set; } = "All";
|
||||||
public bool TkoolFilterModdedOnly { get; set; }
|
public bool TkoolFilterModdedOnly { get; set; }
|
||||||
|
|||||||
@@ -3,6 +3,81 @@
|
|||||||
RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製ゲームを1つの洗練された画面で一元管理・高速起動できる統合ランチャーです。
|
RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製ゲームを1つの洗練された画面で一元管理・高速起動できる統合ランチャーです。
|
||||||
従来の **TkoolLauncher** と **UnityLauncher** の全機能(スクリプト改造、ASAR解凍・復元、PlayerPrefsレジストリ編集、セーブファイル編集、バックアップ)が欠けることなく完全に統合されています。
|
従来の **TkoolLauncher** と **UnityLauncher** の全機能(スクリプト改造、ASAR解凍・復元、PlayerPrefsレジストリ編集、セーブファイル編集、バックアップ)が欠けることなく完全に統合されています。
|
||||||
|
|
||||||
|
> 📌 **AI エージェント / 開発者向け規則**: 本プロジェクトでの変更は必ず [`AGENTS.md`](AGENTS.md) に従ってください(エンジン別構成・ゲーム個別対応の隔離・外部ツールのエンジン別配置など)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📁 フォルダ構成(エンジン別アーキテクチャ)
|
||||||
|
|
||||||
|
エンジンごとに処理を統一し、ゲーム専用の改造が他ゲームへ影響しないよう、エンジン別フォルダで完全に分離しています。
|
||||||
|
|
||||||
|
```
|
||||||
|
GameLauncher/
|
||||||
|
├── Engines/ … エンジン別の処理(エンジンごとに独立)
|
||||||
|
│ ├── Common/ … 全エンジン共通の基盤
|
||||||
|
│ │ ├── IEngineModule.cs … エンジン共通インターフェース
|
||||||
|
│ │ └── EngineDetectionHelper.cs … エンジン判定・誤検出補正
|
||||||
|
│ ├── Rgss/ … RPGツクールVX/VX Ace (RGSS) / SRPG Studio
|
||||||
|
│ │ ├── RgssModService.cs … スクリプト改造 (Scripts.rvdata2)
|
||||||
|
│ │ ├── SrpgModService.cs … SRPG Studio 改造
|
||||||
|
│ │ ├── SrpgArchiveService.cs … data.dts 解凍・再構築
|
||||||
|
│ │ ├── Games/ … ゲーム個別対応
|
||||||
|
│ │ │ └── IiniTitleRepair/ … Game.ini タイトル文字化け修復
|
||||||
|
│ │ └── Tools/ … エンジン専用ツール
|
||||||
|
│ │ └── SRPG_Unpacker.exe
|
||||||
|
│ ├── Tkool/ … RPGツクールMV/MZ (NW.js)
|
||||||
|
│ │ ├── TkoolModService.cs
|
||||||
|
│ │ ├── TkoolInjectionService.cs
|
||||||
|
│ │ ├── TkoolPackagedExtractionService.cs
|
||||||
|
│ │ ├── TkoolGameItem.cs
|
||||||
|
│ │ ├── Games/ … ゲーム個別対応
|
||||||
|
│ │ └── Tools/ … エンジン専用ツール
|
||||||
|
│ ├── Tyrano/ … ティラノスクリプト
|
||||||
|
│ │ ├── TyranoModService.cs
|
||||||
|
│ │ ├── Games/
|
||||||
|
│ │ └── Tools/
|
||||||
|
│ ├── Wolf/ … WOLF RPGエディター(ウディタ)
|
||||||
|
│ │ ├── WolfModService.cs
|
||||||
|
│ │ ├── WolfArchiveService.cs
|
||||||
|
│ │ ├── WolfSaveService.cs
|
||||||
|
│ │ ├── Games/
|
||||||
|
│ │ └── Tools/
|
||||||
|
│ │ └── UberWolfCli.exe
|
||||||
|
│ ├── Unity/ … Unity (IL2CPP / Mono)
|
||||||
|
│ │ ├── UnitySaveManagerService.cs
|
||||||
|
│ │ ├── UnityGameItem.cs / UnitySaveItem.cs / UnityEnums.cs
|
||||||
|
│ │ ├── Games/
|
||||||
|
│ │ └── Tools/
|
||||||
|
│ └── Nwjs/ … 汎用 NW.js パッケージ / ASAR
|
||||||
|
│ ├── NwjsPackageUnpacker.cs
|
||||||
|
│ ├── NwjsUnpackerToolProvider.cs
|
||||||
|
│ ├── AsarArchiveService.cs
|
||||||
|
│ ├── Games/
|
||||||
|
│ └── Tools/
|
||||||
|
│ └── speedhack-i686/ … 倍速プロキシDLL(version.dll)
|
||||||
|
├── Services/ … エンジン非依存の共通サービス
|
||||||
|
│ ├── GameScannerService.cs … ゲーム検出・キャッシュ
|
||||||
|
│ ├── SaveDataCodecManager.cs … セーブコーデック統括
|
||||||
|
│ ├── WindowResizeService.cs
|
||||||
|
│ └── Codecs/ … EasySave3 / YU-RIS コーデック
|
||||||
|
├── Models/ … エンジン非依存の共通モデル
|
||||||
|
│ ├── GameItemBase.cs
|
||||||
|
│ ├── LauncherConfig.cs
|
||||||
|
│ └── ModPluginDefinition.cs
|
||||||
|
├── Helpers/ … パス解決・コンバータ
|
||||||
|
│ ├── AppPathHelper.cs … 実行時パス・エンジン別ツール解決
|
||||||
|
│ └── Converters.cs
|
||||||
|
├── plugins/ … 改造スクリプト(JS)
|
||||||
|
├── Backups/ … セーブ・アーカイブのバックアップ
|
||||||
|
└── (UI)MainWindow / ConfigDialog / SaveEditorWindow など … WPF画面
|
||||||
|
```
|
||||||
|
|
||||||
|
### 設計原則
|
||||||
|
|
||||||
|
- **エンジンごとに処理を統一**: 各エンジンは `Engines/<Engine>/` 配下にサービス・モデルをまとめる。
|
||||||
|
- **ゲーム個別対応はエンジン配下に隔離**: 特定ゲーム専用の改造は `Engines/<Engine>/Games/<GameName>/` に配置し、共通処理から **明示的に呼び出す**。他ゲームへ影響しないことを保証する。
|
||||||
|
- **外部ツールもエンジン別**: 外部ツール・外部ファイルは `Engines/<Engine>/Tools/` に配置し、`AppPathHelper.ResolveEngineTool(engine, fileName)` で解決する。エンジン間でツールを共有しない。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🌟 主な機能一覧
|
## 🌟 主な機能一覧
|
||||||
@@ -52,6 +127,23 @@ RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🧩 新しいエンジンを追加する手順
|
||||||
|
|
||||||
|
1. `Engines/<NewEngine>/` フォルダを作成する。
|
||||||
|
2. `IEngineModule`(`Engines/Common/IEngineModule.cs`)を実装したサービスを作成する。
|
||||||
|
3. `EngineDetectionHelper` に判定ロジック・エイリアスを追加し、必要なら `DetectFromDirectory` にディレクトリ特徴を追記する。
|
||||||
|
4. エンジン専用の外部ツールがある場合は `Engines/<NewEngine>/Tools/` に配置し、`AppPathHelper.ResolveEngineTool("<NewEngine>", "<tool>")` で解決する。
|
||||||
|
5. エンジン専用モデルは同フォルダに配置し、名前空間を `GameLauncher.Engines.<NewEngine>` とする。
|
||||||
|
|
||||||
|
## 🎮 ゲーム個別対応を追加する手順
|
||||||
|
|
||||||
|
1. `Engines/<Engine>/Games/<GameName>/` フォルダを作成する。
|
||||||
|
2. 名前空間を `GameLauncher.Engines.<Engine>.Games.<GameName>` とした専用クラスを作成する。
|
||||||
|
3. 共通処理から **明示的に呼び出す**(他ゲームには一切影響させない)。
|
||||||
|
4. 可能な限りバックアップからの復元手段を用意し、後で元に戻せるようにする。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 💻 動作環境 & 技術スタック
|
## 💻 動作環境 & 技術スタック
|
||||||
- **プラットフォーム**: Windows (x64)
|
- **プラットフォーム**: Windows (x64)
|
||||||
- **ターゲットフレームワーク**: .NET 10.0 (`net10.0-windows`)
|
- **ターゲットフレームワーク**: .NET 10.0 (`net10.0-windows`)
|
||||||
@@ -68,9 +160,11 @@ RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製
|
|||||||
- **プロファイル格納先**: `Z:\自作ソフト\GameLauncher\Profiles\`
|
- **プロファイル格納先**: `Z:\自作ソフト\GameLauncher\Profiles\`
|
||||||
- **セーブバックアップ先**: `Z:\自作ソフト\GameLauncher\Backups\`
|
- **セーブバックアップ先**: `Z:\自作ソフト\GameLauncher\Backups\`
|
||||||
- **プラグイン格納先**: `Z:\自作ソフト\GameLauncher\plugins\`
|
- **プラグイン格納先**: `Z:\自作ソフト\GameLauncher\plugins\`
|
||||||
|
- **エンジン別ツール**: `Z:\自作ソフト\GameLauncher\Engines\<Engine>\Tools\`
|
||||||
|
|
||||||
### 発行方法
|
### 発行方法
|
||||||
`publish.bat` または `publish.ps1` を実行することで、自動的に単一ファイルとして `Z:\自作ソフト\GameLauncher\` に出力されます。
|
`publish.ps1` を実行することで、自動的に単一ファイルとして `Z:\自作ソフト\GameLauncher\` に出力されます。
|
||||||
|
(`publish.ps1` は `Engines/<Engine>/Tools/` 配下の外部ツールも併せて配置します)
|
||||||
```powershell
|
```powershell
|
||||||
dotnet publish "c:\VS2026\GameLauncher\GameLauncher.csproj" -c Release -r win-x64 --self-contained false -o "Z:\自作ソフト\GameLauncher"
|
dotnet publish "c:\VS2026\GameLauncher\GameLauncher.csproj" -c Release -r win-x64 --self-contained false -o "Z:\自作ソフト\GameLauncher"
|
||||||
```
|
```
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:GameLauncher"
|
xmlns:local="clr-namespace:GameLauncher"
|
||||||
xmlns:helpers="clr-namespace:GameLauncher.Helpers"
|
xmlns:helpers="clr-namespace:GameLauncher.Helpers"
|
||||||
xmlns:models="clr-namespace:GameLauncher.Models"
|
xmlns:models="clr-namespace:GameLauncher.Models"
|
||||||
|
xmlns:unity="clr-namespace:GameLauncher.Engines.Unity"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Unity セーブエディタ" Height="720" Width="1080"
|
Title="Unity セーブエディタ" Height="720" Width="1080"
|
||||||
MinHeight="550" MinWidth="850"
|
MinHeight="550" MinWidth="850"
|
||||||
@@ -331,7 +332,7 @@
|
|||||||
<ListBox x:Name="lstSaveFiles" Grid.Row="1" Background="#1C1C26" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1"
|
<ListBox x:Name="lstSaveFiles" Grid.Row="1" Background="#1C1C26" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1"
|
||||||
SelectionChanged="lstSaveFiles_SelectionChanged">
|
SelectionChanged="lstSaveFiles_SelectionChanged">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="{x:Type models:SaveFileEntry}">
|
<DataTemplate DataType="{x:Type unity:SaveFileEntry}">
|
||||||
<Border Padding="8,6" CornerRadius="4" BorderBrush="#2D2D3E" BorderThickness="0,0,0,1">
|
<Border Padding="8,6" CornerRadius="4" BorderBrush="#2D2D3E" BorderThickness="0,0,0,1">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ using GameLauncher.Helpers;
|
|||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
using GameLauncher.Services;
|
using GameLauncher.Services;
|
||||||
using GameLauncher.Services.Codecs;
|
using GameLauncher.Services.Codecs;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Engines.Nwjs;
|
||||||
|
using GameLauncher.Engines.Wolf;
|
||||||
|
using GameLauncher.Engines.Rgss;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
namespace GameLauncher
|
namespace GameLauncher
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Text.Encodings.Web;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
|
|||||||
+449
-94
@@ -16,6 +16,12 @@ using System.Windows.Media.Imaging;
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Engines.Rgss;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Tyrano;
|
||||||
|
using GameLauncher.Engines.Wolf;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Engines.Nwjs;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Services
|
||||||
{
|
{
|
||||||
@@ -58,6 +64,15 @@ namespace GameLauncher.Services
|
|||||||
public bool SrpgProxyDll { get; set; }
|
public bool SrpgProxyDll { get; set; }
|
||||||
public double SrpgSpeedMultiplier { get; set; } = 3.0;
|
public double SrpgSpeedMultiplier { get; set; } = 3.0;
|
||||||
|
|
||||||
|
// 単体exe梱包(FOSSIL / boxed)専用
|
||||||
|
public bool IsFossilSingleExe { get; set; }
|
||||||
|
public bool IsBoxedExe { get; set; }
|
||||||
|
public bool IsStandaloneExeExtracted { get; set; }
|
||||||
|
public string? StandaloneExtractedDirPath { get; set; }
|
||||||
|
public string? StandaloneBackupPath { get; set; }
|
||||||
|
public string? BoxedPayloadEntryPath { get; set; }
|
||||||
|
public bool CanExtractViaExternalTool { get; set; }
|
||||||
|
|
||||||
// Unity専用
|
// Unity専用
|
||||||
public string DataDirectoryPath { get; set; } = string.Empty;
|
public string DataDirectoryPath { get; set; } = string.Empty;
|
||||||
public string CompanyName { get; set; } = string.Empty;
|
public string CompanyName { get; set; } = string.Empty;
|
||||||
@@ -166,7 +181,13 @@ namespace GameLauncher.Services
|
|||||||
IsSrpgExtracted = entry.IsSrpgExtracted,
|
IsSrpgExtracted = entry.IsSrpgExtracted,
|
||||||
SrpgArchivePath = entry.SrpgArchivePath,
|
SrpgArchivePath = entry.SrpgArchivePath,
|
||||||
SrpgProxyDll = entry.SrpgProxyDll,
|
SrpgProxyDll = entry.SrpgProxyDll,
|
||||||
SrpgSpeedMultiplier = entry.SrpgSpeedMultiplier > 0 ? entry.SrpgSpeedMultiplier : 3.0
|
SrpgSpeedMultiplier = entry.SrpgSpeedMultiplier > 0 ? entry.SrpgSpeedMultiplier : 3.0,
|
||||||
|
IsFossilSingleExe = entry.IsFossilSingleExe,
|
||||||
|
IsBoxedExe = entry.IsBoxedExe,
|
||||||
|
IsStandaloneExeExtracted = entry.IsStandaloneExeExtracted,
|
||||||
|
StandaloneExtractedDirPath = entry.StandaloneExtractedDirPath,
|
||||||
|
StandaloneBackupPath = entry.StandaloneBackupPath,
|
||||||
|
BoxedPayloadEntryPath = entry.BoxedPayloadEntryPath
|
||||||
};
|
};
|
||||||
if (entry.PluginSettings != null)
|
if (entry.PluginSettings != null)
|
||||||
{
|
{
|
||||||
@@ -264,6 +285,14 @@ namespace GameLauncher.Services
|
|||||||
string? asarExtP = element.TryGetProperty("AsarExtractedDirPath", out var aep) ? aep.GetString() : null;
|
string? asarExtP = element.TryGetProperty("AsarExtractedDirPath", out var aep) ? aep.GetString() : null;
|
||||||
string? relJs = element.TryGetProperty("RelativePluginsJsInAsar", out var rj) ? rj.GetString() : null;
|
string? relJs = element.TryGetProperty("RelativePluginsJsInAsar", out var rj) ? rj.GetString() : null;
|
||||||
|
|
||||||
|
bool isFossilSingleExe = element.TryGetProperty("IsFossilSingleExe", out var ifs) && ifs.GetBoolean();
|
||||||
|
bool isBoxedExe = element.TryGetProperty("IsBoxedExe", out var ibx) && ibx.GetBoolean();
|
||||||
|
bool isStandaloneExeExtracted = element.TryGetProperty("IsStandaloneExeExtracted", out var isx) && isx.GetBoolean();
|
||||||
|
string? standaloneExtDir = element.TryGetProperty("StandaloneExtractedDirPath", out var sed) ? sed.GetString() : null;
|
||||||
|
string? standaloneBackup = element.TryGetProperty("StandaloneBackupPath", out var sbp) ? sbp.GetString() : null;
|
||||||
|
string? boxedEntry = element.TryGetProperty("BoxedPayloadEntryPath", out var bep) ? bep.GetString() : null;
|
||||||
|
bool canExtractViaExternalTool = element.TryGetProperty("CanExtractViaExternalTool", out var cet) && cet.GetBoolean();
|
||||||
|
|
||||||
var item = new TkoolGameItem
|
var item = new TkoolGameItem
|
||||||
{
|
{
|
||||||
Title = title,
|
Title = title,
|
||||||
@@ -281,7 +310,14 @@ namespace GameLauncher.Services
|
|||||||
IsAsarExtracted = isAsarExt,
|
IsAsarExtracted = isAsarExt,
|
||||||
AsarPath = asarP,
|
AsarPath = asarP,
|
||||||
AsarExtractedDirPath = asarExtP,
|
AsarExtractedDirPath = asarExtP,
|
||||||
RelativePluginsJsInAsar = relJs
|
RelativePluginsJsInAsar = relJs,
|
||||||
|
IsFossilSingleExe = isFossilSingleExe,
|
||||||
|
IsBoxedExe = isBoxedExe,
|
||||||
|
IsStandaloneExeExtracted = isStandaloneExeExtracted,
|
||||||
|
StandaloneExtractedDirPath = standaloneExtDir,
|
||||||
|
StandaloneBackupPath = standaloneBackup,
|
||||||
|
BoxedPayloadEntryPath = boxedEntry,
|
||||||
|
CanExtractViaExternalTool = canExtractViaExternalTool
|
||||||
};
|
};
|
||||||
|
|
||||||
// 既存キャッシュの自動修復: ウディタの誤判定を修正
|
// 既存キャッシュの自動修復: ウディタの誤判定を修正
|
||||||
@@ -441,7 +477,14 @@ namespace GameLauncher.Services
|
|||||||
IsSrpgExtracted = tg.IsSrpgExtracted,
|
IsSrpgExtracted = tg.IsSrpgExtracted,
|
||||||
SrpgArchivePath = tg.SrpgArchivePath,
|
SrpgArchivePath = tg.SrpgArchivePath,
|
||||||
SrpgProxyDll = tg.SrpgProxyDll,
|
SrpgProxyDll = tg.SrpgProxyDll,
|
||||||
SrpgSpeedMultiplier = tg.SrpgSpeedMultiplier
|
SrpgSpeedMultiplier = tg.SrpgSpeedMultiplier,
|
||||||
|
IsFossilSingleExe = tg.IsFossilSingleExe,
|
||||||
|
IsBoxedExe = tg.IsBoxedExe,
|
||||||
|
IsStandaloneExeExtracted = tg.IsStandaloneExeExtracted,
|
||||||
|
StandaloneExtractedDirPath = tg.StandaloneExtractedDirPath,
|
||||||
|
StandaloneBackupPath = tg.StandaloneBackupPath,
|
||||||
|
BoxedPayloadEntryPath = tg.BoxedPayloadEntryPath,
|
||||||
|
CanExtractViaExternalTool = tg.CanExtractViaExternalTool
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -858,7 +901,21 @@ namespace GameLauncher.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 通常のティラノスクリプト探索
|
// 2. boxed(nw.js埋め込み: *boxed*.exe + 埋め込みpackage.nw または on-disk www\)のツクール探索
|
||||||
|
var boxedGame = DetectBoxedNwGameInDirectory(dirPath, folderName, folderModified);
|
||||||
|
if (boxedGame != null)
|
||||||
|
{
|
||||||
|
return boxedGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. FOSSIL単体exe同梱のツクールMZ探索 (js/plugins.jsがexe内に埋め込まれている形態)
|
||||||
|
var fossilMzGame = DetectFossilMZGameInDirectory(dirPath, folderName, folderModified);
|
||||||
|
if (fossilMzGame != null)
|
||||||
|
{
|
||||||
|
return fossilMzGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 通常のティラノスクリプト探索
|
||||||
var tyranoIndex = FindTyranoIndexHtml(dirPath);
|
var tyranoIndex = FindTyranoIndexHtml(dirPath);
|
||||||
if (tyranoIndex != null)
|
if (tyranoIndex != null)
|
||||||
{
|
{
|
||||||
@@ -888,7 +945,7 @@ namespace GameLauncher.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. app.asar パッケージであるか判定
|
// 4. app.asar パッケージであるか判定
|
||||||
if (AsarArchiveService.FindAsarPackage(dirPath, out var asarPath, out bool isExtracted, out var extractedDirPath))
|
if (AsarArchiveService.FindAsarPackage(dirPath, out var asarPath, out bool isExtracted, out var extractedDirPath))
|
||||||
{
|
{
|
||||||
var inspect = _asarService.InspectAsar(asarPath!);
|
var inspect = _asarService.InspectAsar(asarPath!);
|
||||||
@@ -933,21 +990,21 @@ namespace GameLauncher.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. WOLF RPGエディター(ウディタ)ゲームの検出
|
// 5. WOLF RPGエディター(ウディタ)ゲームの検出
|
||||||
var wolfGame = DetectWolfGameInDirectory(dirPath, folderName, folderModified);
|
var wolfGame = DetectWolfGameInDirectory(dirPath, folderName, folderModified);
|
||||||
if (wolfGame != null)
|
if (wolfGame != null)
|
||||||
{
|
{
|
||||||
return wolfGame;
|
return wolfGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. SRPG Studio ゲームの検出
|
// 6. SRPG Studio ゲームの検出
|
||||||
var srpgGame = DetectSrpgGameInDirectory(dirPath, folderName, folderModified);
|
var srpgGame = DetectSrpgGameInDirectory(dirPath, folderName, folderModified);
|
||||||
if (srpgGame != null)
|
if (srpgGame != null)
|
||||||
{
|
{
|
||||||
return srpgGame;
|
return srpgGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. ツクールVX / VX Ace (RGSS2 / RGSS3) ゲームの検出
|
// 7. ツクールVX / VX Ace (RGSS2 / RGSS3) ゲームの検出
|
||||||
var rgssGame = DetectRgssGameInDirectory(dirPath, folderName, folderModified);
|
var rgssGame = DetectRgssGameInDirectory(dirPath, folderName, folderModified);
|
||||||
if (rgssGame != null)
|
if (rgssGame != null)
|
||||||
{
|
{
|
||||||
@@ -959,6 +1016,364 @@ namespace GameLauncher.Services
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 単体exe梱包されたツクールMZゲームを判定し、TkoolGameItemを生成します。
|
||||||
|
/// 対象とするexe形態は次の2種で、いずれも js/plugins.js がディスク上に存在しません。
|
||||||
|
/// - FOSSIL形態: エントリHTMLが FOSSILindex.html、本体は Game.exe(data/System.json はディスク上)
|
||||||
|
/// - boxed形態: ゲーム本体を exe に内包(例: Game_boxed.exe)。ディスク上にゲーム実体が無い
|
||||||
|
/// 誤検出を避けるため、以下の条件が全て揃った場合のみ検出します。
|
||||||
|
/// - 候補exe(Game.exe / *boxed*.exe / *.exe)が存在する
|
||||||
|
/// - js/plugins.js および www/js/plugins.js がディスク上に存在しない
|
||||||
|
/// - FOSSILindex.html が存在する、又は data/System.json が存在する、又は boxed 命名のexeである
|
||||||
|
/// 本形態はゲーム本体をexeへ埋め込むため、他のツクールゲームには一切影響しません。
|
||||||
|
/// </summary>
|
||||||
|
public TkoolGameItem? DetectFossilMZGameInDirectory(string dirPath, string folderName, DateTime? folderModified)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 0. ディスク上に plugins.js が存在する場合は通常のMV/MZ検出に任せる
|
||||||
|
if (File.Exists(Path.Combine(dirPath, "js", "plugins.js")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "www", "js", "plugins.js")))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 候補exeの解決(Game.exe を最優先、次に *boxed*.exe、最後に任意のexe)
|
||||||
|
var exePath = ResolveStandaloneEntryExecutable(dirPath);
|
||||||
|
if (exePath == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 判定マーカーの確認
|
||||||
|
bool hasFossilHtml = File.Exists(Path.Combine(dirPath, "FOSSILindex.html"));
|
||||||
|
var systemJson = Path.Combine(dirPath, "data", "System.json");
|
||||||
|
bool hasSystemJson = File.Exists(systemJson);
|
||||||
|
bool isBoxedExe = Path.GetFileName(exePath).IndexOf("boxed", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||||
|
|
||||||
|
if (!hasFossilHtml && !hasSystemJson && !isBoxedExe)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var icon = LoadIcon(exePath, dirPath);
|
||||||
|
string? title = null;
|
||||||
|
string? pluginsJsInContainer = null;
|
||||||
|
string? embeddedPluginsPath = null;
|
||||||
|
|
||||||
|
// 3. boxed 命名exeは内包コンテナ(package.nw)からplugins.js位置を推定
|
||||||
|
if (isBoxedExe)
|
||||||
|
{
|
||||||
|
TryProbeBoxedEmbeddedPayload(exePath, out pluginsJsInContainer, out embeddedPluginsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. タイトル解決: data/System.json の gameTitle を優先、無ければフォルダ名
|
||||||
|
if (hasSystemJson)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(systemJson);
|
||||||
|
var match = Regex.Match(json, @"""gameTitle""\s*:\s*""([^""]*)\""");
|
||||||
|
if (match.Success && !string.IsNullOrWhiteSpace(match.Groups[1].Value))
|
||||||
|
{
|
||||||
|
title = Regex.Unescape(match.Groups[1].Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. boxed命名exeで data/System.json がディスク上に無い場合は内包コンテナを注入対象とする
|
||||||
|
bool isBoxed = isBoxedExe && !hasSystemJson;
|
||||||
|
|
||||||
|
return new TkoolGameItem
|
||||||
|
{
|
||||||
|
Title = string.IsNullOrWhiteSpace(title) ? folderName : title!,
|
||||||
|
FolderName = folderName,
|
||||||
|
RootDirectory = dirPath,
|
||||||
|
ExecutablePath = exePath,
|
||||||
|
PluginsJsPath = embeddedPluginsPath ?? string.Empty,
|
||||||
|
PluginsDirPath = string.Empty,
|
||||||
|
EngineType = TkoolEngineType.MZ,
|
||||||
|
IsModded = false,
|
||||||
|
// ディスク上にJS実体が無い単体exe形態は、そのままではプラグイン注入できないため初期は改造OFF
|
||||||
|
ApplyMod = false,
|
||||||
|
IconImage = icon,
|
||||||
|
FolderLastModified = folderModified,
|
||||||
|
IsAsar = false,
|
||||||
|
// 形態フラグ(他ゲームへ影響しないための識別子)
|
||||||
|
IsFossilSingleExe = hasFossilHtml || !isBoxed,
|
||||||
|
IsBoxedExe = isBoxed,
|
||||||
|
BoxedPayloadEntryPath = pluginsJsInContainer
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 単体exe形態の候補となる実行ファイルを解決します。
|
||||||
|
/// 優先順: Game.exe → *boxed*.exe → それ以外の *.exe(unins* を除く)。
|
||||||
|
/// </summary>
|
||||||
|
private static string? ResolveStandaloneEntryExecutable(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var gameExe = Path.Combine(dirPath, "Game.exe");
|
||||||
|
if (File.Exists(gameExe))
|
||||||
|
{
|
||||||
|
return gameExe;
|
||||||
|
}
|
||||||
|
|
||||||
|
var exes = Directory.GetFiles(dirPath, "*.exe", SearchOption.TopDirectoryOnly);
|
||||||
|
if (exes.Length == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// *boxed*.exe を優先
|
||||||
|
foreach (var exe in exes)
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(exe);
|
||||||
|
if (name.IndexOf("boxed", StringComparison.OrdinalIgnoreCase) >= 0)
|
||||||
|
{
|
||||||
|
return exe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// unins* を除外した最初のexe
|
||||||
|
foreach (var exe in exes)
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(exe);
|
||||||
|
if (name.StartsWith("unins", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return exe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// boxed命名exeの内包コンテナ(package.nw相当)を限定部分読みで探索し、
|
||||||
|
/// タイトル情報(package.json)と js/plugins.js 相当のエントリ有無を推定します。
|
||||||
|
/// 全走査は行いません(1.14GB級exeを対象に含むため)。
|
||||||
|
/// </summary>
|
||||||
|
private static void TryProbeBoxedEmbeddedPayload(string exePath, out string? packageJsonEntryName, out string? embeddedPluginsJsPath)
|
||||||
|
{
|
||||||
|
packageJsonEntryName = null;
|
||||||
|
embeddedPluginsJsPath = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const int windowSize = 4 * 1024 * 1024; // 4MB限定ウィンドウ
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long size = fs.Length;
|
||||||
|
|
||||||
|
// package.nw マーカーは exe の中間域に置かれることが多いため、中央付近から数点だけ走査する
|
||||||
|
long[] probes = new[]
|
||||||
|
{
|
||||||
|
Math.Max(0, size / 2 - windowSize / 2),
|
||||||
|
Math.Max(0, size / 4),
|
||||||
|
Math.Max(0, size * 3 / 4),
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var start in probes)
|
||||||
|
{
|
||||||
|
int readLen = (int)Math.Min(windowSize, size - start);
|
||||||
|
if (readLen <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf = new byte[readLen];
|
||||||
|
fs.Seek(start, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, buf.Length);
|
||||||
|
|
||||||
|
// ASCII/UTF8 の "package.json" を探す
|
||||||
|
var text = System.Text.Encoding.ASCII.GetString(buf, 0, read);
|
||||||
|
int idx = text.IndexOf("package.json", StringComparison.Ordinal);
|
||||||
|
if (idx >= 0)
|
||||||
|
{
|
||||||
|
packageJsonEntryName = "package.json";
|
||||||
|
// 同一ウィンドウ内に plugins.js があれば注入対象として記録
|
||||||
|
if (text.IndexOf("plugins.js", StringComparison.Ordinal) >= 0)
|
||||||
|
{
|
||||||
|
embeddedPluginsJsPath = "js/plugins.js";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// nw.js埋め込み(*boxed*.exe + 埋め込みpackage.nw または on-disk www\)のツクールMZゲームを検出します。
|
||||||
|
/// 全走査は行わず、exe内のpackage.nwマーカー周辺の限定読みで埋め込みコンテナ有無を判定します。
|
||||||
|
/// boxed命名exeが存在する場合のみ発火するため、他のツクールゲームには一切影響しません。
|
||||||
|
/// </summary>
|
||||||
|
public TkoolGameItem? DetectBoxedNwGameInDirectory(string dirPath, string folderName, DateTime? folderModified)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// (a) ディスク上の www\js\plugins.js を優先(通常検出で拾えない露出パターンを補完)
|
||||||
|
var onDiskPlugins = FindPluginsJsUnderWww(dirPath);
|
||||||
|
|
||||||
|
// (b) *boxed*.exe の存在確認(Game.exe固定を一般化)
|
||||||
|
var boxedExe = Directory.EnumerateFiles(dirPath, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
|
.FirstOrDefault(f => Path.GetFileName(f).Contains("boxed", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
// boxed命名exeが無ければここでは扱わない(厳密に追加的)
|
||||||
|
if (boxedExe == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (c) 埋め込みpackage.nwマーカーの有無(限定部分読み)
|
||||||
|
bool hasEmbeddedPkg = ContainsPackageNwMarker(boxedExe);
|
||||||
|
|
||||||
|
// (d) boxed命名exeが存在すれば、マーカー未確定でも外部アンパッカーでの展開を試行できるため一覧に表示する。
|
||||||
|
// (マーカーは中盤の限られた窓でしか確認しないため、非標準コンテナでは拾えない場合がある)
|
||||||
|
// 展開可否は実行時(ExtractPackageNw)に確定し、不可なら「起動のみ」にフォールバックする。
|
||||||
|
bool canTryExternalTool = true;
|
||||||
|
if (!hasEmbeddedPkg && onDiskPlugins == null && !canTryExternalTool)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataDir = Path.Combine(dirPath, "data");
|
||||||
|
var engine = DetectEngineTypeByDataJson(dirPath);
|
||||||
|
var title = ExtractTkoolTitle(dirPath, dataDir);
|
||||||
|
var icon = LoadIcon(boxedExe, dirPath);
|
||||||
|
|
||||||
|
return new TkoolGameItem
|
||||||
|
{
|
||||||
|
Title = string.IsNullOrWhiteSpace(title) ? folderName : title,
|
||||||
|
FolderName = folderName,
|
||||||
|
RootDirectory = dirPath,
|
||||||
|
ExecutablePath = boxedExe,
|
||||||
|
PluginsJsPath = onDiskPlugins ?? string.Empty,
|
||||||
|
PluginsDirPath = onDiskPlugins != null ? Path.Combine(Path.GetDirectoryName(onDiskPlugins)!, "plugins") : string.Empty,
|
||||||
|
EngineType = engine,
|
||||||
|
IsModded = false,
|
||||||
|
// on-disk露出時のみその場で注入可。埋め込みのみの場合はAI展開後に注入可となる
|
||||||
|
ApplyMod = onDiskPlugins != null,
|
||||||
|
IconImage = icon,
|
||||||
|
FolderLastModified = folderModified,
|
||||||
|
IsAsar = false,
|
||||||
|
IsFossilSingleExe = false,
|
||||||
|
IsBoxedExe = true,
|
||||||
|
BoxedPayloadEntryPath = hasEmbeddedPkg ? "js/plugins.js" : null,
|
||||||
|
// boxed命名exeが存在するため、外部アンパッカーでの展開を試行できる可能性がある
|
||||||
|
CanExtractViaExternalTool = canTryExternalTool
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ディスク上に露出した www\js\plugins.js(または www\www\js\plugins.js)を探索します。
|
||||||
|
/// 通常の FindPluginsJs は深さ2で js\・www\js\ を見ますが、boxed形態の
|
||||||
|
/// www 直下露出を取りこぼさないための補完です。
|
||||||
|
/// </summary>
|
||||||
|
private static string? FindPluginsJsUnderWww(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var candidates = new[]
|
||||||
|
{
|
||||||
|
Path.Combine(dirPath, "www", "js", "plugins.js"),
|
||||||
|
Path.Combine(dirPath, "www", "www", "js", "plugins.js"),
|
||||||
|
};
|
||||||
|
foreach (var c in candidates)
|
||||||
|
{
|
||||||
|
if (File.Exists(c))
|
||||||
|
{
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exe内に nw.js の埋め込みコンテナ(package.nw)マーカーが存在するかを
|
||||||
|
/// 限定部分読み(4MB窓×数点)で判定します。全走査は行いません(1.14GB級exe対策)。
|
||||||
|
/// </summary>
|
||||||
|
private static bool ContainsPackageNwMarker(string exePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const int windowSize = 4 * 1024 * 1024;
|
||||||
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
long size = fs.Length;
|
||||||
|
if (size < 1024)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double[] fractions = { 0.25, 0.5, 0.75, 0.9 };
|
||||||
|
foreach (var frac in fractions)
|
||||||
|
{
|
||||||
|
long start = (long)(size * frac);
|
||||||
|
int readLen = (int)Math.Min(windowSize, size - start);
|
||||||
|
if (readLen <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf = new byte[readLen];
|
||||||
|
fs.Seek(start, SeekOrigin.Begin);
|
||||||
|
int read = fs.Read(buf, 0, buf.Length);
|
||||||
|
var text = System.Text.Encoding.ASCII.GetString(buf, 0, read);
|
||||||
|
|
||||||
|
if (text.IndexOf("package.nw", StringComparison.Ordinal) >= 0 ||
|
||||||
|
text.IndexOf("package.json", StringComparison.Ordinal) >= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// data\System.json の有無と内容からエンジン種別(MZ/MV)を判定します。
|
||||||
|
/// jsディレクトリが無い単体exe梱包形態でも動作します。
|
||||||
|
/// </summary>
|
||||||
|
private static TkoolEngineType DetectEngineTypeByDataJson(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var systemJson = Path.Combine(dirPath, "data", "System.json");
|
||||||
|
if (File.Exists(systemJson))
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(systemJson);
|
||||||
|
// MZ固有のキー(例: "hasEncryptedImages" は両者にあるが、"optDisplayTp"等はMZのみ)
|
||||||
|
if (json.Contains("\"optDisplayTp\"") ||
|
||||||
|
json.Contains("\"optExtraExp\"") ||
|
||||||
|
json.Contains("\"optAntiLag\""))
|
||||||
|
{
|
||||||
|
return TkoolEngineType.MZ;
|
||||||
|
}
|
||||||
|
return TkoolEngineType.MZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return TkoolEngineType.MZ;
|
||||||
|
}
|
||||||
|
|
||||||
#region WOLF RPGエディター(ウディタ)検出ロジック
|
#region WOLF RPGエディター(ウディタ)検出ロジック
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1346,99 +1761,17 @@ namespace GameLauncher.Services
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// BOMの有無やShift_JIS (CP932) を自動判定して安全にINIファイルを行単位で読み込みます。
|
/// BOMの有無やShift_JIS (CP932) を自動判定して安全にINIファイルを行単位で読み込みます。
|
||||||
|
/// 実装は Engines/Rgss/Games/IiniTitleRepair に分離済み(RGSS個別対応)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string[] ReadIniLinesSafe(string filePath)
|
public static string[] ReadIniLinesSafe(string filePath)
|
||||||
{
|
=> GameLauncher.Engines.Rgss.Games.IiniTitleRepair.GameIniTitleRepair.ReadIniLinesSafe(filePath);
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!File.Exists(filePath)) return Array.Empty<string>();
|
|
||||||
|
|
||||||
byte[] bytes = File.ReadAllBytes(filePath);
|
|
||||||
if (bytes.Length == 0) return Array.Empty<string>();
|
|
||||||
|
|
||||||
// 1. UTF-8 BOM (EF BB BF)
|
|
||||||
if (bytes.Length >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
|
|
||||||
{
|
|
||||||
var text = System.Text.Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3);
|
|
||||||
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. UTF-16 LE BOM (FF FE)
|
|
||||||
if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE)
|
|
||||||
{
|
|
||||||
var text = System.Text.Encoding.Unicode.GetString(bytes, 2, bytes.Length - 2);
|
|
||||||
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Shift_JIS (CP932) でデコード(ツクールVX/VX Aceおよびウディタの標準)
|
|
||||||
System.Text.Encoding encoding;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
encoding = System.Text.Encoding.GetEncoding(932);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
encoding = System.Text.Encoding.GetEncoding("shift_jis");
|
|
||||||
}
|
|
||||||
|
|
||||||
var decoded = encoding.GetString(bytes);
|
|
||||||
return decoded.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return Array.Empty<string>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// キャッシュ内に文字化けして保存されたRGSSタイトルの修復を行います。
|
/// キャッシュ内に文字化けして保存されたRGSSタイトルの修復を行います。
|
||||||
|
/// 実装は Engines/Rgss/Games/IiniTitleRepair に分離済み(RGSS個別対応)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void FixRgssTitleFromIni(TkoolGameItem tg)
|
public static void FixRgssTitleFromIni(TkoolGameItem tg)
|
||||||
{
|
=> GameLauncher.Engines.Rgss.Games.IiniTitleRepair.GameIniTitleRepair.Fix(tg);
|
||||||
try
|
|
||||||
{
|
|
||||||
string? iniPath = null;
|
|
||||||
var directIni = Path.Combine(tg.RootDirectory, "Game.ini");
|
|
||||||
if (File.Exists(directIni))
|
|
||||||
{
|
|
||||||
iniPath = directIni;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Directory.Exists(tg.RootDirectory))
|
|
||||||
{
|
|
||||||
foreach (var sub in Directory.GetDirectories(tg.RootDirectory))
|
|
||||||
{
|
|
||||||
var subIni = Path.Combine(sub, "Game.ini");
|
|
||||||
if (File.Exists(subIni))
|
|
||||||
{
|
|
||||||
iniPath = subIni;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iniPath != null)
|
|
||||||
{
|
|
||||||
var lines = ReadIniLinesSafe(iniPath);
|
|
||||||
foreach (var line in lines)
|
|
||||||
{
|
|
||||||
var trim = line.Trim();
|
|
||||||
if (trim.StartsWith("Title=", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
var val = trim.Substring(6).Trim();
|
|
||||||
if (!string.IsNullOrWhiteSpace(val) && !val.Contains('\uFFFD'))
|
|
||||||
{
|
|
||||||
tg.Title = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1709,6 +2042,13 @@ namespace GameLauncher.Services
|
|||||||
return directIndex;
|
return directIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FOSSILで梱包されたティラノスクリプトは index.html が FOSSILindex.html にリネームされる
|
||||||
|
var directFossilIndex = Path.Combine(dirPath, "FOSSILindex.html");
|
||||||
|
if (File.Exists(directFossilIndex) && CheckIsTyranoDirectory(dirPath))
|
||||||
|
{
|
||||||
|
return directFossilIndex;
|
||||||
|
}
|
||||||
|
|
||||||
var subDirs = Directory.GetDirectories(dirPath);
|
var subDirs = Directory.GetDirectories(dirPath);
|
||||||
foreach (var sub in subDirs)
|
foreach (var sub in subDirs)
|
||||||
{
|
{
|
||||||
@@ -1723,6 +2063,12 @@ namespace GameLauncher.Services
|
|||||||
{
|
{
|
||||||
return subIndex;
|
return subIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var subFossilIndex = Path.Combine(sub, "FOSSILindex.html");
|
||||||
|
if (File.Exists(subFossilIndex) && CheckIsTyranoDirectory(sub))
|
||||||
|
{
|
||||||
|
return subFossilIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@@ -1744,6 +2090,15 @@ namespace GameLauncher.Services
|
|||||||
if (html.Contains("tyrano", StringComparison.OrdinalIgnoreCase))
|
if (html.Contains("tyrano", StringComparison.OrdinalIgnoreCase))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FOSSIL梱包のティラノスクリプト用エントリ
|
||||||
|
var fossilIndexPath = Path.Combine(dir, "FOSSILindex.html");
|
||||||
|
if (File.Exists(fossilIndexPath))
|
||||||
|
{
|
||||||
|
var html = File.ReadAllText(fossilIndexPath);
|
||||||
|
if (html.Contains("tyrano", StringComparison.OrdinalIgnoreCase))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
using GameLauncher.Services.Codecs;
|
using GameLauncher.Services.Codecs;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Engines.Wolf;
|
||||||
|
|
||||||
namespace GameLauncher.Services
|
namespace GameLauncher.Services
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ツクールVX / VX Ace のゲームウィンドウを、ディスプレイに収まる最大の整数倍へ拡大する外部連携サービス。
|
||||||
|
/// ゲーム側は無改造のまま、ランチャーがゲームウィンドウを検出して Win32 API で拡大します。
|
||||||
|
/// 外部ツールパスが設定されている場合はそちらを優先起動します。
|
||||||
|
/// </summary>
|
||||||
|
public class WindowResizeService
|
||||||
|
{
|
||||||
|
#region Win32 API
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern int GetSystemMetrics(int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern int GetWindowTextLength(IntPtr hWnd);
|
||||||
|
|
||||||
|
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||||
|
|
||||||
|
private const int SM_CXSCREEN = 0;
|
||||||
|
private const int SM_CYSCREEN = 1;
|
||||||
|
|
||||||
|
private const uint SWP_NOZORDER = 0x0004;
|
||||||
|
private const uint SWP_NOACTIVATE = 0x0010;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ゲーム起動後にウィンドウ拡大を適用します。
|
||||||
|
/// 外部ツールパスが設定されていればそれを起動し、無ければ内蔵の Win32 API 方式で拡大します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="process">起動済みのゲームプロセス</param>
|
||||||
|
/// <param name="externalToolPath">外部ツール(Sizer等)の実行ファイルパス。空なら内蔵方式。</param>
|
||||||
|
/// <returns>(成功可否, ログ用メッセージ)</returns>
|
||||||
|
public async Task<(bool Success, string Message)> ApplyResizeAsync(Process process, string? externalToolPath)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(externalToolPath) && File.Exists(externalToolPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = externalToolPath,
|
||||||
|
UseShellExecute = true
|
||||||
|
});
|
||||||
|
return (true, $"外部ツールを起動しました: {Path.GetFileName(externalToolPath)}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 外部ツール起動失敗時は内蔵方式にフォールバック
|
||||||
|
var (ok, msg) = await ApplyBuiltInResizeAsync(process);
|
||||||
|
return (ok, $"外部ツール起動に失敗したため内蔵方式を使用: {ex.Message} / {msg}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return await ApplyBuiltInResizeAsync(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内蔵の Win32 API 方式でゲームウィンドウを整数倍に拡大します。
|
||||||
|
/// </summary>
|
||||||
|
public async Task<(bool Success, string Message)> ApplyBuiltInResizeAsync(Process process)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IntPtr hWnd = IntPtr.Zero;
|
||||||
|
|
||||||
|
// ウィンドウが生成されるまで最大約5秒待機
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
process.Refresh();
|
||||||
|
if (process.HasExited)
|
||||||
|
{
|
||||||
|
return (false, "ゲームプロセスが終了しました。");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.MainWindowHandle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
hWnd = process.MainWindowHandle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// メインウィンドウが未確定な場合、可視ウィンドウをプロセスIDで探索
|
||||||
|
hWnd = FindWindowByProcessId((uint)process.Id);
|
||||||
|
if (hWnd != IntPtr.Zero) break;
|
||||||
|
|
||||||
|
await Task.Delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hWnd == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return (false, "ゲームウィンドウを検出できませんでした。");
|
||||||
|
}
|
||||||
|
|
||||||
|
int screenW = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
int screenH = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
|
// ゲームの既定ウィンドウサイズ(VX/VX Ace 標準)
|
||||||
|
int baseW = 544;
|
||||||
|
int baseH = 416;
|
||||||
|
|
||||||
|
int scale = Math.Min(screenW / baseW, screenH / baseH);
|
||||||
|
if (scale < 1) scale = 1;
|
||||||
|
|
||||||
|
int newW = baseW * scale;
|
||||||
|
int newH = baseH * scale;
|
||||||
|
|
||||||
|
bool moved = SetWindowPos(hWnd, IntPtr.Zero, 0, 0, newW, newH, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
|
||||||
|
return moved
|
||||||
|
? (true, $"ウィンドウを {newW}x{newH} ({scale}x) に拡大しました。")
|
||||||
|
: (false, "ウィンドウサイズの変更に失敗しました。");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return (false, $"ウィンドウ拡大中にエラーが発生しました: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定プロセスIDに属する可視トップレベルウィンドウを検索します。
|
||||||
|
/// </summary>
|
||||||
|
private static IntPtr FindWindowByProcessId(uint processId)
|
||||||
|
{
|
||||||
|
IntPtr result = IntPtr.Zero;
|
||||||
|
|
||||||
|
EnumWindows((hWnd, lParam) =>
|
||||||
|
{
|
||||||
|
GetWindowThreadProcessId(hWnd, out uint pid);
|
||||||
|
if (pid == processId && IsWindowVisible(hWnd) && GetWindowTextLength(hWnd) > 0)
|
||||||
|
{
|
||||||
|
result = hWnd;
|
||||||
|
return false; // 見つかったので列挙終了
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, IntPtr.Zero);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -9,6 +9,8 @@ using Microsoft.Win32;
|
|||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
using GameLauncher.Services;
|
using GameLauncher.Services;
|
||||||
|
using GameLauncher.Engines.Wolf;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
namespace GameLauncher
|
namespace GameLauncher
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*:
|
||||||
|
* @plugindesc GameLauncher mod (HP once at self turn start / MP always MAX / speed).
|
||||||
|
* @author GameLauncher
|
||||||
|
*
|
||||||
|
* @param EnableHpRecover
|
||||||
|
* @text HP自動回復(自ターン開始時のみ)
|
||||||
|
* @type boolean
|
||||||
|
* @default true
|
||||||
|
*
|
||||||
|
* @param EnableMpRecover
|
||||||
|
* @text MP常時MAX
|
||||||
|
* @type boolean
|
||||||
|
* @default true
|
||||||
|
*
|
||||||
|
* @param SpeedMultiplier
|
||||||
|
* @text 速度倍率
|
||||||
|
* @type number
|
||||||
|
* @decimals 2
|
||||||
|
* @default 3.0
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var pluginName = 'GameLauncher_Mod';
|
||||||
|
var params = PluginManager.parameters(pluginName) || {};
|
||||||
|
|
||||||
|
function toBool(v, def) {
|
||||||
|
if (v === undefined || v === null || v === '') return def;
|
||||||
|
return String(v).toLowerCase() === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
|
var ENABLE_HP = toBool(params['EnableHpRecover'], true);
|
||||||
|
var ENABLE_MP = toBool(params['EnableMpRecover'], true);
|
||||||
|
var SPEED = parseFloat(params['SpeedMultiplier']);
|
||||||
|
if (isNaN(SPEED) || SPEED <= 0) SPEED = 3.0;
|
||||||
|
|
||||||
|
// 自パーティのアクターかどうか(他ゲーム・敵などへ影響しないよう厳密判定)
|
||||||
|
function isPlayerActor(battler) {
|
||||||
|
return battler && typeof battler.isActor === 'function' && battler.isActor();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// HP: 自ターン開始時に1度だけ MAX まで回復する。
|
||||||
|
// 毎フレーム回復はしない(次ターンまでプレイヤーは自由にHPを減らせる)。
|
||||||
|
// =========================================================================
|
||||||
|
if (ENABLE_HP && typeof BattleManager !== 'undefined' && BattleManager.startTurn) {
|
||||||
|
var _GameLauncher_startTurn = BattleManager.startTurn;
|
||||||
|
BattleManager.startTurn = function () {
|
||||||
|
_GameLauncher_startTurn.call(this);
|
||||||
|
var battler = this.actor && this.actor();
|
||||||
|
if (isPlayerActor(battler)) {
|
||||||
|
// この瞬間に一度だけ全回復(以降はダメージで減らせる)
|
||||||
|
battler.setHp(battler.mhp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// MP: 常時 MAX を維持する(自アクターのみ、値が mmp 未満なら即座に戻す)。
|
||||||
|
// =========================================================================
|
||||||
|
if (ENABLE_MP && typeof Game_Battler !== 'undefined' && Game_Battler.prototype) {
|
||||||
|
var _GameLauncher_setMp = Game_Battler.prototype.setMp;
|
||||||
|
Game_Battler.prototype.setMp = function (value) {
|
||||||
|
_GameLauncher_setMp.call(this, value);
|
||||||
|
if (isPlayerActor(this)) {
|
||||||
|
this._mp = this.mmp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var _GameLauncher_refresh = Game_Battler.prototype.refresh;
|
||||||
|
Game_Battler.prototype.refresh = function () {
|
||||||
|
_GameLauncher_refresh.call(this);
|
||||||
|
if (isPlayerActor(this)) {
|
||||||
|
this._mp = this.mmp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 速度倍率: シーン更新のデルタタイムを実質的に乗算する(speedhack)。
|
||||||
|
// =========================================================================
|
||||||
|
if (SPEED !== 1.0 && typeof SceneManager !== 'undefined' && SceneManager.updateMain) {
|
||||||
|
var _GameLauncher_updateMain = SceneManager.updateMain;
|
||||||
|
SceneManager.updateMain = function () {
|
||||||
|
var scene = this._scene;
|
||||||
|
if (scene && scene.isActive && scene.isActive()) {
|
||||||
|
var delta = this._deltaTime || (1000 / 60);
|
||||||
|
if (scene.update) {
|
||||||
|
scene.update(delta * SPEED);
|
||||||
|
}
|
||||||
|
if (scene.isActive && scene.isActive()) {
|
||||||
|
_GameLauncher_updateMain.call(this);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_GameLauncher_updateMain.call(this);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
@echo off
|
|
||||||
chcp 65001 > nul
|
|
||||||
echo === GameLauncher 発行処理を開始します ===
|
|
||||||
powershell -ExecutionPolicy Bypass -File "%~dp0publish.ps1"
|
|
||||||
pause
|
|
||||||
+33
-5
@@ -27,12 +27,40 @@ if ($LASTEXITCODE -eq 0) {
|
|||||||
if (Test-Path "$projectDir\Config.tjs") {
|
if (Test-Path "$projectDir\Config.tjs") {
|
||||||
Copy-Item -Path "$projectDir\Config.tjs" -Destination "$publishDir\Config.tjs" -Force
|
Copy-Item -Path "$projectDir\Config.tjs" -Destination "$publishDir\Config.tjs" -Force
|
||||||
}
|
}
|
||||||
# ウディタおよびSRPG Studio用ツール(UberWolfCli, SRPG_Unpacker, speedhack-i686プロキシDLL等)の配置
|
# エンジン別の外部ツール(Engines\<Engine>\Tools 配下)を配置する。
|
||||||
if (Test-Path "$projectDir\Tools") {
|
# 各エンジンは自身のツールフォルダのみを参照するため、エンジン間で干渉しない。
|
||||||
if (!(Test-Path "$publishDir\Tools")) {
|
$enginesRoot = Join-Path $projectDir "Engines"
|
||||||
New-Item -ItemType Directory -Path "$publishDir\Tools" -Force | Out-Null
|
if (Test-Path $enginesRoot) {
|
||||||
|
foreach ($engineDir in Get-ChildItem -Path $enginesRoot -Directory) {
|
||||||
|
$srcTools = Join-Path $engineDir.FullName "Tools"
|
||||||
|
if (Test-Path $srcTools) {
|
||||||
|
$dstTools = Join-Path (Join-Path $publishDir "Engines") (Join-Path $engineDir.Name "Tools")
|
||||||
|
if (!(Test-Path $dstTools)) {
|
||||||
|
New-Item -ItemType Directory -Path $dstTools -Force | Out-Null
|
||||||
|
}
|
||||||
|
robocopy $srcTools $dstTools /E /NP /R:1 /W:1 | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# nw.js boxed 用の外部アンパッカーを事前配置(未配置なら実行時にも自動取得を試行)
|
||||||
|
# 7zr.exe は依存DLL不要の単体実行版。取得失敗時はスキップし、実行時に NwjsUnpackerToolProvider が再取得を試みる。
|
||||||
|
$nwjsToolsDir = Join-Path (Join-Path $publishDir "Engines") "Nwjs\Tools"
|
||||||
|
$unpackerPresent = $false
|
||||||
|
foreach ($cand in @("$nwjsToolsDir\7zr.exe", "$nwjsToolsDir\7z.exe")) {
|
||||||
|
if (Test-Path $cand) { $unpackerPresent = $true; break }
|
||||||
|
}
|
||||||
|
if (!$unpackerPresent) {
|
||||||
|
if (!(Test-Path $nwjsToolsDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $nwjsToolsDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Write-Host "nw.js boxed 用アンパッカー(7zr.exe)を取得中..." -ForegroundColor Yellow
|
||||||
|
Invoke-WebRequest -Uri "https://www.7-zip.org/a/7zr.exe" -OutFile "$nwjsToolsDir\7zr.exe" -UseBasicParsing -TimeoutSec 120
|
||||||
|
Write-Host "アンパッカーを配置しました: $nwjsToolsDir\7zr.exe" -ForegroundColor Green
|
||||||
|
} catch {
|
||||||
|
Write-Host "アンパッカーの取得に失敗しました(実行時に再取得を試行します): $($_.Exception.Message)" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
robocopy "$projectDir\Tools" "$publishDir\Tools" /E /NP /R:1 /W:1 | Out-Null
|
|
||||||
}
|
}
|
||||||
Write-Host "発行成功: $publishDir\GameLauncher.exe" -ForegroundColor Green
|
Write-Host "発行成功: $publishDir\GameLauncher.exe" -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user