refactor(plugins): プラグイン管理UIのグループ化表示および特定ゲーム専用プラグインの分離に対応
- ModPluginDefinition に IsGameSpecific, TargetGameKey, GroupName, DefaultEnabled を追加 - プリンセスシナジー専用プラグイン(AlwaysMaxHp/AlwaysMaxMp)を一般ゲーム一覧から除外し対象ゲーム限定で表示 - TkoolGameItem のプラグイン一覧を CommonPluginOptions と SpecificPluginOptions に分離 - プラグイン設定Expander内に「共通プラグイン」と「固有ゲーム専用プラグイン」のグループ分けUIを実装 - 右側詳細パネルのレイアウトを改善し、起動ボタンを上部固定したまま下部設定のみを開閉可能に変更 - 不要な旧プラグイン GameLauncher_Mod.js の削除および読み込み除外処理を徹底
This commit is contained in:
1 parent
c0989362a9
commit
6f98860892
8 files changed
+273
-198
No files matched your search
@@ -615,27 +615,46 @@ namespace GameLauncher.Engines.Tkool
|
||||
|
||||
private Dictionary<string, bool> _pluginSettings = new(StringComparer.OrdinalIgnoreCase);
|
||||
private ObservableCollection<ModPluginOptionItem> _pluginOptions = [];
|
||||
private ObservableCollection<ModPluginOptionItem> _commonPluginOptions = [];
|
||||
private ObservableCollection<ModPluginOptionItem> _specificPluginOptions = [];
|
||||
|
||||
public Dictionary<string, bool> 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<ModPluginOptionItem> PluginOptions
|
||||
{
|
||||
get => _pluginOptions;
|
||||
set { if (_pluginOptions != value) { _pluginOptions = value; OnPropertyChanged(); } }
|
||||
get => this._pluginOptions;
|
||||
set { if (this._pluginOptions != value) { this._pluginOptions = value; this.OnPropertyChanged(); } }
|
||||
}
|
||||
|
||||
/// <summary>共通プラグイン設定コレクション</summary>
|
||||
public ObservableCollection<ModPluginOptionItem> CommonPluginOptions
|
||||
{
|
||||
get => this._commonPluginOptions;
|
||||
set { if (this._commonPluginOptions != value) { this._commonPluginOptions = value; this.OnPropertyChanged(); } }
|
||||
}
|
||||
|
||||
/// <summary>固有ゲーム専用プラグイン設定コレクション</summary>
|
||||
public ObservableCollection<ModPluginOptionItem> SpecificPluginOptions
|
||||
{
|
||||
get => this._specificPluginOptions;
|
||||
set { if (this._specificPluginOptions != value) { this._specificPluginOptions = value; this.OnPropertyChanged(); } }
|
||||
}
|
||||
|
||||
/// <summary>固有ゲーム専用プラグインが存在するかどうか</summary>
|
||||
public bool HasSpecificPlugins => this._specificPluginOptions.Count > 0;
|
||||
|
||||
/// <summary>
|
||||
/// プリンセスシナジー専用: HP常時MAX(プラグイン "AlwaysMaxHp")の有効状態。
|
||||
/// PluginSettings に直接マッピングされ、既存の改造適用パイプラインで反映されます。
|
||||
/// </summary>
|
||||
public bool PrincessAlwaysMaxHp
|
||||
{
|
||||
get => IsPluginEnabled("AlwaysMaxHp", fallbackVal: false);
|
||||
set => SetPrincessPluginSetting("AlwaysMaxHp", value);
|
||||
get => this.IsPluginEnabled("AlwaysMaxHp", fallbackVal: false);
|
||||
set => this.SetPrincessPluginSetting("AlwaysMaxHp", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -643,8 +662,8 @@ namespace GameLauncher.Engines.Tkool
|
||||
/// </summary>
|
||||
public bool PrincessAlwaysMaxMp
|
||||
{
|
||||
get => IsPluginEnabled("AlwaysMaxMp", fallbackVal: false);
|
||||
set => SetPrincessPluginSetting("AlwaysMaxMp", value);
|
||||
get => this.IsPluginEnabled("AlwaysMaxMp", fallbackVal: false);
|
||||
set => this.SetPrincessPluginSetting("AlwaysMaxMp", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -652,15 +671,23 @@ namespace GameLauncher.Engines.Tkool
|
||||
/// </summary>
|
||||
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<string, bool>? 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<ModPluginDefinition> availablePlugins, Dictionary<string, bool>? 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<ModPluginDefinition> 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
|
||||
|
||||
@@ -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<ModPluginDefinition> _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 { }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user