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 => this._title;
set { if (this._title != value) { this._title = value; this.OnPropertyChanged(); } }
}
/// フォルダ名
public string FolderName
{
get => this._folderName;
set { if (this._folderName != value) { this._folderName = value; this.OnPropertyChanged(); } }
}
/// ゲームのルートディレクトリ絶対パス
public string RootDirectory
{
get => this._rootDirectory;
set { if (this._rootDirectory != value) { this._rootDirectory = value; this.OnPropertyChanged(); } }
}
/// ゲームの実行ファイル(.exe等)絶対パス
public string ExecutablePath
{
get => this._executablePath;
set { if (this._executablePath != value) { this._executablePath = value; this.OnPropertyChanged(); } }
}
/// アプリアイコン画像
public ImageSource? IconImage
{
get => this._iconImage;
set { if (this._iconImage != value) { this._iconImage = value; this.OnPropertyChanged(); } }
}
/// ランチャーからの最終起動日時
public DateTime? LastLaunched
{
get => this._lastLaunched;
set
{
if (this._lastLaunched != value)
{
this._lastLaunched = value;
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.LastLaunchedDisplay));
this.OnPropertyChanged(nameof(this.LastLaunchedCardDisplay));
this.OnPropertyChanged(nameof(this.LastLaunchedDetailDisplay));
}
}
}
/// フォルダ更新日時
public DateTime? FolderLastModified
{
get => this._folderLastModified;
set
{
if (this._folderLastModified != value)
{
this._folderLastModified = value;
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.FolderLastModifiedDisplay));
this.OnPropertyChanged(nameof(this.FolderLastModifiedCardDisplay));
this.OnPropertyChanged(nameof(this.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 => this.EngineKind is GameEngineKind.Tkool or GameEngineKind.Tyrano;
public bool IsUnity => this.EngineKind == GameEngineKind.Unity;
/// Enigma Virtual Box でパックされたゲームか
public virtual bool IsEvb => false;
/// Enigma Virtual Box でパックされた exe を持つゲームかどうか
public virtual bool IsEvbPacked
{
get => false;
set { }
}
/// EVB 解凍済みかどうか
public virtual bool IsEvbExtracted
{
get => false;
set { }
}
/// EVB バッジの可視性(該当しなければ Collapsed)
public virtual Visibility EvbBadgeVisibility => Visibility.Collapsed;
/// EVB バッジのテキスト(該当しなければ空文字)
public virtual string EvbBadgeText => string.Empty;
/// EVB 要解凍バッジの可視性(該当しなければ Collapsed)
public virtual Visibility EvbNeedsUnpackVisibility => Visibility.Collapsed;
/// EVB 要解凍バッジのテキスト(該当しなければ空文字)
public virtual string EvbNeedsUnpackBadgeText => string.Empty;
/// EVB 解凍済みバッジの可視性(該当しなければ Collapsed)
public virtual Visibility EvbExtractedVisibility => Visibility.Collapsed;
/// EVB 解凍済みバッジのテキスト(該当しなければ空文字)
public virtual string EvbExtractedBadgeText => string.Empty;
/// EVB 詳細状態テキスト
public virtual string EvbDetailStatusText => string.Empty;
public string LastLaunchedDisplay => this.LastLaunched.HasValue
? this.LastLaunched.Value.ToString("yyyy/MM/dd HH:mm")
: "未起動";
public string LastLaunchedCardDisplay => this.LastLaunched.HasValue
? $"▶ {this.LastLaunched.Value:yy/MM/dd HH:mm}"
: "▶ 未起動";
public string LastLaunchedDetailDisplay => this.LastLaunched.HasValue
? this.LastLaunched.Value.ToString("yyyy/MM/dd HH:mm:ss")
: "まだ起動されていません";
public string FolderLastModifiedDisplay => this.FolderLastModified.HasValue
? this.FolderLastModified.Value.ToString("yyyy/MM/dd HH:mm")
: "-";
public string FolderLastModifiedCardDisplay => this.FolderLastModified.HasValue
? $"📁 {this.FolderLastModified.Value:yy/MM/dd HH:mm}"
: "📁 -";
public string FolderLastModifiedDetailDisplay => this.FolderLastModified.HasValue
? this.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;
/// その他のゲームエンジンか
public virtual bool IsOther => false;
///
/// エンジン種別ラベルの表示文字列。空文字の場合はラベル自体を表示しません。
/// (Unity等は該当しないため空、ツクール系は MV/MZ 等を返す)
///
public virtual string EngineLabelText => string.Empty;
/// エンジン種別ラベルの背景色
public virtual Brush EngineLabelBackground => Brushes.Transparent;
/// その他バッジの可視性(該当しなければ Collapsed)
public virtual Visibility OtherBadgeVisibility => Visibility.Collapsed;
/// プリンセスシナジー(専用改造対象の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 { }
}
/// ウディタアーカイブバッジのテキスト(該当しなければ空文字)
public virtual string WolfArchiveBadgeText => string.Empty;
/// ウディタアーカイブバッジの背景色
public virtual Brush WolfArchiveBadgeBackground => Brushes.Transparent;
/// ウディタアーカイブバッジの可視性(該当しなければ Collapsed)
public virtual Visibility WolfArchiveBadgeVisibility => Visibility.Collapsed;
/// ウディタアーカイブ詳細状態テキスト
public virtual string WolfArchiveDetailStatusText => string.Empty;
/// 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 { }
}
/// 共通プラグイン設定コレクション
public virtual ObservableCollection CommonPluginOptions
{
get => _emptyPluginOptions;
set { }
}
/// 固有ゲーム専用プラグイン設定コレクション
public virtual ObservableCollection SpecificPluginOptions
{
get => _emptyPluginOptions;
set { }
}
/// 固有ゲーム専用プラグインが存在するかどうか
public virtual bool HasSpecificPlugins => false;
/// プリンセスシナジー専用: HP常時MAX
public virtual bool PrincessAlwaysMaxHp
{
get => false;
set { }
}
/// プリンセスシナジー専用: MP常時MAX
public virtual bool PrincessAlwaysMaxMp
{
get => false;
set { }
}
/// ウディタ プロキシDLL適用フラグ
public virtual bool WolfProxyDll
{
get => false;
set { }
}
/// SRPG Studio プロキシDLL適用フラグ
public virtual bool SrpgProxyDll
{
get => false;
set { }
}
///
/// スクリプト改造(プラグイン注入など)が適用可能な状態かどうか。
/// 該当ゲームが改造非対応(ウディタ・SRPG・NW.js・その他・未解凍状態など)の場合は false を返し、
/// 右側パネルのスクリプト改造項目を非表示にします。
///
public virtual bool CanApplyScriptMod => false;
}
}