Compare commits
30
Commits
05e7bdb3c0
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93cd4eecd6 | ||
|
|
152abae1f8 | ||
|
|
f50976a6c0 | ||
|
|
b0fdea2411 | ||
|
|
dd00c96e20 | ||
|
|
4c94cf814f | ||
|
|
2c02e10dd1 | ||
|
|
b65122537d | ||
|
|
ee9eeb3118 | ||
|
|
dc03f5284a | ||
|
|
6447fc2635 | ||
|
|
ec4d718311 | ||
|
|
c03cc97af1 | ||
|
|
ae86b53147 | ||
|
|
2fa40c950f | ||
|
|
7ead7386f6 | ||
|
|
ee7b37323c | ||
|
|
922f669191 | ||
|
|
751e382adc | ||
|
|
cfdba6806a | ||
|
|
45bff52198 | ||
|
|
4398f80aa4 | ||
|
|
908dc443eb | ||
|
|
8f67ab1864 | ||
|
|
6f98860892 | ||
|
|
c0989362a9 | ||
|
|
59519208f3 | ||
|
|
90584379b7 | ||
|
|
5433371a77 | ||
|
|
3550e20891 |
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8-bom
|
||||||
|
end_of_line = crlf
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.cs]
|
||||||
|
# this. の明示
|
||||||
|
dotnet_style_qualification_for_field = true:suggestion
|
||||||
|
dotnet_style_qualification_for_property = true:suggestion
|
||||||
|
dotnet_style_qualification_for_method = true:suggestion
|
||||||
|
dotnet_style_qualification_for_event = true:suggestion
|
||||||
|
|
||||||
|
# 改行・波括弧スタイル
|
||||||
|
csharp_new_line_before_open_brace = all
|
||||||
|
csharp_new_line_before_else = true
|
||||||
|
csharp_new_line_before_catch = true
|
||||||
|
csharp_new_line_before_finally = true
|
||||||
|
|
||||||
|
# 空白スタイル
|
||||||
|
csharp_space_after_cast = false
|
||||||
|
csharp_space_after_keywords_in_control_flow_statements = true
|
||||||
|
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
## Visual Studio 2026 / .NET .gitignore
|
## Visual Studio 2026 / .NET .gitignore
|
||||||
[Bb]in/
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
[Ll]og/
|
[Ll]og/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# AGENTS.md — GameLauncher エージェント規則
|
# AGENTS.md — GameLauncher エージェント規則
|
||||||
|
|
||||||
このファイルは **GameLauncher プロジェクトの AI エージェント向け規則** である。
|
このファイルは **GameLauncher プロジェクトの AI エージェント向け規則** である。
|
||||||
本プロジェクトでのすべての変更(コード追加・修正・削除・発行)は、必ず以下の規則に従って実施すること。
|
本プロジェクトでのすべての変更(コード追加・修正・削除・発行)は、必ず以下の規則に従って実施すること。
|
||||||
@@ -50,6 +50,10 @@
|
|||||||
- コードコメントは既存コードに合わせて日本語/英語を適切に使い分ける。
|
- コードコメントは既存コードに合わせて日本語/英語を適切に使い分ける。
|
||||||
- 新規ファイルには冒頭に説明コメントを付ける。
|
- 新規ファイルには冒頭に説明コメントを付ける。
|
||||||
- ファイル名・シンボル参照はバッククォートで囲む。
|
- ファイル名・シンボル参照はバッククォートで囲む。
|
||||||
|
- UI 文字列を追加・変更する場合は、既存の日本語表記に合わせる。
|
||||||
|
|
||||||
|
> 注: ユーザーから見える出力の言語(日本語)については、グローバルのユーザー記憶
|
||||||
|
> (`/memories/preferences.md`)で規定する。重複を避けるため本ファイルでは規定しない。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -60,3 +64,4 @@
|
|||||||
3. ゲーム個別処理は `Engines/<Engine>/Games/<GameName>/` に分離し、他ゲームへ影響しないか。
|
3. ゲーム個別処理は `Engines/<Engine>/Games/<GameName>/` に分離し、他ゲームへ影響しないか。
|
||||||
4. 外部ツールは `Engines/<Engine>/Tools/` にあり、`AppPathHelper` 経由で参照しているか。
|
4. 外部ツールは `Engines/<Engine>/Tools/` にあり、`AppPathHelper` 経由で参照しているか。
|
||||||
5. ビルドが成功し、`publish.ps1` で発行できるか。
|
5. ビルドが成功し、`publish.ps1` で発行できるか。
|
||||||
|
6. ユーザーから見える出力が日本語になっているか(判定基準は `/memories/preferences.md`)。
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="GameLauncher.AddKeyDialog"
|
<Window x:Class="GameLauncher.AddKeyDialog"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
|||||||
+12
-12
@@ -1,4 +1,4 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
using GameLauncher.Engines.Unity;
|
using GameLauncher.Engines.Unity;
|
||||||
@@ -16,37 +16,37 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public AddKeyDialog()
|
public AddKeyDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
txtKeyName.Focus();
|
this.txtKeyName.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOk_Click(object sender, RoutedEventArgs e)
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var keyName = txtKeyName.Text.Trim();
|
var keyName = this.txtKeyName.Text.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(keyName))
|
if (string.IsNullOrWhiteSpace(keyName))
|
||||||
{
|
{
|
||||||
MessageBox.Show("キー名を入力してください。", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show("キー名を入力してください。", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyName = keyName;
|
this.KeyName = keyName;
|
||||||
var selectedTag = (cmbKeyType.SelectedItem as ComboBoxItem)?.Tag?.ToString();
|
var selectedTag = (this.cmbKeyType.SelectedItem as ComboBoxItem)?.Tag?.ToString();
|
||||||
KeyType = selectedTag switch
|
this.KeyType = selectedTag switch
|
||||||
{
|
{
|
||||||
"Float" => PlayerPrefsType.Float,
|
"Float" => PlayerPrefsType.Float,
|
||||||
"String" => PlayerPrefsType.String,
|
"String" => PlayerPrefsType.String,
|
||||||
_ => PlayerPrefsType.Int
|
_ => PlayerPrefsType.Int
|
||||||
};
|
};
|
||||||
KeyValue = txtKeyValue.Text;
|
this.KeyValue = this.txtKeyValue.Text;
|
||||||
|
|
||||||
DialogResult = true;
|
this.DialogResult = true;
|
||||||
Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = false;
|
this.DialogResult = false;
|
||||||
Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Application x:Class="GameLauncher.App"
|
<Application x:Class="GameLauncher.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:GameLauncher"
|
xmlns:local="clr-namespace:GameLauncher"
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using GameLauncher.Helpers;
|
using GameLauncher.Helpers;
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
//ティラノビルダーによる自動ビルド
|
//ティラノビルダーによる自動ビルド
|
||||||
;debugMenu.visible=false
|
;debugMenu.visible=false
|
||||||
;configSave=file
|
;configSave=file
|
||||||
;global.config_version=5.00
|
;global.config_version=5.00
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="GameLauncher.ConfigDialog"
|
<Window x:Class="GameLauncher.ConfigDialog"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="アプリケーション設定"
|
Title="アプリケーション設定"
|
||||||
|
|||||||
+23
-23
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -19,14 +19,14 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public ConfigDialog(LauncherConfig config)
|
public ConfigDialog(LauncherConfig config)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
_config = config;
|
this._config = config;
|
||||||
|
|
||||||
txtRgssExtractorPath.Text = _config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
|
this.txtRgssExtractorPath.Text = this._config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
|
||||||
txtWolfExtractorPath.Text = _config.WolfExtractorPath ?? string.Empty;
|
this.txtWolfExtractorPath.Text = this._config.WolfExtractorPath ?? string.Empty;
|
||||||
txtWindowResizeToolPath.Text = _config.WindowResizeToolPath ?? string.Empty;
|
this.txtWindowResizeToolPath.Text = this._config.WindowResizeToolPath ?? string.Empty;
|
||||||
txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
|
this.txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
|
||||||
chkDefaultApplyMod.IsChecked = _config.DefaultApplyMod;
|
this.chkDefaultApplyMod.IsChecked = this._config.DefaultApplyMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnBrowseExtractor_Click(object sender, RoutedEventArgs e)
|
private void btnBrowseExtractor_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -38,7 +38,7 @@ namespace GameLauncher
|
|||||||
FileName = "RGSS Extractor.exe"
|
FileName = "RGSS Extractor.exe"
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentDir = Path.GetDirectoryName(txtRgssExtractorPath.Text);
|
var currentDir = Path.GetDirectoryName(this.txtRgssExtractorPath.Text);
|
||||||
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
||||||
{
|
{
|
||||||
ofd.InitialDirectory = currentDir;
|
ofd.InitialDirectory = currentDir;
|
||||||
@@ -46,7 +46,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
if (ofd.ShowDialog() == true)
|
if (ofd.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
txtRgssExtractorPath.Text = ofd.FileName;
|
this.txtRgssExtractorPath.Text = ofd.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ namespace GameLauncher
|
|||||||
FileName = "UberWolfCli.exe"
|
FileName = "UberWolfCli.exe"
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentDir = Path.GetDirectoryName(txtWolfExtractorPath.Text);
|
var currentDir = Path.GetDirectoryName(this.txtWolfExtractorPath.Text);
|
||||||
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
||||||
{
|
{
|
||||||
ofd.InitialDirectory = currentDir;
|
ofd.InitialDirectory = currentDir;
|
||||||
@@ -67,7 +67,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
if (ofd.ShowDialog() == true)
|
if (ofd.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
txtWolfExtractorPath.Text = ofd.FileName;
|
this.txtWolfExtractorPath.Text = ofd.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ namespace GameLauncher
|
|||||||
FileName = "Sizer.exe"
|
FileName = "Sizer.exe"
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentDir = Path.GetDirectoryName(txtWindowResizeToolPath.Text);
|
var currentDir = Path.GetDirectoryName(this.txtWindowResizeToolPath.Text);
|
||||||
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
|
||||||
{
|
{
|
||||||
ofd.InitialDirectory = currentDir;
|
ofd.InitialDirectory = currentDir;
|
||||||
@@ -88,7 +88,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
if (ofd.ShowDialog() == true)
|
if (ofd.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
txtWindowResizeToolPath.Text = ofd.FileName;
|
this.txtWindowResizeToolPath.Text = ofd.FileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,19 +111,19 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnSave_Click(object sender, RoutedEventArgs e)
|
private void btnSave_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_config.RgssExtractorPath = txtRgssExtractorPath.Text.Trim();
|
this._config.RgssExtractorPath = this.txtRgssExtractorPath.Text.Trim();
|
||||||
_config.WolfExtractorPath = txtWolfExtractorPath.Text.Trim();
|
this._config.WolfExtractorPath = this.txtWolfExtractorPath.Text.Trim();
|
||||||
_config.WindowResizeToolPath = txtWindowResizeToolPath.Text.Trim();
|
this._config.WindowResizeToolPath = this.txtWindowResizeToolPath.Text.Trim();
|
||||||
_config.DefaultApplyMod = chkDefaultApplyMod.IsChecked == true;
|
this._config.DefaultApplyMod = this.chkDefaultApplyMod.IsChecked == true;
|
||||||
IsSaved = true;
|
this.IsSaved = true;
|
||||||
DialogResult = true;
|
this.DialogResult = true;
|
||||||
Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = false;
|
this.DialogResult = false;
|
||||||
Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
// Engines/Bakin/BakinDetector.cs — RPG Developer Bakin (Smile Game Builder 系 YUKRDATA) ゲーム検出ヘルパー
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Bakin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// RPG Developer Bakin / Smile Game Builder 系ゲームの検出およびメタデータ解決を行うヘルパークラス。
|
||||||
|
/// </summary>
|
||||||
|
public static class BakinDetector
|
||||||
|
{
|
||||||
|
#region □変数(Private)
|
||||||
|
|
||||||
|
private static readonly HashSet<string> ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"bakinplayer.exe",
|
||||||
|
"notification_helper.exe",
|
||||||
|
"crashpad_handler.exe",
|
||||||
|
"elevate.exe",
|
||||||
|
"UnityCrashHandler32.exe",
|
||||||
|
"UnityCrashHandler64.exe"
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたディレクトリが RPG Developer Bakin 製ゲームであるかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">対象ディレクトリパス</param>
|
||||||
|
/// <returns>Bakin ゲームであれば true</returns>
|
||||||
|
public static bool IsBakinGame(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataSubDir = Path.Combine(dirPath, "data");
|
||||||
|
|
||||||
|
// data/ サブフォルダまたはルート直下に Bakin 固有ファイルが存在するか確認
|
||||||
|
if (File.Exists(Path.Combine(dataSubDir, "bakinplayer.exe")) ||
|
||||||
|
File.Exists(Path.Combine(dataSubDir, "bakinengine.dll")) ||
|
||||||
|
File.Exists(Path.Combine(dataSubDir, "data.rbpack")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "bakinplayer.exe")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "bakinengine.dll")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "data.rbpack")))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定ディレクトリ内の RPG Developer Bakin ゲームを検出し、TkoolGameItem を生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ゲームフォルダの絶対パス</param>
|
||||||
|
/// <param name="folderName">フォルダ名</param>
|
||||||
|
/// <param name="folderModified">フォルダ更新日時</param>
|
||||||
|
/// <param name="iconLoader">アイコン読み込み関数</param>
|
||||||
|
/// <returns>検出されたゲームアイテム。該当しない場合は null</returns>
|
||||||
|
public static TkoolGameItem? DetectBakinGame(
|
||||||
|
string dirPath,
|
||||||
|
string folderName,
|
||||||
|
DateTime? folderModified,
|
||||||
|
Func<string?, string?, ImageSource?>? iconLoader)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!BakinDetector.IsBakinGame(dirPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var exePath = BakinDetector.FindBakinExecutable(dirPath, folderName);
|
||||||
|
string title = folderName;
|
||||||
|
if (!string.IsNullOrEmpty(exePath))
|
||||||
|
{
|
||||||
|
var exeName = Path.GetFileNameWithoutExtension(exePath);
|
||||||
|
if (!string.IsNullOrWhiteSpace(exeName) &&
|
||||||
|
!string.Equals(exeName, "bakinplayer", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!string.Equals(exeName, "Game", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
title = folderName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageSource? icon = null;
|
||||||
|
if (iconLoader != null)
|
||||||
|
{
|
||||||
|
icon = iconLoader(exePath, dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasSave = BakinSaveService.HasAnySaveData(dirPath);
|
||||||
|
|
||||||
|
return new TkoolGameItem
|
||||||
|
{
|
||||||
|
Title = title,
|
||||||
|
FolderName = folderName,
|
||||||
|
RootDirectory = dirPath,
|
||||||
|
ExecutablePath = exePath ?? string.Empty,
|
||||||
|
EngineType = TkoolEngineType.Bakin,
|
||||||
|
IsModded = false,
|
||||||
|
ApplyMod = false,
|
||||||
|
HasSaveData = hasSave,
|
||||||
|
IconImage = icon,
|
||||||
|
FolderLastModified = folderModified
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bakin ゲームの起動用実行ファイル(ランチャー .exe または bakinplayer.exe)を検索します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ゲームルートディレクトリ</param>
|
||||||
|
/// <param name="folderName">フォルダ名(省略可)</param>
|
||||||
|
/// <returns>実行ファイルのフルパス。見つからない場合は null</returns>
|
||||||
|
public static string? FindBakinExecutable(string dirPath, string? folderName = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var topExes = Directory.GetFiles(dirPath, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(p => !BakinDetector.IsExcludedLauncherCandidate(p))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (topExes.Count == 1)
|
||||||
|
{
|
||||||
|
return topExes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topExes.Count > 1)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(folderName))
|
||||||
|
{
|
||||||
|
var match = topExes.FirstOrDefault(p =>
|
||||||
|
folderName.Contains(Path.GetFileNameWithoutExtension(p), StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
Path.GetFileNameWithoutExtension(p).Contains(folderName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (match != null)
|
||||||
|
{
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return topExes
|
||||||
|
.OrderByDescending(p =>
|
||||||
|
{
|
||||||
|
try { return new FileInfo(p).Length; } catch { return 0L; }
|
||||||
|
})
|
||||||
|
.First();
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataPlayer = Path.Combine(dirPath, "data", "bakinplayer.exe");
|
||||||
|
if (File.Exists(dataPlayer))
|
||||||
|
{
|
||||||
|
return dataPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootPlayer = Path.Combine(dirPath, "bakinplayer.exe");
|
||||||
|
if (File.Exists(rootPlayer))
|
||||||
|
{
|
||||||
|
return rootPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 無視
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bakin ゲームのセーブデータ格納ディレクトリ (`data/savedata` または `savedata`) を解決します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ゲームルートディレクトリ</param>
|
||||||
|
/// <returns>セーブデータディレクトリのフルパス</returns>
|
||||||
|
public static string ResolveSaveDirectory(string dirPath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dirPath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataSaveDir = Path.Combine(dirPath, "data", "savedata");
|
||||||
|
if (Directory.Exists(dataSaveDir))
|
||||||
|
{
|
||||||
|
return dataSaveDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rootSaveDir = Path.Combine(dirPath, "savedata");
|
||||||
|
if (Directory.Exists(rootSaveDir))
|
||||||
|
{
|
||||||
|
return rootSaveDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(Path.Combine(dirPath, "data")))
|
||||||
|
{
|
||||||
|
return dataSaveDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rootSaveDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
private static bool IsExcludedLauncherCandidate(string exePath)
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(exePath);
|
||||||
|
if (BakinDetector.ExcludedExeNames.Contains(fileName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileName.StartsWith("unins", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Contains("setup", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Contains("config", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Contains("軽量化", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
// Engines/Bakin/BakinEngineModule.cs — RPG Developer Bakin エンジンモジュール実装
|
||||||
|
using GameLauncher.Engines.Common;
|
||||||
|
using GameLauncher.Helpers;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Bakin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// RPG Developer Bakin エンジン用の <see cref="IEngineModule"/> 実装クラス。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class BakinEngineModule : IEngineModule
|
||||||
|
{
|
||||||
|
#region □プロパティ(Public)
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string EngineName => EngineDetectionHelper.EngineBakin;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool Detect(string gameDirectory)
|
||||||
|
{
|
||||||
|
return BakinDetector.IsBakinGame(gameDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool ApplyMod(string gameDirectory, ModPluginDefinition plugin)
|
||||||
|
{
|
||||||
|
// Bakin はセーブデータエディタ方式で改造を行うため、スクリプト注入は不要
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool IsModApplied(string gameDirectory)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public string ResolveToolPath(string toolFileName)
|
||||||
|
{
|
||||||
|
return AppPathHelper.ResolveEngineTool(this.EngineName, toolFileName) ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
<Window x:Class="GameLauncher.Engines.Bakin.BakinSaveEditorDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="🛠 RPG Developer Bakin セーブデータ改造エディタ"
|
||||||
|
Width="1040" Height="740"
|
||||||
|
MinWidth="820" MinHeight="560"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Background="#141720"
|
||||||
|
Foreground="#ECEFF4">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="DarkButtonStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2563EB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3B82F6"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="12,6"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="5"
|
||||||
|
Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Opacity" Value="0.9"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" Value="0.45"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Grid Margin="16">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 1. ヘッダー&セーブファイル選択 -->
|
||||||
|
<Border Grid.Row="0" Background="#1E2332" BorderBrush="#2A3142" BorderThickness="1" CornerRadius="8" Padding="14,10" Margin="0,0,0,10">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,8">
|
||||||
|
<TextBlock Text="🛠 RPG Developer Bakin セーブデータ改造エディタ (YUKRDATA .sgs)" FontSize="16" FontWeight="Bold" Foreground="#FDCB6E" VerticalAlignment="Center"/>
|
||||||
|
<TextBlock x:Name="GameTitleText" Text="" FontSize="13" Foreground="#A5B1C2" VerticalAlignment="Center" Margin="14,0,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="対象セーブ:" VerticalAlignment="Center" Foreground="#ECEFF4" FontWeight="SemiBold" Margin="0,0,10,0"/>
|
||||||
|
<ComboBox x:Name="SaveFileComboBox" Grid.Column="1"
|
||||||
|
DisplayMemberPath="SummaryText"
|
||||||
|
SelectionChanged="SaveFileComboBox_SelectionChanged"
|
||||||
|
Height="30" VerticalContentAlignment="Center"
|
||||||
|
Margin="0,0,8,0"/>
|
||||||
|
<Button Grid.Column="2" Content="🔄 再読込" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="ReloadButton_Click" Margin="0,0,8,0"/>
|
||||||
|
<Button Grid.Column="3" Content="📂 セーブフォルダを開く" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="OpenFolderButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 2. ワンクリック・クイック改造バー -->
|
||||||
|
<Border Grid.Row="1" Background="#1A2436" BorderBrush="#D97706" BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,10">
|
||||||
|
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="⚡ クイック改造:" Foreground="#FBBF24" FontWeight="Bold" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||||
|
<Button Content="💰 所持金 MAX (9,999,999)" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#059669" BorderBrush="#10B981" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxMoney_Click"/>
|
||||||
|
<Button Content="⚡ 行動力 MAX (999)" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#D97706" BorderBrush="#F59E0B" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxActionPoints_Click"/>
|
||||||
|
<Button Content="💪 全員 Lv99 & ステータス MAX" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#7C3AED" BorderBrush="#8B5CF6" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxPartyStats_Click"/>
|
||||||
|
<Button Content="🎒 所持品×99 & 全アイテム/レシピ習得" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#0284C7" BorderBrush="#38BDF8" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxItems_Click"/>
|
||||||
|
<Button Content="🔓 動画・回想解放フラグ 全ON" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#DB2777" BorderBrush="#F472B6" Padding="10,4" Margin="0,2,0,2"
|
||||||
|
Click="QuickUnlockAllGallery_Click"/>
|
||||||
|
</WrapPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 3. 検索・カテゴリ絞り込み・一括変更バー -->
|
||||||
|
<Border Grid.Row="2" Background="#1E2332" BorderBrush="#2A3142" BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,10">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="210"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="100"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="90"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="分類:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<ComboBox x:Name="CategoryFilterComboBox" Grid.Column="1" Height="28" VerticalContentAlignment="Center"
|
||||||
|
SelectionChanged="FilterChanged" Margin="0,0,10,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="2" Text="検索:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="KeywordFilterTextBox" Grid.Column="3" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#ECEFF4" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
ToolTip="項目名・変数名・GUID等で絞り込みます"
|
||||||
|
TextChanged="FilterChanged" Margin="0,0,10,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="現在値一致:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="ExactValueFilterTextBox" Grid.Column="5" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#38BDF8" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
ToolTip="指定した値と完全一致する項目だけをピンポイント抽出します(例: 500)"
|
||||||
|
TextChanged="FilterChanged" Margin="0,0,12,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="6" Text="一括値:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="BulkValueTextBox" Grid.Column="7" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#00E676" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
Text="99" Margin="0,0,6,0"/>
|
||||||
|
<Button Grid.Column="8" Content="表示中へ一括反映" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569" Padding="10,4"
|
||||||
|
Click="ApplyBulkValue_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 4. メイン編集グリッド -->
|
||||||
|
<Border Grid.Row="3" Background="#141720" BorderBrush="#2A3142" BorderThickness="1" CornerRadius="6">
|
||||||
|
<DataGrid x:Name="EntriesDataGrid"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserDeleteRows="False"
|
||||||
|
Background="#141720"
|
||||||
|
RowBackground="#1E2332"
|
||||||
|
AlternatingRowBackground="#191D2A"
|
||||||
|
Foreground="#ECEFF4"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HorizontalGridLinesBrush="#2A3142"
|
||||||
|
BorderBrush="#2A3142"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
SelectionMode="Single"
|
||||||
|
RowHeight="30">
|
||||||
|
<DataGrid.Resources>
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#252B3D"/>
|
||||||
|
<Setter Property="Foreground" Value="#FDCB6E"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="10,6"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#2A3142"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0,0,1,1"/>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.Resources>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="カテゴリ" Binding="{Binding Category}" Width="195" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="項目名 / ステータス・変数・アイテム名" Binding="{Binding DisplayKey}" Width="*" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="型" Binding="{Binding ValueType}" Width="75" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="変更前の値" Binding="{Binding OriginalValueText}" Width="125" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="✏️ 編集後の値 (ダブルクリックで変更)" Binding="{Binding ValueText, UpdateSourceTrigger=PropertyChanged}" Width="210">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#00E5FF"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="6,0"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
<DataGridTextColumn.EditingElementStyle>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#0F172A"/>
|
||||||
|
<Setter Property="Foreground" Value="#00E676"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="4,2"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="内部識別子" Binding="{Binding InternalKey}" Width="170" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 5. フッター&保存・バックアップ復元ボタン -->
|
||||||
|
<Grid Grid.Row="4" Margin="0,12,0,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock x:Name="StatusTextBlock" Grid.Column="0"
|
||||||
|
Text="セーブデータを選択してください。"
|
||||||
|
Foreground="#00E676" VerticalAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
|
||||||
|
|
||||||
|
<Button x:Name="RestoreBackupButton" Grid.Column="1"
|
||||||
|
Content="⏪ バックアップから復元"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#B45309" BorderBrush="#F59E0B"
|
||||||
|
Click="RestoreBackupButton_Click" Margin="10,0,8,0"/>
|
||||||
|
|
||||||
|
<Button x:Name="SaveButton" Grid.Column="2"
|
||||||
|
Content="💾 変更をセーブデータに保存"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#059669" BorderBrush="#10B981"
|
||||||
|
Click="SaveButton_Click" Margin="0,0,8,0"/>
|
||||||
|
|
||||||
|
<Button Grid.Column="3" Content="閉じる"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="CloseButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,510 @@
|
|||||||
|
// Engines/Bakin/BakinSaveEditorDialog.xaml.cs — RPG Developer Bakin セーブデータ改造エディタ ウィンドウ
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Bakin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// RPG Developer Bakin (YUKRDATA .sgs) セーブデータの閲覧・編集・クイックチート・バックアップ復元を行うダイアログウィンドウ。
|
||||||
|
/// </summary>
|
||||||
|
public partial class BakinSaveEditorDialog : Window
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
|
||||||
|
private const string AllCategoriesLabel = "すべて表示";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □変数(Private)
|
||||||
|
|
||||||
|
private readonly TkoolGameItem _game;
|
||||||
|
private List<BakinSaveFileInfo> _saveFiles = new();
|
||||||
|
private BakinSaveDocument? _currentDoc;
|
||||||
|
private ICollectionView? _entriesView;
|
||||||
|
private bool _suppressFilterEvents;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □コンストラクタ
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="BakinSaveEditorDialog"/> の新しいインスタンスを初期化します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">対象の Bakin ゲームアイテム</param>
|
||||||
|
public BakinSaveEditorDialog(TkoolGameItem game)
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
this._game = game ?? throw new ArgumentNullException(nameof(game));
|
||||||
|
this.GameTitleText.Text = $"— {this._game.Title}";
|
||||||
|
this.LoadSaveFileList();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □イベント
|
||||||
|
|
||||||
|
private void SaveFileComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.SaveFileComboBox.SelectedItem is BakinSaveFileInfo selected)
|
||||||
|
{
|
||||||
|
this.LoadSelectedSaveFile(selected.FilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string? currentPath = (this.SaveFileComboBox.SelectedItem as BakinSaveFileInfo)?.FilePath;
|
||||||
|
this.LoadSaveFileList(currentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenFolderButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var saveDir = BakinDetector.ResolveSaveDirectory(this._game.RootDirectory);
|
||||||
|
if (!string.IsNullOrEmpty(saveDir) && Directory.Exists(saveDir))
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo { FileName = saveDir, UseShellExecute = true });
|
||||||
|
}
|
||||||
|
else if (Directory.Exists(this._game.RootDirectory))
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo { FileName = this._game.RootDirectory, UseShellExecute = true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, $"フォルダを開けませんでした:\n{ex.Message}", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxMoney_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int updated = 0;
|
||||||
|
foreach (var entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.InternalKey == "Party.Money")
|
||||||
|
{
|
||||||
|
entry.ValueText = "9999999";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else if (entry.InternalKey == "Party.InventoryMax")
|
||||||
|
{
|
||||||
|
if (int.TryParse(entry.ValueText, out int curMax) && curMax < 999)
|
||||||
|
{
|
||||||
|
entry.ValueText = "999";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = updated > 0
|
||||||
|
? "💰 所持金を 9,999,999 に設定しました。「💾 変更をセーブデータに保存」を押すと確定します。"
|
||||||
|
: "⚠️ このセーブファイルには所持金データが含まれていません(Save_00.sgs 等の通常セーブを選択してください)。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxActionPoints_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int updated = 0;
|
||||||
|
foreach (var entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.Category == BakinSaveService.CategoryVariables &&
|
||||||
|
(entry.DisplayKey.Contains("行動力", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("AP", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("スタミナ", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
entry.ValueText = "999";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = updated > 0
|
||||||
|
? $"⚡ 行動力・最大行動力関連の変数 ({updated} 件) を 999 に設定しました。「💾 変更をセーブデータに保存」を押すと確定します。"
|
||||||
|
: "⚠️ 行動力関連の変数が見つかりませんでした。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxPartyStats_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int updated = 0;
|
||||||
|
foreach (var entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.Category != BakinSaveService.CategoryParty)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.InternalKey.EndsWith(".Level", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
entry.ValueText = "99";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else if (entry.InternalKey.EndsWith(".Exp", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
entry.ValueText = "9999999";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else if (entry.InternalKey.EndsWith(".HP", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".MaxHP", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".MP", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".MaxMP", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
entry.ValueText = "9999";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else if (entry.InternalKey.EndsWith(".Power", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".Vitality", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".Magic", StringComparison.Ordinal) ||
|
||||||
|
entry.InternalKey.EndsWith(".Speed", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
entry.ValueText = "999";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = updated > 0
|
||||||
|
? $"💪 パーティ・控えメンバー全員の Lv99 / HP・MP 9999 / 各能力 999 ({updated} 項目) を設定しました。"
|
||||||
|
: "⚠️ パーティメンバーのステータス項目が見つかりませんでした。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxItems_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int itemUpdated = 0;
|
||||||
|
int flagUpdated = 0;
|
||||||
|
|
||||||
|
foreach (var entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.Category == BakinSaveService.CategoryItems)
|
||||||
|
{
|
||||||
|
entry.ValueText = "99";
|
||||||
|
itemUpdated++;
|
||||||
|
}
|
||||||
|
else if (entry.Category == BakinSaveService.CategoryVariables)
|
||||||
|
{
|
||||||
|
if (entry.InternalKey.Contains("(dbGetAllItems)", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.InternalKey.Contains("(dbLearnAll)", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
entry.ValueText = "1";
|
||||||
|
flagUpdated++;
|
||||||
|
}
|
||||||
|
else if (entry.InternalKey.Contains("(dbGetAllItemsAmount)", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
entry.ValueText = "99";
|
||||||
|
flagUpdated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = $"🎒 所持アイテム ({itemUpdated} 枠) を ×99 に設定し、全アイテム/全レシピ習得変数 ({flagUpdated} 件) を有効化しました。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickUnlockAllGallery_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int updated = 0;
|
||||||
|
foreach (var entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.ValueType != "Double" && entry.ValueType != "Int32")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.Category == BakinSaveService.CategoryCrossSave ||
|
||||||
|
entry.DisplayKey.Contains("動画", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("解放", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("回想", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("ギャラリー", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
entry.DisplayKey.Contains("CG", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
entry.ValueText = "1";
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = updated > 0
|
||||||
|
? $"🔓 動画・回想・クロスセーブ解放フラグ ({updated} 件) をすべて ON(1) に設定しました(Save_xx.sgs にも同時反映されます)。"
|
||||||
|
: "⚠️ 解放フラグ系の変数が見つかりませんでした。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this._suppressFilterEvents || this._entriesView == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._entriesView.Refresh();
|
||||||
|
this.UpdateFilteredCountStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyBulkValue_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._entriesView == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string bulkVal = this.BulkValueTextBox.Text.Trim();
|
||||||
|
if (string.IsNullOrEmpty(bulkVal))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (var obj in this._entriesView)
|
||||||
|
{
|
||||||
|
if (obj is BakinSaveEntry entry)
|
||||||
|
{
|
||||||
|
entry.ValueText = bulkVal;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
this.StatusTextBlock.Text = $"✏️ 現在表示中の {count} 件の項目に「{bulkVal}」を一括設定しました。";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.EntriesDataGrid.CommitEdit(DataGridEditingUnit.Cell, true);
|
||||||
|
this.EntriesDataGrid.CommitEdit(DataGridEditingUnit.Row, true);
|
||||||
|
|
||||||
|
string backupPath = BakinSaveService.SaveSaveData(
|
||||||
|
this._currentDoc,
|
||||||
|
this._game.FolderName,
|
||||||
|
this._game.RootDirectory);
|
||||||
|
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
string fileName = Path.GetFileName(this._currentDoc.FilePath);
|
||||||
|
this.StatusTextBlock.Text = $"✅ 「{fileName}」を保存しました!(バックアップ作成済み: {Path.GetFileName(backupPath)})";
|
||||||
|
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"セーブデータ「{fileName}」への保存が完了しました!\n" +
|
||||||
|
(string.IsNullOrEmpty(this._currentDoc.CompanionCrossSavePath) ? string.Empty : "(※クロスセーブ Save_xx.sgs の変更も同時に保存されました)\n") +
|
||||||
|
$"\n自動バックアップ保存先:\n{backupPath}",
|
||||||
|
"セーブデータ保存完了",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"セーブデータの保存中にエラーが発生しました:\n{ex.Message}",
|
||||||
|
"保存エラー",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreBackupButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string fileName = Path.GetFileName(this._currentDoc.FilePath);
|
||||||
|
var ask = MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"「{fileName}」を最新のバックアップから復元しますか?\n(現在の未保存の編集内容は破棄されます)",
|
||||||
|
"バックアップ復元の確認",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Question);
|
||||||
|
|
||||||
|
if (ask != MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var (success, message) = BakinSaveService.RestoreLatestBackup(
|
||||||
|
this._currentDoc.FilePath,
|
||||||
|
this._game.FolderName,
|
||||||
|
this._game.RootDirectory);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
this.LoadSelectedSaveFile(this._currentDoc.FilePath);
|
||||||
|
this.StatusTextBlock.Text = $"⏪ {message.Replace("\n", " ")}";
|
||||||
|
MessageBox.Show(this, message, "復元完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, message, "復元案内", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
private void LoadSaveFileList(string? preferFilePath = null)
|
||||||
|
{
|
||||||
|
this._saveFiles = BakinSaveService.FindSaveFiles(this._game.RootDirectory);
|
||||||
|
this.SaveFileComboBox.ItemsSource = this._saveFiles;
|
||||||
|
|
||||||
|
if (this._saveFiles.Count == 0)
|
||||||
|
{
|
||||||
|
this._currentDoc = null;
|
||||||
|
this.EntriesDataGrid.ItemsSource = null;
|
||||||
|
this.SaveButton.IsEnabled = false;
|
||||||
|
this.RestoreBackupButton.IsEnabled = false;
|
||||||
|
this.StatusTextBlock.Text = "⚠️ セーブデータ (data/savedata/Save_*.sgs) が見つかりません。一度ゲーム内でセーブを作成してください。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SaveButton.IsEnabled = true;
|
||||||
|
this.RestoreBackupButton.IsEnabled = true;
|
||||||
|
|
||||||
|
BakinSaveFileInfo? target = null;
|
||||||
|
if (!string.IsNullOrEmpty(preferFilePath))
|
||||||
|
{
|
||||||
|
target = this._saveFiles.FirstOrDefault(f => string.Equals(f.FilePath, preferFilePath, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
// デフォルトでは Save_00.sgs 等の通常セーブを優先選択
|
||||||
|
target ??= this._saveFiles.FirstOrDefault(f => !f.IsCrossSave) ?? this._saveFiles[0];
|
||||||
|
this.SaveFileComboBox.SelectedItem = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadSelectedSaveFile(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this._currentDoc = BakinSaveService.LoadSaveData(filePath);
|
||||||
|
|
||||||
|
this._suppressFilterEvents = true;
|
||||||
|
var categories = new List<string> { BakinSaveEditorDialog.AllCategoriesLabel };
|
||||||
|
categories.AddRange(this._currentDoc.Entries.Select(e => e.Category).Distinct());
|
||||||
|
string? prevCat = this.CategoryFilterComboBox.SelectedItem as string;
|
||||||
|
this.CategoryFilterComboBox.ItemsSource = categories;
|
||||||
|
this.CategoryFilterComboBox.SelectedItem = (prevCat != null && categories.Contains(prevCat))
|
||||||
|
? prevCat
|
||||||
|
: BakinSaveEditorDialog.AllCategoriesLabel;
|
||||||
|
this._suppressFilterEvents = false;
|
||||||
|
|
||||||
|
this._entriesView = CollectionViewSource.GetDefaultView(this._currentDoc.Entries);
|
||||||
|
this._entriesView.Filter = this.FilterEntry;
|
||||||
|
this.EntriesDataGrid.ItemsSource = this._entriesView;
|
||||||
|
|
||||||
|
this.UpdateFilteredCountStatus();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.StatusTextBlock.Text = $"❌ 読み込みエラー: {ex.Message}";
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"セーブデータの読み込み中にエラーが発生しました:\n{ex.Message}",
|
||||||
|
"読み込みエラー",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool FilterEntry(object obj)
|
||||||
|
{
|
||||||
|
if (obj is not BakinSaveEntry entry)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. カテゴリフィルタ
|
||||||
|
if (this.CategoryFilterComboBox.SelectedItem is string cat &&
|
||||||
|
!string.Equals(cat, BakinSaveEditorDialog.AllCategoriesLabel, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
if (!string.Equals(entry.Category, cat, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. キーワード検索フィルタ
|
||||||
|
string kw = this.KeywordFilterTextBox.Text.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(kw))
|
||||||
|
{
|
||||||
|
bool matchDisplay = entry.DisplayKey.Contains(kw, StringComparison.OrdinalIgnoreCase);
|
||||||
|
bool matchInternal = entry.InternalKey.Contains(kw, StringComparison.OrdinalIgnoreCase);
|
||||||
|
bool matchCategory = entry.Category.Contains(kw, StringComparison.OrdinalIgnoreCase);
|
||||||
|
bool matchValue = entry.ValueText.Contains(kw, StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (!matchDisplay && !matchInternal && !matchCategory && !matchValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 現在値完全一致フィルタ
|
||||||
|
string exact = this.ExactValueFilterTextBox.Text.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(exact))
|
||||||
|
{
|
||||||
|
if (!string.Equals(entry.ValueText.Trim(), exact, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateFilteredCountStatus()
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null || this._entriesView == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int total = this._currentDoc.Entries.Count;
|
||||||
|
int visible = this._entriesView.Cast<object>().Count();
|
||||||
|
string fileName = Path.GetFileName(this._currentDoc.FilePath);
|
||||||
|
this.StatusTextBlock.Text = $"📂 読込完了: {fileName} — 全 {total} 項目中 {visible} 項目を表示中(ダブルクリックまたはクイック改造ボタンで編集できます)";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace GameLauncher.Engines.Common
|
namespace GameLauncher.Engines.Common
|
||||||
@@ -29,6 +29,9 @@ namespace GameLauncher.Engines.Common
|
|||||||
/// <summary>Canonical engine name for generic NW.js packaged games.</summary>
|
/// <summary>Canonical engine name for generic NW.js packaged games.</summary>
|
||||||
public const string EngineNwjs = "Nwjs";
|
public const string EngineNwjs = "Nwjs";
|
||||||
|
|
||||||
|
/// <summary>Canonical engine name for RPG Developer Bakin games.</summary>
|
||||||
|
public const string EngineBakin = "Bakin";
|
||||||
|
|
||||||
/// <summary>Canonical engine name for Enigma Virtual Box packed applications.</summary>
|
/// <summary>Canonical engine name for Enigma Virtual Box packed applications.</summary>
|
||||||
public const string EngineEvb = "Evb";
|
public const string EngineEvb = "Evb";
|
||||||
|
|
||||||
@@ -80,6 +83,11 @@ namespace GameLauncher.Engines.Common
|
|||||||
return EngineNwjs;
|
return EngineNwjs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Matches(value, "Bakin", "RPGDeveloperBakin", "SmileGameBuilder", "SGB"))
|
||||||
|
{
|
||||||
|
return EngineBakin;
|
||||||
|
}
|
||||||
|
|
||||||
if (Matches(value, "Evb", "Enigma", "EnigmaVB", "EnigmaVirtualBox"))
|
if (Matches(value, "Evb", "Enigma", "EnigmaVB", "EnigmaVirtualBox"))
|
||||||
{
|
{
|
||||||
return EngineEvb;
|
return EngineEvb;
|
||||||
@@ -129,6 +137,12 @@ namespace GameLauncher.Engines.Common
|
|||||||
return EngineEvb;
|
return EngineEvb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RPG Developer Bakin: data/bakinplayer.exe, bakinengine.dll, or data.rbpack.
|
||||||
|
if (Engines.Bakin.BakinDetector.IsBakinGame(gameDirectory))
|
||||||
|
{
|
||||||
|
return EngineBakin;
|
||||||
|
}
|
||||||
|
|
||||||
// RPG Maker MV/MZ: www/ folder or a Game.exe next to nw.js package files.
|
// RPG Maker MV/MZ: www/ folder or a Game.exe next to nw.js package files.
|
||||||
var wwwDir = Path.Combine(gameDirectory, "www");
|
var wwwDir = Path.Combine(gameDirectory, "www");
|
||||||
if (Directory.Exists(wwwDir))
|
if (Directory.Exists(wwwDir))
|
||||||
@@ -136,8 +150,7 @@ namespace GameLauncher.Engines.Common
|
|||||||
return EngineTkool;
|
return EngineTkool;
|
||||||
}
|
}
|
||||||
|
|
||||||
var packageJson = Path.Combine(gameDirectory, "package.json");
|
if (Engines.Nwjs.NwjsDetector.IsNwjsGame(gameDirectory))
|
||||||
if (File.Exists(packageJson) && Directory.Exists(Path.Combine(gameDirectory, "nwjs")))
|
|
||||||
{
|
{
|
||||||
return EngineNwjs;
|
return EngineNwjs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Engines.Common
|
namespace GameLauncher.Engines.Common
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,43 +1,40 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace GameLauncher.Engines.Evb
|
namespace GameLauncher.Engines.Evb
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Detects Enigma Virtual Box (EVB) packed executables using reliable PE signatures
|
/// Detects Enigma Virtual Box (EVB) packed executables that are actually compressed
|
||||||
/// only. Heuristic checks such as file name or extension are intentionally avoided so
|
/// with EVB and unpackable by <c>evbunpack</c>.
|
||||||
/// that ordinary (unpacked) games are never misclassified.
|
|
||||||
///
|
///
|
||||||
/// Detection strategy:
|
/// Detection strategy:
|
||||||
/// 1. Parse the PE header and inspect the section table for the packer's sections
|
/// 1. Parse the PE header and inspect the section table for the packer's
|
||||||
/// (".enigma1" / ".enigma2"). A present section is a decisive match.
|
/// <c>.enigma1</c> section (required by <c>evbunpack</c> to restore the PE).
|
||||||
/// 2. When sections are inconclusive, scan bounded windows of the file for the
|
/// 2. Verify the presence of the EVB virtual filesystem pack header signature
|
||||||
/// "Enigma Virtual Box" marker string embedded by the packer.
|
/// (<c>"EVB\0"</c> / <c>0x45, 0x56, 0x42, 0x00</c>) inside the Enigma section
|
||||||
|
/// data or PE overlay (required by <c>evbunpack</c> to extract the VFS, and
|
||||||
|
/// distinguishes Enigma Virtual Box from commercial Enigma Protector DRM which
|
||||||
|
/// cannot be unpacked).
|
||||||
///
|
///
|
||||||
/// This class is engine-local and has no side effects.
|
/// This class is engine-local and has no side effects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class EvbDetectionHelper
|
public static class EvbDetectionHelper
|
||||||
{
|
{
|
||||||
/// <summary>Marker string embedded by the Enigma Virtual Box packer.</summary>
|
/// <summary>Primary section name required by evbunpack.</summary>
|
||||||
private const string EnigmaMarker = "Enigma Virtual Box";
|
private const string EnigmaPrimarySection = ".enigma1";
|
||||||
|
|
||||||
/// <summary>Section names produced by the packer.</summary>
|
/// <summary>Secondary section name produced by the packer.</summary>
|
||||||
private static readonly string[] EnigmaSections = { ".enigma1", ".enigma2" };
|
private const string EnigmaSecondarySection = ".enigma2";
|
||||||
|
|
||||||
/// <summary>Additional loader identifiers checked during the content scan.</summary>
|
/// <summary>EVB virtual filesystem header magic ("EVB\0").</summary>
|
||||||
private static readonly string[] EvbContentMarkers =
|
private static readonly byte[] EvbMagic = [0x45, 0x56, 0x42, 0x00];
|
||||||
{
|
|
||||||
EnigmaMarker,
|
|
||||||
"evb.dll",
|
|
||||||
"EnigmaVB",
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>Returns true when the given executable is packed with EVB.</summary>
|
/// <summary>Returns true when the given executable is packed with EVB and can be unpacked.</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Step 1 reads the PE section table for the packer's section names.
|
/// Reads the PE section table for <c>.enigma1</c> and verifies the <c>EVB\0</c>
|
||||||
/// Step 2 falls back to a bounded content scan for the packer marker.
|
/// virtual filesystem header. Any IO/format error yields false.
|
||||||
/// Any IO/format error yields false (treated as "not confidently EVB").
|
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static bool IsEvbPacked(string exePath)
|
public static bool IsEvbPacked(string exePath)
|
||||||
{
|
{
|
||||||
@@ -48,24 +45,11 @@ namespace GameLauncher.Engines.Evb
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Step 1: decisive PE section check.
|
return HasExtractableEnigmaPackage(exePath);
|
||||||
if (HasEnigmaSection(exePath))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Fall through to the content scan on any parse failure.
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Step 2: content marker scan over bounded windows.
|
|
||||||
return ContainsEvbContentMarker(exePath);
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
// Unparseable executable -> never claim EVB.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +67,11 @@ namespace GameLauncher.Engines.Evb
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Directory.GetFiles(gameDirectory, "*.exe", SearchOption.TopDirectoryOnly)
|
var exes = Directory.GetFiles(gameDirectory, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
.FirstOrDefault(IsEvbPacked);
|
.Where(f => !IsExcludedUtilityExe(Path.GetFileName(f)))
|
||||||
|
.OrderBy(f => string.Equals(Path.GetFileName(f), "Game.exe", StringComparison.OrdinalIgnoreCase) ? 0 : 1);
|
||||||
|
|
||||||
|
return exes.FirstOrDefault(IsEvbPacked);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -92,10 +79,49 @@ namespace GameLauncher.Engines.Evb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsExcludedUtilityExe(string fileName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(fileName)) return true;
|
||||||
|
return fileName.StartsWith("unins", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.StartsWith("UnityCrashHandler", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("notification_helper.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("crashpad_handler.exe", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses the PE section table and checks for the EVB packer's section names.
|
/// Returns true when the game directory already holds a completed EVB extraction.
|
||||||
|
///
|
||||||
|
/// Once a game is unpacked, the original packed exe is renamed to "*.glbak" and the
|
||||||
|
/// unpacked files (including the real exe) live inside the game-local "_evb_extracted"
|
||||||
|
/// folder. At that point <see cref="FindEvbPackedExecutable"/> can no longer find a
|
||||||
|
/// top-level "*.exe", so this extra signal is required to keep recognizing the folder
|
||||||
|
/// as an EVB game (otherwise launch and icon resolution break after unpacking).
|
||||||
|
///
|
||||||
|
/// Only a completed extraction (completion marker present) is accepted, so a normal
|
||||||
|
/// unpacked game without any EVB artifacts is never misclassified.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool HasEnigmaSection(string exePath)
|
public static bool IsExtracted(string gameDirectory)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(gameDirectory) || !Directory.Exists(gameDirectory))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return EvbUnpackService.IsExtractionComplete(gameDirectory, out _);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the PE section table, verifies the <c>.enigma1</c> section, and checks
|
||||||
|
/// for the <c>EVB\0</c> virtual filesystem header required by <c>evbunpack</c>.
|
||||||
|
/// </summary>
|
||||||
|
private static bool HasExtractableEnigmaPackage(string exePath)
|
||||||
{
|
{
|
||||||
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
using var reader = new BinaryReader(fs);
|
using var reader = new BinaryReader(fs);
|
||||||
@@ -124,22 +150,30 @@ namespace GameLauncher.Engines.Evb
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// COFF header: skip machine + number of sections is at offset 2 from here.
|
// COFF header: number of sections is at offset 6 from PE signature (peOffset + 6).
|
||||||
fs.Seek(peOffset + 4, SeekOrigin.Begin);
|
fs.Seek(peOffset + 6, SeekOrigin.Begin);
|
||||||
ushort sectionCount = reader.ReadUInt16();
|
ushort sectionCount = reader.ReadUInt16();
|
||||||
|
if (sectionCount == 0 || sectionCount > 96)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Optional header size (end of the optional header) is at offset 20 in the COFF header.
|
// Optional header size is at offset 20 in the COFF header.
|
||||||
fs.Seek(peOffset + 20, SeekOrigin.Begin);
|
fs.Seek(peOffset + 20, SeekOrigin.Begin);
|
||||||
ushort optionalHeaderSize = reader.ReadUInt16();
|
ushort optionalHeaderSize = reader.ReadUInt16();
|
||||||
|
|
||||||
// Section table starts right after the optional header.
|
// Section table starts right after the optional header.
|
||||||
long sectionTable = peOffset + 24 + optionalHeaderSize;
|
long sectionTable = peOffset + 24 + optionalHeaderSize;
|
||||||
|
|
||||||
// Each section header is 40 bytes; the section name is the first 8 bytes.
|
bool hasEnigma1 = false;
|
||||||
|
var enigmaRanges = new List<(long Offset, long Size)>();
|
||||||
|
long maxSectionEnd = 0;
|
||||||
|
|
||||||
|
// Each section header is 40 bytes.
|
||||||
for (int i = 0; i < sectionCount; i++)
|
for (int i = 0; i < sectionCount; i++)
|
||||||
{
|
{
|
||||||
long offset = sectionTable + (long)i * 40;
|
long offset = sectionTable + (long)i * 40;
|
||||||
if (offset + 8 > fs.Length)
|
if (offset + 40 > fs.Length)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -148,54 +182,100 @@ namespace GameLauncher.Engines.Evb
|
|||||||
var nameBytes = reader.ReadBytes(8);
|
var nameBytes = reader.ReadBytes(8);
|
||||||
var name = System.Text.Encoding.ASCII.GetString(nameBytes).TrimEnd('\0').Trim();
|
var name = System.Text.Encoding.ASCII.GetString(nameBytes).TrimEnd('\0').Trim();
|
||||||
|
|
||||||
foreach (var section in EnigmaSections)
|
fs.Seek(offset + 16, SeekOrigin.Begin);
|
||||||
|
uint rawSize = reader.ReadUInt32();
|
||||||
|
uint rawPtr = reader.ReadUInt32();
|
||||||
|
|
||||||
|
if (rawPtr > 0 && rawSize > 0)
|
||||||
{
|
{
|
||||||
if (string.Equals(name, section, StringComparison.OrdinalIgnoreCase))
|
long end = (long)rawPtr + rawSize;
|
||||||
|
if (end > maxSectionEnd && end <= fs.Length)
|
||||||
{
|
{
|
||||||
return true;
|
maxSectionEnd = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.Equals(name, EnigmaPrimarySection, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
hasEnigma1 = true;
|
||||||
|
if (rawPtr > 0 && rawSize > 0 && rawPtr < fs.Length)
|
||||||
|
{
|
||||||
|
enigmaRanges.Insert(0, (rawPtr, Math.Min((long)rawSize, fs.Length - rawPtr)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (string.Equals(name, EnigmaSecondarySection, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (rawPtr > 0 && rawSize > 0 && rawPtr < fs.Length)
|
||||||
|
{
|
||||||
|
enigmaRanges.Add((rawPtr, Math.Min((long)rawSize, fs.Length - rawPtr)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// evbunpack requires the .enigma1 section to unpack and rebuild the executable.
|
||||||
|
if (!hasEnigma1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also include PE overlay if any bytes exist after the last section.
|
||||||
|
if (maxSectionEnd > 0 && maxSectionEnd + 64 <= fs.Length)
|
||||||
|
{
|
||||||
|
enigmaRanges.Add((maxSectionEnd, fs.Length - maxSectionEnd));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify that the EVB virtual filesystem signature ("EVB\0") exists in the
|
||||||
|
// Enigma sections or overlay so that Enigma Protector DRM executables (which
|
||||||
|
// have .enigma1/.enigma2 but no unpackable EVB VFS) are not misclassified.
|
||||||
|
foreach (var (rangeOffset, rangeSize) in enigmaRanges)
|
||||||
|
{
|
||||||
|
if (ContainsEvbMagicInRange(fs, rangeOffset, rangeSize))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scans bounded windows of the executable for EVB loader markers.
|
/// Searches for the "EVB\0" pack header signature within the given file range
|
||||||
/// EVB metadata typically sits near the end of the PE (overlay).
|
/// (scanning up to the first 16 MB of the range in 64 KB chunks).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool ContainsEvbContentMarker(string exePath)
|
private static bool ContainsEvbMagicInRange(FileStream fs, long startOffset, long length)
|
||||||
{
|
{
|
||||||
const int windowSize = 2 * 1024 * 1024;
|
const int chunkSize = 64 * 1024;
|
||||||
using var fs = new FileStream(exePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
long maxScan = Math.Min(length, 16L * 1024 * 1024);
|
||||||
long size = fs.Length;
|
if (maxScan < EvbMagic.Length)
|
||||||
if (size < 1024)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double[] fractions = { 0.5, 0.8, 0.9, 0.97 };
|
var buffer = new byte[chunkSize + EvbMagic.Length];
|
||||||
foreach (var frac in fractions)
|
long scanned = 0;
|
||||||
|
|
||||||
|
while (scanned < maxScan)
|
||||||
{
|
{
|
||||||
long start = (long)(size * frac);
|
long readPos = startOffset + scanned;
|
||||||
int readLen = (int)Math.Min(windowSize, size - start);
|
int toRead = (int)Math.Min(buffer.Length, (startOffset + maxScan) - readPos);
|
||||||
if (readLen <= 0)
|
if (toRead < EvbMagic.Length)
|
||||||
{
|
{
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = new byte[readLen];
|
fs.Seek(readPos, SeekOrigin.Begin);
|
||||||
fs.Seek(start, SeekOrigin.Begin);
|
int read = fs.Read(buffer, 0, toRead);
|
||||||
int read = fs.Read(buf, 0, buf.Length);
|
if (read < EvbMagic.Length)
|
||||||
var text = System.Text.Encoding.ASCII.GetString(buf, 0, read);
|
|
||||||
|
|
||||||
foreach (var marker in EvbContentMarkers)
|
|
||||||
{
|
{
|
||||||
if (text.IndexOf(marker, StringComparison.OrdinalIgnoreCase) >= 0)
|
break;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buffer.AsSpan(0, read).IndexOf(EvbMagic) >= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
scanned += chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+14
-14
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using GameLauncher.Engines.Common;
|
using GameLauncher.Engines.Common;
|
||||||
|
|
||||||
@@ -18,9 +18,16 @@ namespace GameLauncher.Engines.Evb
|
|||||||
public static class EvbDetector
|
public static class EvbDetector
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true when the game directory holds an EVB packed executable.
|
/// Returns true when the game directory holds an EVB packed executable
|
||||||
/// A packed project file (<c>*.evb</c>) in the folder is also accepted as a
|
/// that can actually be unpacked (or a completed extraction of one).
|
||||||
/// decisive signal, in addition to the PE-signature check.
|
///
|
||||||
|
/// Accepts only the following decisive signals:
|
||||||
|
/// 1. A top-level executable carrying both a decisive EVB PE section (.enigma1)
|
||||||
|
/// and the EVB virtual filesystem signature ("EVB\0"), so it is unpackable.
|
||||||
|
/// 2. An already-unpacked game (game-local "_evb_extracted" with a completion
|
||||||
|
/// marker). This is required because unpacking renames the original packed exe
|
||||||
|
/// to "*.glbak", after which the signature check alone would no longer detect
|
||||||
|
/// the game and its launch / icon resolution would break.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsEvbGame(string gameDirectory)
|
public static bool IsEvbGame(string gameDirectory)
|
||||||
{
|
{
|
||||||
@@ -29,17 +36,10 @@ namespace GameLauncher.Engines.Evb
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
// A completed extraction keeps the game recognized even without the packed exe.
|
||||||
|
if (EvbDetectionHelper.IsExtracted(gameDirectory))
|
||||||
{
|
{
|
||||||
// A packed project file in the folder is the strongest single signal.
|
return true;
|
||||||
if (Directory.GetFiles(gameDirectory, "*.evb", SearchOption.TopDirectoryOnly).Length > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// Fall through to the executable signature check.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory) != null;
|
return EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory) != null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using GameLauncher.Engines.Common;
|
using GameLauncher.Engines.Common;
|
||||||
using GameLauncher.Models;
|
using GameLauncher.Models;
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ namespace GameLauncher.Engines.Evb
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string ResolveToolPath(string toolFileName)
|
public string ResolveToolPath(string toolFileName)
|
||||||
=> AppPathHelperBridge.Resolve(EngineName, toolFileName);
|
=> AppPathHelperBridge.Resolve(this.EngineName, toolFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -79,7 +79,7 @@ namespace GameLauncher.Engines.Evb
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Preferred names commonly used by NW.js / RPG Maker / Tyrano bundles.
|
// Preferred names commonly used by NW.js / RPG Maker / Tyrano bundles.
|
||||||
string[] preferred = { "Game.exe", "game.exe", "nw.exe", "Game_boxed.exe" };
|
string[] preferred = ["Game.exe", "game.exe", "nw.exe", "Game_boxed.exe"];
|
||||||
foreach (var name in preferred)
|
foreach (var name in preferred)
|
||||||
{
|
{
|
||||||
var direct = Path.Combine(outputDirectory, name);
|
var direct = Path.Combine(outputDirectory, name);
|
||||||
@@ -89,8 +89,10 @@ namespace GameLauncher.Engines.Evb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First exe at the top level, then one level deeper.
|
// First exe at the top level, then one level deeper (excluding helper/installer exes).
|
||||||
var top = Directory.GetFiles(outputDirectory, "*.exe", SearchOption.TopDirectoryOnly);
|
var top = Directory.GetFiles(outputDirectory, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(f => !IsExcludedHelperExe(Path.GetFileName(f)))
|
||||||
|
.ToArray();
|
||||||
if (top.Length > 0)
|
if (top.Length > 0)
|
||||||
{
|
{
|
||||||
return top[0];
|
return top[0];
|
||||||
@@ -98,7 +100,9 @@ namespace GameLauncher.Engines.Evb
|
|||||||
|
|
||||||
foreach (var sub in Directory.GetDirectories(outputDirectory))
|
foreach (var sub in Directory.GetDirectories(outputDirectory))
|
||||||
{
|
{
|
||||||
var nested = Directory.GetFiles(sub, "*.exe", SearchOption.TopDirectoryOnly);
|
var nested = Directory.GetFiles(sub, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(f => !IsExcludedHelperExe(Path.GetFileName(f)))
|
||||||
|
.ToArray();
|
||||||
if (nested.Length > 0)
|
if (nested.Length > 0)
|
||||||
{
|
{
|
||||||
return nested[0];
|
return nested[0];
|
||||||
@@ -113,6 +117,17 @@ namespace GameLauncher.Engines.Evb
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsExcludedHelperExe(string? fileName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(fileName)) return true;
|
||||||
|
return fileName.StartsWith("unins", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.StartsWith("UnityCrashHandler", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("notification_helper.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("crashpad_handler.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("elevate.exe", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
fileName.Equals("nacl64.exe", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True when the game folder already holds a completed EVB extraction.
|
/// True when the game folder already holds a completed EVB extraction.
|
||||||
/// A non-empty output folder is NOT enough: the run may have been interrupted,
|
/// A non-empty output folder is NOT enough: the run may have been interrupted,
|
||||||
@@ -302,7 +317,7 @@ namespace GameLauncher.Engines.Evb
|
|||||||
{
|
{
|
||||||
foreach (var backup in Directory.GetFiles(gameRootDir, "*" + ExeBackupSuffix))
|
foreach (var backup in Directory.GetFiles(gameRootDir, "*" + ExeBackupSuffix))
|
||||||
{
|
{
|
||||||
var original = backup.Substring(0, backup.Length - ExeBackupSuffix.Length);
|
var original = backup[..^ExeBackupSuffix.Length];
|
||||||
if (!File.Exists(original))
|
if (!File.Exists(original))
|
||||||
{
|
{
|
||||||
File.Move(backup, original);
|
File.Move(backup, original);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# evbunpack (bundled tool)
|
# evbunpack (bundled tool)
|
||||||
|
|
||||||
`evbunpack.exe` is a bundled, third-party unpacker used by the **Evb** engine module to
|
`evbunpack.exe` is a bundled, third-party unpacker used by the **Evb** engine module to
|
||||||
unpack applications protected with **Enigma Virtual Box**.
|
unpack applications protected with **Enigma Virtual Box**.
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
long packageJsonOffset = -1;
|
long packageJsonOffset = -1;
|
||||||
long packageJsonSize = -1;
|
long packageJsonSize = -1;
|
||||||
|
|
||||||
TraverseFiles(filesRoot, "", dataOffset, fs.Length, result, includeFileList,
|
this.TraverseFiles(filesRoot, "", dataOffset, fs.Length, result, includeFileList,
|
||||||
ref systemJsonRelative, ref systemJsonOffset, ref systemJsonSize,
|
ref systemJsonRelative, ref systemJsonOffset, ref systemJsonSize,
|
||||||
ref packageJsonRelative, ref packageJsonOffset, ref packageJsonSize);
|
ref packageJsonRelative, ref packageJsonOffset, ref packageJsonSize);
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
|
|
||||||
if (val.TryGetProperty("files", out var subFiles))
|
if (val.TryGetProperty("files", out var subFiles))
|
||||||
{
|
{
|
||||||
TraverseFiles(subFiles, path, dataOffset, fileLength, result, includeFileList,
|
this.TraverseFiles(subFiles, path, dataOffset, fileLength, result, includeFileList,
|
||||||
ref systemJsonRelative, ref systemJsonOffset, ref systemJsonSize,
|
ref systemJsonRelative, ref systemJsonOffset, ref systemJsonSize,
|
||||||
ref packageJsonRelative, ref packageJsonOffset, ref packageJsonSize);
|
ref packageJsonRelative, ref packageJsonOffset, ref packageJsonSize);
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
// UNC パス (例: \\server\share\...) の場合
|
// UNC パス (例: \\server\share\...) の場合
|
||||||
if (normalized.StartsWith(@"\\", StringComparison.Ordinal))
|
if (normalized.StartsWith(@"\\", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return @"\\?\UNC\" + normalized.Substring(2);
|
return @"\\?\UNC\" + normalized[2..];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 相対パスの場合は安全に絶対パスを取得してからプレフィックスを付与
|
// 相対パスの場合は安全に絶対パスを取得してからプレフィックスを付与
|
||||||
@@ -408,7 +408,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
}
|
}
|
||||||
if (full.StartsWith(@"\\", StringComparison.Ordinal))
|
if (full.StartsWith(@"\\", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return @"\\?\UNC\" + full.Substring(2);
|
return @"\\?\UNC\" + full[2..];
|
||||||
}
|
}
|
||||||
return @"\\?\" + full;
|
return @"\\?\" + full;
|
||||||
}
|
}
|
||||||
@@ -447,7 +447,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ヘッダ詳細解析
|
// ヘッダ詳細解析
|
||||||
var inspect = InspectAsar(targetAsar, includeFileList: true);
|
var inspect = this.InspectAsar(targetAsar, includeFileList: true);
|
||||||
if (!inspect.IsValid || inspect.FileEntries.Count == 0)
|
if (!inspect.IsValid || inspect.FileEntries.Count == 0)
|
||||||
{
|
{
|
||||||
return (false, "asar ファイルのヘッダ解析に失敗したか、ファイルが含まれていません。");
|
return (false, "asar ファイルのヘッダ解析に失敗したか、ファイルが含まれていません。");
|
||||||
@@ -503,20 +503,18 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
fs.Seek(dataOffset + entry.Offset, SeekOrigin.Begin);
|
fs.Seek(dataOffset + entry.Offset, SeekOrigin.Begin);
|
||||||
long remaining = entry.Size;
|
long remaining = entry.Size;
|
||||||
|
|
||||||
using (var outFs = new FileStream(destFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
|
using var outFs = new FileStream(destFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||||
|
while (remaining > 0)
|
||||||
{
|
{
|
||||||
while (remaining > 0)
|
int toRead = (int)Math.Min(remaining, buffer.Length);
|
||||||
{
|
int read = fs.Read(buffer, 0, toRead);
|
||||||
int toRead = (int)Math.Min(remaining, buffer.Length);
|
if (read == 0) break;
|
||||||
int read = fs.Read(buffer, 0, toRead);
|
|
||||||
if (read == 0) break;
|
|
||||||
|
|
||||||
outFs.Write(buffer, 0, read);
|
outFs.Write(buffer, 0, read);
|
||||||
remaining -= read;
|
remaining -= read;
|
||||||
extractedBytes += read;
|
extractedBytes += read;
|
||||||
|
|
||||||
progress?.Report((extractedBytes, totalBytes, i + 1, totalFiles, Path.GetFileName(entry.RelativePath)));
|
progress?.Report((extractedBytes, totalBytes, i + 1, totalFiles, Path.GetFileName(entry.RelativePath)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception fileEx)
|
catch (Exception fileEx)
|
||||||
@@ -573,7 +571,7 @@ namespace GameLauncher.Engines.Nwjs
|
|||||||
: asarPath + AsarBackupSuffix;
|
: asarPath + AsarBackupSuffix;
|
||||||
|
|
||||||
var originalAsar = asarPath.EndsWith(AsarBackupSuffix, StringComparison.OrdinalIgnoreCase)
|
var originalAsar = asarPath.EndsWith(AsarBackupSuffix, StringComparison.OrdinalIgnoreCase)
|
||||||
? asarPath.Substring(0, asarPath.Length - AsarBackupSuffix.Length)
|
? asarPath[..^AsarBackupSuffix.Length]
|
||||||
: asarPath;
|
: asarPath;
|
||||||
|
|
||||||
string extExtractedDir = ToExtendedPath(extractedDir);
|
string extExtractedDir = ToExtendedPath(extractedDir);
|
||||||
|
|||||||
@@ -0,0 +1,401 @@
|
|||||||
|
// Engines/Nwjs/NwjsDetector.cs — 汎用 NW.js ゲーム検出およびメタデータ解決ヘルパー
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Nwjs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス。
|
||||||
|
/// </summary>
|
||||||
|
public static class NwjsDetector
|
||||||
|
{
|
||||||
|
#region □変数(Private)
|
||||||
|
|
||||||
|
private static readonly HashSet<string> ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
"notification_helper.exe",
|
||||||
|
"crashpad_handler.exe",
|
||||||
|
"elevate.exe"
|
||||||
|
};
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたディレクトリが汎用 NW.js ゲームであるかを判定します。
|
||||||
|
/// ツクール(MV/MZ/RGSS)、ティラノスクリプト、ウディタ、SRPG Studio など既存エンジン形式は除外します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">対象ディレクトリパス</param>
|
||||||
|
/// <returns>NW.js ゲームであれば true</returns>
|
||||||
|
public static bool IsNwjsGame(string dirPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var packageJsonPath = Path.Combine(dirPath, "package.json");
|
||||||
|
if (!File.Exists(packageJsonPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 既存の他エンジン判定(ツクール・ティラノ・ウディタ・SRPG)を最優先で除外
|
||||||
|
if (Directory.Exists(Path.Combine(dirPath, "www")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "data", "System.json")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "Game.ini")) ||
|
||||||
|
Directory.Exists(Path.Combine(dirPath, "tyrano")) ||
|
||||||
|
Directory.GetFiles(dirPath, "*.tjs", SearchOption.TopDirectoryOnly).Length > 0 ||
|
||||||
|
Directory.GetFiles(dirPath, "*.wolf", SearchOption.TopDirectoryOnly).Length > 0 ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "data.dts")))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NW.js の痕跡を確認
|
||||||
|
if (File.Exists(Path.Combine(dirPath, "nw.dll")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "nw.exe")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "resources.pak")) ||
|
||||||
|
File.Exists(Path.Combine(dirPath, "node.dll")) ||
|
||||||
|
Directory.Exists(Path.Combine(dirPath, "nwjs")))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// package.json に main や window 記述があるか確認
|
||||||
|
if (NwjsDetector.TryReadPackageJson(dirPath, out _, out _, out var main, out _))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(main) && File.Exists(Path.Combine(dirPath, main)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定ディレクトリ内の NW.js ゲームを検出し、TkoolGameItem を生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ゲームフォルダの絶対パス</param>
|
||||||
|
/// <param name="folderName">フォルダ名</param>
|
||||||
|
/// <param name="folderModified">フォルダ更新日時</param>
|
||||||
|
/// <param name="iconLoader">アイコン読み込み関数</param>
|
||||||
|
/// <returns>検出されたゲームアイテム。該当しない場合は null</returns>
|
||||||
|
public static TkoolGameItem? DetectNwjsGame(
|
||||||
|
string dirPath,
|
||||||
|
string folderName,
|
||||||
|
DateTime? folderModified,
|
||||||
|
Func<string?, string?, ImageSource?> iconLoader)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!NwjsDetector.IsNwjsGame(dirPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
NwjsDetector.TryReadPackageJson(dirPath, out var windowTitle, out var packageName, out var mainFile, out var iconRelPath);
|
||||||
|
|
||||||
|
// タイトルの決定: window.title > index.html の <title> > package.json の name > フォルダ名
|
||||||
|
string title = string.Empty;
|
||||||
|
if (!string.IsNullOrWhiteSpace(windowTitle))
|
||||||
|
{
|
||||||
|
title = windowTitle.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(title))
|
||||||
|
{
|
||||||
|
var htmlPath = !string.IsNullOrWhiteSpace(mainFile)
|
||||||
|
? Path.Combine(dirPath, mainFile)
|
||||||
|
: Path.Combine(dirPath, "index.html");
|
||||||
|
|
||||||
|
title = NwjsDetector.ExtractHtmlTitle(htmlPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(packageName))
|
||||||
|
{
|
||||||
|
title = packageName.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(title))
|
||||||
|
{
|
||||||
|
title = folderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 実行ファイルの探索
|
||||||
|
var exePath = NwjsDetector.FindNwjsExecutable(dirPath, title, packageName);
|
||||||
|
|
||||||
|
// アイコンの取得
|
||||||
|
ImageSource? icon = null;
|
||||||
|
if (iconLoader != null)
|
||||||
|
{
|
||||||
|
icon = iconLoader(exePath, dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
string entryHtmlPath = NwjsDetector.ResolveEntryHtmlPath(dirPath, mainFile);
|
||||||
|
string entryDirPath = !string.IsNullOrEmpty(entryHtmlPath)
|
||||||
|
? (Path.GetDirectoryName(entryHtmlPath) ?? dirPath)
|
||||||
|
: dirPath;
|
||||||
|
bool isModded = !string.IsNullOrEmpty(entryHtmlPath) && NwjsModService.CheckIsModded(entryHtmlPath);
|
||||||
|
var saveFiles = NwjsSaveService.FindSaveFiles(dirPath, folderName);
|
||||||
|
string saveDirPath = saveFiles.Count > 0
|
||||||
|
? (Path.GetDirectoryName(saveFiles[0].FilePath) ?? dirPath)
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
|
return new TkoolGameItem
|
||||||
|
{
|
||||||
|
Title = title,
|
||||||
|
FolderName = folderName,
|
||||||
|
RootDirectory = dirPath,
|
||||||
|
ExecutablePath = exePath ?? string.Empty,
|
||||||
|
PluginsJsPath = entryHtmlPath,
|
||||||
|
PluginsDirPath = entryDirPath,
|
||||||
|
EngineType = TkoolEngineType.Nwjs,
|
||||||
|
IsModded = isModded,
|
||||||
|
ApplyMod = isModded,
|
||||||
|
HasSaveData = saveFiles.Count > 0,
|
||||||
|
// セーブデータ有無
|
||||||
|
IconImage = icon,
|
||||||
|
FolderLastModified = folderModified
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// NW.js ゲームのエントリ HTML ファイル(index.html 等)の絶対パスを解決します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ゲームルートディレクトリ</param>
|
||||||
|
/// <param name="mainFromPackage">package.json の main フィールド(省略可)</param>
|
||||||
|
/// <returns>存在する HTML ファイルのフルパス。見つからない場合は空文字列</returns>
|
||||||
|
public static string ResolveEntryHtmlPath(string dirPath, string? mainFromPackage = null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dirPath) || !Directory.Exists(dirPath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(mainFromPackage))
|
||||||
|
{
|
||||||
|
NwjsDetector.TryReadPackageJson(dirPath, out _, out _, out mainFromPackage, out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(mainFromPackage))
|
||||||
|
{
|
||||||
|
string candidate = Path.Combine(dirPath, mainFromPackage.TrimStart('/', '\\'));
|
||||||
|
string ext = Path.GetExtension(candidate);
|
||||||
|
if ((ext.Equals(".html", StringComparison.OrdinalIgnoreCase) || ext.Equals(".htm", StringComparison.OrdinalIgnoreCase)) &&
|
||||||
|
File.Exists(candidate))
|
||||||
|
{
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string rootIndex = Path.Combine(dirPath, "index.html");
|
||||||
|
if (File.Exists(rootIndex))
|
||||||
|
{
|
||||||
|
return rootIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
string wwwIndex = Path.Combine(dirPath, "www", "index.html");
|
||||||
|
if (File.Exists(wwwIndex))
|
||||||
|
{
|
||||||
|
return wwwIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// NW.js ゲーム用の実行可能ファイル(.exe)を探索します。
|
||||||
|
/// notification_helper.exe などの Chromium 内部ユーティリティを除外し、ゲーム本体の exe を特定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dirPath">ディレクトリパス</param>
|
||||||
|
/// <param name="title">ゲームタイトル</param>
|
||||||
|
/// <param name="packageName">package.json の name</param>
|
||||||
|
/// <returns>実行ファイルのパス。見つからない場合は null</returns>
|
||||||
|
public static string? FindNwjsExecutable(string dirPath, string? title, string? packageName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var exes = Directory.GetFiles(dirPath, "*.exe", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(f =>
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(f);
|
||||||
|
if (fileName.StartsWith("unins", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NwjsDetector.ExcludedExeNames.Contains(fileName))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (exes.Count == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exes.Count == 1)
|
||||||
|
{
|
||||||
|
return exes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 優先度1: タイトル名またはパッケージ名が含まれる実行ファイル
|
||||||
|
if (!string.IsNullOrWhiteSpace(title))
|
||||||
|
{
|
||||||
|
var match = exes.FirstOrDefault(f => Path.GetFileNameWithoutExtension(f).Contains(title, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (match != null)
|
||||||
|
{
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(packageName))
|
||||||
|
{
|
||||||
|
var match = exes.FirstOrDefault(f => Path.GetFileNameWithoutExtension(f).Contains(packageName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (match != null)
|
||||||
|
{
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 優先度2: Game.exe または nw.exe
|
||||||
|
var gameExe = exes.FirstOrDefault(f => string.Equals(Path.GetFileName(f), "Game.exe", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (gameExe != null)
|
||||||
|
{
|
||||||
|
return gameExe;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nwExe = exes.FirstOrDefault(f => string.Equals(Path.GetFileName(f), "nw.exe", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (nwExe != null)
|
||||||
|
{
|
||||||
|
return nwExe;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 優先度3: 候補の先頭
|
||||||
|
return exes[0];
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// package.json を読み込み、主要な設定値を抽出します。
|
||||||
|
/// </summary>
|
||||||
|
private static bool TryReadPackageJson(
|
||||||
|
string dirPath,
|
||||||
|
out string? windowTitle,
|
||||||
|
out string? name,
|
||||||
|
out string? main,
|
||||||
|
out string? iconRelPath)
|
||||||
|
{
|
||||||
|
windowTitle = null;
|
||||||
|
name = null;
|
||||||
|
main = null;
|
||||||
|
iconRelPath = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var packageJsonPath = Path.Combine(dirPath, "package.json");
|
||||||
|
if (!File.Exists(packageJsonPath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var json = File.ReadAllText(packageJsonPath);
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
var root = doc.RootElement;
|
||||||
|
|
||||||
|
if (root.TryGetProperty("name", out var nameProp) && nameProp.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
name = nameProp.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.TryGetProperty("main", out var mainProp) && mainProp.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
main = mainProp.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.TryGetProperty("window", out var winProp) && winProp.ValueKind == JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
if (winProp.TryGetProperty("title", out var titleProp) && titleProp.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
windowTitle = titleProp.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (winProp.TryGetProperty("icon", out var iconProp) && iconProp.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
iconRelPath = iconProp.GetString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HTML ファイルから title タグのテキストを抽出します。
|
||||||
|
/// </summary>
|
||||||
|
private static string ExtractHtmlTitle(string htmlPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(htmlPath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = File.ReadAllText(htmlPath);
|
||||||
|
var match = Regex.Match(html, @"<title[^>]*>(.*?)</title>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
var title = match.Groups[1].Value.Trim();
|
||||||
|
return System.Net.WebUtility.HtmlDecode(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,260 @@
|
|||||||
|
<Window x:Class="GameLauncher.Engines.Nwjs.NwjsSaveEditorDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="🛠 NW.js セーブデータ改造エディタ"
|
||||||
|
Width="980" Height="720"
|
||||||
|
MinWidth="780" MinHeight="560"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Background="#141720"
|
||||||
|
Foreground="#ECEFF4">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="DarkButtonStyle" TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="#2563EB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#3B82F6"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Padding" Value="12,6"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Cursor" Value="Hand"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="5"
|
||||||
|
Padding="{TemplateBinding Padding}">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Opacity" Value="0.9"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="False">
|
||||||
|
<Setter Property="Opacity" Value="0.45"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
|
<Grid Margin="16">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- 1. ヘッダー&セーブファイル選択 -->
|
||||||
|
<Border Grid.Row="0" Background="#1E2332" BorderBrush="#2A3142" BorderThickness="1" CornerRadius="8" Padding="14,10" Margin="0,0,0,10">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,8">
|
||||||
|
<TextBlock Text="🛠 NW.js セーブデータ改造エディタ" FontSize="16" FontWeight="Bold" Foreground="#00E5FF" VerticalAlignment="Center"/>
|
||||||
|
<TextBlock x:Name="GameTitleText" Text="" FontSize="13" Foreground="#A5B1C2" VerticalAlignment="Center" Margin="14,0,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Grid Grid.Row="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="対象ファイル:" VerticalAlignment="Center" Foreground="#ECEFF4" FontWeight="SemiBold" Margin="0,0,10,0"/>
|
||||||
|
<ComboBox x:Name="SaveFileComboBox" Grid.Column="1"
|
||||||
|
DisplayMemberPath="SummaryText"
|
||||||
|
SelectionChanged="SaveFileComboBox_SelectionChanged"
|
||||||
|
Height="30" VerticalContentAlignment="Center"
|
||||||
|
Margin="0,0,8,0"/>
|
||||||
|
<Button Grid.Column="2" Content="🔄 再読込" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="ReloadButton_Click" Margin="0,0,8,0"/>
|
||||||
|
<Button Grid.Column="3" Content="📂 フォルダを開く" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="OpenFolderButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 2. ワンクリック・クイック改造バー -->
|
||||||
|
<Border Grid.Row="1" Background="#1A2436" BorderBrush="#2563EB" BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,10">
|
||||||
|
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
|
<TextBlock Text="⚡ クイック改造:" Foreground="#38BDF8" FontWeight="Bold" VerticalAlignment="Center" Margin="0,0,10,0"/>
|
||||||
|
<Button Content="💰 所持金 MAX (9,999,999)" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#059669" BorderBrush="#10B981" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxGold_Click"/>
|
||||||
|
<Button Content="🧾 借金を 0 にする" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#D97706" BorderBrush="#F59E0B" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickZeroDebt_Click"/>
|
||||||
|
<Button Content="❤️ スタミナ/HP 全快 (999)" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#7C3AED" BorderBrush="#8B5CF6" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxStamina_Click"/>
|
||||||
|
<Button Content="🎒 所持アイテム数 ×99" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#0284C7" BorderBrush="#38BDF8" Padding="10,4" Margin="0,2,6,2"
|
||||||
|
Click="QuickMaxItems_Click"/>
|
||||||
|
<Button Content="🔓 全スイッチ・ギャラリー解放ON" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#DB2777" BorderBrush="#F472B6" Padding="10,4" Margin="0,2,0,2"
|
||||||
|
Click="QuickUnlockAllSwitches_Click"/>
|
||||||
|
</WrapPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 3. 検索・カテゴリ絞り込み・一括変更バー -->
|
||||||
|
<Border Grid.Row="2" Background="#1E2332" BorderBrush="#2A3142" BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,10">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="180"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="110"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="90"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="0" Text="分類:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<ComboBox x:Name="CategoryFilterComboBox" Grid.Column="1" Height="28" VerticalContentAlignment="Center"
|
||||||
|
SelectionChanged="FilterChanged" Margin="0,0,10,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="2" Text="検索:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="KeywordFilterTextBox" Grid.Column="3" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#ECEFF4" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
ToolTip="項目名や変数番号・パスで絞り込みます"
|
||||||
|
TextChanged="FilterChanged" Margin="0,0,10,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="4" Text="現在値一致:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="ExactValueFilterTextBox" Grid.Column="5" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#38BDF8" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
ToolTip="指定した値と完全一致する項目だけをピンポイント抽出します(例: 100)"
|
||||||
|
TextChanged="FilterChanged" Margin="0,0,12,0"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="6" Text="一括値:" VerticalAlignment="Center" Foreground="#A5B1C2" Margin="0,0,6,0"/>
|
||||||
|
<TextBox x:Name="BulkValueTextBox" Grid.Column="7" Height="28" VerticalContentAlignment="Center"
|
||||||
|
Background="#141720" Foreground="#00E676" BorderBrush="#3B4252" Padding="6,0"
|
||||||
|
Text="999" Margin="0,0,6,0"/>
|
||||||
|
<Button Grid.Column="8" Content="表示中へ一括反映" Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569" Padding="10,4"
|
||||||
|
Click="ApplyBulkValue_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 4. メイン編集タブ(GUIテーブル / JSONテキスト直接編集) -->
|
||||||
|
<TabControl x:Name="EditorTabControl" Grid.Row="3" Background="#1E2332" BorderBrush="#2A3142"
|
||||||
|
SelectionChanged="EditorTabControl_SelectionChanged">
|
||||||
|
<TabItem Header="📊 ステータス・変数・アイテム一覧 (GUI編集)" Foreground="#141720" FontWeight="Bold">
|
||||||
|
<Grid Background="#141720">
|
||||||
|
<DataGrid x:Name="EntriesDataGrid"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserDeleteRows="False"
|
||||||
|
Background="#141720"
|
||||||
|
RowBackground="#1E2332"
|
||||||
|
AlternatingRowBackground="#191D2A"
|
||||||
|
Foreground="#ECEFF4"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HorizontalGridLinesBrush="#2A3142"
|
||||||
|
BorderBrush="#2A3142"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
SelectionMode="Single"
|
||||||
|
RowHeight="30">
|
||||||
|
<DataGrid.Resources>
|
||||||
|
<Style TargetType="DataGridColumnHeader">
|
||||||
|
<Setter Property="Background" Value="#252B3D"/>
|
||||||
|
<Setter Property="Foreground" Value="#38BDF8"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="10,6"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#2A3142"/>
|
||||||
|
<Setter Property="BorderThickness" Value="0,0,1,1"/>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.Resources>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="カテゴリ" Binding="{Binding Category}" Width="165" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="項目名 / 変数・ステータス名" Binding="{Binding DisplayKey}" Width="*" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="型" Binding="{Binding ValueType}" Width="75" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="変更前の値" Binding="{Binding OriginalValueText}" Width="130" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="✏️ 編集後の値 (ダブルクリックで変更)" Binding="{Binding ValueText, UpdateSourceTrigger=PropertyChanged}" Width="210">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="#00E5FF"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="6,0"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
<DataGridTextColumn.EditingElementStyle>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#0F172A"/>
|
||||||
|
<Setter Property="Foreground" Value="#00E676"/>
|
||||||
|
<Setter Property="FontWeight" Value="Bold"/>
|
||||||
|
<Setter Property="Padding" Value="4,2"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="内部パス" Binding="{Binding JsonPath}" Width="150" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<TabItem Header="📝 JSON ソース直接編集 (上級者向け)" Foreground="#141720" FontWeight="Bold">
|
||||||
|
<Grid Background="#141720" Margin="4">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Row="0"
|
||||||
|
Text="💡 復号・展開されたセーブデータの JSON 全文を直接編集できます(GameCreator の暗号化 .gcdata も保存時に自動で再暗号化されます)。"
|
||||||
|
Foreground="#A5B1C2" FontSize="12" Margin="4,4,4,6"/>
|
||||||
|
<TextBox x:Name="RawJsonTextBox" Grid.Row="1"
|
||||||
|
AcceptsReturn="True" AcceptsTab="True"
|
||||||
|
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
|
||||||
|
FontFamily="Consolas, Meiryo UI" FontSize="13"
|
||||||
|
Background="#0F172A" Foreground="#E2E8F0" BorderBrush="#334155"
|
||||||
|
Padding="10"/>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
|
||||||
|
<!-- 5. フッター&保存・バックアップ復元ボタン -->
|
||||||
|
<Grid Grid.Row="4" Margin="0,12,0,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock x:Name="StatusTextBlock" Grid.Column="0"
|
||||||
|
Text="セーブデータを選択してください。"
|
||||||
|
Foreground="#00E676" VerticalAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>
|
||||||
|
|
||||||
|
<Button x:Name="RestoreBackupButton" Grid.Column="1"
|
||||||
|
Content="⏪ バックアップから復元"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#B45309" BorderBrush="#F59E0B"
|
||||||
|
Click="RestoreBackupButton_Click" Margin="10,0,8,0"/>
|
||||||
|
|
||||||
|
<Button x:Name="SaveButton" Grid.Column="2"
|
||||||
|
Content="💾 変更をセーブデータに保存"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#059669" BorderBrush="#10B981"
|
||||||
|
Click="SaveButton_Click" Margin="0,0,8,0"/>
|
||||||
|
|
||||||
|
<Button Grid.Column="3" Content="閉じる"
|
||||||
|
Style="{StaticResource DarkButtonStyle}"
|
||||||
|
Background="#334155" BorderBrush="#475569"
|
||||||
|
Click="CloseButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,504 @@
|
|||||||
|
// Engines/Nwjs/NwjsSaveEditorDialog.xaml.cs — NW.js セーブデータ改造エディタダイアログ
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Nwjs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// NW.js 分類ゲーム(GameCreator .gcdata 暗号化セーブおよびカスタム HTML5/JS .json セーブ)の
|
||||||
|
/// ステータス・変数・所持品・フラグを編集・バックアップ・復元するダイアログウィンドウ。
|
||||||
|
/// </summary>
|
||||||
|
public partial class NwjsSaveEditorDialog : Window
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// カテゴリフィルタの「すべて表示」項目文字列。
|
||||||
|
/// </summary>
|
||||||
|
private const string AllCategoriesLabel = "すべて表示";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □変数(Private)
|
||||||
|
|
||||||
|
private readonly TkoolGameItem _game;
|
||||||
|
private List<NwjsSaveFileInfo> _saveFiles = new List<NwjsSaveFileInfo>();
|
||||||
|
private NwjsLoadedSaveDocument? _currentDoc;
|
||||||
|
private List<NwjsSaveEntryItem> _filteredEntries = new List<NwjsSaveEntryItem>();
|
||||||
|
private bool _isSuppressingEvents;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □コンストラクタ
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="NwjsSaveEditorDialog"/> クラスの新しいインスタンスを初期化します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">編集対象の NW.js ゲームアイテム</param>
|
||||||
|
public NwjsSaveEditorDialog(TkoolGameItem game)
|
||||||
|
{
|
||||||
|
this._game = game ?? throw new ArgumentNullException(nameof(game));
|
||||||
|
this.InitializeComponent();
|
||||||
|
this.GameTitleText.Text = $"— {this._game.Title}";
|
||||||
|
this.LoadSaveFileList();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □イベント
|
||||||
|
|
||||||
|
private void SaveFileComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._isSuppressingEvents)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.SaveFileComboBox.SelectedItem is NwjsSaveFileInfo selectedFile)
|
||||||
|
{
|
||||||
|
this.LoadSelectedSaveFile(selectedFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.LoadSaveFileList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenFolderButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string targetDir = this._game.RootDirectory;
|
||||||
|
if (this.SaveFileComboBox.SelectedItem is NwjsSaveFileInfo selectedFile && !string.IsNullOrEmpty(selectedFile.FilePath))
|
||||||
|
{
|
||||||
|
string? dir = Path.GetDirectoryName(selectedFile.FilePath);
|
||||||
|
if (!string.IsNullOrEmpty(dir) && Directory.Exists(dir))
|
||||||
|
{
|
||||||
|
targetDir = dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(targetDir))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = targetDir,
|
||||||
|
UseShellExecute = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(this, $"フォルダを開けませんでした:\n{ex.Message}", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this._isSuppressingEvents)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ApplyFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditorTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._isSuppressingEvents || this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ReferenceEquals(e.Source, this.EditorTabControl))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// タブ2 (JSON直接編集) に切り替えた際、GUIテーブルでの変更をJSON文字列に同期する
|
||||||
|
if (this.EditorTabControl.SelectedIndex == 1)
|
||||||
|
{
|
||||||
|
string updatedJson = NwjsSaveService.ApplyEntriesToDocument(this._currentDoc);
|
||||||
|
this.RawJsonTextBox.Text = updatedJson;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxGold_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (item.ValueType == "Number" &&
|
||||||
|
(item.JsonPath.EndsWith("money", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith("gold", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.DisplayKey.Contains("所持金", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
item.ValueText = "9999999";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus(count > 0
|
||||||
|
? $"💰 所持金項目 ({count} 件) を 9,999,999 に設定しました。「💾 変更をセーブデータに保存」で確定します。"
|
||||||
|
: "ℹ️ このセーブファイル内に直接の所持金プロパティ (gold / money) が見つかりませんでした。数値変数またはゲーム内チート [F10] をご利用ください。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickZeroDebt_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (item.ValueType == "Number" &&
|
||||||
|
(item.JsonPath.EndsWith("debt", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.DisplayKey.Contains("借金残高", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
item.ValueText = "0";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus(count > 0
|
||||||
|
? $"🧾 借金項目 ({count} 件) を 0 に設定しました。「💾 変更をセーブデータに保存」で確定します。"
|
||||||
|
: "ℹ️ このセーブファイル内に借金プロパティ (debt) はありません。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxStamina_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (item.ValueType == "Number" &&
|
||||||
|
(item.JsonPath.EndsWith("stamina", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith("maxStamina", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith(".hp", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith(".maxHp", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith(".mp", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.JsonPath.EndsWith(".maxMp", StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
item.ValueText = "999";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus(count > 0
|
||||||
|
? $"❤️ スタミナ・HP/MP 項目 ({count} 件) を 999 に設定しました。「💾 変更をセーブデータに保存」で確定します。"
|
||||||
|
: "ℹ️ 該当するスタミナ・HPプロパティが見つかりませんでした。変数検索またはゲーム内チート [F10] をご利用ください。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickMaxItems_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (item.Category == "🎒 所持アイテム" && item.ValueType == "Number")
|
||||||
|
{
|
||||||
|
item.ValueText = "99";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus(count > 0
|
||||||
|
? $"🎒 所持アイテム ({count} 件) の個数を 99 に設定しました。「💾 変更をセーブデータに保存」で確定します。"
|
||||||
|
: "ℹ️ 現在所持しているアイテムエントリが 0 件です(新規アイテムの入手はゲーム内チートメニュー [F10] から行えます)。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuickUnlockAllSwitches_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (item.JsonPath.Equals("userUnlockAll", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
item.ValueText = "true";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
else if (item.Category.Contains("スイッチ", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
item.Category.Contains("フラグ", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
item.ValueText = item.ValueType == "Boolean" ? "true" : "1";
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus(count > 0
|
||||||
|
? $"🔓 スイッチ・解放フラグ ({count} 件) を ON に設定しました。「💾 変更をセーブデータに保存」で確定します。"
|
||||||
|
: "ℹ️ 対象のスイッチ・解放フラグ項目が見つかりませんでした。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyBulkValue_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null || this._filteredEntries.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string bulkVal = this.BulkValueTextBox.Text?.Trim() ?? string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(bulkVal))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (NwjsSaveEntryItem item in this._filteredEntries)
|
||||||
|
{
|
||||||
|
item.ValueText = bulkVal;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshGridAndStatus($"✏️ 現在表示中の {count} 件の項目に「{bulkVal}」を一括設定しました。");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.EntriesDataGrid.CommitEdit(DataGridEditingUnit.Cell, true);
|
||||||
|
this.EntriesDataGrid.CommitEdit(DataGridEditingUnit.Row, true);
|
||||||
|
|
||||||
|
string jsonToSave;
|
||||||
|
if (this.EditorTabControl.SelectedIndex == 1)
|
||||||
|
{
|
||||||
|
jsonToSave = this.RawJsonTextBox.Text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jsonToSave = NwjsSaveService.ApplyEntriesToDocument(this._currentDoc);
|
||||||
|
this.RawJsonTextBox.Text = jsonToSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
NwjsSaveService.SaveToFile(this._currentDoc.FileInfo, this._game.RootDirectory, jsonToSave, createBackup: true);
|
||||||
|
|
||||||
|
foreach (NwjsSaveEntryItem entry in this._currentDoc.Entries)
|
||||||
|
{
|
||||||
|
if (entry.IsModified)
|
||||||
|
{
|
||||||
|
entry.InitializeValue(entry.ValueText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RestoreBackupButton.IsEnabled = this._currentDoc.FileInfo.HasBackup;
|
||||||
|
this.StatusTextBlock.Text = $"✔ 保存完了: {this._currentDoc.FileInfo.DisplayName} (初回バックアップ保護済み)";
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"セーブデータを保存しました!\n\n対象: {this._currentDoc.FileInfo.DisplayName}\n※元のセーブデータは自動バックアップされています。",
|
||||||
|
"セーブデータ保存完了",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"セーブデータの保存中にエラーが発生しました:\n{ex.Message}",
|
||||||
|
"保存エラー",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreBackupButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null || !this._currentDoc.FileInfo.HasBackup)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBoxResult res = MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"バックアップから元のセーブデータを復元しますか?\n\n対象: {this._currentDoc.FileInfo.DisplayName}",
|
||||||
|
"バックアップ復元の確認",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Question);
|
||||||
|
|
||||||
|
if (res != MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (NwjsSaveService.RestoreBackup(this._currentDoc.FileInfo))
|
||||||
|
{
|
||||||
|
this.LoadSelectedSaveFile(this._currentDoc.FileInfo);
|
||||||
|
this.StatusTextBlock.Text = $"⏪ バックアップから復元しました: {this._currentDoc.FileInfo.DisplayName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
this,
|
||||||
|
$"バックアップの復元に失敗しました:\n{ex.Message}",
|
||||||
|
"復元エラー",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
private void LoadSaveFileList()
|
||||||
|
{
|
||||||
|
this._isSuppressingEvents = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? previousPath = (this.SaveFileComboBox.SelectedItem as NwjsSaveFileInfo)?.FilePath;
|
||||||
|
this._saveFiles = NwjsSaveService.FindSaveFiles(this._game.RootDirectory, this._game.FolderName);
|
||||||
|
this.SaveFileComboBox.ItemsSource = this._saveFiles;
|
||||||
|
|
||||||
|
if (this._saveFiles.Count == 0)
|
||||||
|
{
|
||||||
|
this._currentDoc = null;
|
||||||
|
this.EntriesDataGrid.ItemsSource = null;
|
||||||
|
this.RawJsonTextBox.Text = string.Empty;
|
||||||
|
this.SaveButton.IsEnabled = false;
|
||||||
|
this.RestoreBackupButton.IsEnabled = false;
|
||||||
|
this.StatusTextBlock.Text = "⚠️ セーブファイルが見つかりません。ゲームを起動して一度セーブを作成するか、ゲーム内チート [F10] をご利用ください。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NwjsSaveFileInfo? target = null;
|
||||||
|
if (!string.IsNullOrEmpty(previousPath))
|
||||||
|
{
|
||||||
|
target = this._saveFiles.FirstOrDefault(f => string.Equals(f.FilePath, previousPath, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
target ??= this._saveFiles[0];
|
||||||
|
this.SaveFileComboBox.SelectedItem = target;
|
||||||
|
this._isSuppressingEvents = false;
|
||||||
|
this.LoadSelectedSaveFile(target);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
this._isSuppressingEvents = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadSelectedSaveFile(NwjsSaveFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this._currentDoc = NwjsSaveService.LoadSaveFile(fileInfo, this._game.RootDirectory);
|
||||||
|
this.RawJsonTextBox.Text = this._currentDoc.FormattedJson;
|
||||||
|
this.SaveButton.IsEnabled = true;
|
||||||
|
this.RestoreBackupButton.IsEnabled = fileInfo.HasBackup;
|
||||||
|
|
||||||
|
// カテゴリ一覧を更新
|
||||||
|
this._isSuppressingEvents = true;
|
||||||
|
var categories = new List<string> { NwjsSaveEditorDialog.AllCategoriesLabel };
|
||||||
|
categories.AddRange(this._currentDoc.Entries.Select(x => x.Category).Distinct());
|
||||||
|
this.CategoryFilterComboBox.ItemsSource = categories;
|
||||||
|
this.CategoryFilterComboBox.SelectedIndex = 0;
|
||||||
|
this._isSuppressingEvents = false;
|
||||||
|
|
||||||
|
this.ApplyFilter();
|
||||||
|
string formatLabel = fileInfo.FormatKind == NwjsSaveFormatKind.GameCreatorGcData
|
||||||
|
? "GameCreator 暗号化セーブ (.gcdata 復号済)"
|
||||||
|
: "JSON セーブデータ";
|
||||||
|
this.StatusTextBlock.Text = $"✔ 読込完了: {fileInfo.DisplayName} [{formatLabel}] — 全 {this._currentDoc.Entries.Count} 項目";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this._currentDoc = null;
|
||||||
|
this.EntriesDataGrid.ItemsSource = null;
|
||||||
|
this.RawJsonTextBox.Text = string.Empty;
|
||||||
|
this.SaveButton.IsEnabled = false;
|
||||||
|
this.RestoreBackupButton.IsEnabled = false;
|
||||||
|
this.StatusTextBlock.Text = $"❌ 読込エラー: {ex.Message}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyFilter()
|
||||||
|
{
|
||||||
|
if (this._currentDoc == null)
|
||||||
|
{
|
||||||
|
this._filteredEntries = new List<NwjsSaveEntryItem>();
|
||||||
|
this.EntriesDataGrid.ItemsSource = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string selectedCategory = this.CategoryFilterComboBox.SelectedItem as string ?? NwjsSaveEditorDialog.AllCategoriesLabel;
|
||||||
|
string keyword = this.KeywordFilterTextBox.Text?.Trim() ?? string.Empty;
|
||||||
|
string exactVal = this.ExactValueFilterTextBox.Text?.Trim() ?? string.Empty;
|
||||||
|
|
||||||
|
IEnumerable<NwjsSaveEntryItem> query = this._currentDoc.Entries;
|
||||||
|
|
||||||
|
if (!string.Equals(selectedCategory, NwjsSaveEditorDialog.AllCategoriesLabel, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
query = query.Where(x => string.Equals(x.Category, selectedCategory, StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(keyword))
|
||||||
|
{
|
||||||
|
query = query.Where(x =>
|
||||||
|
x.DisplayKey.Contains(keyword, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
x.JsonPath.Contains(keyword, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
x.ValueText.Contains(keyword, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(exactVal))
|
||||||
|
{
|
||||||
|
query = query.Where(x => string.Equals(x.ValueText.Trim(), exactVal, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
this._filteredEntries = query.ToList();
|
||||||
|
this.EntriesDataGrid.ItemsSource = this._filteredEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshGridAndStatus(string message)
|
||||||
|
{
|
||||||
|
this.EntriesDataGrid.Items.Refresh();
|
||||||
|
if (this._currentDoc != null && this.EditorTabControl.SelectedIndex == 1)
|
||||||
|
{
|
||||||
|
this.RawJsonTextBox.Text = NwjsSaveService.ApplyEntriesToDocument(this._currentDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.StatusTextBlock.Text = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using GameLauncher.Engines.Tkool;
|
using GameLauncher.Engines.Tkool;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace GameLauncher.Engines.Rgss.Games.IiniTitleRepair
|
|||||||
var trim = line.Trim();
|
var trim = line.Trim();
|
||||||
if (trim.StartsWith("Title=", StringComparison.OrdinalIgnoreCase))
|
if (trim.StartsWith("Title=", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var val = trim.Substring(6).Trim();
|
var val = trim[6..].Trim();
|
||||||
if (!string.IsNullOrWhiteSpace(val) && !val.Contains('\uFFFD'))
|
if (!string.IsNullOrWhiteSpace(val) && !val.Contains('\uFFFD'))
|
||||||
{
|
{
|
||||||
tg.Title = val;
|
tg.Title = val;
|
||||||
@@ -73,23 +73,23 @@ namespace GameLauncher.Engines.Rgss.Games.IiniTitleRepair
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(filePath)) return Array.Empty<string>();
|
if (!File.Exists(filePath)) return [];
|
||||||
|
|
||||||
byte[] bytes = File.ReadAllBytes(filePath);
|
byte[] bytes = File.ReadAllBytes(filePath);
|
||||||
if (bytes.Length == 0) return Array.Empty<string>();
|
if (bytes.Length == 0) return [];
|
||||||
|
|
||||||
// 1. UTF-8 BOM (EF BB BF)
|
// 1. UTF-8 BOM (EF BB BF)
|
||||||
if (bytes.Length >= 3 && bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF)
|
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);
|
var text = System.Text.Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3);
|
||||||
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
return text.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. UTF-16 LE BOM (FF FE)
|
// 2. UTF-16 LE BOM (FF FE)
|
||||||
if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE)
|
if (bytes.Length >= 2 && bytes[0] == 0xFF && bytes[1] == 0xFE)
|
||||||
{
|
{
|
||||||
var text = System.Text.Encoding.Unicode.GetString(bytes, 2, bytes.Length - 2);
|
var text = System.Text.Encoding.Unicode.GetString(bytes, 2, bytes.Length - 2);
|
||||||
return text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
return text.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Shift_JIS (CP932)
|
// 3. Shift_JIS (CP932)
|
||||||
@@ -104,11 +104,11 @@ namespace GameLauncher.Engines.Rgss.Games.IiniTitleRepair
|
|||||||
}
|
}
|
||||||
|
|
||||||
var decoded = encoding.GetString(bytes);
|
var decoded = encoding.GetString(bytes);
|
||||||
return decoded.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
return decoded.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return Array.Empty<string>();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,11 +415,11 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
{
|
{
|
||||||
if (game.ApplyMod)
|
if (game.ApplyMod)
|
||||||
{
|
{
|
||||||
return await ApplyModAsync(game, pluginSettings, rgssExtractorPath);
|
return await this.ApplyModAsync(game, pluginSettings, rgssExtractorPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return RestoreOriginal(game);
|
return this.RestoreOriginal(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +439,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
// 1. スクリプトファイルが存在しない場合(RGSS暗号化アーカイブ内の場合)、自動抽出
|
// 1. スクリプトファイルが存在しない場合(RGSS暗号化アーカイブ内の場合)、自動抽出
|
||||||
if (string.IsNullOrEmpty(scriptsPath) || !File.Exists(scriptsPath))
|
if (string.IsNullOrEmpty(scriptsPath) || !File.Exists(scriptsPath))
|
||||||
{
|
{
|
||||||
var (extractSuccess, extractMsg) = await ExtractScriptsAsync(game, rgssExtractorPath);
|
var (extractSuccess, extractMsg) = await this.ExtractScriptsAsync(game, rgssExtractorPath);
|
||||||
if (!extractSuccess)
|
if (!extractSuccess)
|
||||||
{
|
{
|
||||||
return (false, $"スクリプトの抽出に失敗したため改造を適用できませんでした: {extractMsg}");
|
return (false, $"スクリプトの抽出に失敗したため改造を適用できませんでした: {extractMsg}");
|
||||||
@@ -819,14 +819,13 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
if (parserType != null)
|
if (parserType != null)
|
||||||
{
|
{
|
||||||
var parser = Activator.CreateInstance(parserType);
|
var parser = Activator.CreateInstance(parserType);
|
||||||
var parseFileMethod = parserType.GetMethod("parse_file", new[] { typeof(string) });
|
var parseFileMethod = parserType.GetMethod("parse_file", [typeof(string)]);
|
||||||
var getFileDataMethod = parserType.GetMethod("get_filedata");
|
var getFileDataMethod = parserType.GetMethod("get_filedata");
|
||||||
var closeFileMethod = parserType.GetMethod("close_file");
|
var closeFileMethod = parserType.GetMethod("close_file");
|
||||||
|
|
||||||
if (parseFileMethod != null && getFileDataMethod != null && parser != null)
|
if (parseFileMethod != null && getFileDataMethod != null && parser != null)
|
||||||
{
|
{
|
||||||
var entries = parseFileMethod.Invoke(parser, new object[] { archivePath }) as System.Collections.IEnumerable;
|
if (parseFileMethod.Invoke(parser, [archivePath]) is System.Collections.IEnumerable entries)
|
||||||
if (entries != null)
|
|
||||||
{
|
{
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
@@ -839,8 +838,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
(entryName.EndsWith(targetFileName, StringComparison.OrdinalIgnoreCase) ||
|
(entryName.EndsWith(targetFileName, StringComparison.OrdinalIgnoreCase) ||
|
||||||
Path.GetFileName(entryName).Equals(targetFileName, StringComparison.OrdinalIgnoreCase)))
|
Path.GetFileName(entryName).Equals(targetFileName, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
var fileBytes = getFileDataMethod.Invoke(parser, new object[] { entry }) as byte[];
|
if (getFileDataMethod.Invoke(parser, [entry]) is byte[] fileBytes && fileBytes.Length > 0)
|
||||||
if (fileBytes != null && fileBytes.Length > 0)
|
|
||||||
{
|
{
|
||||||
closeFileMethod?.Invoke(parser, null);
|
closeFileMethod?.Invoke(parser, null);
|
||||||
|
|
||||||
@@ -873,10 +871,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
};
|
};
|
||||||
|
|
||||||
using var proc = Process.Start(psi);
|
using var proc = Process.Start(psi);
|
||||||
if (proc != null)
|
proc?.WaitForExit(30000); // 最大30秒待機
|
||||||
{
|
|
||||||
proc.WaitForExit(30000); // 最大30秒待機
|
|
||||||
}
|
|
||||||
|
|
||||||
// RGSS Extractor はツール自身のフォルダ配下に Data\Scripts.rvdata2 等を出力
|
// RGSS Extractor はツール自身のフォルダ配下に Data\Scripts.rvdata2 等を出力
|
||||||
var possibleOutput = Path.Combine(toolDir, "Data", targetFileName);
|
var possibleOutput = Path.Combine(toolDir, "Data", targetFileName);
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
int endIdx = content.IndexOf(ModEndTag, StringComparison.Ordinal);
|
int endIdx = content.IndexOf(ModEndTag, StringComparison.Ordinal);
|
||||||
if (endIdx > startIdx)
|
if (endIdx > startIdx)
|
||||||
{
|
{
|
||||||
content = content.Substring(0, startIdx).TrimEnd() + "\n\n" + modCode + "\n";
|
content = content[..startIdx].TrimEnd() + "\n\n" + modCode + "\n";
|
||||||
File.WriteAllText(scriptPath, content, Encoding.UTF8);
|
File.WriteAllText(scriptPath, content, Encoding.UTF8);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -562,7 +562,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
if (!SrpgArchiveService.IsExtracted(gameDir))
|
if (!SrpgArchiveService.IsExtracted(gameDir))
|
||||||
{
|
{
|
||||||
progress?.Report("アーカイブ(data.dts)を初回展開中...");
|
progress?.Report("アーカイブ(data.dts)を初回展開中...");
|
||||||
var unpackRes = await _archiveService.UnpackDataDtsAsync(gameDir, progress);
|
var unpackRes = await this._archiveService.UnpackDataDtsAsync(gameDir, progress);
|
||||||
if (!unpackRes.Success)
|
if (!unpackRes.Success)
|
||||||
{
|
{
|
||||||
return unpackRes;
|
return unpackRes;
|
||||||
@@ -571,7 +571,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
|
|
||||||
var extractedDir = SrpgArchiveService.GetExtractedDirectory(gameDir);
|
var extractedDir = SrpgArchiveService.GetExtractedDirectory(gameDir);
|
||||||
progress?.Report("Modスクリプトを生成中...");
|
progress?.Report("Modスクリプトを生成中...");
|
||||||
var modBody = GenerateModScript(item);
|
var modBody = this.GenerateModScript(item);
|
||||||
var jsContent = $"{ModStartTag}\n{modBody}\n{ModEndTag}";
|
var jsContent = $"{ModStartTag}\n{modBody}\n{ModEndTag}";
|
||||||
|
|
||||||
// 2. 既存のスクリプトへ注入
|
// 2. 既存のスクリプトへ注入
|
||||||
@@ -604,7 +604,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
|
|
||||||
// 3. data.dts を再パック
|
// 3. data.dts を再パック
|
||||||
progress?.Report("Modを適用した data.dts を再構築中...");
|
progress?.Report("Modを適用した data.dts を再構築中...");
|
||||||
var repackRes = await _archiveService.RepackDataDtsAsync(gameDir, progress);
|
var repackRes = await this._archiveService.RepackDataDtsAsync(gameDir, progress);
|
||||||
if (repackRes.Success)
|
if (repackRes.Success)
|
||||||
{
|
{
|
||||||
item.IsModded = true;
|
item.IsModded = true;
|
||||||
@@ -658,8 +658,8 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
|
|
||||||
// 2. バックアップが存在すればバックアップ復元を試行
|
// 2. バックアップが存在すればバックアップ復元を試行
|
||||||
progress?.Report("オリジナルバックアップから data.dts を復元中...");
|
progress?.Report("オリジナルバックアップから data.dts を復元中...");
|
||||||
var revertRes = await _archiveService.RevertBackupAsync(gameDir);
|
var (Success, Message) = await this._archiveService.RevertBackupAsync(gameDir);
|
||||||
if (revertRes.Success)
|
if (Success)
|
||||||
{
|
{
|
||||||
item.IsModded = false;
|
item.IsModded = false;
|
||||||
return (true, "改造プラグインを解除し、元のアーカイブへ復元しました。");
|
return (true, "改造プラグインを解除し、元のアーカイブへ復元しました。");
|
||||||
@@ -667,7 +667,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
|
|
||||||
// バックアップが無い場合は Mod解除状態で再パック
|
// バックアップが無い場合は Mod解除状態で再パック
|
||||||
progress?.Report("Mod解除状態でアーカイブを再構築中...");
|
progress?.Report("Mod解除状態でアーカイブを再構築中...");
|
||||||
var repackRes = await _archiveService.RepackDataDtsAsync(gameDir, progress);
|
var repackRes = await this._archiveService.RepackDataDtsAsync(gameDir, progress);
|
||||||
if (repackRes.Success)
|
if (repackRes.Success)
|
||||||
{
|
{
|
||||||
item.IsModded = false;
|
item.IsModded = false;
|
||||||
@@ -689,7 +689,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
// 1. プロキシDLL解除
|
// 1. プロキシDLL解除
|
||||||
if (IsProxyDllEnabled(gameDir))
|
if (IsProxyDllEnabled(gameDir))
|
||||||
{
|
{
|
||||||
DisableProxyDll(gameDir);
|
this.DisableProxyDll(gameDir);
|
||||||
logs.Add("・プロキシDLL (version.dll) を解除しました");
|
logs.Add("・プロキシDLL (version.dll) を解除しました");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,10 +726,10 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
|
|
||||||
// 3. バックアップからの data.dts 復元
|
// 3. バックアップからの data.dts 復元
|
||||||
progress?.Report("バックアップから元の data.dts を復元中...");
|
progress?.Report("バックアップから元の data.dts を復元中...");
|
||||||
var revertRes = await _archiveService.RevertBackupAsync(gameDir);
|
var (Success, Message) = await this._archiveService.RevertBackupAsync(gameDir);
|
||||||
if (revertRes.Success)
|
if (Success)
|
||||||
{
|
{
|
||||||
logs.Add($"・{revertRes.Message}");
|
logs.Add($"・{Message}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -737,7 +737,7 @@ namespace GameLauncher.Engines.Rgss
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4. 解凍フォルダの退避
|
// 4. 解凍フォルダの退避
|
||||||
var restoreExtractedRes = _archiveService.RestoreExtractedState(gameDir);
|
var restoreExtractedRes = this._archiveService.RestoreExtractedState(gameDir);
|
||||||
if (restoreExtractedRes.Success && !restoreExtractedRes.Message.Contains("存在しません"))
|
if (restoreExtractedRes.Success && !restoreExtractedRes.Message.Contains("存在しません"))
|
||||||
{
|
{
|
||||||
logs.Add($"・{restoreExtractedRes.Message}");
|
logs.Add($"・{restoreExtractedRes.Message}");
|
||||||
|
|||||||
+564
-236
File diff suppressed because it is too large.
Load diff
@@ -159,9 +159,9 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
|
|
||||||
var entry = $"{BeginMarker}{{\"name\":\"{ModPluginId}\",\"status\":true,\"description\":\"GameLauncher mod\",\"parameters\":{{}}}}{EndMarker}";
|
var entry = $"{BeginMarker}{{\"name\":\"{ModPluginId}\",\"status\":true,\"description\":\"GameLauncher mod\",\"parameters\":{{}}}}{EndMarker}";
|
||||||
|
|
||||||
var prefix = content.Substring(0, arrayStart + 1);
|
var prefix = content[..(arrayStart + 1)];
|
||||||
var inner = content.Substring(arrayStart + 1, arrayEnd - arrayStart - 1);
|
var inner = content.Substring(arrayStart + 1, arrayEnd - arrayStart - 1);
|
||||||
var suffix = content.Substring(arrayEnd);
|
var suffix = content[arrayEnd..];
|
||||||
|
|
||||||
var trimmedInner = inner.Trim();
|
var trimmedInner = inner.Trim();
|
||||||
var newInner = string.IsNullOrEmpty(trimmedInner)
|
var newInner = string.IsNullOrEmpty(trimmedInner)
|
||||||
@@ -198,7 +198,7 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
while (scan >= 0 && char.IsWhiteSpace(content[scan])) scan--;
|
while (scan >= 0 && char.IsWhiteSpace(content[scan])) scan--;
|
||||||
if (scan >= 0 && content[scan] == ',') cutStart = scan;
|
if (scan >= 0 && content[scan] == ',') cutStart = scan;
|
||||||
|
|
||||||
content = content.Substring(0, cutStart) + content.Substring(end);
|
content = content[..cutStart] + content[end..];
|
||||||
}
|
}
|
||||||
while (content != prev);
|
while (content != prev);
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,21 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
"BattleTurnRecover",
|
"BattleTurnRecover",
|
||||||
"MaxGainGold",
|
"MaxGainGold",
|
||||||
"MaxGainExp",
|
"MaxGainExp",
|
||||||
"InstantMessage"
|
"InstantMessage",
|
||||||
|
"GameLauncher_Mod",
|
||||||
|
"GameLauncherMod",
|
||||||
|
"GameLauncher_StandaloneMod",
|
||||||
|
"GameLauncherStandaloneMod"
|
||||||
];
|
];
|
||||||
|
|
||||||
private List<ModPluginDefinition> _availablePlugins = [];
|
private List<ModPluginDefinition> _availablePlugins = [];
|
||||||
|
|
||||||
/// <summary>現在認識されている利用可能なプラグイン一覧</summary>
|
/// <summary>現在認識されている利用可能なプラグイン一覧</summary>
|
||||||
public IReadOnlyList<ModPluginDefinition> AvailablePlugins => _availablePlugins;
|
public IReadOnlyList<ModPluginDefinition> AvailablePlugins => this._availablePlugins;
|
||||||
|
|
||||||
public TkoolModService()
|
public TkoolModService()
|
||||||
{
|
{
|
||||||
LoadAvailablePlugins();
|
this.LoadAvailablePlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,13 +90,22 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
list.Add(ModPluginDefinition.FromFile(file));
|
var def = ModPluginDefinition.FromFile(file);
|
||||||
|
if (string.Equals(def.Id, "GameLauncher_Mod", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(def.Id, "GameLauncher_StandaloneMod", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(def.Id, "GameLauncherMod", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(def.Id, "GameLauncherStandaloneMod", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(def);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_availablePlugins = list;
|
this._availablePlugins = list;
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,11 +159,11 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
{
|
{
|
||||||
if (game.ApplyMod)
|
if (game.ApplyMod)
|
||||||
{
|
{
|
||||||
return ApplyMod(game, defaultSettings);
|
return this.ApplyMod(game, defaultSettings);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return RestoreOriginal(game);
|
return this.RestoreOriginal(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -203,18 +216,27 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
string baseContent = File.ReadAllText(backupPath, Encoding.UTF8);
|
string baseContent = File.ReadAllText(backupPath, Encoding.UTF8);
|
||||||
|
|
||||||
// 最新の動的プラグイン一覧を取得
|
// 最新の動的プラグイン一覧を取得
|
||||||
if (_availablePlugins.Count == 0)
|
if (this._availablePlugins.Count == 0)
|
||||||
{
|
{
|
||||||
LoadAvailablePlugins();
|
this.LoadAvailablePlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有効化対象のプラグインを取得
|
// 有効化対象のプラグインを取得
|
||||||
var pluginsToEnable = _availablePlugins
|
// ※ResourceLoaderFix はリソース読み込み不具合の必須救済プラグインのため、常に有効化・先頭配置
|
||||||
.Where(p => game.IsPluginEnabled(p.Id, defaultSettings, fallbackVal: true))
|
var fixPlugin = this._availablePlugins.FirstOrDefault(p => string.Equals(p.Id, "ResourceLoaderFix", StringComparison.OrdinalIgnoreCase));
|
||||||
|
var pluginsToEnable = this._availablePlugins
|
||||||
|
.Where(p => string.Equals(p.Id, "ResourceLoaderFix", StringComparison.OrdinalIgnoreCase) || game.IsPluginEnabled(p.Id, defaultSettings, fallbackVal: p.DefaultEnabled))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
// ResourceLoaderFix を最優先(先頭)に配置して、他プラグイン実行前のリソース要求も確実に救済
|
||||||
|
if (fixPlugin != null && pluginsToEnable.Contains(fixPlugin))
|
||||||
|
{
|
||||||
|
pluginsToEnable.Remove(fixPlugin);
|
||||||
|
pluginsToEnable.Insert(0, fixPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
// 3. ゲーム側の plugins ディレクトリから不要な旧プラグインや無効プラグインを安全に掃除
|
// 3. ゲーム側の plugins ディレクトリから不要な旧プラグインや無効プラグインを安全に掃除
|
||||||
var allManaged = GetAllManagedPluginNames(_availablePlugins);
|
var allManaged = GetAllManagedPluginNames(this._availablePlugins);
|
||||||
var enabledIds = new HashSet<string>(pluginsToEnable.Select(p => p.Id), StringComparer.OrdinalIgnoreCase);
|
var enabledIds = new HashSet<string>(pluginsToEnable.Select(p => p.Id), StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
foreach (var pluginId in allManaged)
|
foreach (var pluginId in allManaged)
|
||||||
@@ -233,7 +255,7 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
// 4. 有効対象のプラグインファイルをゲーム側へ配置
|
// 4. 有効対象のプラグインファイルをゲーム側へ配置
|
||||||
foreach (var plugin in pluginsToEnable)
|
foreach (var plugin in pluginsToEnable)
|
||||||
{
|
{
|
||||||
CopyPluginToGame(plugin, pluginsDir);
|
this.CopyPluginToGame(plugin, pluginsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. plugins.js をパース・再構築して有効プラグインを追加
|
// 5. plugins.js をパース・再構築して有効プラグインを追加
|
||||||
@@ -285,7 +307,7 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
// 2. ゲーム側の plugins フォルダから新旧すべてのプラグインファイルを安全に削除(ゴミを残さない)
|
// 2. ゲーム側の plugins フォルダから新旧すべてのプラグインファイルを安全に削除(ゴミを残さない)
|
||||||
if (!string.IsNullOrEmpty(pluginsDir) && Directory.Exists(pluginsDir))
|
if (!string.IsNullOrEmpty(pluginsDir) && Directory.Exists(pluginsDir))
|
||||||
{
|
{
|
||||||
var allManaged = GetAllManagedPluginNames(_availablePlugins);
|
var allManaged = GetAllManagedPluginNames(this._availablePlugins);
|
||||||
foreach (var pluginName in allManaged)
|
foreach (var pluginName in allManaged)
|
||||||
{
|
{
|
||||||
var targetFile = Path.Combine(pluginsDir, $"{pluginName}.js");
|
var targetFile = Path.Combine(pluginsDir, $"{pluginName}.js");
|
||||||
@@ -332,9 +354,9 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
string prefix = content.Substring(0, arrayStart + 1);
|
string prefix = content[..(arrayStart + 1)];
|
||||||
string inner = content.Substring(arrayStart + 1, arrayEnd - arrayStart - 1);
|
string inner = content.Substring(arrayStart + 1, arrayEnd - arrayStart - 1);
|
||||||
string suffix = content.Substring(arrayEnd);
|
string suffix = content[arrayEnd..];
|
||||||
|
|
||||||
// 新旧すべてのプラグイン名を除去対象とする
|
// 新旧すべてのプラグイン名を除去対象とする
|
||||||
var managedSet = GetAllManagedPluginNames();
|
var managedSet = GetAllManagedPluginNames();
|
||||||
@@ -388,7 +410,7 @@ namespace GameLauncher.Engines.Tkool
|
|||||||
|
|
||||||
if (depth == 0)
|
if (depth == 0)
|
||||||
{
|
{
|
||||||
string objText = inner.Substring(objStart, i - objStart).Trim();
|
string objText = inner[objStart..i].Trim();
|
||||||
// このオブジェクトが新旧管理対象プラグインかどうか判定
|
// このオブジェクトが新旧管理対象プラグインかどうか判定
|
||||||
var match = Regex.Match(objText, @"""name""\s*:\s*""([^""]+)""");
|
var match = Regex.Match(objText, @"""name""\s*:\s*""([^""]+)""");
|
||||||
if (match.Success && managedSet.Contains(match.Groups[1].Value))
|
if (match.Success && managedSet.Contains(match.Groups[1].Value))
|
||||||
|
|||||||
@@ -0,0 +1,747 @@
|
|||||||
|
// Engines/Tkool/TkoolMzFixService.cs
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Tkool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// RPGツクールMZ専用のPixi.js・Spineエラー修復およびDevTools有効化サービス。
|
||||||
|
/// マップ移動時に発生する Pixi.js の "Cannot read property 'valid' of null" クラッシュ、
|
||||||
|
/// および Spine の "Animation not found" クラッシュを防止し、開発者ツール(DevTools)の制限を解除します。
|
||||||
|
/// </summary>
|
||||||
|
public static class TkoolMzFixService
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
|
||||||
|
private const string BackupSuffix = ".bak";
|
||||||
|
private const string SpineFixMarker = "/* GameLauncher_SpineFix */";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたゲームディレクトリに対して、Pixi.js のエラー修復および DevTools 有効化を適用します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rootDir">ゲームのルートディレクトリ</param>
|
||||||
|
/// <returns>処理成否およびメッセージ</returns>
|
||||||
|
public static (bool Success, string Message) ApplyMzPixiFix(string rootDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(rootDir) || !Directory.Exists(rootDir))
|
||||||
|
{
|
||||||
|
return (false, "ゲームディレクトリが存在しません。");
|
||||||
|
}
|
||||||
|
|
||||||
|
int patchedCount = 0;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// 1. package.json の --disable-devtools 除去
|
||||||
|
var packageJsonPath = Path.Combine(rootDir, "package.json");
|
||||||
|
if (File.Exists(packageJsonPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PatchPackageJson(packageJsonPath))
|
||||||
|
{
|
||||||
|
patchedCount++;
|
||||||
|
sb.Append("DevTools有効化, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sb.Append($"package.json修復失敗({ex.Message}), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. js/libs/pixi.js の null安全パッチ適用
|
||||||
|
var pixiJsPath = Path.Combine(rootDir, "js", "libs", "pixi.js");
|
||||||
|
if (File.Exists(pixiJsPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PatchPixiJs(pixiJsPath))
|
||||||
|
{
|
||||||
|
patchedCount++;
|
||||||
|
sb.Append("pixi.js安全化, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sb.Append($"pixi.js修復失敗({ex.Message}), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. js/libs/pixi-picture.js の null安全パッチ適用
|
||||||
|
var pixiPicturePath = Path.Combine(rootDir, "js", "libs", "pixi-picture.js");
|
||||||
|
if (File.Exists(pixiPicturePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PatchPixiPictureJs(pixiPicturePath))
|
||||||
|
{
|
||||||
|
patchedCount++;
|
||||||
|
sb.Append("pixi-picture.js安全化, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sb.Append($"pixi-picture.js修復失敗({ex.Message}), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchedCount > 0)
|
||||||
|
{
|
||||||
|
var summary = sb.ToString().TrimEnd(' ', ',');
|
||||||
|
return (true, $"ツクールMZ修復パッチを適用しました: [{summary}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true, "ツクールMZ修復パッチは既に適用済みです。");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// バックアップファイルからオリジナル状態への復元を行います。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rootDir">ゲームのルートディレクトリ</param>
|
||||||
|
/// <returns>処理成否およびメッセージ</returns>
|
||||||
|
public static (bool Success, string Message) RestoreMzPixiFix(string rootDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(rootDir) || !Directory.Exists(rootDir))
|
||||||
|
{
|
||||||
|
return (false, "ゲームディレクトリが存在しません。");
|
||||||
|
}
|
||||||
|
|
||||||
|
int restoredCount = 0;
|
||||||
|
|
||||||
|
// 1. package.json の復元
|
||||||
|
var packageJsonPath = Path.Combine(rootDir, "package.json");
|
||||||
|
var packageJsonBak = packageJsonPath + BackupSuffix;
|
||||||
|
if (File.Exists(packageJsonBak))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(packageJsonBak, packageJsonPath, true);
|
||||||
|
restoredCount++;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. js/libs/pixi.js の復元
|
||||||
|
var pixiJsPath = Path.Combine(rootDir, "js", "libs", "pixi.js");
|
||||||
|
var pixiJsBak = pixiJsPath + BackupSuffix;
|
||||||
|
if (File.Exists(pixiJsBak))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(pixiJsBak, pixiJsPath, true);
|
||||||
|
restoredCount++;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. js/libs/pixi-picture.js の復元
|
||||||
|
var pixiPicturePath = Path.Combine(rootDir, "js", "libs", "pixi-picture.js");
|
||||||
|
var pixiPictureBak = pixiPicturePath + BackupSuffix;
|
||||||
|
if (File.Exists(pixiPictureBak))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(pixiPictureBak, pixiPicturePath, true);
|
||||||
|
restoredCount++;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true, $"ツクールMZ修復パッチを元に戻しました(復元ファイル数: {restoredCount})");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたゲームディレクトリに対して、Spineアニメーション未定義エラー(Animation not found 等)の修復パッチを適用します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rootDir">ゲームのルートディレクトリ</param>
|
||||||
|
/// <returns>処理成否およびメッセージ</returns>
|
||||||
|
public static (bool Success, string Message) ApplyMzSpineFix(string rootDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(rootDir) || !Directory.Exists(rootDir))
|
||||||
|
{
|
||||||
|
return (false, "ゲームディレクトリが存在しません。");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasTargetFile = false;
|
||||||
|
int patchedCount = 0;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// 1. js/libs/pixi-spine.js の未定義アニメーション安全化パッチ適用
|
||||||
|
var pixiSpinePath = Path.Combine(rootDir, "js", "libs", "pixi-spine.js");
|
||||||
|
if (File.Exists(pixiSpinePath))
|
||||||
|
{
|
||||||
|
hasTargetFile = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PatchPixiSpineJs(pixiSpinePath))
|
||||||
|
{
|
||||||
|
patchedCount++;
|
||||||
|
sb.Append("pixi-spine.js安全化, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sb.Append($"pixi-spine.js修復失敗({ex.Message}), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. js/plugins/PictureSpine.js のスケルトン整合・null安全化パッチ適用
|
||||||
|
var pictureSpinePath = Path.Combine(rootDir, "js", "plugins", "PictureSpine.js");
|
||||||
|
if (File.Exists(pictureSpinePath))
|
||||||
|
{
|
||||||
|
hasTargetFile = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (PatchPictureSpineJs(pictureSpinePath))
|
||||||
|
{
|
||||||
|
patchedCount++;
|
||||||
|
sb.Append("PictureSpine.js安全化, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sb.Append($"PictureSpine.js修復失敗({ex.Message}), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasTargetFile)
|
||||||
|
{
|
||||||
|
return (true, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchedCount > 0)
|
||||||
|
{
|
||||||
|
var summary = sb.ToString().TrimEnd(' ', ',');
|
||||||
|
return (true, $"ツクールMZ Spine修復パッチを適用しました: [{summary}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true, "ツクールMZ Spine修復パッチは既に適用済みです。");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spine修復パッチのバックアップファイルからオリジナル状態への復元を行います。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rootDir">ゲームのルートディレクトリ</param>
|
||||||
|
/// <returns>処理成否およびメッセージ</returns>
|
||||||
|
public static (bool Success, string Message) RestoreMzSpineFix(string rootDir)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(rootDir) || !Directory.Exists(rootDir))
|
||||||
|
{
|
||||||
|
return (false, "ゲームディレクトリが存在しません。");
|
||||||
|
}
|
||||||
|
|
||||||
|
int restoredCount = 0;
|
||||||
|
|
||||||
|
var pixiSpinePath = Path.Combine(rootDir, "js", "libs", "pixi-spine.js");
|
||||||
|
var pixiSpineBak = pixiSpinePath + BackupSuffix;
|
||||||
|
if (File.Exists(pixiSpineBak))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(pixiSpineBak, pixiSpinePath, true);
|
||||||
|
restoredCount++;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
var pictureSpinePath = Path.Combine(rootDir, "js", "plugins", "PictureSpine.js");
|
||||||
|
var pictureSpineBak = pictureSpinePath + BackupSuffix;
|
||||||
|
if (File.Exists(pictureSpineBak))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(pictureSpineBak, pictureSpinePath, true);
|
||||||
|
restoredCount++;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (restoredCount == 0)
|
||||||
|
{
|
||||||
|
return (true, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true, $"ツクールMZ Spine修復パッチを元に戻しました(復元ファイル数: {restoredCount})");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
private static bool PatchPackageJson(string path)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(path, Encoding.UTF8);
|
||||||
|
if (!content.Contains("--disable-devtools"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bakPath = path + BackupSuffix;
|
||||||
|
if (!File.Exists(bakPath))
|
||||||
|
{
|
||||||
|
File.Copy(path, bakPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string updated = content.Replace("--disable-devtools", string.Empty);
|
||||||
|
updated = updated.Replace(" ", " ");
|
||||||
|
File.WriteAllText(path, updated, new UTF8Encoding(true));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PatchPixiJs(string path)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(path, Encoding.UTF8);
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
|
var bakPath = path + BackupSuffix;
|
||||||
|
if (!File.Exists(bakPath))
|
||||||
|
{
|
||||||
|
File.Copy(path, bakPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// A. AbstractBatchRenderer.prototype.render
|
||||||
|
if (content.Contains("if (!element._texture.valid) {"))
|
||||||
|
{
|
||||||
|
content = content.Replace("if (!element._texture.valid) {", "if (!element || !element._texture || !element._texture.valid) {");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// B. SpriteMaskFilter.prototype.apply
|
||||||
|
if (content.Contains("var maskSprite = this.maskSprite;\n\t var tex = maskSprite._texture;\n\t if (!tex.valid) {"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"var maskSprite = this.maskSprite;\n\t var tex = maskSprite._texture;\n\t if (!tex.valid) {",
|
||||||
|
"var maskSprite = this.maskSprite;\n\t var tex = maskSprite ? maskSprite._texture : null;\n\t if (!tex || !tex.valid) {");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("var maskSprite = this.maskSprite;\r\n\t var tex = maskSprite._texture;\r\n\t if (!tex.valid) {"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"var maskSprite = this.maskSprite;\r\n\t var tex = maskSprite._texture;\r\n\t if (!tex.valid) {",
|
||||||
|
"var maskSprite = this.maskSprite;\r\n\t var tex = maskSprite ? maskSprite._texture : null;\r\n\t if (!tex || !tex.valid) {");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// C. Texture constructor
|
||||||
|
if (content.Contains("if (!baseTexture.valid) {\n\t baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (!baseTexture.valid) {\n\t baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);",
|
||||||
|
"if (!baseTexture || !baseTexture.valid) {\n\t if (baseTexture) baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("if (!baseTexture.valid) {\r\n\t baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (!baseTexture.valid) {\r\n\t baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);",
|
||||||
|
"if (!baseTexture || !baseTexture.valid) {\r\n\t if (baseTexture) baseTexture.once('loaded', _this.onBaseTextureUpdated, _this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// D. Texture.prototype.onBaseTextureUpdated
|
||||||
|
if (content.Contains("if (!this.baseTexture.valid) {"))
|
||||||
|
{
|
||||||
|
content = content.Replace("if (!this.baseTexture.valid) {", "if (!this.baseTexture || !this.baseTexture.valid) {");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// E. Graphics
|
||||||
|
if (content.Contains("if (fill && !fill.texture.baseTexture.valid)"))
|
||||||
|
{
|
||||||
|
content = content.Replace("if (fill && !fill.texture.baseTexture.valid)", "if (fill && (!fill.texture || !fill.texture.baseTexture || !fill.texture.baseTexture.valid))");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
if (content.Contains("if (line && !line.texture.baseTexture.valid)"))
|
||||||
|
{
|
||||||
|
content = content.Replace("if (line && !line.texture.baseTexture.valid)", "if (line && (!line.texture || !line.texture.baseTexture || !line.texture.baseTexture.valid))");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// F. Sprite.prototype texture setter
|
||||||
|
if (content.Contains("if (value.baseTexture.valid) {\n\t this._onTextureUpdate();\n\t }\n\t else {\n\t value.once('update', this._onTextureUpdate, this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (value.baseTexture.valid) {\n\t this._onTextureUpdate();\n\t }\n\t else {\n\t value.once('update', this._onTextureUpdate, this);",
|
||||||
|
"if (value.baseTexture && value.baseTexture.valid) {\n\t this._onTextureUpdate();\n\t }\n\t else if (value.baseTexture) {\n\t value.once('update', this._onTextureUpdate, this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("if (value.baseTexture.valid) {\r\n\t this._onTextureUpdate();\r\n\t }\r\n\t else {\r\n\t value.once('update', this._onTextureUpdate, this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (value.baseTexture.valid) {\r\n\t this._onTextureUpdate();\r\n\t }\r\n\t else {\r\n\t value.once('update', this._onTextureUpdate, this);",
|
||||||
|
"if (value.baseTexture && value.baseTexture.valid) {\r\n\t this._onTextureUpdate();\r\n\t }\r\n\t else if (value.baseTexture) {\r\n\t value.once('update', this._onTextureUpdate, this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// H. Texture constructor: baseTexture null safety (Cannot read property 'on' of null)
|
||||||
|
if (content.Contains("if (baseTexture instanceof Texture) {\n\t baseTexture = baseTexture.baseTexture;\n\t }"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (baseTexture instanceof Texture) {\n\t baseTexture = baseTexture.baseTexture;\n\t }",
|
||||||
|
"if (baseTexture instanceof Texture) {\n\t baseTexture = baseTexture.baseTexture;\n\t }\n\t if (!baseTexture) {\n\t baseTexture = new BaseTexture();\n\t }");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("if (baseTexture instanceof Texture) {\r\n\t baseTexture = baseTexture.baseTexture;\r\n\t }"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (baseTexture instanceof Texture) {\r\n\t baseTexture = baseTexture.baseTexture;\r\n\t }",
|
||||||
|
"if (baseTexture instanceof Texture) {\r\n\t baseTexture = baseTexture.baseTexture;\r\n\t }\r\n\t if (!baseTexture) {\r\n\t baseTexture = new BaseTexture();\r\n\t }");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// I. Texture constructor: noFrame on update safety
|
||||||
|
if (content.Contains("if (_this.noFrame) {\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\n\t }"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (_this.noFrame) {\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\n\t }",
|
||||||
|
"if (_this.noFrame && baseTexture) {\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\n\t }");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("if (_this.noFrame) {\r\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\r\n\t }"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (_this.noFrame) {\r\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\r\n\t }",
|
||||||
|
"if (_this.noFrame && baseTexture) {\r\n\t baseTexture.on('update', _this.onBaseTextureUpdated, _this);\r\n\t }");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// G. Mesh.prototype texture setter
|
||||||
|
if (content.Contains("if (value.baseTexture.valid) {\n\t this.textureUpdated();\n\t }\n\t else {\n\t value.once('update', this.textureUpdated, this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (value.baseTexture.valid) {\n\t this.textureUpdated();\n\t }\n\t else {\n\t value.once('update', this.textureUpdated, this);",
|
||||||
|
"if (value && value.baseTexture && value.baseTexture.valid) {\n\t this.textureUpdated();\n\t }\n\t else if (value && value.baseTexture) {\n\t value.once('update', this.textureUpdated, this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
else if (content.Contains("if (value.baseTexture.valid) {\r\n\t this.textureUpdated();\r\n\t }\r\n\t else {\r\n\t value.once('update', this.textureUpdated, this);"))
|
||||||
|
{
|
||||||
|
content = content.Replace(
|
||||||
|
"if (value.baseTexture.valid) {\r\n\t this.textureUpdated();\r\n\t }\r\n\t else {\r\n\t value.once('update', this.textureUpdated, this);",
|
||||||
|
"if (value && value.baseTexture && value.baseTexture.valid) {\r\n\t this.textureUpdated();\r\n\t }\r\n\t else if (value && value.baseTexture) {\r\n\t value.once('update', this.textureUpdated, this);");
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modified)
|
||||||
|
{
|
||||||
|
File.WriteAllText(path, content, new UTF8Encoding(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PatchPixiPictureJs(string path)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(path, Encoding.UTF8);
|
||||||
|
if (!content.Contains("if (!sprite.texture.valid) {"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bakPath = path + BackupSuffix;
|
||||||
|
if (!File.Exists(bakPath))
|
||||||
|
{
|
||||||
|
File.Copy(path, bakPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string updated = content.Replace("if (!sprite.texture.valid) {", "if (!sprite || !sprite.texture.valid) {");
|
||||||
|
File.WriteAllText(path, updated, new UTF8Encoding(true));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PatchPixiSpineJs(string path)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(path, Encoding.UTF8);
|
||||||
|
if (content.Contains(SpineFixMarker))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string updated = content;
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
|
const string setAnimReplacement =
|
||||||
|
"var animation = this.data.skeletonData.findAnimation(animationName);\n" +
|
||||||
|
" if (!animation) {\n" +
|
||||||
|
" animation = typeof __glResolveSpineAnim === \"function\" ? __glResolveSpineAnim(this, trackIndex, animationName) : null;\n" +
|
||||||
|
" if (!animation) {\n" +
|
||||||
|
" if (typeof console !== \"undefined\" && console.warn) { console.warn(\"[GameLauncher SpineFix] Animation not found, using empty:\", animationName, \"track:\", trackIndex); }\n" +
|
||||||
|
" return typeof this.setEmptyAnimation === \"function\" ? this.setEmptyAnimation(trackIndex, 0) : null;\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" return this.setAnimationWith(trackIndex, animation, loop);";
|
||||||
|
|
||||||
|
var setAnimRegex = new Regex(
|
||||||
|
@"(?:var|let|const)\s+animation\s*=\s*this\.data\.skeletonData\.findAnimation\(animationName\);\s*if\s*\(\s*(?:animation\s*==\s*null|!animation)\s*\)\s*\{?\s*throw\s+new\s+Error\([""']Animation not found:\s*[""']\s*\+\s*animationName\);\s*\}?\s*return\s+this\.setAnimationWith\(trackIndex,\s*animation,\s*loop\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
string afterSet = setAnimRegex.Replace(updated, _ => setAnimReplacement);
|
||||||
|
if (!string.Equals(afterSet, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterSet;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string addAnimReplacement =
|
||||||
|
"var animation = this.data.skeletonData.findAnimation(animationName);\n" +
|
||||||
|
" if (!animation) {\n" +
|
||||||
|
" animation = typeof __glResolveSpineAnim === \"function\" ? __glResolveSpineAnim(this, trackIndex, animationName) : null;\n" +
|
||||||
|
" if (!animation) {\n" +
|
||||||
|
" if (typeof console !== \"undefined\" && console.warn) { console.warn(\"[GameLauncher SpineFix] Animation not found, using empty:\", animationName, \"track:\", trackIndex); }\n" +
|
||||||
|
" return typeof this.addEmptyAnimation === \"function\" ? this.addEmptyAnimation(trackIndex, 0, delay) : null;\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" return this.addAnimationWith(trackIndex, animation, loop, delay);";
|
||||||
|
|
||||||
|
var addAnimRegex = new Regex(
|
||||||
|
@"(?:var|let|const)\s+animation\s*=\s*this\.data\.skeletonData\.findAnimation\(animationName\);\s*if\s*\(\s*(?:animation\s*==\s*null|!animation)\s*\)\s*\{?\s*throw\s+new\s+Error\([""']Animation not found:\s*[""']\s*\+\s*animationName\);\s*\}?\s*return\s+this\.addAnimationWith\(trackIndex,\s*animation,\s*loop,\s*delay\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
string afterAdd = addAnimRegex.Replace(updated, _ => addAnimReplacement);
|
||||||
|
if (!string.Equals(afterAdd, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterAdd;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string setMixReplacement =
|
||||||
|
"var from = this.skeletonData.findAnimation(fromName);\n" +
|
||||||
|
" if (!from) return;\n" +
|
||||||
|
" var to = this.skeletonData.findAnimation(toName);\n" +
|
||||||
|
" if (!to) return;\n" +
|
||||||
|
" this.setMixWith(from, to, duration);";
|
||||||
|
|
||||||
|
var setMixRegex = new Regex(
|
||||||
|
@"(?:var|let|const)\s+from\s*=\s*this\.skeletonData\.findAnimation\(fromName\);\s*if\s*\(\s*(?:from\s*==\s*null|!from)\s*\)\s*\{?\s*throw\s+new\s+Error\([""']Animation not found:\s*[""']\s*\+\s*fromName\);\s*\}?\s*(?:var|let|const)\s+to\s*=\s*this\.skeletonData\.findAnimation\(toName\);\s*if\s*\(\s*(?:to\s*==\s*null|!to)\s*\)\s*\{?\s*throw\s+new\s+Error\([""']Animation not found:\s*[""']\s*\+\s*toName\);\s*\}?\s*this\.setMixWith\(from,\s*to,\s*duration\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
string afterMix = setMixRegex.Replace(updated, _ => setMixReplacement);
|
||||||
|
if (!string.Equals(afterMix, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterMix;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modified)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bakPath = path + BackupSuffix;
|
||||||
|
if (!File.Exists(bakPath))
|
||||||
|
{
|
||||||
|
File.Copy(path, bakPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const string helperBlock =
|
||||||
|
SpineFixMarker + "\n" +
|
||||||
|
"function __glResolveSpineAnim(state, trackIndex, animationName) {\n" +
|
||||||
|
" try {\n" +
|
||||||
|
" var sd = state && state.data && state.data.skeletonData;\n" +
|
||||||
|
" var anims = sd && sd.animations;\n" +
|
||||||
|
" if (!Array.isArray(anims) || anims.length === 0) return null;\n" +
|
||||||
|
" var req = String(animationName == null ? \"\" : animationName);\n" +
|
||||||
|
" var alt = req.indexOf(\"chimpo\") >= 0 ? req.replace(/chimpo/g, \"chinpo\") : (req.indexOf(\"chinpo\") >= 0 ? req.replace(/chinpo/g, \"chimpo\") : \"\");\n" +
|
||||||
|
" var find = function (fn) {\n" +
|
||||||
|
" for (var i = 0; i < anims.length; i++) {\n" +
|
||||||
|
" if (anims[i] && fn(anims[i])) return anims[i];\n" +
|
||||||
|
" }\n" +
|
||||||
|
" return null;\n" +
|
||||||
|
" };\n" +
|
||||||
|
" var found = find(function (a) { return a.name === req || (alt && a.name === alt); })\n" +
|
||||||
|
" || find(function (a) { return typeof a.name === \"string\" && (a.name.endsWith(\"/\" + req) || (alt && a.name.endsWith(\"/\" + alt))); });\n" +
|
||||||
|
" if (found) return found;\n" +
|
||||||
|
" var isMainTrack = Number(trackIndex) === 0 || /idle/i.test(req);\n" +
|
||||||
|
" if (isMainTrack) {\n" +
|
||||||
|
" found = find(function (a) { return /(?:^|\\/)0_idle$/i.test(a.name); })\n" +
|
||||||
|
" || find(function (a) { return /(?:^|\\/)idle$/i.test(a.name); })\n" +
|
||||||
|
" || find(function (a) { return /idle/i.test(a.name); })\n" +
|
||||||
|
" || find(function (a) { return /^(?:0\\/|0_move\\/|0_)/i.test(a.name); });\n" +
|
||||||
|
" if (found) return found;\n" +
|
||||||
|
" }\n" +
|
||||||
|
" if (Number(trackIndex) === 1 || /^1_face/i.test(req)) {\n" +
|
||||||
|
" found = find(function (a) { return /(?:^|\\/)1_face_normal$/i.test(a.name); })\n" +
|
||||||
|
" || find(function (a) { return /(?:^|\\/)1_face_/i.test(a.name); });\n" +
|
||||||
|
" if (found) return found;\n" +
|
||||||
|
" }\n" +
|
||||||
|
" found = find(function (a) { return a.name === \"none\"; });\n" +
|
||||||
|
" if (found) return found;\n" +
|
||||||
|
" if (Number(trackIndex) === 0) return anims[0];\n" +
|
||||||
|
" } catch (e) {}\n" +
|
||||||
|
" return null;\n" +
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
string newline = content.Contains("\r\n") ? "\r\n" : "\n";
|
||||||
|
string normalizedHelper = helperBlock.Replace("\n", newline);
|
||||||
|
updated = normalizedHelper + updated;
|
||||||
|
|
||||||
|
File.WriteAllText(path, updated, new UTF8Encoding(true));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PatchPictureSpineJs(string path)
|
||||||
|
{
|
||||||
|
string content = File.ReadAllText(path, Encoding.UTF8);
|
||||||
|
if (content.Contains(SpineFixMarker))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string updated = content;
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
|
// 1. Game_Spine.setAnimation: velo_damage状態で通常立ち絵系アニメが指定された場合のスケルトン自動復旧
|
||||||
|
var setAnimRegex = new Regex(
|
||||||
|
@"setAnimation\s*\(\s*id\s*,\s*animations\s*,\s*\.\.\.args\s*\)\s*\{\s*\[id,\s*animations,\s*args\]\s*=\s*convars\(\s*\[id,\s*animations,\s*args\]\s*\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
const string setAnimReplacement =
|
||||||
|
"setAnimation(id, animations, ...args) {\n" +
|
||||||
|
" " + SpineFixMarker + "\n" +
|
||||||
|
" [id, animations, args] = convars([id, animations, args]);\n" +
|
||||||
|
" if (Number(id) === 0 && typeof this._skeleton === 'string' && /^velo_damage_\\d+$/.test(this._skeleton)) {\n" +
|
||||||
|
" let _firstAnim = Array.isArray(animations) ? animations[0] : animations;\n" +
|
||||||
|
" let _animBase = typeof _firstAnim === 'string' ? _firstAnim.split(/\\s*\\/\\s*/)[0].trim() : '';\n" +
|
||||||
|
" if (/^0_(?:idle|low|yoin|shy|talk|bind)/i.test(_animBase)) {\n" +
|
||||||
|
" let _targetSkel = (typeof $gameParty !== 'undefined' && $gameParty && $gameParty.members && $gameParty.members()[0] && $gameParty.members()[0].hp === 0) ? 'velo_hunou' : 'velo_normal';\n" +
|
||||||
|
" if (typeof Game_Spine !== 'undefined' && Game_Spine.fullName && Game_Spine.fullName(_targetSkel)) {\n" +
|
||||||
|
" this._skeleton = _targetSkel + '_' + Date.now();\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }";
|
||||||
|
|
||||||
|
string afterSetAnim = setAnimRegex.Replace(updated, _ => setAnimReplacement);
|
||||||
|
if (!string.Equals(afterSetAnim, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterSetAnim;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1.5. Sprite_Spine.updateSkeleton: スケルトン切り替え破棄前に未発火のswitchイベントを完了させ、イベントループ停止を防止
|
||||||
|
var updateSkelRegex = new Regex(
|
||||||
|
@"updateSkeleton\s*\(\s*spine\s*\)\s*\{\s*if\s*\(\s*spine\s*\)\s*\{\s*if\s*\(\s*spine\.skeleton\s*!=\s*this\._skeleton\s*\)\s*\{\s*this\.init\(\s*\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
const string updateSkelReplacement =
|
||||||
|
"updateSkeleton(spine) {\n" +
|
||||||
|
" if (spine) {\n" +
|
||||||
|
" if (spine.skeleton != this._skeleton) {\n" +
|
||||||
|
" try {\n" +
|
||||||
|
" if (this._data && this._data.state && Array.isArray(this._data.state.tracks) && typeof $gameSwitches !== 'undefined') {\n" +
|
||||||
|
" for (let _glEntry of this._data.state.tracks) {\n" +
|
||||||
|
" if (!_glEntry || !_glEntry.animation || !Array.isArray(_glEntry.animation.timelines)) continue;\n" +
|
||||||
|
" for (let _glTl of _glEntry.animation.timelines) {\n" +
|
||||||
|
" if (!_glTl || !Array.isArray(_glTl.events) || !_glTl.frames || typeof _glTl.frames.length !== 'number') continue;\n" +
|
||||||
|
" for (let _glIdx = 0; _glIdx < _glTl.events.length; _glIdx++) {\n" +
|
||||||
|
" if (_glTl.frames[_glIdx] < _glEntry.trackTime) continue;\n" +
|
||||||
|
" let _glEv = _glTl.events[_glIdx];\n" +
|
||||||
|
" let _glStr = _glEv && _glEv.stringValue;\n" +
|
||||||
|
" if (!_glStr) continue;\n" +
|
||||||
|
" for (let _glTok of String(_glStr).replace(/ +/, '').split(/,/)) {\n" +
|
||||||
|
" if (_glTok.match(/^([!~]?)switch:(\\d+)$/i)) {\n" +
|
||||||
|
" let _glType = RegExp.$1.replace('!', 'off').replace('~', 'reverse') || 'on';\n" +
|
||||||
|
" let _glSwId = Number(RegExp.$2);\n" +
|
||||||
|
" let _glVal = _glType == 'on' ? true : _glType == 'off' ? false : !$gameSwitches.value(_glSwId);\n" +
|
||||||
|
" $gameSwitches.setValue(_glSwId, _glVal);\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" } catch (_glErr) {}\n" +
|
||||||
|
" this.init();";
|
||||||
|
|
||||||
|
string afterUpdateSkel = updateSkelRegex.Replace(updated, _ => updateSkelReplacement);
|
||||||
|
if (!string.Equals(afterUpdateSkel, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterUpdateSkel;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. updateSkin: findSkin null安全化
|
||||||
|
var skinRegex = new Regex(
|
||||||
|
@"skin\.addSkin\(\s*this\._data\.skeleton\.data\.findSkin\(\s*name\s*\)\s*\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
const string skinReplacement =
|
||||||
|
"let _glSkin = this._data.skeleton.data.findSkin(name);\n" +
|
||||||
|
" if (_glSkin) skin.addSkin(_glSkin);";
|
||||||
|
|
||||||
|
string afterSkin = skinRegex.Replace(updated, _ => skinReplacement);
|
||||||
|
if (!string.Equals(afterSkin, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterSkin;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. updateAnimation: entry null安全化
|
||||||
|
var entryRegex = new Regex(
|
||||||
|
@"entry\.timeScale\s*=\s*animation\.timeScale;\s*entry\.alpha\s*=\s*animation\.alpha;\s*entry\.plainAlpha\s*=\s*animation\.alpha;\s*spine\.setPlayData\(\s*entry\s*\);",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
const string entryReplacement =
|
||||||
|
"if (entry) {\n" +
|
||||||
|
" entry.timeScale = animation.timeScale;\n" +
|
||||||
|
" entry.alpha = animation.alpha;\n" +
|
||||||
|
" entry.plainAlpha = animation.alpha;\n" +
|
||||||
|
" spine.setPlayData(entry);\n" +
|
||||||
|
" }";
|
||||||
|
|
||||||
|
string afterEntry = entryRegex.Replace(updated, _ => entryReplacement);
|
||||||
|
if (!string.Equals(afterEntry, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterEntry;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. restoreAnimation: animations.find(...).duration および entry の null安全化
|
||||||
|
var restoreRegex = new Regex(
|
||||||
|
@"data\.trackTime\s*%=\s*this\._data\.spineData\.animations\.find\(\s*animation\s*=>\s*animation\.name\s*==\s*data\.name\s*\)\.duration;",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
const string restoreReplacement =
|
||||||
|
"let _glAnim = this._data.spineData.animations.find(animation => animation.name == data.name);\n" +
|
||||||
|
" data.trackTime = (_glAnim && _glAnim.duration) ? (data.trackTime % _glAnim.duration) : 0;";
|
||||||
|
|
||||||
|
string afterRestore = restoreRegex.Replace(updated, _ => restoreReplacement);
|
||||||
|
if (!string.Equals(afterRestore, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterRestore;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var restoreEntryRegex = new Regex(
|
||||||
|
@"(entry\s*=\s*this\._data\.state\.(?:setAnimation|addAnimation)\([^;]+\);)\s*(entry\.alpha\s*=)",
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
string afterRestoreEntry = restoreEntryRegex.Replace(updated, "$1\n if (!entry) break;\n $2");
|
||||||
|
if (!string.Equals(afterRestoreEntry, updated, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
updated = afterRestoreEntry;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modified)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bakPath = path + BackupSuffix;
|
||||||
|
if (!File.Exists(bakPath))
|
||||||
|
{
|
||||||
|
File.Copy(path, bakPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(path, updated, new UTF8Encoding(true));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,618 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using GameLauncher.Helpers;
|
||||||
|
|
||||||
|
namespace GameLauncher.Engines.Tkool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ツクールMV/MZ等のゲームリソース(画像・音声・スクリプト等)における
|
||||||
|
/// URLエンコード名、文字化け、機種依存文字(丸数字等)の不整合を、
|
||||||
|
/// 「実際のゲームコード・データで使われているファイル名」と照合して並列かつ超高速に自動修復するサービス。
|
||||||
|
///
|
||||||
|
/// 設計方針:
|
||||||
|
/// - コード主導のピンポイント照合:
|
||||||
|
/// 1. data/*.json や plugins.js 等のゲームコード・定義データから要求リソース名を並列抽出。
|
||||||
|
/// 2. コード側が要求しているのにディスク上に存在しないファイル名(例: エロステ_ページ②.png)を特定。
|
||||||
|
/// 3. ディスク上の類似ファイル(エロステ_ページ2.png や URLデコード名)から要求通りのファイルを作成。
|
||||||
|
/// - マルチスレッド並列処理:
|
||||||
|
/// ・Parallel.ForEach による CPU コア全開の超高速走査・チェック・リンク生成。
|
||||||
|
/// - 独立ログファイル出力:
|
||||||
|
/// ・Logs フォルダ内に詳細ログファイル(ResourceRepair_*.log)を出力し、
|
||||||
|
/// ランチャー画面上のテキストボックス肥大化によるUIフリーズを完全防止。
|
||||||
|
/// </summary>
|
||||||
|
public class TkoolResourceRepairService
|
||||||
|
{
|
||||||
|
[DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
|
private static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes);
|
||||||
|
|
||||||
|
/// <summary>修復完了キャッシュマーカーファイル名</summary>
|
||||||
|
public const string RepairMarkerFileName = ".gl_resource_repaired";
|
||||||
|
|
||||||
|
private static bool _encodingProviderRegistered;
|
||||||
|
|
||||||
|
// 丸数字マッピング (①: U+2460 〜 ⑳: U+2473)
|
||||||
|
private static readonly string[] CircleNumbers =
|
||||||
|
[
|
||||||
|
"①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩",
|
||||||
|
"⑪", "⑫", "⑬", "⑭", "⑮", "⑯", "⑰", "⑱", "⑲", "⑳"
|
||||||
|
];
|
||||||
|
|
||||||
|
// 全角数字マッピング (0: U+FF10 〜 9: U+FF19)
|
||||||
|
private static readonly string[] FullWidthNumbers =
|
||||||
|
[
|
||||||
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||||
|
];
|
||||||
|
|
||||||
|
public TkoolResourceRepairService()
|
||||||
|
{
|
||||||
|
EnsureEncodingProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureEncodingProvider()
|
||||||
|
{
|
||||||
|
if (!_encodingProviderRegistered)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
_encodingProviderRegistered = true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修復処理のリアルタイム進捗情報
|
||||||
|
/// </summary>
|
||||||
|
public record RepairProgress(int Current, int Total, int RepairedCount, string CurrentStatus);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修復処理の結果情報
|
||||||
|
/// </summary>
|
||||||
|
public record RepairResult(bool Success, int RepairedCount, int CleanedCount, long ElapsedMilliseconds, string Message, string LogFilePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ログファイルの保存先ディレクトリを取得します。
|
||||||
|
/// </summary>
|
||||||
|
public static string GetLogsDirectory()
|
||||||
|
{
|
||||||
|
var exeDir = AppPathHelper.GetExeDirectory();
|
||||||
|
var logsDir = Path.Combine(exeDir, "Logs");
|
||||||
|
if (!Directory.Exists(logsDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(logsDir);
|
||||||
|
}
|
||||||
|
return logsDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定したツクールゲームのリソースファイルを非同期・並列で修復します(UIをブロックしません)。
|
||||||
|
/// </summary>
|
||||||
|
public Task<RepairResult> RepairGameResourcesAsync(
|
||||||
|
TkoolGameItem game,
|
||||||
|
bool forceRescan = false,
|
||||||
|
IProgress<RepairProgress>? progress = null,
|
||||||
|
Action<string>? uiLogCallback = null)
|
||||||
|
{
|
||||||
|
return Task.Run(() => this.RepairGameResources(game, forceRescan, progress, uiLogCallback));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定したツクールゲームのリソースファイルを並列走査・コード照合修復します。
|
||||||
|
/// </summary>
|
||||||
|
public RepairResult RepairGameResources(
|
||||||
|
TkoolGameItem game,
|
||||||
|
bool forceRescan = false,
|
||||||
|
IProgress<RepairProgress>? progress = null,
|
||||||
|
Action<string>? uiLogCallback = null)
|
||||||
|
{
|
||||||
|
if (game == null)
|
||||||
|
{
|
||||||
|
return new RepairResult(false, 0, 0, 0, "対象ゲームが指定されていません。", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
// ログファイルの初期化
|
||||||
|
var logsDir = GetLogsDirectory();
|
||||||
|
var safeGameName = Regex.Replace(game.FolderName ?? game.Title ?? "Game", @"[\\/:*?""<>|]", "_");
|
||||||
|
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
|
var logFilePath = Path.Combine(logsDir, $"ResourceRepair_{safeGameName}_{timestamp}.log");
|
||||||
|
|
||||||
|
var logLines = new ConcurrentBag<string>();
|
||||||
|
void FileLog(string message)
|
||||||
|
{
|
||||||
|
logLines.Add($"[{DateTime.Now:HH:mm:ss.fff}] {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileLog($"=== ゲームリソース高速並列修復開始 ===");
|
||||||
|
FileLog($"ゲーム名: {game.Title}");
|
||||||
|
FileLog($"ルートフォルダ: {game.RootDirectory}");
|
||||||
|
FileLog($"並列CPUコア数: {Environment.ProcessorCount}");
|
||||||
|
|
||||||
|
uiLogCallback?.Invoke($"[リソース修復] {game.Title}: ゲームコードとの並列照合を開始します...");
|
||||||
|
progress?.Report(new RepairProgress(0, 100, 0, "ゲームコード・データを収集中..."));
|
||||||
|
|
||||||
|
var targetDirs = this.CollectResourceDirectories(game);
|
||||||
|
if (targetDirs.Count == 0)
|
||||||
|
{
|
||||||
|
sw.Stop();
|
||||||
|
var msg = "修復対象のリソースディレクトリが見つかりませんでした。";
|
||||||
|
FileLog(msg);
|
||||||
|
this.WriteLogFile(logFilePath, logLines);
|
||||||
|
uiLogCallback?.Invoke($"[リソース修復] {msg}");
|
||||||
|
return new RepairResult(true, 0, 0, sw.ElapsedMilliseconds, msg, logFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// ステップ 1: ゲームデータ (data/*.json, js/*.js) から要求リソース名を並列抽出
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
FileLog("ステップ 1: data フォルダ内の JSON およびスクリプトから、コード上で実際に使用されているリソース名を並列抽出中...");
|
||||||
|
var requestedNames = this.ExtractRequestedResourceNamesFromCode(game, FileLog);
|
||||||
|
FileLog($"ステップ 1 完了: コード上で使われているリソース識別子を {requestedNames.Count} 件抽出しました。");
|
||||||
|
progress?.Report(new RepairProgress(20, 100, 0, $"コードリソース抽出完了 ({requestedNames.Count}件)"));
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// ステップ 2: 素材フォルダ (img, audio 等) の実ファイルを並列収集
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
FileLog("ステップ 2: 素材フォルダ (img, audio 等) の全ファイルを並列収集・分類中...");
|
||||||
|
var resourceFiles = new ConcurrentBag<string>();
|
||||||
|
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount };
|
||||||
|
|
||||||
|
Parallel.ForEach(targetDirs, parallelOptions, dir =>
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(dir)) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var f in Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(f);
|
||||||
|
if (!string.Equals(name, RepairMarkerFileName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
resourceFiles.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FileLog($"[警告] 一覧取得例外: {dir} ({ex.Message})");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var allFilesList = resourceFiles.ToList();
|
||||||
|
FileLog($"ステップ 2 完了: 素材ファイルを合計 {allFilesList.Count} 件検出しました。");
|
||||||
|
progress?.Report(new RepairProgress(40, 100, 0, $"素材ファイル収集完了 ({allFilesList.Count}件)"));
|
||||||
|
|
||||||
|
int repairedCount = 0;
|
||||||
|
int cleanedCount = 0;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// ステップ 3: 過去の破損ファイル (%と丸数字の混在) の並列クリーンアップ
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
Parallel.ForEach(allFilesList, parallelOptions, filePath =>
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(filePath);
|
||||||
|
if (fileName.Contains('%') && this.ContainsCircleNumber(fileName))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
System.Threading.Interlocked.Increment(ref cleanedCount);
|
||||||
|
FileLog($"[不正ファイル削除] {fileName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// ステップ 4: パーセントエンコードされたファイル名の安全完全デコード (並列)
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
FileLog("ステップ 4: URLエンコードされたファイル名の完全デコードと日本語リンク作成中 (並列)...");
|
||||||
|
var newlyDecodedFiles = new ConcurrentBag<string>();
|
||||||
|
Parallel.ForEach(allFilesList, parallelOptions, filePath =>
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(filePath);
|
||||||
|
if (fileName.Contains('%'))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var unescaped = this.FullyUnescapeString(fileName);
|
||||||
|
if (!string.Equals(unescaped, fileName, StringComparison.Ordinal) && !unescaped.Contains('%'))
|
||||||
|
{
|
||||||
|
var dirPath = Path.GetDirectoryName(filePath);
|
||||||
|
if (!string.IsNullOrEmpty(dirPath))
|
||||||
|
{
|
||||||
|
var unescapedPath = Path.Combine(dirPath, unescaped);
|
||||||
|
if (!File.Exists(unescapedPath))
|
||||||
|
{
|
||||||
|
if (this.CreateLinkOrCopy(filePath, unescapedPath))
|
||||||
|
{
|
||||||
|
System.Threading.Interlocked.Increment(ref repairedCount);
|
||||||
|
newlyDecodedFiles.Add(unescapedPath);
|
||||||
|
FileLog($"[URLデコード作成] {fileName} -> {unescaped}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ステップ4で新しく作成されたファイルも素材リストに合流
|
||||||
|
if (!newlyDecodedFiles.IsEmpty)
|
||||||
|
{
|
||||||
|
allFilesList.AddRange(newlyDecodedFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
progress?.Report(new RepairProgress(70, 100, repairedCount, "コード上のファイル名と実素材の照合中..."));
|
||||||
|
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
// ステップ 5: コード上で要求されているファイル名と実素材の照合・表記揺れ解決 (並列)
|
||||||
|
// -------------------------------------------------------------
|
||||||
|
FileLog("ステップ 5: コード上で要求されているファイル名(丸数字など)と実素材の表記揺れ照合中 (並列)...");
|
||||||
|
|
||||||
|
// ディレクトリごとに実ファイル名辞書を作成(高速ルックアップ用)
|
||||||
|
var dirFilesMap = allFilesList
|
||||||
|
.GroupBy(f => Path.GetDirectoryName(f) ?? string.Empty)
|
||||||
|
.ToDictionary(g => g.Key, g => g.Select(p => Path.GetFileName(p)).ToHashSet(StringComparer.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
// ディレクトリごとに実ファイルの正規化キー辞書を作成(重複キーによるArgumentException例外を安全に回避)
|
||||||
|
var dirNormalizedMap = allFilesList
|
||||||
|
.GroupBy(f => Path.GetDirectoryName(f) ?? string.Empty)
|
||||||
|
.ToDictionary(g => g.Key, g =>
|
||||||
|
{
|
||||||
|
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
foreach (var p in g)
|
||||||
|
{
|
||||||
|
var key = this.NormalizeFuzzyKey(Path.GetFileNameWithoutExtension(p));
|
||||||
|
if (!dict.ContainsKey(key))
|
||||||
|
{
|
||||||
|
dict[key] = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
});
|
||||||
|
|
||||||
|
// コードで要求されている各リソース名について照合
|
||||||
|
Parallel.ForEach(requestedNames, parallelOptions, reqName =>
|
||||||
|
{
|
||||||
|
var reqExt = Path.GetExtension(reqName);
|
||||||
|
var reqNameNoExt = string.IsNullOrEmpty(reqExt) ? reqName : Path.GetFileNameWithoutExtension(reqName);
|
||||||
|
var normalizedReq = this.NormalizeFuzzyKey(reqNameNoExt);
|
||||||
|
|
||||||
|
foreach (var (dirPath, fileSet) in dirFilesMap)
|
||||||
|
{
|
||||||
|
// 拡張子がある場合とない場合(.png を補完)を検討
|
||||||
|
var extensionsToCheck = string.IsNullOrEmpty(reqExt)
|
||||||
|
? new[] { ".png", ".ogg", ".m4a" }
|
||||||
|
: [reqExt];
|
||||||
|
|
||||||
|
foreach (var ext in extensionsToCheck)
|
||||||
|
{
|
||||||
|
var expectedFileName = reqNameNoExt + ext;
|
||||||
|
|
||||||
|
// すでにその名前が存在していれば修復不要
|
||||||
|
if (fileSet.Contains(expectedFileName)) continue;
|
||||||
|
|
||||||
|
// ディレクトリ内に正規化キーが一致する実ファイルがあるか探す
|
||||||
|
if (dirNormalizedMap.TryGetValue(dirPath, out var normDict) &&
|
||||||
|
normDict.TryGetValue(normalizedReq, out var existingFilePath))
|
||||||
|
{
|
||||||
|
var existingExt = Path.GetExtension(existingFilePath);
|
||||||
|
if (string.Equals(existingExt, ext, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var targetPath = Path.Combine(dirPath, expectedFileName);
|
||||||
|
if (!File.Exists(targetPath))
|
||||||
|
{
|
||||||
|
if (this.CreateLinkOrCopy(existingFilePath, targetPath))
|
||||||
|
{
|
||||||
|
System.Threading.Interlocked.Increment(ref repairedCount);
|
||||||
|
FileLog($"[コード要求リソース修復] コード要求名: {expectedFileName} <- 実ファイル: {Path.GetFileName(existingFilePath)}");
|
||||||
|
lock (fileSet) { fileSet.Add(expectedFileName); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sw.Stop();
|
||||||
|
|
||||||
|
// ログファイルへの一括書き込み
|
||||||
|
FileLog($"=== 修復完了: 作成 {repairedCount} 件、クリーンアップ {cleanedCount} 件 (所要時間: {sw.ElapsedMilliseconds}ms) ===");
|
||||||
|
this.WriteLogFile(logFilePath, logLines);
|
||||||
|
|
||||||
|
var summaryMsg = $"リソース修復完了: コード要求照合により {repairedCount} 件作成、{cleanedCount} 件クリーンアップ (所要時間: {sw.ElapsedMilliseconds}ms)";
|
||||||
|
uiLogCallback?.Invoke($"[リソース修復] {summaryMsg}");
|
||||||
|
uiLogCallback?.Invoke($"[リソース修復] 詳細ログを出力しました: {logFilePath}");
|
||||||
|
|
||||||
|
progress?.Report(new RepairProgress(100, 100, repairedCount, "完了"));
|
||||||
|
|
||||||
|
return new RepairResult(true, repairedCount, cleanedCount, sw.ElapsedMilliseconds, summaryMsg, logFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ゲームの data/*.json および js/*.js からコード上で要求されているリソース名を並列抽出します。
|
||||||
|
/// </summary>
|
||||||
|
private HashSet<string> ExtractRequestedResourceNamesFromCode(TkoolGameItem game, Action<string> log)
|
||||||
|
{
|
||||||
|
var requested = new ConcurrentBag<string>();
|
||||||
|
var dataDirs = new List<string>();
|
||||||
|
|
||||||
|
// data フォルダおよび js フォルダの探索
|
||||||
|
var roots = new List<string>();
|
||||||
|
if (game.IsEvbExtracted && !string.IsNullOrEmpty(game.EvbExtractedDirPath) && Directory.Exists(game.EvbExtractedDirPath))
|
||||||
|
{
|
||||||
|
roots.Add(game.EvbExtractedDirPath);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(game.RootDirectory) && Directory.Exists(game.RootDirectory))
|
||||||
|
{
|
||||||
|
roots.Add(game.RootDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var r in roots)
|
||||||
|
{
|
||||||
|
var candidates = new[] { r, Path.Combine(r, "www") };
|
||||||
|
foreach (var c in candidates)
|
||||||
|
{
|
||||||
|
var dataPath = Path.Combine(c, "data");
|
||||||
|
if (Directory.Exists(dataPath) && !dataDirs.Contains(dataPath)) dataDirs.Add(dataPath);
|
||||||
|
|
||||||
|
var jsPath = Path.Combine(c, "js");
|
||||||
|
if (Directory.Exists(jsPath) && !dataDirs.Contains(jsPath)) dataDirs.Add(jsPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var textFiles = new List<string>();
|
||||||
|
foreach (var d in dataDirs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
textFiles.AddRange(Directory.GetFiles(d, "*.json", SearchOption.AllDirectories));
|
||||||
|
textFiles.AddRange(Directory.GetFiles(d, "*.js", SearchOption.AllDirectories));
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
log($"コード検査対象ファイル数: {textFiles.Count} 件 (並列抽出)");
|
||||||
|
|
||||||
|
var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount };
|
||||||
|
Parallel.ForEach(textFiles, parallelOptions, file =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var text = File.ReadAllText(file, Encoding.UTF8);
|
||||||
|
|
||||||
|
// JSON/JS文字列 "..." または '...' を抽出
|
||||||
|
var matches = Regex.Matches(text, @"""([^""\r\n]{1,80})""|'([^'\r\n]{1,80})'");
|
||||||
|
foreach (Match m in matches)
|
||||||
|
{
|
||||||
|
var val = (m.Groups[1].Success ? m.Groups[1].Value : m.Groups[2].Value).Trim();
|
||||||
|
// 素材名として意味のある文字列(日本語、丸数字、記号、拡張子付き等)を収集
|
||||||
|
if (this.IsPotentialResourceName(val))
|
||||||
|
{
|
||||||
|
requested.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HashSet<string>(requested, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列が画像・音声等のリソース名候補として適切か判定します。
|
||||||
|
/// </summary>
|
||||||
|
private bool IsPotentialResourceName(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text) || text.Length > 80) return false;
|
||||||
|
|
||||||
|
// システム予約語やJSON構文は除外
|
||||||
|
if (text == "true" || text == "false" || text == "null" || text == "undefined") return false;
|
||||||
|
if (text.StartsWith("{") || text.StartsWith("[")) return false;
|
||||||
|
|
||||||
|
// 拡張子を持つ、または日本語/丸数字を含む、または _ や - を含む識別子
|
||||||
|
if (text.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
text.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
text.EndsWith(".m4a", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 日本語・全角文字または丸数字を含む文字列(例: "エロステ_ページ②")
|
||||||
|
if (this.ContainsNonAscii(text) || this.ContainsCircleNumber(text))
|
||||||
|
{
|
||||||
|
// 空白のみや極端な記号列は除外
|
||||||
|
return !text.Contains("<") && !text.Contains(">");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 丸数字(①〜⑳)⇔ 通常数字(1〜20)および 全角数字 を正規化したファジーマッチ用キーを生成します。
|
||||||
|
/// </summary>
|
||||||
|
private string NormalizeFuzzyKey(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return string.Empty;
|
||||||
|
var res = text.Normalize(NormalizationForm.FormC).ToLowerInvariant();
|
||||||
|
|
||||||
|
// 丸数字 -> 通常数字
|
||||||
|
for (int i = 0; i < CircleNumbers.Length; i++)
|
||||||
|
{
|
||||||
|
res = res.Replace(CircleNumbers[i], (i + 1).ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全角数字 -> 半角数字
|
||||||
|
for (int i = 0; i < FullWidthNumbers.Length; i++)
|
||||||
|
{
|
||||||
|
res = res.Replace(FullWidthNumbers[i], i.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 波ダッシュ・チルダ
|
||||||
|
res = res.Replace('\u301C', '\uFF5E');
|
||||||
|
|
||||||
|
// 全角カッコ -> 半角カッコ
|
||||||
|
res = res.Replace('(', '(').Replace(')', ')');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 蓄積されたログ行をログファイルへ一括書き込みします。
|
||||||
|
/// </summary>
|
||||||
|
private void WriteLogFile(string path, IEnumerable<string> lines)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllLines(path, lines, new UTF8Encoding(true));
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パーセントエンコードされた文字列を100%完全にデコードします。
|
||||||
|
/// </summary>
|
||||||
|
private string FullyUnescapeString(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(input) || !input.Contains('%')) return input;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var unescaped = Uri.UnescapeDataString(input);
|
||||||
|
if (!unescaped.Contains('%')) return unescaped;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Regex.Replace(input, @"((?:%[0-9A-Fa-f]{2})+)", match =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var hexPart = match.Value;
|
||||||
|
var bytes = new List<byte>();
|
||||||
|
for (int i = 0; i < hexPart.Length; i += 3)
|
||||||
|
{
|
||||||
|
if (hexPart[i] == '%' && i + 2 < hexPart.Length)
|
||||||
|
{
|
||||||
|
bytes.Add(Convert.ToByte(hexPart.Substring(i + 1, 2), 16));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Encoding.UTF8.GetString([.. bytes]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return match.Value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 丸数字が含まれているか判定します。
|
||||||
|
/// </summary>
|
||||||
|
private bool ContainsCircleNumber(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return false;
|
||||||
|
foreach (var circle in CircleNumbers)
|
||||||
|
{
|
||||||
|
if (text.Contains(circle)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 非ASCII文字(全角文字・日本語等)が含まれているか判定します。
|
||||||
|
/// </summary>
|
||||||
|
private bool ContainsNonAscii(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return false;
|
||||||
|
foreach (char c in text)
|
||||||
|
{
|
||||||
|
if (c > 127) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ハードリンクを最優先で作成し、失敗した場合はファイルコピーを行います。
|
||||||
|
/// </summary>
|
||||||
|
private bool CreateLinkOrCopy(string sourceFile, string targetFile)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(targetFile)) return true;
|
||||||
|
|
||||||
|
if (CreateHardLink(targetFile, sourceFile, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Copy(sourceFile, targetFile, overwrite: false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修復対象となるリソースフォルダ一覧(img, audio, js, data等)を収集します。
|
||||||
|
/// </summary>
|
||||||
|
private List<string> CollectResourceDirectories(TkoolGameItem game)
|
||||||
|
{
|
||||||
|
var result = new List<string>();
|
||||||
|
var roots = new List<string>();
|
||||||
|
|
||||||
|
if (game.IsEvbExtracted && !string.IsNullOrEmpty(game.EvbExtractedDirPath) && Directory.Exists(game.EvbExtractedDirPath))
|
||||||
|
{
|
||||||
|
roots.Add(game.EvbExtractedDirPath);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(game.RootDirectory) && Directory.Exists(game.RootDirectory))
|
||||||
|
{
|
||||||
|
roots.Add(game.RootDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var root in roots)
|
||||||
|
{
|
||||||
|
var candidates = new[] { root, Path.Combine(root, "www"), Path.Combine(root, "package.nw") };
|
||||||
|
foreach (var baseDir in candidates)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(baseDir)) continue;
|
||||||
|
|
||||||
|
var subDirs = new[] { "img", "audio", "js", "data" };
|
||||||
|
foreach (var sub in subDirs)
|
||||||
|
{
|
||||||
|
var target = Path.Combine(baseDir, sub);
|
||||||
|
if (Directory.Exists(target) && !result.Contains(target))
|
||||||
|
{
|
||||||
|
result.Add(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,10 @@
|
|||||||
Unity,
|
Unity,
|
||||||
Wolf,
|
Wolf,
|
||||||
SrpgStudio,
|
SrpgStudio,
|
||||||
Evb
|
Evb,
|
||||||
|
Nwjs,
|
||||||
|
Bakin,
|
||||||
|
Other
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -25,6 +28,9 @@
|
|||||||
VXAce,
|
VXAce,
|
||||||
Wolf,
|
Wolf,
|
||||||
SrpgStudio,
|
SrpgStudio,
|
||||||
|
Nwjs,
|
||||||
|
Bakin,
|
||||||
|
Other,
|
||||||
Unknown
|
Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +55,8 @@
|
|||||||
FolderLastModifiedAsc = 3, // フォルダ更新日時 (古い順)
|
FolderLastModifiedAsc = 3, // フォルダ更新日時 (古い順)
|
||||||
TitleAsc = 4, // タイトル (昇順)
|
TitleAsc = 4, // タイトル (昇順)
|
||||||
TitleDesc = 5, // タイトル (降順)
|
TitleDesc = 5, // タイトル (降順)
|
||||||
FolderNameAsc = 6 // フォルダ名 (昇順)
|
FolderNameAsc = 6, // フォルダ名 (昇順)
|
||||||
|
BookmarkedFirst = 7 // ★ ブックマーク優先
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -21,22 +21,22 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>[Game]_Data ディレクトリ絶対パス</summary>
|
/// <summary>[Game]_Data ディレクトリ絶対パス</summary>
|
||||||
public string DataDirectoryPath
|
public string DataDirectoryPath
|
||||||
{
|
{
|
||||||
get => _dataDirectoryPath;
|
get => this._dataDirectoryPath;
|
||||||
set { if (_dataDirectoryPath != value) { _dataDirectoryPath = value; OnPropertyChanged(); } }
|
set { if (this._dataDirectoryPath != value) { this._dataDirectoryPath = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>app.info 由来の会社名/開発者名</summary>
|
/// <summary>app.info 由来の会社名/開発者名</summary>
|
||||||
public string CompanyName
|
public string CompanyName
|
||||||
{
|
{
|
||||||
get => _companyName;
|
get => this._companyName;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_companyName != value)
|
if (this._companyName != value)
|
||||||
{
|
{
|
||||||
_companyName = value;
|
this._companyName = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(RegistryPath));
|
this.OnPropertyChanged(nameof(this.RegistryPath));
|
||||||
OnPropertyChanged(nameof(LocalLowPath));
|
this.OnPropertyChanged(nameof(this.LocalLowPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,35 +44,35 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>app.info 由来の製品名</summary>
|
/// <summary>app.info 由来の製品名</summary>
|
||||||
public string ProductName
|
public string ProductName
|
||||||
{
|
{
|
||||||
get => _productName;
|
get => this._productName;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_productName != value)
|
if (this._productName != value)
|
||||||
{
|
{
|
||||||
_productName = value;
|
this._productName = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(RegistryPath));
|
this.OnPropertyChanged(nameof(this.RegistryPath));
|
||||||
OnPropertyChanged(nameof(LocalLowPath));
|
this.OnPropertyChanged(nameof(this.LocalLowPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsIL2CPP => BackendType == UnityBackendType.IL2CPP;
|
public override bool IsIL2CPP => this.BackendType == UnityBackendType.IL2CPP;
|
||||||
public override bool IsMono => BackendType == UnityBackendType.Mono;
|
public override bool IsMono => this.BackendType == UnityBackendType.Mono;
|
||||||
|
|
||||||
/// <summary>バックエンド形式 (IL2CPP / Mono)</summary>
|
/// <summary>バックエンド形式 (IL2CPP / Mono)</summary>
|
||||||
public UnityBackendType BackendType
|
public UnityBackendType BackendType
|
||||||
{
|
{
|
||||||
get => _backendType;
|
get => this._backendType;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_backendType != value)
|
if (this._backendType != value)
|
||||||
{
|
{
|
||||||
_backendType = value;
|
this._backendType = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(BackendBadgeText));
|
this.OnPropertyChanged(nameof(this.BackendBadgeText));
|
||||||
OnPropertyChanged(nameof(IsIL2CPP));
|
this.OnPropertyChanged(nameof(this.IsIL2CPP));
|
||||||
OnPropertyChanged(nameof(IsMono));
|
this.OnPropertyChanged(nameof(this.IsMono));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,15 +80,15 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>Unityバージョン文字列</summary>
|
/// <summary>Unityバージョン文字列</summary>
|
||||||
public override string UnityVersion
|
public override string UnityVersion
|
||||||
{
|
{
|
||||||
get => _unityVersion;
|
get => this._unityVersion;
|
||||||
set { if (_unityVersion != value) { _unityVersion = value; OnPropertyChanged(); } }
|
set { if (this._unityVersion != value) { this._unityVersion = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>セーブデータ(レジストリまたはファイル)が検出されたかどうか</summary>
|
/// <summary>セーブデータ(レジストリまたはファイル)が検出されたかどうか</summary>
|
||||||
public override bool HasSaveData
|
public override bool HasSaveData
|
||||||
{
|
{
|
||||||
get => _hasSaveData;
|
get => this._hasSaveData;
|
||||||
set { if (_hasSaveData != value) { _hasSaveData = value; OnPropertyChanged(); } }
|
set { if (this._hasSaveData != value) { this._hasSaveData = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -99,9 +99,9 @@ namespace GameLauncher.Engines.Unity
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(CompanyName) || string.IsNullOrEmpty(ProductName))
|
if (string.IsNullOrEmpty(this.CompanyName) || string.IsNullOrEmpty(this.ProductName))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return $@"Software\{CompanyName}\{ProductName}";
|
return $@"Software\{this.CompanyName}\{this.ProductName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,22 +113,28 @@ namespace GameLauncher.Engines.Unity
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(CompanyName) || string.IsNullOrEmpty(ProductName))
|
if (string.IsNullOrEmpty(this.CompanyName) || string.IsNullOrEmpty(this.ProductName))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
var appData = Path.GetDirectoryName(localAppData);
|
var appData = Path.GetDirectoryName(localAppData);
|
||||||
if (string.IsNullOrEmpty(appData)) return string.Empty;
|
if (string.IsNullOrEmpty(appData)) return string.Empty;
|
||||||
|
|
||||||
return Path.Combine(appData, "LocalLow", CompanyName, ProductName);
|
return Path.Combine(appData, "LocalLow", this.CompanyName, this.ProductName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string BackendBadgeText => BackendType switch
|
public override string BackendBadgeText => this.BackendType switch
|
||||||
{
|
{
|
||||||
UnityBackendType.IL2CPP => "IL2CPP",
|
UnityBackendType.IL2CPP => "IL2CPP",
|
||||||
UnityBackendType.Mono => "Mono",
|
UnityBackendType.Mono => "Mono",
|
||||||
_ => "Unity"
|
_ => "Unity"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// エンジン種別ラベル。Unityは専用バッジ(IL2CPP/Mono等)で表現するため空文字を返し、
|
||||||
|
/// エンジン種別ラベル自体は表示しません。
|
||||||
|
/// </summary>
|
||||||
|
public override string EngineLabelText => string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,35 +28,35 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>レジストリの生キー名(例: ClearedLevel_h1378399435)</summary>
|
/// <summary>レジストリの生キー名(例: ClearedLevel_h1378399435)</summary>
|
||||||
public string RawKey
|
public string RawKey
|
||||||
{
|
{
|
||||||
get => _rawKey;
|
get => this._rawKey;
|
||||||
set { if (_rawKey != value) { _rawKey = value; OnPropertyChanged(); } }
|
set { if (this._rawKey != value) { this._rawKey = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Unityのハッシュを除去した整形式キー名(例: ClearedLevel)</summary>
|
/// <summary>Unityのハッシュを除去した整形式キー名(例: ClearedLevel)</summary>
|
||||||
public string CleanKey
|
public string CleanKey
|
||||||
{
|
{
|
||||||
get => _cleanKey;
|
get => this._cleanKey;
|
||||||
set { if (_cleanKey != value) { _cleanKey = value; OnPropertyChanged(); } }
|
set { if (this._cleanKey != value) { this._cleanKey = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>値のデータ型</summary>
|
/// <summary>値のデータ型</summary>
|
||||||
public PlayerPrefsType Type
|
public PlayerPrefsType Type
|
||||||
{
|
{
|
||||||
get => _type;
|
get => this._type;
|
||||||
set { if (_type != value) { _type = value; OnPropertyChanged(); OnPropertyChanged(nameof(TypeDisplay)); } }
|
set { if (this._type != value) { this._type = value; this.OnPropertyChanged(); this.OnPropertyChanged(nameof(this.TypeDisplay)); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>実際の値(int, float, string, byte[])</summary>
|
/// <summary>実際の値(int, float, string, byte[])</summary>
|
||||||
public object? Value
|
public object? Value
|
||||||
{
|
{
|
||||||
get => _value;
|
get => this._value;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!Equals(_value, value))
|
if (!Equals(this._value, value))
|
||||||
{
|
{
|
||||||
_value = value;
|
this._value = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
UpdateEditValue();
|
this.UpdateEditValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,15 +64,15 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>UI表示・編集用の文字列値</summary>
|
/// <summary>UI表示・編集用の文字列値</summary>
|
||||||
public string EditValue
|
public string EditValue
|
||||||
{
|
{
|
||||||
get => _editValue;
|
get => this._editValue;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_editValue != value)
|
if (this._editValue != value)
|
||||||
{
|
{
|
||||||
_editValue = value;
|
this._editValue = value;
|
||||||
_isModified = true;
|
this._isModified = true;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(IsModified));
|
this.OnPropertyChanged(nameof(this.IsModified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ namespace GameLauncher.Engines.Unity
|
|||||||
/// <summary>値が変更されたかどうか</summary>
|
/// <summary>値が変更されたかどうか</summary>
|
||||||
public bool IsModified
|
public bool IsModified
|
||||||
{
|
{
|
||||||
get => _isModified;
|
get => this._isModified;
|
||||||
set { if (_isModified != value) { _isModified = value; OnPropertyChanged(); } }
|
set { if (this._isModified != value) { this._isModified = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TypeDisplay => Type switch
|
public string TypeDisplay => this.Type switch
|
||||||
{
|
{
|
||||||
PlayerPrefsType.Int => "Int (数値)",
|
PlayerPrefsType.Int => "Int (数値)",
|
||||||
PlayerPrefsType.Float => "Float (小数)",
|
PlayerPrefsType.Float => "Float (小数)",
|
||||||
@@ -95,19 +95,19 @@ namespace GameLauncher.Engines.Unity
|
|||||||
|
|
||||||
private void UpdateEditValue()
|
private void UpdateEditValue()
|
||||||
{
|
{
|
||||||
if (_value == null)
|
if (this._value == null)
|
||||||
{
|
{
|
||||||
_editValue = string.Empty;
|
this._editValue = string.Empty;
|
||||||
}
|
}
|
||||||
else if (_value is byte[] bytes)
|
else if (this._value is byte[] bytes)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var text = System.Text.Encoding.UTF8.GetString(bytes).TrimEnd('\0');
|
var text = System.Text.Encoding.UTF8.GetString(bytes).TrimEnd('\0');
|
||||||
if (text.All(c => !char.IsControl(c) || c == '\r' || c == '\n' || c == '\t'))
|
if (text.All(c => !char.IsControl(c) || c == '\r' || c == '\n' || c == '\t'))
|
||||||
{
|
{
|
||||||
_editValue = text;
|
this._editValue = text;
|
||||||
_type = PlayerPrefsType.String;
|
this._type = PlayerPrefsType.String;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,21 +118,21 @@ namespace GameLauncher.Engines.Unity
|
|||||||
float f = BitConverter.ToSingle(bytes, 0);
|
float f = BitConverter.ToSingle(bytes, 0);
|
||||||
if (!float.IsNaN(f) && !float.IsInfinity(f))
|
if (!float.IsNaN(f) && !float.IsInfinity(f))
|
||||||
{
|
{
|
||||||
_editValue = f.ToString("G");
|
this._editValue = f.ToString("G");
|
||||||
_type = PlayerPrefsType.Float;
|
this._type = PlayerPrefsType.Float;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_editValue = BitConverter.ToString(bytes).Replace("-", " ");
|
this._editValue = BitConverter.ToString(bytes).Replace("-", " ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_editValue = _value.ToString() ?? string.Empty;
|
this._editValue = this._value.ToString() ?? string.Empty;
|
||||||
}
|
}
|
||||||
_isModified = false;
|
this._isModified = false;
|
||||||
OnPropertyChanged(nameof(EditValue));
|
this.OnPropertyChanged(nameof(this.EditValue));
|
||||||
OnPropertyChanged(nameof(IsModified));
|
this.OnPropertyChanged(nameof(this.IsModified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,13 +152,13 @@ namespace GameLauncher.Engines.Unity
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (FileSize < 1024) return $"{FileSize} B";
|
if (this.FileSize < 1024) return $"{this.FileSize} B";
|
||||||
if (FileSize < 1024 * 1024) return $"{FileSize / 1024.0:F1} KB";
|
if (this.FileSize < 1024 * 1024) return $"{this.FileSize / 1024.0:F1} KB";
|
||||||
return $"{FileSize / (1024.0 * 1024.0):F2} MB";
|
return $"{this.FileSize / (1024.0 * 1024.0):F2} MB";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LastModifiedDisplay => LastModified.ToString("yyyy/MM/dd HH:mm:ss");
|
public string LastModifiedDisplay => this.LastModified.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -172,6 +172,6 @@ namespace GameLauncher.Engines.Unity
|
|||||||
public string BackupType { get; set; } = string.Empty; // "Registry (.reg)" または "ファイル"
|
public string BackupType { get; set; } = string.Empty; // "Registry (.reg)" または "ファイル"
|
||||||
public string Note { get; set; } = string.Empty;
|
public string Note { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string TimestampDisplay => Timestamp.ToString("yyyy/MM/dd HH:mm:ss");
|
public string TimestampDisplay => this.Timestamp.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
// キー名昇順でソート
|
// キー名昇順でソート
|
||||||
return list.OrderBy(e => e.CleanKey, StringComparer.OrdinalIgnoreCase).ToList();
|
return [.. list.OrderBy(e => e.CleanKey, StringComparer.OrdinalIgnoreCase)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -319,7 +319,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
proc?.WaitForExit(3000);
|
proc?.WaitForExit(3000);
|
||||||
|
|
||||||
// JSONバックアップも併せて出力
|
// JSONバックアップも併せて出力
|
||||||
var entries = GetPlayerPrefs(registryPath);
|
var entries = this.GetPlayerPrefs(registryPath);
|
||||||
var jsonBackupFile = Path.Combine(backupDir, $"PlayerPrefs_{timestamp}.json");
|
var jsonBackupFile = Path.Combine(backupDir, $"PlayerPrefs_{timestamp}.json");
|
||||||
var serializableList = entries.Select(e => new
|
var serializableList = entries.Select(e => new
|
||||||
{
|
{
|
||||||
@@ -416,7 +416,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
FileSize = fi.Length,
|
FileSize = fi.Length,
|
||||||
LastModified = fi.LastWriteTime,
|
LastModified = fi.LastWriteTime,
|
||||||
LocationType = "LocalLow",
|
LocationType = "LocalLow",
|
||||||
IsTextOrJson = CheckIsTextOrJson(f)
|
IsTextOrJson = this.CheckIsTextOrJson(f)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,7 +429,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// ルート直下
|
// ルート直下
|
||||||
CollectCandidateFiles(game.RootDirectory, "ゲームフォルダ", list);
|
this.CollectCandidateFiles(game.RootDirectory, "ゲームフォルダ", list);
|
||||||
|
|
||||||
// Save / SaveData / saves / savedata サブフォルダ
|
// Save / SaveData / saves / savedata サブフォルダ
|
||||||
var subNames = new[] { "Save", "SaveData", "saves", "savedata", "Save_Data" };
|
var subNames = new[] { "Save", "SaveData", "saves", "savedata", "Save_Data" };
|
||||||
@@ -438,21 +438,21 @@ namespace GameLauncher.Engines.Unity
|
|||||||
var subPath = Path.Combine(game.RootDirectory, sub);
|
var subPath = Path.Combine(game.RootDirectory, sub);
|
||||||
if (Directory.Exists(subPath))
|
if (Directory.Exists(subPath))
|
||||||
{
|
{
|
||||||
CollectCandidateFiles(subPath, "ゲームフォルダ/" + sub, list, isStrict: false);
|
this.CollectCandidateFiles(subPath, "ゲームフォルダ/" + sub, list, isStrict: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dataフォルダ直下のセーブファイル候補
|
// Dataフォルダ直下のセーブファイル候補
|
||||||
if (!string.IsNullOrEmpty(game.DataDirectoryPath) && Directory.Exists(game.DataDirectoryPath))
|
if (!string.IsNullOrEmpty(game.DataDirectoryPath) && Directory.Exists(game.DataDirectoryPath))
|
||||||
{
|
{
|
||||||
CollectCandidateFiles(game.DataDirectoryPath, "Dataフォルダ", list);
|
this.CollectCandidateFiles(game.DataDirectoryPath, "Dataフォルダ", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新日時降順でソート
|
// 更新日時降順でソート
|
||||||
return list.OrderByDescending(f => f.LastModified).ToList();
|
return [.. list.OrderByDescending(f => f.LastModified)];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CollectCandidateFiles(string dir, string locationLabel, List<SaveFileEntry> list, bool isStrict = true)
|
private void CollectCandidateFiles(string dir, string locationLabel, List<SaveFileEntry> list, bool isStrict = true)
|
||||||
@@ -480,8 +480,9 @@ namespace GameLauncher.Engines.Unity
|
|||||||
if (isStrict)
|
if (isStrict)
|
||||||
{
|
{
|
||||||
// セーブファイル候補のフィルタ
|
// セーブファイル候補のフィルタ
|
||||||
|
// .sd / .es3 は Easy Save 3 の標準拡張子(0.sd, s.sd, h.sd などファイル名に "save" を含まない)
|
||||||
bool isCandidate = fileName.Contains("save", StringComparison.OrdinalIgnoreCase) ||
|
bool isCandidate = fileName.Contains("save", StringComparison.OrdinalIgnoreCase) ||
|
||||||
ext is ".sav" or ".save" or ".savegame" or ".dat";
|
ext is ".sav" or ".save" or ".savegame" or ".dat" or ".sd" or ".es3";
|
||||||
|
|
||||||
if (!isCandidate) continue;
|
if (!isCandidate) continue;
|
||||||
}
|
}
|
||||||
@@ -494,7 +495,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
FileSize = fi.Length,
|
FileSize = fi.Length,
|
||||||
LastModified = fi.LastWriteTime,
|
LastModified = fi.LastWriteTime,
|
||||||
LocationType = locationLabel,
|
LocationType = locationLabel,
|
||||||
IsTextOrJson = CheckIsTextOrJson(f)
|
IsTextOrJson = this.CheckIsTextOrJson(f)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,7 +650,7 @@ namespace GameLauncher.Engines.Unity
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
return list.OrderByDescending(b => b.Timestamp).ToList();
|
return [.. list.OrderByDescending(b => b.Timestamp)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
return (false, "ゲームのルートディレクトリが見つかりません。");
|
return (false, "ゲームのルートディレクトリが見つかりません。");
|
||||||
}
|
}
|
||||||
|
|
||||||
var extractorPath = ResolveExtractorPath(customExtractorPath);
|
var extractorPath = this.ResolveExtractorPath(customExtractorPath);
|
||||||
if (string.IsNullOrEmpty(extractorPath) || !File.Exists(extractorPath))
|
if (string.IsNullOrEmpty(extractorPath) || !File.Exists(extractorPath))
|
||||||
{
|
{
|
||||||
return (false, "Wolf RPG アーカイブ解凍ツール(UberWolfCli.exe / WolfDec.exe)が見つかりません。設定ダイアログからツールのパスを指定してください。");
|
return (false, "Wolf RPG アーカイブ解凍ツール(UberWolfCli.exe / WolfDec.exe)が見つかりません。設定ダイアログからツールのパスを指定してください。");
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 1. プロキシDLL本体の探索 (Tools\speedhack-i686\version.dll)
|
// 1. プロキシDLL本体の探索 (Tools\speedhack-i686\version.dll)
|
||||||
var sourceDllPath = ResolveProxyDllPath();
|
var sourceDllPath = this.ResolveProxyDllPath();
|
||||||
if (string.IsNullOrEmpty(sourceDllPath) || !File.Exists(sourceDllPath))
|
if (string.IsNullOrEmpty(sourceDllPath) || !File.Exists(sourceDllPath))
|
||||||
{
|
{
|
||||||
return (false, "プロキシDLL(Engines\\Wolf\\Tools\\speedhack-i686\\version.dll)が見つかりません。");
|
return (false, "プロキシDLL(Engines\\Wolf\\Tools\\speedhack-i686\\version.dll)が見つかりません。");
|
||||||
@@ -73,7 +73,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
File.Copy(sourceDllPath, targetDllPath, overwrite: true);
|
File.Copy(sourceDllPath, targetDllPath, overwrite: true);
|
||||||
|
|
||||||
// 4. speedhack_config.json の生成・書き込み
|
// 4. speedhack_config.json の生成・書き込み
|
||||||
var configContent = GenerateSpeedhackConfig(baseSpeed, toggleSpeed, holdSpeed);
|
var configContent = this.GenerateSpeedhackConfig(baseSpeed, toggleSpeed, holdSpeed);
|
||||||
File.WriteAllText(targetConfigPath, configContent, new UTF8Encoding(false));
|
File.WriteAllText(targetConfigPath, configContent, new UTF8Encoding(false));
|
||||||
|
|
||||||
game.WolfProxyDll = true;
|
game.WolfProxyDll = true;
|
||||||
@@ -138,7 +138,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
// 1. プロキシDLLの解除
|
// 1. プロキシDLLの解除
|
||||||
var (dllSuccess, dllMsg) = RemoveProxyDll(game);
|
var (dllSuccess, dllMsg) = this.RemoveProxyDll(game);
|
||||||
sb.AppendLine(dllMsg);
|
sb.AppendLine(dllMsg);
|
||||||
|
|
||||||
// 2. Game.exe バックアップからの復元(存在する場合)
|
// 2. Game.exe バックアップからの復元(存在する場合)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
return [.. result.Distinct(StringComparer.OrdinalIgnoreCase)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -186,7 +186,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
throw new FileNotFoundException($"セーブデータファイルが見つかりません: {filePath}");
|
throw new FileNotFoundException($"セーブデータファイルが見つかりません: {filePath}");
|
||||||
|
|
||||||
byte[] rawBytes = File.ReadAllBytes(filePath);
|
byte[] rawBytes = File.ReadAllBytes(filePath);
|
||||||
byte[] decrypted = Decrypt(rawBytes);
|
byte[] decrypted = this.Decrypt(rawBytes);
|
||||||
|
|
||||||
var result = new WolfSaveData
|
var result = new WolfSaveData
|
||||||
{
|
{
|
||||||
@@ -217,10 +217,10 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
}
|
}
|
||||||
|
|
||||||
// セーブデータ内の全文字列スキャン
|
// セーブデータ内の全文字列スキャン
|
||||||
ScanStrings(result, decrypted, enc);
|
this.ScanStrings(result, decrypted, enc);
|
||||||
|
|
||||||
// セーブデータ内の通常変数スキャン
|
// セーブデータ内の通常変数スキャン
|
||||||
ScanVariables(result, decrypted);
|
this.ScanVariables(result, decrypted);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -293,7 +293,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
throw new InvalidOperationException("保存対象のデータが空です。");
|
throw new InvalidOperationException("保存対象のデータが空です。");
|
||||||
|
|
||||||
// 1. バックアップ作成 (Backups フォルダへ)
|
// 1. バックアップ作成 (Backups フォルダへ)
|
||||||
string? backupPath = BackupSaveFile(model.FilePath, folderName, rootDirectory);
|
string? backupPath = this.BackupSaveFile(model.FilePath, folderName, rootDirectory);
|
||||||
|
|
||||||
// 2. 変数・項目の変更を RawDecryptedBytes に書き戻し
|
// 2. 変数・項目の変更を RawDecryptedBytes に書き戻し
|
||||||
foreach (var item in model.Variables)
|
foreach (var item in model.Variables)
|
||||||
@@ -306,7 +306,7 @@ namespace GameLauncher.Engines.Wolf
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. 暗号化 & チェックサム再計算
|
// 3. 暗号化 & チェックサム再計算
|
||||||
byte[] encrypted = Encrypt(model.RawDecryptedBytes);
|
byte[] encrypted = this.Encrypt(model.RawDecryptedBytes);
|
||||||
|
|
||||||
// 4. アトミック書き込み
|
// 4. アトミック書き込み
|
||||||
string tempFile = model.FilePath + ".tmp_" + Guid.NewGuid().ToString("N");
|
string tempFile = model.FilePath + ".tmp_" + Guid.NewGuid().ToString("N");
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||||
<DebugType>embedded</DebugType>
|
<DebugType>embedded</DebugType>
|
||||||
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -24,7 +25,6 @@
|
|||||||
<None Remove="Engines\Nwjs\Tools\speedhack-i686\hid.dll" />
|
<None Remove="Engines\Nwjs\Tools\speedhack-i686\hid.dll" />
|
||||||
<None Remove="Engines\Nwjs\Tools\speedhack-i686\version.dll" />
|
<None Remove="Engines\Nwjs\Tools\speedhack-i686\version.dll" />
|
||||||
<None Remove="plugins\AlwaysMaxHpMp.js" />
|
<None Remove="plugins\AlwaysMaxHpMp.js" />
|
||||||
<None Remove="plugins\GameLauncher_StandaloneMod.js" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
<Solution>
|
<Solution>
|
||||||
<Project Path="GameLauncher.csproj" />
|
<Project Path="GameLauncher.csproj" />
|
||||||
</Solution>
|
</Solution>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace GameLauncher.Helpers
|
namespace GameLauncher.Helpers
|
||||||
@@ -157,6 +157,24 @@ namespace GameLauncher.Helpers
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// サムネイル画像キャッシュの格納ルートディレクトリを取得します。
|
||||||
|
/// GameLauncher.exe のあるフォルダ直下の「Thumbnails」フォルダを使用・作成します。
|
||||||
|
/// </summary>
|
||||||
|
public static string GetThumbnailsDirectory()
|
||||||
|
{
|
||||||
|
var thumbDir = Path.Combine(GetExeDirectory(), "Thumbnails");
|
||||||
|
if (!Directory.Exists(thumbDir))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(thumbDir);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
return thumbDir;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unityセーブデータバックアップ全体の格納ルートディレクトリを取得します。
|
/// Unityセーブデータバックアップ全体の格納ルートディレクトリを取得します。
|
||||||
/// GameLauncher.exe のあるフォルダ直下の「Backups」フォルダを使用・作成します。
|
/// GameLauncher.exe のあるフォルダ直下の「Backups」フォルダを使用・作成します。
|
||||||
|
|||||||
+60
-1
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
@@ -108,4 +108,63 @@ namespace GameLauncher.Helpers
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列が null または空文字(空白のみ含む)の場合に Collapsed、文字が存在する場合に Visible を返すコンバーター
|
||||||
|
/// </summary>
|
||||||
|
public class StringNotEmptyToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public static readonly StringNotEmptyToVisibilityConverter Instance = new();
|
||||||
|
|
||||||
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is string s && !string.IsNullOrWhiteSpace(s))
|
||||||
|
{
|
||||||
|
return Visibility.Visible;
|
||||||
|
}
|
||||||
|
return Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// bool 値・bool? 値が true の場合に Visible、false または null の場合に Collapsed を返すコンバーター。
|
||||||
|
/// セーブエディタのセルテンプレートで、型ごとに表示するエディタを切り替える用途に使用します。
|
||||||
|
/// </summary>
|
||||||
|
public class BoolToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public static readonly BoolToVisibilityConverter Instance = new();
|
||||||
|
|
||||||
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return value is true ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return value is Visibility v && v == Visibility.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// bool値が true の場合に Visible、false または null の場合に Collapsed を返すコンバーター
|
||||||
|
/// </summary>
|
||||||
|
public class BooleanToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public static readonly BooleanToVisibilityConverter Instance = new();
|
||||||
|
|
||||||
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return value is true ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return value is Visibility v && v == Visibility.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+456
-413
File diff suppressed because it is too large.
Load diff
+1068
-558
File diff suppressed because it is too large.
Load diff
+211
-40
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -22,6 +22,7 @@ namespace GameLauncher.Models
|
|||||||
private ImageSource? _iconImage;
|
private ImageSource? _iconImage;
|
||||||
private DateTime? _lastLaunched;
|
private DateTime? _lastLaunched;
|
||||||
private DateTime? _folderLastModified;
|
private DateTime? _folderLastModified;
|
||||||
|
private bool _isBookmarked;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
@@ -33,51 +34,51 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>ゲームの表示タイトル</summary>
|
/// <summary>ゲームの表示タイトル</summary>
|
||||||
public string Title
|
public string Title
|
||||||
{
|
{
|
||||||
get => _title;
|
get => this._title;
|
||||||
set { if (_title != value) { _title = value; OnPropertyChanged(); } }
|
set { if (this._title != value) { this._title = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>フォルダ名</summary>
|
/// <summary>フォルダ名</summary>
|
||||||
public string FolderName
|
public string FolderName
|
||||||
{
|
{
|
||||||
get => _folderName;
|
get => this._folderName;
|
||||||
set { if (_folderName != value) { _folderName = value; OnPropertyChanged(); } }
|
set { if (this._folderName != value) { this._folderName = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>ゲームのルートディレクトリ絶対パス</summary>
|
/// <summary>ゲームのルートディレクトリ絶対パス</summary>
|
||||||
public string RootDirectory
|
public string RootDirectory
|
||||||
{
|
{
|
||||||
get => _rootDirectory;
|
get => this._rootDirectory;
|
||||||
set { if (_rootDirectory != value) { _rootDirectory = value; OnPropertyChanged(); } }
|
set { if (this._rootDirectory != value) { this._rootDirectory = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>ゲームの実行ファイル(.exe等)絶対パス</summary>
|
/// <summary>ゲームの実行ファイル(.exe等)絶対パス</summary>
|
||||||
public string ExecutablePath
|
public string ExecutablePath
|
||||||
{
|
{
|
||||||
get => _executablePath;
|
get => this._executablePath;
|
||||||
set { if (_executablePath != value) { _executablePath = value; OnPropertyChanged(); } }
|
set { if (this._executablePath != value) { this._executablePath = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>アプリアイコン画像</summary>
|
/// <summary>アプリアイコン画像</summary>
|
||||||
public ImageSource? IconImage
|
public ImageSource? IconImage
|
||||||
{
|
{
|
||||||
get => _iconImage;
|
get => this._iconImage;
|
||||||
set { if (_iconImage != value) { _iconImage = value; OnPropertyChanged(); } }
|
set { if (this._iconImage != value) { this._iconImage = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>ランチャーからの最終起動日時</summary>
|
/// <summary>ランチャーからの最終起動日時</summary>
|
||||||
public DateTime? LastLaunched
|
public DateTime? LastLaunched
|
||||||
{
|
{
|
||||||
get => _lastLaunched;
|
get => this._lastLaunched;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_lastLaunched != value)
|
if (this._lastLaunched != value)
|
||||||
{
|
{
|
||||||
_lastLaunched = value;
|
this._lastLaunched = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(LastLaunchedDisplay));
|
this.OnPropertyChanged(nameof(this.LastLaunchedDisplay));
|
||||||
OnPropertyChanged(nameof(LastLaunchedCardDisplay));
|
this.OnPropertyChanged(nameof(this.LastLaunchedCardDisplay));
|
||||||
OnPropertyChanged(nameof(LastLaunchedDetailDisplay));
|
this.OnPropertyChanged(nameof(this.LastLaunchedDetailDisplay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,51 +86,111 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>フォルダ更新日時</summary>
|
/// <summary>フォルダ更新日時</summary>
|
||||||
public DateTime? FolderLastModified
|
public DateTime? FolderLastModified
|
||||||
{
|
{
|
||||||
get => _folderLastModified;
|
get => this._folderLastModified;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_folderLastModified != value)
|
if (this._folderLastModified != value)
|
||||||
{
|
{
|
||||||
_folderLastModified = value;
|
this._folderLastModified = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(FolderLastModifiedDisplay));
|
this.OnPropertyChanged(nameof(this.FolderLastModifiedDisplay));
|
||||||
OnPropertyChanged(nameof(FolderLastModifiedCardDisplay));
|
this.OnPropertyChanged(nameof(this.FolderLastModifiedCardDisplay));
|
||||||
OnPropertyChanged(nameof(FolderLastModifiedDetailDisplay));
|
this.OnPropertyChanged(nameof(this.FolderLastModifiedDetailDisplay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>ユーザーによるブックマーク登録状態</summary>
|
||||||
|
public bool IsBookmarked
|
||||||
|
{
|
||||||
|
get => this._isBookmarked;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (this._isBookmarked != value)
|
||||||
|
{
|
||||||
|
this._isBookmarked = value;
|
||||||
|
this.OnPropertyChanged();
|
||||||
|
this.OnPropertyChanged(nameof(this.BookmarkIcon));
|
||||||
|
this.OnPropertyChanged(nameof(this.BookmarkTooltip));
|
||||||
|
this.OnPropertyChanged(nameof(this.BookmarkButtonText));
|
||||||
|
this.OnPropertyChanged(nameof(this.BookmarkBrush));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string BookmarkIcon => this._isBookmarked ? "★" : "☆";
|
||||||
|
public string BookmarkTooltip => this._isBookmarked ? "ブックマーク解除" : "ブックマークに追加";
|
||||||
|
public string BookmarkButtonText => this._isBookmarked ? "★ ブックマーク中" : "☆ ブックマーク";
|
||||||
|
public Brush BookmarkBrush => this._isBookmarked
|
||||||
|
? new SolidColorBrush(Color.FromRgb(0xFD, 0xCB, 0x6E))
|
||||||
|
: new SolidColorBrush(Color.FromArgb(0x88, 0xAA, 0xAA, 0xBB));
|
||||||
|
|
||||||
/// <summary>ゲームエンジンの種別</summary>
|
/// <summary>ゲームエンジンの種別</summary>
|
||||||
public abstract GameEngineKind EngineKind { get; }
|
public abstract GameEngineKind EngineKind { get; }
|
||||||
|
|
||||||
public bool IsTkoolOrTyrano => EngineKind is GameEngineKind.Tkool or GameEngineKind.Tyrano;
|
public bool IsTkoolOrTyrano => this.EngineKind is GameEngineKind.Tkool or GameEngineKind.Tyrano;
|
||||||
public bool IsUnity => EngineKind == GameEngineKind.Unity;
|
public bool IsUnity => this.EngineKind == GameEngineKind.Unity;
|
||||||
|
|
||||||
/// <summary>Enigma Virtual Box でパックされたゲームか</summary>
|
/// <summary>Enigma Virtual Box でパックされたゲームか</summary>
|
||||||
public virtual bool IsEvb => false;
|
public virtual bool IsEvb => false;
|
||||||
|
|
||||||
public string LastLaunchedDisplay => LastLaunched.HasValue
|
/// <summary>Enigma Virtual Box でパックされた exe を持つゲームかどうか</summary>
|
||||||
? LastLaunched.Value.ToString("yyyy/MM/dd HH:mm")
|
public virtual bool IsEvbPacked
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>EVB 解凍済みかどうか</summary>
|
||||||
|
public virtual bool IsEvbExtracted
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>EVB バッジの可視性(該当しなければ Collapsed)</summary>
|
||||||
|
public virtual Visibility EvbBadgeVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
|
/// <summary>EVB バッジのテキスト(該当しなければ空文字)</summary>
|
||||||
|
public virtual string EvbBadgeText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>EVB 要解凍バッジの可視性(該当しなければ Collapsed)</summary>
|
||||||
|
public virtual Visibility EvbNeedsUnpackVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
|
/// <summary>EVB 要解凍バッジのテキスト(該当しなければ空文字)</summary>
|
||||||
|
public virtual string EvbNeedsUnpackBadgeText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>EVB 解凍済みバッジの可視性(該当しなければ Collapsed)</summary>
|
||||||
|
public virtual Visibility EvbExtractedVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
|
/// <summary>EVB 解凍済みバッジのテキスト(該当しなければ空文字)</summary>
|
||||||
|
public virtual string EvbExtractedBadgeText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>EVB 詳細状態テキスト</summary>
|
||||||
|
public virtual string EvbDetailStatusText => string.Empty;
|
||||||
|
|
||||||
|
public string LastLaunchedDisplay => this.LastLaunched.HasValue
|
||||||
|
? this.LastLaunched.Value.ToString("yyyy/MM/dd HH:mm")
|
||||||
: "未起動";
|
: "未起動";
|
||||||
|
|
||||||
public string LastLaunchedCardDisplay => LastLaunched.HasValue
|
public string LastLaunchedCardDisplay => this.LastLaunched.HasValue
|
||||||
? $"▶ {LastLaunched.Value:yy/MM/dd HH:mm}"
|
? $"▶ {this.LastLaunched.Value:yy/MM/dd HH:mm}"
|
||||||
: "▶ 未起動";
|
: "▶ 未起動";
|
||||||
|
|
||||||
public string LastLaunchedDetailDisplay => LastLaunched.HasValue
|
public string LastLaunchedDetailDisplay => this.LastLaunched.HasValue
|
||||||
? LastLaunched.Value.ToString("yyyy/MM/dd HH:mm:ss")
|
? this.LastLaunched.Value.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
: "まだ起動されていません";
|
: "まだ起動されていません";
|
||||||
|
|
||||||
public string FolderLastModifiedDisplay => FolderLastModified.HasValue
|
public string FolderLastModifiedDisplay => this.FolderLastModified.HasValue
|
||||||
? FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm")
|
? this.FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm")
|
||||||
: "-";
|
: "-";
|
||||||
|
|
||||||
public string FolderLastModifiedCardDisplay => FolderLastModified.HasValue
|
public string FolderLastModifiedCardDisplay => this.FolderLastModified.HasValue
|
||||||
? $"📁 {FolderLastModified.Value:yy/MM/dd HH:mm}"
|
? $"📁 {this.FolderLastModified.Value:yy/MM/dd HH:mm}"
|
||||||
: "📁 -";
|
: "📁 -";
|
||||||
|
|
||||||
public string FolderLastModifiedDetailDisplay => FolderLastModified.HasValue
|
public string FolderLastModifiedDetailDisplay => this.FolderLastModified.HasValue
|
||||||
? FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm:ss")
|
? this.FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
: "不明";
|
: "不明";
|
||||||
|
|
||||||
// ================= バッジ・UIバインディング共通仮想プロパティ =================
|
// ================= バッジ・UIバインディング共通仮想プロパティ =================
|
||||||
@@ -157,6 +218,27 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>SRPG Studioか</summary>
|
/// <summary>SRPG Studioか</summary>
|
||||||
public virtual bool IsSrpgStudio => false;
|
public virtual bool IsSrpgStudio => false;
|
||||||
|
|
||||||
|
/// <summary>NW.js汎用ゲームか</summary>
|
||||||
|
public virtual bool IsNwjs => false;
|
||||||
|
|
||||||
|
/// <summary>RPG Developer Bakinか</summary>
|
||||||
|
public virtual bool IsBakin => false;
|
||||||
|
|
||||||
|
/// <summary>その他のゲームエンジンか</summary>
|
||||||
|
public virtual bool IsOther => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// エンジン種別ラベルの表示文字列。空文字の場合はラベル自体を表示しません。
|
||||||
|
/// (Unity等は該当しないため空、ツクール系は MV/MZ 等を返す)
|
||||||
|
/// </summary>
|
||||||
|
public virtual string EngineLabelText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>エンジン種別ラベルの背景色</summary>
|
||||||
|
public virtual Brush EngineLabelBackground => Brushes.Transparent;
|
||||||
|
|
||||||
|
/// <summary>その他バッジの可視性(該当しなければ Collapsed)</summary>
|
||||||
|
public virtual Visibility OtherBadgeVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
/// <summary>プリンセスシナジー(専用改造対象のMZゲーム)か</summary>
|
/// <summary>プリンセスシナジー(専用改造対象のMZゲーム)か</summary>
|
||||||
public virtual bool IsPrincessSynergy => false;
|
public virtual bool IsPrincessSynergy => false;
|
||||||
|
|
||||||
@@ -188,6 +270,18 @@ namespace GameLauncher.Models
|
|||||||
set { }
|
set { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>ウディタアーカイブバッジのテキスト(該当しなければ空文字)</summary>
|
||||||
|
public virtual string WolfArchiveBadgeText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>ウディタアーカイブバッジの背景色</summary>
|
||||||
|
public virtual Brush WolfArchiveBadgeBackground => Brushes.Transparent;
|
||||||
|
|
||||||
|
/// <summary>ウディタアーカイブバッジの可視性(該当しなければ Collapsed)</summary>
|
||||||
|
public virtual Visibility WolfArchiveBadgeVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
|
/// <summary>ウディタアーカイブ詳細状態テキスト</summary>
|
||||||
|
public virtual string WolfArchiveDetailStatusText => string.Empty;
|
||||||
|
|
||||||
/// <summary>SRPG Studioアーカイブ(data.dts)を持つか</summary>
|
/// <summary>SRPG Studioアーカイブ(data.dts)を持つか</summary>
|
||||||
public virtual bool HasSrpgArchive
|
public virtual bool HasSrpgArchive
|
||||||
{
|
{
|
||||||
@@ -226,6 +320,18 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>SRPG Studio詳細状態テキスト</summary>
|
/// <summary>SRPG Studio詳細状態テキスト</summary>
|
||||||
public virtual string SrpgDetailStatusText => string.Empty;
|
public virtual string SrpgDetailStatusText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>NW.jsバッジのテキスト</summary>
|
||||||
|
public virtual string NwjsBadgeText => string.Empty;
|
||||||
|
|
||||||
|
/// <summary>NW.jsバッジの背景色</summary>
|
||||||
|
public virtual Brush NwjsBadgeBackground => Brushes.Transparent;
|
||||||
|
|
||||||
|
/// <summary>NW.jsバッジの可視性</summary>
|
||||||
|
public virtual Visibility NwjsBadgeVisibility => Visibility.Collapsed;
|
||||||
|
|
||||||
|
/// <summary>NW.js詳細状態テキスト</summary>
|
||||||
|
public virtual string NwjsDetailStatusText => string.Empty;
|
||||||
|
|
||||||
/// <summary>Unity IL2CPPか</summary>
|
/// <summary>Unity IL2CPPか</summary>
|
||||||
public virtual bool IsIL2CPP => false;
|
public virtual bool IsIL2CPP => false;
|
||||||
|
|
||||||
@@ -248,7 +354,7 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>Unity LocalLowパス</summary>
|
/// <summary>Unity LocalLowパス</summary>
|
||||||
public virtual string LocalLowPath => string.Empty;
|
public virtual string LocalLowPath => string.Empty;
|
||||||
|
|
||||||
/// <summary>Unity セーブデータ検出フラグ</summary>
|
/// <summary>セーブデータ検出フラグ</summary>
|
||||||
public virtual bool HasSaveData
|
public virtual bool HasSaveData
|
||||||
{
|
{
|
||||||
get => false;
|
get => false;
|
||||||
@@ -301,5 +407,70 @@ namespace GameLauncher.Models
|
|||||||
get => _emptyPluginOptions;
|
get => _emptyPluginOptions;
|
||||||
set { }
|
set { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>共通プラグイン設定コレクション</summary>
|
||||||
|
public virtual ObservableCollection<ModPluginOptionItem> CommonPluginOptions
|
||||||
|
{
|
||||||
|
get => _emptyPluginOptions;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>固有ゲーム専用プラグイン設定コレクション</summary>
|
||||||
|
public virtual ObservableCollection<ModPluginOptionItem> SpecificPluginOptions
|
||||||
|
{
|
||||||
|
get => _emptyPluginOptions;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>固有ゲーム専用プラグインが存在するかどうか</summary>
|
||||||
|
public virtual bool HasSpecificPlugins => false;
|
||||||
|
|
||||||
|
/// <summary>プリンセスシナジー専用: HP常時MAX</summary>
|
||||||
|
public virtual bool PrincessAlwaysMaxHp
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>プリンセスシナジー専用: MP常時MAX</summary>
|
||||||
|
public virtual bool PrincessAlwaysMaxMp
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>ウディタ プロキシDLL適用フラグ</summary>
|
||||||
|
public virtual bool WolfProxyDll
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>SRPG Studio プロキシDLL適用フラグ</summary>
|
||||||
|
public virtual bool SrpgProxyDll
|
||||||
|
{
|
||||||
|
get => false;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>ツクールMZ専用: Pixi.jsエラー修復およびDevTools有効化フラグ(初期状態: true)</summary>
|
||||||
|
public virtual bool MzPixiErrorFix
|
||||||
|
{
|
||||||
|
get => true;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>ツクールMZ専用: Spineアニメーション未定義エラー(Animation not found: 0_idle 等)修復フラグ(初期状態: true)</summary>
|
||||||
|
public virtual bool MzSpineErrorFix
|
||||||
|
{
|
||||||
|
get => true;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// スクリプト改造(プラグイン注入など)が適用可能な状態かどうか。
|
||||||
|
/// 該当ゲームが改造非対応(ウディタ・SRPG・NW.js・その他・未解凍状態など)の場合は false を返し、
|
||||||
|
/// 右側パネルのスクリプト改造項目を非表示にします。
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool CanApplyScriptMod => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
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.Tkool;
|
||||||
@@ -40,6 +40,7 @@ namespace GameLauncher.Models
|
|||||||
public bool TkoolFilterAsarOnly { get; set; }
|
public bool TkoolFilterAsarOnly { get; set; }
|
||||||
public bool TkoolFilterRgssOnly { get; set; }
|
public bool TkoolFilterRgssOnly { get; set; }
|
||||||
public bool TkoolFilterAllRgss { get; set; }
|
public bool TkoolFilterAllRgss { get; set; }
|
||||||
|
public bool FilterBookmarkedOnly { get; set; }
|
||||||
public string UnityBackendFilter { get; set; } = "All";
|
public string UnityBackendFilter { get; set; } = "All";
|
||||||
public bool UnityFilterSaveOnly { get; set; }
|
public bool UnityFilterSaveOnly { get; set; }
|
||||||
}
|
}
|
||||||
@@ -56,8 +57,9 @@ namespace GameLauncher.Models
|
|||||||
if (x is not GameItemBase a || y is not GameItemBase b)
|
if (x is not GameItemBase a || y is not GameItemBase b)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return SortOrder switch
|
return this.SortOrder switch
|
||||||
{
|
{
|
||||||
|
GameSortOrder.BookmarkedFirst => CompareBookmarkedFirst(a, b),
|
||||||
GameSortOrder.LastLaunchedDesc => CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
GameSortOrder.LastLaunchedDesc => CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
||||||
GameSortOrder.LastLaunchedAsc => CompareNullableDateTimeAsc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
GameSortOrder.LastLaunchedAsc => CompareNullableDateTimeAsc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
|
||||||
GameSortOrder.FolderLastModifiedDesc => CompareNullableDateTimeDesc(a.FolderLastModified, b.FolderLastModified, a.Title, b.Title),
|
GameSortOrder.FolderLastModifiedDesc => CompareNullableDateTimeDesc(a.FolderLastModified, b.FolderLastModified, a.Title, b.Title),
|
||||||
@@ -69,6 +71,15 @@ namespace GameLauncher.Models
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int CompareBookmarkedFirst(GameItemBase a, GameItemBase b)
|
||||||
|
{
|
||||||
|
if (a.IsBookmarked != b.IsBookmarked)
|
||||||
|
{
|
||||||
|
return a.IsBookmarked ? -1 : 1;
|
||||||
|
}
|
||||||
|
return CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title);
|
||||||
|
}
|
||||||
|
|
||||||
private static int CompareNullableDateTimeDesc(DateTime? d1, DateTime? d2, string title1, string title2)
|
private static int CompareNullableDateTimeDesc(DateTime? d1, DateTime? d2, string title1, string title2)
|
||||||
{
|
{
|
||||||
if (d1.HasValue && d2.HasValue)
|
if (d1.HasValue && d2.HasValue)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -17,6 +17,18 @@ namespace GameLauncher.Models
|
|||||||
public string FileName { get; set; } = string.Empty; // ファイル名 (例: "BattleSpeedUp.js")
|
public string FileName { get; set; } = string.Empty; // ファイル名 (例: "BattleSpeedUp.js")
|
||||||
public string FilePath { get; set; } = string.Empty; // フルパス
|
public string FilePath { get; set; } = string.Empty; // フルパス
|
||||||
|
|
||||||
|
/// <summary>特定ゲーム専用プラグインかどうか</summary>
|
||||||
|
public bool IsGameSpecific { get; set; }
|
||||||
|
|
||||||
|
/// <summary>対象ゲーム識別子 (例: "PrincessSynergy")</summary>
|
||||||
|
public string TargetGameKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>表示用グループ名</summary>
|
||||||
|
public string GroupName { get; set; } = "共通機能";
|
||||||
|
|
||||||
|
/// <summary>初期チェックの既定値 (未設定時の初期値)</summary>
|
||||||
|
public bool DefaultEnabled { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// .js ファイルから定義情報を解析・生成します。
|
/// .js ファイルから定義情報を解析・生成します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,6 +50,17 @@ namespace GameLauncher.Models
|
|||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
string displayName = GetFriendlyName(id, desc);
|
string displayName = GetFriendlyName(id, desc);
|
||||||
|
bool isSpecific = id is "AlwaysMaxHp" or "AlwaysMaxMp";
|
||||||
|
string targetKey = isSpecific ? "PrincessSynergy" : string.Empty;
|
||||||
|
string groupName = isSpecific ? "固有ゲーム専用プラグイン" : "共通プラグイン";
|
||||||
|
bool defEnabled = id switch
|
||||||
|
{
|
||||||
|
"ShopMaxBuy" => false,
|
||||||
|
"AlwaysMaxHp" => false,
|
||||||
|
"AlwaysMaxMp" => false,
|
||||||
|
"SpineDebugTrace" => false,
|
||||||
|
_ => true
|
||||||
|
};
|
||||||
|
|
||||||
return new ModPluginDefinition
|
return new ModPluginDefinition
|
||||||
{
|
{
|
||||||
@@ -45,7 +68,11 @@ namespace GameLauncher.Models
|
|||||||
Name = displayName,
|
Name = displayName,
|
||||||
Description = desc,
|
Description = desc,
|
||||||
FileName = fileName,
|
FileName = fileName,
|
||||||
FilePath = filePath
|
FilePath = filePath,
|
||||||
|
IsGameSpecific = isSpecific,
|
||||||
|
TargetGameKey = targetKey,
|
||||||
|
GroupName = groupName,
|
||||||
|
DefaultEnabled = defEnabled
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +92,9 @@ namespace GameLauncher.Models
|
|||||||
"GoldGainMax" => "所持金増減時MAX (9999999G)",
|
"GoldGainMax" => "所持金増減時MAX (9999999G)",
|
||||||
"ExpGainMax" => "経験値獲得時MAX (一気にLv99)",
|
"ExpGainMax" => "経験値獲得時MAX (一気にLv99)",
|
||||||
"MessageInstant" => "メッセージ瞬間表示 (ウェイトスキップ)",
|
"MessageInstant" => "メッセージ瞬間表示 (ウェイトスキップ)",
|
||||||
|
"AlwaysMaxHp" => "HP常時MAX (プリンセスシナジー専用)",
|
||||||
|
"AlwaysMaxMp" => "MP常時MAX (プリンセスシナジー専用)",
|
||||||
|
"SpineDebugTrace" => "Spine診断ログ出力 (save/spine_debug_trace.log)",
|
||||||
_ => !string.IsNullOrEmpty(desc) ? $"{id} ({desc})" : id
|
_ => !string.IsNullOrEmpty(desc) ? $"{id} ({desc})" : id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -78,19 +108,21 @@ namespace GameLauncher.Models
|
|||||||
private bool _isEnabled = true;
|
private bool _isEnabled = true;
|
||||||
|
|
||||||
public ModPluginDefinition Definition { get; set; } = null!;
|
public ModPluginDefinition Definition { get; set; } = null!;
|
||||||
public string Id => Definition.Id;
|
public string Id => this.Definition.Id;
|
||||||
public string Name => Definition.Name;
|
public string Name => this.Definition.Name;
|
||||||
public string Description => Definition.Description;
|
public string Description => this.Definition.Description;
|
||||||
|
public string GroupName => this.Definition.GroupName;
|
||||||
|
public bool IsGameSpecific => this.Definition.IsGameSpecific;
|
||||||
|
|
||||||
public bool IsEnabled
|
public bool IsEnabled
|
||||||
{
|
{
|
||||||
get => _isEnabled;
|
get => this._isEnabled;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_isEnabled != value)
|
if (this._isEnabled != value)
|
||||||
{
|
{
|
||||||
_isEnabled = value;
|
this._isEnabled = value;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ namespace GameLauncher.Models
|
|||||||
private string _editValue = string.Empty;
|
private string _editValue = string.Empty;
|
||||||
private bool _isModified;
|
private bool _isModified;
|
||||||
private string _description = string.Empty;
|
private string _description = string.Empty;
|
||||||
|
private ValueKind _kind = ValueKind.Unknown;
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
@@ -26,36 +27,36 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>項目名(キー名、変数名)</summary>
|
/// <summary>項目名(キー名、変数名)</summary>
|
||||||
public string Key
|
public string Key
|
||||||
{
|
{
|
||||||
get => _key;
|
get => this._key;
|
||||||
set { if (_key != value) { _key = value; OnPropertyChanged(); } }
|
set { if (this._key != value) { this._key = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>分類・カテゴリ(セクション、オブジェクト名など)</summary>
|
/// <summary>分類・カテゴリ(セクション、オブジェクト名など)</summary>
|
||||||
public string Category
|
public string Category
|
||||||
{
|
{
|
||||||
get => _category;
|
get => this._category;
|
||||||
set { if (_category != value) { _category = value; OnPropertyChanged(); } }
|
set { if (this._category != value) { this._category = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>データ型(Int, Float, Bool, String など)</summary>
|
/// <summary>データ型(Int, Float, Bool, String など)</summary>
|
||||||
public string Type
|
public string Type
|
||||||
{
|
{
|
||||||
get => _type;
|
get => this._type;
|
||||||
set { if (_type != value) { _type = value; OnPropertyChanged(); } }
|
set { if (this._type != value) { this._type = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>GUI編集用の値文字列</summary>
|
/// <summary>GUI編集用の値文字列</summary>
|
||||||
public string EditValue
|
public string EditValue
|
||||||
{
|
{
|
||||||
get => _editValue;
|
get => this._editValue;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_editValue != value)
|
if (this._editValue != value)
|
||||||
{
|
{
|
||||||
_editValue = value;
|
this._editValue = value;
|
||||||
_isModified = true;
|
this._isModified = true;
|
||||||
OnPropertyChanged();
|
this.OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(IsModified));
|
this.OnPropertyChanged(nameof(this.IsModified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,18 +64,89 @@ namespace GameLauncher.Models
|
|||||||
/// <summary>値がユーザーによって変更されたかどうか</summary>
|
/// <summary>値がユーザーによって変更されたかどうか</summary>
|
||||||
public bool IsModified
|
public bool IsModified
|
||||||
{
|
{
|
||||||
get => _isModified;
|
get => this._isModified;
|
||||||
set { if (_isModified != value) { _isModified = value; OnPropertyChanged(); } }
|
set { if (this._isModified != value) { this._isModified = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>備考・説明・オフセット位置など</summary>
|
/// <summary>備考・説明・オフセット位置など</summary>
|
||||||
public string Description
|
public string Description
|
||||||
{
|
{
|
||||||
get => _description;
|
get => this._description;
|
||||||
set { if (_description != value) { _description = value; OnPropertyChanged(); } }
|
set { if (this._description != value) { this._description = value; this.OnPropertyChanged(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>内部保持用の生データや元データ(再エンコード用)</summary>
|
/// <summary>内部保持用の生データや元データ(再エンコード用)</summary>
|
||||||
public object? RawData { get; set; }
|
public object? RawData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 真偽値として編集できる項目かどうか。
|
||||||
|
/// </summary>
|
||||||
|
public bool IsBool => this._kind == ValueKind.Boolean;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数値(整数・小数)として編集できる項目かどうか。
|
||||||
|
/// </summary>
|
||||||
|
public bool IsNumeric => this._kind is ValueKind.Integer or ValueKind.Float or ValueKind.Enum;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列などテキスト入力で編集する項目かどうか。
|
||||||
|
/// </summary>
|
||||||
|
public bool IsStringLike => !this.IsBool && !this.IsNumeric;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 真偽値エディタ(チェックボックス)用の値。
|
||||||
|
/// 設定すると <see cref="EditValue"/> も "true"/"false" に同期します。
|
||||||
|
/// </summary>
|
||||||
|
public bool BoolValue
|
||||||
|
{
|
||||||
|
get => bool.TryParse(this._editValue, out var parsed) && parsed;
|
||||||
|
set => this.EditValue = value ? "true" : "false";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 値の種別。設定すると型別エディタの表示切り替えに反映されます。
|
||||||
|
/// </summary>
|
||||||
|
public ValueKind Kind
|
||||||
|
{
|
||||||
|
get => this._kind;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (this._kind != value)
|
||||||
|
{
|
||||||
|
this._kind = value;
|
||||||
|
this.OnPropertyChanged();
|
||||||
|
this.OnPropertyChanged(nameof(this.IsBool));
|
||||||
|
this.OnPropertyChanged(nameof(this.IsNumeric));
|
||||||
|
this.OnPropertyChanged(nameof(this.IsStringLike));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 値の種別(型別エディタの切り替え用)。
|
||||||
|
/// </summary>
|
||||||
|
public enum ValueKind
|
||||||
|
{
|
||||||
|
/// <summary>不明・未判定。</summary>
|
||||||
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>真偽値。</summary>
|
||||||
|
Boolean,
|
||||||
|
|
||||||
|
/// <summary>整数。</summary>
|
||||||
|
Integer,
|
||||||
|
|
||||||
|
/// <summary>浮動小数。</summary>
|
||||||
|
Float,
|
||||||
|
|
||||||
|
/// <summary>文字列。</summary>
|
||||||
|
String,
|
||||||
|
|
||||||
|
/// <summary>列挙体。</summary>
|
||||||
|
Enum,
|
||||||
|
|
||||||
|
/// <summary>配列・辞書・オブジェクトなど複合型。</summary>
|
||||||
|
Complex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# GameLauncher (ツクールMV・MZ・ティラノ & Unity 統合ゲームランチャー)
|
# GameLauncher (ツクールMV・MZ・ティラノ & Unity 統合ゲームランチャー)
|
||||||
|
|
||||||
RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製ゲームを1つの洗練された画面で一元管理・高速起動できる統合ランチャーです。
|
RPGツクール(MV・MZ)、ティラノスクリプト、およびUnity製ゲームを1つの洗練された画面で一元管理・高速起動できる統合ランチャーです。
|
||||||
従来の **TkoolLauncher** と **UnityLauncher** の全機能(スクリプト改造、ASAR解凍・復元、PlayerPrefsレジストリ編集、セーブファイル編集、バックアップ)が欠けることなく完全に統合されています。
|
従来の **TkoolLauncher** と **UnityLauncher** の全機能(スクリプト改造、ASAR解凍・復元、PlayerPrefsレジストリ編集、セーブファイル編集、バックアップ)が欠けることなく完全に統合されています。
|
||||||
|
|||||||
+50
-7
@@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="GameLauncher.SaveEditorWindow"
|
<Window x:Class="GameLauncher.SaveEditorWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
@@ -30,6 +30,9 @@
|
|||||||
<SolidColorBrush x:Key="AccentGreenHover" Color="#10D3AC"/>
|
<SolidColorBrush x:Key="AccentGreenHover" Color="#10D3AC"/>
|
||||||
<SolidColorBrush x:Key="AccentRed" Color="#D63031"/>
|
<SolidColorBrush x:Key="AccentRed" Color="#D63031"/>
|
||||||
|
|
||||||
|
<!-- 型別エディタの表示切り替え用コンバーター -->
|
||||||
|
<helpers:BoolToVisibilityConverter x:Key="BoolToVisibility"/>
|
||||||
|
|
||||||
<!-- ボタン標準スタイル -->
|
<!-- ボタン標準スタイル -->
|
||||||
<Style x:Key="ModernButton" TargetType="Button">
|
<Style x:Key="ModernButton" TargetType="Button">
|
||||||
<Setter Property="Background" Value="#2E2E3E"/>
|
<Setter Property="Background" Value="#2E2E3E"/>
|
||||||
@@ -396,13 +399,32 @@
|
|||||||
<!-- ================= 1. GUI セーブエディタ ================= -->
|
<!-- ================= 1. GUI セーブエディタ ================= -->
|
||||||
<Grid x:Name="pnlGuiEditor" Visibility="Collapsed">
|
<Grid x:Name="pnlGuiEditor" Visibility="Collapsed">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!-- パスワード/診断バー(暗号化セーブデータ用) -->
|
||||||
|
<Border x:Name="pnlPasswordBar" Grid.Row="0" Background="#1E1E2A" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" CornerRadius="6" Padding="10,8" Margin="0,0,0,8" Visibility="Collapsed">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Text="🔑 パスワード:" Foreground="{StaticResource TextSecondary}" FontSize="12" VerticalAlignment="Center" Margin="0,0,8,0"/>
|
||||||
|
<TextBox x:Name="txtPassword" Grid.Column="1" Background="#262636" BorderBrush="{StaticResource BorderBrushColor}"
|
||||||
|
BorderThickness="1" Padding="8,4" Foreground="{StaticResource TextPrimary}" FontSize="12"
|
||||||
|
VerticalAlignment="Center" KeyDown="txtPassword_KeyDown"/>
|
||||||
|
<Button x:Name="btnApplyPassword" Grid.Column="2" Style="{StaticResource PrimaryGreenButton}" Content="このパスワードで再読込" Margin="8,0,0,0" Click="btnApplyPassword_Click"/>
|
||||||
|
<Button x:Name="btnAutoDetectPassword" Grid.Column="3" Style="{StaticResource ModernButton}" Content="🔎 自動特定" Margin="6,0,0,0" Click="btnAutoDetectPassword_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<!-- 検索バー -->
|
<!-- 検索バー -->
|
||||||
<Border Grid.Row="0" Background="#1C1C26" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" CornerRadius="6" Padding="8,6" Margin="0,0,0,8">
|
<Border Grid.Row="1" Background="#1C1C26" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" CornerRadius="6" Padding="8,6" Margin="0,0,0,8">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="26"/>
|
<ColumnDefinition Width="26"/>
|
||||||
@@ -417,19 +439,40 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- プロパティ DataGrid -->
|
<!-- プロパティ DataGrid(型に応じたエディタを表示) -->
|
||||||
<DataGrid x:Name="dgGuiProperties" Grid.Row="1" SelectionChanged="dgGuiProperties_SelectionChanged">
|
<DataGrid x:Name="dgGuiProperties" Grid.Row="2" SelectionChanged="dgGuiProperties_SelectionChanged" AutoGenerateColumns="False" CanUserAddRows="False">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="分類" Binding="{Binding Category}" Width="120" IsReadOnly="True" Foreground="#A29BFE"/>
|
<DataGridTextColumn Header="分類" Binding="{Binding Category}" Width="120" IsReadOnly="True" Foreground="#A29BFE"/>
|
||||||
<DataGridTextColumn Header="変数名 (キー)" Binding="{Binding Key}" Width="2*" IsReadOnly="True" FontWeight="SemiBold"/>
|
<DataGridTextColumn Header="変数名 (キー)" Binding="{Binding Key}" Width="2*" IsReadOnly="True" FontWeight="SemiBold"/>
|
||||||
<DataGridTextColumn Header="型" Binding="{Binding Type}" Width="80" IsReadOnly="True" Foreground="{StaticResource TextSecondary}"/>
|
<DataGridTextColumn Header="型" Binding="{Binding Type}" Width="90" IsReadOnly="True" Foreground="{StaticResource TextSecondary}"/>
|
||||||
<DataGridTextColumn Header="値 (ダブルクリックで直接編集)" Binding="{Binding EditValue, UpdateSourceTrigger=PropertyChanged}" Width="2*"/>
|
<DataGridTemplateColumn Header="値 (型に応じて編集)" Width="2*">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid>
|
||||||
|
<!-- 真偽値: チェックボックス -->
|
||||||
|
<CheckBox IsChecked="{Binding BoolValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
Visibility="{Binding IsBool, Converter={StaticResource BoolToVisibility}}"/>
|
||||||
|
<!-- 数値: 上下ボタン付き -->
|
||||||
|
<TextBox Text="{Binding EditValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Visibility="{Binding IsNumeric, Converter={StaticResource BoolToVisibility}}"
|
||||||
|
Background="Transparent" BorderThickness="0"
|
||||||
|
Foreground="#A29BFE" VerticalAlignment="Center"/>
|
||||||
|
<!-- 文字列・その他: 通常テキスト -->
|
||||||
|
<TextBox Text="{Binding EditValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Visibility="{Binding IsStringLike, Converter={StaticResource BoolToVisibility}}"
|
||||||
|
Background="Transparent" BorderThickness="0"
|
||||||
|
Foreground="{StaticResource TextPrimary}" VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
<DataGridTextColumn Header="備考" Binding="{Binding Description}" Width="140" IsReadOnly="True" Foreground="{StaticResource TextSecondary}"/>
|
<DataGridTextColumn Header="備考" Binding="{Binding Description}" Width="140" IsReadOnly="True" Foreground="{StaticResource TextSecondary}"/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<!-- インライン編集バー -->
|
<!-- インライン編集バー -->
|
||||||
<Border Grid.Row="2" Background="#1E1E2A" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" CornerRadius="6" Padding="10,8" Margin="0,8,0,0">
|
<Border Grid.Row="3" Background="#1E1E2A" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" CornerRadius="6" Padding="10,8" Margin="0,8,0,0">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
|||||||
+296
-164
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -33,7 +33,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
// PlayerPrefs データ
|
// PlayerPrefs データ
|
||||||
private readonly ObservableCollection<PlayerPrefsEntry> _allPrefs = [];
|
private readonly ObservableCollection<PlayerPrefsEntry> _allPrefs = [];
|
||||||
private ListCollectionView _prefsView = null!;
|
private readonly ListCollectionView _prefsView = null!;
|
||||||
|
|
||||||
// ファイル一覧データ
|
// ファイル一覧データ
|
||||||
private readonly ObservableCollection<SaveFileEntry> _saveFiles = [];
|
private readonly ObservableCollection<SaveFileEntry> _saveFiles = [];
|
||||||
@@ -41,7 +41,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
// GUIセーブプロパティデータ
|
// GUIセーブプロパティデータ
|
||||||
private readonly ObservableCollection<SaveDataPropertyEntry> _guiProperties = [];
|
private readonly ObservableCollection<SaveDataPropertyEntry> _guiProperties = [];
|
||||||
private ListCollectionView _guiPropsView = null!;
|
private readonly ListCollectionView _guiPropsView = null!;
|
||||||
private ISaveDataCodec? _currentCodec;
|
private ISaveDataCodec? _currentCodec;
|
||||||
|
|
||||||
// バックアップ一覧データ
|
// バックアップ一覧データ
|
||||||
@@ -49,36 +49,36 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public SaveEditorWindow(UnityGameItem game)
|
public SaveEditorWindow(UnityGameItem game)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
Game = game;
|
this.Game = game;
|
||||||
|
|
||||||
lblGameTitle.Text = game.Title;
|
this.lblGameTitle.Text = game.Title;
|
||||||
lblGameInfo.Text = $"{game.CompanyName} / {game.ProductName} ({game.BackendBadgeText})";
|
this.lblGameInfo.Text = $"{game.CompanyName} / {game.ProductName} ({game.BackendBadgeText})";
|
||||||
|
|
||||||
// PlayerPrefs ビュー
|
// PlayerPrefs ビュー
|
||||||
_prefsView = (ListCollectionView)CollectionViewSource.GetDefaultView(_allPrefs);
|
this._prefsView = (ListCollectionView)CollectionViewSource.GetDefaultView(this._allPrefs);
|
||||||
_prefsView.Filter = FilterPrefs;
|
this._prefsView.Filter = this.FilterPrefs;
|
||||||
dgPlayerPrefs.ItemsSource = _prefsView;
|
this.dgPlayerPrefs.ItemsSource = this._prefsView;
|
||||||
|
|
||||||
// ファイル一覧
|
// ファイル一覧
|
||||||
lstSaveFiles.ItemsSource = _saveFiles;
|
this.lstSaveFiles.ItemsSource = this._saveFiles;
|
||||||
|
|
||||||
// GUI プロパティビュー
|
// GUI プロパティビュー
|
||||||
_guiPropsView = (ListCollectionView)CollectionViewSource.GetDefaultView(_guiProperties);
|
this._guiPropsView = (ListCollectionView)CollectionViewSource.GetDefaultView(this._guiProperties);
|
||||||
_guiPropsView.Filter = FilterGuiProperties;
|
this._guiPropsView.Filter = this.FilterGuiProperties;
|
||||||
dgGuiProperties.ItemsSource = _guiPropsView;
|
this.dgGuiProperties.ItemsSource = this._guiPropsView;
|
||||||
|
|
||||||
// バックアップ一覧
|
// バックアップ一覧
|
||||||
dgBackups.ItemsSource = _backups;
|
this.dgBackups.ItemsSource = this._backups;
|
||||||
|
|
||||||
Loaded += SaveEditorWindow_Loaded;
|
Loaded += this.SaveEditorWindow_Loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveEditorWindow_Loaded(object sender, RoutedEventArgs e)
|
private void SaveEditorWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ReloadPlayerPrefs();
|
this.ReloadPlayerPrefs();
|
||||||
ReloadSaveFiles();
|
this.ReloadSaveFiles();
|
||||||
ReloadBackups();
|
this.ReloadBackups();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@@ -87,26 +87,26 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public void ReloadPlayerPrefs()
|
public void ReloadPlayerPrefs()
|
||||||
{
|
{
|
||||||
_allPrefs.Clear();
|
this._allPrefs.Clear();
|
||||||
if (string.IsNullOrEmpty(Game.RegistryPath))
|
if (string.IsNullOrEmpty(this.Game.RegistryPath))
|
||||||
{
|
{
|
||||||
lblStatus.Text = "レジストリ情報が設定されていません (app.info が見つかりませんでした)";
|
this.lblStatus.Text = "レジストリ情報が設定されていません (app.info が見つかりませんでした)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entries = _saveService.GetPlayerPrefs(Game.RegistryPath);
|
var entries = this._saveService.GetPlayerPrefs(this.Game.RegistryPath);
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
_allPrefs.Add(entry);
|
this._allPrefs.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
lblStatus.Text = $"PlayerPrefs: {entries.Count} 件のキーを読み込みました (HKCU\\{Game.RegistryPath})";
|
this.lblStatus.Text = $"PlayerPrefs: {entries.Count} 件のキーを読み込みました (HKCU\\{this.Game.RegistryPath})";
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FilterPrefs(object obj)
|
private bool FilterPrefs(object obj)
|
||||||
{
|
{
|
||||||
if (obj is not PlayerPrefsEntry entry) return false;
|
if (obj is not PlayerPrefsEntry entry) return false;
|
||||||
var query = txtSearchPrefs.Text.Trim();
|
var query = this.txtSearchPrefs.Text.Trim();
|
||||||
if (string.IsNullOrEmpty(query)) return true;
|
if (string.IsNullOrEmpty(query)) return true;
|
||||||
|
|
||||||
return entry.CleanKey.Contains(query, StringComparison.OrdinalIgnoreCase) ||
|
return entry.CleanKey.Contains(query, StringComparison.OrdinalIgnoreCase) ||
|
||||||
@@ -116,26 +116,26 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void txtSearchPrefs_TextChanged(object sender, TextChangedEventArgs e)
|
private void txtSearchPrefs_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
_prefsView.Refresh();
|
this._prefsView.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dgPlayerPrefs_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void dgPlayerPrefs_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
if (this.dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
||||||
{
|
{
|
||||||
lblSelectedKeyName.Text = entry.CleanKey;
|
this.lblSelectedKeyName.Text = entry.CleanKey;
|
||||||
txtEditValueBar.Text = entry.EditValue;
|
this.txtEditValueBar.Text = entry.EditValue;
|
||||||
txtEditValueBar.IsEnabled = true;
|
this.txtEditValueBar.IsEnabled = true;
|
||||||
btnSaveCurrentPref.IsEnabled = true;
|
this.btnSaveCurrentPref.IsEnabled = true;
|
||||||
btnDeleteCurrentPref.IsEnabled = true;
|
this.btnDeleteCurrentPref.IsEnabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblSelectedKeyName.Text = "(なし)";
|
this.lblSelectedKeyName.Text = "(なし)";
|
||||||
txtEditValueBar.Text = string.Empty;
|
this.txtEditValueBar.Text = string.Empty;
|
||||||
txtEditValueBar.IsEnabled = false;
|
this.txtEditValueBar.IsEnabled = false;
|
||||||
btnSaveCurrentPref.IsEnabled = false;
|
this.btnSaveCurrentPref.IsEnabled = false;
|
||||||
btnDeleteCurrentPref.IsEnabled = false;
|
this.btnDeleteCurrentPref.IsEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,25 +143,25 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
SaveCurrentSelectedPref();
|
this.SaveCurrentSelectedPref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSaveCurrentPref_Click(object sender, RoutedEventArgs e)
|
private void btnSaveCurrentPref_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SaveCurrentSelectedPref();
|
this.SaveCurrentSelectedPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveCurrentSelectedPref()
|
private void SaveCurrentSelectedPref()
|
||||||
{
|
{
|
||||||
if (dgPlayerPrefs.SelectedItem is not PlayerPrefsEntry entry) return;
|
if (this.dgPlayerPrefs.SelectedItem is not PlayerPrefsEntry entry) return;
|
||||||
|
|
||||||
entry.EditValue = txtEditValueBar.Text;
|
entry.EditValue = this.txtEditValueBar.Text;
|
||||||
bool success = _saveService.SavePlayerPref(Game.RegistryPath, entry);
|
bool success = this._saveService.SavePlayerPref(this.Game.RegistryPath, entry);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
lblStatus.Text = $"キー '{entry.CleanKey}' の値を正常に更新しました。";
|
this.lblStatus.Text = $"キー '{entry.CleanKey}' の値を正常に更新しました。";
|
||||||
dgPlayerPrefs.Items.Refresh();
|
this.dgPlayerPrefs.Items.Refresh();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -172,16 +172,16 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnDeleteCurrentPref_Click(object sender, RoutedEventArgs e)
|
private void btnDeleteCurrentPref_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgPlayerPrefs.SelectedItem is not PlayerPrefsEntry entry) return;
|
if (this.dgPlayerPrefs.SelectedItem is not PlayerPrefsEntry entry) return;
|
||||||
|
|
||||||
var res = MessageBox.Show($"キー '{entry.CleanKey}' ({entry.RawKey}) をレジストリから削除しますか?",
|
var res = MessageBox.Show($"キー '{entry.CleanKey}' ({entry.RawKey}) をレジストリから削除しますか?",
|
||||||
"キー削除の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
"キー削除の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||||
if (res != MessageBoxResult.Yes) return;
|
if (res != MessageBoxResult.Yes) return;
|
||||||
|
|
||||||
if (_saveService.DeletePlayerPref(Game.RegistryPath, entry.RawKey))
|
if (this._saveService.DeletePlayerPref(this.Game.RegistryPath, entry.RawKey))
|
||||||
{
|
{
|
||||||
_allPrefs.Remove(entry);
|
this._allPrefs.Remove(entry);
|
||||||
lblStatus.Text = $"キー '{entry.CleanKey}' を削除しました。";
|
this.lblStatus.Text = $"キー '{entry.CleanKey}' を削除しました。";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -194,10 +194,10 @@ namespace GameLauncher
|
|||||||
var dlg = new AddKeyDialog { Owner = this };
|
var dlg = new AddKeyDialog { Owner = this };
|
||||||
if (dlg.ShowDialog() == true)
|
if (dlg.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
if (_saveService.AddPlayerPref(Game.RegistryPath, dlg.KeyName, dlg.KeyType, dlg.KeyValue, out string rawKey))
|
if (this._saveService.AddPlayerPref(this.Game.RegistryPath, dlg.KeyName, dlg.KeyType, dlg.KeyValue, out string rawKey))
|
||||||
{
|
{
|
||||||
ReloadPlayerPrefs();
|
this.ReloadPlayerPrefs();
|
||||||
lblStatus.Text = $"新規キー '{dlg.KeyName}' ({rawKey}) を追加しました。";
|
this.lblStatus.Text = $"新規キー '{dlg.KeyName}' ({rawKey}) を追加しました。";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -208,12 +208,12 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnBackupPrefs_Click(object sender, RoutedEventArgs e)
|
private void btnBackupPrefs_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var backupDir = AppPathHelper.GetGameBackupDirectory(Game.FolderName, Game.RootDirectory);
|
var backupDir = AppPathHelper.GetGameBackupDirectory(this.Game.FolderName, this.Game.RootDirectory);
|
||||||
var result = _saveService.BackupRegistry(Game.RegistryPath, backupDir);
|
var result = this._saveService.BackupRegistry(this.Game.RegistryPath, backupDir);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
ReloadBackups();
|
this.ReloadBackups();
|
||||||
lblStatus.Text = $"レジストリをバックアップしました: {Path.GetFileName(result)}";
|
this.lblStatus.Text = $"レジストリをバックアップしました: {Path.GetFileName(result)}";
|
||||||
MessageBox.Show($"レジストリをバックアップしました:\n\n{result}", "バックアップ完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show($"レジストリをバックアップしました:\n\n{result}", "バックアップ完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -224,7 +224,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnRestorePrefs_Click(object sender, RoutedEventArgs e)
|
private void btnRestorePrefs_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var backupDir = AppPathHelper.GetGameBackupDirectory(Game.FolderName, Game.RootDirectory);
|
var backupDir = AppPathHelper.GetGameBackupDirectory(this.Game.FolderName, this.Game.RootDirectory);
|
||||||
var dlg = new OpenFileDialog
|
var dlg = new OpenFileDialog
|
||||||
{
|
{
|
||||||
Title = "復元する .reg ファイルを選択",
|
Title = "復元する .reg ファイルを選択",
|
||||||
@@ -238,10 +238,10 @@ namespace GameLauncher
|
|||||||
"復元の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
"復元の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||||
if (res != MessageBoxResult.Yes) return;
|
if (res != MessageBoxResult.Yes) return;
|
||||||
|
|
||||||
if (_saveService.RestoreRegistry(dlg.FileName))
|
if (this._saveService.RestoreRegistry(dlg.FileName))
|
||||||
{
|
{
|
||||||
ReloadPlayerPrefs();
|
this.ReloadPlayerPrefs();
|
||||||
lblStatus.Text = "レジストリを正常に復元しました。";
|
this.lblStatus.Text = "レジストリを正常に復元しました。";
|
||||||
MessageBox.Show("レジストリを正常に復元しました。", "復元完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show("レジストリを正常に復元しました。", "復元完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -253,17 +253,17 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnReloadPrefs_Click(object sender, RoutedEventArgs e)
|
private void btnReloadPrefs_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ReloadPlayerPrefs();
|
this.ReloadPlayerPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ctxSavePref_Click(object sender, RoutedEventArgs e)
|
private void ctxSavePref_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SaveCurrentSelectedPref();
|
this.SaveCurrentSelectedPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ctxCopyKey_Click(object sender, RoutedEventArgs e)
|
private void ctxCopyKey_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
if (this.dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(entry.CleanKey);
|
Clipboard.SetText(entry.CleanKey);
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void ctxCopyValue_Click(object sender, RoutedEventArgs e)
|
private void ctxCopyValue_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
if (this.dgPlayerPrefs.SelectedItem is PlayerPrefsEntry entry)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(entry.EditValue);
|
Clipboard.SetText(entry.EditValue);
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void ctxDeletePref_Click(object sender, RoutedEventArgs e)
|
private void ctxDeletePref_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnDeleteCurrentPref_Click(sender, e);
|
this.btnDeleteCurrentPref_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@@ -288,98 +288,216 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public void ReloadSaveFiles()
|
public void ReloadSaveFiles()
|
||||||
{
|
{
|
||||||
_saveFiles.Clear();
|
this._saveFiles.Clear();
|
||||||
var files = _saveService.GetSaveFiles(Game);
|
var files = this._saveService.GetSaveFiles(this.Game);
|
||||||
foreach (var f in files)
|
foreach (var f in files)
|
||||||
{
|
{
|
||||||
_saveFiles.Add(f);
|
this._saveFiles.Add(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_saveFiles.Count > 0)
|
if (this._saveFiles.Count > 0)
|
||||||
{
|
{
|
||||||
lstSaveFiles.SelectedIndex = 0;
|
this.lstSaveFiles.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblCurrentFileName.Text = "セーブファイルは見つかりませんでした";
|
this.lblCurrentFileName.Text = "セーブファイルは見つかりませんでした";
|
||||||
lblCurrentFilePath.Text = string.Empty;
|
this.lblCurrentFilePath.Text = string.Empty;
|
||||||
txtFileContent.Text = string.Empty;
|
this.txtFileContent.Text = string.Empty;
|
||||||
HideAllEditorPanels();
|
this.HideAllEditorPanels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideAllEditorPanels()
|
private void HideAllEditorPanels()
|
||||||
{
|
{
|
||||||
pnlGuiEditor.Visibility = Visibility.Collapsed;
|
this.pnlGuiEditor.Visibility = Visibility.Collapsed;
|
||||||
pnlTextEditor.Visibility = Visibility.Collapsed;
|
this.pnlTextEditor.Visibility = Visibility.Collapsed;
|
||||||
pnlUnsupportedBinary.Visibility = Visibility.Collapsed;
|
this.pnlUnsupportedBinary.Visibility = Visibility.Collapsed;
|
||||||
btnFormatJson.Visibility = Visibility.Collapsed;
|
this.btnFormatJson.Visibility = Visibility.Collapsed;
|
||||||
btnSaveFileContent.Visibility = Visibility.Collapsed;
|
this.btnSaveFileContent.Visibility = Visibility.Collapsed;
|
||||||
btnSaveGuiProperties.Visibility = Visibility.Collapsed;
|
this.btnSaveGuiProperties.Visibility = Visibility.Collapsed;
|
||||||
badgeCodec.Visibility = Visibility.Collapsed;
|
this.badgeCodec.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lstSaveFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void lstSaveFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (lstSaveFiles.SelectedItem is not SaveFileEntry entry) return;
|
if (this.lstSaveFiles.SelectedItem is not SaveFileEntry entry) return;
|
||||||
_currentSelectedFile = entry;
|
this._currentSelectedFile = entry;
|
||||||
|
|
||||||
lblCurrentFileName.Text = entry.FileName;
|
this.lblCurrentFileName.Text = entry.FileName;
|
||||||
lblCurrentFilePath.Text = entry.FilePath;
|
this.lblCurrentFilePath.Text = entry.FilePath;
|
||||||
HideAllEditorPanels();
|
this.HideAllEditorPanels();
|
||||||
|
|
||||||
// 1. コーデック(対応形式)が存在するか判定
|
// 1. コーデック(対応形式)が存在するか判定
|
||||||
var codec = SaveDataCodecManager.Instance.FindCodec(Game, entry);
|
var codec = SaveDataCodecManager.Instance.FindCodec(this.Game, entry);
|
||||||
if (codec != null)
|
if (codec != null)
|
||||||
{
|
{
|
||||||
// GUI エディタモードをアクティブ化
|
// GUI エディタモードをアクティブ化
|
||||||
_currentCodec = codec;
|
this._currentCodec = codec;
|
||||||
badgeCodec.Visibility = Visibility.Visible;
|
this.badgeCodec.Visibility = Visibility.Visible;
|
||||||
lblCodecName.Text = codec.CodecName;
|
this.lblCodecName.Text = codec.CodecName;
|
||||||
|
|
||||||
LoadGuiPropertiesFromCodec(codec, entry.FilePath);
|
this.LoadGuiPropertiesFromCodec(codec, entry.FilePath);
|
||||||
pnlGuiEditor.Visibility = Visibility.Visible;
|
this.pnlGuiEditor.Visibility = Visibility.Visible;
|
||||||
btnSaveGuiProperties.Visibility = Visibility.Visible;
|
this.btnSaveGuiProperties.Visibility = Visibility.Visible;
|
||||||
lblStatus.Text = $"{codec.CodecName} で読み込みました: {entry.FileName}";
|
this.lblStatus.Text = $"{codec.CodecName} で読み込みました: {entry.FileName}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. プレーンテキスト/JSON形式の場合
|
// 2. プレーンテキスト/JSON形式の場合
|
||||||
if (entry.IsTextOrJson)
|
if (entry.IsTextOrJson)
|
||||||
{
|
{
|
||||||
pnlTextEditor.Visibility = Visibility.Visible;
|
this.pnlTextEditor.Visibility = Visibility.Visible;
|
||||||
txtFileContent.Text = _saveService.ReadSaveFileText(entry.FilePath);
|
this.txtFileContent.Text = this._saveService.ReadSaveFileText(entry.FilePath);
|
||||||
btnFormatJson.Visibility = Visibility.Visible;
|
this.btnFormatJson.Visibility = Visibility.Visible;
|
||||||
btnSaveFileContent.Visibility = Visibility.Visible;
|
this.btnSaveFileContent.Visibility = Visibility.Visible;
|
||||||
lblStatus.Text = $"テキストとして開きました: {entry.FileName}";
|
this.lblStatus.Text = $"テキストとして開きました: {entry.FileName}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 未対応のバイナリセーブデータ形式の場合
|
// 3. 未対応のバイナリセーブデータ形式の場合
|
||||||
pnlUnsupportedBinary.Visibility = Visibility.Visible;
|
this.pnlUnsupportedBinary.Visibility = Visibility.Visible;
|
||||||
DisplayUnsupportedBinaryInfo(entry);
|
this.DisplayUnsupportedBinaryInfo(entry);
|
||||||
lblStatus.Text = $"未対応のバイナリセーブデータ: {entry.FileName}";
|
this.lblStatus.Text = $"未対応のバイナリセーブデータ: {entry.FileName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直近の読み込みで入力・特定されたパスワード。
|
||||||
|
/// </summary>
|
||||||
|
private string? _currentPassword;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// コーデックからプロパティ一覧を読み込み、パスワードバーの表示を更新します。
|
||||||
|
/// </summary>
|
||||||
private void LoadGuiPropertiesFromCodec(ISaveDataCodec codec, string filePath)
|
private void LoadGuiPropertiesFromCodec(ISaveDataCodec codec, string filePath)
|
||||||
{
|
{
|
||||||
_guiProperties.Clear();
|
this._guiProperties.Clear();
|
||||||
var props = codec.LoadProperties(filePath);
|
var props = codec.LoadProperties(filePath, this._currentPassword);
|
||||||
foreach (var p in props)
|
foreach (var p in props)
|
||||||
{
|
{
|
||||||
_guiProperties.Add(p);
|
this._guiProperties.Add(p);
|
||||||
}
|
}
|
||||||
lblGuiPropCount.Text = $"{props.Count} 項目";
|
this.lblGuiPropCount.Text = $"{props.Count} 項目";
|
||||||
if (props.Count > 0)
|
if (props.Count > 0)
|
||||||
{
|
{
|
||||||
dgGuiProperties.SelectedIndex = 0;
|
this.dgGuiProperties.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.UpdatePasswordBar(codec, filePath, props.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワードバーの表示要否と内容を更新します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="codec">使用中のコーデック</param>
|
||||||
|
/// <param name="filePath">対象セーブファイルのパス</param>
|
||||||
|
/// <param name="propertyCount">読み込めたプロパティ数</param>
|
||||||
|
private void UpdatePasswordBar(ISaveDataCodec codec, string filePath, int propertyCount)
|
||||||
|
{
|
||||||
|
// ES3 コーデックかつ暗号化されている場合のみパスワードバーを表示する
|
||||||
|
if (codec is EasySave3Codec es3Codec && es3Codec.NeedsPassword(filePath))
|
||||||
|
{
|
||||||
|
this.pnlPasswordBar.Visibility = Visibility.Visible;
|
||||||
|
this.txtPassword.Text = this._currentPassword ?? string.Empty;
|
||||||
|
|
||||||
|
if (this.txtPassword.Text.Length == 0)
|
||||||
|
{
|
||||||
|
this.txtPassword.ToolTip = es3Codec.PasswordPromptMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
var diagnostics = es3Codec.Diagnostics;
|
||||||
|
if (propertyCount <= 1 && diagnostics.Count > 0)
|
||||||
|
{
|
||||||
|
this.lblStatus.Text = "復号できませんでした。パスワードを入力するか「自動特定」を試してください。";
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pnlPasswordBar.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 入力されたパスワードでセーブファイルを再読み込みします。
|
||||||
|
/// </summary>
|
||||||
|
private void btnApplyPassword_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentSelectedFile == null || this._currentCodec == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._currentPassword = this.txtPassword.Text;
|
||||||
|
this.LoadGuiPropertiesFromCodec(this._currentCodec, this._currentSelectedFile.FilePath);
|
||||||
|
this.lblStatus.Text = $"パスワードを適用して再読み込みしました: {this._currentSelectedFile.FileName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワード入力欄で Enter を押した際に適用します。
|
||||||
|
/// </summary>
|
||||||
|
private void txtPassword_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
this.btnApplyPassword_Click(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワードの多段自動特定を実行します。
|
||||||
|
/// </summary>
|
||||||
|
private void btnAutoDetectPassword_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (this._currentSelectedFile is not { } entry)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resolver = new GameLauncher.Services.Codecs.Es3.Es3PasswordResolver();
|
||||||
|
var result = resolver.Resolve(
|
||||||
|
entry.FilePath,
|
||||||
|
gameRootDirectory: string.IsNullOrEmpty(this.Game.RootDirectory) ? null : this.Game.RootDirectory,
|
||||||
|
gameKey: entry.FilePath);
|
||||||
|
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
this._currentPassword = result.Password;
|
||||||
|
this.txtPassword.Text = result.Password;
|
||||||
|
|
||||||
|
if (this._currentCodec != null)
|
||||||
|
{
|
||||||
|
this.LoadGuiPropertiesFromCodec(this._currentCodec, entry.FilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var sourceLabel = result.Source switch
|
||||||
|
{
|
||||||
|
GameLauncher.Services.Codecs.Es3.Es3PasswordSource.LearnedCache => "学習済みキャッシュ",
|
||||||
|
GameLauncher.Services.Codecs.Es3.Es3PasswordSource.Explicit => "指定値",
|
||||||
|
GameLauncher.Services.Codecs.Es3.Es3PasswordSource.GameBinaryStrings => "ゲームバイナリの文字列",
|
||||||
|
GameLauncher.Services.Codecs.Es3.Es3PasswordSource.GameIl2CppMetadata => "IL2CPP メタデータ",
|
||||||
|
GameLauncher.Services.Codecs.Es3.Es3PasswordSource.Dictionary => "辞書探索",
|
||||||
|
_ => "平文"
|
||||||
|
};
|
||||||
|
|
||||||
|
this.lblStatus.Text = $"パスワードを特定しました({sourceLabel} / 試行 {result.TriedCandidates} 件)。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var detail = result.Diagnostics.Count > 0
|
||||||
|
? string.Join("\n", result.Diagnostics)
|
||||||
|
: "診断情報がありません。";
|
||||||
|
|
||||||
|
MessageBox.Show(
|
||||||
|
$"パスワードを自動特定できませんでした。\n(試行候補数: {result.TriedCandidates})\n\n{detail}",
|
||||||
|
"自動特定の結果",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool FilterGuiProperties(object obj)
|
private bool FilterGuiProperties(object obj)
|
||||||
{
|
{
|
||||||
if (obj is not SaveDataPropertyEntry prop) return false;
|
if (obj is not SaveDataPropertyEntry prop) return false;
|
||||||
var query = txtSearchGuiProps.Text.Trim();
|
var query = this.txtSearchGuiProps.Text.Trim();
|
||||||
if (string.IsNullOrEmpty(query)) return true;
|
if (string.IsNullOrEmpty(query)) return true;
|
||||||
|
|
||||||
return prop.Key.Contains(query, StringComparison.OrdinalIgnoreCase) ||
|
return prop.Key.Contains(query, StringComparison.OrdinalIgnoreCase) ||
|
||||||
@@ -389,26 +507,26 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void txtSearchGuiProps_TextChanged(object sender, TextChangedEventArgs e)
|
private void txtSearchGuiProps_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
_guiPropsView.Refresh();
|
this._guiPropsView.Refresh();
|
||||||
int visibleCount = _guiPropsView.Cast<object>().Count();
|
int visibleCount = this._guiPropsView.Cast<object>().Count();
|
||||||
lblGuiPropCount.Text = $"{visibleCount} / {_guiProperties.Count} 項目";
|
this.lblGuiPropCount.Text = $"{visibleCount} / {this._guiProperties.Count} 項目";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dgGuiProperties_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void dgGuiProperties_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgGuiProperties.SelectedItem is SaveDataPropertyEntry prop)
|
if (this.dgGuiProperties.SelectedItem is SaveDataPropertyEntry prop)
|
||||||
{
|
{
|
||||||
lblSelectedPropKey.Text = prop.Key;
|
this.lblSelectedPropKey.Text = prop.Key;
|
||||||
txtEditPropValueBar.Text = prop.EditValue;
|
this.txtEditPropValueBar.Text = prop.EditValue;
|
||||||
txtEditPropValueBar.IsEnabled = true;
|
this.txtEditPropValueBar.IsEnabled = true;
|
||||||
btnApplyPropValue.IsEnabled = true;
|
this.btnApplyPropValue.IsEnabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblSelectedPropKey.Text = "(未選択)";
|
this.lblSelectedPropKey.Text = "(未選択)";
|
||||||
txtEditPropValueBar.Text = string.Empty;
|
this.txtEditPropValueBar.Text = string.Empty;
|
||||||
txtEditPropValueBar.IsEnabled = false;
|
this.txtEditPropValueBar.IsEnabled = false;
|
||||||
btnApplyPropValue.IsEnabled = false;
|
this.btnApplyPropValue.IsEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,34 +534,48 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
btnApplyPropValue_Click(sender, e);
|
this.btnApplyPropValue_Click(sender, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnApplyPropValue_Click(object sender, RoutedEventArgs e)
|
private void btnApplyPropValue_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgGuiProperties.SelectedItem is SaveDataPropertyEntry prop)
|
if (this.dgGuiProperties.SelectedItem is SaveDataPropertyEntry prop)
|
||||||
{
|
{
|
||||||
prop.EditValue = txtEditPropValueBar.Text;
|
prop.EditValue = this.txtEditPropValueBar.Text;
|
||||||
dgGuiProperties.Items.Refresh();
|
this.dgGuiProperties.Items.Refresh();
|
||||||
lblStatus.Text = $"項目 '{prop.Key}' の値を変更しました。(「変更を保存」ボタンでファイルへ書き戻せます)";
|
this.lblStatus.Text = $"項目 '{prop.Key}' の値を変更しました。(「変更を保存」ボタンでファイルへ書き戻せます)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSaveGuiProperties_Click(object sender, RoutedEventArgs e)
|
private void btnSaveGuiProperties_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSelectedFile == null || _currentCodec == null) return;
|
if (this._currentSelectedFile == null || this._currentCodec == null) return;
|
||||||
|
|
||||||
|
// 編集で復号に使ったパスワードを渡し、同一パスワードで再暗号化させる
|
||||||
|
bool success = this._currentCodec.SaveProperties(
|
||||||
|
this._currentSelectedFile.FilePath,
|
||||||
|
[.. this._guiProperties],
|
||||||
|
this._currentPassword);
|
||||||
|
|
||||||
bool success = _currentCodec.SaveProperties(_currentSelectedFile.FilePath, _guiProperties.ToList());
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
lblStatus.Text = $"セーブファイルを正常に更新しました (自動バックアップ .bak 作成済み): {_currentSelectedFile.FileName}";
|
this.lblStatus.Text = $"セーブファイルを正常に更新しました (自動バックアップ .bak 作成済み): {this._currentSelectedFile.FileName}";
|
||||||
|
|
||||||
|
// 保存したファイルを読み直して、実際に反映された内容を画面へ再表示する
|
||||||
|
this.LoadGuiPropertiesFromCodec(this._currentCodec, this._currentSelectedFile.FilePath);
|
||||||
|
|
||||||
MessageBox.Show("セーブファイルを正常に更新・保存しました。\n(元のファイルは同階層に .bak として自動バックアップされています)",
|
MessageBox.Show("セーブファイルを正常に更新・保存しました。\n(元のファイルは同階層に .bak として自動バックアップされています)",
|
||||||
"保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
"保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("セーブデータの保存・再エンコードに失敗しました。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
// コーデックが出力した診断情報(往復検証の失敗理由など)を提示する
|
||||||
|
var detail = this._currentCodec is EasySave3Codec es3 && es3.Diagnostics.Count > 0
|
||||||
|
? "\n\n" + string.Join("\n", es3.Diagnostics)
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
|
MessageBox.Show($"セーブデータの保存・再エンコードに失敗しました。{detail}", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,41 +592,41 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
hexList.Add(bytes[i].ToString("X2"));
|
hexList.Add(bytes[i].ToString("X2"));
|
||||||
}
|
}
|
||||||
lblHexPreview.Text = string.Join(" ", hexList) + (bytes.Length > 32 ? " ..." : "");
|
this.lblHexPreview.Text = string.Join(" ", hexList) + (bytes.Length > 32 ? " ..." : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
lblHexPreview.Text = "(読み込み失敗)";
|
this.lblHexPreview.Text = "(読み込み失敗)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCopyIdePrompt_Click(object sender, RoutedEventArgs e)
|
private void btnCopyIdePrompt_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSelectedFile == null) return;
|
if (this._currentSelectedFile == null) return;
|
||||||
|
|
||||||
string prompt = SaveDataCodecManager.Instance.GenerateAntigravityPrompt(Game, _currentSelectedFile);
|
string prompt = SaveDataCodecManager.Instance.GenerateAntigravityPrompt(this.Game, this._currentSelectedFile);
|
||||||
Clipboard.SetText(prompt);
|
Clipboard.SetText(prompt);
|
||||||
|
|
||||||
lblStatus.Text = "📋 Antigravity IDE 用の解析依頼プロンプトをクリップボードにコピーしました!";
|
this.lblStatus.Text = "📋 Antigravity IDE 用の解析依頼プロンプトをクリップボードにコピーしました!";
|
||||||
MessageBox.Show("Antigravity IDE 解析用プロンプトをコピーしました!\n\nAntigravity IDE のチャット欄に貼り付けて送信すると、AIがこのゲームのセーブデータ構造を解析し、GUI編集プラグインを自動で追加してくれます。",
|
MessageBox.Show("Antigravity IDE 解析用プロンプトをコピーしました!\n\nAntigravity IDE のチャット欄に貼り付けて送信すると、AIがこのゲームのセーブデータ構造を解析し、GUI編集プラグインを自動で追加してくれます。",
|
||||||
"プロンプトをコピーしました", MessageBoxButton.OK, MessageBoxImage.Information);
|
"プロンプトをコピーしました", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnForceShowBinary_Click(object sender, RoutedEventArgs e)
|
private void btnForceShowBinary_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSelectedFile == null) return;
|
if (this._currentSelectedFile == null) return;
|
||||||
pnlUnsupportedBinary.Visibility = Visibility.Collapsed;
|
this.pnlUnsupportedBinary.Visibility = Visibility.Collapsed;
|
||||||
pnlTextEditor.Visibility = Visibility.Visible;
|
this.pnlTextEditor.Visibility = Visibility.Visible;
|
||||||
btnSaveFileContent.Visibility = Visibility.Visible;
|
this.btnSaveFileContent.Visibility = Visibility.Visible;
|
||||||
txtFileContent.Text = _saveService.ReadSaveFileText(_currentSelectedFile.FilePath);
|
this.txtFileContent.Text = this._saveService.ReadSaveFileText(this._currentSelectedFile.FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnFormatJson_Click(object sender, RoutedEventArgs e)
|
private void btnFormatJson_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var raw = txtFileContent.Text;
|
var raw = this.txtFileContent.Text;
|
||||||
if (string.IsNullOrWhiteSpace(raw)) return;
|
if (string.IsNullOrWhiteSpace(raw)) return;
|
||||||
|
|
||||||
using var doc = JsonDocument.Parse(raw);
|
using var doc = JsonDocument.Parse(raw);
|
||||||
@@ -503,8 +635,8 @@ namespace GameLauncher
|
|||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
});
|
});
|
||||||
txtFileContent.Text = formatted;
|
this.txtFileContent.Text = formatted;
|
||||||
lblStatus.Text = "JSONを整形しました。";
|
this.lblStatus.Text = "JSONを整形しました。";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -514,12 +646,12 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnSaveFileContent_Click(object sender, RoutedEventArgs e)
|
private void btnSaveFileContent_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSelectedFile == null) return;
|
if (this._currentSelectedFile == null) return;
|
||||||
|
|
||||||
bool success = _saveService.WriteSaveFileText(_currentSelectedFile.FilePath, txtFileContent.Text);
|
bool success = this._saveService.WriteSaveFileText(this._currentSelectedFile.FilePath, this.txtFileContent.Text);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
lblStatus.Text = $"ファイルを保存しました (自動バックアップ .bak 作成済み): {_currentSelectedFile.FileName}";
|
this.lblStatus.Text = $"ファイルを保存しました (自動バックアップ .bak 作成済み): {this._currentSelectedFile.FileName}";
|
||||||
MessageBox.Show("ファイルを保存しました。\n(元のファイルは同階層に .bak としてバックアップされています)",
|
MessageBox.Show("ファイルを保存しました。\n(元のファイルは同階層に .bak としてバックアップされています)",
|
||||||
"保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
"保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
@@ -532,14 +664,14 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnBackupSingleFile_Click(object sender, RoutedEventArgs e)
|
private void btnBackupSingleFile_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSelectedFile == null) return;
|
if (this._currentSelectedFile == null) return;
|
||||||
|
|
||||||
var backupDir = AppPathHelper.GetGameBackupDirectory(Game.FolderName, Game.RootDirectory);
|
var backupDir = AppPathHelper.GetGameBackupDirectory(this.Game.FolderName, this.Game.RootDirectory);
|
||||||
var result = _saveService.BackupSaveFile(_currentSelectedFile.FilePath, backupDir);
|
var result = this._saveService.BackupSaveFile(this._currentSelectedFile.FilePath, backupDir);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
ReloadBackups();
|
this.ReloadBackups();
|
||||||
lblStatus.Text = $"ファイルをバックアップしました: {Path.GetFileName(result)}";
|
this.lblStatus.Text = $"ファイルをバックアップしました: {Path.GetFileName(result)}";
|
||||||
MessageBox.Show($"ファイルをバックアップしました:\n\n{result}", "バックアップ完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show($"ファイルをバックアップしました:\n\n{result}", "バックアップ完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -550,7 +682,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnReloadSaveFiles_Click(object sender, RoutedEventArgs e)
|
private void btnReloadSaveFiles_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ReloadSaveFiles();
|
this.ReloadSaveFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@@ -559,22 +691,22 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public void ReloadBackups()
|
public void ReloadBackups()
|
||||||
{
|
{
|
||||||
_backups.Clear();
|
this._backups.Clear();
|
||||||
var list = _saveService.GetBackupList(Game);
|
var list = this._saveService.GetBackupList(this.Game);
|
||||||
foreach (var b in list)
|
foreach (var b in list)
|
||||||
{
|
{
|
||||||
_backups.Add(b);
|
this._backups.Add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnReloadBackups_Click(object sender, RoutedEventArgs e)
|
private void btnReloadBackups_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ReloadBackups();
|
this.ReloadBackups();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOpenBackupDir_Click(object sender, RoutedEventArgs e)
|
private void btnOpenBackupDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var backupDir = AppPathHelper.GetGameBackupDirectory(Game.FolderName, Game.RootDirectory);
|
var backupDir = AppPathHelper.GetGameBackupDirectory(this.Game.FolderName, this.Game.RootDirectory);
|
||||||
UnitySaveManagerService.OpenFolderInExplorer(backupDir);
|
UnitySaveManagerService.OpenFolderInExplorer(backupDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,9 +720,9 @@ namespace GameLauncher
|
|||||||
"復元の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
"復元の確認", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||||
if (res == MessageBoxResult.Yes)
|
if (res == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
if (_saveService.RestoreRegistry(backup.BackupPath))
|
if (this._saveService.RestoreRegistry(backup.BackupPath))
|
||||||
{
|
{
|
||||||
ReloadPlayerPrefs();
|
this.ReloadPlayerPrefs();
|
||||||
MessageBox.Show("レジストリを正常に復元しました。", "復元完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show("レジストリを正常に復元しました。", "復元完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -613,29 +745,29 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void btnOpenLocalLow_Click(object sender, RoutedEventArgs e)
|
private void btnOpenLocalLow_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Game.LocalLowPath))
|
if (!string.IsNullOrEmpty(this.Game.LocalLowPath))
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Game.LocalLowPath))
|
if (!Directory.Exists(this.Game.LocalLowPath))
|
||||||
{
|
{
|
||||||
var parent = Path.GetDirectoryName(Game.LocalLowPath);
|
var parent = Path.GetDirectoryName(this.Game.LocalLowPath);
|
||||||
if (parent != null && Directory.Exists(parent))
|
if (parent != null && Directory.Exists(parent))
|
||||||
{
|
{
|
||||||
UnitySaveManagerService.OpenFolderInExplorer(parent);
|
UnitySaveManagerService.OpenFolderInExplorer(parent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnitySaveManagerService.OpenFolderInExplorer(Game.LocalLowPath);
|
UnitySaveManagerService.OpenFolderInExplorer(this.Game.LocalLowPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOpenGameFolder_Click(object sender, RoutedEventArgs e)
|
private void btnOpenGameFolder_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
UnitySaveManagerService.OpenFolderInExplorer(Game.RootDirectory);
|
UnitySaveManagerService.OpenFolderInExplorer(this.Game.RootDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOpenRegedit_Click(object sender, RoutedEventArgs e)
|
private void btnOpenRegedit_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_saveService.OpenRegistryEditor(Game.RegistryPath);
|
this._saveService.OpenRegistryEditor(this.Game.RegistryPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
@@ -7,8 +7,9 @@ using System.Text;
|
|||||||
using System.Text.Encodings.Web;
|
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.Engines.Unity;
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
using GameLauncher.Services.Codecs.Es3;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
@@ -17,17 +18,76 @@ namespace GameLauncher.Services.Codecs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EasySave3Codec : ISaveDataCodec
|
public class EasySave3Codec : ISaveDataCodec
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// コーデックの表示名を取得します。
|
||||||
|
/// </summary>
|
||||||
public string CodecName => "Easy Save 3 (ES3) コーデック";
|
public string CodecName => "Easy Save 3 (ES3) コーデック";
|
||||||
|
|
||||||
public bool RequiresPassword => false;
|
/// <summary>
|
||||||
|
/// パスワード入力が必要かどうかを取得します。
|
||||||
|
/// 暗号化の有無はファイルごとに異なるため、実際の要否は <see cref="NeedsPassword"/> で判定します。
|
||||||
|
/// </summary>
|
||||||
|
public bool RequiresPassword => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワード入力ダイアログに表示する案内メッセージを取得します。
|
||||||
|
/// </summary>
|
||||||
public string? PasswordPromptMessage => "暗号化パスワードが設定されている場合は入力してください(未設定・既定の場合は空欄):";
|
public string? PasswordPromptMessage => "暗号化パスワードが設定されている場合は入力してください(未設定・既定の場合は空欄):";
|
||||||
|
|
||||||
// キャッシュ用の最新平文JSONノード
|
/// <summary>
|
||||||
private JsonNode? _cachedRootNode;
|
/// 直近の読み込み時に使用した解析ドキュメント(編集・書き戻し用)。
|
||||||
|
/// </summary>
|
||||||
|
private Es3SaveDocument? _document;
|
||||||
|
|
||||||
|
/// <summary>直近の読み込み対象ファイルの絶対パス。</summary>
|
||||||
|
private string? _loadedFilePath;
|
||||||
|
|
||||||
|
/// <summary>直近の読み込み時に暗号化されていたか。</summary>
|
||||||
private bool _wasEncrypted;
|
private bool _wasEncrypted;
|
||||||
|
|
||||||
|
/// <summary>直近の読み込み時に復号に使用したパスワード。</summary>
|
||||||
private string? _usedPassword;
|
private string? _usedPassword;
|
||||||
|
|
||||||
|
/// <summary>直近の読み込み時に Gzip 圧縮されていたか。</summary>
|
||||||
|
private bool _wasGzip;
|
||||||
|
|
||||||
|
/// <summary>直近の読み込み時の診断メッセージ(未対応時の案内表示に使用)。</summary>
|
||||||
|
private readonly List<string> _diagnostics = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直近の読み込みに関する診断メッセージを取得します。
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyList<string> Diagnostics => this._diagnostics;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定ファイルがパスワード入力(復号)を必要とするかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">セーブファイルの絶対パス</param>
|
||||||
|
/// <returns>暗号化されており復号が必要な場合 true</returns>
|
||||||
|
public bool NeedsPassword(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytes = File.ReadAllBytes(filePath);
|
||||||
|
return Es3PasswordResolver.LooksEncrypted(bytes);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたセーブファイルが本コーデックで処理可能かを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">対象のUnityゲーム情報</param>
|
||||||
|
/// <param name="file">対象のセーブファイル情報</param>
|
||||||
|
/// <returns>処理可能な場合は true、それ以外は false</returns>
|
||||||
public bool CanHandle(UnityGameItem game, SaveFileEntry file)
|
public bool CanHandle(UnityGameItem game, SaveFileEntry file)
|
||||||
{
|
{
|
||||||
var ext = Path.GetExtension(file.FilePath).ToLowerInvariant();
|
var ext = Path.GetExtension(file.FilePath).ToLowerInvariant();
|
||||||
@@ -43,17 +103,28 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// セーブファイルからプロパティ一覧を読み込みます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>展開されたセーブデータプロパティのリスト</returns>
|
||||||
public List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null)
|
public List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null)
|
||||||
{
|
{
|
||||||
var list = new List<SaveDataPropertyEntry>();
|
var list = new List<SaveDataPropertyEntry>();
|
||||||
|
this._diagnostics.Clear();
|
||||||
|
this._document = null;
|
||||||
|
this._loadedFilePath = filePath;
|
||||||
|
this._wasEncrypted = false;
|
||||||
|
this._usedPassword = null;
|
||||||
|
this._wasGzip = false;
|
||||||
|
|
||||||
if (!File.Exists(filePath)) return list;
|
if (!File.Exists(filePath)) return list;
|
||||||
|
|
||||||
byte[] fileBytes = File.ReadAllBytes(filePath);
|
byte[] fileBytes = File.ReadAllBytes(filePath);
|
||||||
if (fileBytes.Length == 0) return list;
|
if (fileBytes.Length == 0) return list;
|
||||||
|
|
||||||
string? jsonText = null;
|
string? jsonText = null;
|
||||||
_wasEncrypted = false;
|
|
||||||
_usedPassword = null;
|
|
||||||
|
|
||||||
// 1. まず平文 JSON または Gzip 解凍を試みる
|
// 1. まず平文 JSON または Gzip 解凍を試みる
|
||||||
try
|
try
|
||||||
@@ -62,6 +133,7 @@ namespace GameLauncher.Services.Codecs
|
|||||||
if (text.TrimStart().StartsWith("{") || text.TrimStart().StartsWith("["))
|
if (text.TrimStart().StartsWith("{") || text.TrimStart().StartsWith("["))
|
||||||
{
|
{
|
||||||
jsonText = text;
|
jsonText = text;
|
||||||
|
this._diagnostics.Add("平文 JSON として読み込みました。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
@@ -75,60 +147,148 @@ namespace GameLauncher.Services.Codecs
|
|||||||
using var gzip = new GZipStream(ms, CompressionMode.Decompress);
|
using var gzip = new GZipStream(ms, CompressionMode.Decompress);
|
||||||
using var reader = new StreamReader(gzip, Encoding.UTF8);
|
using var reader = new StreamReader(gzip, Encoding.UTF8);
|
||||||
jsonText = reader.ReadToEnd();
|
jsonText = reader.ReadToEnd();
|
||||||
|
this._wasGzip = true;
|
||||||
|
this._diagnostics.Add("Gzip 圧縮を解凍して読み込みました。");
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. パスワード指定または既定パスワードによる AES 復号を試みる
|
// 3. パスワードを多段フォールバックで解決して AES 復号する
|
||||||
if (jsonText == null)
|
if (jsonText == null)
|
||||||
{
|
{
|
||||||
var candidatePasswords = new List<string>();
|
var gameRoot = Path.GetDirectoryName(filePath);
|
||||||
if (!string.IsNullOrEmpty(optionalPassword))
|
var resolution = Es3PasswordResolver.Instance.Resolve(
|
||||||
{
|
filePath,
|
||||||
candidatePasswords.Add(optionalPassword);
|
gameRootDirectory: gameRoot,
|
||||||
}
|
gameKey: gameRoot,
|
||||||
candidatePasswords.AddRange(new[] { "Moodkie", "password", "", "SaveData" });
|
explicitPassword: optionalPassword);
|
||||||
|
|
||||||
foreach (var pwd in candidatePasswords)
|
this._diagnostics.AddRange(resolution.Diagnostics);
|
||||||
|
|
||||||
|
if (resolution.Success && !string.IsNullOrEmpty(resolution.Password))
|
||||||
{
|
{
|
||||||
var decrypted = TryDecryptAes(fileBytes, pwd);
|
jsonText = Es3PasswordResolver.TryDecrypt(fileBytes, resolution.Password);
|
||||||
if (!string.IsNullOrEmpty(decrypted))
|
if (!string.IsNullOrEmpty(jsonText))
|
||||||
{
|
{
|
||||||
jsonText = decrypted;
|
this._wasEncrypted = true;
|
||||||
_wasEncrypted = true;
|
this._usedPassword = resolution.Password;
|
||||||
_usedPassword = pwd;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(jsonText))
|
if (string.IsNullOrEmpty(jsonText))
|
||||||
{
|
{
|
||||||
// JSON展開ができなかった場合、バイナリキー・バリュー形式として先頭・重要オフセットを抽出
|
this._diagnostics.Add("復号できませんでした。パスワードを手動で入力してください。");
|
||||||
return ExtractBinaryPropertiesFallback(fileBytes);
|
return this.ExtractBinaryPropertiesFallback(fileBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON からプロパティを再帰的に展開
|
// 4. ES3 の型付き形式を解析してプロパティへ展開
|
||||||
try
|
var document = Es3SaveDocument.Parse(jsonText);
|
||||||
|
if (!document.IsLoaded)
|
||||||
{
|
{
|
||||||
_cachedRootNode = JsonNode.Parse(jsonText);
|
this._diagnostics.AddRange(document.Warnings);
|
||||||
if (_cachedRootNode is JsonObject rootObj)
|
return this.ExtractBinaryPropertiesFallback(fileBytes);
|
||||||
{
|
|
||||||
FlattenJsonObject(rootObj, "", list);
|
|
||||||
}
|
|
||||||
else if (_cachedRootNode is JsonArray rootArr)
|
|
||||||
{
|
|
||||||
FlattenJsonArray(rootArr, "Array", list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return ExtractBinaryPropertiesFallback(fileBytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._document = document;
|
||||||
|
this._diagnostics.AddRange(document.Warnings);
|
||||||
|
this.FlattenNodes(document.RootNodes, string.Empty, list);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 型付きノードを平坦化してプロパティ一覧へ変換します(型タグ付きで編集可能にします)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nodes">変換対象のノード</param>
|
||||||
|
/// <param name="prefix">現在の階層プレフィックス</param>
|
||||||
|
/// <param name="list">追加先のプロパティリスト</param>
|
||||||
|
private void FlattenNodes(List<Es3Node> nodes, string prefix, List<SaveDataPropertyEntry> list)
|
||||||
|
{
|
||||||
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
var key = string.IsNullOrEmpty(prefix) ? node.Key : $"{prefix}.{node.Key}";
|
||||||
|
var category = string.IsNullOrEmpty(prefix) ? "基本変数" : prefix;
|
||||||
|
|
||||||
|
if (node.HasChildren)
|
||||||
|
{
|
||||||
|
list.Add(new SaveDataPropertyEntry
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Category = category,
|
||||||
|
Type = FormatKindLabel(node),
|
||||||
|
EditValue = node.DisplayValue,
|
||||||
|
Description = $"JSON パス: {node.Path}",
|
||||||
|
RawData = node,
|
||||||
|
Kind = MapToValueKind(node.Kind)
|
||||||
|
});
|
||||||
|
|
||||||
|
this.FlattenNodes(node.Children, key, list);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(new SaveDataPropertyEntry
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Category = category,
|
||||||
|
Type = FormatKindLabel(node),
|
||||||
|
EditValue = node.DisplayValue,
|
||||||
|
Description = $"JSON パス: {node.Path}",
|
||||||
|
RawData = node,
|
||||||
|
Kind = MapToValueKind(node.Kind)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の値種別を、GUI の型別エディタ用の種別へ変換します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="kind">ES3 の値種別</param>
|
||||||
|
/// <returns>GUI 用の値種別</returns>
|
||||||
|
private static SaveDataPropertyEntry.ValueKind MapToValueKind(Es3ValueKind kind)
|
||||||
|
{
|
||||||
|
return kind switch
|
||||||
|
{
|
||||||
|
Es3ValueKind.Boolean => SaveDataPropertyEntry.ValueKind.Boolean,
|
||||||
|
Es3ValueKind.Integer => SaveDataPropertyEntry.ValueKind.Integer,
|
||||||
|
Es3ValueKind.Float => SaveDataPropertyEntry.ValueKind.Float,
|
||||||
|
Es3ValueKind.String => SaveDataPropertyEntry.ValueKind.String,
|
||||||
|
Es3ValueKind.Enum => SaveDataPropertyEntry.ValueKind.Enum,
|
||||||
|
Es3ValueKind.Array or Es3ValueKind.Dictionary or Es3ValueKind.Object
|
||||||
|
=> SaveDataPropertyEntry.ValueKind.Complex,
|
||||||
|
_ => SaveDataPropertyEntry.ValueKind.Unknown
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ノードの型名を表示用ラベルに整形します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="node">対象ノード</param>
|
||||||
|
/// <returns>表示用の型ラベル</returns>
|
||||||
|
private static string FormatKindLabel(Es3Node node)
|
||||||
|
{
|
||||||
|
var kind = node.Kind switch
|
||||||
|
{
|
||||||
|
Es3ValueKind.Boolean => "bool",
|
||||||
|
Es3ValueKind.Integer => "int",
|
||||||
|
Es3ValueKind.Float => "float",
|
||||||
|
Es3ValueKind.String => "string",
|
||||||
|
Es3ValueKind.Enum => "enum",
|
||||||
|
Es3ValueKind.Array => "array",
|
||||||
|
Es3ValueKind.Dictionary => "dictionary",
|
||||||
|
Es3ValueKind.Object => "object",
|
||||||
|
_ => "unknown"
|
||||||
|
};
|
||||||
|
|
||||||
|
return string.IsNullOrEmpty(node.TypeName) ? kind : $"{kind} ({node.TypeName})";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSONオブジェクトを再帰的に走査し、プロパティ一覧に追加します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">対象のJSONオブジェクト</param>
|
||||||
|
/// <param name="prefix">現在のキー階層プレフィックス</param>
|
||||||
|
/// <param name="list">追加先のプロパティリスト</param>
|
||||||
private void FlattenJsonObject(JsonObject obj, string prefix, List<SaveDataPropertyEntry> list)
|
private void FlattenJsonObject(JsonObject obj, string prefix, List<SaveDataPropertyEntry> list)
|
||||||
{
|
{
|
||||||
foreach (var kvp in obj)
|
foreach (var kvp in obj)
|
||||||
@@ -181,14 +341,14 @@ namespace GameLauncher.Services.Codecs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FlattenJsonObject(childObj, key, list);
|
this.FlattenJsonObject(childObj, key, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node is JsonArray childArr)
|
else if (node is JsonArray childArr)
|
||||||
{
|
{
|
||||||
if (childArr.Count <= 20)
|
if (childArr.Count <= 20)
|
||||||
{
|
{
|
||||||
FlattenJsonArray(childArr, key, list);
|
this.FlattenJsonArray(childArr, key, list);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -206,6 +366,12 @@ namespace GameLauncher.Services.Codecs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON配列を再帰的に走査し、プロパティ一覧に追加します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arr">対象のJSON配列</param>
|
||||||
|
/// <param name="prefix">現在のキー階層プレフィックス</param>
|
||||||
|
/// <param name="list">追加先のプロパティリスト</param>
|
||||||
private void FlattenJsonArray(JsonArray arr, string prefix, List<SaveDataPropertyEntry> list)
|
private void FlattenJsonArray(JsonArray arr, string prefix, List<SaveDataPropertyEntry> list)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arr.Count; i++)
|
for (int i = 0; i < arr.Count; i++)
|
||||||
@@ -225,22 +391,29 @@ namespace GameLauncher.Services.Codecs
|
|||||||
}
|
}
|
||||||
else if (node is JsonObject childObj)
|
else if (node is JsonObject childObj)
|
||||||
{
|
{
|
||||||
FlattenJsonObject(childObj, key, list);
|
this.FlattenJsonObject(childObj, key, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON展開に失敗した場合のフォールバックとしてバイナリ値を抽出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">ファイル全体のバイナリデータ</param>
|
||||||
|
/// <returns>バイナリ情報プロパティのリスト</returns>
|
||||||
private List<SaveDataPropertyEntry> ExtractBinaryPropertiesFallback(byte[] bytes)
|
private List<SaveDataPropertyEntry> ExtractBinaryPropertiesFallback(byte[] bytes)
|
||||||
{
|
{
|
||||||
var list = new List<SaveDataPropertyEntry>();
|
var list = new List<SaveDataPropertyEntry>
|
||||||
list.Add(new SaveDataPropertyEntry
|
|
||||||
{
|
{
|
||||||
Key = "FileSize",
|
new SaveDataPropertyEntry
|
||||||
Category = "ファイル情報",
|
{
|
||||||
Type = "Int",
|
Key = "FileSize",
|
||||||
EditValue = bytes.Length.ToString(),
|
Category = "ファイル情報",
|
||||||
Description = "ファイルサイズ (bytes)"
|
Type = "Int",
|
||||||
});
|
EditValue = bytes.Length.ToString(),
|
||||||
|
Description = "ファイルサイズ (bytes)"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 先頭 128 バイトから 4 バイト整数と ASCII 文字列を検出してプロパティ化
|
// 先頭 128 バイトから 4 バイト整数と ASCII 文字列を検出してプロパティ化
|
||||||
int limit = Math.Min(bytes.Length - 4, 128);
|
int limit = Math.Min(bytes.Length - 4, 128);
|
||||||
@@ -261,44 +434,82 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 編集後のプロパティ一覧をセーブファイルへ書き戻して保存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">保存先セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="properties">編集されたプロパティ一覧</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>保存に成功した場合は true、それ以外は false</returns>
|
||||||
public bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null)
|
public bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_cachedRootNode != null)
|
if (this._document is { IsLoaded: true } document)
|
||||||
{
|
{
|
||||||
// JSON の値を更新
|
// 編集値を解析ツリーへ適用する
|
||||||
foreach (var prop in properties)
|
foreach (var prop in properties)
|
||||||
{
|
{
|
||||||
if (prop.RawData is string keyPath)
|
if (!prop.IsModified || prop.RawData is not Es3Node node)
|
||||||
{
|
{
|
||||||
UpdateJsonNodeByPath(_cachedRootNode, keyPath, prop.EditValue, prop.Type);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!node.IsEditable)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.TrySetValue(node.Path, prop.EditValue, out var applyError))
|
||||||
|
{
|
||||||
|
node.DisplayValue = prop.EditValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._diagnostics.Add($"'{prop.Key}' の適用をスキップしました: {applyError}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = new JsonSerializerOptions
|
// 変更がなければ書き込まない
|
||||||
|
if (!document.HasChanges())
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
this._diagnostics.Add("変更点がないため保存をスキップしました。");
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
return true;
|
||||||
};
|
|
||||||
string updatedJson = _cachedRootNode.ToJsonString(options);
|
|
||||||
|
|
||||||
byte[] outputBytes = Encoding.UTF8.GetBytes(updatedJson);
|
|
||||||
|
|
||||||
// もともと暗号化されていた場合は再暗号化
|
|
||||||
if (_wasEncrypted)
|
|
||||||
{
|
|
||||||
string pwd = !string.IsNullOrEmpty(optionalPassword) ? optionalPassword : (_usedPassword ?? "Moodkie");
|
|
||||||
outputBytes = EncryptAes(outputBytes, pwd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// バックアップ作成
|
byte[] outputBytes = Encoding.UTF8.GetBytes(document.ToJson());
|
||||||
|
|
||||||
|
// もともと Gzip 圧縮されていた場合は再圧縮する
|
||||||
|
if (this._wasGzip)
|
||||||
|
{
|
||||||
|
outputBytes = CompressGzip(outputBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// もともと暗号化されていた場合は同一パスワードで再暗号化する
|
||||||
|
if (this._wasEncrypted)
|
||||||
|
{
|
||||||
|
var pwd = !string.IsNullOrEmpty(optionalPassword)
|
||||||
|
? optionalPassword!
|
||||||
|
: this._usedPassword ?? string.Empty;
|
||||||
|
|
||||||
|
outputBytes = Es3PasswordResolver.Encrypt(outputBytes, pwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 往復検証: 書き込み前に「出力バイト列を読み直して構造が一致するか」を確認する
|
||||||
|
if (!this.VerifyRoundTrip(outputBytes, document, out var verifyError))
|
||||||
|
{
|
||||||
|
this._diagnostics.Add($"往復検証に失敗したため保存を中止しました: {verifyError}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// バックアップ作成(既存規約に従い .bak を残す)
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
File.Copy(filePath, filePath + ".bak", overwrite: true);
|
File.Copy(filePath, filePath + ".bak", overwrite: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllBytes(filePath, outputBytes);
|
File.WriteAllBytes(filePath, outputBytes);
|
||||||
|
this._diagnostics.Add($"保存しました({outputBytes.Length} bytes)。");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -325,18 +536,104 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
this._diagnostics.Add($"保存中に例外が発生しました: {ex.Message}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出力バイト列を読み直して編集内容が保持されているかを検証します(往復検証)。
|
||||||
|
/// 検証に失敗した場合はファイルへ書き込まず、元データを温存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="outputBytes">書き込み予定のバイト列</param>
|
||||||
|
/// <param name="document">編集済みドキュメント</param>
|
||||||
|
/// <param name="error">検証失敗の理由</param>
|
||||||
|
/// <returns>検証に成功した場合 true</returns>
|
||||||
|
private bool VerifyRoundTrip(byte[] outputBytes, Es3SaveDocument document, out string error)
|
||||||
|
{
|
||||||
|
error = string.Empty;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string? verifiedJson;
|
||||||
|
|
||||||
|
if (this._wasEncrypted)
|
||||||
|
{
|
||||||
|
var pwd = this._usedPassword ?? string.Empty;
|
||||||
|
verifiedJson = Es3PasswordResolver.TryDecrypt(outputBytes, pwd);
|
||||||
|
}
|
||||||
|
else if (this._wasGzip)
|
||||||
|
{
|
||||||
|
using var ms = new MemoryStream(outputBytes);
|
||||||
|
using var gzip = new GZipStream(ms, CompressionMode.Decompress);
|
||||||
|
using var reader = new StreamReader(gzip, Encoding.UTF8);
|
||||||
|
verifiedJson = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
verifiedJson = Encoding.UTF8.GetString(outputBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(verifiedJson))
|
||||||
|
{
|
||||||
|
error = "出力データを復号・解凍できませんでした。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reparsed = Es3SaveDocument.Parse(verifiedJson);
|
||||||
|
if (!reparsed.IsLoaded)
|
||||||
|
{
|
||||||
|
error = "出力データを再解析できませんでした。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ルート直下の要素数が一致することを最低条件とする
|
||||||
|
if (reparsed.RootNodes.Count != document.RootNodes.Count)
|
||||||
|
{
|
||||||
|
error = $"要素数が一致しません(期待 {document.RootNodes.Count} / 実際 {reparsed.RootNodes.Count})。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
error = ex.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// バイト列を Gzip 圧縮します(元が Gzip だった場合に元形式を維持するため)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plainBytes">平文バイト列</param>
|
||||||
|
/// <returns>圧縮済みバイト列</returns>
|
||||||
|
private static byte[] CompressGzip(byte[] plainBytes)
|
||||||
|
{
|
||||||
|
using var output = new MemoryStream();
|
||||||
|
using (var gzip = new GZipStream(output, CompressionLevel.Optimal, leaveOpen: true))
|
||||||
|
{
|
||||||
|
gzip.Write(plainBytes, 0, plainBytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// キーパスに基づいてJSONノードの値を更新します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="root">ルートのJSONノード</param>
|
||||||
|
/// <param name="path">ドット区切りのキーパス</param>
|
||||||
|
/// <param name="newValue">更新後の値文字列</param>
|
||||||
|
/// <param name="type">値の型名</param>
|
||||||
private void UpdateJsonNodeByPath(JsonNode root, string path, string newValue, string type)
|
private void UpdateJsonNodeByPath(JsonNode root, string path, string newValue, string type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// ドットと角括弧でパスを分割
|
// ドットと角括弧でパスを分割
|
||||||
var parts = path.Split(new[] { '.', '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = path.Split(['.', '[', ']'], StringSplitOptions.RemoveEmptyEntries);
|
||||||
JsonNode? current = root;
|
JsonNode? current = root;
|
||||||
|
|
||||||
for (int i = 0; i < parts.Length - 1; i++)
|
for (int i = 0; i < parts.Length - 1; i++)
|
||||||
@@ -358,16 +655,22 @@ namespace GameLauncher.Services.Codecs
|
|||||||
string lastKey = parts[^1];
|
string lastKey = parts[^1];
|
||||||
if (current is JsonObject finalObj)
|
if (current is JsonObject finalObj)
|
||||||
{
|
{
|
||||||
finalObj[lastKey] = ParseJsonValue(newValue, type);
|
finalObj[lastKey] = this.ParseJsonValue(newValue, type);
|
||||||
}
|
}
|
||||||
else if (current is JsonArray finalArr && int.TryParse(lastKey, out int finalIdx) && finalIdx < finalArr.Count)
|
else if (current is JsonArray finalArr && int.TryParse(lastKey, out int finalIdx) && finalIdx < finalArr.Count)
|
||||||
{
|
{
|
||||||
finalArr[finalIdx] = ParseJsonValue(newValue, type);
|
finalArr[finalIdx] = this.ParseJsonValue(newValue, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列値と型名から対応するJSONノードを生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">値文字列</param>
|
||||||
|
/// <param name="type">型名</param>
|
||||||
|
/// <returns>生成されたJSONノード</returns>
|
||||||
private JsonNode? ParseJsonValue(string value, string type)
|
private JsonNode? ParseJsonValue(string value, string type)
|
||||||
{
|
{
|
||||||
if (type == "Int" && int.TryParse(value, out int i)) return JsonValue.Create(i);
|
if (type == "Int" && int.TryParse(value, out int i)) return JsonValue.Create(i);
|
||||||
@@ -389,6 +692,12 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return JsonValue.Create(value);
|
return JsonValue.Create(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AESアルゴリズムによるセーブデータの復号を試みます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">暗号化バイナリデータ</param>
|
||||||
|
/// <param name="password">復号パスワード</param>
|
||||||
|
/// <returns>復号された平文文字列。失敗時は null</returns>
|
||||||
private string? TryDecryptAes(byte[] data, string password)
|
private string? TryDecryptAes(byte[] data, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -424,6 +733,12 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平文バイト配列をAESアルゴリズムで暗号化します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plainBytes">平文バイナリデータ</param>
|
||||||
|
/// <param name="password">暗号化パスワード</param>
|
||||||
|
/// <returns>暗号化されたバイナリデータ</returns>
|
||||||
private byte[] EncryptAes(byte[] plainBytes, string password)
|
private byte[] EncryptAes(byte[] plainBytes, string password)
|
||||||
{
|
{
|
||||||
byte[] rawUtf8 = Encoding.UTF8.GetBytes(password);
|
byte[] rawUtf8 = Encoding.UTF8.GetBytes(password);
|
||||||
|
|||||||
@@ -0,0 +1,585 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services.Codecs.Es3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ゲームのバイナリから ES3 のパスワード候補文字列を抽出する汎用ヘルパー。
|
||||||
|
///
|
||||||
|
/// Easy Save 3 のパスワードは <c>new ES3Settings(ES3.EncryptionType.AES, "password")</c> のように
|
||||||
|
/// コード中の文字列リテラルとして埋め込まれることが多いため、
|
||||||
|
/// マネージドアセンブリ(Mono)/IL2CPP メタデータの双方から文字列を回収します。
|
||||||
|
/// 特定のゲーム名に依存しない汎用実装です。
|
||||||
|
/// </summary>
|
||||||
|
public static class Es3PasswordExtractor
|
||||||
|
{
|
||||||
|
/// <summary>文字列抽出対象とする最大ファイルサイズ(バイト)。巨大ファイルの全走査を避けます。</summary>
|
||||||
|
private const long MaxScanFileSize = 512L * 1024 * 1024;
|
||||||
|
|
||||||
|
/// <summary>1 ファイルあたりに保持する候補の上限。</summary>
|
||||||
|
private const int MaxCandidatesPerFile = 4000;
|
||||||
|
|
||||||
|
/// <summary>抽出する文字列の最小長。</summary>
|
||||||
|
private const int MinCandidateLength = 3;
|
||||||
|
|
||||||
|
/// <summary>抽出する文字列の最大長。</summary>
|
||||||
|
private const int MaxCandidateLength = 64;
|
||||||
|
|
||||||
|
/// <summary>ES3 の既定設定アセットにおいて暗号化パスワードを保持するフィールド名。</summary>
|
||||||
|
private const string FieldNameEncryptionPassword = "encryptionPassword";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワードらしい文字列のみを通すための許可パターン(英数字記号のみ、空白・制御文字を除外)。
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Regex CandidatePattern =
|
||||||
|
new(@"^[\x21-\x7E]{3,64}$", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 のパスワード指定箇所の近傍を示す手がかりキーワード。
|
||||||
|
/// これらを含む文字列は優先的に候補の先頭へ寄せます。
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string[] PasswordHints =
|
||||||
|
[
|
||||||
|
"password", "Password", "PASSWORD",
|
||||||
|
"pass", "Pass", "pwd", "Pwd",
|
||||||
|
"encrypt", "Encrypt", "encryption", "Encryption",
|
||||||
|
"ES3Settings", "ES3", "es3"
|
||||||
|
];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 明らかにパスワードではない文字列(Unity の内部名・型名・UI ラベルなど)を除外するパターン。
|
||||||
|
///
|
||||||
|
/// 実ゲーム検証では "GUILayoutPasswordField" のような UI クラス名や
|
||||||
|
/// "The password Text" のような説明文が大量に抽出され、真のパスワードが埋もれていました。
|
||||||
|
/// それらを除外して候補の精度を上げます。
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Regex NoisePattern = new(
|
||||||
|
@"^(Unity|UnityEngine|UnityEditor|System|Microsoft|Mono|mscorlib|netstandard|" +
|
||||||
|
@"Assembly-CSharp|Library|Packages|Assets|Resources|StreamingAssets|" +
|
||||||
|
@"com\.unity|Unity\.|UnityEngine\.|System\.)" +
|
||||||
|
@"|PasswordField|passwordField|TextField|password Text|Password Text" +
|
||||||
|
@"|GUILayout|OnGUI|m_[A-Z]|get_|set_|<[A-Za-z]",
|
||||||
|
RegexOptions.Compiled);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 空白を含む文字列は UI ラベル・説明文である可能性が高いため、
|
||||||
|
/// パスワード候補としては扱いません(パスワードは通常 1 トークン)。
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Regex SentenceLikePattern = new(
|
||||||
|
@"\s{1,}.*\s|[.!?]$",
|
||||||
|
RegexOptions.Compiled);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ゲームルートディレクトリから ES3 パスワード候補を抽出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameRootDirectory">ゲームのルートディレクトリ</param>
|
||||||
|
/// <param name="diagnostics">診断メッセージの追加先(null 可)</param>
|
||||||
|
/// <returns>優先度順に並んだパスワード候補</returns>
|
||||||
|
public static List<string> ExtractCandidates(string gameRootDirectory, List<string>? diagnostics = null)
|
||||||
|
{
|
||||||
|
var result = new List<string>();
|
||||||
|
if (string.IsNullOrWhiteSpace(gameRootDirectory) || !Directory.Exists(gameRootDirectory))
|
||||||
|
{
|
||||||
|
diagnostics?.Add($"ゲームフォルダが見つかりません: {gameRootDirectory}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var scanTargets = CollectScanTargets(gameRootDirectory);
|
||||||
|
if (scanTargets.Count == 0)
|
||||||
|
{
|
||||||
|
diagnostics?.Add("文字列抽出の対象ファイル(マネージドアセンブリ/IL2CPPメタデータ)が見つかりませんでした。");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics?.Add($"文字列抽出対象: {scanTargets.Count} ファイル");
|
||||||
|
|
||||||
|
// 「パスワード指定の近傍にある文字列」を高優先、「その他の文字列」を低優先として収集する
|
||||||
|
var settingsDerived = new List<string>();
|
||||||
|
var highPriority = new List<string>();
|
||||||
|
var lowPriority = new List<string>();
|
||||||
|
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||||
|
|
||||||
|
foreach (var path in scanTargets)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var info = new FileInfo(path);
|
||||||
|
if (!info.Exists || info.Length == 0 || info.Length > MaxScanFileSize)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytes = File.ReadAllBytes(path);
|
||||||
|
|
||||||
|
// ES3Defaults の encryptionPassword フィールドを持つアセットは、
|
||||||
|
// 値域に格納された文字列をパスワード候補として最優先で回収する
|
||||||
|
CollectFromEs3DefaultSettings(bytes, settingsDerived, seen);
|
||||||
|
|
||||||
|
CollectFromBytes(bytes, highPriority, lowPriority, seen);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
diagnostics?.Add($"読み込み失敗: {Path.GetFileName(path)} ({ex.Message})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsDerived.Count > 0)
|
||||||
|
{
|
||||||
|
diagnostics?.Add($"ES3Defaults の encryptionPassword 近傍から {settingsDerived.Count} 件の候補を抽出しました。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ES3Defaults 由来 → 高優先 → 低優先の順で連結
|
||||||
|
foreach (var candidate in settingsDerived.Concat(highPriority).Concat(lowPriority))
|
||||||
|
{
|
||||||
|
if (result.Count >= 512)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics?.Add(
|
||||||
|
$"抽出候補数: {result.Count}(設定由来 {settingsDerived.Count} / 高優先 {highPriority.Count} / 低優先 {lowPriority.Count})");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の既定設定(<c>ES3Defaults</c>)を持つアセットから、<c>encryptionPassword</c> の値候補を抽出します。
|
||||||
|
///
|
||||||
|
/// Unity のアセットは「フィールド名テーブル」と「値テーブル」が分離しており、
|
||||||
|
/// フィールド名の直後に値があるとは限りません。そのため、フィールド名が存在するアセットでは
|
||||||
|
/// ファイル全体の文字列を候補化しつつ、パスワードらしい短い文字列を優先的に先頭へ寄せます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">アセットのバイト列</param>
|
||||||
|
/// <param name="settingsDerived">設定由来の候補の追加先</param>
|
||||||
|
/// <param name="seen">重複排除用の集合</param>
|
||||||
|
private static void CollectFromEs3DefaultSettings(
|
||||||
|
byte[] bytes,
|
||||||
|
List<string> settingsDerived,
|
||||||
|
HashSet<string> seen)
|
||||||
|
{
|
||||||
|
if (bytes.Length == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 高速化のため、まず encryptionPassword の存在を確認する
|
||||||
|
bool hasField;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var probeLength = Math.Min(bytes.Length, 4 * 1024 * 1024);
|
||||||
|
var probe = Encoding.ASCII.GetString(bytes, 0, probeLength);
|
||||||
|
hasField = probe.Contains(FieldNameEncryptionPassword, StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasField)
|
||||||
|
{
|
||||||
|
// 巨大アセットでは先頭 4MB に無いことが多いため、全体を再度確認する
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var all = Encoding.ASCII.GetString(bytes);
|
||||||
|
hasField = all.Contains(FieldNameEncryptionPassword, StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasField)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// フィールド名が存在するアセットの文字列を候補化する
|
||||||
|
var asciiCandidates = new List<string>();
|
||||||
|
var utf16Candidates = new List<string>();
|
||||||
|
CollectAsciiStrings(bytes, asciiCandidates, asciiCandidates, seen, 0);
|
||||||
|
CollectUtf16Strings(bytes, utf16Candidates, utf16Candidates, seen, 0);
|
||||||
|
|
||||||
|
// 実ゲーム検証では、PlayMaker アクションのスキーマ定義に encryptionPassword が
|
||||||
|
// 並ぶだけで実際の値は別領域にあり、無関係な文字列が大量に候補化されました。
|
||||||
|
// パスワード指定の手がかり(password / encrypt 等)を含む文字列だけに絞り込みます。
|
||||||
|
foreach (var candidate in asciiCandidates.Concat(utf16Candidates))
|
||||||
|
{
|
||||||
|
if (!ContainsPasswordHint(candidate))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LooksLikePasswordValue(candidate) && !settingsDerived.Contains(candidate))
|
||||||
|
{
|
||||||
|
settingsDerived.Add(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列がパスワード値そのものらしいかを判定します(フィールド名や型名を除外)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">候補文字列</param>
|
||||||
|
/// <returns>パスワード値らしい場合 true</returns>
|
||||||
|
private static bool LooksLikePasswordValue(string candidate)
|
||||||
|
{
|
||||||
|
if (candidate.Length < 3 || candidate.Length > 32)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ES3 の設定フィールド名・型名は値ではない
|
||||||
|
if (candidate.Equals(FieldNameEncryptionPassword, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.Equals("encryptionType", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.Equals("compressionType", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.Equals("bufferSize", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.Equals("errorMessage", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.Equals("overrideDefaultSettings", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.StartsWith("ES3", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 空白・記号のみのものは除外
|
||||||
|
if (candidate.Contains(' '))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsPlausibleCandidate(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 走査対象のファイル一覧を収集します。
|
||||||
|
/// Mono の場合は Managed 配下の DLL、IL2CPP の場合は GameAssembly.dll と global-metadata.dat を対象にします。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameRootDirectory">ゲームのルートディレクトリ</param>
|
||||||
|
/// <returns>走査対象ファイルの絶対パス一覧</returns>
|
||||||
|
private static List<string> CollectScanTargets(string gameRootDirectory)
|
||||||
|
{
|
||||||
|
var targets = new List<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 1. Mono: <Game>_Data\Managed\*.dll(Assembly-CSharp.dll を最優先)
|
||||||
|
foreach (var dataDir in Directory.GetDirectories(gameRootDirectory))
|
||||||
|
{
|
||||||
|
if (!Path.GetFileName(dataDir).EndsWith("_Data", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var managedDir = Path.Combine(dataDir, "Managed");
|
||||||
|
if (Directory.Exists(managedDir))
|
||||||
|
{
|
||||||
|
var dlls = Directory.GetFiles(managedDir, "*.dll", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(f =>
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(f);
|
||||||
|
return !name.StartsWith("Unity", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!name.StartsWith("System", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!name.StartsWith("Mono", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!name.StartsWith("mscorlib", StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!name.StartsWith("netstandard", StringComparison.OrdinalIgnoreCase);
|
||||||
|
})
|
||||||
|
.OrderByDescending(f =>
|
||||||
|
Path.GetFileName(f).StartsWith("Assembly-CSharp", StringComparison.OrdinalIgnoreCase))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
targets.AddRange(dlls);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. IL2CPP: il2cpp_data\Metadata\global-metadata.dat
|
||||||
|
var metadata = Path.Combine(dataDir, "il2cpp_data", "Metadata", "global-metadata.dat");
|
||||||
|
if (File.Exists(metadata))
|
||||||
|
{
|
||||||
|
targets.Add(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. ES3 の既定設定(ES3Defaults ScriptableObject)はアセットに格納されるため、
|
||||||
|
// アセット内の文字列も走査対象に含める。コード側にパスワードリテラルが
|
||||||
|
// 存在しないゲームでは、ここが唯一の手がかりになる。
|
||||||
|
targets.AddRange(CollectAssetTargets(dataDir));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. IL2CPP: ルート直下の GameAssembly.dll
|
||||||
|
var gameAssembly = Path.Combine(gameRootDirectory, "GameAssembly.dll");
|
||||||
|
if (File.Exists(gameAssembly))
|
||||||
|
{
|
||||||
|
targets.Add(gameAssembly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 列挙失敗時は取得できた分だけ返す
|
||||||
|
}
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の既定設定(<c>ES3Defaults</c> ScriptableObject)が格納され得るアセットファイルを収集します。
|
||||||
|
///
|
||||||
|
/// 実ゲーム検証ではコード側にパスワードリテラルが存在せず(<c>encryption</c> 文字列すら無い)、
|
||||||
|
/// 既定設定アセットにのみパスワードが入っているケースがありました。
|
||||||
|
/// 巨大な .resS / .bundle を避け、テキスト情報を持つ .assets 系に限定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataDirectory">ゲームの *_Data ディレクトリ</param>
|
||||||
|
/// <returns>走査対象アセットの絶対パス一覧</returns>
|
||||||
|
private static List<string> CollectAssetTargets(string dataDirectory)
|
||||||
|
{
|
||||||
|
var targets = new List<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var extensionSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
".assets", ".asset", ".json", ".bytes", ".dat"
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var file in Directory.GetFiles(dataDirectory, "*", SearchOption.TopDirectoryOnly))
|
||||||
|
{
|
||||||
|
var ext = Path.GetExtension(file);
|
||||||
|
if (!extensionSet.Contains(ext))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var info = new FileInfo(file);
|
||||||
|
if (info.Length == 0 || info.Length > MaxScanFileSize)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.Add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 列挙失敗時は取得できた分だけ返す
|
||||||
|
}
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// バイト列から ASCII 文字列を抽出し、優先度別のリストへ振り分けます。
|
||||||
|
///
|
||||||
|
/// .NET アセンブリ(Assembly-CSharp.dll 等)の文字列定数は UTF-16LE で格納されるため、
|
||||||
|
/// 8bit ASCII 走査に加えて 16bit 走査も行います。これを行わないと
|
||||||
|
/// コード中のパスワードリテラルを取り逃がします。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">対象バイト列</param>
|
||||||
|
/// <param name="highPriority">パスワード指定近傍の候補の追加先</param>
|
||||||
|
/// <param name="lowPriority">その他の候補の追加先</param>
|
||||||
|
/// <param name="seen">重複排除用の集合</param>
|
||||||
|
private static void CollectFromBytes(
|
||||||
|
byte[] bytes,
|
||||||
|
List<string> highPriority,
|
||||||
|
List<string> lowPriority,
|
||||||
|
HashSet<string> seen)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
count = CollectAsciiStrings(bytes, highPriority, lowPriority, seen, count);
|
||||||
|
if (count >= MaxCandidatesPerFile)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UTF-16LE(.NET の文字列定数)としても走査する
|
||||||
|
CollectUtf16Strings(bytes, highPriority, lowPriority, seen, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 8bit ASCII 文字列を抽出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">対象バイト列</param>
|
||||||
|
/// <param name="highPriority">高優先候補の追加先</param>
|
||||||
|
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||||
|
/// <param name="seen">重複排除用の集合</param>
|
||||||
|
/// <param name="count">既に追加済みの件数</param>
|
||||||
|
/// <returns>追加後の件数</returns>
|
||||||
|
private static int CollectAsciiStrings(
|
||||||
|
byte[] bytes,
|
||||||
|
List<string> highPriority,
|
||||||
|
List<string> lowPriority,
|
||||||
|
HashSet<string> seen,
|
||||||
|
int count)
|
||||||
|
{
|
||||||
|
var current = new StringBuilder(MaxCandidateLength);
|
||||||
|
|
||||||
|
for (int i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
byte b = bytes[i];
|
||||||
|
|
||||||
|
// 印字可能な ASCII のみを文字列として扱う
|
||||||
|
if (b >= 0x21 && b <= 0x7E)
|
||||||
|
{
|
||||||
|
if (current.Length < MaxCandidateLength)
|
||||||
|
{
|
||||||
|
current.Append((char)b);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||||
|
if (count >= MaxCandidatesPerFile)
|
||||||
|
{
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
current.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UTF-16LE(下位バイトが印字可能 ASCII、上位バイトが 0x00)の文字列を抽出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">対象バイト列</param>
|
||||||
|
/// <param name="highPriority">高優先候補の追加先</param>
|
||||||
|
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||||
|
/// <param name="seen">重複排除用の集合</param>
|
||||||
|
/// <param name="count">既に追加済みの件数</param>
|
||||||
|
/// <returns>追加後の件数</returns>
|
||||||
|
private static int CollectUtf16Strings(
|
||||||
|
byte[] bytes,
|
||||||
|
List<string> highPriority,
|
||||||
|
List<string> lowPriority,
|
||||||
|
HashSet<string> seen,
|
||||||
|
int count)
|
||||||
|
{
|
||||||
|
var current = new StringBuilder(MaxCandidateLength);
|
||||||
|
|
||||||
|
for (int i = 0; i + 1 < bytes.Length; i += 2)
|
||||||
|
{
|
||||||
|
byte lo = bytes[i];
|
||||||
|
byte hi = bytes[i + 1];
|
||||||
|
|
||||||
|
if (lo >= 0x21 && lo <= 0x7E && hi == 0x00)
|
||||||
|
{
|
||||||
|
if (current.Length < MaxCandidateLength)
|
||||||
|
{
|
||||||
|
current.Append((char)lo);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||||
|
if (count >= MaxCandidatesPerFile)
|
||||||
|
{
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
current.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return FlushCandidate(current, highPriority, lowPriority, seen, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 蓄積中の文字列を候補として確定し、優先度別リストへ追加します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="buffer">蓄積中の文字列バッファ</param>
|
||||||
|
/// <param name="highPriority">高優先候補の追加先</param>
|
||||||
|
/// <param name="lowPriority">低優先候補の追加先</param>
|
||||||
|
/// <param name="seen">重複排除用の集合</param>
|
||||||
|
/// <param name="count">既に追加済みの件数</param>
|
||||||
|
/// <returns>追加後の件数</returns>
|
||||||
|
private static int FlushCandidate(
|
||||||
|
StringBuilder buffer,
|
||||||
|
List<string> highPriority,
|
||||||
|
List<string> lowPriority,
|
||||||
|
HashSet<string> seen,
|
||||||
|
int count)
|
||||||
|
{
|
||||||
|
if (buffer.Length < MinCandidateLength || buffer.Length > MaxCandidateLength)
|
||||||
|
{
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
var candidate = buffer.ToString();
|
||||||
|
if (!IsPlausibleCandidate(candidate) || !seen.Add(candidate))
|
||||||
|
{
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ContainsPasswordHint(candidate))
|
||||||
|
{
|
||||||
|
highPriority.Add(candidate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lowPriority.Add(candidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return count + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 抽出した文字列がパスワード候補として妥当かどうかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">候補文字列</param>
|
||||||
|
/// <returns>妥当な場合 true</returns>
|
||||||
|
private static bool IsPlausibleCandidate(string candidate)
|
||||||
|
{
|
||||||
|
if (!CandidatePattern.IsMatch(candidate))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 空白を含む説明文・UI ラベルは除外
|
||||||
|
if (SentenceLikePattern.IsMatch(candidate))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unity の内部名・名前空間などはノイズとして除外
|
||||||
|
if (NoisePattern.IsMatch(candidate))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拡張子付きファイル名は除外
|
||||||
|
if (candidate.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.EndsWith(".dat", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.EndsWith(".es3", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
candidate.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字列がパスワード指定箇所の手がかりを含むかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">候補文字列</param>
|
||||||
|
/// <returns>手がかりを含む場合 true</returns>
|
||||||
|
private static bool ContainsPasswordHint(string candidate)
|
||||||
|
{
|
||||||
|
foreach (var hint in PasswordHints)
|
||||||
|
{
|
||||||
|
if (candidate.Contains(hint, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,559 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services.Codecs.Es3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// "どの段階でパスワードが判明したか" を表す解決手段の種別。
|
||||||
|
/// </summary>
|
||||||
|
public enum Es3PasswordSource
|
||||||
|
{
|
||||||
|
/// <summary>学習キャッシュ(過去に解決済みのパスワード)から復元。</summary>
|
||||||
|
LearnedCache,
|
||||||
|
|
||||||
|
/// <summary>呼び出し元が明示指定したパスワード。</summary>
|
||||||
|
Explicit,
|
||||||
|
|
||||||
|
/// <summary>ゲーム内のマネージドアセンブリ(Assembly-CSharp.dll 等)の文字列リテラルから抽出。</summary>
|
||||||
|
GameBinaryStrings,
|
||||||
|
|
||||||
|
/// <summary>ゲーム内バイナリ(IL2CPP の GameAssembly.dll / global-metadata.dat)から抽出。</summary>
|
||||||
|
GameIl2CppMetadata,
|
||||||
|
|
||||||
|
/// <summary>ユーザー辞書ファイル/既定の候補リストからの探索。</summary>
|
||||||
|
Dictionary,
|
||||||
|
|
||||||
|
/// <summary>平文のまま(暗号化されていない)。</summary>
|
||||||
|
PlainText
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 パスワード解決の結果。<see cref="Success"/> が false の場合は <see cref="Diagnostics"/> に理由が入ります。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Es3PasswordResolution
|
||||||
|
{
|
||||||
|
/// <summary>解決に成功したか。</summary>
|
||||||
|
public bool Success { get; init; }
|
||||||
|
|
||||||
|
/// <summary>解決したパスワード(平文・暗号化なしの場合は空文字)。</summary>
|
||||||
|
public string Password { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>解決手段の種別。</summary>
|
||||||
|
public Es3PasswordSource Source { get; init; }
|
||||||
|
|
||||||
|
/// <summary>試行した候補数。</summary>
|
||||||
|
public int TriedCandidates { get; init; }
|
||||||
|
|
||||||
|
/// <summary>診断用のメッセージ一覧(失敗理由・各段階の結果)。</summary>
|
||||||
|
public IReadOnlyList<string> Diagnostics { get; init; } = [];
|
||||||
|
|
||||||
|
/// <summary>失敗結果を生成します。</summary>
|
||||||
|
public static Es3PasswordResolution Fail(List<string> diagnostics, int tried)
|
||||||
|
=> new() { Success = false, Diagnostics = diagnostics, TriedCandidates = tried };
|
||||||
|
|
||||||
|
/// <summary>成功結果を生成します。</summary>
|
||||||
|
public static Es3PasswordResolution Ok(string password, Es3PasswordSource source, int tried)
|
||||||
|
=> new() { Success = true, Password = password, Source = source, TriedCandidates = tried };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 (Easy Save 3) の暗号化セーブデータからパスワードを多段フォールバックで特定する汎用リゾルバ。
|
||||||
|
///
|
||||||
|
/// 解決順序:
|
||||||
|
/// 1. 学習キャッシュ(<see cref="Es3PasswordStore"/>)
|
||||||
|
/// 2. 呼び出し元の明示指定
|
||||||
|
/// 3. ゲームのマネージドアセンブリ文字列リテラル抽出(Mono)
|
||||||
|
/// 4. 既定候補 + ユーザー辞書による探索
|
||||||
|
///
|
||||||
|
/// すべての候補は実際に AES 復号して妥当性を検証し、成功したものだけを採用します。
|
||||||
|
/// これにより「誤ったパスワードで復号して壊れたデータを書く」事故を防止します。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Es3PasswordResolver
|
||||||
|
{
|
||||||
|
/// <summary>ES3 が AES 暗号化時にファイル先頭へ埋め込む IV の長さ(バイト)。</summary>
|
||||||
|
public const int AesIvLength = 16;
|
||||||
|
|
||||||
|
/// <summary>復号結果が「ES3 の平文 JSON」らしいかを判定する際の最小文字数。</summary>
|
||||||
|
private const int MinimumPlainTextLength = 2;
|
||||||
|
|
||||||
|
private readonly Es3PasswordStore _store;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既定のストアを用いて <see cref="Es3PasswordResolver"/> を初期化します。
|
||||||
|
/// </summary>
|
||||||
|
public Es3PasswordResolver()
|
||||||
|
: this(Es3PasswordStore.Instance)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任意のストアを指定して <see cref="Es3PasswordResolver"/> を初期化します(テスト用途を含む)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="store">学習済みパスワードの永続ストア</param>
|
||||||
|
public Es3PasswordResolver(Es3PasswordStore store)
|
||||||
|
{
|
||||||
|
this._store = store ?? throw new ArgumentNullException(nameof(store));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既定のシングルトンインスタンス。
|
||||||
|
/// </summary>
|
||||||
|
public static Es3PasswordResolver Instance { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 のファイルが暗号化されているかどうかを統計的に判定します。
|
||||||
|
/// 平文 JSON / Gzip はもちろん「暗号化されていない」と判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">ファイル全体のバイト列</param>
|
||||||
|
/// <returns>暗号化されている可能性が高い場合 true</returns>
|
||||||
|
public static bool LooksEncrypted(byte[] bytes)
|
||||||
|
{
|
||||||
|
if (bytes == null || bytes.Length < AesIvLength * 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 平文 JSON はそのまま読める
|
||||||
|
if (IsLikelyJson(bytes))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gzip マジック
|
||||||
|
if (bytes[0] == 0x1F && bytes[1] == 0x8B)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AES ブロック境界に一致し、かつ高エントロピーなら暗号化とみなす
|
||||||
|
if (bytes.Length % AesIvLength != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CalculateEntropy(bytes) >= 7.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワードを多段フォールバックで解決します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="saveFilePath">対象の .es3 ファイルの絶対パス</param>
|
||||||
|
/// <param name="gameRootDirectory">ゲームのルートディレクトリ(文字列抽出元の探索に使用)</param>
|
||||||
|
/// <param name="gameKey">学習キャッシュのキー(通常はゲームのルートディレクトリ)</param>
|
||||||
|
/// <param name="explicitPassword">呼び出し元が既に知っているパスワード(任意)</param>
|
||||||
|
/// <param name="userDictionaryPath">追加候補を列挙したテキストファイルのパス(任意)</param>
|
||||||
|
/// <returns>解決結果</returns>
|
||||||
|
public Es3PasswordResolution Resolve(
|
||||||
|
string saveFilePath,
|
||||||
|
string? gameRootDirectory = null,
|
||||||
|
string? gameKey = null,
|
||||||
|
string? explicitPassword = null,
|
||||||
|
string? userDictionaryPath = null)
|
||||||
|
{
|
||||||
|
var diagnostics = new List<string>();
|
||||||
|
int tried = 0;
|
||||||
|
|
||||||
|
byte[] fileBytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileBytes = File.ReadAllBytes(saveFilePath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
diagnostics.Add($"セーブファイルを読み込めません: {ex.Message}");
|
||||||
|
return Es3PasswordResolution.Fail(diagnostics, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileBytes.Length == 0)
|
||||||
|
{
|
||||||
|
diagnostics.Add("セーブファイルが空です。");
|
||||||
|
return Es3PasswordResolution.Fail(diagnostics, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暗号化されていない場合はパスワード不要
|
||||||
|
if (!LooksEncrypted(fileBytes))
|
||||||
|
{
|
||||||
|
diagnostics.Add("暗号化は検出されませんでした(平文または Gzip)。");
|
||||||
|
return Es3PasswordResolution.Ok(string.Empty, Es3PasswordSource.PlainText, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.Add($"暗号化を検出しました({fileBytes.Length} bytes / AES-128-CBC 相当)。");
|
||||||
|
|
||||||
|
// ---- 段階 1: 学習キャッシュ ----
|
||||||
|
var cacheKey = this.BuildCacheKey(gameKey, saveFilePath);
|
||||||
|
if (!string.IsNullOrEmpty(cacheKey))
|
||||||
|
{
|
||||||
|
var learned = this._store.TryGet(cacheKey);
|
||||||
|
if (!string.IsNullOrEmpty(learned))
|
||||||
|
{
|
||||||
|
tried++;
|
||||||
|
if (this.VerifyPassword(fileBytes, learned, out _))
|
||||||
|
{
|
||||||
|
diagnostics.Add("学習キャッシュのパスワードで復号に成功しました。");
|
||||||
|
return Es3PasswordResolution.Ok(learned, Es3PasswordSource.LearnedCache, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.Add("学習キャッシュのパスワードは無効でした(破棄します)。");
|
||||||
|
this._store.Remove(cacheKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- 段階 2: 明示指定 ----
|
||||||
|
if (!string.IsNullOrEmpty(explicitPassword))
|
||||||
|
{
|
||||||
|
tried++;
|
||||||
|
if (this.VerifyPassword(fileBytes, explicitPassword, out _))
|
||||||
|
{
|
||||||
|
diagnostics.Add("指定されたパスワードで復号に成功しました。");
|
||||||
|
this.Remember(cacheKey, explicitPassword);
|
||||||
|
return Es3PasswordResolution.Ok(explicitPassword, Es3PasswordSource.Explicit, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.Add("指定されたパスワードでは復号できませんでした。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- 段階 3: ゲームバイナリの文字列リテラル抽出 ----
|
||||||
|
if (!string.IsNullOrEmpty(gameRootDirectory) && Directory.Exists(gameRootDirectory))
|
||||||
|
{
|
||||||
|
var extracted = Es3PasswordExtractor.ExtractCandidates(gameRootDirectory, diagnostics);
|
||||||
|
foreach (var candidate in extracted)
|
||||||
|
{
|
||||||
|
tried++;
|
||||||
|
if (this.VerifyPassword(fileBytes, candidate, out _))
|
||||||
|
{
|
||||||
|
diagnostics.Add($"ゲームバイナリから抽出した候補で復号に成功しました(候補: {Mask(candidate)})。");
|
||||||
|
this.Remember(cacheKey, candidate);
|
||||||
|
return Es3PasswordResolution.Ok(candidate, Es3PasswordSource.GameBinaryStrings, tried);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extracted.Count == 0)
|
||||||
|
{
|
||||||
|
diagnostics.Add("ゲームバイナリから有効なパスワード候補を抽出できませんでした。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- 段階 4: 既定候補 + ユーザー辞書 ----
|
||||||
|
foreach (var candidate in this.EnumerateDictionaryCandidates(userDictionaryPath, diagnostics))
|
||||||
|
{
|
||||||
|
tried++;
|
||||||
|
if (this.VerifyPassword(fileBytes, candidate, out _))
|
||||||
|
{
|
||||||
|
diagnostics.Add($"辞書探索で復号に成功しました(候補: {Mask(candidate)})。");
|
||||||
|
this.Remember(cacheKey, candidate);
|
||||||
|
return Es3PasswordResolution.Ok(candidate, Es3PasswordSource.Dictionary, tried);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.Add($"すべての段階で復号に失敗しました(試行候補数: {tried})。パスワードを手動で入力してください。");
|
||||||
|
return Es3PasswordResolution.Fail(diagnostics, tried);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定パスワードで ES3 ファイルを復号し、平文 JSON 文字列を取得します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileBytes">ファイル全体のバイト列</param>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
/// <param name="plainText">復号された平文 JSON</param>
|
||||||
|
/// <returns>復号に成功した場合 true</returns>
|
||||||
|
public bool VerifyPassword(byte[] fileBytes, string password, out string plainText)
|
||||||
|
{
|
||||||
|
plainText = string.Empty;
|
||||||
|
var plain = TryDecrypt(fileBytes, password);
|
||||||
|
if (plain == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
plainText = plain;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の AES-128-CBC 形式で復号を試みます。
|
||||||
|
/// ファイル先頭 16 バイトを IV、残りを暗号文として扱い、鍵はパスワード UTF-8 の先頭 16 バイトをゼロ埋めします。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileBytes">ファイル全体のバイト列</param>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
/// <returns>復号された平文 JSON。失敗時は null</returns>
|
||||||
|
public static string? TryDecrypt(byte[] fileBytes, string password)
|
||||||
|
{
|
||||||
|
if (fileBytes == null || fileBytes.Length <= AesIvLength)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var iv = new byte[AesIvLength];
|
||||||
|
Array.Copy(fileBytes, 0, iv, 0, AesIvLength);
|
||||||
|
|
||||||
|
var cipher = new byte[fileBytes.Length - AesIvLength];
|
||||||
|
Array.Copy(fileBytes, AesIvLength, cipher, 0, cipher.Length);
|
||||||
|
|
||||||
|
using var aes = Aes.Create();
|
||||||
|
aes.Mode = CipherMode.CBC;
|
||||||
|
aes.Padding = PaddingMode.PKCS7;
|
||||||
|
aes.Key = DeriveKey(password);
|
||||||
|
aes.IV = iv;
|
||||||
|
|
||||||
|
using var decryptor = aes.CreateDecryptor();
|
||||||
|
var plain = decryptor.TransformFinalBlock(cipher, 0, cipher.Length);
|
||||||
|
|
||||||
|
var text = Encoding.UTF8.GetString(plain);
|
||||||
|
return IsPlausiblePlainText(text) ? text : null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 平文バイト列を ES3 の AES-128-CBC 形式で暗号化します(IV を先頭に付与)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plainBytes">平文バイト列</param>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
/// <returns>IV + 暗号文のバイト列</returns>
|
||||||
|
public static byte[] Encrypt(byte[] plainBytes, string password)
|
||||||
|
{
|
||||||
|
using var aes = Aes.Create();
|
||||||
|
aes.Mode = CipherMode.CBC;
|
||||||
|
aes.Padding = PaddingMode.PKCS7;
|
||||||
|
aes.Key = DeriveKey(password);
|
||||||
|
aes.GenerateIV();
|
||||||
|
|
||||||
|
using var encryptor = aes.CreateEncryptor();
|
||||||
|
var cipher = encryptor.TransformFinalBlock(plainBytes, 0, plainBytes.Length);
|
||||||
|
|
||||||
|
var result = new byte[aes.IV.Length + cipher.Length];
|
||||||
|
Array.Copy(aes.IV, 0, result, 0, aes.IV.Length);
|
||||||
|
Array.Copy(cipher, 0, result, aes.IV.Length, cipher.Length);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワード文字列から AES-128 用の 16 バイト鍵を導出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
/// <returns>16 バイトの鍵</returns>
|
||||||
|
private static byte[] DeriveKey(string password)
|
||||||
|
{
|
||||||
|
var raw = Encoding.UTF8.GetBytes(password ?? string.Empty);
|
||||||
|
var key = new byte[16];
|
||||||
|
Array.Copy(raw, key, Math.Min(raw.Length, key.Length));
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 復号結果が ES3 の平文として妥当かを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">復号された文字列</param>
|
||||||
|
/// <returns>妥当な場合 true</returns>
|
||||||
|
private static bool IsPlausiblePlainText(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text) || text.Length < MinimumPlainTextLength)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var trimmed = text.TrimStart();
|
||||||
|
if (trimmed.StartsWith('{') || trimmed.StartsWith('['))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ES3 の内部シリアライズ形式は "__type" を必ず含む
|
||||||
|
return text.Contains("__type", StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// バイト列が平文 JSON かどうかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">対象バイト列</param>
|
||||||
|
/// <returns>平文 JSON と判断できる場合 true</returns>
|
||||||
|
private static bool IsLikelyJson(byte[] bytes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int length = Math.Min(bytes.Length, 64);
|
||||||
|
var head = Encoding.UTF8.GetString(bytes, 0, length).TrimStart();
|
||||||
|
return head.StartsWith('{') || head.StartsWith('[');
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// バイト列のシャノンエントロピー(bits/byte)を算出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes">対象バイト列</param>
|
||||||
|
/// <returns>エントロピー値</returns>
|
||||||
|
private static double CalculateEntropy(byte[] bytes)
|
||||||
|
{
|
||||||
|
var frequency = new int[256];
|
||||||
|
foreach (var b in bytes)
|
||||||
|
{
|
||||||
|
frequency[b]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
double entropy = 0.0;
|
||||||
|
foreach (var count in frequency)
|
||||||
|
{
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
double p = (double)count / bytes.Length;
|
||||||
|
entropy -= p * Math.Log2(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return entropy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 学習キャッシュ用のキーを生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameKey">ゲーム識別キー</param>
|
||||||
|
/// <param name="saveFilePath">セーブファイルパス</param>
|
||||||
|
/// <returns>キャッシュキー</returns>
|
||||||
|
private string BuildCacheKey(string? gameKey, string saveFilePath)
|
||||||
|
{
|
||||||
|
var key = !string.IsNullOrWhiteSpace(gameKey)
|
||||||
|
? gameKey!
|
||||||
|
: Path.GetDirectoryName(saveFilePath) ?? string.Empty;
|
||||||
|
|
||||||
|
return key.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解決済みパスワードを学習キャッシュへ保存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cacheKey">キャッシュキー</param>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
private void Remember(string? cacheKey, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(cacheKey))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._store.Set(cacheKey, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 辞書段階で試行する候補列挙子を返します(既定候補 → ユーザー辞書の順)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userDictionaryPath">ユーザー辞書ファイルのパス</param>
|
||||||
|
/// <param name="diagnostics">診断メッセージの追加先</param>
|
||||||
|
/// <returns>候補の列挙</returns>
|
||||||
|
private IEnumerable<string> EnumerateDictionaryCandidates(string? userDictionaryPath, List<string> diagnostics)
|
||||||
|
{
|
||||||
|
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||||
|
|
||||||
|
foreach (var candidate in GetBuiltInCandidates())
|
||||||
|
{
|
||||||
|
if (seen.Add(candidate))
|
||||||
|
{
|
||||||
|
yield return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(userDictionaryPath))
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(userDictionaryPath))
|
||||||
|
{
|
||||||
|
diagnostics.Add($"ユーザー辞書が見つかりません: {userDictionaryPath}");
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] lines;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lines = File.ReadAllLines(userDictionaryPath, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
diagnostics.Add($"ユーザー辞書の読み込みに失敗しました: {ex.Message}");
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnostics.Add($"ユーザー辞書を適用します({lines.Length} 行): {userDictionaryPath}");
|
||||||
|
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
var candidate = line.Trim();
|
||||||
|
if (candidate.Length == 0 || candidate.StartsWith('#'))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seen.Add(candidate))
|
||||||
|
{
|
||||||
|
yield return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Easy Save 3 でよく使われる既定のパスワード候補を返します。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>既定候補の並び</returns>
|
||||||
|
private static IEnumerable<string> GetBuiltInCandidates()
|
||||||
|
{
|
||||||
|
// 空文字(パスワード未設定のまま暗号化されたケース)を最初に試す
|
||||||
|
yield return string.Empty;
|
||||||
|
yield return "password";
|
||||||
|
yield return "Password";
|
||||||
|
yield return "PASSWORD";
|
||||||
|
yield return "Moodkie";
|
||||||
|
yield return "moodkie";
|
||||||
|
yield return "EasySave";
|
||||||
|
yield return "easysave";
|
||||||
|
yield return "EasySave3";
|
||||||
|
yield return "es3";
|
||||||
|
yield return "ES3";
|
||||||
|
yield return "SaveData";
|
||||||
|
yield return "savedata";
|
||||||
|
yield return "Save";
|
||||||
|
yield return "save";
|
||||||
|
yield return "secret";
|
||||||
|
yield return "Secret";
|
||||||
|
yield return "123456";
|
||||||
|
yield return "1234567890";
|
||||||
|
yield return "admin";
|
||||||
|
yield return "test";
|
||||||
|
yield return "game";
|
||||||
|
yield return "Game";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 診断ログ用にパスワードをマスクします(先頭 2 文字のみ残す)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="password">パスワード</param>
|
||||||
|
/// <returns>マスク済み文字列</returns>
|
||||||
|
private static string Mask(string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
return "(空)";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password.Length <= 2)
|
||||||
|
{
|
||||||
|
return new string('*', password.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return password[..2] + new string('*', Math.Min(password.Length - 2, 8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using GameLauncher.Helpers;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services.Codecs.Es3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 のパスワード特定結果を「ゲーム単位」で永続化する学習キャッシュ。
|
||||||
|
///
|
||||||
|
/// 一度解決したパスワードを保存しておくことで、次回以降は自動適用できます。
|
||||||
|
/// 保存先は exe 直下の <c>es3-passwords.json</c> で、キャッシュ破棄やブックマークとは独立に管理します。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Es3PasswordStore
|
||||||
|
{
|
||||||
|
/// <summary>永続化ファイル名。</summary>
|
||||||
|
private const string FileName = "es3-passwords.json";
|
||||||
|
|
||||||
|
/// <summary>既定のシングルトンインスタンス。</summary>
|
||||||
|
public static Es3PasswordStore Instance { get; } = new();
|
||||||
|
|
||||||
|
private readonly object _syncRoot = new();
|
||||||
|
private readonly string _filePath;
|
||||||
|
private Dictionary<string, string>? _entries;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// exe 直下の既定パスを用いて <see cref="Es3PasswordStore"/> を初期化します。
|
||||||
|
/// </summary>
|
||||||
|
public Es3PasswordStore()
|
||||||
|
: this(Path.Combine(AppPathHelper.GetExeDirectory(), FileName))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任意のファイルパスを指定して <see cref="Es3PasswordStore"/> を初期化します(テスト用途を含む)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">永続化ファイルの絶対パス</param>
|
||||||
|
public Es3PasswordStore(string filePath)
|
||||||
|
{
|
||||||
|
this._filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 永続化ファイルのパスを取得します。
|
||||||
|
/// </summary>
|
||||||
|
public string FilePath => this._filePath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定キーに対応する学習済みパスワードを取得します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">ゲーム単位のキー(通常はゲームのルートディレクトリ)</param>
|
||||||
|
/// <returns>保存済みパスワード。未登録の場合は null</returns>
|
||||||
|
public string? TryGet(string key)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(key))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (this._syncRoot)
|
||||||
|
{
|
||||||
|
var entries = this.LoadEntries();
|
||||||
|
return entries.TryGetValue(Normalize(key), out var password) ? password : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 学習済みパスワードを保存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">ゲーム単位のキー</param>
|
||||||
|
/// <param name="password">保存するパスワード(空文字も有効な値として保存します)</param>
|
||||||
|
public void Set(string key, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(key))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (this._syncRoot)
|
||||||
|
{
|
||||||
|
var entries = this.LoadEntries();
|
||||||
|
entries[Normalize(key)] = password ?? string.Empty;
|
||||||
|
this.SaveEntries(entries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定キーの学習済みパスワードを削除します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">ゲーム単位のキー</param>
|
||||||
|
/// <returns>削除できた場合 true</returns>
|
||||||
|
public bool Remove(string key)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(key))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (this._syncRoot)
|
||||||
|
{
|
||||||
|
var entries = this.LoadEntries();
|
||||||
|
if (!entries.Remove(Normalize(key)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SaveEntries(entries);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存済みエントリのスナップショットを取得します(表示・診断用)。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>キーとパスワードの読み取り専用ディクショナリ</returns>
|
||||||
|
public IReadOnlyDictionary<string, string> Snapshot()
|
||||||
|
{
|
||||||
|
lock (this._syncRoot)
|
||||||
|
{
|
||||||
|
return new Dictionary<string, string>(this.LoadEntries(), StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 永続化ファイルを読み込みます。壊れている場合は空のディクショナリを返します。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>読み込んだエントリ</returns>
|
||||||
|
private Dictionary<string, string> LoadEntries()
|
||||||
|
{
|
||||||
|
if (this._entries != null)
|
||||||
|
{
|
||||||
|
return this._entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(this._filePath))
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(this._filePath, Encoding.UTF8);
|
||||||
|
if (!string.IsNullOrWhiteSpace(json))
|
||||||
|
{
|
||||||
|
var loaded = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
|
||||||
|
if (loaded != null)
|
||||||
|
{
|
||||||
|
foreach (var kvp in loaded)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(kvp.Key))
|
||||||
|
{
|
||||||
|
result[Normalize(kvp.Key)] = kvp.Value ?? string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 破損ファイルは無視し、空の状態から再構築する
|
||||||
|
result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._entries = result;
|
||||||
|
return this._entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// エントリを永続化ファイルへ書き出します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries">書き出すエントリ</param>
|
||||||
|
private void SaveEntries(Dictionary<string, string> entries)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var directory = Path.GetDirectoryName(this._filePath);
|
||||||
|
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||||
|
var json = JsonSerializer.Serialize(entries, options);
|
||||||
|
|
||||||
|
// BOM なし UTF-8 で保存する
|
||||||
|
File.WriteAllText(this._filePath, json, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 保存失敗は致命的ではないため握りつぶす(次回再度解決を試みる)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// キーを比較用に正規化します(パス区切りと大文字小文字の揺れを吸収)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">元のキー</param>
|
||||||
|
/// <returns>正規化済みキー</returns>
|
||||||
|
private static string Normalize(string key)
|
||||||
|
{
|
||||||
|
var trimmed = key.Trim();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Path.GetFullPath(trimmed).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,891 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services.Codecs.Es3
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 のシリアライズ要素が持つ「型」の種別。
|
||||||
|
/// ES3 は <c>{ "__type": "System.Int32", "value": 42 }</c> 形式で値を格納するため、
|
||||||
|
/// この列挙子で GUI 側へ型情報を伝えます。
|
||||||
|
/// </summary>
|
||||||
|
public enum Es3ValueKind
|
||||||
|
{
|
||||||
|
/// <summary>不明・未判定。</summary>
|
||||||
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>真偽値。</summary>
|
||||||
|
Boolean,
|
||||||
|
|
||||||
|
/// <summary>整数(Int32 / Int64 / UInt32 等)。</summary>
|
||||||
|
Integer,
|
||||||
|
|
||||||
|
/// <summary>浮動小数(Single / Double / Decimal)。</summary>
|
||||||
|
Float,
|
||||||
|
|
||||||
|
/// <summary>文字列。</summary>
|
||||||
|
String,
|
||||||
|
|
||||||
|
/// <summary>列挙体。</summary>
|
||||||
|
Enum,
|
||||||
|
|
||||||
|
/// <summary>配列。</summary>
|
||||||
|
Array,
|
||||||
|
|
||||||
|
/// <summary>辞書(キーと値の組)。</summary>
|
||||||
|
Dictionary,
|
||||||
|
|
||||||
|
/// <summary>入れ子オブジェクト。</summary>
|
||||||
|
Object
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 ファイル内の 1 項目を表す型付きノード。
|
||||||
|
/// JSON ツリー上の位置(<see cref="Path"/>)を保持するため、編集後の書き戻しが安全に行えます。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Es3Node
|
||||||
|
{
|
||||||
|
/// <summary>キー名(辞書・オブジェクトの子の場合)。</summary>
|
||||||
|
public string Key { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>親をたどる JSON パス(例: <c>$.player.stats.hp</c>)。</summary>
|
||||||
|
public string Path { get; set; } = "$";
|
||||||
|
|
||||||
|
/// <summary>ES3 が示す型名(例: <c>System.Int32</c>、<c>System.Collections.Generic.List`1</c>)。</summary>
|
||||||
|
public string TypeName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>判定した値種別。</summary>
|
||||||
|
public Es3ValueKind Kind { get; set; } = Es3ValueKind.Unknown;
|
||||||
|
|
||||||
|
/// <summary>現在の値(文字列化した表示・編集用の値)。</summary>
|
||||||
|
public string DisplayValue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>元の JSON 値(書き戻し時の型再現に使用)。</summary>
|
||||||
|
public JsonNode? OriginalNode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>配列・辞書・オブジェクトの場合の子要素。</summary>
|
||||||
|
public List<Es3Node> Children { get; } = [];
|
||||||
|
|
||||||
|
/// <summary>子要素を持つか。</summary>
|
||||||
|
public bool HasChildren => this.Children.Count > 0;
|
||||||
|
|
||||||
|
/// <summary>エディタで直接値を編集できる型か。</summary>
|
||||||
|
public bool IsEditable => this.Kind is Es3ValueKind.Boolean
|
||||||
|
or Es3ValueKind.Integer
|
||||||
|
or Es3ValueKind.Float
|
||||||
|
or Es3ValueKind.String
|
||||||
|
or Es3ValueKind.Enum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 (Easy Save 3) のセーブデータ本体(復号後の JSON)を解析し、
|
||||||
|
/// キー名・型・値を読み取るとともに、編集結果を安全に書き戻すパーサ/ライタ。
|
||||||
|
///
|
||||||
|
/// ES3 の内部形式は次の 2 通りが混在します:
|
||||||
|
/// <c>{ "key": { "__type": "System.Int32", "value": 100 } }</c>
|
||||||
|
/// <c>{ "key": { "__type": "System.Collections.Generic.Dictionary`2[...]", "value": { ... } } }</c>
|
||||||
|
/// 本クラスは両形式を展開し、編集後は元の型情報を保持したまま再構築します。
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Es3SaveDocument
|
||||||
|
{
|
||||||
|
/// <summary>ES3 が型情報を格納するプロパティ名。</summary>
|
||||||
|
public const string TypePropertyName = "__type";
|
||||||
|
|
||||||
|
/// <summary>ES3 が値を格納するプロパティ名。</summary>
|
||||||
|
public const string ValuePropertyName = "value";
|
||||||
|
|
||||||
|
/// <summary>解析対象のルート JSON オブジェクト(編集はこのインスタンスを直接書き換えます)。</summary>
|
||||||
|
private JsonNode? _root;
|
||||||
|
|
||||||
|
/// <summary>復号直後の JSON 文字列(差分検出・バックアップ用)。</summary>
|
||||||
|
public string OriginalJson { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>解析に成功したか。</summary>
|
||||||
|
public bool IsLoaded => this._root != null;
|
||||||
|
|
||||||
|
/// <summary>解析時の警告(解釈できなかった要素など)。</summary>
|
||||||
|
public List<string> Warnings { get; } = [];
|
||||||
|
|
||||||
|
/// <summary>ルート直下の項目一覧。</summary>
|
||||||
|
public List<Es3Node> RootNodes { get; } = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の平文 JSON 文字列を解析してドキュメントを構築します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="json">復号済みの平文 JSON</param>
|
||||||
|
/// <returns>解析されたドキュメント</returns>
|
||||||
|
public static Es3SaveDocument Parse(string json)
|
||||||
|
{
|
||||||
|
var document = new Es3SaveDocument { OriginalJson = json ?? string.Empty };
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(json))
|
||||||
|
{
|
||||||
|
document.Warnings.Add("平文 JSON が空です。");
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode? root;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
root = JsonNode.Parse(json, documentOptions: new JsonDocumentOptions
|
||||||
|
{
|
||||||
|
AllowTrailingCommas = true,
|
||||||
|
CommentHandling = JsonCommentHandling.Skip,
|
||||||
|
MaxDepth = 256
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (JsonException ex)
|
||||||
|
{
|
||||||
|
document.Warnings.Add($"JSON 解析に失敗しました: {ex.Message}");
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root == null)
|
||||||
|
{
|
||||||
|
document.Warnings.Add("JSON のルートが null です。");
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
document._root = root;
|
||||||
|
document.BuildTree(root, "$", string.Empty);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析ツリーを走査してルート直下の項目一覧を構築します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="root">JSON ルート</param>
|
||||||
|
/// <param name="path">ルートパス</param>
|
||||||
|
/// <param name="key">キー名</param>
|
||||||
|
private void BuildTree(JsonNode root, string path, string key)
|
||||||
|
{
|
||||||
|
if (root is JsonObject rootObject)
|
||||||
|
{
|
||||||
|
foreach (var kvp in rootObject)
|
||||||
|
{
|
||||||
|
var childPath = $"{path}.{kvp.Key}";
|
||||||
|
var node = this.CreateNode(kvp.Key, childPath, kvp.Value);
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
this.RootNodes.Add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root is JsonArray rootArray)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rootArray.Count; i++)
|
||||||
|
{
|
||||||
|
var childPath = $"{path}[{i}]";
|
||||||
|
var node = this.CreateNode($"[{i}]", childPath, rootArray[i]);
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
this.RootNodes.Add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Warnings.Add($"ルート要素を解釈できませんでした({root.GetValueKind()})。");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON ノードから型付きの <see cref="Es3Node"/> を生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">キー名</param>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <param name="node">対象ノード</param>
|
||||||
|
/// <returns>生成されたノード。解釈不能な場合は null</returns>
|
||||||
|
private Es3Node? CreateNode(string key, string path, JsonNode? node)
|
||||||
|
{
|
||||||
|
var result = new Es3Node
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Path = path,
|
||||||
|
OriginalNode = node
|
||||||
|
};
|
||||||
|
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
result.Kind = Es3ValueKind.Unknown;
|
||||||
|
result.DisplayValue = "null";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (node.GetValueKind())
|
||||||
|
{
|
||||||
|
case JsonValueKind.Object:
|
||||||
|
this.PopulateObject(result, path, node.AsObject());
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case JsonValueKind.Array:
|
||||||
|
result.Kind = Es3ValueKind.Array;
|
||||||
|
result.TypeName = "System.Array";
|
||||||
|
PopulateArray(result, path, node.AsArray());
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case JsonValueKind.String:
|
||||||
|
result.Kind = Es3ValueKind.String;
|
||||||
|
result.TypeName = "System.String";
|
||||||
|
result.DisplayValue = node.GetValue<string>();
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case JsonValueKind.Number:
|
||||||
|
PopulateNumber(result, node);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case JsonValueKind.True:
|
||||||
|
case JsonValueKind.False:
|
||||||
|
result.Kind = Es3ValueKind.Boolean;
|
||||||
|
result.TypeName = "System.Boolean";
|
||||||
|
result.DisplayValue = node.GetValue<bool>() ? "true" : "false";
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case JsonValueKind.Null:
|
||||||
|
result.Kind = Es3ValueKind.Unknown;
|
||||||
|
result.DisplayValue = "null";
|
||||||
|
return result;
|
||||||
|
|
||||||
|
default:
|
||||||
|
result.Kind = Es3ValueKind.Unknown;
|
||||||
|
result.DisplayValue = node.ToJsonString();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON オブジェクトが ES3 の型付き要素か、単なる入れ子オブジェクトかを判定して展開します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">構築対象のノード</param>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <param name="jsonObject">対象の JSON オブジェクト</param>
|
||||||
|
private void PopulateObject(Es3Node target, string path, JsonObject jsonObject)
|
||||||
|
{
|
||||||
|
// ES3 の型付き要素(__type と value を持つ)か判定
|
||||||
|
bool isTyped = jsonObject.ContainsKey(TypePropertyName);
|
||||||
|
|
||||||
|
if (isTyped)
|
||||||
|
{
|
||||||
|
target.TypeName = jsonObject[TypePropertyName]?.GetValue<string>() ?? string.Empty;
|
||||||
|
var inner = jsonObject[ValuePropertyName];
|
||||||
|
|
||||||
|
if (inner == null)
|
||||||
|
{
|
||||||
|
target.Kind = MapTypeNameToKind(target.TypeName);
|
||||||
|
target.DisplayValue = "null";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var innerKind = inner.GetValueKind();
|
||||||
|
|
||||||
|
if (innerKind == JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
// 辞書・入れ子オブジェクト
|
||||||
|
var innerObject = inner.AsObject();
|
||||||
|
target.Kind = LooksLikeDictionary(innerObject, target.TypeName)
|
||||||
|
? Es3ValueKind.Dictionary
|
||||||
|
: Es3ValueKind.Object;
|
||||||
|
|
||||||
|
foreach (var kvp in innerObject)
|
||||||
|
{
|
||||||
|
var childPath = $"{path}.{kvp.Key}";
|
||||||
|
var child = this.CreateNode(kvp.Key, childPath, kvp.Value);
|
||||||
|
if (child != null)
|
||||||
|
{
|
||||||
|
target.Children.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.DisplayValue = $"({target.Children.Count} 項目)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (innerKind == JsonValueKind.Array)
|
||||||
|
{
|
||||||
|
target.Kind = Es3ValueKind.Array;
|
||||||
|
PopulateArray(target, path, inner.AsArray());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// プリミティブ値
|
||||||
|
target.Kind = MapTypeNameToKind(target.TypeName);
|
||||||
|
target.DisplayValue = FormatScalar(inner, target.Kind);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 型情報なしの入れ子オブジェクト
|
||||||
|
target.Kind = Es3ValueKind.Object;
|
||||||
|
target.TypeName = "System.Object";
|
||||||
|
|
||||||
|
foreach (var kvp in jsonObject)
|
||||||
|
{
|
||||||
|
var childPath = $"{path}.{kvp.Key}";
|
||||||
|
var child = this.CreateNode(kvp.Key, childPath, kvp.Value);
|
||||||
|
if (child != null)
|
||||||
|
{
|
||||||
|
target.Children.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.DisplayValue = $"({target.Children.Count} 項目)";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配列を走査して子要素を追加します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">構築対象のノード</param>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <param name="array">対象の JSON 配列</param>
|
||||||
|
private static void PopulateArray(Es3Node target, string path, JsonArray array)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < array.Count; i++)
|
||||||
|
{
|
||||||
|
var childPath = $"{path}[{i}]";
|
||||||
|
var elementNode = array[i];
|
||||||
|
|
||||||
|
var child = new Es3Node
|
||||||
|
{
|
||||||
|
Key = $"[{i}]",
|
||||||
|
Path = childPath,
|
||||||
|
OriginalNode = elementNode
|
||||||
|
};
|
||||||
|
|
||||||
|
if (elementNode == null)
|
||||||
|
{
|
||||||
|
child.Kind = Es3ValueKind.Unknown;
|
||||||
|
child.DisplayValue = "null";
|
||||||
|
}
|
||||||
|
else if (elementNode.GetValueKind() == JsonValueKind.Object &&
|
||||||
|
elementNode.AsObject().ContainsKey(TypePropertyName))
|
||||||
|
{
|
||||||
|
// 配列要素が型付き要素の場合は再帰的に展開する
|
||||||
|
var innerObject = elementNode.AsObject();
|
||||||
|
child.TypeName = innerObject[TypePropertyName]?.GetValue<string>() ?? string.Empty;
|
||||||
|
var inner = innerObject[ValuePropertyName];
|
||||||
|
|
||||||
|
if (inner != null && inner.GetValueKind() == JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
child.Kind = Es3ValueKind.Object;
|
||||||
|
foreach (var kvp in inner.AsObject())
|
||||||
|
{
|
||||||
|
var grandChild = new Es3Node
|
||||||
|
{
|
||||||
|
Key = kvp.Key,
|
||||||
|
Path = $"{childPath}.{kvp.Key}",
|
||||||
|
OriginalNode = kvp.Value,
|
||||||
|
Kind = MapValueKind(kvp.Value),
|
||||||
|
DisplayValue = FormatScalar(kvp.Value, MapValueKind(kvp.Value))
|
||||||
|
};
|
||||||
|
child.Children.Add(grandChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
child.DisplayValue = $"({child.Children.Count} 項目)";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
child.Kind = MapTypeNameToKind(child.TypeName);
|
||||||
|
child.DisplayValue = inner == null ? "null" : FormatScalar(inner, child.Kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
child.Kind = MapValueKind(elementNode);
|
||||||
|
child.DisplayValue = FormatScalar(elementNode, child.Kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
target.Children.Add(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
target.DisplayValue = $"({target.Children.Count} 件)";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数値ノードの型情報と表示値を設定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">構築対象のノード</param>
|
||||||
|
/// <param name="node">数値ノード</param>
|
||||||
|
private void PopulateNumber(Es3Node target, JsonNode node)
|
||||||
|
{
|
||||||
|
var raw = node.ToJsonString();
|
||||||
|
|
||||||
|
if (raw.Contains('.') || raw.Contains('e', StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!raw.Contains("0x", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
target.Kind = Es3ValueKind.Float;
|
||||||
|
target.TypeName = "System.Single";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target.Kind = Es3ValueKind.Integer;
|
||||||
|
target.TypeName = "System.Int32";
|
||||||
|
}
|
||||||
|
|
||||||
|
target.DisplayValue = raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ES3 の型名から値種別を推定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="typeName">ES3 の型名</param>
|
||||||
|
/// <returns>推定した値種別</returns>
|
||||||
|
public static Es3ValueKind MapTypeNameToKind(string typeName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(typeName))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
var normalized = typeName.Replace(" ", string.Empty);
|
||||||
|
|
||||||
|
if (normalized.Contains("System.Boolean", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("System.Single", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Double", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Decimal", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Float;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("System.Int", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.UInt", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Byte", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Int64", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Int16", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Integer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("System.String", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("System.Char", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.String;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("Dictionary", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Dictionary;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("[]", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("List`1", StringComparison.Ordinal) ||
|
||||||
|
normalized.Contains("HashSet", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Array;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normalized.Contains("System.Enum", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Enum;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Es3ValueKind.Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 辞書形式(キーと値の組)かどうかを推定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jsonObject">対象オブジェクト</param>
|
||||||
|
/// <param name="typeName">型名</param>
|
||||||
|
/// <returns>辞書と判断できる場合 true</returns>
|
||||||
|
private static bool LooksLikeDictionary(JsonObject jsonObject, string typeName)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(typeName) &&
|
||||||
|
typeName.Contains("Dictionary", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ES3 の辞書は {"key": "...", "value": ...} の対を持つ
|
||||||
|
return jsonObject.ContainsKey("key") && jsonObject.ContainsKey(ValuePropertyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON 値の種別を簡易判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="node">対象ノード</param>
|
||||||
|
/// <returns>判定した値種別</returns>
|
||||||
|
private static Es3ValueKind MapValueKind(JsonNode? node)
|
||||||
|
{
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return Es3ValueKind.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
return node.GetValueKind() switch
|
||||||
|
{
|
||||||
|
JsonValueKind.Object => Es3ValueKind.Object,
|
||||||
|
JsonValueKind.Array => Es3ValueKind.Array,
|
||||||
|
JsonValueKind.String => Es3ValueKind.String,
|
||||||
|
JsonValueKind.Number => node.ToJsonString().Contains('.')
|
||||||
|
? Es3ValueKind.Float
|
||||||
|
: Es3ValueKind.Integer,
|
||||||
|
JsonValueKind.True or JsonValueKind.False => Es3ValueKind.Boolean,
|
||||||
|
_ => Es3ValueKind.Unknown
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// スカラー値を表示用文字列へ整形します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="node">対象ノード</param>
|
||||||
|
/// <param name="kind">値種別</param>
|
||||||
|
/// <returns>表示用文字列</returns>
|
||||||
|
private static string FormatScalar(JsonNode? node, Es3ValueKind kind)
|
||||||
|
{
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return kind switch
|
||||||
|
{
|
||||||
|
Es3ValueKind.Boolean => node.GetValue<bool>() ? "true" : "false",
|
||||||
|
Es3ValueKind.String => node.GetValue<string>(),
|
||||||
|
Es3ValueKind.Enum => node.GetValueKind() == JsonValueKind.Number
|
||||||
|
? node.ToJsonString()
|
||||||
|
: node.GetValue<string>(),
|
||||||
|
_ => node.ToJsonString()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return node.ToJsonString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定パスのノードへ編集値を適用します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">JSON パス(<see cref="Es3Node.Path"/>)</param>
|
||||||
|
/// <param name="newValue">新しい値(表示文字列)</param>
|
||||||
|
/// <param name="error">失敗理由</param>
|
||||||
|
/// <returns>適用に成功した場合 true</returns>
|
||||||
|
public bool TrySetValue(string path, string newValue, out string error)
|
||||||
|
{
|
||||||
|
error = string.Empty;
|
||||||
|
|
||||||
|
if (this._root == null)
|
||||||
|
{
|
||||||
|
error = "ドキュメントが読み込まれていません。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.TryResolveParent(path, out var parent, out var key, out error))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 既存ノードから型情報を取得
|
||||||
|
var existing = this.FindNode(path);
|
||||||
|
var kind = existing?.Kind ?? Es3ValueKind.String;
|
||||||
|
var typeName = existing?.TypeName ?? "System.String";
|
||||||
|
|
||||||
|
if (existing != null && !existing.IsEditable)
|
||||||
|
{
|
||||||
|
error = $"型 {typeName} は直接編集できません。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode? parsed = this.BuildValueNode(newValue, kind, typeName, out error);
|
||||||
|
if (parsed == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// ES3 の型付き要素として書き戻す
|
||||||
|
if (parent is JsonObject parentObject && parentObject.ContainsKey(TypePropertyName))
|
||||||
|
{
|
||||||
|
parentObject[ValuePropertyName] = parsed;
|
||||||
|
}
|
||||||
|
else if (parent is JsonObject plainObject)
|
||||||
|
{
|
||||||
|
plainObject[key] = parsed;
|
||||||
|
}
|
||||||
|
else if (parent is JsonArray array && int.TryParse(key, out int index) &&
|
||||||
|
index >= 0 && index < array.Count)
|
||||||
|
{
|
||||||
|
array[index] = parsed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = "書き戻し先の親要素を特定できませんでした。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
error = $"書き戻しに失敗しました: {ex.Message}";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 編集後の JSON を文字列として取得します。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>整形済み JSON 文字列</returns>
|
||||||
|
public string ToJson()
|
||||||
|
{
|
||||||
|
if (this._root == null)
|
||||||
|
{
|
||||||
|
return this.OriginalJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._root.ToJsonString(new JsonSerializerOptions { WriteIndented = false });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元の JSON から変更があったかを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>変更がある場合 true</returns>
|
||||||
|
public bool HasChanges()
|
||||||
|
{
|
||||||
|
if (this._root == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !string.Equals(this.ToJson(), this.OriginalJson, StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスから親ノードと最終キーを解決します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <param name="parent">親ノード</param>
|
||||||
|
/// <param name="key">最終キー(配列の場合はインデックス文字列)</param>
|
||||||
|
/// <param name="error">失敗理由</param>
|
||||||
|
/// <returns>解決に成功した場合 true</returns>
|
||||||
|
private bool TryResolveParent(string path, out JsonNode? parent, out string key, out string error)
|
||||||
|
{
|
||||||
|
parent = null;
|
||||||
|
key = string.Empty;
|
||||||
|
error = string.Empty;
|
||||||
|
|
||||||
|
if (path == "$")
|
||||||
|
{
|
||||||
|
error = "ルート要素は編集できません。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var segments = SplitPath(path);
|
||||||
|
if (segments.Count < 2)
|
||||||
|
{
|
||||||
|
error = $"パスの解析に失敗しました: {path}";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode? current = this._root;
|
||||||
|
|
||||||
|
for (int i = 1; i < segments.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (current == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = Descend(current, segments[i], out _);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current == null)
|
||||||
|
{
|
||||||
|
error = $"パス {path} を解決できませんでした。";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
key = segments[^1];
|
||||||
|
parent = current;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パス文字列をセグメントへ分割します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <returns>セグメント一覧(先頭は "$")</returns>
|
||||||
|
private static List<string> SplitPath(string path)
|
||||||
|
{
|
||||||
|
var segments = new List<string>();
|
||||||
|
var buffer = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var ch in path)
|
||||||
|
{
|
||||||
|
if (ch == '.' || ch == '[' || ch == ']')
|
||||||
|
{
|
||||||
|
if (buffer.Length > 0)
|
||||||
|
{
|
||||||
|
segments.Add(buffer.ToString());
|
||||||
|
buffer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.Append(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer.Length > 0)
|
||||||
|
{
|
||||||
|
segments.Add(buffer.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定キーで子要素へ降下します(ES3 の型付き要素は value を透過します)。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="current">現在のノード</param>
|
||||||
|
/// <param name="key">キー</param>
|
||||||
|
/// <param name="found">見つかった子ノード</param>
|
||||||
|
/// <returns>降下先ノード。見つからない場合は null</returns>
|
||||||
|
private static JsonNode? Descend(JsonNode current, string key, out JsonNode? found)
|
||||||
|
{
|
||||||
|
found = null;
|
||||||
|
|
||||||
|
if (current is JsonObject obj)
|
||||||
|
{
|
||||||
|
// ES3 の型付き要素は value の中身を透過的に扱う
|
||||||
|
if (obj.ContainsKey(TypePropertyName) && obj[ValuePropertyName] is JsonNode inner)
|
||||||
|
{
|
||||||
|
return Descend(inner, key, out found);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj.TryGetPropertyValue(key, out var child))
|
||||||
|
{
|
||||||
|
found = child;
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current is JsonArray array && int.TryParse(key, out int index) &&
|
||||||
|
index >= 0 && index < array.Count)
|
||||||
|
{
|
||||||
|
found = array[index];
|
||||||
|
return array[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定パスに対応するノードを探索します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <returns>見つかったノード。見つからない場合は null</returns>
|
||||||
|
private Es3Node? FindNode(string path)
|
||||||
|
{
|
||||||
|
return FindNodeRecursive(this.RootNodes, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ノードツリーを再帰的に探索します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nodes">探索対象</param>
|
||||||
|
/// <param name="path">JSON パス</param>
|
||||||
|
/// <returns>見つかったノード</returns>
|
||||||
|
private static Es3Node? FindNodeRecursive(List<Es3Node> nodes, string path)
|
||||||
|
{
|
||||||
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
if (node.Path == path)
|
||||||
|
{
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
var found = FindNodeRecursive(node.Children, path);
|
||||||
|
if (found != null)
|
||||||
|
{
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 編集値から実際の JSON ノードを構築します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newValue">編集された値文字列</param>
|
||||||
|
/// <param name="kind">型種別</param>
|
||||||
|
/// <param name="typeName">ES3 の型名</param>
|
||||||
|
/// <param name="error">失敗理由</param>
|
||||||
|
/// <returns>構築された JSON ノード。失敗時は null</returns>
|
||||||
|
private JsonNode? BuildValueNode(string newValue, Es3ValueKind kind, string typeName, out string error)
|
||||||
|
{
|
||||||
|
error = string.Empty;
|
||||||
|
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case Es3ValueKind.Boolean:
|
||||||
|
if (bool.TryParse(newValue, out var boolValue))
|
||||||
|
{
|
||||||
|
return JsonValue.Create(boolValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newValue.Trim() == "1")
|
||||||
|
{
|
||||||
|
return JsonValue.Create(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newValue.Trim() == "0")
|
||||||
|
{
|
||||||
|
return JsonValue.Create(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = $"真偽値として解釈できません: {newValue}";
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case Es3ValueKind.Integer:
|
||||||
|
if (long.TryParse(newValue.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var longValue))
|
||||||
|
{
|
||||||
|
return JsonValue.Create(longValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = $"整数として解釈できません: {newValue}";
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case Es3ValueKind.Float:
|
||||||
|
if (double.TryParse(newValue.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var doubleValue))
|
||||||
|
{
|
||||||
|
return JsonValue.Create(doubleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = $"小数として解釈できません: {newValue}";
|
||||||
|
return null;
|
||||||
|
|
||||||
|
case Es3ValueKind.Enum:
|
||||||
|
// 列挙体は元が数値なら数値、文字列なら文字列として保持する
|
||||||
|
if (long.TryParse(newValue.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var enumNumeric))
|
||||||
|
{
|
||||||
|
return JsonValue.Create(enumNumeric);
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonValue.Create(newValue);
|
||||||
|
|
||||||
|
case Es3ValueKind.String:
|
||||||
|
return JsonValue.Create(newValue);
|
||||||
|
|
||||||
|
default:
|
||||||
|
error = $"型 {typeName} は直接編集できません。";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using GameLauncher.Models;
|
|
||||||
using GameLauncher.Engines.Unity;
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
@@ -9,22 +9,44 @@ namespace GameLauncher.Services.Codecs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISaveDataCodec
|
public interface ISaveDataCodec
|
||||||
{
|
{
|
||||||
/// <summary>コーデックの識別名称(例: "Easy Save 3 (ES3)", "YU-RIS セーブデータ")</summary>
|
/// <summary>
|
||||||
|
/// コーデックの識別名称(例: "Easy Save 3 (ES3)", "YU-RIS セーブデータ")を取得します。
|
||||||
|
/// </summary>
|
||||||
string CodecName { get; }
|
string CodecName { get; }
|
||||||
|
|
||||||
/// <summary>このコーデックで指定ファイルを処理可能か判定</summary>
|
/// <summary>
|
||||||
|
/// このコーデックで指定ファイルを処理可能か判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">対象のUnityゲーム情報</param>
|
||||||
|
/// <param name="file">対象のセーブファイル情報</param>
|
||||||
|
/// <returns>処理可能な場合は true、それ以外は false</returns>
|
||||||
bool CanHandle(UnityGameItem game, SaveFileEntry file);
|
bool CanHandle(UnityGameItem game, SaveFileEntry file);
|
||||||
|
|
||||||
/// <summary>セーブファイルからGUI編集用プロパティ一覧をロード・解析</summary>
|
/// <summary>
|
||||||
|
/// セーブファイルからGUI編集用プロパティ一覧をロード・解析します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>展開されたセーブデータプロパティのリスト</returns>
|
||||||
List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null);
|
List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null);
|
||||||
|
|
||||||
/// <summary>GUI編集されたプロパティ一覧をファイルへ再エンコード・保存</summary>
|
/// <summary>
|
||||||
|
/// GUI編集されたプロパティ一覧をファイルへ再エンコード・保存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">保存先セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="properties">編集されたプロパティ一覧</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>保存に成功した場合は true、それ以外は false</returns>
|
||||||
bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null);
|
bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null);
|
||||||
|
|
||||||
/// <summary>復号にパスワードやキーが必要かどうか</summary>
|
/// <summary>
|
||||||
|
/// 復号にパスワードやキーが必要かどうかを取得します。
|
||||||
|
/// </summary>
|
||||||
bool RequiresPassword { get; }
|
bool RequiresPassword { get; }
|
||||||
|
|
||||||
/// <summary>パスワード入力時の案内メッセージ</summary>
|
/// <summary>
|
||||||
|
/// パスワード入力時の案内メッセージを取得します。
|
||||||
|
/// </summary>
|
||||||
string? PasswordPromptMessage { get; }
|
string? PasswordPromptMessage { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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 GameLauncher.Models;
|
|
||||||
using GameLauncher.Engines.Unity;
|
using GameLauncher.Engines.Unity;
|
||||||
|
using GameLauncher.Models;
|
||||||
|
|
||||||
namespace GameLauncher.Services.Codecs
|
namespace GameLauncher.Services.Codecs
|
||||||
{
|
{
|
||||||
@@ -12,12 +12,27 @@ namespace GameLauncher.Services.Codecs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class YurisSaveCodec : ISaveDataCodec
|
public class YurisSaveCodec : ISaveDataCodec
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// コーデックの表示名を取得します。
|
||||||
|
/// </summary>
|
||||||
public string CodecName => "YU-RIS セーブデータ (YSSD) コーデック";
|
public string CodecName => "YU-RIS セーブデータ (YSSD) コーデック";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワード入力が必要かどうかを取得します。
|
||||||
|
/// </summary>
|
||||||
public bool RequiresPassword => false;
|
public bool RequiresPassword => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パスワード入力ダイアログに表示する案内メッセージを取得します。
|
||||||
|
/// </summary>
|
||||||
public string? PasswordPromptMessage => null;
|
public string? PasswordPromptMessage => null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたセーブファイルが本コーデックで処理可能かを判定します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="game">対象のUnityゲーム情報</param>
|
||||||
|
/// <param name="file">対象のセーブファイル情報</param>
|
||||||
|
/// <returns>処理可能な場合は true、それ以外は false</returns>
|
||||||
public bool CanHandle(UnityGameItem game, SaveFileEntry file)
|
public bool CanHandle(UnityGameItem game, SaveFileEntry file)
|
||||||
{
|
{
|
||||||
if (!File.Exists(file.FilePath)) return false;
|
if (!File.Exists(file.FilePath)) return false;
|
||||||
@@ -39,6 +54,12 @@ namespace GameLauncher.Services.Codecs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// セーブファイルからプロパティ一覧を読み込みます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>展開されたセーブデータプロパティのリスト</returns>
|
||||||
public List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null)
|
public List<SaveDataPropertyEntry> LoadProperties(string filePath, string? optionalPassword = null)
|
||||||
{
|
{
|
||||||
var list = new List<SaveDataPropertyEntry>();
|
var list = new List<SaveDataPropertyEntry>();
|
||||||
@@ -101,6 +122,13 @@ namespace GameLauncher.Services.Codecs
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 編集後のプロパティ一覧をセーブファイルへ書き戻して保存します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">保存先セーブファイルの絶対パス</param>
|
||||||
|
/// <param name="properties">編集されたプロパティ一覧</param>
|
||||||
|
/// <param name="optionalPassword">任意の暗号化パスワード</param>
|
||||||
|
/// <returns>保存に成功した場合は true、それ以外は false</returns>
|
||||||
public bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null)
|
public bool SaveProperties(string filePath, List<SaveDataPropertyEntry> properties, string? optionalPassword = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -0,0 +1,312 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 高速検索ソフト「Everything」のIPC (WM_COPYDATA) APIを利用して、
|
||||||
|
/// 指定フォルダ配下の全ファイルおよびサブディレクトリを0.1秒未満で一括取得するサービス
|
||||||
|
/// </summary>
|
||||||
|
public class EverythingSearchService
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
private const int WM_COPYDATA = 0x004A;
|
||||||
|
private const int EVERYTHING_IPC_COPYDATA_QUERYW = 2;
|
||||||
|
private const uint EVERYTHING_IPC_ALLRESULTS = 0xFFFFFFFF;
|
||||||
|
private const uint EVERYTHING_IPC_FOLDER = 0x00000002;
|
||||||
|
private const uint EVERYTHING_IPC_DRIVE = 0x00000004;
|
||||||
|
private const uint PM_REMOVE = 0x0001;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □構造体(Private)
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct COPYDATASTRUCT
|
||||||
|
{
|
||||||
|
public IntPtr dwData;
|
||||||
|
public int cbData;
|
||||||
|
public IntPtr lpData;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
private struct EVERYTHING_IPC_QUERYW_HEADER
|
||||||
|
{
|
||||||
|
public uint max_results;
|
||||||
|
public uint offset;
|
||||||
|
public uint reply_copydata_message;
|
||||||
|
public uint search_flags;
|
||||||
|
public IntPtr reply_hwnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct MSG
|
||||||
|
{
|
||||||
|
public IntPtr hwnd;
|
||||||
|
public uint message;
|
||||||
|
public IntPtr wParam;
|
||||||
|
public IntPtr lParam;
|
||||||
|
public uint time;
|
||||||
|
public int pt_x;
|
||||||
|
public int pt_y;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
/// <summary>
|
||||||
|
/// Everything が現在システム上で実行中であるか判定します。
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsEverythingRunning()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var procs = Process.GetProcessesByName("Everything");
|
||||||
|
if (procs != null && procs.Length > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var hwnd = FindWindowW("EVERYTHING_TASKBAR_NOTIFICATION", null);
|
||||||
|
if (hwnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたパス群(例: C:\..., Z:\...)に対して、Everything IPCを用いて高速スナップショットを生成します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetDirectories">走査対象のディレクトリルート一覧</param>
|
||||||
|
/// <param name="timeoutMs">タイムアウト(ミリ秒)</param>
|
||||||
|
/// <returns>生成されたスナップショット。Everything未稼働または失敗時は null</returns>
|
||||||
|
public static FastDirectorySnapshot? TryScanTargetsFast(IEnumerable<string> targetDirectories, int timeoutMs = 3000)
|
||||||
|
{
|
||||||
|
var everythingHwnd = FindWindowW("EVERYTHING_TASKBAR_NOTIFICATION", null);
|
||||||
|
if (everythingHwnd == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapshot = new FastDirectorySnapshot();
|
||||||
|
bool anySuccess = false;
|
||||||
|
|
||||||
|
foreach (var targetDir in targetDirectories)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(targetDir)) continue;
|
||||||
|
string cleanDir = Path.GetFullPath(targetDir).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool ok = QueryDirectory(everythingHwnd, cleanDir, snapshot, timeoutMs);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
anySuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 個別パスのクエリ失敗時はスキップ
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return anySuccess ? snapshot : null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
/// <summary>
|
||||||
|
/// Everything IPC を用いて1つのディレクトリ配下のファイル・フォルダ一覧を取得し、スナップショットに格納します。
|
||||||
|
/// </summary>
|
||||||
|
private static bool QueryDirectory(IntPtr everythingHwnd, string targetDirectory, FastDirectorySnapshot snapshot, int timeoutMs)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
var resetEvent = new ManualResetEvent(false);
|
||||||
|
|
||||||
|
// STAスレッド上でメッセージ受信用 HwndSource を作成
|
||||||
|
var thread = new Thread(() =>
|
||||||
|
{
|
||||||
|
HwndSource? source = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var parameters = new HwndSourceParameters("GameLauncher_Everything_Receiver")
|
||||||
|
{
|
||||||
|
Width = 0,
|
||||||
|
Height = 0,
|
||||||
|
PositionX = -100,
|
||||||
|
PositionY = -100,
|
||||||
|
WindowStyle = 0x800000 // WS_BORDER (非表示)
|
||||||
|
};
|
||||||
|
source = new HwndSource(parameters);
|
||||||
|
source.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
|
||||||
|
{
|
||||||
|
if (msg == WM_COPYDATA)
|
||||||
|
{
|
||||||
|
var cds = Marshal.PtrToStructure<COPYDATASTRUCT>(lParam);
|
||||||
|
if (cds.lpData != IntPtr.Zero && cds.cbData > 12)
|
||||||
|
{
|
||||||
|
ParseEverythingIpcList(cds.lpData, targetDirectory, snapshot);
|
||||||
|
success = true;
|
||||||
|
handled = true;
|
||||||
|
resetEvent.Set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return IntPtr.Zero;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Everything への検索文字列構築(指定パス配下の全エントリ)
|
||||||
|
string searchQuery = $"path:\"{targetDirectory}\"";
|
||||||
|
|
||||||
|
byte[] queryBytes = BuildQueryPayload(source.Handle, searchQuery);
|
||||||
|
GCHandle pinnedQuery = GCHandle.Alloc(queryBytes, GCHandleType.Pinned);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cdsSend = new COPYDATASTRUCT
|
||||||
|
{
|
||||||
|
dwData = (IntPtr)EVERYTHING_IPC_COPYDATA_QUERYW,
|
||||||
|
cbData = queryBytes.Length,
|
||||||
|
lpData = pinnedQuery.AddrOfPinnedObject()
|
||||||
|
};
|
||||||
|
|
||||||
|
SendMessage(everythingHwnd, WM_COPYDATA, source.Handle, ref cdsSend);
|
||||||
|
|
||||||
|
// メッセージループを回して結果を待つ
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
while (sw.ElapsedMilliseconds < timeoutMs && !success)
|
||||||
|
{
|
||||||
|
while (PeekMessage(out var msg, IntPtr.Zero, 0, 0, PM_REMOVE))
|
||||||
|
{
|
||||||
|
TranslateMessage(ref msg);
|
||||||
|
DispatchMessage(ref msg);
|
||||||
|
}
|
||||||
|
Thread.Sleep(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pinnedQuery.IsAllocated) pinnedQuery.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// クエリ処理中の例外
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
source?.Dispose();
|
||||||
|
resetEvent.Set();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
thread.SetApartmentState(ApartmentState.STA);
|
||||||
|
thread.IsBackground = true;
|
||||||
|
thread.Start();
|
||||||
|
|
||||||
|
resetEvent.WaitOne(timeoutMs);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Everything IPC 送信用クエリバイナリペイロードを構築します。
|
||||||
|
/// </summary>
|
||||||
|
private static byte[] BuildQueryPayload(IntPtr replyHwnd, string searchQuery)
|
||||||
|
{
|
||||||
|
var header = new EVERYTHING_IPC_QUERYW_HEADER
|
||||||
|
{
|
||||||
|
max_results = EVERYTHING_IPC_ALLRESULTS,
|
||||||
|
offset = 0,
|
||||||
|
reply_copydata_message = 0,
|
||||||
|
search_flags = 0,
|
||||||
|
reply_hwnd = replyHwnd
|
||||||
|
};
|
||||||
|
|
||||||
|
int headerSize = Marshal.SizeOf(typeof(EVERYTHING_IPC_QUERYW_HEADER));
|
||||||
|
byte[] queryStrBytes = Encoding.Unicode.GetBytes(searchQuery + "\0");
|
||||||
|
|
||||||
|
byte[] payload = new byte[headerSize + queryStrBytes.Length];
|
||||||
|
|
||||||
|
IntPtr headerPtr = Marshal.AllocHGlobal(headerSize);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Marshal.StructureToPtr(header, headerPtr, false);
|
||||||
|
Marshal.Copy(headerPtr, payload, 0, headerSize);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(headerPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Buffer.BlockCopy(queryStrBytes, 0, payload, headerSize, queryStrBytes.Length);
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Everything から返信された EVERYTHING_IPC_LISTW バイナリをパースし、スナップショットに登録します。
|
||||||
|
/// </summary>
|
||||||
|
private static void ParseEverythingIpcList(IntPtr pList, string targetDirectory, FastDirectorySnapshot snapshot)
|
||||||
|
{
|
||||||
|
int totitems = Marshal.ReadInt32(pList, 0);
|
||||||
|
int numitems = Marshal.ReadInt32(pList, 4);
|
||||||
|
int offset = Marshal.ReadInt32(pList, 8);
|
||||||
|
|
||||||
|
if (numitems <= 0) return;
|
||||||
|
|
||||||
|
int itemHeaderBase = 12; // sizeof(DWORD) * 3
|
||||||
|
int itemSize = 12; // sizeof(DWORD) * 3 (flags, filename_offset, path_offset)
|
||||||
|
|
||||||
|
for (int i = 0; i < numitems; i++)
|
||||||
|
{
|
||||||
|
int itemOffset = itemHeaderBase + (i * itemSize);
|
||||||
|
uint flags = (uint)Marshal.ReadInt32(pList, itemOffset);
|
||||||
|
int filenameOffset = Marshal.ReadInt32(pList, itemOffset + 4);
|
||||||
|
int pathOffset = Marshal.ReadInt32(pList, itemOffset + 8);
|
||||||
|
|
||||||
|
string filename = Marshal.PtrToStringUni(IntPtr.Add(pList, filenameOffset)) ?? string.Empty;
|
||||||
|
string dirPath = Marshal.PtrToStringUni(IntPtr.Add(pList, pathOffset)) ?? string.Empty;
|
||||||
|
|
||||||
|
bool isFolder = (flags & EVERYTHING_IPC_FOLDER) != 0 || (flags & EVERYTHING_IPC_DRIVE) != 0;
|
||||||
|
|
||||||
|
if (isFolder)
|
||||||
|
{
|
||||||
|
string fullSubDir = Path.Combine(dirPath, filename);
|
||||||
|
snapshot.AddDirectory(dirPath, fullSubDir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snapshot.AddFile(dirPath, filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □P/Invoke(Private)
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern IntPtr FindWindowW(string lpClassName, string? lpWindowName);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static extern bool PeekMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern bool TranslateMessage([In] ref MSG lpMsg);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern IntPtr DispatchMessage([In] ref MSG lpmsg);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// メモリ上に展開されたディレクトリおよびファイル構成の高速インメモリスナップショット
|
||||||
|
/// </summary>
|
||||||
|
public class FastDirectorySnapshot
|
||||||
|
{
|
||||||
|
#region □プロパティ(Public)
|
||||||
|
/// <summary>
|
||||||
|
/// ディレクトリパス -> 直下のファイル名(ファイル名のみ)のハッシュセット
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, HashSet<string>> FilesByDir { get; } = new(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ディレクトリパス -> 直下のサブディレクトリのフルパスリスト
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, List<string>> SubDirsByDir { get; } = new(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登録されている総ディレクトリ数
|
||||||
|
/// </summary>
|
||||||
|
public int TotalDirectoryCount => this.SubDirsByDir.Count;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登録されている総ファイル数
|
||||||
|
/// </summary>
|
||||||
|
public int TotalFileCount => this.FilesByDir.Values.Sum(set => set.Count);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
/// <summary>
|
||||||
|
/// ファイルをスナップショットに登録します。
|
||||||
|
/// </summary>
|
||||||
|
public void AddFile(string dirPath, string fileName)
|
||||||
|
{
|
||||||
|
var normalizedDir = NormalizePath(dirPath);
|
||||||
|
if (!this.FilesByDir.TryGetValue(normalizedDir, out var files))
|
||||||
|
{
|
||||||
|
files = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
this.FilesByDir[normalizedDir] = files;
|
||||||
|
}
|
||||||
|
files.Add(fileName);
|
||||||
|
|
||||||
|
if (!this.SubDirsByDir.ContainsKey(normalizedDir))
|
||||||
|
{
|
||||||
|
this.SubDirsByDir[normalizedDir] = new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// サブディレクトリを親ディレクトリのスナップショットに登録します。
|
||||||
|
/// </summary>
|
||||||
|
public void AddDirectory(string parentDirPath, string childDirPath)
|
||||||
|
{
|
||||||
|
var normalizedParent = NormalizePath(parentDirPath);
|
||||||
|
var normalizedChild = NormalizePath(childDirPath);
|
||||||
|
|
||||||
|
if (!this.SubDirsByDir.TryGetValue(normalizedParent, out var children))
|
||||||
|
{
|
||||||
|
children = new List<string>();
|
||||||
|
this.SubDirsByDir[normalizedParent] = children;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!children.Contains(normalizedChild, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
children.Add(normalizedChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.SubDirsByDir.ContainsKey(normalizedChild))
|
||||||
|
{
|
||||||
|
this.SubDirsByDir[normalizedChild] = new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたディレクトリが存在するかどうかをインメモリで判定します。
|
||||||
|
/// </summary>
|
||||||
|
public bool DirectoryExists(string dirPath)
|
||||||
|
{
|
||||||
|
var normalized = NormalizePath(dirPath);
|
||||||
|
return this.SubDirsByDir.ContainsKey(normalized) || this.FilesByDir.ContainsKey(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたファイルが存在するかどうかをインメモリで判定します。
|
||||||
|
/// </summary>
|
||||||
|
public bool FileExists(string filePath)
|
||||||
|
{
|
||||||
|
var dir = NormalizePath(Path.GetDirectoryName(filePath) ?? string.Empty);
|
||||||
|
var name = Path.GetFileName(filePath);
|
||||||
|
if (this.FilesByDir.TryGetValue(dir, out var files))
|
||||||
|
{
|
||||||
|
return files.Contains(name);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたディレクトリ直下のサブディレクトリ一覧を取得します。
|
||||||
|
/// </summary>
|
||||||
|
public string[] GetDirectories(string dirPath)
|
||||||
|
{
|
||||||
|
var normalized = NormalizePath(dirPath);
|
||||||
|
if (this.SubDirsByDir.TryGetValue(normalized, out var subDirs))
|
||||||
|
{
|
||||||
|
return subDirs.ToArray();
|
||||||
|
}
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたディレクトリ直下のファイルフルパス一覧を取得します。
|
||||||
|
/// </summary>
|
||||||
|
public string[] GetFiles(string dirPath, string searchPattern = "*")
|
||||||
|
{
|
||||||
|
var normalized = NormalizePath(dirPath);
|
||||||
|
if (!this.FilesByDir.TryGetValue(normalized, out var files))
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(searchPattern) || searchPattern == "*")
|
||||||
|
{
|
||||||
|
return files.Select(f => Path.Combine(normalized, f)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchPattern.StartsWith("*.") && searchPattern.IndexOf('*', 1) < 0 && searchPattern.IndexOf('?', 1) < 0)
|
||||||
|
{
|
||||||
|
string ext = searchPattern.Substring(1);
|
||||||
|
return files
|
||||||
|
.Where(f => f.EndsWith(ext, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Select(f => Path.Combine(normalized, f))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
var regex = WildcardToRegex(searchPattern);
|
||||||
|
return files
|
||||||
|
.Where(f => regex.IsMatch(f))
|
||||||
|
.Select(f => Path.Combine(normalized, f))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 別のスナップショットの内容を現在のスナップショットにマージします。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">マージ元のスナップショット</param>
|
||||||
|
public void MergeFrom(FastDirectorySnapshot other)
|
||||||
|
{
|
||||||
|
if (other == null) return;
|
||||||
|
|
||||||
|
foreach (var kvp in other.FilesByDir)
|
||||||
|
{
|
||||||
|
if (!this.FilesByDir.TryGetValue(kvp.Key, out var files))
|
||||||
|
{
|
||||||
|
files = new HashSet<string>(kvp.Value, StringComparer.OrdinalIgnoreCase);
|
||||||
|
this.FilesByDir[kvp.Key] = files;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.UnionWith(kvp.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var kvp in other.SubDirsByDir)
|
||||||
|
{
|
||||||
|
if (!this.SubDirsByDir.TryGetValue(kvp.Key, out var subDirs))
|
||||||
|
{
|
||||||
|
subDirs = new List<string>(kvp.Value);
|
||||||
|
this.SubDirsByDir[kvp.Key] = subDirs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var dir in kvp.Value)
|
||||||
|
{
|
||||||
|
if (!subDirs.Contains(dir, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
subDirs.Add(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
/// <summary>
|
||||||
|
/// パス末尾の区切り文字を除去し、正規化します。
|
||||||
|
/// </summary>
|
||||||
|
private static string NormalizePath(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path)) return string.Empty;
|
||||||
|
return path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ワイルドカードパターンを正規表現に変換します。
|
||||||
|
/// </summary>
|
||||||
|
private static Regex WildcardToRegex(string pattern)
|
||||||
|
{
|
||||||
|
string escaped = Regex.Escape(pattern).Replace("\\*", ".*").Replace("\\?", ".");
|
||||||
|
return new Regex("^" + escaped + "$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
+1356
-223
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,399 @@
|
|||||||
|
using System;
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
|
||||||
|
namespace GameLauncher.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// NTFS の MFT (USN Journal: FSCTL_ENUM_USN_DATA) を直接読み取り、
|
||||||
|
/// ドライブ内のファイルおよびディレクトリツリーを爆速で一括抽出するサービス
|
||||||
|
/// </summary>
|
||||||
|
public class NtfsMftScanService
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
private const uint GENERIC_READ = 0x80000000;
|
||||||
|
private const uint FILE_SHARE_READ = 0x00000001;
|
||||||
|
private const uint FILE_SHARE_WRITE = 0x00000002;
|
||||||
|
private const uint OPEN_EXISTING = 3;
|
||||||
|
private const uint FSCTL_QUERY_USN_JOURNAL = 0x000900f4;
|
||||||
|
private const uint FSCTL_ENUM_USN_DATA = 0x000900b3;
|
||||||
|
private const uint FILE_ATTRIBUTE_DIRECTORY = 0x00000010;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MFT読み込みバッファサイズ(2MB)。1回のDeviceIoControl呼び出しで最大効率を引き出します。
|
||||||
|
/// </summary>
|
||||||
|
private const int BufferSize = 2048 * 1024;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □構造体(Private)
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct USN_JOURNAL_DATA
|
||||||
|
{
|
||||||
|
public ulong UsnJournalID;
|
||||||
|
public long FirstUsn;
|
||||||
|
public long NextUsn;
|
||||||
|
public long LowestValidUsn;
|
||||||
|
public long MaxUsn;
|
||||||
|
public ulong MaximumSize;
|
||||||
|
public ulong AllocationDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct MFT_ENUM_DATA_V0
|
||||||
|
{
|
||||||
|
public ulong StartFileReferenceNumber;
|
||||||
|
public long LowUsn;
|
||||||
|
public long HighUsn;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MFTディレクトリ情報ノード
|
||||||
|
/// </summary>
|
||||||
|
private struct DirNode
|
||||||
|
{
|
||||||
|
public ulong Id;
|
||||||
|
public ulong ParentId;
|
||||||
|
public string Name;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
/// <summary>
|
||||||
|
/// 指定されたパス群(例: C:\..., Z:\...)に対して、NTFS MFT 直接読み取りを用いて高速スナップショットを生成します。
|
||||||
|
/// 複数ドライブが存在する場合は、各ドライブを並列処理してディスクアクセス速度を極限まで高めます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetDirectories">走査対象のディレクトリルート一覧</param>
|
||||||
|
/// <returns>生成されたスナップショット。失敗または非NTFS時は null</returns>
|
||||||
|
public static FastDirectorySnapshot? TryScanTargetsFast(IEnumerable<string> targetDirectories)
|
||||||
|
{
|
||||||
|
var targetsByDrive = new Dictionary<char, List<string>>();
|
||||||
|
|
||||||
|
foreach (var dir in targetDirectories)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dir)) continue;
|
||||||
|
var full = Path.GetFullPath(dir).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||||
|
if (full.Length >= 2 && full[1] == ':')
|
||||||
|
{
|
||||||
|
char driveLetter = char.ToUpperInvariant(full[0]);
|
||||||
|
if (!targetsByDrive.TryGetValue(driveLetter, out var list))
|
||||||
|
{
|
||||||
|
list = new List<string>();
|
||||||
|
targetsByDrive[driveLetter] = list;
|
||||||
|
}
|
||||||
|
list.Add(full);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetsByDrive.Count == 0) return null;
|
||||||
|
|
||||||
|
var snapshots = new ConcurrentBag<FastDirectorySnapshot>();
|
||||||
|
|
||||||
|
// ドライブごとに並列処理を実行(物理/論理ドライブ間のI/OおよびCPUを限界まで同時並行化)
|
||||||
|
Parallel.ForEach(targetsByDrive, kvp =>
|
||||||
|
{
|
||||||
|
char driveLetter = kvp.Key;
|
||||||
|
var targetPaths = kvp.Value;
|
||||||
|
var driveSnapshot = new FastDirectorySnapshot();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool ok = ScanVolumeMft(driveLetter, targetPaths, driveSnapshot);
|
||||||
|
if (ok && (driveSnapshot.TotalDirectoryCount > 0 || driveSnapshot.TotalFileCount > 0))
|
||||||
|
{
|
||||||
|
snapshots.Add(driveSnapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ドライブスキャン失敗時はスキップ
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (snapshots.IsEmpty) return null;
|
||||||
|
|
||||||
|
var merged = new FastDirectorySnapshot();
|
||||||
|
foreach (var snap in snapshots)
|
||||||
|
{
|
||||||
|
merged.MergeFrom(snap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return merged;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
/// <summary>
|
||||||
|
/// 1つのドライブボリュームのMFTを読み込み、指定されたターゲットパス配下のファイルをスナップショットに登録します。
|
||||||
|
/// </summary>
|
||||||
|
private static bool ScanVolumeMft(char driveLetter, List<string> targetPaths, FastDirectorySnapshot snapshot)
|
||||||
|
{
|
||||||
|
string volumePath = @"\\.\" + driveLetter + ":";
|
||||||
|
using var hVolume = CreateFile(
|
||||||
|
volumePath,
|
||||||
|
GENERIC_READ,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
IntPtr.Zero,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
0,
|
||||||
|
IntPtr.Zero);
|
||||||
|
|
||||||
|
if (hVolume.IsInvalid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. USNジャーナル情報の取得
|
||||||
|
var journalData = new USN_JOURNAL_DATA();
|
||||||
|
int journalDataSize = Marshal.SizeOf(typeof(USN_JOURNAL_DATA));
|
||||||
|
if (!DeviceIoControl(hVolume, FSCTL_QUERY_USN_JOURNAL, IntPtr.Zero, 0, out journalData, journalDataSize, out _, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. MFT列挙用パラメータの準備
|
||||||
|
var enumData = new MFT_ENUM_DATA_V0
|
||||||
|
{
|
||||||
|
StartFileReferenceNumber = 0,
|
||||||
|
LowUsn = 0,
|
||||||
|
HighUsn = journalData.NextUsn
|
||||||
|
};
|
||||||
|
|
||||||
|
int enumDataSize = Marshal.SizeOf(typeof(MFT_ENUM_DATA_V0));
|
||||||
|
IntPtr enumDataPtr = Marshal.AllocHGlobal(enumDataSize);
|
||||||
|
Marshal.StructureToPtr(enumData, enumDataPtr, false);
|
||||||
|
|
||||||
|
byte[] buffer = new byte[BufferSize];
|
||||||
|
GCHandle bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
|
IntPtr bufferPtr = bufferHandle.AddrOfPinnedObject();
|
||||||
|
|
||||||
|
// 読み込んだ全MFTデータチャンクを保持(I/Oを最優先で一括連続完了させる)
|
||||||
|
var chunks = new List<(byte[] Buffer, int Length)>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (DeviceIoControl(hVolume, FSCTL_ENUM_USN_DATA, enumDataPtr, enumDataSize, bufferPtr, BufferSize, out uint bytesReturned, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
if (bytesReturned <= 8) break;
|
||||||
|
|
||||||
|
// 次の開始参照番号を取得
|
||||||
|
ulong nextId = (ulong)Marshal.ReadInt64(bufferPtr);
|
||||||
|
Marshal.WriteInt64(enumDataPtr, (long)nextId);
|
||||||
|
|
||||||
|
byte[] chunkCopy = new byte[bytesReturned];
|
||||||
|
Buffer.BlockCopy(buffer, 0, chunkCopy, 0, (int)bytesReturned);
|
||||||
|
chunks.Add((chunkCopy, (int)bytesReturned));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (bufferHandle.IsAllocated) bufferHandle.Free();
|
||||||
|
if (enumDataPtr != IntPtr.Zero) Marshal.FreeHGlobal(enumDataPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chunks.Count == 0) return false;
|
||||||
|
|
||||||
|
// 3. 【第1パス】ディレクトリのみを収集(ディレクトリは全体の数%に過ぎないため極めて高速)
|
||||||
|
var dirNodes = new Dictionary<ulong, DirNode>(65536);
|
||||||
|
var childrenByParent = new Dictionary<ulong, List<ulong>>(65536);
|
||||||
|
|
||||||
|
foreach (var chunk in chunks)
|
||||||
|
{
|
||||||
|
ReadOnlySpan<byte> span = chunk.Buffer.AsSpan(0, chunk.Length);
|
||||||
|
int offset = 8;
|
||||||
|
while (offset < chunk.Length)
|
||||||
|
{
|
||||||
|
if (offset + 60 > chunk.Length) break;
|
||||||
|
ReadOnlySpan<byte> record = span.Slice(offset);
|
||||||
|
int recordLength = BinaryPrimitives.ReadInt32LittleEndian(record);
|
||||||
|
if (recordLength <= 0 || offset + recordLength > chunk.Length) break;
|
||||||
|
|
||||||
|
uint fileAttributes = BinaryPrimitives.ReadUInt32LittleEndian(record.Slice(52));
|
||||||
|
if ((fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||||
|
{
|
||||||
|
ulong fileRef = BinaryPrimitives.ReadUInt64LittleEndian(record.Slice(8)) & 0x0000FFFFFFFFFFFFUL;
|
||||||
|
ulong parentRef = BinaryPrimitives.ReadUInt64LittleEndian(record.Slice(16)) & 0x0000FFFFFFFFFFFFUL;
|
||||||
|
ushort fileNameLength = BinaryPrimitives.ReadUInt16LittleEndian(record.Slice(56));
|
||||||
|
ushort fileNameOffset = BinaryPrimitives.ReadUInt16LittleEndian(record.Slice(58));
|
||||||
|
|
||||||
|
if (fileNameLength > 0 && fileNameOffset + fileNameLength <= recordLength)
|
||||||
|
{
|
||||||
|
string dirName = Encoding.Unicode.GetString(record.Slice(fileNameOffset, fileNameLength));
|
||||||
|
dirNodes[fileRef] = new DirNode { Id = fileRef, ParentId = parentRef, Name = dirName };
|
||||||
|
|
||||||
|
if (!childrenByParent.TryGetValue(parentRef, out var childList))
|
||||||
|
{
|
||||||
|
childList = new List<ulong>();
|
||||||
|
childrenByParent[parentRef] = childList;
|
||||||
|
}
|
||||||
|
childList.Add(fileRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += recordLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. ターゲットパスのNodeId特定と、配下の子孫ディレクトリパスの確定
|
||||||
|
var targetDirIds = new HashSet<ulong>();
|
||||||
|
var dirIdToFullPath = new Dictionary<ulong, string>();
|
||||||
|
|
||||||
|
foreach (var targetPath in targetPaths)
|
||||||
|
{
|
||||||
|
ulong? targetNodeId = FindDirNodeIdByPath(driveLetter, targetPath, dirNodes, childrenByParent);
|
||||||
|
if (targetNodeId.HasValue)
|
||||||
|
{
|
||||||
|
CollectDescendantDirectories(targetNodeId.Value, targetPath, dirNodes, childrenByParent, targetDirIds, dirIdToFullPath, snapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 該当するターゲットディレクトリが存在しなければ終了
|
||||||
|
if (targetDirIds.Count == 0) return true;
|
||||||
|
|
||||||
|
// 5. 【第2パス】ターゲット配下のファイルのみを高速抽出
|
||||||
|
// (ターゲット外の数百万個の無関係なファイルは名前取得やオブジェクト生成を完全にスキップ!)
|
||||||
|
foreach (var chunk in chunks)
|
||||||
|
{
|
||||||
|
ReadOnlySpan<byte> span = chunk.Buffer.AsSpan(0, chunk.Length);
|
||||||
|
int offset = 8;
|
||||||
|
while (offset < chunk.Length)
|
||||||
|
{
|
||||||
|
if (offset + 60 > chunk.Length) break;
|
||||||
|
ReadOnlySpan<byte> record = span.Slice(offset);
|
||||||
|
int recordLength = BinaryPrimitives.ReadInt32LittleEndian(record);
|
||||||
|
if (recordLength <= 0 || offset + recordLength > chunk.Length) break;
|
||||||
|
|
||||||
|
uint fileAttributes = BinaryPrimitives.ReadUInt32LittleEndian(record.Slice(52));
|
||||||
|
// ディレクトリは第1パスですでに登録済みのためスキップ
|
||||||
|
if ((fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||||
|
{
|
||||||
|
ulong parentRef = BinaryPrimitives.ReadUInt64LittleEndian(record.Slice(16)) & 0x0000FFFFFFFFFFFFUL;
|
||||||
|
|
||||||
|
// ターゲット配下のディレクトリに属するファイルのみを抽出
|
||||||
|
if (targetDirIds.Contains(parentRef) && dirIdToFullPath.TryGetValue(parentRef, out string? parentDirPath))
|
||||||
|
{
|
||||||
|
ushort fileNameLength = BinaryPrimitives.ReadUInt16LittleEndian(record.Slice(56));
|
||||||
|
ushort fileNameOffset = BinaryPrimitives.ReadUInt16LittleEndian(record.Slice(58));
|
||||||
|
|
||||||
|
if (fileNameLength > 0 && fileNameOffset + fileNameLength <= recordLength)
|
||||||
|
{
|
||||||
|
string fileName = Encoding.Unicode.GetString(record.Slice(fileNameOffset, fileNameLength));
|
||||||
|
snapshot.AddFile(parentDirPath, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += recordLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// パス文字列から対応するディレクトリのノードIDを特定します。
|
||||||
|
/// </summary>
|
||||||
|
private static ulong? FindDirNodeIdByPath(
|
||||||
|
char driveLetter,
|
||||||
|
string path,
|
||||||
|
Dictionary<ulong, DirNode> dirNodes,
|
||||||
|
Dictionary<ulong, List<ulong>> childrenByParent)
|
||||||
|
{
|
||||||
|
string rootStr = driveLetter + @":\";
|
||||||
|
if (path.Equals(rootStr.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase) || path.Equals(rootStr, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return 5UL; // ルートディレクトリID
|
||||||
|
}
|
||||||
|
|
||||||
|
var parts = path.Substring(3).Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
ulong currentParent = 5UL;
|
||||||
|
|
||||||
|
foreach (var part in parts)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
if (childrenByParent.TryGetValue(currentParent, out var childIds))
|
||||||
|
{
|
||||||
|
foreach (var childId in childIds)
|
||||||
|
{
|
||||||
|
if (dirNodes.TryGetValue(childId, out var node) && string.Equals(node.Name, part, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
currentParent = node.Id;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ターゲットディレクトリ配下の子孫ディレクトリIDおよびフルパスを再帰的に収集し、スナップショットに登録します。
|
||||||
|
/// </summary>
|
||||||
|
private static void CollectDescendantDirectories(
|
||||||
|
ulong parentNodeId,
|
||||||
|
string currentPath,
|
||||||
|
Dictionary<ulong, DirNode> dirNodes,
|
||||||
|
Dictionary<ulong, List<ulong>> childrenByParent,
|
||||||
|
HashSet<ulong> targetDirIds,
|
||||||
|
Dictionary<ulong, string> dirIdToFullPath,
|
||||||
|
FastDirectorySnapshot snapshot)
|
||||||
|
{
|
||||||
|
targetDirIds.Add(parentNodeId);
|
||||||
|
dirIdToFullPath[parentNodeId] = currentPath;
|
||||||
|
|
||||||
|
if (!childrenByParent.TryGetValue(parentNodeId, out var childIds)) return;
|
||||||
|
|
||||||
|
foreach (var childId in childIds)
|
||||||
|
{
|
||||||
|
if (!dirNodes.TryGetValue(childId, out var childNode)) continue;
|
||||||
|
|
||||||
|
string childPath = Path.Combine(currentPath, childNode.Name);
|
||||||
|
snapshot.AddDirectory(currentPath, childPath);
|
||||||
|
CollectDescendantDirectories(childId, childPath, dirNodes, childrenByParent, targetDirIds, dirIdToFullPath, snapshot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □P/Invoke(Private)
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
private static extern SafeFileHandle CreateFile(
|
||||||
|
string lpFileName,
|
||||||
|
uint dwDesiredAccess,
|
||||||
|
uint dwShareMode,
|
||||||
|
IntPtr lpSecurityAttributes,
|
||||||
|
uint dwCreationDisposition,
|
||||||
|
uint dwFlagsAndAttributes,
|
||||||
|
IntPtr hTemplateFile);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
private static extern bool DeviceIoControl(
|
||||||
|
SafeFileHandle hDevice,
|
||||||
|
uint dwIoControlCode,
|
||||||
|
IntPtr lpInBuffer,
|
||||||
|
int nInBufferSize,
|
||||||
|
out USN_JOURNAL_DATA lpOutBuffer,
|
||||||
|
int nOutBufferSize,
|
||||||
|
out uint lpBytesReturned,
|
||||||
|
IntPtr lpOverlapped);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
|
private static extern bool DeviceIoControl(
|
||||||
|
SafeFileHandle hDevice,
|
||||||
|
uint dwIoControlCode,
|
||||||
|
IntPtr lpInBuffer,
|
||||||
|
int nInBufferSize,
|
||||||
|
IntPtr lpOutBuffer,
|
||||||
|
int nOutBufferSize,
|
||||||
|
out uint lpBytesReturned,
|
||||||
|
IntPtr lpOverlapped);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
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.Engines.Unity;
|
||||||
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
|
||||||
{
|
{
|
||||||
@@ -15,23 +14,32 @@ namespace GameLauncher.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SaveDataCodecManager
|
public class SaveDataCodecManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// シングルトンインスタンスを取得します。
|
||||||
|
/// </summary>
|
||||||
public static readonly SaveDataCodecManager Instance = new();
|
public static readonly SaveDataCodecManager Instance = new();
|
||||||
|
|
||||||
private readonly List<ISaveDataCodec> _codecs = [];
|
private readonly List<ISaveDataCodec> _codecs = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="SaveDataCodecManager"/> クラスの新しいインスタンスを初期化します。
|
||||||
|
/// </summary>
|
||||||
public SaveDataCodecManager()
|
public SaveDataCodecManager()
|
||||||
{
|
{
|
||||||
// コーデックの登録
|
// コーデックの登録
|
||||||
_codecs.Add(new EasySave3Codec());
|
this._codecs.Add(new EasySave3Codec());
|
||||||
_codecs.Add(new YurisSaveCodec());
|
this._codecs.Add(new YurisSaveCodec());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定されたゲームおよびセーブファイルに対応するコーデックを検索します。
|
/// 指定されたゲームおよびセーブファイルに対応するコーデックを検索します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="game">対象のUnityゲーム情報</param>
|
||||||
|
/// <param name="file">対象のセーブファイル情報</param>
|
||||||
|
/// <returns>対応するコーデック。見つからない場合は null</returns>
|
||||||
public ISaveDataCodec? FindCodec(UnityGameItem game, SaveFileEntry file)
|
public ISaveDataCodec? FindCodec(UnityGameItem game, SaveFileEntry file)
|
||||||
{
|
{
|
||||||
foreach (var codec in _codecs)
|
foreach (var codec in this._codecs)
|
||||||
{
|
{
|
||||||
if (codec.CanHandle(game, file))
|
if (codec.CanHandle(game, file))
|
||||||
{
|
{
|
||||||
@@ -44,6 +52,9 @@ namespace GameLauncher.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 未対応セーブデータについて、Antigravity IDE に依頼できる安全なプロンプトを自動生成します。
|
/// 未対応セーブデータについて、Antigravity IDE に依頼できる安全なプロンプトを自動生成します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="game">対象のUnityゲーム情報</param>
|
||||||
|
/// <param name="file">対象のセーブファイル情報</param>
|
||||||
|
/// <returns>生成された依頼プロンプト文字列</returns>
|
||||||
public string GenerateAntigravityPrompt(UnityGameItem game, SaveFileEntry file)
|
public string GenerateAntigravityPrompt(UnityGameItem game, SaveFileEntry file)
|
||||||
{
|
{
|
||||||
// ポリシー配慮: 会社名・タイトル名からセンシティブ表現を除去/安全な別名に変換
|
// ポリシー配慮: 会社名・タイトル名からセンシティブ表現を除去/安全な別名に変換
|
||||||
@@ -98,8 +109,10 @@ namespace GameLauncher.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AIプロンプト向けに文字列を安全・中立的な表現にサニタイズ
|
/// AIプロンプト向けに文字列を安全・中立的な表現にサニタイズします。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="input">元の文字列</param>
|
||||||
|
/// <returns>サニタイズされた安全な文字列</returns>
|
||||||
private static string SanitizeForPrompt(string input)
|
private static string SanitizeForPrompt(string input)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(input)) return "Game";
|
if (string.IsNullOrWhiteSpace(input)) return "Game";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -67,12 +67,12 @@ namespace GameLauncher.Services
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// 外部ツール起動失敗時は内蔵方式にフォールバック
|
// 外部ツール起動失敗時は内蔵方式にフォールバック
|
||||||
var (ok, msg) = await ApplyBuiltInResizeAsync(process);
|
var (ok, msg) = await this.ApplyBuiltInResizeAsync(process);
|
||||||
return (ok, $"外部ツール起動に失敗したため内蔵方式を使用: {ex.Message} / {msg}");
|
return (ok, $"外部ツール起動に失敗したため内蔵方式を使用: {ex.Message} / {msg}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await ApplyBuiltInResizeAsync(process);
|
return await this.ApplyBuiltInResizeAsync(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="GameLauncher.WolfSaveEditorDialog"
|
<Window x:Class="GameLauncher.WolfSaveEditorDialog"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -27,15 +27,15 @@ namespace GameLauncher
|
|||||||
|
|
||||||
public WolfSaveEditorDialog(TkoolGameItem game, WolfSaveService saveService)
|
public WolfSaveEditorDialog(TkoolGameItem game, WolfSaveService saveService)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
_game = game;
|
this._game = game;
|
||||||
_saveService = saveService;
|
this._saveService = saveService;
|
||||||
|
|
||||||
lblGameTitle.Text = _game.Title;
|
this.lblGameTitle.Text = this._game.Title;
|
||||||
lblGamePath.Text = _game.RootDirectory;
|
this.lblGamePath.Text = this._game.RootDirectory;
|
||||||
txtInfoBackupDir.Text = AppPathHelper.GetGameBackupDirectory(_game.FolderName, _game.RootDirectory);
|
this.txtInfoBackupDir.Text = AppPathHelper.GetGameBackupDirectory(this._game.FolderName, this._game.RootDirectory);
|
||||||
|
|
||||||
LoadSaveFileList();
|
this.LoadSaveFileList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -45,36 +45,36 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var files = _saveService.GetSaveFiles(_game.RootDirectory);
|
var files = this._saveService.GetSaveFiles(this._game.RootDirectory);
|
||||||
cboSaveFiles.Items.Clear();
|
this.cboSaveFiles.Items.Clear();
|
||||||
|
|
||||||
foreach (var f in files)
|
foreach (var f in files)
|
||||||
{
|
{
|
||||||
cboSaveFiles.Items.Add(Path.GetFileName(f));
|
this.cboSaveFiles.Items.Add(Path.GetFileName(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cboSaveFiles.Items.Count > 0)
|
if (this.cboSaveFiles.Items.Count > 0)
|
||||||
{
|
{
|
||||||
cboSaveFiles.SelectedIndex = 0;
|
this.cboSaveFiles.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblStatus.Text = "セーブデータ(*.sav)が見つかりませんでした。";
|
this.lblStatus.Text = "セーブデータ(*.sav)が見つかりませんでした。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
lblStatus.Text = $"セーブファイル列挙エラー: {ex.Message}";
|
this.lblStatus.Text = $"セーブファイル列挙エラー: {ex.Message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cboSaveFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void cboSaveFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (cboSaveFiles.SelectedItem == null) return;
|
if (this.cboSaveFiles.SelectedItem == null) return;
|
||||||
var fileName = cboSaveFiles.SelectedItem.ToString();
|
var fileName = this.cboSaveFiles.SelectedItem.ToString();
|
||||||
if (string.IsNullOrEmpty(fileName)) return;
|
if (string.IsNullOrEmpty(fileName)) return;
|
||||||
|
|
||||||
LoadSaveFile(fileName);
|
this.LoadSaveFile(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -84,46 +84,46 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var files = _saveService.GetSaveFiles(_game.RootDirectory);
|
var files = this._saveService.GetSaveFiles(this._game.RootDirectory);
|
||||||
var fullPath = files.FirstOrDefault(f => string.Equals(Path.GetFileName(f), fileName, StringComparison.OrdinalIgnoreCase));
|
var fullPath = files.FirstOrDefault(f => string.Equals(Path.GetFileName(f), fileName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(fullPath) || !File.Exists(fullPath))
|
if (string.IsNullOrEmpty(fullPath) || !File.Exists(fullPath))
|
||||||
{
|
{
|
||||||
lblStatus.Text = $"ファイルが存在しません: {fileName}";
|
this.lblStatus.Text = $"ファイルが存在しません: {fileName}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentSaveData = _saveService.LoadSave(fullPath);
|
this._currentSaveData = this._saveService.LoadSave(fullPath);
|
||||||
_allVariables = [.. _currentSaveData.Variables];
|
this._allVariables = [.. this._currentSaveData.Variables];
|
||||||
_allStrings = [.. _currentSaveData.Strings];
|
this._allStrings = [.. this._currentSaveData.Strings];
|
||||||
|
|
||||||
// メタ情報表示
|
// メタ情報表示
|
||||||
txtInfoTitle.Text = string.IsNullOrEmpty(_currentSaveData.GameTitle) ? "(不明)" : _currentSaveData.GameTitle;
|
this.txtInfoTitle.Text = string.IsNullOrEmpty(this._currentSaveData.GameTitle) ? "(不明)" : this._currentSaveData.GameTitle;
|
||||||
txtInfoVersion.Text = $"0x{_currentSaveData.FileVersion:X4}";
|
this.txtInfoVersion.Text = $"0x{this._currentSaveData.FileVersion:X4}";
|
||||||
txtInfoEncoding.Text = _currentSaveData.IsUtf8 ? "UTF-8" : "Shift-JIS (CP932)";
|
this.txtInfoEncoding.Text = this._currentSaveData.IsUtf8 ? "UTF-8" : "Shift-JIS (CP932)";
|
||||||
txtInfoSize.Text = $"{_currentSaveData.RawDecryptedBytes.Length:N0} バイト";
|
this.txtInfoSize.Text = $"{this._currentSaveData.RawDecryptedBytes.Length:N0} バイト";
|
||||||
|
|
||||||
ApplyFilter();
|
this.ApplyFilter();
|
||||||
|
|
||||||
lblStatus.Text = $"'{fileName}' を正常に読み込みました。";
|
this.lblStatus.Text = $"'{fileName}' を正常に読み込みました。";
|
||||||
lblSaveCount.Text = $"変数項目: {_allVariables.Count}件, 文字列項目: {_allStrings.Count}件";
|
this.lblSaveCount.Text = $"変数項目: {this._allVariables.Count}件, 文字列項目: {this._allStrings.Count}件";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"セーブデータの読み込みに失敗しました:\n{ex.Message}", "読み込みエラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"セーブデータの読み込みに失敗しました:\n{ex.Message}", "読み込みエラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
lblStatus.Text = $"読み込みエラー: {ex.Message}";
|
this.lblStatus.Text = $"読み込みエラー: {ex.Message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnReload_Click(object sender, RoutedEventArgs e)
|
private void btnReload_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (cboSaveFiles.SelectedItem != null)
|
if (this.cboSaveFiles.SelectedItem != null)
|
||||||
{
|
{
|
||||||
LoadSaveFile(cboSaveFiles.SelectedItem.ToString()!);
|
this.LoadSaveFile(this.cboSaveFiles.SelectedItem.ToString()!);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadSaveFileList();
|
this.LoadSaveFileList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,23 +132,23 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void ApplyFilter()
|
private void ApplyFilter()
|
||||||
{
|
{
|
||||||
var filter = txtFilter.Text?.Trim() ?? string.Empty;
|
var filter = this.txtFilter.Text?.Trim() ?? string.Empty;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(filter))
|
if (string.IsNullOrEmpty(filter))
|
||||||
{
|
{
|
||||||
dgVariables.ItemsSource = _allVariables;
|
this.dgVariables.ItemsSource = this._allVariables;
|
||||||
dgStrings.ItemsSource = _allStrings;
|
this.dgStrings.ItemsSource = this._allStrings;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dgVariables.ItemsSource = _allVariables
|
this.dgVariables.ItemsSource = this._allVariables
|
||||||
.Where(v => v.DisplayName.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
.Where(v => v.DisplayName.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||||
v.Category.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
v.Category.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||||
v.Value.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
v.Value.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||||
v.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
v.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
dgStrings.ItemsSource = _allStrings
|
this.dgStrings.ItemsSource = this._allStrings
|
||||||
.Where(s => s.Value.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
.Where(s => s.Value.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||||
s.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
s.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -157,7 +157,7 @@ namespace GameLauncher
|
|||||||
|
|
||||||
private void txtFilter_TextChanged(object sender, TextChangedEventArgs e)
|
private void txtFilter_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
ApplyFilter();
|
this.ApplyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -165,21 +165,21 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnSearchValue_Click(object sender, RoutedEventArgs e)
|
private void btnSearchValue_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!int.TryParse(txtTargetValue.Text.Trim(), out int target))
|
if (!int.TryParse(this.txtTargetValue.Text.Trim(), out int target))
|
||||||
{
|
{
|
||||||
MessageBox.Show("検索する数値を半角数字で入力してください。(例: 現在の所持金やステータス)", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show("検索する数値を半角数字で入力してください。(例: 現在の所持金やステータス)", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = _allVariables.Where(v => v.Value == target).ToList();
|
var matches = this._allVariables.Where(v => v.Value == target).ToList();
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"値が {target:N0} と一致する変数が見つかりませんでした。", "検索結果", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show($"値が {target:N0} と一致する変数が見つかりませんでした。", "検索結果", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dgVariables.ItemsSource = matches;
|
this.dgVariables.ItemsSource = matches;
|
||||||
lblStatus.Text = $"値 {target:N0} に一致する候補が {matches.Count} 件見つかりました。";
|
this.lblStatus.Text = $"値 {target:N0} に一致する候補が {matches.Count} 件見つかりました。";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -187,7 +187,7 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnSetMaxTarget_Click(object sender, RoutedEventArgs e)
|
private void btnSetMaxTarget_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (dgVariables.ItemsSource is not IEnumerable<WolfVariableItem> currentList) return;
|
if (this.dgVariables.ItemsSource is not IEnumerable<WolfVariableItem> currentList) return;
|
||||||
var list = currentList.ToList();
|
var list = currentList.ToList();
|
||||||
if (list.Count == 0) return;
|
if (list.Count == 0) return;
|
||||||
|
|
||||||
@@ -201,8 +201,8 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
item.Value = 9999999;
|
item.Value = 9999999;
|
||||||
}
|
}
|
||||||
dgVariables.Items.Refresh();
|
this.dgVariables.Items.Refresh();
|
||||||
lblStatus.Text = $"{list.Count} 件の値を 9,999,999 に変更しました。保存ボタンを押すと反映されます。";
|
this.lblStatus.Text = $"{list.Count} 件の値を 9,999,999 に変更しました。保存ボタンを押すと反映されます。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,14 +214,14 @@ namespace GameLauncher
|
|||||||
if (sender is Button btn && btn.Tag is WolfVariableItem item)
|
if (sender is Button btn && btn.Tag is WolfVariableItem item)
|
||||||
{
|
{
|
||||||
item.Value = 9999999;
|
item.Value = 9999999;
|
||||||
dgVariables.Items.Refresh();
|
this.dgVariables.Items.Refresh();
|
||||||
lblStatus.Text = $"{item.DisplayName} の値を 9,999,999 に設定しました。";
|
this.lblStatus.Text = $"{item.DisplayName} の値を 9,999,999 に設定しました。";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dgVariables_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
private void dgVariables_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||||
{
|
{
|
||||||
lblStatus.Text = "値を編集しました。「上書き保存」を押すとバックアップを作成して保存されます。";
|
this.lblStatus.Text = "値を編集しました。「上書き保存」を押すとバックアップを作成して保存されます。";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -229,7 +229,7 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnSave_Click(object sender, RoutedEventArgs e)
|
private void btnSave_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSaveData == null)
|
if (this._currentSaveData == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("保存対象のセーブデータがありません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show("保存対象のセーブデータがありません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return;
|
return;
|
||||||
@@ -238,19 +238,19 @@ namespace GameLauncher
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 変数リストの最新値をモデルへ反映
|
// 変数リストの最新値をモデルへ反映
|
||||||
_currentSaveData.Variables = _allVariables;
|
this._currentSaveData.Variables = this._allVariables;
|
||||||
|
|
||||||
// 保存実行 (自動バックアップ)
|
// 保存実行 (自動バックアップ)
|
||||||
string backupPath = _saveService.SaveToFile(_currentSaveData, _game.FolderName, _game.RootDirectory);
|
string backupPath = this._saveService.SaveToFile(this._currentSaveData, this._game.FolderName, this._game.RootDirectory);
|
||||||
|
|
||||||
var msg = $"セーブデータ '{_currentSaveData.FileName}' を安全に上書き保存しました!\n\n【バックアップ保存先】\n{backupPath}";
|
var msg = $"セーブデータ '{this._currentSaveData.FileName}' を安全に上書き保存しました!\n\n【バックアップ保存先】\n{backupPath}";
|
||||||
MessageBox.Show(msg, "保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show(msg, "保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
lblStatus.Text = $"保存完了 (バックアップ: {Path.GetFileName(backupPath)})";
|
this.lblStatus.Text = $"保存完了 (バックアップ: {Path.GetFileName(backupPath)})";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"保存中にエラーが発生しました:\n{ex.Message}", "保存エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show($"保存中にエラーが発生しました:\n{ex.Message}", "保存エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
lblStatus.Text = $"保存エラー: {ex.Message}";
|
this.lblStatus.Text = $"保存エラー: {ex.Message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,20 +259,20 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnExportJson_Click(object sender, RoutedEventArgs e)
|
private void btnExportJson_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSaveData == null) return;
|
if (this._currentSaveData == null) return;
|
||||||
|
|
||||||
var sfd = new SaveFileDialog
|
var sfd = new SaveFileDialog
|
||||||
{
|
{
|
||||||
Title = "セーブデータを JSON としてエクスポート",
|
Title = "セーブデータを JSON としてエクスポート",
|
||||||
Filter = "JSON ファイル (*.json)|*.json",
|
Filter = "JSON ファイル (*.json)|*.json",
|
||||||
FileName = $"{Path.GetFileNameWithoutExtension(_currentSaveData.FileName)}_export.json"
|
FileName = $"{Path.GetFileNameWithoutExtension(this._currentSaveData.FileName)}_export.json"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sfd.ShowDialog() == true)
|
if (sfd.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_saveService.ExportToJson(_currentSaveData, sfd.FileName);
|
this._saveService.ExportToJson(this._currentSaveData, sfd.FileName);
|
||||||
MessageBox.Show($"JSON ファイルをエクスポートしました:\n{sfd.FileName}", "エクスポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show($"JSON ファイルをエクスポートしました:\n{sfd.FileName}", "エクスポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -287,7 +287,7 @@ namespace GameLauncher
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void btnImportJson_Click(object sender, RoutedEventArgs e)
|
private void btnImportJson_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_currentSaveData == null) return;
|
if (this._currentSaveData == null) return;
|
||||||
|
|
||||||
var ofd = new OpenFileDialog
|
var ofd = new OpenFileDialog
|
||||||
{
|
{
|
||||||
@@ -299,9 +299,9 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_saveService.ImportFromJson(_currentSaveData, ofd.FileName);
|
this._saveService.ImportFromJson(this._currentSaveData, ofd.FileName);
|
||||||
_allVariables = [.. _currentSaveData.Variables];
|
this._allVariables = [.. this._currentSaveData.Variables];
|
||||||
ApplyFilter();
|
this.ApplyFilter();
|
||||||
MessageBox.Show("JSON データを正常に取り込みました。「上書き保存」を押すとファイルへ反映されます。", "インポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
MessageBox.Show("JSON データを正常に取り込みました。「上書き保存」を押すとファイルへ反映されます。", "インポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -318,7 +318,7 @@ namespace GameLauncher
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dir = AppPathHelper.GetGameBackupDirectory(_game.FolderName, _game.RootDirectory);
|
var dir = AppPathHelper.GetGameBackupDirectory(this._game.FolderName, this._game.RootDirectory);
|
||||||
if (!Directory.Exists(dir))
|
if (!Directory.Exists(dir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<assemblyIdentity version="1.0.0.0" name="GameLauncher.app"/>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<!-- 常に管理者権限で実行する -->
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- Windows 10 / Windows 11 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
|
||||||
|
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<windowsSettings>
|
||||||
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||||
|
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
|
||||||
|
</windowsSettings>
|
||||||
|
</application>
|
||||||
|
</assembly>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ
|
* @target MZ
|
||||||
* @plugindesc プリンセスシナジー専用: 主人公のHPを常時最大に固定する
|
* @plugindesc プリンセスシナジー専用: 主人公のHPを常時最大に固定する
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ
|
* @target MZ
|
||||||
* @plugindesc プリンセスシナジー専用: 主人公のMPを常時最大に固定する
|
* @plugindesc プリンセスシナジー専用: 主人公のMPを常時最大に固定する
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ
|
* @target MZ
|
||||||
* @plugindesc 戦闘高速化・ウェイト削除・アニメーション早送り
|
* @plugindesc 戦闘高速化・ウェイト削除・アニメーション早送り
|
||||||
* @author Antigravity
|
* @author Antigravity
|
||||||
@@ -207,4 +207,3 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のHPを全回復します。
|
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のHPを全回復します。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
@@ -28,4 +28,3 @@
|
|||||||
_BattleManager_startInput.call(this);
|
_BattleManager_startInput.call(this);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のMPを全回復します。
|
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のMPを全回復します。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
@@ -28,4 +28,3 @@
|
|||||||
_BattleManager_startInput.call(this);
|
_BattleManager_startInput.call(this);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のTPを全回復します。
|
* @plugindesc 戦闘ターン開始時およびコマンド選択時に味方全員のTPを全回復します。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
@@ -28,4 +28,3 @@
|
|||||||
_BattleManager_startInput.call(this);
|
_BattleManager_startInput.call(this);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc マップ移動時のダッシュ速度を通常より大幅に高速化します。
|
* @plugindesc マップ移動時のダッシュ速度を通常より大幅に高速化します。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc 経験値を獲得した際、即座に最大レベル(99)まで成長させます。
|
* @plugindesc 経験値を獲得した際、即座に最大レベル(99)まで成長させます。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
/*:
|
|
||||||
* @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,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc お金(ゴールド)を入手した際、所持金を即座に最大値(9999999)にします。
|
* @plugindesc お金(ゴールド)を入手した際、所持金を即座に最大値(9999999)にします。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc アイテム・武器・防具を入手した際、自動的に所持数を最大値(99個)にします。
|
* @plugindesc アイテム・武器・防具を入手した際、自動的に所持数を最大値(99個)にします。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc 通常アイテム使用時の消費を無効化します(減らずに何度でも使用可能)。
|
* @plugindesc 通常アイテム使用時の消費を無効化します(減らずに何度でも使用可能)。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc メッセージを常に瞬間表示し、文章中のウェイトを無効化します。
|
* @plugindesc メッセージを常に瞬間表示し、文章中のウェイトを無効化します。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -0,0 +1,317 @@
|
|||||||
|
/*:
|
||||||
|
* @target MZ MV
|
||||||
|
* @plugindesc 日本語・URLエンコード・文字化け・機種依存文字(丸数字等)の素材読み込み失敗を自動修復・救済します。
|
||||||
|
* @author GameLauncher
|
||||||
|
*
|
||||||
|
* @help
|
||||||
|
* 日本語ファイル名がURLエンコード(%E3%...)されたり、ファイル名と要求パスが
|
||||||
|
* 一致せず「Loading Error Failed to load」で停止してしまう現象を自動的に修復・救済します。
|
||||||
|
* 丸数字(①②...)と通常数字(1, 2...)の表記揺れやNW.jsのファイルシステム探索に対応しています。
|
||||||
|
*/
|
||||||
|
(() => {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const hasNode = typeof require === 'function' && typeof process === 'object';
|
||||||
|
const fs = hasNode ? require('fs') : null;
|
||||||
|
const path = hasNode ? require('path') : null;
|
||||||
|
|
||||||
|
// 1x1 透明 PNG (Data URL) - 万が一ファイルが見つからない場合のフォールバック用
|
||||||
|
const BLANK_PNG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
|
||||||
|
|
||||||
|
// 丸数字・ローマ数字・全角数字のマッピングテーブル
|
||||||
|
const CIRCLE_NUMBERS = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬', '⑭', '⑮', '⑯', '⑰', '⑱', '⑲', '⑳'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文字列内の丸数字や全角数字、波ダッシュ等を正規化して比較用キーを生成します。
|
||||||
|
* @param {string} str - 対象文字列
|
||||||
|
* @returns {string} 正規化文字列
|
||||||
|
*/
|
||||||
|
function normalizeFuzzy(str) {
|
||||||
|
if (!str) return '';
|
||||||
|
let res = str.normalize('NFC').toLowerCase();
|
||||||
|
|
||||||
|
// 丸数字 -> 通常数字
|
||||||
|
for (let i = 0; i < CIRCLE_NUMBERS.length; i++) {
|
||||||
|
res = res.replaceAll(CIRCLE_NUMBERS[i], String(i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全角数字 -> 半角数字
|
||||||
|
res = res.replace(/[0-9]/g, s => String.fromCharCode(s.charCodeAt(0) - 0xFEE0));
|
||||||
|
|
||||||
|
// 波ダッシュ・チルダ
|
||||||
|
res = res.replaceAll('\u301C', '\uFF5E');
|
||||||
|
|
||||||
|
// 全角カッコ -> 半角カッコ
|
||||||
|
res = res.replaceAll('(', '(').replaceAll(')', ')');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URLからファイルシステム上の実ファイルを探索します。
|
||||||
|
* @param {string} url - 読み込み対象のURL/相対パス
|
||||||
|
* @returns {string|null} 実ファイルの絶対パスまたは相対パス(見つからない場合はnull)
|
||||||
|
*/
|
||||||
|
function findActualFile(url) {
|
||||||
|
if (!fs || !path || !url) return null;
|
||||||
|
|
||||||
|
// クエリパラメータやハッシュを除去
|
||||||
|
const cleanUrl = url.split('?')[0].split('#')[0];
|
||||||
|
let decodedUrl = cleanUrl;
|
||||||
|
try {
|
||||||
|
decodedUrl = decodeURIComponent(cleanUrl);
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
// 中途半端に % が残っている場合の再デコード
|
||||||
|
if (decodedUrl.includes('%')) {
|
||||||
|
try {
|
||||||
|
decodedUrl = decodedUrl.replace(/(%[0-9A-Fa-f]{2})+/g, match => {
|
||||||
|
try { return decodeURIComponent(match); } catch (e) { return match; }
|
||||||
|
});
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
let encodedUrl = cleanUrl;
|
||||||
|
try {
|
||||||
|
const parts = cleanUrl.split('/');
|
||||||
|
encodedUrl = parts.map(p => encodeURIComponent(decodeURIComponent(p))).join('/');
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
// 1. そのままのパスで存在するか
|
||||||
|
if (fs.existsSync(cleanUrl)) return cleanUrl;
|
||||||
|
|
||||||
|
// 2. URLデコードしたパスで存在するか
|
||||||
|
if (fs.existsSync(decodedUrl)) return decodedUrl;
|
||||||
|
|
||||||
|
// 3. URLエンコードしたパスで存在するか
|
||||||
|
if (fs.existsSync(encodedUrl)) return encodedUrl;
|
||||||
|
|
||||||
|
// 4. ディレクトリ内の実ファイルを走査して柔軟に検索(丸数字・表記揺れ対応)
|
||||||
|
try {
|
||||||
|
const dir = path.dirname(decodedUrl);
|
||||||
|
const targetBase = path.basename(decodedUrl);
|
||||||
|
const targetExt = path.extname(decodedUrl);
|
||||||
|
const targetNameWithoutExt = path.basename(decodedUrl, targetExt);
|
||||||
|
|
||||||
|
if (fs.existsSync(dir)) {
|
||||||
|
const files = fs.readdirSync(dir);
|
||||||
|
const fuzzyTarget = normalizeFuzzy(targetBase);
|
||||||
|
const fuzzyTargetWithoutExt = normalizeFuzzy(targetNameWithoutExt);
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const fileExt = path.extname(file);
|
||||||
|
const fileNameWithoutExt = path.basename(file, fileExt);
|
||||||
|
|
||||||
|
// A. 通常比較
|
||||||
|
if (file.toLowerCase() === targetBase.toLowerCase()) {
|
||||||
|
return path.join(dir, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// B. 表記揺れ(丸数字①⇔1、全角数字等)のファジーマッチ
|
||||||
|
const fuzzyFile = normalizeFuzzy(file);
|
||||||
|
const fuzzyFileWithoutExt = normalizeFuzzy(fileNameWithoutExt);
|
||||||
|
|
||||||
|
if (fuzzyFile === fuzzyTarget) {
|
||||||
|
return path.join(dir, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fuzzyFileWithoutExt === fuzzyTargetWithoutExt && fileExt.toLowerCase() === targetExt.toLowerCase()) {
|
||||||
|
return path.join(dir, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// C. URLエンコード/デコードされたファイル名との比較
|
||||||
|
try {
|
||||||
|
const decodedFile = decodeURIComponent(file);
|
||||||
|
if (normalizeFuzzy(decodedFile) === fuzzyTarget) {
|
||||||
|
return path.join(dir, file);
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 実ファイルをBase64 DataURLとして読み込みます。
|
||||||
|
* @param {string} filePath - 実ファイルのパス
|
||||||
|
* @param {string} mimeType - MIMEタイプ
|
||||||
|
* @returns {string|null} DataURL
|
||||||
|
*/
|
||||||
|
function readFileAsDataUrl(filePath, mimeType = 'image/png') {
|
||||||
|
if (!fs || !filePath) return null;
|
||||||
|
try {
|
||||||
|
const buf = fs.readFileSync(filePath);
|
||||||
|
return `data:${mimeType};base64,${buf.toString('base64')}`;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 1. Bitmap ロードの救済 (ツクールMV / MZ)
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof Bitmap !== 'undefined') {
|
||||||
|
const _Bitmap_load = Bitmap.load;
|
||||||
|
Bitmap.load = function(url) {
|
||||||
|
if (fs && url) {
|
||||||
|
const actual = findActualFile(url);
|
||||||
|
if (actual && actual !== url) {
|
||||||
|
try {
|
||||||
|
const actualUrl = actual.replace(/\\/g, '/');
|
||||||
|
return _Bitmap_load.call(this, actualUrl);
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _Bitmap_load.call(this, url);
|
||||||
|
};
|
||||||
|
|
||||||
|
const _Bitmap_prototype_onError = Bitmap.prototype._onError;
|
||||||
|
Bitmap.prototype._onError = function() {
|
||||||
|
if (!this._recoveryAttempted && this._url) {
|
||||||
|
this._recoveryAttempted = true;
|
||||||
|
|
||||||
|
const actualFile = findActualFile(this._url);
|
||||||
|
if (actualFile) {
|
||||||
|
const dataUrl = readFileAsDataUrl(actualFile, 'image/png');
|
||||||
|
if (dataUrl && this._image) {
|
||||||
|
console.log(`[GameLauncher] 画像の実ファイルを特定して自動救済: ${this._url} -> ${actualFile}`);
|
||||||
|
this._isLoading = true;
|
||||||
|
this._hasError = false;
|
||||||
|
this._image.src = dataUrl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLデコード版を直接 image.src に設定してリトライ
|
||||||
|
try {
|
||||||
|
const decoded = decodeURIComponent(this._url);
|
||||||
|
if (decoded !== this._url && this._image) {
|
||||||
|
this._isLoading = true;
|
||||||
|
this._hasError = false;
|
||||||
|
this._url = decoded;
|
||||||
|
this._image.src = decoded;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
// 最終手段: ゲーム停止・クラッシュを回避するため透明PNGで代替
|
||||||
|
if (this._image) {
|
||||||
|
console.warn(`[GameLauncher] 未存在画像の透過代替を適用(エラー停止回避): ${this._url}`);
|
||||||
|
this._isLoading = false;
|
||||||
|
this._hasError = false;
|
||||||
|
this._image.src = BLANK_PNG;
|
||||||
|
if (typeof this._onLoad === 'function') {
|
||||||
|
try { this._onLoad(); } catch (e) { }
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_Bitmap_prototype_onError.call(this);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 2. WebAudio / AudioManager ロードの救済 (ツクールMV / MZ)
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof WebAudio !== 'undefined') {
|
||||||
|
const _WebAudio_prototype_load = WebAudio.prototype._load;
|
||||||
|
WebAudio.prototype._load = function(url) {
|
||||||
|
let targetUrl = url;
|
||||||
|
if (fs && url) {
|
||||||
|
const actual = findActualFile(url);
|
||||||
|
if (actual) {
|
||||||
|
targetUrl = actual.replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _WebAudio_prototype_load.call(this, targetUrl);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 3. Graphics.printLoadingError のエラー停止緩和
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof Graphics !== 'undefined' && Graphics.printLoadingError) {
|
||||||
|
const _Graphics_printLoadingError = Graphics.printLoadingError;
|
||||||
|
Graphics.printLoadingError = function(url) {
|
||||||
|
console.warn(`[GameLauncher] Loading Error が検出されました: ${url}`);
|
||||||
|
_Graphics_printLoadingError.call(this, url);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 4. PluginManager スクリプト読み込みの救済
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof PluginManager !== 'undefined' && PluginManager.loadScript) {
|
||||||
|
const _PluginManager_loadScript = PluginManager.loadScript;
|
||||||
|
PluginManager.loadScript = function(name) {
|
||||||
|
if (fs && name) {
|
||||||
|
const target = 'js/plugins/' + name;
|
||||||
|
const actual = findActualFile(target);
|
||||||
|
if (actual) {
|
||||||
|
const baseName = path.basename(actual);
|
||||||
|
return _PluginManager_loadScript.call(this, baseName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _PluginManager_loadScript.call(this, name);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 5. グローバル例外ロギング & デバッグ補助(スタックトレース追跡)
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.addEventListener('error', function(event) {
|
||||||
|
try {
|
||||||
|
var err = event.error || event;
|
||||||
|
var msg = '[' + new Date().toISOString() + '] Uncaught Error:\nMessage: ' + event.message + '\nFile: ' + event.filename + ':' + event.lineno + ':' + event.colno + '\nStack:\n' + (err.stack || 'No stack') + '\n\n';
|
||||||
|
if (fs) {
|
||||||
|
fs.appendFileSync('error_trace.log', msg, 'utf8');
|
||||||
|
}
|
||||||
|
console.error('[GameLauncher Error Hook]', msg);
|
||||||
|
} catch (ex) { }
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('unhandledrejection', function(event) {
|
||||||
|
try {
|
||||||
|
var reason = event.reason;
|
||||||
|
var msg = '[' + new Date().toISOString() + '] Unhandled Promise Rejection:\n' + (reason ? (reason.stack || reason) : 'Unknown') + '\n\n';
|
||||||
|
if (fs) {
|
||||||
|
fs.appendFileSync('error_trace.log', msg, 'utf8');
|
||||||
|
}
|
||||||
|
console.error('[GameLauncher Promise Error Hook]', msg);
|
||||||
|
} catch (ex) { }
|
||||||
|
});
|
||||||
|
|
||||||
|
// F12 / F8 キーで DevTools をトグル可能にする
|
||||||
|
window.addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === 'F12' || event.keyCode === 123 || event.key === 'F8' || event.keyCode === 119) {
|
||||||
|
if (typeof nw !== 'undefined' && nw.Window && nw.Window.get) {
|
||||||
|
try {
|
||||||
|
nw.Window.get().showDevTools();
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// 6. Pixi.js / RMMZ Tilemap & Sprite の null 安全保護
|
||||||
|
// =========================================================================
|
||||||
|
if (typeof PIXI !== 'undefined') {
|
||||||
|
if (PIXI.Sprite && PIXI.Sprite.prototype) {
|
||||||
|
var _Sprite_prototype_destroy = PIXI.Sprite.prototype.destroy;
|
||||||
|
PIXI.Sprite.prototype.destroy = function(options) {
|
||||||
|
try {
|
||||||
|
_Sprite_prototype_destroy.call(this, options);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('[GameLauncher] Sprite.destroy error suppressed:', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[GameLauncher] ResourceLoaderFix プラグインが正常にロードされました。');
|
||||||
|
})();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/*:
|
/*:
|
||||||
* @target MZ MV
|
* @target MZ MV
|
||||||
* @plugindesc ショップでのアイテム購入時、個数入力の初期値を最大購入可能数にします。
|
* @plugindesc ショップでのアイテム購入時、個数入力の初期値を最大購入可能数にします。
|
||||||
* @author GameLauncher
|
* @author GameLauncher
|
||||||
|
|||||||
@@ -0,0 +1,317 @@
|
|||||||
|
/*:
|
||||||
|
* @target MZ
|
||||||
|
* @plugindesc Spine処理およびイベント進行の診断ログを save/spine_debug_trace.log へ出力します(調査完了後に削除・無効化可能)。
|
||||||
|
* @author GameLauncher
|
||||||
|
*/
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
let fs = null;
|
||||||
|
let path = null;
|
||||||
|
try {
|
||||||
|
fs = require('fs');
|
||||||
|
path = require('path');
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveLogPath() {
|
||||||
|
const candidates = [];
|
||||||
|
try {
|
||||||
|
if (typeof StorageManager !== 'undefined' && typeof StorageManager.fileDirectoryPath === 'function') {
|
||||||
|
candidates.push(StorageManager.fileDirectoryPath());
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
try {
|
||||||
|
if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
|
||||||
|
candidates.push(path.join(process.cwd(), 'save'));
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
for (const dir of candidates) {
|
||||||
|
if (!dir) continue;
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
return path.join(dir, 'spine_debug_trace.log');
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const logFilePath = resolveLogPath();
|
||||||
|
if (!logFilePath) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(logFilePath) && fs.statSync(logFilePath).size > 5 * 1024 * 1024) {
|
||||||
|
fs.renameSync(logFilePath, logFilePath + '.old');
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
function frame() {
|
||||||
|
return (typeof Graphics !== 'undefined' && typeof Graphics.frameCount === 'number') ? Graphics.frameCount : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeLog(tag, msg, detail) {
|
||||||
|
try {
|
||||||
|
const ts = new Date().toISOString();
|
||||||
|
let line = `[${ts}][F:${frame()}][${tag}] ${msg}`;
|
||||||
|
if (detail !== undefined) {
|
||||||
|
try {
|
||||||
|
line += ' | ' + (typeof detail === 'string' ? detail : JSON.stringify(detail));
|
||||||
|
} catch (e) {
|
||||||
|
line += ' | [unserializable]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fs.appendFileSync(logFilePath, line + '\r\n', 'utf8');
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeLog('INIT', 'SpineDebugTrace 起動', { logFilePath });
|
||||||
|
|
||||||
|
// グローバルエラー・警告フック
|
||||||
|
window.addEventListener('error', (ev) => {
|
||||||
|
const err = ev && ev.error ? ev.error : ev;
|
||||||
|
writeLog('WINDOW_ERROR', ev && ev.message ? ev.message : 'unknown', {
|
||||||
|
file: ev && ev.filename,
|
||||||
|
line: ev && ev.lineno,
|
||||||
|
stack: err && err.stack ? String(err.stack) : ''
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('unhandledrejection', (ev) => {
|
||||||
|
const r = ev && ev.reason;
|
||||||
|
writeLog('UNHANDLED_REJECTION', r && r.message ? r.message : String(r), {
|
||||||
|
stack: r && r.stack ? String(r.stack) : ''
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const _origWarn = console.warn;
|
||||||
|
console.warn = function (...args) {
|
||||||
|
try {
|
||||||
|
const text = args.map(a => typeof a === 'string' ? a : String(a)).join(' ');
|
||||||
|
if (/SpineFix|Animation not found|GameLauncher|Error|Spine/i.test(text)) {
|
||||||
|
writeLog('CONSOLE_WARN', text);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
return _origWarn.apply(this, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
const _origError = console.error;
|
||||||
|
console.error = function (...args) {
|
||||||
|
try {
|
||||||
|
const text = args.map(a => typeof a === 'string' ? a : (a && a.stack ? a.stack : String(a))).join(' ');
|
||||||
|
writeLog('CONSOLE_ERROR', text);
|
||||||
|
} catch (e) {}
|
||||||
|
return _origError.apply(this, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
// SceneManager.catchException フック
|
||||||
|
if (typeof SceneManager !== 'undefined' && SceneManager.catchException) {
|
||||||
|
const _catchEx = SceneManager.catchException;
|
||||||
|
SceneManager.catchException = function (e) {
|
||||||
|
writeLog('SCENE_EXCEPTION', e && e.message ? e.message : String(e), {
|
||||||
|
stack: e && e.stack ? String(e.stack) : ''
|
||||||
|
});
|
||||||
|
return _catchEx.apply(this, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// スイッチ・変数監視
|
||||||
|
const watchSwitches = new Set([8, 10, 11, 15, 20, 21, 50, 51, 58, 521]);
|
||||||
|
const watchVars = new Set([51, 54, 55, 100, 101, 102]);
|
||||||
|
|
||||||
|
const _swSetValue = Game_Switches.prototype.setValue;
|
||||||
|
Game_Switches.prototype.setValue = function (switchId, value) {
|
||||||
|
const prev = this.value(switchId);
|
||||||
|
const res = _swSetValue.apply(this, arguments);
|
||||||
|
const next = this.value(switchId);
|
||||||
|
if (watchSwitches.has(Number(switchId)) && prev !== next) {
|
||||||
|
writeLog('SWITCH', `S[${switchId}] ${prev} -> ${next}`);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
const _varSetValue = Game_Variables.prototype.setValue;
|
||||||
|
Game_Variables.prototype.setValue = function (variableId, value) {
|
||||||
|
const prev = this.value(variableId);
|
||||||
|
const res = _varSetValue.apply(this, arguments);
|
||||||
|
const next = this.value(variableId);
|
||||||
|
if (watchVars.has(Number(variableId)) && prev !== next) {
|
||||||
|
writeLog('VAR', `V[${variableId}] ${JSON.stringify(prev)} -> ${JSON.stringify(next)}`);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
// BattleManager フェーズ監視
|
||||||
|
let _lastBattlePhase = '';
|
||||||
|
const _bmUpdate = BattleManager.update;
|
||||||
|
BattleManager.update = function () {
|
||||||
|
if (this._phase !== _lastBattlePhase) {
|
||||||
|
_lastBattlePhase = this._phase;
|
||||||
|
writeLog('BATTLE_PHASE', `phase=${this._phase}`, {
|
||||||
|
busy: this.isBusy ? this.isBusy() : null,
|
||||||
|
troopRunning: typeof $gameTroop !== 'undefined' && $gameTroop && $gameTroop._interpreter ? $gameTroop._interpreter.isRunning() : null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return _bmUpdate.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Game_Interpreter 監視(セットアップ・コマンド実行・例外・停滞スナップショット)
|
||||||
|
const _giSetup = Game_Interpreter.prototype.setup;
|
||||||
|
Game_Interpreter.prototype.setup = function (list, eventId) {
|
||||||
|
const res = _giSetup.apply(this, arguments);
|
||||||
|
writeLog('INTERP_SETUP', `depth=${this._depth} eventId=${eventId || this._eventId} len=${list ? list.length : 0}`);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
const _giTerminate = Game_Interpreter.prototype.terminate;
|
||||||
|
Game_Interpreter.prototype.terminate = function () {
|
||||||
|
writeLog('INTERP_END', `depth=${this._depth} eventId=${this._eventId}`);
|
||||||
|
return _giTerminate.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
const _giExec = Game_Interpreter.prototype.executeCommand;
|
||||||
|
Game_Interpreter.prototype.executeCommand = function () {
|
||||||
|
const cmd = this.currentCommand();
|
||||||
|
const idx = this._index;
|
||||||
|
try {
|
||||||
|
if (cmd) {
|
||||||
|
if (cmd.code === 117) {
|
||||||
|
writeLog('INTERP_CE', `depth=${this._depth} idx=${idx} call CE[${cmd.parameters[0]}]`);
|
||||||
|
} else if (cmd.code === 355) {
|
||||||
|
const line = String(cmd.parameters[0] || '');
|
||||||
|
if (/spine|setSkeleton|setAnimation|setSkin|PluginManager/i.test(line)) {
|
||||||
|
writeLog('INTERP_SCRIPT', `depth=${this._depth} idx=${idx}`, line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _giExec.apply(this, arguments);
|
||||||
|
} catch (e) {
|
||||||
|
writeLog('INTERP_ERROR', `depth=${this._depth} idx=${idx} code=${cmd ? cmd.code : -1} err=${e && e.message}`, {
|
||||||
|
stack: e && e.stack ? String(e.stack) : ''
|
||||||
|
});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 停滞監視(バトル中のインタープリタや並列イベントが30フレーム以上止まっているように見える場合のスナップショット)
|
||||||
|
let _lastSnapshotFrame = -999;
|
||||||
|
const _sbUpdate = Scene_Base.prototype.update;
|
||||||
|
Scene_Base.prototype.update = function () {
|
||||||
|
const res = _sbUpdate.apply(this, arguments);
|
||||||
|
try {
|
||||||
|
const f = frame();
|
||||||
|
if (f - _lastSnapshotFrame >= 60 && typeof $gameSwitches !== 'undefined' && $gameSwitches) {
|
||||||
|
const s15 = $gameSwitches.value(15);
|
||||||
|
const s20 = $gameSwitches.value(20);
|
||||||
|
const s51 = $gameSwitches.value(51);
|
||||||
|
const troopInterp = typeof $gameTroop !== 'undefined' && $gameTroop && $gameTroop._interpreter;
|
||||||
|
const running = troopInterp && troopInterp.isRunning();
|
||||||
|
if (s15 || s20 || s51 || running) {
|
||||||
|
_lastSnapshotFrame = f;
|
||||||
|
const cmd = running ? troopInterp.currentCommand() : null;
|
||||||
|
let pic1Spine = null;
|
||||||
|
try {
|
||||||
|
const p1 = $gameScreen && $gameScreen.picture(1);
|
||||||
|
if (p1 && p1._spine) {
|
||||||
|
pic1Spine = {
|
||||||
|
skel: p1._spine._skeleton,
|
||||||
|
track0: p1._spine._track && p1._spine._track[0] ? p1._spine._track[0].list.map(x => x.name) : null,
|
||||||
|
play0: p1._spine._playData && p1._spine._playData[0] ? p1._spine._playData[0].map(x => x.name + ':' + x.state + '@' + Number(x.trackTime).toFixed(2)) : null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
writeLog('SNAPSHOT', `phase=${BattleManager._phase} troopRun=${running} idx=${troopInterp ? troopInterp._index : -1} code=${cmd ? cmd.code : -1}`, {
|
||||||
|
S15: s15, S20: s20, S51: s51,
|
||||||
|
V54: $gameVariables ? $gameVariables.value(54) : null,
|
||||||
|
V55: $gameVariables ? $gameVariables.value(55) : null,
|
||||||
|
V102: $gameVariables ? $gameVariables.value(102) : null,
|
||||||
|
pic1Spine
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
// PictureSpine フック (Game_Spine & Sprite_Spine)
|
||||||
|
function hookPictureSpine() {
|
||||||
|
if (typeof Game_Spine !== 'undefined' && !Game_Spine.__glTraceHooked) {
|
||||||
|
Game_Spine.__glTraceHooked = true;
|
||||||
|
const _gsSetSkel = Game_Spine.prototype.setSkeleton;
|
||||||
|
Game_Spine.prototype.setSkeleton = function (name) {
|
||||||
|
const before = this._skeleton;
|
||||||
|
const res = _gsSetSkel.apply(this, arguments);
|
||||||
|
writeLog('GS_SETSKEL', `name=${name} (${before} -> ${this._skeleton})`);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
const _gsSetAnim = Game_Spine.prototype.setAnimation;
|
||||||
|
Game_Spine.prototype.setAnimation = function (id, animations, ...args) {
|
||||||
|
const before = this._skeleton;
|
||||||
|
const res = _gsSetAnim.apply(this, arguments);
|
||||||
|
writeLog('GS_SETANIM', `track=${id} anim=${JSON.stringify(animations)} args=${JSON.stringify(args)} skel=${before}->${this._skeleton}`);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof Sprite_Spine !== 'undefined' && !Sprite_Spine.__glTraceHooked) {
|
||||||
|
Sprite_Spine.__glTraceHooked = true;
|
||||||
|
const _ssUpdate = Sprite_Spine.prototype.update;
|
||||||
|
Sprite_Spine.prototype.update = function () {
|
||||||
|
try {
|
||||||
|
return _ssUpdate.apply(this, arguments);
|
||||||
|
} catch (e) {
|
||||||
|
writeLog('SS_UPDATE_ERROR', e && e.message ? e.message : String(e), {
|
||||||
|
picId: this._pictureId,
|
||||||
|
skel: this._skeleton,
|
||||||
|
stack: e && e.stack ? String(e.stack) : ''
|
||||||
|
});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const _ssUpdSkel = Sprite_Spine.prototype.updateSkeleton;
|
||||||
|
Sprite_Spine.prototype.updateSkeleton = function (spine) {
|
||||||
|
const prevSkel = this._skeleton;
|
||||||
|
const nextSkel = spine ? spine.skeleton : null;
|
||||||
|
const res = _ssUpdSkel.apply(this, arguments);
|
||||||
|
if (nextSkel && nextSkel !== prevSkel) {
|
||||||
|
writeLog('SS_UPDSKEL', `pic=${this._pictureId} ${prevSkel} -> ${this._skeleton} (target=${nextSkel}, hasData=${!!this._data})`);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
const _ssUpdAnim = Sprite_Spine.prototype.updateAnimation;
|
||||||
|
Sprite_Spine.prototype.updateAnimation = function (spine) {
|
||||||
|
const changed = spine && spine.track !== this._track;
|
||||||
|
const res = _ssUpdAnim.apply(this, arguments);
|
||||||
|
if (changed) {
|
||||||
|
try {
|
||||||
|
const tracks = this._data && this._data.state ? this._data.state.tracks.map(t => t && t.animation ? t.animation.name : null) : null;
|
||||||
|
writeLog('SS_UPDANIM', `pic=${this._pictureId} skel=${this._skeleton}`, { tracks });
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
const _ssOnEvent = Sprite_Spine.prototype.onEvent;
|
||||||
|
Sprite_Spine.prototype.onEvent = function (entry, event) {
|
||||||
|
writeLog('SS_EVENT', `pic=${this._pictureId} anim=${entry && entry.animation ? entry.animation.name : '?'} ev=${event && event.data ? event.data.name : '?'} str=${event ? event.stringValue : ''}`);
|
||||||
|
return _ssOnEvent.apply(this, arguments);
|
||||||
|
};
|
||||||
|
const _ssOnComplete = Sprite_Spine.prototype.onComplete;
|
||||||
|
Sprite_Spine.prototype.onComplete = function (entry) {
|
||||||
|
if (entry && !entry.loop) {
|
||||||
|
writeLog('SS_COMPLETE', `pic=${this._pictureId} track=${entry.trackIndex} anim=${entry.animation ? entry.animation.name : '?'}`);
|
||||||
|
}
|
||||||
|
return _ssOnComplete.apply(this, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _smInit = SceneManager.initialize;
|
||||||
|
SceneManager.initialize = function () {
|
||||||
|
const res = _smInit.apply(this, arguments);
|
||||||
|
hookPictureSpine();
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
hookPictureSpine();
|
||||||
|
})();
|
||||||
Reference in new issue
Block a user