diff --git a/Engines/Bakin/BakinDetector.cs b/Engines/Bakin/BakinDetector.cs
new file mode 100644
index 0000000..7573b8f
--- /dev/null
+++ b/Engines/Bakin/BakinDetector.cs
@@ -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
+{
+ ///
+ /// RPG Developer Bakin / Smile Game Builder 系ゲームの検出およびメタデータ解決を行うヘルパークラス。
+ ///
+ public static class BakinDetector
+ {
+ #region □変数(Private)
+
+ private static readonly HashSet ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
+ {
+ "bakinplayer.exe",
+ "notification_helper.exe",
+ "crashpad_handler.exe",
+ "elevate.exe",
+ "UnityCrashHandler32.exe",
+ "UnityCrashHandler64.exe"
+ };
+
+ #endregion
+
+ #region □メソッド(Public)
+
+ ///
+ /// 指定されたディレクトリが RPG Developer Bakin 製ゲームであるかを判定します。
+ ///
+ /// 対象ディレクトリパス
+ /// Bakin ゲームであれば true
+ 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;
+ }
+
+ ///
+ /// 指定ディレクトリ内の RPG Developer Bakin ゲームを検出し、TkoolGameItem を生成します。
+ ///
+ /// ゲームフォルダの絶対パス
+ /// フォルダ名
+ /// フォルダ更新日時
+ /// アイコン読み込み関数
+ /// 検出されたゲームアイテム。該当しない場合は null
+ public static TkoolGameItem? DetectBakinGame(
+ string dirPath,
+ string folderName,
+ DateTime? folderModified,
+ Func? 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;
+ }
+ }
+
+ ///
+ /// Bakin ゲームの起動用実行ファイル(ランチャー .exe または bakinplayer.exe)を検索します。
+ ///
+ /// ゲームルートディレクトリ
+ /// フォルダ名(省略可)
+ /// 実行ファイルのフルパス。見つからない場合は null
+ 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;
+ }
+
+ ///
+ /// Bakin ゲームのセーブデータ格納ディレクトリ (`data/savedata` または `savedata`) を解決します。
+ ///
+ /// ゲームルートディレクトリ
+ /// セーブデータディレクトリのフルパス
+ 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
+ }
+}
diff --git a/Engines/Bakin/BakinEngineModule.cs b/Engines/Bakin/BakinEngineModule.cs
new file mode 100644
index 0000000..842fe7e
--- /dev/null
+++ b/Engines/Bakin/BakinEngineModule.cs
@@ -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
+{
+ ///
+ /// RPG Developer Bakin エンジン用の 実装クラス。
+ ///
+ public sealed class BakinEngineModule : IEngineModule
+ {
+ #region □プロパティ(Public)
+
+ ///
+ public string EngineName => EngineDetectionHelper.EngineBakin;
+
+ #endregion
+
+ #region □メソッド(Public)
+
+ ///
+ public bool Detect(string gameDirectory)
+ {
+ return BakinDetector.IsBakinGame(gameDirectory);
+ }
+
+ ///
+ public bool ApplyMod(string gameDirectory, ModPluginDefinition plugin)
+ {
+ // Bakin はセーブデータエディタ方式で改造を行うため、スクリプト注入は不要
+ return false;
+ }
+
+ ///
+ public bool IsModApplied(string gameDirectory)
+ {
+ return false;
+ }
+
+ ///
+ public string ResolveToolPath(string toolFileName)
+ {
+ return AppPathHelper.ResolveEngineTool(this.EngineName, toolFileName) ?? string.Empty;
+ }
+
+ #endregion
+ }
+}
diff --git a/Engines/Bakin/BakinSaveEditorDialog.xaml b/Engines/Bakin/BakinSaveEditorDialog.xaml
new file mode 100644
index 0000000..4405a87
--- /dev/null
+++ b/Engines/Bakin/BakinSaveEditorDialog.xaml
@@ -0,0 +1,237 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Engines/Bakin/BakinSaveEditorDialog.xaml.cs b/Engines/Bakin/BakinSaveEditorDialog.xaml.cs
new file mode 100644
index 0000000..94d9964
--- /dev/null
+++ b/Engines/Bakin/BakinSaveEditorDialog.xaml.cs
@@ -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
+{
+ ///
+ /// RPG Developer Bakin (YUKRDATA .sgs) セーブデータの閲覧・編集・クイックチート・バックアップ復元を行うダイアログウィンドウ。
+ ///
+ public partial class BakinSaveEditorDialog : Window
+ {
+ #region □定数(Private)
+
+ private const string AllCategoriesLabel = "すべて表示";
+
+ #endregion
+
+ #region □変数(Private)
+
+ private readonly TkoolGameItem _game;
+ private List _saveFiles = new();
+ private BakinSaveDocument? _currentDoc;
+ private ICollectionView? _entriesView;
+ private bool _suppressFilterEvents;
+
+ #endregion
+
+ #region □コンストラクタ
+
+ ///
+ /// の新しいインスタンスを初期化します。
+ ///
+ /// 対象の Bakin ゲームアイテム
+ 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 { 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