Make SteamNative completely internal

This commit is contained in:
Garry Newman 2016-11-02 21:00:25 +00:00
parent 0b11025afe
commit d5eca996cd
8 changed files with 318 additions and 192 deletions

View File

@ -14,16 +14,6 @@
Called with a message from Steam Called with a message from Steam
</summary> </summary>
</member> </member>
<member name="M:Facepunch.Steamworks.BaseSteamworks.AddCallback``2(System.Action{``0},System.Int32)">
<summary>
Global callback type
</summary>
</member>
<member name="M:Facepunch.Steamworks.BaseSteamworks.AddCallResult(Facepunch.Steamworks.Interop.CallResult)">
<summary>
Call results are results to specific actions
</summary>
</member>
<member name="T:Facepunch.Steamworks.Inventory.Item"> <member name="T:Facepunch.Steamworks.Inventory.Item">
<summary> <summary>
An item in your inventory. An item in your inventory.
@ -341,13 +331,62 @@
</summary> </summary>
</member> </member>
<member name="M:Facepunch.Steamworks.Config.ForcePlatform(SteamNative.OperatingSystem,SteamNative.Architecture)"> <member name="M:Facepunch.Steamworks.Config.ForcePlatform(Facepunch.Steamworks.OperatingSystem,Facepunch.Steamworks.Architecture)">
<summary> <summary>
You can force the platform to a particular one here. You can force the platform to a particular one here.
This is useful if you're on OSX because some versions of mono don't have a way This is useful if you're on OSX because some versions of mono don't have a way
to tell which platform we're running to tell which platform we're running
</summary> </summary>
</member> </member>
<member name="T:Facepunch.Steamworks.Workshop">
<summary>
Allows you to interact with Steam's UGC stuff (User Generated Content).
To put simply, this allows you to upload a folder of files to Steam.
To upload a new file use CreateItem. This returns an Editor object.
This object is also used to edit existing items.
To get a list of items you can call CreateQuery. From there you can download
an item and retrieve the folder that it's downloaded to.
Generally there's no need to compress and decompress your uploads, so you should
usually be able to use the content straight from the destination folder.
</summary>
</member>
<member name="E:Facepunch.Steamworks.Workshop.OnFileDownloaded">
<summary>
Called when an item has been downloaded. This could have been
because of a call to Download or because of a subscription triggered
via the browser/app.
</summary>
</member>
<member name="E:Facepunch.Steamworks.Workshop.OnItemInstalled">
<summary>
Called when an item has been installed. This could have been
because of a call to Download or because of a subscription triggered
via the browser/app.
</summary>
</member>
<member name="M:Facepunch.Steamworks.Workshop.Dispose">
<summary>
You should never have to call this manually
</summary>
</member>
<member name="M:Facepunch.Steamworks.Workshop.CreateQuery">
<summary>
Creates a query object, which is used to get a list of items.
This could be a list of the most popular items, or a search,
or just getting a list of the items you've uploaded.
</summary>
</member>
<member name="M:Facepunch.Steamworks.Workshop.CreateItem(Facepunch.Steamworks.Workshop.ItemType)">
<summary>
Create a new Editor object with the intention of creating a new item.
Your item won't actually be created until you call Publish() on the object.
</summary>
</member>
<member name="M:Facepunch.Steamworks.Workshop.EditItem(System.UInt64)"> <member name="M:Facepunch.Steamworks.Workshop.EditItem(System.UInt64)">
<summary> <summary>
Returns a class representing this ItemId. We don't query Returns a class representing this ItemId. We don't query
@ -355,6 +394,24 @@
We don't verify that this item belongs to your app. We don't verify that this item belongs to your app.
</summary> </summary>
</member> </member>
<member name="M:Facepunch.Steamworks.Workshop.GetItem(System.UInt64)">
<summary>
Gets an Item object for a specific item. This doesn't currently
query the item's name and description. It's only really useful
if you know an item's ID and want to download it, or check its
current download status.
</summary>
</member>
<member name="T:Facepunch.Steamworks.Workshop.Order">
<summary>
How a query should be ordered.
</summary>
</member>
<member name="T:Facepunch.Steamworks.Workshop.QueryType">
<summary>
The type of item you are querying for
</summary>
</member>
<member name="F:Facepunch.Steamworks.Workshop.QueryType.Items"> <member name="F:Facepunch.Steamworks.Workshop.QueryType.Items">
<summary> <summary>
Both MicrotransactionItems and subscriptionItems Both MicrotransactionItems and subscriptionItems
@ -370,6 +427,17 @@
normal Workshop item that can be subscribed to normal Workshop item that can be subscribed to
</summary> </summary>
</member> </member>
<member name="T:Facepunch.Steamworks.Workshop.ItemType">
<summary>
Used to define the item type when creating
</summary>
</member>
<member name="T:Facepunch.Steamworks.Workshop.UserQueryType">
<summary>
When querying a specific user's items this defines what
type of items you're looking for.
</summary>
</member>
<member name="P:Facepunch.Steamworks.Workshop.Item.Url"> <member name="P:Facepunch.Steamworks.Workshop.Item.Url">
<summary> <summary>
Return a URL to view this item online Return a URL to view this item online
@ -504,11 +572,6 @@
Steam authetication statuses Steam authetication statuses
</summary> </summary>
</member> </member>
<member name="F:Facepunch.Steamworks.ServerAuth.Status.OK">
<summary>
Steam has verified the user is online, the ticket is valid and ticket has not been reused.
</summary>
</member>
<member name="M:Facepunch.Steamworks.ServerAuth.StartSession(System.Byte[],System.UInt64)"> <member name="M:Facepunch.Steamworks.ServerAuth.StartSession(System.Byte[],System.UInt64)">
<summary> <summary>
Start authorizing a ticket. This user isn't authorized yet. Wait for a call to OnAuthChange. Start authorizing a ticket. This user isn't authorized yet. Wait for a call to OnAuthChange.

