using ytLive.Helpers; using ytLive.Models; using ytLive.Services.Entitlement; namespace ytLive.ViewModels; /// /// The app-wide Steam ownership flag and its output-profile consumer. /// /// Only the entitlement service decides whether the current Steam account owns the paid app. /// Development builds use a fake owned result; Release builds use Steam. /// public partial class MainViewModel { private IEntitlement _entitlement = CreateEntitlement(); private bool _isAppOwned; private string? _entitlementErrorMessage; public bool IsAppOwned { get => _isAppOwned; private set { var changed = SetProperty(ref _isAppOwned, value); EntitlementErrorMessage = _entitlement.ErrorMessage; if (!changed) return; OnPropertyChanged(nameof(HasProOutput)); RefreshSteamLicenceAlert(); if (!HasProOutput && _selectedQuality is { RequiresPro: true } && CanChangeQuality) SelectedQuality = QualityOptions.Single(option => option.Display == OutputProfile.FreeFallbackName); } } public string? EntitlementErrorMessage { get => _entitlementErrorMessage; private set => SetProperty(ref _entitlementErrorMessage, value); } public bool HasProOutput => DeveloperMode || IsAppOwned; private static IEntitlement CreateEntitlement() { #if DEBUG return new FakeEntitlement(true); #else return SteamEntitlement.NotConfigured(); #endif } /// Test seam: swap the ownership source without a Steam client. internal IEntitlement EntitlementOverride { get => _entitlement; set { _entitlement = value; IsAppOwned = value.IsAppOwned; EntitlementErrorMessage = value.ErrorMessage; } } private bool _developerMode; /// /// Development-only override: ignore the output budget and allow every shipped tier. /// /// There is no UI to reach this in a Release build — the panel that hosts the /// checkbox is excluded from the Release compile — and the setter refuses the value /// unless is true, so even a hand-edited settings /// file cannot unlock it. /// public bool DeveloperMode { get => _developerMode; set { if (!DevBuild.IsDevelopment) return; if (!SetProperty(ref _developerMode, value)) return; OnPropertyChanged(nameof(HasProOutput)); RefreshSteamLicenceAlert(); } } }