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

+83 -14
View File
@@ -1,12 +1,11 @@
using System;
// Engines/Nwjs/NwjsDetector.cs — 汎用 NW.js ゲーム検出およびメタデータ解決ヘルパー
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Windows.Media;
using GameLauncher.Engines.Common;
using GameLauncher.Engines.Tkool;
using GameLauncher.Engines.Unity;
using GameLauncher.Models;
@@ -14,10 +13,12 @@ using GameLauncher.Models;
namespace GameLauncher.Engines.Nwjs
{
/// <summary>
/// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス
/// 汎用 NW.js (Node-Webkit) アプリケーション/ゲームの検出およびアイテム生成を行うヘルパークラス。
/// </summary>
public static class NwjsDetector
{
#region □変数(Private)
private static readonly HashSet<string> ExcludedExeNames = new(StringComparer.OrdinalIgnoreCase)
{
"notification_helper.exe",
@@ -25,6 +26,10 @@ namespace GameLauncher.Engines.Nwjs
"elevate.exe"
};
#endregion
#region □メソッド(Public)
/// <summary>
/// 指定されたディレクトリが汎用 NW.js ゲームであるかを判定します。
/// ツクール(MV/MZ/RGSS)、ティラノスクリプト、ウディタ、SRPG Studio など既存エンジン形式は除外します。
@@ -69,7 +74,7 @@ namespace GameLauncher.Engines.Nwjs
}
// package.json に main や window 記述があるか確認
if (TryReadPackageJson(dirPath, out _, out _, out var main, out _))
if (NwjsDetector.TryReadPackageJson(dirPath, out _, out _, out var main, out _))
{
if (!string.IsNullOrWhiteSpace(main) && File.Exists(Path.Combine(dirPath, main)))
{
@@ -101,12 +106,12 @@ namespace GameLauncher.Engines.Nwjs
{
try
{
if (!IsNwjsGame(dirPath))
if (!NwjsDetector.IsNwjsGame(dirPath))
{
return null;
}
TryReadPackageJson(dirPath, out var windowTitle, out var packageName, out var mainFile, out var iconRelPath);
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;
@@ -121,7 +126,7 @@ namespace GameLauncher.Engines.Nwjs
? Path.Combine(dirPath, mainFile)
: Path.Combine(dirPath, "index.html");
title = ExtractHtmlTitle(htmlPath);
title = NwjsDetector.ExtractHtmlTitle(htmlPath);
}
if (string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(packageName))
@@ -135,7 +140,7 @@ namespace GameLauncher.Engines.Nwjs
}
// 実行ファイルの探索
var exePath = FindNwjsExecutable(dirPath, title, packageName);
var exePath = NwjsDetector.FindNwjsExecutable(dirPath, title, packageName);
// アイコンの取得
ImageSource? icon = null;
@@ -144,17 +149,29 @@ namespace GameLauncher.Engines.Nwjs
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 = string.Empty,
PluginsDirPath = string.Empty,
PluginsJsPath = entryHtmlPath,
PluginsDirPath = entryDirPath,
EngineType = TkoolEngineType.Nwjs,
IsModded = false,
ApplyMod = false,
IsModded = isModded,
ApplyMod = isModded,
HasSaveData = saveFiles.Count > 0,
// セーブデータ有無
IconImage = icon,
FolderLastModified = folderModified
};
@@ -165,6 +182,50 @@ namespace GameLauncher.Engines.Nwjs
}
}
/// <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 を特定します。
@@ -185,10 +246,12 @@ namespace GameLauncher.Engines.Nwjs
{
return false;
}
if (ExcludedExeNames.Contains(fileName))
if (NwjsDetector.ExcludedExeNames.Contains(fileName))
{
return false;
}
return true;
})
.ToList();
@@ -244,6 +307,10 @@ namespace GameLauncher.Engines.Nwjs
}
}
#endregion
#region □メソッド(Private)
/// <summary>
/// package.json を読み込み、主要な設定値を抽出します。
/// </summary>
@@ -328,5 +395,7 @@ namespace GameLauncher.Engines.Nwjs
return string.Empty;
}
#endregion
}
}
File diff suppressed because it is too large. Load diff
+260
View File
@@ -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>
+504
View File
@@ -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