From 15fc1baba3e64df53b7a689169bb1582a434df9b Mon Sep 17 00:00:00 2001 From: kellydornhaus Date: Sun, 8 Jun 2025 11:39:49 -0700 Subject: [PATCH] Add support for Steam beta branch management APIs Implements GetNumBetas, GetBetaInfo, and SetActiveBeta Steam APIs that were missing from the library. These APIs allow applications to query available beta branches and programmatically switch between them. New APIs added: - SteamApps.GetBetaCount() - Get total number of beta branches with breakdown of available/private counts - SteamApps.GetBetaInfo() - Get detailed information about a specific beta branch by index - SteamApps.GetBetaInformation() - Get enumerable of all available beta branches - SteamApps.SetActiveBeta() - Set the active beta branch for the application Also adds BetaInformation struct with convenient property accessors for beta branch flags (IsDefault, IsAvailable, IsPrivate, IsSelected, IsInstalled). The low-level Steam API bindings were already generated, this change adds the high-level C# wrapper methods following existing code patterns in SteamApps.cs. --- Facepunch.Steamworks/SteamApps.cs | 62 +++++++++++++++++++ .../Structs/BetaInformation.cs | 59 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 Facepunch.Steamworks/Structs/BetaInformation.cs diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index baad5fa87..26934e81d 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -161,6 +161,68 @@ public static string CurrentBetaName } } + /// + /// Gets the total number of known app branches including the default "public" branch. + /// + /// Returns the number of available beta branches. + /// Returns the number of private beta branches. + /// The total number of beta branches. + public static int GetBetaCount( out int availableCount, out int privateCount ) + { + availableCount = 0; + privateCount = 0; + return Internal.GetNumBetas( ref availableCount, ref privateCount ); + } + + /// + /// Gets detailed information about a specific beta branch by index. + /// + /// The index of the beta branch (0-based). + /// Beta branch information, or null if the index is invalid. + public static BetaInformation? GetBetaInfo( int betaIndex ) + { + uint flags = 0; + uint buildId = 0; + + if ( !Internal.GetBetaInfo( betaIndex, ref flags, ref buildId, out var name, out var description ) ) + return null; + + return new BetaInformation + { + Name = name, + Description = description, + BuildId = buildId, + Flags = (BetaBranchFlags)flags + }; + } + + /// + /// Gets information about all available beta branches. + /// + /// An enumerable of beta branch information. + public static IEnumerable GetBetaInformation() + { + int totalCount = GetBetaCount( out var availableCount, out var privateCount ); + + for ( int i = 0; i < totalCount; i++ ) + { + var betaInfo = GetBetaInfo( i ); + if ( betaInfo.HasValue ) + yield return betaInfo.Value; + } + } + + /// + /// Selects the specified beta branch as active for this app. + /// The game may need to restart so Steam can update to that branch. + /// + /// The name of the beta branch to activate. Use null or empty string to select the default "public" branch. + /// True if the beta branch was successfully set as active. + public static bool SetActiveBeta( string betaName ) + { + return Internal.SetActiveBeta( betaName ?? "" ); + } + /// /// Force verify game content on next launch. /// diff --git a/Facepunch.Steamworks/Structs/BetaInformation.cs b/Facepunch.Steamworks/Structs/BetaInformation.cs new file mode 100644 index 000000000..1dc2cdf9e --- /dev/null +++ b/Facepunch.Steamworks/Structs/BetaInformation.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + + +namespace Steamworks.Data +{ + /// + /// Provides information about a beta branch. + /// + public struct BetaInformation + { + /// + /// The name of the beta branch. + /// + public string Name { get; internal set; } + + /// + /// The description of the beta branch. + /// + public string Description { get; internal set; } + + /// + /// The build ID of the beta branch. + /// + public uint BuildId { get; internal set; } + + /// + /// The flags indicating the status of the beta branch. + /// + internal BetaBranchFlags Flags { get; set; } + + /// + /// Whether this is the default branch. + /// + public bool IsDefault => (Flags & BetaBranchFlags.Default) != 0; + + /// + /// Whether this beta branch is available for selection. + /// + public bool IsAvailable => (Flags & BetaBranchFlags.Available) != 0; + + /// + /// Whether this beta branch is private (requires password or invitation). + /// + public bool IsPrivate => (Flags & BetaBranchFlags.Private) != 0; + + /// + /// Whether this beta branch is currently selected by the user. + /// + public bool IsSelected => (Flags & BetaBranchFlags.Selected) != 0; + + /// + /// Whether this beta branch is currently installed. + /// + public bool IsInstalled => (Flags & BetaBranchFlags.Installed) != 0; + } +} \ No newline at end of file