Files
GameLauncher/Models/LauncherConfig.cs
T

106 lines
4.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections;
using System.Collections.Generic;
namespace GameLauncher.Models
{
/// <summary>
/// アプリケーション設定DTO
/// </summary>
public class LauncherConfig
{
public GameSortOrder SortOrder { get; set; } = GameSortOrder.LastLaunchedDesc;
/// <summary>選択中のメインタブ (0: すべて, 1: ツクール・ティラノ, 2: Unity)</summary>
public int SelectedTab { get; set; } = 0;
/// <summary>一度も変更していないゲームにおける「起動時に改造を適用する」の初期値</summary>
public bool DefaultApplyMod { get; set; } = true;
/// <summary>一度も変更していないゲームにおける各改造プラグインの個別有効/無効の初期値</summary>
public Dictionary<string, bool> DefaultPluginSettings { get; set; } = new(StringComparer.OrdinalIgnoreCase);
/// <summary>追加のスキャン対象ルートディレクトリ一覧</summary>
public List<string> TargetDirectories { get; set; } = [];
/// <summary>RGSS Extractor の実行ファイルパス(ツクールVX/VX Ace暗号化アーカイブ展開用)</summary>
public string RgssExtractorPath { get; set; } = @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
/// <summary>Wolf RPG アーカイブ解凍ツールの実行ファイルパス(UberWolfCli.exe / WolfDec.exe など)</summary>
public string WolfExtractorPath { get; set; } = string.Empty;
// フィルター状態の保存(再起動時復元用)
public string TkoolEngineFilter { get; set; } = "All";
public bool TkoolFilterModdedOnly { get; set; }
public bool TkoolFilterAsarOnly { get; set; }
public bool TkoolFilterRgssOnly { get; set; }
public bool TkoolFilterAllRgss { get; set; }
public string UnityBackendFilter { get; set; } = "All";
public bool UnityFilterSaveOnly { get; set; }
}
/// <summary>
/// ゲーム一覧のソート用カスタムComparer(GameItemBase全般に対応)
/// </summary>
public class GameItemComparer : IComparer
{
public GameSortOrder SortOrder { get; set; } = GameSortOrder.LastLaunchedDesc;
public int Compare(object? x, object? y)
{
if (x is not GameItemBase a || y is not GameItemBase b)
return 0;
return SortOrder switch
{
GameSortOrder.LastLaunchedDesc => CompareNullableDateTimeDesc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
GameSortOrder.LastLaunchedAsc => CompareNullableDateTimeAsc(a.LastLaunched, b.LastLaunched, a.Title, b.Title),
GameSortOrder.FolderLastModifiedDesc => CompareNullableDateTimeDesc(a.FolderLastModified, b.FolderLastModified, a.Title, b.Title),
GameSortOrder.FolderLastModifiedAsc => CompareNullableDateTimeAsc(a.FolderLastModified, b.FolderLastModified, a.Title, b.Title),
GameSortOrder.TitleAsc => string.Compare(a.Title, b.Title, StringComparison.CurrentCultureIgnoreCase),
GameSortOrder.TitleDesc => string.Compare(b.Title, a.Title, StringComparison.CurrentCultureIgnoreCase),
GameSortOrder.FolderNameAsc => string.Compare(a.FolderName, b.FolderName, StringComparison.CurrentCultureIgnoreCase),
_ => string.Compare(a.Title, b.Title, StringComparison.CurrentCultureIgnoreCase)
};
}
private static int CompareNullableDateTimeDesc(DateTime? d1, DateTime? d2, string title1, string title2)
{
if (d1.HasValue && d2.HasValue)
{
int cmp = d2.Value.CompareTo(d1.Value);
if (cmp != 0) return cmp;
}
else if (d1.HasValue)
{
return -1; // 値がある方を上に
}
else if (d2.HasValue)
{
return 1;
}
return string.Compare(title1, title2, StringComparison.CurrentCultureIgnoreCase);
}
private static int CompareNullableDateTimeAsc(DateTime? d1, DateTime? d2, string title1, string title2)
{
if (d1.HasValue && d2.HasValue)
{
int cmp = d1.Value.CompareTo(d2.Value);
if (cmp != 0) return cmp;
}
else if (d1.HasValue)
{
return -1;
}
else if (d2.HasValue)
{
return 1;
}
return string.Compare(title1, title2, StringComparison.CurrentCultureIgnoreCase);
}
}
}