using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Media;
namespace GameLauncher.Models
{
///
/// 各プラグイン改造の個別有効/無効オプション(互換用)
///
public class ModPluginOptions : System.ComponentModel.INotifyPropertyChanged
{
private bool _speedUp = true;
private bool _antigravityGameTweaks = true;
private bool _dropItem99 = true;
private bool _turnStartFullRecover = true;
private bool _turnStartFullRecoverHp = true;
private bool _turnStartFullRecoverMp = true;
private bool _turnStartFullRecoverTp = true;
private bool _maxGainGold = true;
private bool _maxGainExp = true;
private bool _instantMessage = true;
public bool SpeedUp
{
get => _speedUp;
set { if (_speedUp != value) { _speedUp = value; OnPropertyChanged(); } }
}
public bool AntigravityGameTweaks
{
get => _antigravityGameTweaks;
set { if (_antigravityGameTweaks != value) { _antigravityGameTweaks = value; OnPropertyChanged(); } }
}
public bool DropItem99
{
get => _dropItem99;
set { if (_dropItem99 != value) { _dropItem99 = value; OnPropertyChanged(); } }
}
public bool TurnStartFullRecover
{
get => _turnStartFullRecover;
set { if (_turnStartFullRecover != value) { _turnStartFullRecover = value; OnPropertyChanged(); } }
}
public bool TurnStartFullRecoverHp
{
get => _turnStartFullRecoverHp;
set { if (_turnStartFullRecoverHp != value) { _turnStartFullRecoverHp = value; OnPropertyChanged(); } }
}
public bool TurnStartFullRecoverMp
{
get => _turnStartFullRecoverMp;
set { if (_turnStartFullRecoverMp != value) { _turnStartFullRecoverMp = value; OnPropertyChanged(); } }
}
public bool TurnStartFullRecoverTp
{
get => _turnStartFullRecoverTp;
set { if (_turnStartFullRecoverTp != value) { _turnStartFullRecoverTp = value; OnPropertyChanged(); } }
}
public bool MaxGainGold
{
get => _maxGainGold;
set { if (_maxGainGold != value) { _maxGainGold = value; OnPropertyChanged(); } }
}
public bool MaxGainExp
{
get => _maxGainExp;
set { if (_maxGainExp != value) { _maxGainExp = value; OnPropertyChanged(); } }
}
public bool InstantMessage
{
get => _instantMessage;
set { if (_instantMessage != value) { _instantMessage = value; OnPropertyChanged(); } }
}
public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged;
protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string? name = null)
{
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(name));
}
}
///
/// ツクールおよびティラノスクリプトゲームのデータモデル
///
public class TkoolGameItem : GameItemBase
{
private string _pluginsJsPath = string.Empty;
private string _pluginsDirPath = string.Empty;
private TkoolEngineType _engineType = TkoolEngineType.Unknown;
private bool _isModded;
private bool _applyMod = true;
private bool _hasCustomApplyMod;
private bool _isInitializingApplyMod;
private ModPluginOptions _modOptions = new();
// app.asar 関連プロパティ
private bool _isAsar;
private bool _isAsarExtracted;
private string? _asarPath;
private string? _asarExtractedDirPath;
private string? _relativePluginsJsInAsar;
public override GameEngineKind EngineKind => EngineType == TkoolEngineType.Tyrano
? GameEngineKind.Tyrano
: GameEngineKind.Tkool;
public string PluginsJsPath
{
get => _pluginsJsPath;
set { if (_pluginsJsPath != value) { _pluginsJsPath = value; OnPropertyChanged(); } }
}
public string PluginsDirPath
{
get => _pluginsDirPath;
set { if (_pluginsDirPath != value) { _pluginsDirPath = value; OnPropertyChanged(); } }
}
public override bool IsMV => EngineType == TkoolEngineType.MV;
public override bool IsMZ => EngineType == TkoolEngineType.MZ;
public override bool IsTyrano => EngineType == TkoolEngineType.Tyrano;
public override bool IsVX => EngineType == TkoolEngineType.VX;
public override bool IsVXAce => EngineType == TkoolEngineType.VXAce;
public override bool IsRgss => EngineType is TkoolEngineType.VX or TkoolEngineType.VXAce;
// RGSS (VX / VX Ace) アーカイブ関連プロパティ
private bool _hasRgssArchive;
private bool _isRgssExtracted;
private string? _rgssArchivePath;
public override bool HasRgssArchive
{
get => _hasRgssArchive;
set
{
if (_hasRgssArchive != value)
{
_hasRgssArchive = value;
OnPropertyChanged();
OnPropertyChanged(nameof(RgssBadgeVisibility));
OnPropertyChanged(nameof(RgssBadgeText));
OnPropertyChanged(nameof(RgssBadgeBackground));
OnPropertyChanged(nameof(RgssDetailStatusText));
}
}
}
public override bool IsRgssExtracted
{
get => _isRgssExtracted;
set
{
if (_isRgssExtracted != value)
{
_isRgssExtracted = value;
OnPropertyChanged();
OnPropertyChanged(nameof(RgssBadgeText));
OnPropertyChanged(nameof(RgssBadgeBackground));
OnPropertyChanged(nameof(RgssDetailStatusText));
}
}
}
public string? RgssArchivePath
{
get => _rgssArchivePath;
set { if (_rgssArchivePath != value) { _rgssArchivePath = value; OnPropertyChanged(); } }
}
public override Visibility RgssBadgeVisibility => HasRgssArchive ? Visibility.Visible : Visibility.Collapsed;
public override string RgssBadgeText => !HasRgssArchive ? string.Empty : (IsRgssExtracted ? "RGSS (抽出済)" : "RGSS (暗号化)");
public override Brush RgssBadgeBackground => IsRgssExtracted
? new SolidColorBrush(Color.FromRgb(0x00, 0x89, 0x7B))
: new SolidColorBrush(Color.FromRgb(0xD3, 0x54, 0x00));
public override string RgssDetailStatusText => !HasRgssArchive
? string.Empty
: (IsRgssExtracted ? "📦 RGSSアーカイブ(スクリプト抽出済み・改造可能)" : "🔒 RGSS暗号化アーカイブ(起動時またはボタンでスクリプト抽出可能)");
public TkoolEngineType EngineType
{
get => _engineType;
set
{
if (_engineType != value)
{
_engineType = value;
OnPropertyChanged();
OnPropertyChanged(nameof(EngineKind));
OnPropertyChanged(nameof(EngineDisplayName));
OnPropertyChanged(nameof(IsMV));
OnPropertyChanged(nameof(IsMZ));
OnPropertyChanged(nameof(IsTyrano));
OnPropertyChanged(nameof(IsVX));
OnPropertyChanged(nameof(IsVXAce));
OnPropertyChanged(nameof(IsRgss));
}
}
}
public override bool IsModded
{
get => _isModded;
set { if (_isModded != value) { _isModded = value; OnPropertyChanged(); } }
}
public bool HasCustomApplyMod
{
get => _hasCustomApplyMod;
set { if (_hasCustomApplyMod != value) { _hasCustomApplyMod = value; OnPropertyChanged(); } }
}
public override bool ApplyMod
{
get => _applyMod;
set
{
if (_applyMod != value)
{
_applyMod = value;
if (!_isInitializingApplyMod)
{
HasCustomApplyMod = true;
}
OnPropertyChanged();
}
}
}
public void SetDefaultApplyMod(bool defaultVal)
{
if (!_hasCustomApplyMod)
{
_isInitializingApplyMod = true;
_applyMod = defaultVal;
_isInitializingApplyMod = false;
OnPropertyChanged(nameof(ApplyMod));
}
}
public override bool IsAsar
{
get => _isAsar;
set
{
if (_isAsar != value)
{
_isAsar = value;
OnPropertyChanged();
OnPropertyChanged(nameof(AsarBadgeVisibility));
OnPropertyChanged(nameof(AsarBadgeText));
OnPropertyChanged(nameof(AsarBadgeBackground));
OnPropertyChanged(nameof(AsarDetailStatusText));
}
}
}
public override bool IsAsarExtracted
{
get => _isAsarExtracted;
set
{
if (_isAsarExtracted != value)
{
_isAsarExtracted = value;
OnPropertyChanged();
OnPropertyChanged(nameof(AsarBadgeText));
OnPropertyChanged(nameof(AsarBadgeBackground));
OnPropertyChanged(nameof(AsarDetailStatusText));
}
}
}
public string? AsarPath
{
get => _asarPath;
set { if (_asarPath != value) { _asarPath = value; OnPropertyChanged(); } }
}
public string? AsarExtractedDirPath
{
get => _asarExtractedDirPath;
set { if (_asarExtractedDirPath != value) { _asarExtractedDirPath = value; OnPropertyChanged(); } }
}
public string? RelativePluginsJsInAsar
{
get => _relativePluginsJsInAsar;
set { if (_relativePluginsJsInAsar != value) { _relativePluginsJsInAsar = value; OnPropertyChanged(); } }
}
public override Visibility AsarBadgeVisibility => IsAsar ? Visibility.Visible : Visibility.Collapsed;
public override string AsarBadgeText => !IsAsar ? string.Empty : (IsAsarExtracted ? "ASAR (解凍済)" : "ASAR (圧縮)");
public override Brush AsarBadgeBackground => IsAsarExtracted
? new SolidColorBrush(Color.FromRgb(0x00, 0x89, 0x7B))
: new SolidColorBrush(Color.FromRgb(0x5E, 0x35, 0xB1));
public override string AsarDetailStatusText => !IsAsar
? string.Empty
: (IsAsarExtracted ? "📦 app.asar 形式(解凍済み・改造可能)" : "📦 app.asar 形式(圧縮中・起動時またはボタンで解凍可能)");
private Dictionary _pluginSettings = new(StringComparer.OrdinalIgnoreCase);
private ObservableCollection _pluginOptions = [];
public Dictionary PluginSettings
{
get => _pluginSettings;
set { if (_pluginSettings != value) { _pluginSettings = value; OnPropertyChanged(); } }
}
public override ObservableCollection PluginOptions
{
get => _pluginOptions;
set { if (_pluginOptions != value) { _pluginOptions = value; OnPropertyChanged(); } }
}
public bool IsPluginEnabled(string pluginId, Dictionary? defaultSettings = null, bool fallbackVal = true)
{
if (_pluginSettings.TryGetValue(pluginId, out var val))
{
return val;
}
if (pluginId is "BattleTurnRecoverHp" or "BattleTurnRecoverMp" or "BattleTurnRecoverTp")
{
if (_pluginSettings.TryGetValue("BattleTurnRecover", out var legacyVal))
{
return legacyVal;
}
}
if (defaultSettings != null && defaultSettings.TryGetValue(pluginId, out var defVal))
{
return defVal;
}
if (pluginId is "BattleTurnRecoverHp" or "BattleTurnRecoverMp" or "BattleTurnRecoverTp")
{
if (defaultSettings != null && defaultSettings.TryGetValue("BattleTurnRecover", out var legacyDefVal))
{
return legacyDefVal;
}
}
return fallbackVal;
}
public static readonly ModPluginDefinition[] DefaultTyranoPlugins =
[
new() { Id = "TyranoUnlockAllCg", Name = "🔓 全CG・全回想の全開放", Description = "システム変数(sf)のCG・回想フラグを全開放し、最初からCG・シーン鑑賞を可能にします。" },
new() { Id = "TyranoFastMessage", Name = "⚡ メッセージ超高速化・演出ウェイト短縮", Description = "文字送り速度を最大化し、[wait]演出の停止時間を短縮して快適にスキップ可能にします。" },
new() { Id = "TyranoDevTools", Name = "🛠 開発者ツール (F12) の有効化", Description = "F12キーでブラウザ・アプリの開発者ツールコンソールを開けるようにします。" },
new() { Id = "TyranoCheatMenu", Name = "🎛 画面上変数(f)チートエディタ表示", Description = "画面右上にボタンを配置し、ゲーム内変数・フラグの閲覧と直接書き換えができるメニューを表示します。" }
];
/// ツクールVX / VX Ace用スクリプト改造定義一覧
public static readonly ModPluginDefinition[] DefaultRgssPlugins =
[
new() { Id = "RgssDashSpeedUp", Name = "⚡ 移動速度高速化&常時オートダッシュ", Description = "キャラクターの移動速度を高速化し、Shiftキーを押さなくても常時ダッシュ状態にします。" },
new() { Id = "RgssItemGainMax", Name = "🎁 アイテム入手時 99個固定化", Description = "宝箱・イベント・戦闘等で通常アイテムを入手した際、入手個数を99個にします。" },
new() { Id = "RgssItemNoConsume", Name = "♾️ アイテム消費なし", Description = "アイテムを使用しても所持個数を減少しないようにします。" },
new() { Id = "RgssGoldGainMax", Name = "💰 獲得ゴールド最大化 (999,999G)", Description = "戦闘勝利時の獲得ゴールドを999,999Gにします。" },
new() { Id = "RgssExpGainMax", Name = "📈 獲得経験値最大化 (999,999Exp)", Description = "戦闘勝利時の獲得経験値を999,999Expにします。" },
new() { Id = "RgssBattleTurnRecoverHp", Name = "💖 ターン開始時 全回復 (HP)", Description = "戦闘中の毎ターン開始時にパーティ全員のHPを全回復します。" },
new() { Id = "RgssBattleTurnRecoverMp", Name = "🔷 ターン開始時 全回復 (MP)", Description = "戦闘中の毎ターン開始時にパーティ全員のMPを全回復します。" },
new() { Id = "RgssBattleTurnRecoverTp", Name = "⚡ ターン開始時 全回復 (TP)", Description = "戦闘中の毎ターン開始時にパーティ全員のTPを最大(100)にします。(VX Ace)" },
new() { Id = "RgssMessageInstant", Name = "⏩ メッセージ瞬間表示・高速スキップ", Description = "会話ウィンドウの文字送りウェイトをカットし、瞬間表示します。" },
new() { Id = "RgssCommandMemory", Name = "🧠 コマンド位置記憶 (ツクールMV風)", Description = "メニュー画面や戦闘中のアクターコマンドのカーソル選択位置を記憶して次回遷移時に復元します。" }
];
public void SyncPluginOptions(IEnumerable availablePlugins, Dictionary? defaultSettings = null)
{
_pluginOptions.Clear();
IEnumerable targetDefs;
if (EngineType == TkoolEngineType.Tyrano)
{
targetDefs = DefaultTyranoPlugins;
}
else if (IsRgss)
{
targetDefs = DefaultRgssPlugins;
}
else
{
targetDefs = availablePlugins;
}
foreach (var def in targetDefs)
{
bool isEnabled = IsPluginEnabled(def.Id, defaultSettings, fallbackVal: true);
var item = new ModPluginOptionItem
{
Definition = def,
IsEnabled = isEnabled
};
item.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(ModPluginOptionItem.IsEnabled))
{
_pluginSettings[def.Id] = item.IsEnabled;
}
};
_pluginOptions.Add(item);
}
}
public ModPluginOptions ModOptions
{
get => _modOptions;
set { if (_modOptions != value) { _modOptions = value; OnPropertyChanged(); } }
}
public string EngineDisplayName => EngineType switch
{
TkoolEngineType.MV => "RPGツクールMV",
TkoolEngineType.MZ => "RPGツクールMZ",
TkoolEngineType.Tyrano => "ティラノスクリプト",
TkoolEngineType.VX => "RPGツクールVX",
TkoolEngineType.VXAce => "RPGツクールVX Ace",
_ => "ツクール/ティラノ"
};
}
}