diff --git a/Engines/Tkool/TkoolGameItem.cs b/Engines/Tkool/TkoolGameItem.cs index e1e59b2..d5a372a 100644 --- a/Engines/Tkool/TkoolGameItem.cs +++ b/Engines/Tkool/TkoolGameItem.cs @@ -615,27 +615,46 @@ namespace GameLauncher.Engines.Tkool private Dictionary _pluginSettings = new(StringComparer.OrdinalIgnoreCase); private ObservableCollection _pluginOptions = []; + private ObservableCollection _commonPluginOptions = []; + private ObservableCollection _specificPluginOptions = []; public Dictionary PluginSettings { - get => _pluginSettings; - set { if (_pluginSettings != value) { _pluginSettings = value; OnPropertyChanged(); } } + get => this._pluginSettings; + set { if (this._pluginSettings != value) { this._pluginSettings = value; this.OnPropertyChanged(); } } } public override ObservableCollection PluginOptions { - get => _pluginOptions; - set { if (_pluginOptions != value) { _pluginOptions = value; OnPropertyChanged(); } } + get => this._pluginOptions; + set { if (this._pluginOptions != value) { this._pluginOptions = value; this.OnPropertyChanged(); } } } + /// 共通プラグイン設定コレクション + public ObservableCollection CommonPluginOptions + { + get => this._commonPluginOptions; + set { if (this._commonPluginOptions != value) { this._commonPluginOptions = value; this.OnPropertyChanged(); } } + } + + /// 固有ゲーム専用プラグイン設定コレクション + public ObservableCollection SpecificPluginOptions + { + get => this._specificPluginOptions; + set { if (this._specificPluginOptions != value) { this._specificPluginOptions = value; this.OnPropertyChanged(); } } + } + + /// 固有ゲーム専用プラグインが存在するかどうか + public bool HasSpecificPlugins => this._specificPluginOptions.Count > 0; + /// /// プリンセスシナジー専用: HP常時MAX(プラグイン "AlwaysMaxHp")の有効状態。 /// PluginSettings に直接マッピングされ、既存の改造適用パイプラインで反映されます。 /// public bool PrincessAlwaysMaxHp { - get => IsPluginEnabled("AlwaysMaxHp", fallbackVal: false); - set => SetPrincessPluginSetting("AlwaysMaxHp", value); + get => this.IsPluginEnabled("AlwaysMaxHp", fallbackVal: false); + set => this.SetPrincessPluginSetting("AlwaysMaxHp", value); } /// @@ -643,8 +662,8 @@ namespace GameLauncher.Engines.Tkool /// public bool PrincessAlwaysMaxMp { - get => IsPluginEnabled("AlwaysMaxMp", fallbackVal: false); - set => SetPrincessPluginSetting("AlwaysMaxMp", value); + get => this.IsPluginEnabled("AlwaysMaxMp", fallbackVal: false); + set => this.SetPrincessPluginSetting("AlwaysMaxMp", value); } /// @@ -652,15 +671,23 @@ namespace GameLauncher.Engines.Tkool /// private void SetPrincessPluginSetting(string pluginId, bool value) { - if (_pluginSettings.TryGetValue(pluginId, out var cur) && cur == value) + if (this._pluginSettings.TryGetValue(pluginId, out var cur) && cur == value) { return; } - _pluginSettings[pluginId] = value; - OnPropertyChanged(pluginId == "AlwaysMaxHp" ? nameof(PrincessAlwaysMaxHp) : nameof(PrincessAlwaysMaxMp)); + this._pluginSettings[pluginId] = value; + this.OnPropertyChanged(pluginId == "AlwaysMaxHp" ? nameof(this.PrincessAlwaysMaxHp) : nameof(this.PrincessAlwaysMaxMp)); + + // プラグイン一覧側のアイテムとも同期 + var optItem = this._pluginOptions.FirstOrDefault(o => string.Equals(o.Id, pluginId, StringComparison.OrdinalIgnoreCase)); + if (optItem != null && optItem.IsEnabled != value) + { + optItem.IsEnabled = value; + } + // 連動して独自の改造設定であることを示す - HasCustomApplyMod = true; + this.HasCustomApplyMod = true; } public bool IsPluginEnabled(string pluginId, Dictionary? defaultSettings = null, bool fallbackVal = true) @@ -691,6 +718,12 @@ namespace GameLauncher.Engines.Tkool } } + // ショップ初期個数最大および個別ゲーム専用プラグインは既定でOFF + if (pluginId is "ShopMaxBuy" or "AlwaysMaxHp" or "AlwaysMaxMp") + { + return false; + } + return fallbackVal; } @@ -732,33 +765,55 @@ namespace GameLauncher.Engines.Tkool public void SyncPluginOptions(IEnumerable availablePlugins, Dictionary? defaultSettings = null) { - _pluginOptions.Clear(); - if (EngineType is TkoolEngineType.Wolf or TkoolEngineType.Nwjs) + this._pluginOptions.Clear(); + this._commonPluginOptions.Clear(); + this._specificPluginOptions.Clear(); + + if (this.EngineType is TkoolEngineType.Wolf or TkoolEngineType.Nwjs) { + this.OnPropertyChanged(nameof(this.HasSpecificPlugins)); return; } IEnumerable targetDefs; - if (EngineType == TkoolEngineType.Tyrano) + if (this.EngineType == TkoolEngineType.Tyrano) { targetDefs = DefaultTyranoPlugins; } - else if (IsRgss) + else if (this.IsRgss) { targetDefs = DefaultRgssPlugins; } - else if (IsSrpgStudio) + else if (this.IsSrpgStudio) { targetDefs = DefaultSrpgPlugins; } else { - targetDefs = availablePlugins; + // MV / MZ: 固有ゲームプラグイン(AlwaysMaxHp/AlwaysMaxMp等)は、対象ゲーム以外では一覧に表示しない + targetDefs = availablePlugins.Where(p => + { + // 削除対象の旧プラグインは除外 + if (string.Equals(p.Id, "GameLauncher_Mod", StringComparison.OrdinalIgnoreCase) || + string.Equals(p.Id, "GameLauncher_StandaloneMod", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + if (p.IsGameSpecific) + { + if (string.Equals(p.TargetGameKey, "PrincessSynergy", StringComparison.OrdinalIgnoreCase) && !this.IsPrincessSynergy) + { + return false; + } + } + return true; + }); } foreach (var def in targetDefs) { - bool isEnabled = IsPluginEnabled(def.Id, defaultSettings, fallbackVal: true); + bool isEnabled = this.IsPluginEnabled(def.Id, defaultSettings, fallbackVal: def.DefaultEnabled); var item = new ModPluginOptionItem { Definition = def, @@ -768,11 +823,30 @@ namespace GameLauncher.Engines.Tkool { if (e.PropertyName == nameof(ModPluginOptionItem.IsEnabled)) { - _pluginSettings[def.Id] = item.IsEnabled; + this._pluginSettings[def.Id] = item.IsEnabled; + if (def.Id == "AlwaysMaxHp") + { + this.OnPropertyChanged(nameof(this.PrincessAlwaysMaxHp)); + } + else if (def.Id == "AlwaysMaxMp") + { + this.OnPropertyChanged(nameof(this.PrincessAlwaysMaxMp)); + } } }; - _pluginOptions.Add(item); + + this._pluginOptions.Add(item); + if (def.IsGameSpecific) + { + this._specificPluginOptions.Add(item); + } + else + { + this._commonPluginOptions.Add(item); + } } + + this.OnPropertyChanged(nameof(this.HasSpecificPlugins)); } public ModPluginOptions ModOptions diff --git a/Engines/Tkool/TkoolModService.cs b/Engines/Tkool/TkoolModService.cs index 98f196a..4e82dc1 100644 --- a/Engines/Tkool/TkoolModService.cs +++ b/Engines/Tkool/TkoolModService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -31,7 +31,11 @@ namespace GameLauncher.Engines.Tkool "BattleTurnRecover", "MaxGainGold", "MaxGainExp", - "InstantMessage" + "InstantMessage", + "GameLauncher_Mod", + "GameLauncherMod", + "GameLauncher_StandaloneMod", + "GameLauncherStandaloneMod" ]; private List _availablePlugins = []; @@ -86,7 +90,16 @@ namespace GameLauncher.Engines.Tkool { try { - list.Add(ModPluginDefinition.FromFile(file)); + var def = ModPluginDefinition.FromFile(file); + if (string.Equals(def.Id, "GameLauncher_Mod", StringComparison.OrdinalIgnoreCase) || + string.Equals(def.Id, "GameLauncher_StandaloneMod", StringComparison.OrdinalIgnoreCase) || + string.Equals(def.Id, "GameLauncherMod", StringComparison.OrdinalIgnoreCase) || + string.Equals(def.Id, "GameLauncherStandaloneMod", StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + list.Add(def); } catch { } } diff --git a/GameLauncher.csproj b/GameLauncher.csproj index ab0ff44..4da616d 100644 --- a/GameLauncher.csproj +++ b/GameLauncher.csproj @@ -24,7 +24,6 @@ - diff --git a/MainWindow.xaml b/MainWindow.xaml index 5215e1d..5f5e2e9 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -784,25 +784,24 @@ - - - - - + +