Check Steam ownership of the paid app with BIsSubscribedApp; keep Debug fake ownership out of Release. Ref: https://partner.steamgames.com/doc/api/ISteamApps#BIsSubscribedApp
70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using ytLive.Helpers;
|
|
using ytLive.Services.Entitlement;
|
|
|
|
namespace ytLive.ViewModels;
|
|
|
|
/// <summary>
|
|
/// The app-wide Steam ownership flag and its output-profile consumer.
|
|
///
|
|
/// <para>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.</para>
|
|
/// </summary>
|
|
public partial class MainViewModel
|
|
{
|
|
private IEntitlement _entitlement = CreateEntitlement();
|
|
private bool _isAppOwned;
|
|
|
|
public bool IsAppOwned
|
|
{
|
|
get => _isAppOwned;
|
|
private set
|
|
{
|
|
if (!SetProperty(ref _isAppOwned, value)) return;
|
|
OnPropertyChanged(nameof(HasProOutput));
|
|
}
|
|
}
|
|
|
|
public bool HasProOutput => DeveloperMode || IsAppOwned;
|
|
|
|
private static IEntitlement CreateEntitlement()
|
|
{
|
|
#if DEBUG
|
|
return new FakeEntitlement(true);
|
|
#else
|
|
return SteamEntitlement.NotConfigured();
|
|
#endif
|
|
}
|
|
|
|
/// <summary>Test seam: swap the ownership source without a Steam client.</summary>
|
|
internal IEntitlement EntitlementOverride
|
|
{
|
|
get => _entitlement;
|
|
set
|
|
{
|
|
_entitlement = value;
|
|
IsAppOwned = value.IsAppOwned;
|
|
}
|
|
}
|
|
|
|
private bool _developerMode;
|
|
|
|
/// <summary>
|
|
/// Development-only override: ignore the output budget and allow every shipped tier.
|
|
///
|
|
/// <para>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 <see cref="DevBuild.IsDevelopment"/> is true, so even a hand-edited settings
|
|
/// file cannot unlock it.</para>
|
|
/// </summary>
|
|
public bool DeveloperMode
|
|
{
|
|
get => _developerMode;
|
|
set
|
|
{
|
|
if (!DevBuild.IsDevelopment) return;
|
|
if (!SetProperty(ref _developerMode, value)) return;
|
|
OnPropertyChanged(nameof(HasProOutput));
|
|
}
|
|
}
|
|
}
|