- 自インスタンスメンバーアクセスへの this. 付与(28ファイル) - .editorconfig に準拠したインデント・波括弧・空白スタイルの適用 - UTF-8 (BOMあり)、CRLF改行コード、行末空白除去の整合性検証
141 lines
5.0 KiB
C#
141 lines
5.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using GameLauncher.Models;
|
|
|
|
namespace GameLauncher.Engines.Unity
|
|
{
|
|
/// <summary>
|
|
/// Unityゲームのデータモデル
|
|
/// </summary>
|
|
public class UnityGameItem : GameItemBase
|
|
{
|
|
private string _dataDirectoryPath = string.Empty;
|
|
private string _companyName = string.Empty;
|
|
private string _productName = string.Empty;
|
|
private UnityBackendType _backendType = UnityBackendType.Unknown;
|
|
private string _unityVersion = string.Empty;
|
|
private bool _hasSaveData;
|
|
|
|
public override GameEngineKind EngineKind => GameEngineKind.Unity;
|
|
|
|
/// <summary>[Game]_Data ディレクトリ絶対パス</summary>
|
|
public string DataDirectoryPath
|
|
{
|
|
get => this._dataDirectoryPath;
|
|
set { if (this._dataDirectoryPath != value) { this._dataDirectoryPath = value; this.OnPropertyChanged(); } }
|
|
}
|
|
|
|
/// <summary>app.info 由来の会社名/開発者名</summary>
|
|
public string CompanyName
|
|
{
|
|
get => this._companyName;
|
|
set
|
|
{
|
|
if (this._companyName != value)
|
|
{
|
|
this._companyName = value;
|
|
this.OnPropertyChanged();
|
|
this.OnPropertyChanged(nameof(this.RegistryPath));
|
|
this.OnPropertyChanged(nameof(this.LocalLowPath));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>app.info 由来の製品名</summary>
|
|
public string ProductName
|
|
{
|
|
get => this._productName;
|
|
set
|
|
{
|
|
if (this._productName != value)
|
|
{
|
|
this._productName = value;
|
|
this.OnPropertyChanged();
|
|
this.OnPropertyChanged(nameof(this.RegistryPath));
|
|
this.OnPropertyChanged(nameof(this.LocalLowPath));
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool IsIL2CPP => this.BackendType == UnityBackendType.IL2CPP;
|
|
public override bool IsMono => this.BackendType == UnityBackendType.Mono;
|
|
|
|
/// <summary>バックエンド形式 (IL2CPP / Mono)</summary>
|
|
public UnityBackendType BackendType
|
|
{
|
|
get => this._backendType;
|
|
set
|
|
{
|
|
if (this._backendType != value)
|
|
{
|
|
this._backendType = value;
|
|
this.OnPropertyChanged();
|
|
this.OnPropertyChanged(nameof(this.BackendBadgeText));
|
|
this.OnPropertyChanged(nameof(this.IsIL2CPP));
|
|
this.OnPropertyChanged(nameof(this.IsMono));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>Unityバージョン文字列</summary>
|
|
public override string UnityVersion
|
|
{
|
|
get => this._unityVersion;
|
|
set { if (this._unityVersion != value) { this._unityVersion = value; this.OnPropertyChanged(); } }
|
|
}
|
|
|
|
/// <summary>セーブデータ(レジストリまたはファイル)が検出されたかどうか</summary>
|
|
public override bool HasSaveData
|
|
{
|
|
get => this._hasSaveData;
|
|
set { if (this._hasSaveData != value) { this._hasSaveData = value; this.OnPropertyChanged(); } }
|
|
}
|
|
|
|
/// <summary>
|
|
/// レジストリ (PlayerPrefs) のキーパス
|
|
/// HKCU\Software\[CompanyName]\[ProductName]
|
|
/// </summary>
|
|
public override string RegistryPath
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrEmpty(this.CompanyName) || string.IsNullOrEmpty(this.ProductName))
|
|
return string.Empty;
|
|
return $@"Software\{this.CompanyName}\{this.ProductName}";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// LocalLow のセーブデータ保存ディレクトリ
|
|
/// %USERPROFILE%\AppData\LocalLow\[CompanyName]\[ProductName]
|
|
/// </summary>
|
|
public override string LocalLowPath
|
|
{
|
|
get
|
|
{
|
|
if (string.IsNullOrEmpty(this.CompanyName) || string.IsNullOrEmpty(this.ProductName))
|
|
return string.Empty;
|
|
|
|
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
var appData = Path.GetDirectoryName(localAppData);
|
|
if (string.IsNullOrEmpty(appData)) return string.Empty;
|
|
|
|
return Path.Combine(appData, "LocalLow", this.CompanyName, this.ProductName);
|
|
}
|
|
}
|
|
|
|
public override string BackendBadgeText => this.BackendType switch
|
|
{
|
|
UnityBackendType.IL2CPP => "IL2CPP",
|
|
UnityBackendType.Mono => "Mono",
|
|
_ => "Unity"
|
|
};
|
|
|
|
/// <summary>
|
|
/// エンジン種別ラベル。Unityは専用バッジ(IL2CPP/Mono等)で表現するため空文字を返し、
|
|
/// エンジン種別ラベル自体は表示しません。
|
|
/// </summary>
|
|
public override string EngineLabelText => string.Empty;
|
|
}
|
|
}
|