機能追加: 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

+252
View File
@@ -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
}
}
+49
View File
@@ -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
}
}
+237
View File
@@ -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>
+510
View File
@@ -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