Steamworks.Data

This commit is contained in:
Garry Newman 2019-04-16 14:38:10 +01:00
parent 51b2b7dee2
commit 8e97489def
35 changed files with 89 additions and 71 deletions

View File

@ -22,7 +22,7 @@ namespace Steamworks
// //
// Init Server // Init Server
// //
var serverInit = new ServerInit( "gmod", "Garry Mode" ) var serverInit = new SteamServerInit( "gmod", "Garry Mode" )
{ {
GamePort = 28015, GamePort = 28015,
Secure = true, Secure = true,

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamApps : BaseSteamInterface internal class ISteamApps : BaseSteamInterface
{ {
public ISteamApps( bool server = false ) : base( server ) public ISteamApps( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamFriends : BaseSteamInterface internal class ISteamFriends : BaseSteamInterface
{ {
public ISteamFriends( bool server = false ) : base( server ) public ISteamFriends( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamGameServer : BaseSteamInterface internal class ISteamGameServer : BaseSteamInterface
{ {
public ISteamGameServer( bool server = false ) : base( server ) public ISteamGameServer( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamMatchmakingServers : BaseSteamInterface internal class ISteamMatchmakingServers : BaseSteamInterface
{ {
public ISteamMatchmakingServers( bool server = false ) : base( server ) public ISteamMatchmakingServers( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamMusic : BaseSteamInterface internal class ISteamMusic : BaseSteamInterface
{ {
public ISteamMusic( bool server = false ) : base( server ) public ISteamMusic( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamParentalSettings : BaseSteamInterface internal class ISteamParentalSettings : BaseSteamInterface
{ {
public ISteamParentalSettings( bool server = false ) : base( server ) public ISteamParentalSettings( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamUser : BaseSteamInterface internal class ISteamUser : BaseSteamInterface
{ {
public ISteamUser( bool server = false ) : base( server ) public ISteamUser( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamUtils : BaseSteamInterface internal class ISteamUtils : BaseSteamInterface
{ {
public ISteamUtils( bool server = false ) : base( server ) public ISteamUtils( bool server = false ) : base( server )
{ {

View File

@ -2,11 +2,12 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks.Internal namespace Steamworks
{ {
public class ISteamVideo : BaseSteamInterface internal class ISteamVideo : BaseSteamInterface
{ {
public ISteamVideo( bool server = false ) : base( server ) public ISteamVideo( bool server = false ) : base( server )
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {
@ -14,13 +15,13 @@ namespace Steamworks
#region ISteamMatchmakingServers #region ISteamMatchmakingServers
static Internal.ISteamMatchmakingServers _internal; static ISteamMatchmakingServers _internal;
internal static Internal.ISteamMatchmakingServers Internal internal static ISteamMatchmakingServers Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamMatchmakingServers(); _internal = new ISteamMatchmakingServers();
return _internal; return _internal;
} }

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {
@ -12,13 +13,13 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamApps public static class SteamApps
{ {
static Internal.ISteamApps _internal; static ISteamApps _internal;
internal static Internal.ISteamApps Internal internal static ISteamApps Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamApps(); _internal = new ISteamApps();
return _internal; return _internal;
} }

View File

@ -11,14 +11,14 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamFriends public static class SteamFriends
{ {
static Internal.ISteamFriends _internal; static ISteamFriends _internal;
internal static Internal.ISteamFriends Internal internal static ISteamFriends Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
{ {
_internal = new Internal.ISteamFriends(); _internal = new ISteamFriends();
richPresence = new Dictionary<string, string>(); richPresence = new Dictionary<string, string>();
} }
@ -193,19 +193,19 @@ namespace Steamworks
await Task.Delay( 500 ); await Task.Delay( 500 );
} }
public static async Task<Image?> GetSmallAvatarAsync( SteamId steamid ) public static async Task<Data.Image?> GetSmallAvatarAsync( SteamId steamid )
{ {
await CacheUserInformationAsync( steamid, false ); await CacheUserInformationAsync( steamid, false );
return SteamUtils.GetImage( Internal.GetSmallFriendAvatar( steamid ) ); return SteamUtils.GetImage( Internal.GetSmallFriendAvatar( steamid ) );
} }
public static async Task<Image?> GetMediumAvatarAsync( SteamId steamid ) public static async Task<Data.Image?> GetMediumAvatarAsync( SteamId steamid )
{ {
await CacheUserInformationAsync( steamid, false ); await CacheUserInformationAsync( steamid, false );
return SteamUtils.GetImage( Internal.GetMediumFriendAvatar( steamid ) ); return SteamUtils.GetImage( Internal.GetMediumFriendAvatar( steamid ) );
} }
public static async Task<Image?> GetLargeAvatarAsync( SteamId steamid ) public static async Task<Data.Image?> GetLargeAvatarAsync( SteamId steamid )
{ {
await CacheUserInformationAsync( steamid, false ); await CacheUserInformationAsync( steamid, false );

View File

@ -11,13 +11,13 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamMusic public static class SteamMusic
{ {
static Internal.ISteamMusic _internal; static ISteamMusic _internal;
internal static Internal.ISteamMusic Internal internal static ISteamMusic Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamMusic(); _internal = new ISteamMusic();
return _internal; return _internal;
} }

View File

@ -11,13 +11,13 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamParental public static class SteamParental
{ {
static Internal.ISteamParentalSettings _internal; static ISteamParentalSettings _internal;
internal static Internal.ISteamParentalSettings Internal internal static ISteamParentalSettings Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamParentalSettings(); _internal = new ISteamParentalSettings();
return _internal; return _internal;
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks namespace Steamworks
{ {
@ -13,13 +14,13 @@ namespace Steamworks
{ {
static bool initialized; static bool initialized;
static Internal.ISteamGameServer _internal; static ISteamGameServer _internal;
internal static Internal.ISteamGameServer Internal internal static ISteamGameServer Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamGameServer( true ); _internal = new ISteamGameServer( true );
return _internal; return _internal;
} }
@ -37,7 +38,7 @@ namespace Steamworks
/// </summary> /// </summary>
public static event Action<SteamId, SteamId, AuthResponse> OnValidateAuthTicketResponse; public static event Action<SteamId, SteamId, AuthResponse> OnValidateAuthTicketResponse;
public static void Init( AppId appid, ServerInit init ) public static void Init( AppId appid, SteamServerInit init )
{ {
uint ipaddress = 0; // Any Port uint ipaddress = 0; // Any Port

View File

@ -13,14 +13,14 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamUser public static class SteamUser
{ {
static Internal.ISteamUser _internal; static ISteamUser _internal;
internal static Internal.ISteamUser Internal internal static ISteamUser Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
{ {
_internal = new Internal.ISteamUser(); _internal = new ISteamUser();
richPresence = new Dictionary<string, string>(); richPresence = new Dictionary<string, string>();

View File

@ -11,13 +11,13 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamUtils public static class SteamUtils
{ {
static Internal.ISteamUtils _internal; static ISteamUtils _internal;
internal static Internal.ISteamUtils Internal internal static ISteamUtils Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamUtils(); _internal = new ISteamUtils();
return _internal; return _internal;
} }
@ -91,9 +91,9 @@ namespace Steamworks
/// <summary> /// <summary>
/// returns the image in RGBA format /// returns the image in RGBA format
/// </summary> /// </summary>
public static Image? GetImage( int image ) public static Data.Image? GetImage( int image )
{ {
var i = new Image(); var i = new Data.Image();
if ( !GetImageSize( image, out i.Width, out i.Height ) ) if ( !GetImageSize( image, out i.Width, out i.Height ) )
return null; return null;

View File

@ -11,13 +11,13 @@ namespace Steamworks
/// </summary> /// </summary>
public static class SteamVideo public static class SteamVideo
{ {
static Internal.ISteamVideo _internal; static ISteamVideo _internal;
internal static Internal.ISteamVideo Internal internal static ISteamVideo Internal
{ {
get get
{ {
if ( _internal == null ) if ( _internal == null )
_internal = new Internal.ISteamVideo(); _internal = new ISteamVideo();
return _internal; return _internal;
} }

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks namespace Steamworks.Data
{ {
public struct DlcInformation public struct DlcInformation
{ {

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks namespace Steamworks.Data
{ {
public struct DownloadProgress public struct DownloadProgress
{ {

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks namespace Steamworks.Data
{ {
public struct FileDetails public struct FileDetails
{ {

View File

@ -101,17 +101,17 @@ namespace Steamworks
} }
} }
public async Task<Image?> GetSmallAvatarAsync() public async Task<Data.Image?> GetSmallAvatarAsync()
{ {
return await SteamFriends.GetSmallAvatarAsync( Id ); return await SteamFriends.GetSmallAvatarAsync( Id );
} }
public async Task<Image?> GetMediumAvatarAsync() public async Task<Data.Image?> GetMediumAvatarAsync()
{ {
return await SteamFriends.GetMediumAvatarAsync( Id ); return await SteamFriends.GetMediumAvatarAsync( Id );
} }
public async Task<Image?> GetLargeAvatarAsync() public async Task<Data.Image?> GetLargeAvatarAsync()
{ {
return await SteamFriends.GetLargeAvatarAsync( Id ); return await SteamFriends.GetLargeAvatarAsync( Id );
} }

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks namespace Steamworks.Data
{ {
public struct GameId public struct GameId
{ {

View File

@ -1,5 +1,5 @@
 
namespace Steamworks namespace Steamworks.Data
{ {
public struct Image public struct Image
{ {

View File

@ -1,4 +1,4 @@
namespace Steamworks namespace Steamworks.Data
{ {
/// <summary> /// <summary>
/// A server query packet. /// A server query packet.

View File

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks namespace Steamworks.Data
{ {
public struct ServerInfo public struct ServerInfo
{ {

View File

@ -11,7 +11,7 @@ namespace Steamworks
/// Used to set up the server. /// Used to set up the server.
/// The variables in here are all required to be set, and can't be changed once the server is created. /// The variables in here are all required to be set, and can't be changed once the server is created.
/// </summary> /// </summary>
public struct ServerInit public struct SteamServerInit
{ {
public IPAddress IpAddress; public IPAddress IpAddress;
public ushort SteamPort; public ushort SteamPort;
@ -37,7 +37,7 @@ namespace Steamworks
public string GameDescription; public string GameDescription;
public ServerInit( string modDir, string gameDesc ) public SteamServerInit( string modDir, string gameDesc )
{ {
ModDir = modDir; ModDir = modDir;
GameDescription = gameDesc; GameDescription = gameDesc;
@ -54,7 +54,7 @@ namespace Steamworks
/// <summary> /// <summary>
/// Set the Steam quert port /// Set the Steam quert port
/// </summary> /// </summary>
public ServerInit WithRandomSteamPort() public SteamServerInit WithRandomSteamPort()
{ {
SteamPort = (ushort)new Random().Next( 10000, 60000 ); SteamPort = (ushort)new Random().Next( 10000, 60000 );
return this; return this;
@ -67,7 +67,7 @@ namespace Steamworks
/// ///
/// More info about this here: https://partner.steamgames.com/doc/api/ISteamGameServer#HandleIncomingPacket /// More info about this here: https://partner.steamgames.com/doc/api/ISteamGameServer#HandleIncomingPacket
/// </summary> /// </summary>
public ServerInit WithQueryShareGamePort() public SteamServerInit WithQueryShareGamePort()
{ {
QueryPort = 0xFFFF; QueryPort = 0xFFFF;
return this; return this;

View File

@ -7,9 +7,9 @@ using System.Net.Sockets;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Steamworks.Internal namespace Steamworks
{ {
public abstract class BaseSteamInterface internal abstract class BaseSteamInterface
{ {
public IntPtr Self; public IntPtr Self;
public IntPtr VTable; public IntPtr VTable;

View File

@ -18,13 +18,14 @@ namespace Generator
WriteLine( $"using System.Runtime.InteropServices;" ); WriteLine( $"using System.Runtime.InteropServices;" );
WriteLine( $"using System.Text;" ); WriteLine( $"using System.Text;" );
WriteLine( $"using System.Threading.Tasks;" ); WriteLine( $"using System.Threading.Tasks;" );
WriteLine( $"using Steamworks.Data;" );
WriteLine(); WriteLine();
WriteLine(); WriteLine();
StartBlock( $"namespace Steamworks.Internal" ); StartBlock( $"namespace Steamworks" );
{ {
StartBlock( $"public class {clss.Name} : BaseSteamInterface" ); StartBlock( $"internal class {clss.Name} : BaseSteamInterface" );
{ {
StartBlock( $"public {clss.Name}( bool server = false ) : base( server )" ); StartBlock( $"public {clss.Name}( bool server = false ) : base( server )" );
{ {

View File

@ -111,6 +111,7 @@ namespace Generator
WriteLine( "using System;" ); WriteLine( "using System;" );
WriteLine( "using System.Runtime.InteropServices;" ); WriteLine( "using System.Runtime.InteropServices;" );
WriteLine( "using System.Linq;" ); WriteLine( "using System.Linq;" );
WriteLine( "using Steamworks.Data;" );
WriteLine(); WriteLine();
StartBlock( "namespace " + NamespaceName ); StartBlock( "namespace " + NamespaceName );
} }