mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Filled out Client.App
This commit is contained in:
parent
df9b0d3114
commit
c38f45e630
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Facepunch.Steamworks
|
||||
@ -15,13 +16,29 @@ public partial class Client : BaseSteamworks
|
||||
/// </summary>
|
||||
public ulong SteamId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If we're sharing this game, this is the owner of it.
|
||||
/// </summary>
|
||||
public ulong OwnerSteamId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current Beta name, if we're using a beta branch.
|
||||
/// </summary>
|
||||
public string BetaName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The BuildId of the current build
|
||||
/// </summary>
|
||||
public int BuildId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The folder in which this app is installed
|
||||
/// </summary>
|
||||
public DirectoryInfo InstallFolder { get; private set; }
|
||||
|
||||
public Voice Voice { get; private set; }
|
||||
public ServerList ServerList { get; private set; }
|
||||
public App App { get; private set; }
|
||||
|
||||
public Client( uint appId )
|
||||
{
|
||||
@ -47,6 +64,7 @@ public Client( uint appId )
|
||||
//
|
||||
Voice = new Voice( this );
|
||||
ServerList = new ServerList( this );
|
||||
App = new App( this );
|
||||
|
||||
Workshop.friends = Friends;
|
||||
|
||||
@ -58,6 +76,9 @@ public Client( uint appId )
|
||||
Username = native.friends.GetPersonaName();
|
||||
SteamId = native.user.GetSteamID();
|
||||
BetaName = native.apps.GetCurrentBetaName();
|
||||
OwnerSteamId = native.apps.GetAppOwner();
|
||||
InstallFolder = new DirectoryInfo( native.apps.GetAppInstallDir( AppId ) );
|
||||
BuildId = native.apps.GetAppBuildId();
|
||||
|
||||
//
|
||||
// Run update, first call does some initialization
|
||||
@ -104,6 +125,12 @@ public override void Dispose()
|
||||
ServerList = null;
|
||||
}
|
||||
|
||||
if ( App != null )
|
||||
{
|
||||
App.Dispose();
|
||||
App = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@ -129,5 +156,27 @@ public Leaderboard GetLeaderboard( string name, LeaderboardSortMethod sortMethod
|
||||
native.userstats.FindOrCreateLeaderboard( name, (SteamNative.LeaderboardSortMethod)sortMethod, (SteamNative.LeaderboardDisplayType)displayType, board.OnBoardCreated );
|
||||
return board;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// True if we're subscribed/authorised to be running this app
|
||||
/// </summary>
|
||||
public bool IsSubscribed => native.apps.BIsSubscribed();
|
||||
|
||||
/// <summary>
|
||||
/// True if we're a cybercafe account
|
||||
/// </summary>
|
||||
public bool IsCybercafe => native.apps.BIsCybercafe();
|
||||
|
||||
/// <summary>
|
||||
/// True if we're subscribed/authorised to be running this app, but only temporarily
|
||||
/// due to a free weekend etc.
|
||||
/// </summary>
|
||||
public bool IsSubscribedFromFreeWeekend => native.apps.BIsSubscribedFromFreeWeekend();
|
||||
|
||||
/// <summary>
|
||||
/// True if we're in low violence mode (germans are only allowed to see the insides of bodies in porn)
|
||||
/// </summary>
|
||||
public bool IsLowViolence => native.apps.BIsLowViolence();
|
||||
}
|
||||
}
|
||||
|
@ -5,23 +5,7 @@
|
||||
|
||||
namespace Facepunch.Steamworks
|
||||
{
|
||||
public partial class Client : IDisposable
|
||||
{
|
||||
App _app;
|
||||
|
||||
public App App
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( _app == null )
|
||||
_app = new App( this );
|
||||
|
||||
return _app;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class App
|
||||
public class App : IDisposable
|
||||
{
|
||||
internal Client client;
|
||||
|
||||
@ -30,23 +14,63 @@ internal App( Client c )
|
||||
client = c;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
client = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mark the content as corrupt, so it will validate the downloaded files
|
||||
/// once the app is closed. This is good to call when you detect a crash happening
|
||||
/// or a file is missing that is meant to be there.
|
||||
/// </summary>
|
||||
public void MarkContentCorrupt( bool missingFilesOnly = false )
|
||||
{
|
||||
client.native.apps.MarkContentCorrupt( missingFilesOnly );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current BuildId of the game.
|
||||
/// This is pretty useless, as it isn't guarenteed to return
|
||||
/// the build id you're playing, or the latest build id.
|
||||
/// Tell steam to install the Dlc specified by the AppId
|
||||
/// </summary>
|
||||
public int BuildId
|
||||
public void InstallDlc( uint appId )
|
||||
{
|
||||
get
|
||||
{
|
||||
return client.native.apps.GetAppBuildId();
|
||||
}
|
||||
client.native.apps.InstallDLC( appId );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tell steam to uninstall the Dlc specified by the AppId
|
||||
/// </summary>
|
||||
public void UninstallDlc(uint appId)
|
||||
{
|
||||
client.native.apps.UninstallDLC( appId );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the purchase time for this appid. Will return DateTime.MinValue if none.
|
||||
/// </summary>
|
||||
public DateTime PurchaseTime(uint appId)
|
||||
{
|
||||
var time = client.native.apps.GetEarliestPurchaseUnixTime(appId);
|
||||
if ( time == 0 ) return DateTime.MinValue;
|
||||
|
||||
return Utility.Epoch.ToDateTime( time );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this user is subscribed to the specific appid
|
||||
/// ie. If the user owns this game specified.
|
||||
/// </summary>
|
||||
public bool IsSubscribed(uint appId)
|
||||
{
|
||||
return client.native.apps.BIsSubscribedApp(appId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if specified app is installed.
|
||||
/// </summary>
|
||||
public bool IsInstalled(uint appId)
|
||||
{
|
||||
return client.native.apps.BIsAppInstalled(appId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user