From e7aa122c1f343978bd57f27bcc938e5308800277 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sun, 14 Apr 2019 22:05:51 +0100 Subject: [PATCH] Refactor --- Facepunch.Steamworks/Redux/Apps.cs | 54 +++++++++++++------------- Facepunch.Steamworks/Redux/Music.cs | 20 +++++----- Facepunch.Steamworks/Redux/Parental.cs | 14 +++---- Facepunch.Steamworks/Redux/Utils.cs | 54 +++++++++++++------------- 4 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Facepunch.Steamworks/Redux/Apps.cs b/Facepunch.Steamworks/Redux/Apps.cs index 1b43888..d06b4bf 100644 --- a/Facepunch.Steamworks/Redux/Apps.cs +++ b/Facepunch.Steamworks/Redux/Apps.cs @@ -14,7 +14,7 @@ namespace Steamworks public static class Apps { static Internal.ISteamApps _internal; - internal static Internal.ISteamApps steamapps + internal static Internal.ISteamApps Internal { get { @@ -47,62 +47,62 @@ internal static void InstallEvents() /// /// Checks if the active user is subscribed to the current App ID /// - public static bool IsSubscribed => steamapps.BIsSubscribed(); + public static bool IsSubscribed => Internal.BIsSubscribed(); /// /// Check if user borrowed this game via Family Sharing, If true, call GetAppOwner() to get the lender SteamID /// - public static bool IsSubscribedFromFamilySharing => steamapps.BIsSubscribedFromFamilySharing(); + public static bool IsSubscribedFromFamilySharing => Internal.BIsSubscribedFromFamilySharing(); /// /// Checks if the license owned by the user provides low violence depots. /// Low violence depots are useful for copies sold in countries that have content restrictions /// - public static bool IsLowVoilence => steamapps.BIsLowViolence(); + public static bool IsLowVoilence => Internal.BIsLowViolence(); /// /// Checks whether the current App ID license is for Cyber Cafes. /// - public static bool IsCybercafe => steamapps.BIsCybercafe(); + public static bool IsCybercafe => Internal.BIsCybercafe(); /// /// CChecks if the user has a VAC ban on their account /// - public static bool IsVACBanned => steamapps.BIsVACBanned(); + public static bool IsVACBanned => Internal.BIsVACBanned(); /// /// Gets the current language that the user has set. /// This falls back to the Steam UI language if the user hasn't explicitly picked a language for the title. /// - public static string GameLanguage => steamapps.GetCurrentGameLanguage(); + public static string GameLanguage => Internal.GetCurrentGameLanguage(); /// /// Gets a list of the languages the current app supports. /// - public static string[] AvailablLanguages => steamapps.GetAvailableGameLanguages().Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries ); + public static string[] AvailablLanguages => Internal.GetAvailableGameLanguages().Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries ); /// /// Checks if the active user is subscribed to a specified AppId. /// Only use this if you need to check ownership of another game related to yours, a demo for example. /// - public static bool IsSubscribedToApp( AppId appid ) => steamapps.BIsSubscribedApp( appid.Value ); + public static bool IsSubscribedToApp( AppId appid ) => Internal.BIsSubscribedApp( appid.Value ); /// /// Checks if the user owns a specific DLC and if the DLC is installed /// - public static bool IsDlcInstalled( AppId appid ) => steamapps.BIsDlcInstalled( appid.Value ); + public static bool IsDlcInstalled( AppId appid ) => Internal.BIsDlcInstalled( appid.Value ); /// /// Returns the time of the purchase of the app /// - public static DateTime PurchaseTime( AppId appid ) => Facepunch.Steamworks.Utility.Epoch.ToDateTime( steamapps.GetEarliestPurchaseUnixTime( appid.Value ) ); + public static DateTime PurchaseTime( AppId appid ) => Facepunch.Steamworks.Utility.Epoch.ToDateTime( Internal.GetEarliestPurchaseUnixTime( appid.Value ) ); /// /// Checks if the user is subscribed to the current app through a free weekend /// This function will return false for users who have a retail or other type of license /// Before using, please ask your Valve technical contact how to package and secure your free weekened /// - public static bool IsSubscribedFromFreeWeekend => steamapps.BIsSubscribedFromFreeWeekend(); + public static bool IsSubscribedFromFreeWeekend => Internal.BIsSubscribedFromFreeWeekend(); /// /// Returns metadata for all available DLC @@ -112,11 +112,11 @@ public static IEnumerable DlcInformation() var appid = default( SteamNative.AppId_t ); var available = false; - for ( int i = 0; i < steamapps.GetDLCCount(); i++ ) + for ( int i = 0; i < Internal.GetDLCCount(); i++ ) { var sb = SteamNative.Helpers.TakeStringBuilder(); - if ( !steamapps.BGetDLCDataByIndex( i, ref appid, ref available, sb, sb.Capacity ) ) + if ( !Internal.BGetDLCDataByIndex( i, ref appid, ref available, sb, sb.Capacity ) ) continue; yield return new DlcInformation @@ -131,12 +131,12 @@ public static IEnumerable DlcInformation() /// /// Install/Uninstall control for optional DLC /// - public static void InstallDlc( AppId appid ) => steamapps.InstallDLC( appid.Value ); + public static void InstallDlc( AppId appid ) => Internal.InstallDLC( appid.Value ); /// /// Install/Uninstall control for optional DLC /// - public static void UninstallDlc( AppId appid ) => steamapps.UninstallDLC( appid.Value ); + public static void UninstallDlc( AppId appid ) => Internal.UninstallDLC( appid.Value ); /// /// Returns null if we're not on a beta branch, else the name of the branch @@ -147,7 +147,7 @@ public static string CurrentBetaName { var sb = SteamNative.Helpers.TakeStringBuilder(); - if ( !steamapps.GetCurrentBetaName( sb, sb.Capacity ) ) + if ( !Internal.GetCurrentBetaName( sb, sb.Capacity ) ) return null; return sb.ToString(); @@ -160,7 +160,7 @@ public static string CurrentBetaName /// If you detect the game is out-of-date(for example, by having the client detect a version mismatch with a server), /// you can call use MarkContentCorrupt to force a verify, show a message to the user, and then quit. /// - public static void MarkContentCorrupt( bool missingFilesOnly ) => steamapps.MarkContentCorrupt( missingFilesOnly ); + public static void MarkContentCorrupt( bool missingFilesOnly ) => Internal.MarkContentCorrupt( missingFilesOnly ); /// /// Gets a list of all installed depots for a given App ID in mount order @@ -170,7 +170,7 @@ public static IEnumerable InstalledDepots( AppId appid ) var depots = new SteamNative.DepotId_t[32]; uint count = 0; - count = steamapps.GetInstalledDepots( appid.Value, depots, (uint) depots.Length ); + count = Internal.GetInstalledDepots( appid.Value, depots, (uint) depots.Length ); for ( int i = 0; i < count; i++ ) { @@ -186,7 +186,7 @@ public static string AppInstallDir( AppId appid ) { var sb = SteamNative.Helpers.TakeStringBuilder(); - if ( steamapps.GetAppInstallDir( appid.Value, sb, (uint) sb.Capacity ) == 0 ) + if ( Internal.GetAppInstallDir( appid.Value, sb, (uint) sb.Capacity ) == 0 ) return null; return sb.ToString(); @@ -195,12 +195,12 @@ public static string AppInstallDir( AppId appid ) /// /// The app may not actually be owned by the current user, they may have it left over from a free weekend, etc. /// - public static bool IsAppInstalled( AppId appid ) => steamapps.BIsAppInstalled( appid.Value ); + public static bool IsAppInstalled( AppId appid ) => Internal.BIsAppInstalled( appid.Value ); /// /// Gets the Steam ID of the original owner of the current app. If it's different from the current user then it is borrowed.. /// - public static SteamId AppOwner => steamapps.GetAppOwner().Value; + public static SteamId AppOwner => Internal.GetAppOwner().Value; /// /// Gets the associated launch parameter if the game is run via steam://run/appid/?param1=value1;param2=value2;param3=value3 etc. @@ -208,7 +208,7 @@ public static string AppInstallDir( AppId appid ) /// Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, /// but it is advised that you not param names beginning with an underscore for your own features. /// - public static string GetLaunchParam( string param ) => steamapps.GetLaunchQueryParam( param ); + public static string GetLaunchParam( string param ) => Internal.GetLaunchQueryParam( param ); /// /// Gets the download progress for optional DLC. @@ -218,7 +218,7 @@ public static DownloadProgress DlcDownloadProgress( AppId appid ) ulong punBytesDownloaded = 0; ulong punBytesTotal = 0; - if ( !steamapps.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) ) + if ( !Internal.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) ) return default( DownloadProgress ); return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true }; @@ -228,7 +228,7 @@ public static DownloadProgress DlcDownloadProgress( AppId appid ) /// Gets the buildid of this app, may change at any time based on backend updates to the game. /// Defaults to 0 if you're not running a build downloaded from steam. /// - public static int BuildId => steamapps.GetAppBuildId(); + public static int BuildId => Internal.GetAppBuildId(); /// @@ -237,7 +237,7 @@ public static DownloadProgress DlcDownloadProgress( AppId appid ) /// public static async Task GetFileDetails( string filename ) { - var r = await steamapps.GetFileDetails( filename ); + var r = await Internal.GetFileDetails( filename ); if ( !r.HasValue ) { @@ -266,7 +266,7 @@ public static string CommandLine get { var sb = SteamNative.Helpers.TakeStringBuilder(); - var len = steamapps.GetLaunchCommandLine( sb, sb.Capacity ); + var len = Internal.GetLaunchCommandLine( sb, sb.Capacity ); return sb.ToString(); } } diff --git a/Facepunch.Steamworks/Redux/Music.cs b/Facepunch.Steamworks/Redux/Music.cs index b97935e..8d68437 100644 --- a/Facepunch.Steamworks/Redux/Music.cs +++ b/Facepunch.Steamworks/Redux/Music.cs @@ -13,7 +13,7 @@ namespace Steamworks public static class Music { static Internal.ISteamMusic _internal; - internal static Internal.ISteamMusic music + internal static Internal.ISteamMusic Internal { get { @@ -43,40 +43,40 @@ internal static void InstallEvents() /// /// Checks if Steam Music is enabled /// - public static bool IsEnabled => music.BIsEnabled(); + public static bool IsEnabled => Internal.BIsEnabled(); /// /// true if a song is currently playing, paused, or queued up to play; otherwise false. /// - public static bool IsPlaying => music.BIsPlaying(); + public static bool IsPlaying => Internal.BIsPlaying(); /// /// Gets the current status of the Steam Music player /// - public static AudioPlayback_Status Status => music.GetPlaybackStatus(); + public static AudioPlayback_Status Status => Internal.GetPlaybackStatus(); - public static void Play() => music.Play(); + public static void Play() => Internal.Play(); - public static void Pause() => music.Pause(); + public static void Pause() => Internal.Pause(); /// /// Have the Steam Music player play the previous song. /// - public static void PlayPrevious() => music.PlayPrevious(); + public static void PlayPrevious() => Internal.PlayPrevious(); /// /// Have the Steam Music player skip to the next song /// - public static void PlayNext() => music.PlayNext(); + public static void PlayNext() => Internal.PlayNext(); /// /// Gets/Sets the current volume of the Steam Music player /// public static float Volume { - get => music.GetVolume(); - set => music.SetVolume( value ); + get => Internal.GetVolume(); + set => Internal.SetVolume( value ); } } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Parental.cs b/Facepunch.Steamworks/Redux/Parental.cs index d2b3224..4cc49b9 100644 --- a/Facepunch.Steamworks/Redux/Parental.cs +++ b/Facepunch.Steamworks/Redux/Parental.cs @@ -13,7 +13,7 @@ namespace Steamworks public static class Parental { static Internal.ISteamParentalSettings _internal; - internal static Internal.ISteamParentalSettings parentalsettings + internal static Internal.ISteamParentalSettings Internal { get { @@ -38,31 +38,31 @@ internal static void InstallEvents() /// /// /// - public static bool IsParentalLockEnabled => parentalsettings.BIsParentalLockEnabled(); + public static bool IsParentalLockEnabled => Internal.BIsParentalLockEnabled(); /// /// /// - public static bool IsParentalLockLocked => parentalsettings.BIsParentalLockLocked(); + public static bool IsParentalLockLocked => Internal.BIsParentalLockLocked(); /// /// /// - public static bool IsAppBlocked( AppId app ) => parentalsettings.BIsAppBlocked( app.Value ); + public static bool IsAppBlocked( AppId app ) => Internal.BIsAppBlocked( app.Value ); /// /// /// - public static bool BIsAppInBlockList( AppId app ) => parentalsettings.BIsAppInBlockList( app.Value ); + public static bool BIsAppInBlockList( AppId app ) => Internal.BIsAppInBlockList( app.Value ); /// /// /// - public static bool IsFeatureBlocked( ParentalFeature feature ) => parentalsettings.BIsFeatureBlocked( feature ); + public static bool IsFeatureBlocked( ParentalFeature feature ) => Internal.BIsFeatureBlocked( feature ); /// /// /// - public static bool BIsFeatureInBlockList( ParentalFeature feature ) => parentalsettings.BIsFeatureInBlockList( feature ); + public static bool BIsFeatureInBlockList( ParentalFeature feature ) => Internal.BIsFeatureInBlockList( feature ); } } \ No newline at end of file diff --git a/Facepunch.Steamworks/Redux/Utils.cs b/Facepunch.Steamworks/Redux/Utils.cs index 4708387..897e4ba 100644 --- a/Facepunch.Steamworks/Redux/Utils.cs +++ b/Facepunch.Steamworks/Redux/Utils.cs @@ -13,7 +13,7 @@ namespace Steamworks public static class Utils { static Internal.ISteamUtils _internal; - internal static Internal.ISteamUtils steamutils + internal static Internal.ISteamUtils Internal { get { @@ -56,26 +56,26 @@ internal static void InstallEvents() /// /// Returns the number of seconds since the application was active /// - public static uint SecondsSinceAppActive => steamutils.GetSecondsSinceAppActive(); + public static uint SecondsSinceAppActive => Internal.GetSecondsSinceAppActive(); /// /// Returns the number of seconds since the user last moved the mouse etc /// - public static uint SecondsSinceComputerActive => steamutils.GetSecondsSinceComputerActive(); + public static uint SecondsSinceComputerActive => Internal.GetSecondsSinceComputerActive(); // the universe this client is connecting to - public static Universe ConnectedUniverse => steamutils.GetConnectedUniverse(); + public static Universe ConnectedUniverse => Internal.GetConnectedUniverse(); /// /// Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time) /// - public static DateTime SteamServerTime => Facepunch.Steamworks.Utility.Epoch.ToDateTime( steamutils.GetServerRealTime() ); + public static DateTime SteamServerTime => Facepunch.Steamworks.Utility.Epoch.ToDateTime( Internal.GetServerRealTime() ); /// /// returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database) /// e.g "US" or "UK". /// - public static string IpCountry => steamutils.GetIPCountry(); + public static string IpCountry => Internal.GetIPCountry(); /// /// returns true if the image exists, and the buffer was successfully filled out @@ -86,7 +86,7 @@ public static bool GetImageSize( int image, out uint width, out uint height ) { width = 0; height = 0; - return steamutils.GetImageSize( image, ref width, ref height ); + return Internal.GetImageSize( image, ref width, ref height ); } /// @@ -100,7 +100,7 @@ public static byte[] GetImageRGBA( int image ) var size = w * h * 4 * sizeof( char ); var data = new byte[size]; - if ( !steamutils.GetImageRGBA( image, data, data.Length ) ) + if ( !Internal.GetImageRGBA( image, data, data.Length ) ) return null; return data; @@ -109,17 +109,17 @@ public static byte[] GetImageRGBA( int image ) /// /// Returns true if we're using a battery (ie, a laptop not plugged in) /// - public static bool UsingBatteryPower => steamutils.GetCurrentBatteryPower() != 255; + public static bool UsingBatteryPower => Internal.GetCurrentBatteryPower() != 255; /// /// Returns battery power [0-1] /// - public static float CurrentBatteryPower => Math.Min( steamutils.GetCurrentBatteryPower() / 100, 1.0f ); + public static float CurrentBatteryPower => Math.Min( Internal.GetCurrentBatteryPower() / 100, 1.0f ); /// /// returns the appID of the current process /// - public static AppId AppId => steamutils.GetAppID(); + public static AppId AppId => Internal.GetAppID(); static NotificationPosition overlayNotificationPosition = NotificationPosition.BottomRight; @@ -134,7 +134,7 @@ public static NotificationPosition OverlayNotificationPosition set { overlayNotificationPosition = value; - steamutils.SetOverlayNotificationPosition( value ); + Internal.SetOverlayNotificationPosition( value ); } } @@ -142,7 +142,7 @@ public static NotificationPosition OverlayNotificationPosition /// Returns true if the overlay is running and the user can access it. The overlay process could take a few seconds to /// start and hook the game process, so this function will initially return false while the overlay is loading. /// - public static bool IsOverlayEnabled => steamutils.IsOverlayEnabled(); + public static bool IsOverlayEnabled => Internal.IsOverlayEnabled(); /// /// Normally this call is unneeded if your game has a constantly running frame loop that calls the @@ -155,7 +155,7 @@ public static NotificationPosition OverlayNotificationPosition /// in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you /// refresh the screen with Present or SwapBuffers to allow the overlay to do it's work. /// - public static bool DoesOverlayNeedPresent => steamutils.BOverlayNeedsPresent(); + public static bool DoesOverlayNeedPresent => Internal.BOverlayNeedsPresent(); /// /// Asynchronous call to check if an executable file has been signed using the public key set on the signing tab @@ -163,7 +163,7 @@ public static NotificationPosition OverlayNotificationPosition /// public static async Task CheckFileSignature( string filename ) { - var r = await steamutils.CheckFileSignature( filename ); + var r = await Internal.CheckFileSignature( filename ); if ( !r.HasValue ) { @@ -178,7 +178,7 @@ public static async Task CheckFileSignature( string filename /// public static bool ShowGamepadTextInput( GamepadTextInputMode inputMode, GamepadTextInputLineMode lineInputMode, string description, int maxChars, string existingText = "" ) { - return steamutils.ShowGamepadTextInput( inputMode, lineInputMode, description, (uint)maxChars, existingText ); + return Internal.ShowGamepadTextInput( inputMode, lineInputMode, description, (uint)maxChars, existingText ); } /// @@ -186,11 +186,11 @@ public static bool ShowGamepadTextInput( GamepadTextInputMode inputMode, Gamepad /// public static string GetEnteredGamepadText() { - var len = steamutils.GetEnteredGamepadTextLength(); + var len = Internal.GetEnteredGamepadTextLength(); if ( len == 0 ) return string.Empty; var sb = Helpers.TakeStringBuilder(); - if ( !steamutils.GetEnteredGamepadTextInput( sb, len ) ) + if ( !Internal.GetEnteredGamepadTextInput( sb, len ) ) return string.Empty; return sb.ToString(); @@ -200,19 +200,19 @@ public static string GetEnteredGamepadText() /// returns the language the steam client is running in, you probably want /// Apps.CurrentGameLanguage instead, this is for very special usage cases /// - public static string SteamUILanguage => steamutils.GetSteamUILanguage(); + public static string SteamUILanguage => Internal.GetSteamUILanguage(); /// /// returns true if Steam itself is running in VR mode /// - public static bool IsSteamRunningInVR => steamutils.IsSteamRunningInVR(); + public static bool IsSteamRunningInVR => Internal.IsSteamRunningInVR(); /// /// Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition /// public static void SetOverlayNotificationInset( int x, int y ) { - steamutils.SetOverlayNotificationInset( x, y ); + Internal.SetOverlayNotificationInset( x, y ); } /// @@ -220,13 +220,13 @@ public static void SetOverlayNotificationInset( int x, int y ) /// Games much be launched through the Steam client to enable the Big Picture overlay. During development, /// a game can be added as a non-steam game to the developers library to test this feature /// - public static bool IsSteamInBigPictureMode => steamutils.IsSteamInBigPictureMode(); + public static bool IsSteamInBigPictureMode => Internal.IsSteamInBigPictureMode(); /// /// ask SteamUI to create and render its OpenVR dashboard /// - public static void StartVRDashboard() => steamutils.StartVRDashboard(); + public static void StartVRDashboard() => Internal.StartVRDashboard(); /// /// Set whether the HMD content will be streamed via Steam In-Home Streaming @@ -237,11 +237,11 @@ public static void SetOverlayNotificationInset( int x, int y ) /// public static bool VrHeadsetStreaming { - get => steamutils.IsVRHeadsetStreamingEnabled(); + get => Internal.IsVRHeadsetStreamingEnabled(); set { - steamutils.SetVRHeadsetStreamingEnabled( value ); + Internal.SetVRHeadsetStreamingEnabled( value ); } } @@ -249,7 +249,7 @@ public static bool VrHeadsetStreaming internal static bool IsCallComplete( SteamAPICall_t call, out bool failed ) { failed = false; - return steamutils.IsAPICallCompleted( call, ref failed ); + return Internal.IsAPICallCompleted( call, ref failed ); } internal static T? GetResult( SteamAPICall_t call ) where T : struct, ISteamCallback @@ -263,7 +263,7 @@ internal static bool IsCallComplete( SteamAPICall_t call, out bool failed ) { bool failed = false; - if ( !steamutils.GetAPICallResult( call, ptr, size, t.GetCallbackId(), ref failed ) ) + if ( !Internal.GetAPICallResult( call, ptr, size, t.GetCallbackId(), ref failed ) ) return null; if ( failed )