using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Media; using GameLauncher.Engines.Tkool; using GameLauncher.Engines.Unity; namespace GameLauncher.Models { /// /// すべてのゲームアイテムの共通基底クラス /// public abstract class GameItemBase : INotifyPropertyChanged { private static readonly ObservableCollection _emptyPluginOptions = []; private string _title = string.Empty; private string _folderName = string.Empty; private string _rootDirectory = string.Empty; private string _executablePath = string.Empty; private ImageSource? _iconImage; private DateTime? _lastLaunched; private DateTime? _folderLastModified; private bool _isBookmarked; public event PropertyChangedEventHandler? PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } /// ゲームの表示タイトル public string Title { get => _title; set { if (_title != value) { _title = value; OnPropertyChanged(); } } } /// フォルダ名 public string FolderName { get => _folderName; set { if (_folderName != value) { _folderName = value; OnPropertyChanged(); } } } /// ゲームのルートディレクトリ絶対パス public string RootDirectory { get => _rootDirectory; set { if (_rootDirectory != value) { _rootDirectory = value; OnPropertyChanged(); } } } /// ゲームの実行ファイル(.exe等)絶対パス public string ExecutablePath { get => _executablePath; set { if (_executablePath != value) { _executablePath = value; OnPropertyChanged(); } } } /// アプリアイコン画像 public ImageSource? IconImage { get => _iconImage; set { if (_iconImage != value) { _iconImage = value; OnPropertyChanged(); } } } /// ランチャーからの最終起動日時 public DateTime? LastLaunched { get => _lastLaunched; set { if (_lastLaunched != value) { _lastLaunched = value; OnPropertyChanged(); OnPropertyChanged(nameof(LastLaunchedDisplay)); OnPropertyChanged(nameof(LastLaunchedCardDisplay)); OnPropertyChanged(nameof(LastLaunchedDetailDisplay)); } } } /// フォルダ更新日時 public DateTime? FolderLastModified { get => _folderLastModified; set { if (_folderLastModified != value) { _folderLastModified = value; OnPropertyChanged(); OnPropertyChanged(nameof(FolderLastModifiedDisplay)); OnPropertyChanged(nameof(FolderLastModifiedCardDisplay)); OnPropertyChanged(nameof(FolderLastModifiedDetailDisplay)); } } } /// ユーザーによるブックマーク登録状態 public bool IsBookmarked { get => this._isBookmarked; set { if (this._isBookmarked != value) { this._isBookmarked = value; this.OnPropertyChanged(); this.OnPropertyChanged(nameof(this.BookmarkIcon)); this.OnPropertyChanged(nameof(this.BookmarkTooltip)); this.OnPropertyChanged(nameof(this.BookmarkButtonText)); this.OnPropertyChanged(nameof(this.BookmarkBrush)); } } } public string BookmarkIcon => this._isBookmarked ? "★" : "☆"; public string BookmarkTooltip => this._isBookmarked ? "ブックマーク解除" : "ブックマークに追加"; public string BookmarkButtonText => this._isBookmarked ? "★ ブックマーク中" : "☆ ブックマーク"; public Brush BookmarkBrush => this._isBookmarked ? new SolidColorBrush(Color.FromRgb(0xFD, 0xCB, 0x6E)) : new SolidColorBrush(Color.FromArgb(0x88, 0xAA, 0xAA, 0xBB)); /// ゲームエンジンの種別 public abstract GameEngineKind EngineKind { get; } public bool IsTkoolOrTyrano => EngineKind is GameEngineKind.Tkool or GameEngineKind.Tyrano; public bool IsUnity => EngineKind == GameEngineKind.Unity; /// Enigma Virtual Box でパックされたゲームか public virtual bool IsEvb => false; public string LastLaunchedDisplay => LastLaunched.HasValue ? LastLaunched.Value.ToString("yyyy/MM/dd HH:mm") : "未起動"; public string LastLaunchedCardDisplay => LastLaunched.HasValue ? $"▶ {LastLaunched.Value:yy/MM/dd HH:mm}" : "▶ 未起動"; public string LastLaunchedDetailDisplay => LastLaunched.HasValue ? LastLaunched.Value.ToString("yyyy/MM/dd HH:mm:ss") : "まだ起動されていません"; public string FolderLastModifiedDisplay => FolderLastModified.HasValue ? FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm") : "-"; public string FolderLastModifiedCardDisplay => FolderLastModified.HasValue ? $"📁 {FolderLastModified.Value:yy/MM/dd HH:mm}" : "📁 -"; public string FolderLastModifiedDetailDisplay => FolderLastModified.HasValue ? FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm:ss") : "不明"; // ================= バッジ・UIバインディング共通仮想プロパティ ================= /// ツクールMVか public virtual bool IsMV => false; /// ツクールMZか public virtual bool IsMZ => false; /// ツクールVXか public virtual bool IsVX => false; /// ツクールVX Aceか public virtual bool IsVXAce => false; /// RGSS系(VX / VX Ace)か public virtual bool IsRgss => false; /// ティラノスクリプトか public virtual bool IsTyrano => false; /// WOLF RPGエディター(ウディタ)か public virtual bool IsWolf => false; /// SRPG Studioか public virtual bool IsSrpgStudio => false; /// NW.js汎用ゲームか public virtual bool IsNwjs => false; /// プリンセスシナジー(専用改造対象のMZゲーム)か public virtual bool IsPrincessSynergy => false; /// RGSSアーカイブ(rgss3a/rgss2a等)を持つか public virtual bool HasRgssArchive { get => false; set { } } /// RGSSアーカイブが抽出済み(Scripts.rvdata/rvdata2が存在)か public virtual bool IsRgssExtracted { get => false; set { } } /// Wolfアーカイブ(Data.wolf等)を持つか public virtual bool HasWolfArchive { get => false; set { } } /// Wolfアーカイブが解凍済み(Dataフォルダが存在)か public virtual bool IsWolfExtracted { get => false; set { } } /// SRPG Studioアーカイブ(data.dts)を持つか public virtual bool HasSrpgArchive { get => false; set { } } /// SRPG Studioアーカイブが解凍済み(data_extracted等が存在)か public virtual bool IsSrpgExtracted { get => false; set { } } /// RGSSバッジのテキスト public virtual string RgssBadgeText => string.Empty; /// RGSSバッジの背景色 public virtual Brush RgssBadgeBackground => Brushes.Transparent; /// RGSSバッジの可視性 public virtual Visibility RgssBadgeVisibility => Visibility.Collapsed; /// RGSS詳細状態テキスト public virtual string RgssDetailStatusText => string.Empty; /// SRPG Studioバッジのテキスト public virtual string SrpgBadgeText => string.Empty; /// SRPG Studioバッジの背景色 public virtual Brush SrpgBadgeBackground => Brushes.Transparent; /// SRPG Studioバッジの可視性 public virtual Visibility SrpgBadgeVisibility => Visibility.Collapsed; /// SRPG Studio詳細状態テキスト public virtual string SrpgDetailStatusText => string.Empty; /// NW.jsバッジのテキスト public virtual string NwjsBadgeText => string.Empty; /// NW.jsバッジの背景色 public virtual Brush NwjsBadgeBackground => Brushes.Transparent; /// NW.jsバッジの可視性 public virtual Visibility NwjsBadgeVisibility => Visibility.Collapsed; /// NW.js詳細状態テキスト public virtual string NwjsDetailStatusText => string.Empty; /// Unity IL2CPPか public virtual bool IsIL2CPP => false; /// Unity Monoか public virtual bool IsMono => false; /// Unity バックエンドバッジテキスト public virtual string BackendBadgeText => string.Empty; /// Unity バージョン public virtual string UnityVersion { get => string.Empty; set { } } /// Unity レジストリパス (HKCU) public virtual string RegistryPath => string.Empty; /// Unity LocalLowパス public virtual string LocalLowPath => string.Empty; /// Unity セーブデータ検出フラグ public virtual bool HasSaveData { get => false; set { } } /// ASARパッケージ形式か public virtual bool IsAsar { get => false; set { } } /// ASAR解凍済みか public virtual bool IsAsarExtracted { get => false; set { } } /// ASARバッジのテキスト public virtual string AsarBadgeText => string.Empty; /// ASARバッジの背景色 public virtual Brush AsarBadgeBackground => Brushes.Transparent; /// ASARバッジの可視性 public virtual Visibility AsarBadgeVisibility => Visibility.Collapsed; /// ASAR詳細状態テキスト public virtual string AsarDetailStatusText => string.Empty; /// 改造適用中か public virtual bool IsModded { get => false; set { } } /// 改造適用フラグ public virtual bool ApplyMod { get => false; set { } } /// プラグイン設定項目リスト public virtual ObservableCollection PluginOptions { get => _emptyPluginOptions; set { } } } }