diff --git a/Engines/Tkool/TkoolGameItem.cs b/Engines/Tkool/TkoolGameItem.cs index e518366..07a5597 100644 --- a/Engines/Tkool/TkoolGameItem.cs +++ b/Engines/Tkool/TkoolGameItem.cs @@ -148,6 +148,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.EvbExtractedVisibility)); this.OnPropertyChanged(nameof(this.EvbExtractedBadgeText)); this.OnPropertyChanged(nameof(this.EvbDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); this.OnPropertyChanged(nameof(this.IsEvbToolMissing)); } } @@ -170,6 +171,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.EvbExtractedVisibility)); this.OnPropertyChanged(nameof(this.EvbExtractedBadgeText)); this.OnPropertyChanged(nameof(this.EvbDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } @@ -192,7 +194,8 @@ namespace GameLauncher.Engines.Tkool public string EvbUnderlyingEngine { get => this._evbUnderlyingEngine; - set { if (this._evbUnderlyingEngine != value) { this._evbUnderlyingEngine = value; this.OnPropertyChanged(); this.OnPropertyChanged(nameof(this.EvbDetailStatusText)); } } + set { if (this._evbUnderlyingEngine != value) { this._evbUnderlyingEngine = value; this.OnPropertyChanged(); this.OnPropertyChanged(nameof(this.EvbDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } /// EVB として扱うか(UI バッジ判定用) @@ -310,7 +313,7 @@ namespace GameLauncher.Engines.Tkool public string PluginsJsPath { get => this._pluginsJsPath; - set { if (this._pluginsJsPath != value) { this._pluginsJsPath = value; this.OnPropertyChanged(); } } + set { if (this._pluginsJsPath != value) { this._pluginsJsPath = value; this.OnPropertyChanged(); this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } public string PluginsDirPath @@ -330,6 +333,46 @@ namespace GameLauncher.Engines.Tkool public override bool IsNwjs => this.EngineType == TkoolEngineType.Nwjs; public override bool IsOther => this.EngineType == TkoolEngineType.Other; + /// + /// スクリプト改造(プラグイン注入など)が適用可能な状態かどうか。 + /// 該当ゲームが改造非対応(ウディタ・SRPG・NW.js・その他・未解凍状態など)の場合は false を返します。 + /// + public override bool CanApplyScriptMod + { + get + { + if (this.IsWolf || this.IsNwjs || this.IsSrpgStudio || this.IsOther) + { + return false; + } + if (this.IsEvbPacked && !this.IsEvbExtracted) + { + return false; + } + if (this.IsAsar && !this.IsAsarExtracted) + { + return false; + } + if (this.IsStandaloneExePackage && (string.IsNullOrEmpty(this.PluginsJsPath) || !File.Exists(this.PluginsJsPath))) + { + return false; + } + if (this.IsRgss) + { + if (this.HasRgssArchive && !this.IsRgssExtracted) + { + return false; + } + return !string.IsNullOrEmpty(this.PluginsJsPath) && File.Exists(this.PluginsJsPath); + } + if (this.IsMV || this.IsMZ || this.IsTyrano) + { + return !string.IsNullOrEmpty(this.PluginsJsPath) && File.Exists(this.PluginsJsPath); + } + return false; + } + } + /// /// エンジン種別ラベルの表示文字列。該当エンジンが無い場合は空文字を返し、ラベル自体を非表示にします。 /// @@ -454,6 +497,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.RgssBadgeText)); this.OnPropertyChanged(nameof(this.RgssBadgeBackground)); this.OnPropertyChanged(nameof(this.RgssDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } @@ -470,6 +514,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.RgssBadgeText)); this.OnPropertyChanged(nameof(this.RgssBadgeBackground)); this.OnPropertyChanged(nameof(this.RgssDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } @@ -507,6 +552,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.EngineDisplayName)); this.OnPropertyChanged(nameof(this.EngineLabelText)); this.OnPropertyChanged(nameof(this.EngineLabelBackground)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); this.OnPropertyChanged(nameof(this.IsMV)); this.OnPropertyChanged(nameof(this.IsMZ)); this.OnPropertyChanged(nameof(this.IsTyrano)); @@ -532,6 +578,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.RgssBadgeText)); this.OnPropertyChanged(nameof(this.RgssBadgeBackground)); this.OnPropertyChanged(nameof(this.RgssDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } @@ -679,6 +726,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.AsarBadgeText)); this.OnPropertyChanged(nameof(this.AsarBadgeBackground)); this.OnPropertyChanged(nameof(this.AsarDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } @@ -695,6 +743,7 @@ namespace GameLauncher.Engines.Tkool this.OnPropertyChanged(nameof(this.AsarBadgeText)); this.OnPropertyChanged(nameof(this.AsarBadgeBackground)); this.OnPropertyChanged(nameof(this.AsarDetailStatusText)); + this.OnPropertyChanged(nameof(this.CanApplyScriptMod)); } } } diff --git a/Helpers/Converters.cs b/Helpers/Converters.cs index ad34342..a8696a5 100644 --- a/Helpers/Converters.cs +++ b/Helpers/Converters.cs @@ -130,4 +130,22 @@ namespace GameLauncher.Helpers throw new NotImplementedException(); } } + + /// + /// bool値が true の場合に Visible、false または null の場合に Collapsed を返すコンバーター + /// + public class BooleanToVisibilityConverter : IValueConverter + { + public static readonly BooleanToVisibilityConverter Instance = new(); + + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return value is true ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return value is Visibility v && v == Visibility.Visible; + } + } } diff --git a/MainWindow.xaml b/MainWindow.xaml index ec93cd1..5988a23 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -869,20 +869,8 @@ +