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 @@ public static void AssemblyInit( TestContext context )
//
// Init Server
//
var serverInit = new ServerInit( "gmod", "Garry Mode" )
var serverInit = new SteamServerInit( "gmod", "Garry Mode" )
{
GamePort = 28015,
Secure = true,

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

@ -2,11 +2,12 @@
using System.Runtime.InteropServices;
using System.Text;
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 )
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,14 +11,14 @@ namespace Steamworks
/// </summary>
public static class SteamFriends
{
static Internal.ISteamFriends _internal;
internal static Internal.ISteamFriends Internal
static ISteamFriends _internal;
internal static ISteamFriends Internal
{
get
{
if ( _internal == null )
{
_internal = new Internal.ISteamFriends();
_internal = new ISteamFriends();
richPresence = new Dictionary<string, string>();
}
@ -193,19 +193,19 @@ static async Task CacheUserInformationAsync( SteamId steamid, bool nameonly )
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 );
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 );
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 );

View File

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

View File

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

View File

@ -3,6 +3,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Steamworks.Data;
namespace Steamworks
{
@ -13,13 +14,13 @@ public static partial class SteamServer
{
static bool initialized;
static Internal.ISteamGameServer _internal;
internal static Internal.ISteamGameServer Internal
static ISteamGameServer _internal;
internal static ISteamGameServer Internal
{
get
{
if ( _internal == null )
_internal = new Internal.ISteamGameServer( true );
_internal = new ISteamGameServer( true );
return _internal;
}
@ -37,7 +38,7 @@ internal static void InstallEvents()
/// </summary>
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

View File

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

View File

@ -11,13 +11,13 @@ namespace Steamworks
/// </summary>
public static class SteamUtils
{
static Internal.ISteamUtils _internal;
internal static Internal.ISteamUtils Internal
static ISteamUtils _internal;
internal static ISteamUtils Internal
{
get
{
if ( _internal == null )
_internal = new Internal.ISteamUtils();
_internal = new ISteamUtils();
return _internal;
}
@ -91,9 +91,9 @@ public static bool GetImageSize( int image, out uint width, out uint height )
/// <summary>
/// returns the image in RGBA format
/// </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 ) )
return null;

View File

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

View File

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

View File

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

View File

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

View File

@ -101,17 +101,17 @@ internal static FriendGameInfo From( FriendGameInfo_t i )
}
}
public async Task<Image?> GetSmallAvatarAsync()
public async Task<Data.Image?> GetSmallAvatarAsync()
{
return await SteamFriends.GetSmallAvatarAsync( Id );
}
public async Task<Image?> GetMediumAvatarAsync()
public async Task<Data.Image?> GetMediumAvatarAsync()
{
return await SteamFriends.GetMediumAvatarAsync( Id );
}
public async Task<Image?> GetLargeAvatarAsync()
public async Task<Data.Image?> GetLargeAvatarAsync()
{
return await SteamFriends.GetLargeAvatarAsync( Id );
}

View File

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

View File

@ -1,5 +1,5 @@

namespace Steamworks
namespace Steamworks.Data
{
public struct Image
{

View File

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

View File

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

View File

@ -11,7 +11,7 @@ namespace Steamworks
/// 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.
/// </summary>
public struct ServerInit
public struct SteamServerInit
{
public IPAddress IpAddress;
public ushort SteamPort;
@ -37,7 +37,7 @@ public struct ServerInit
public string GameDescription;
public ServerInit( string modDir, string gameDesc )
public SteamServerInit( string modDir, string gameDesc )
{
ModDir = modDir;
GameDescription = gameDesc;
@ -54,7 +54,7 @@ public ServerInit( string modDir, string gameDesc )
/// <summary>
/// Set the Steam quert port
/// </summary>
public ServerInit WithRandomSteamPort()
public SteamServerInit WithRandomSteamPort()
{
SteamPort = (ushort)new Random().Next( 10000, 60000 );
return this;
@ -67,7 +67,7 @@ public ServerInit WithRandomSteamPort()
///
/// More info about this here: https://partner.steamgames.com/doc/api/ISteamGameServer#HandleIncomingPacket
/// </summary>
public ServerInit WithQueryShareGamePort()
public SteamServerInit WithQueryShareGamePort()
{
QueryPort = 0xFFFF;
return this;

View File

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

View File

@ -18,13 +18,14 @@ public void GenerateVTableClass( string className, string filename )
WriteLine( $"using System.Runtime.InteropServices;" );
WriteLine( $"using System.Text;" );
WriteLine( $"using System.Threading.Tasks;" );
WriteLine( $"using Steamworks.Data;" );
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 )" );
{

View File

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