More functions

This commit is contained in:
Garry Newman 2019-04-12 21:47:02 +01:00
parent 199ad77406
commit 34d6b15fb8
4 changed files with 110 additions and 2 deletions

View File

@ -26,6 +26,26 @@ public void GameLangauge()
Console.WriteLine( $"{gl}" );
}
[TestMethod]
public void AppInstallDir()
{
var str = Apps.AppInstallDir( 4000 );
Assert.IsNotNull( str );
Assert.IsTrue( str.Length > 3 );
Console.WriteLine( $"{str}" );
}
[TestMethod]
public void AppOwner()
{
var steamid = Apps.AppOwner;
Assert.IsTrue( steamid.Value > 70561197960279927 );
Assert.IsTrue( steamid.Value < 80561197960279927 );
Console.WriteLine( $"{steamid.Value}" );
}
[TestMethod]
public void InstalledDepots()
{
@ -38,8 +58,6 @@ public void InstalledDepots()
{
Console.WriteLine( $"{depot.Value}" );
}
}
}

View File

@ -152,5 +152,57 @@ public static IEnumerable<DepotId> InstalledDepots( AppId appid )
}
}
/// <summary>
/// Gets the install folder for a specific AppID.
/// This works even if the application is not installed, based on where the game would be installed with the default Steam library location.
/// </summary>
public static string AppInstallDir( AppId appid )
{
var sb = SteamNative.Helpers.TakeStringBuilder();
if ( steamapps.GetAppInstallDir( appid.Value, sb, (uint) sb.Capacity ) == 0 )
return null;
return sb.ToString();
}
/// <summary>
/// The app may not actually be owned by the current user, they may have it left over from a free weekend, etc.
/// </summary>
public static bool IsAppInstalled( AppId appid ) => steamapps.BIsAppInstalled( appid.Value );
/// <summary>
/// Gets the Steam ID of the original owner of the current app. If it's different from the current user then it is borrowed..
/// </summary>
public static SteamId AppOwner => steamapps.GetAppOwner().Value;
/// <summary>
/// Gets the associated launch parameter if the game is run via steam://run/<appid>/?param1=value1;param2=value2;param3=value3 etc.
/// Parameter names starting with the character '@' are reserved for internal use and will always return an empty string.
/// 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.
/// </summary>
public static string GetLaunchParam( string param ) => steamapps.GetLaunchQueryParam( param );
/// <summary>
/// Gets the download progress for optional DLC.
/// </summary>
public static DownloadProgress DlcDownloadProgress( AppId appid )
{
ulong punBytesDownloaded = 0;
ulong punBytesTotal = 0;
if ( !steamapps.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) )
return default( DownloadProgress );
return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true };
}
/// <summary>
/// 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.
/// </summary>
public static int BuildId => steamapps.GetAppBuildId();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Steamworks
{
public struct DownloadProgress
{
public bool Active;
public ulong BytesDownloaded;
public ulong BytesTotal;
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace Steamworks
{
public struct SteamId
{
public ulong Value;
public static implicit operator SteamId( ulong value )
{
return new SteamId { Value = value };
}
public static implicit operator ulong( SteamId value )
{
return value.Value;
}
}
}