From 6f98860892b6dd5bed89b06822f2d55b1838ad05 Mon Sep 17 00:00:00 2001 From: uduki Date: Fri, 9 Oct 2026 10:48:20 +0900 Subject: [PATCH] =?UTF-8?q?refactor(plugins):=20=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=A4=E3=83=B3=E7=AE=A1=E7=90=86UI=E3=81=AE?= =?UTF-8?q?=E3=82=B0=E3=83=AB=E3=83=BC=E3=83=97=E5=8C=96=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=8A=E3=82=88=E3=81=B3=E7=89=B9=E5=AE=9A=E3=82=B2=E3=83=BC?= =?UTF-8?q?=E3=83=A0=E5=B0=82=E7=94=A8=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E5=88=86=E9=9B=A2=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ModPluginDefinition に IsGameSpecific, TargetGameKey, GroupName, DefaultEnabled を追加 - プリンセスシナジー専用プラグイン(AlwaysMaxHp/AlwaysMaxMp)を一般ゲーム一覧から除外し対象ゲーム限定で表示 - TkoolGameItem のプラグイン一覧を CommonPluginOptions と SpecificPluginOptions に分離 - プラグイン設定Expander内に「共通プラグイン」と「固有ゲーム専用プラグイン」のグループ分けUIを実装 - 右側詳細パネルのレイアウトを改善し、起動ボタンを上部固定したまま下部設定のみを開閉可能に変更 - 不要な旧プラグイン GameLauncher_Mod.js の削除および読み込み除外処理を徹底 --- Engines/Tkool/TkoolGameItem.cs | 116 ++++++++++++++++++---- Engines/Tkool/TkoolModService.cs | 19 +++- GameLauncher.csproj | 1 - MainWindow.xaml | 162 ++++++++++++++++++++----------- MainWindow.xaml.cs | 34 ++++--- Models/ModPluginDefinition.cs | 38 +++++++- Services/GameScannerService.cs | 2 +- plugins/GameLauncher_Mod.js | 99 ------------------- 8 files changed, 273 insertions(+), 198 deletions(-) delete mode 100644 plugins/GameLauncher_Mod.js 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 @@ - - - - - + +