LANCommander/LANCommander.Launcher.Avalonia/ViewModels/InstallOptionsViewModel.cs
Pat Hartl 81a6a3a0fc Rework views / interactions
- Added a horizontal and list view for depot/library
- Games only show covers (with fallback cover)
- Added install addon / directory select dialog
- Fixed download queue
- Added footer somewhat matching Blazor launcher
- Temporarily removed sidebar
- Implemented custom window chrome
- Added profile button
- Reworked game details to better match Blazor launcher
- Added grouping by genre, collection, or first letter
2026-03-27 18:59:17 -04:00

57 lines
2.1 KiB
C#

using System.Collections.ObjectModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using LANCommander.SDK.Enums;
namespace LANCommander.Launcher.Avalonia.ViewModels;
public partial class InstallOptionsViewModel : ViewModelBase
{
// ── Install directory ──────────────────────────────────────────────────────
[ObservableProperty]
private ObservableCollection<string> _installDirectories = new();
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasMultipleDirectories))]
private string _selectedInstallDirectory = string.Empty;
public bool HasMultipleDirectories => InstallDirectories.Count > 1;
// ── Addons ────────────────────────────────────────────────────────────────
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasAddons))]
private ObservableCollection<InstallAddonItemViewModel> _addons = new();
public bool HasAddons => Addons.Count > 0;
// ── Result ────────────────────────────────────────────────────────────────
/// <summary>The addons the user chose to install.</summary>
public SDK.Models.Game[] SelectedAddons =>
Addons.Where(a => a.IsSelected).Select(a => a.Game).ToArray();
}
public partial class InstallAddonItemViewModel : ViewModelBase
{
public SDK.Models.Game Game { get; }
public string Title => Game.Title ?? "Unknown";
public string TypeLabel => Game.Type switch
{
GameType.Expansion => "Expansion",
GameType.Mod => "Mod",
_ => Game.Type.ToString()
};
[ObservableProperty]
private bool _isSelected;
public InstallAddonItemViewModel(SDK.Models.Game game, bool selectedByDefault = false)
{
Game = game;
IsSelected = selectedByDefault;
}
}