- ModPluginDefinition に IsGameSpecific, TargetGameKey, GroupName, DefaultEnabled を追加 - プリンセスシナジー専用プラグイン(AlwaysMaxHp/AlwaysMaxMp)を一般ゲーム一覧から除外し対象ゲーム限定で表示 - TkoolGameItem のプラグイン一覧を CommonPluginOptions と SpecificPluginOptions に分離 - プラグイン設定Expander内に「共通プラグイン」と「固有ゲーム専用プラグイン」のグループ分けUIを実装 - 右側詳細パネルのレイアウトを改善し、起動ボタンを上部固定したまま下部設定のみを開閉可能に変更 - 不要な旧プラグイン GameLauncher_Mod.js の削除および読み込み除外処理を徹底
135 lines
5.4 KiB
C#
135 lines
5.4 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace GameLauncher.Models
|
|
{
|
|
/// <summary>
|
|
/// 動的プラグインの定義情報
|
|
/// </summary>
|
|
public class ModPluginDefinition
|
|
{
|
|
public string Id { get; set; } = string.Empty; // プラグイン識別名 (例: "BattleSpeedUp")
|
|
public string Name { get; set; } = string.Empty; // 表示名
|
|
public string Description { get; set; } = string.Empty; // 説明文
|
|
public string FileName { get; set; } = string.Empty; // ファイル名 (例: "BattleSpeedUp.js")
|
|
public string FilePath { get; set; } = string.Empty; // フルパス
|
|
|
|
/// <summary>特定ゲーム専用プラグインかどうか</summary>
|
|
public bool IsGameSpecific { get; set; }
|
|
|
|
/// <summary>対象ゲーム識別子 (例: "PrincessSynergy")</summary>
|
|
public string TargetGameKey { get; set; } = string.Empty;
|
|
|
|
/// <summary>表示用グループ名</summary>
|
|
public string GroupName { get; set; } = "共通機能";
|
|
|
|
/// <summary>初期チェックの既定値 (未設定時の初期値)</summary>
|
|
public bool DefaultEnabled { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// .js ファイルから定義情報を解析・生成します。
|
|
/// </summary>
|
|
public static ModPluginDefinition FromFile(string filePath)
|
|
{
|
|
var fileName = Path.GetFileName(filePath);
|
|
var id = Path.GetFileNameWithoutExtension(filePath);
|
|
string desc = string.Empty;
|
|
|
|
try
|
|
{
|
|
string text = File.ReadAllText(filePath);
|
|
var match = Regex.Match(text, @"@plugindesc\s+(.*)");
|
|
if (match.Success)
|
|
{
|
|
desc = match.Groups[1].Value.Trim();
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
string displayName = GetFriendlyName(id, desc);
|
|
bool isSpecific = id is "AlwaysMaxHp" or "AlwaysMaxMp";
|
|
string targetKey = isSpecific ? "PrincessSynergy" : string.Empty;
|
|
string groupName = isSpecific ? "固有ゲーム専用プラグイン" : "共通プラグイン";
|
|
bool defEnabled = id switch
|
|
{
|
|
"ShopMaxBuy" => false,
|
|
"AlwaysMaxHp" => false,
|
|
"AlwaysMaxMp" => false,
|
|
_ => true
|
|
};
|
|
|
|
return new ModPluginDefinition
|
|
{
|
|
Id = id,
|
|
Name = displayName,
|
|
Description = desc,
|
|
FileName = fileName,
|
|
FilePath = filePath,
|
|
IsGameSpecific = isSpecific,
|
|
TargetGameKey = targetKey,
|
|
GroupName = groupName,
|
|
DefaultEnabled = defEnabled
|
|
};
|
|
}
|
|
|
|
private static string GetFriendlyName(string id, string desc)
|
|
{
|
|
return id switch
|
|
{
|
|
"BattleSpeedUp" => "戦闘高速化 (ウェイト削除・アニメ早送り)",
|
|
"DashSpeedUp" => "ダッシュ高速化 (移動速度+2)",
|
|
"ItemNoConsume" => "アイテム消費無効 (何度でも使用可能)",
|
|
"ShopMaxBuy" => "ショップ初期個数最大 (購入初期値をMAXに)",
|
|
"ItemGainMax" => "アイテム入手時MAX (所持数最大99個)",
|
|
"BattleTurnRecoverHp" => "ターン開始時HP全回復 (味方HP全快)",
|
|
"BattleTurnRecoverMp" => "ターン開始時MP全回復 (味方MP全快)",
|
|
"BattleTurnRecoverTp" => "ターン開始時TP全回復 (味方TP全快)",
|
|
"BattleTurnRecover" => "ターン開始時全回復 (HP/MP/TP全快)",
|
|
"GoldGainMax" => "所持金増減時MAX (9999999G)",
|
|
"ExpGainMax" => "経験値獲得時MAX (一気にLv99)",
|
|
"MessageInstant" => "メッセージ瞬間表示 (ウェイトスキップ)",
|
|
"AlwaysMaxHp" => "HP常時MAX (プリンセスシナジー専用)",
|
|
"AlwaysMaxMp" => "MP常時MAX (プリンセスシナジー専用)",
|
|
_ => !string.IsNullOrEmpty(desc) ? $"{id} ({desc})" : id
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ゲームごとのプラグイン有効/無効設定アイテム(UIバインド用)
|
|
/// </summary>
|
|
public class ModPluginOptionItem : INotifyPropertyChanged
|
|
{
|
|
private bool _isEnabled = true;
|
|
|
|
public ModPluginDefinition Definition { get; set; } = null!;
|
|
public string Id => this.Definition.Id;
|
|
public string Name => this.Definition.Name;
|
|
public string Description => this.Definition.Description;
|
|
public string GroupName => this.Definition.GroupName;
|
|
public bool IsGameSpecific => this.Definition.IsGameSpecific;
|
|
|
|
public bool IsEnabled
|
|
{
|
|
get => _isEnabled;
|
|
set
|
|
{
|
|
if (_isEnabled != value)
|
|
{
|
|
_isEnabled = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
protected void OnPropertyChanged([CallerMemberName] string? name = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
}
|
|
}
|
|
}
|