機能追加: Bakin・NW.jsエンジンおよびセーブ編集対応、ES3パスワード解決機能とRPGツクールMZ修正サービスの追加
This commit is contained in:
1 parent
f50976a6c0
commit
152abae1f8
33 files changed
+11356
-175
No files matched your search
@@ -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
@@ -29,6 +29,9 @@ namespace GameLauncher.Engines.Common
|
||||
/// <summary>Canonical engine name for generic NW.js packaged games.</summary>
|
||||
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>
|
||||
public const string EngineEvb = "Evb";
|
||||
|
||||
@@ -80,6 +83,11 @@ namespace GameLauncher.Engines.Common
|
||||
return EngineNwjs;
|
||||
}
|
||||
|
||||
if (Matches(value, "Bakin", "RPGDeveloperBakin", "SmileGameBuilder", "SGB"))
|
||||
{
|
||||
return EngineBakin;
|
||||
}
|
||||
|
||||
if (Matches(value, "Evb", "Enigma", "EnigmaVB", "EnigmaVirtualBox"))
|
||||
{
|
||||
return EngineEvb;
|
||||
@@ -129,6 +137,12 @@ namespace GameLauncher.Engines.Common
|
||||
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.
|
||||
var wwwDir = Path.Combine(gameDirectory, "www");
|
||||
if (Directory.Exists(wwwDir))
|
||||
|
||||
@@ -89,8 +89,10 @@ namespace GameLauncher.Engines.Evb
|
||||
}
|
||||
}
|
||||
|
||||
// First exe at the top level, then one level deeper.
|
||||
var top = Directory.GetFiles(outputDirectory, "*.exe", SearchOption.TopDirectoryOnly);
|
||||
// First exe at the top level, then one level deeper (excluding helper/installer exes).
|
||||
var top = Directory.GetFiles(outputDirectory, "*.exe", SearchOption.TopDirectoryOnly)
|
||||
.Where(f => !IsExcludedHelperExe(Path.GetFileName(f)))
|
||||
.ToArray();
|
||||
if (top.Length > 0)
|
||||
{
|
||||
return top[0];
|
||||
@@ -98,7 +100,9 @@ namespace GameLauncher.Engines.Evb
|
||||
|
||||
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)
|
||||
{
|
||||
return nested[0];
|
||||
@@ -113,6 +117,17 @@ namespace GameLauncher.Engines.Evb
|
||||
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>
|
||||
/// 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,
|
||||
|
||||
@@ -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
@@ -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
@@ -105,6 +105,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
private bool _applyMod = true;
|
||||
private bool _hasCustomApplyMod;
|
||||
private bool _isInitializingApplyMod;
|
||||
private bool _hasSaveData;
|
||||
private ModPluginOptions _modOptions = new();
|
||||
|
||||
// app.asar 関連プロパティ
|
||||
@@ -130,6 +131,20 @@ namespace GameLauncher.Engines.Tkool
|
||||
private string? _evbBackupPath;
|
||||
private string _evbUnderlyingEngine = string.Empty;
|
||||
|
||||
/// <summary>セーブデータ検出フラグ</summary>
|
||||
public override bool HasSaveData
|
||||
{
|
||||
get => this._hasSaveData;
|
||||
set
|
||||
{
|
||||
if (this._hasSaveData != value)
|
||||
{
|
||||
this._hasSaveData = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Enigma Virtual Box でパックされた exe を持つゲームかどうか</summary>
|
||||
public override bool IsEvbPacked
|
||||
{
|
||||
@@ -306,6 +321,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
TkoolEngineType.Wolf => GameEngineKind.Wolf,
|
||||
TkoolEngineType.SrpgStudio => GameEngineKind.SrpgStudio,
|
||||
TkoolEngineType.Nwjs => GameEngineKind.Nwjs,
|
||||
TkoolEngineType.Bakin => GameEngineKind.Bakin,
|
||||
TkoolEngineType.Other => GameEngineKind.Other,
|
||||
_ => GameEngineKind.Tkool
|
||||
};
|
||||
@@ -331,17 +347,18 @@ namespace GameLauncher.Engines.Tkool
|
||||
public override bool IsSrpgStudio => this.EngineType == TkoolEngineType.SrpgStudio;
|
||||
public override bool IsRgss => this.EngineType is TkoolEngineType.VX or TkoolEngineType.VXAce;
|
||||
public override bool IsNwjs => this.EngineType == TkoolEngineType.Nwjs;
|
||||
public override bool IsBakin => this.EngineType == TkoolEngineType.Bakin;
|
||||
public override bool IsOther => this.EngineType == TkoolEngineType.Other;
|
||||
|
||||
/// <summary>
|
||||
/// スクリプト改造(プラグイン注入など)が適用可能な状態かどうか。
|
||||
/// 該当ゲームが改造非対応(ウディタ・SRPG・NW.js・その他・未解凍状態など)の場合は false を返します。
|
||||
/// 該当ゲームが改造非対応(ウディタ・SRPG・Bakin・NW.js・その他・未解凍状態など)の場合は false を返します。
|
||||
/// </summary>
|
||||
public override bool CanApplyScriptMod
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.IsWolf || this.IsNwjs || this.IsSrpgStudio || this.IsOther)
|
||||
if (this.IsWolf || this.IsSrpgStudio || this.IsBakin || this.IsOther)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -365,7 +382,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
}
|
||||
return !string.IsNullOrEmpty(this.PluginsJsPath) && File.Exists(this.PluginsJsPath);
|
||||
}
|
||||
if (this.IsMV || this.IsMZ || this.IsTyrano)
|
||||
if (this.IsMV || this.IsMZ || this.IsTyrano || this.IsNwjs)
|
||||
{
|
||||
return !string.IsNullOrEmpty(this.PluginsJsPath) && File.Exists(this.PluginsJsPath);
|
||||
}
|
||||
@@ -385,6 +402,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
TkoolEngineType.Tyrano => "ティラノ",
|
||||
TkoolEngineType.Wolf => "ウディタ",
|
||||
TkoolEngineType.SrpgStudio => "SRPG",
|
||||
TkoolEngineType.Bakin => "Bakin",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
@@ -398,6 +416,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
TkoolEngineType.Tyrano => new SolidColorBrush(Color.FromRgb(0xD3, 0x54, 0x00)),
|
||||
TkoolEngineType.Wolf => new SolidColorBrush(Color.FromRgb(0x8B, 0x57, 0x1E)),
|
||||
TkoolEngineType.SrpgStudio => new SolidColorBrush(Color.FromRgb(0x1E, 0x7A, 0x5F)),
|
||||
TkoolEngineType.Bakin => new SolidColorBrush(Color.FromRgb(0xD9, 0x77, 0x06)),
|
||||
_ => Brushes.Transparent
|
||||
};
|
||||
|
||||
@@ -562,6 +581,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
this.OnPropertyChanged(nameof(this.IsSrpgStudio));
|
||||
this.OnPropertyChanged(nameof(this.IsRgss));
|
||||
this.OnPropertyChanged(nameof(this.IsNwjs));
|
||||
this.OnPropertyChanged(nameof(this.IsBakin));
|
||||
this.OnPropertyChanged(nameof(this.IsOther));
|
||||
this.OnPropertyChanged(nameof(this.NwjsBadgeText));
|
||||
this.OnPropertyChanged(nameof(this.NwjsBadgeVisibility));
|
||||
@@ -583,6 +603,44 @@ namespace GameLauncher.Engines.Tkool
|
||||
}
|
||||
}
|
||||
|
||||
// ================= ツクールMZ関連プロパティ =================
|
||||
private bool _mzPixiErrorFix = true;
|
||||
private bool _mzSpineErrorFix = true;
|
||||
|
||||
/// <summary>
|
||||
/// ツクールMZ専用: Pixi.jsのテクスチャ参照エラー(Cannot read property 'valid' of null)修復およびDevTools有効化フラグ。
|
||||
/// 初期値は true(チェックON)
|
||||
/// </summary>
|
||||
public override bool MzPixiErrorFix
|
||||
{
|
||||
get => this._mzPixiErrorFix;
|
||||
set
|
||||
{
|
||||
if (this._mzPixiErrorFix != value)
|
||||
{
|
||||
this._mzPixiErrorFix = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ツクールMZ専用: Spineアニメーション未定義エラー(Animation not found: 0_idle 等)修復フラグ。
|
||||
/// 初期値は true(チェックON)
|
||||
/// </summary>
|
||||
public override bool MzSpineErrorFix
|
||||
{
|
||||
get => this._mzSpineErrorFix;
|
||||
set
|
||||
{
|
||||
if (this._mzSpineErrorFix != value)
|
||||
{
|
||||
this._mzSpineErrorFix = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================= WOLF RPGエディター関連プロパティ =================
|
||||
private bool _wolfProxyDll = false;
|
||||
private double _wolfSpeedMultiplier = 3.0;
|
||||
@@ -919,6 +977,15 @@ namespace GameLauncher.Engines.Tkool
|
||||
new() { Id = "RgssWindowResizeExternal", Name = "🪟 外部ツールでウィンドウ拡大 (Win32 API / Sizer等)", Description = "ゲーム側は無改造のまま、ランチャーがゲームウィンドウを検出してディスプレイに収まる最大の整数倍へ拡大します。外部ツールパス設定があればそちらを優先起動します。(既定OFF)" }
|
||||
];
|
||||
|
||||
/// <summary>NW.js (GameCreator / HTML5・JS) 用スクリプト改造定義一覧</summary>
|
||||
public static readonly ModPluginDefinition[] DefaultNwjsPlugins =
|
||||
[
|
||||
new() { Id = "NwjsCheatMenu", Name = "🎛 ゲーム内ステータス・変数・所持金チートメニュー ([F10] / 画面右上ボタン)", Description = "画面右上の『⚙ チート [F10]』ボタンまたはF10キーで、所持金・ステータス・変数・スイッチ・所持アイテムをリアルタイムに検索・書き換えできるオーバーレイメニューを表示します(GameCreator / HTML5ステート / 汎用NW.js自動認識)。" },
|
||||
new() { Id = "NwjsSpeedHack", Name = "⚡ ゲーム倍速・高速化ショートカット ([F6] 倍速切替 / [Ctrl] 5倍速ブースト)", Description = "F6キーでゲーム速度を 1x → 2x → 3x → 5x に切り替え、Ctrlキー押下中は一時的に5倍速へ加速します(LayaAir/GameCreatorタイマー・アニメーション・動画再生速度対応)。" },
|
||||
new() { Id = "NwjsUnlockGallery", Name = "🔓 全CG・ギャラリー・回想フラグの自動解放", Description = "GalleryStoreやGameCreatorのワールド永続スイッチ(life.gcdata)、localStorage内のギャラリー・回想解放フラグを解放します。" },
|
||||
new() { Id = "NwjsDevTools", Name = "🛠 開発者ツール (F12) の有効化", Description = "F12キーでNW.js / Chromiumの開発者ツールコンソールを開けるようにします。" }
|
||||
];
|
||||
|
||||
/// <summary>SRPG Studio用スクリプト改造定義一覧</summary>
|
||||
public static readonly ModPluginDefinition[] DefaultSrpgPlugins =
|
||||
[
|
||||
@@ -936,14 +1003,18 @@ namespace GameLauncher.Engines.Tkool
|
||||
this._commonPluginOptions.Clear();
|
||||
this._specificPluginOptions.Clear();
|
||||
|
||||
if (this.EngineType is TkoolEngineType.Wolf or TkoolEngineType.Nwjs)
|
||||
if (this.EngineType is TkoolEngineType.Wolf or TkoolEngineType.Bakin or TkoolEngineType.Other)
|
||||
{
|
||||
this.OnPropertyChanged(nameof(this.HasSpecificPlugins));
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<ModPluginDefinition> targetDefs;
|
||||
if (this.EngineType == TkoolEngineType.Tyrano)
|
||||
if (this.IsNwjs)
|
||||
{
|
||||
targetDefs = TkoolGameItem.DefaultNwjsPlugins;
|
||||
}
|
||||
else if (this.EngineType == TkoolEngineType.Tyrano)
|
||||
{
|
||||
targetDefs = DefaultTyranoPlugins;
|
||||
}
|
||||
@@ -1032,6 +1103,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
TkoolEngineType.Wolf => "WOLF RPGエディター",
|
||||
TkoolEngineType.SrpgStudio => "SRPG Studio",
|
||||
TkoolEngineType.Nwjs => "NW.js",
|
||||
TkoolEngineType.Bakin => "RPG Developer Bakin",
|
||||
_ => "ツクール/ティラノ"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace GameLauncher.Engines.Tkool
|
||||
// ※ResourceLoaderFix はリソース読み込み不具合の必須救済プラグインのため、常に有効化・先頭配置
|
||||
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: true))
|
||||
.Where(p => string.Equals(p.Id, "ResourceLoaderFix", StringComparison.OrdinalIgnoreCase) || game.IsPluginEnabled(p.Id, defaultSettings, fallbackVal: p.DefaultEnabled))
|
||||
.ToList();
|
||||
|
||||
// ResourceLoaderFix を最優先(先頭)に配置して、他プラグイン実行前のリソース要求も確実に救済
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
SrpgStudio,
|
||||
Evb,
|
||||
Nwjs,
|
||||
Bakin,
|
||||
Other
|
||||
}
|
||||
|
||||
@@ -28,6 +29,7 @@
|
||||
Wolf,
|
||||
SrpgStudio,
|
||||
Nwjs,
|
||||
Bakin,
|
||||
Other,
|
||||
Unknown
|
||||
}
|
||||
|
||||
@@ -480,8 +480,9 @@ namespace GameLauncher.Engines.Unity
|
||||
if (isStrict)
|
||||
{
|
||||
// セーブファイル候補のフィルタ
|
||||
// .sd / .es3 は Easy Save 3 の標準拡張子(0.sd, s.sd, h.sd などファイル名に "save" を含まない)
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user