View File

@ -24,7 +24,7 @@ namespace Facepunch.Steamworks
/// This is useful if you're on OSX because some versions of mono don't have a way /// This is useful if you're on OSX because some versions of mono don't have a way
/// to tell which platform we're running /// to tell which platform we're running
/// </summary> /// </summary>
public static void ForcePlatform( SteamNative.OperatingSystem os, SteamNative.Architecture arch ) public static void ForcePlatform( Facepunch.Steamworks.OperatingSystem os, Facepunch.Steamworks.Architecture arch )
{ {
SteamNative.Platform.Os = os; SteamNative.Platform.Os = os;
SteamNative.Platform.Arch = arch; SteamNative.Platform.Arch = arch;

View File

@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\..\..\Work\Rust\Main\Assets\Plugins\Facepunch.Steamworks\Facepunch.Steamworks.XML</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>

View File

@ -4,6 +4,20 @@ using SteamNative;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
/// <summary>
/// Allows you to interact with Steam's UGC stuff (User Generated Content).
/// To put simply, this allows you to upload a folder of files to Steam.
///
/// To upload a new file use CreateItem. This returns an Editor object.
/// This object is also used to edit existing items.
///
/// To get a list of items you can call CreateQuery. From there you can download
/// an item and retrieve the folder that it's downloaded to.
///
/// Generally there's no need to compress and decompress your uploads, so you should
/// usually be able to use the content straight from the destination folder.
///
/// </summary>
public partial class Workshop : IDisposable public partial class Workshop : IDisposable
{ {
internal const ulong InvalidHandle = 0xffffffffffffffff; internal const ulong InvalidHandle = 0xffffffffffffffff;
@ -13,7 +27,18 @@ namespace Facepunch.Steamworks
internal BaseSteamworks steamworks; internal BaseSteamworks steamworks;
internal SteamNative.SteamRemoteStorage remoteStorage; internal SteamNative.SteamRemoteStorage remoteStorage;
internal event Action<ulong, Callbacks.Result> OnFileDownloaded; /// <summary>
/// Called when an item has been downloaded. This could have been
/// because of a call to Download or because of a subscription triggered
/// via the browser/app.
/// </summary>
public event Action<ulong, Callbacks.Result> OnFileDownloaded;
/// <summary>
/// Called when an item has been installed. This could have been
/// because of a call to Download or because of a subscription triggered
/// via the browser/app.
/// </summary>
internal event Action<ulong> OnItemInstalled; internal event Action<ulong> OnItemInstalled;
internal Workshop( BaseSteamworks steamworks, SteamNative.SteamUGC ugc, SteamNative.SteamRemoteStorage remoteStorage ) internal Workshop( BaseSteamworks steamworks, SteamNative.SteamUGC ugc, SteamNative.SteamRemoteStorage remoteStorage )
@ -29,6 +54,9 @@ namespace Facepunch.Steamworks
// steamworks.AddCallback<ItemInstalled, ItemInstalled.Small>( onItemInstalled, ItemInstalled.CallbackId ); // steamworks.AddCallback<ItemInstalled, ItemInstalled.Small>( onItemInstalled, ItemInstalled.CallbackId );
} }
/// <summary>
/// You should never have to call this manually
/// </summary>
public void Dispose() public void Dispose()
{ {
ugc = null; ugc = null;
@ -52,6 +80,12 @@ namespace Facepunch.Steamworks
OnFileDownloaded( obj.PublishedFileId, (Callbacks.Result) obj.Result ); OnFileDownloaded( obj.PublishedFileId, (Callbacks.Result) obj.Result );
} }
/// <summary>
/// Creates a query object, which is used to get a list of items.
///
/// This could be a list of the most popular items, or a search,
/// or just getting a list of the items you've uploaded.
/// </summary>
public Query CreateQuery() public Query CreateQuery()
{ {
return new Query() return new Query()
@ -62,6 +96,10 @@ namespace Facepunch.Steamworks
}; };
} }
/// <summary>
/// Create a new Editor object with the intention of creating a new item.
/// Your item won't actually be created until you call Publish() on the object.
/// </summary>
public Editor CreateItem( ItemType type ) public Editor CreateItem( ItemType type )
{ {
return new Editor() { workshop = this, Type = type }; return new Editor() { workshop = this, Type = type };
@ -77,11 +115,21 @@ namespace Facepunch.Steamworks
return new Editor() { workshop = this, Id = itemId }; return new Editor() { workshop = this, Id = itemId };
} }
/// <summary>
/// Gets an Item object for a specific item. This doesn't currently
/// query the item's name and description. It's only really useful
/// if you know an item's ID and want to download it, or check its
/// current download status.
/// </summary>
public Item GetItem( ulong itemid ) public Item GetItem( ulong itemid )
{ {
return new Item( itemid, this ); return new Item( itemid, this );
} }
/// <summary>
/// How a query should be ordered.
/// </summary>
public enum Order public enum Order
{ {
RankedByVote = 0, RankedByVote = 0,
@ -99,6 +147,9 @@ namespace Facepunch.Steamworks
RankedByTotalUniqueSubscriptions = 12, RankedByTotalUniqueSubscriptions = 12,
}; };
/// <summary>
/// The type of item you are querying for
/// </summary>
public enum QueryType public enum QueryType
{ {
/// <summary> /// <summary>
@ -125,6 +176,9 @@ namespace Facepunch.Steamworks
GameManagedItems = 12, // game managed items (not managed by users) GameManagedItems = 12, // game managed items (not managed by users)
}; };
/// <summary>
/// Used to define the item type when creating
/// </summary>
public enum ItemType public enum ItemType
{ {
Community = 0, // normal Workshop item that can be subscribed to Community = 0, // normal Workshop item that can be subscribed to
@ -145,6 +199,10 @@ namespace Facepunch.Steamworks
GameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web GameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web
}; };
/// <summary>
/// When querying a specific user's items this defines what
/// type of items you're looking for.
/// </summary>
public enum UserQueryType : uint public enum UserQueryType : uint
{ {
Published = 0, Published = 0,

View File

@ -37,7 +37,7 @@ namespace SteamNative
// //
// Created on registration of a callback // Created on registration of a callback
// //
public class CallbackHandle : IDisposable internal class CallbackHandle : IDisposable
{ {
internal BaseSteamworks steamworks; internal BaseSteamworks steamworks;
internal SteamAPICall_t CallResultHandle; internal SteamAPICall_t CallResultHandle;

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace SteamNative namespace Facepunch.Steamworks
{ {
public enum OperatingSystem public enum OperatingSystem
{ {
@ -17,34 +17,37 @@ namespace SteamNative
x86, x86,
x64 x64
} }
}
namespace SteamNative
{
internal static partial class Platform internal static partial class Platform
{ {
private static OperatingSystem _os; private static Facepunch.Steamworks.OperatingSystem _os;
private static Architecture _arch; private static Facepunch.Steamworks.Architecture _arch;
internal static OperatingSystem Os internal static Facepunch.Steamworks.OperatingSystem Os
{ {
get get
{ {
// //
// Work out our platform // Work out our platform
// //
if ( _os == OperatingSystem.Unset ) if ( _os == Facepunch.Steamworks.OperatingSystem.Unset )
{ {
_os = OperatingSystem.Windows; _os = Facepunch.Steamworks.OperatingSystem.Windows;
// //
// These checks aren't so accurate on older versions of mono // These checks aren't so accurate on older versions of mono
// //
if ( Environment.OSVersion.Platform == PlatformID.MacOSX ) _os = OperatingSystem.Osx; if ( Environment.OSVersion.Platform == PlatformID.MacOSX ) _os = Facepunch.Steamworks.OperatingSystem.Osx;
if ( Environment.OSVersion.Platform == PlatformID.Unix ) _os = OperatingSystem.Linux; if ( Environment.OSVersion.Platform == PlatformID.Unix ) _os = Facepunch.Steamworks.OperatingSystem.Linux;
// //
// Edging our bets // Edging our bets
// //
if ( Environment.OSVersion.VersionString.ToLower().Contains( "unix" ) ) _os = OperatingSystem.Linux; if ( Environment.OSVersion.VersionString.ToLower().Contains( "unix" ) ) _os = Facepunch.Steamworks.OperatingSystem.Linux;
if ( Environment.OSVersion.VersionString.ToLower().Contains( "osx" ) ) _os = OperatingSystem.Osx; if ( Environment.OSVersion.VersionString.ToLower().Contains( "osx" ) ) _os = Facepunch.Steamworks.OperatingSystem.Osx;
} }
return _os; return _os;
@ -56,19 +59,19 @@ namespace SteamNative
} }
} }
internal static Architecture Arch internal static Facepunch.Steamworks.Architecture Arch
{ {
get get
{ {
// //
// Work out whether we're 64bit or 32bit // Work out whether we're 64bit or 32bit
// //
if ( _arch == Architecture.Unset ) if ( _arch == Facepunch.Steamworks.Architecture.Unset )
{ {
if ( IntPtr.Size == 8 ) if ( IntPtr.Size == 8 )
_arch = Architecture.x64; _arch = Facepunch.Steamworks.Architecture.x64;
else if ( IntPtr.Size == 4 ) else if ( IntPtr.Size == 4 )
_arch = Architecture.x86; _arch = Facepunch.Steamworks.Architecture.x86;
else else
throw new System.Exception( "Unsupported Architecture!" ); throw new System.Exception( "Unsupported Architecture!" );
} }
@ -82,16 +85,17 @@ namespace SteamNative
} }
} }
public static bool IsWindows64 { get { return Arch == Architecture.x64 && Os == OperatingSystem.Windows; } } public static bool IsWindows { get { return Os == Facepunch.Steamworks.OperatingSystem.Windows; } }
public static bool IsWindows32 { get { return Arch == Architecture.x86 && Os == OperatingSystem.Windows; } } public static bool IsWindows64 { get { return Arch == Facepunch.Steamworks.Architecture.x64 && IsWindows; } }
public static bool IsLinux64 { get { return Arch == Architecture.x64 && Os == OperatingSystem.Linux; } } public static bool IsWindows32 { get { return Arch == Facepunch.Steamworks.Architecture.x86 && IsWindows; } }
public static bool IsLinux32 { get { return Arch == Architecture.x86 && Os == OperatingSystem.Linux; } } public static bool IsLinux64 { get { return Arch == Facepunch.Steamworks.Architecture.x64 && Os == Facepunch.Steamworks.OperatingSystem.Linux; } }
public static bool IsOsx { get { return Os == OperatingSystem.Osx; } } public static bool IsLinux32 { get { return Arch == Facepunch.Steamworks.Architecture.x86 && Os == Facepunch.Steamworks.OperatingSystem.Linux; } }
public static bool IsOsx { get { return Os == Facepunch.Steamworks.OperatingSystem.Osx; } }
/// <summary> /// <summary>
/// We're only Pack = 8 on Windows /// We're only Pack = 8 on Windows
/// </summary> /// </summary>
public static bool PackSmall { get { return Os != OperatingSystem.Windows; } } public static bool PackSmall { get { return Os != Facepunch.Steamworks.OperatingSystem.Windows; } }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -301,7 +301,7 @@ namespace Generator
WriteLine( "//" ); WriteLine( "//" );
WriteLine( "// The order of these functions are swapped on Windows" ); WriteLine( "// The order of these functions are swapped on Windows" );
WriteLine( "//" ); WriteLine( "//" );
StartBlock( "if ( Platform.Os == OperatingSystem.Windows )" ); StartBlock( "if ( Platform.IsWindows )" );
{ {
WriteLine( "vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB );" ); WriteLine( "vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB );" );
WriteLine( "vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA );" ); WriteLine( "vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA );" );