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