機能追加: Bakin・NW.jsエンジンおよびセーブ編集対応、ES3パスワード解決機能とRPGツクールMZ修正サービスの追加

This commit is contained in:
armonica committed 2026-11-20 19:55:34 +09:00
1 parent f50976a6c0
commit 152abae1f8
33 files changed
+11356 -175

No files matched your search

+135 -3
View File
@@ -361,10 +361,18 @@ namespace GameLauncher
this.lblStatus.Text = $"未対応のバイナリセーブデータ: {entry.FileName}";
}
/// <summary>
/// 直近の読み込みで入力・特定されたパスワード。
/// </summary>
private string? _currentPassword;
/// <summary>
/// コーデックからプロパティ一覧を読み込み、パスワードバーの表示を更新します。
/// </summary>
private void LoadGuiPropertiesFromCodec(ISaveDataCodec codec, string filePath)
{
this._guiProperties.Clear();
var props = codec.LoadProperties(filePath);
var props = codec.LoadProperties(filePath, this._currentPassword);
foreach (var p in props)
{
this._guiProperties.Add(p);
@@ -374,6 +382,116 @@ namespace GameLauncher
{
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)
@@ -434,16 +552,30 @@ namespace GameLauncher
{
if (this._currentSelectedFile == null || this._currentCodec == null) return;
bool success = this._currentCodec.SaveProperties(this._currentSelectedFile.FilePath, [.. this._guiProperties]);
// 編集で復号に使ったパスワードを渡し、同一パスワードで再暗号化させる
bool success = this._currentCodec.SaveProperties(
this._currentSelectedFile.FilePath,
[.. this._guiProperties],
this._currentPassword);
if (success)
{
this.lblStatus.Text = $"セーブファイルを正常に更新しました (自動バックアップ .bak 作成済み): {this._currentSelectedFile.FileName}";
// 保存したファイルを読み直して、実際に反映された内容を画面へ再表示する
this.LoadGuiPropertiesFromCodec(this._currentCodec, this._currentSelectedFile.FilePath);
MessageBox.Show("セーブファイルを正常に更新・保存しました。\n(元のファイルは同階層に .bak として自動バックアップされています)",
"保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
}
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);
}
}