using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Media;
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;
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 abstract GameEngineKind EngineKind { get; }
public bool IsTkoolOrTyrano => EngineKind is GameEngineKind.Tkool or GameEngineKind.Tyrano;
public bool IsUnity => EngineKind == GameEngineKind.Unity;
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;
/// RGSSアーカイブ(rgss3a/rgss2a等)を持つか
public virtual bool HasRgssArchive
{
get => false;
set { }
}
/// RGSSアーカイブが抽出済み(Scripts.rvdata/rvdata2が存在)か
public virtual bool IsRgssExtracted
{
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;
/// 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 { }
}
}
}