diff --git a/Facepunch.Steamworks/Enum/LeaderboardDisplay.cs b/Facepunch.Steamworks/Enum/LeaderboardDisplay.cs
new file mode 100644
index 0000000..6002297
--- /dev/null
+++ b/Facepunch.Steamworks/Enum/LeaderboardDisplay.cs
@@ -0,0 +1,20 @@
+namespace Steamworks.Data
+{
+ public enum LeaderboardDisplay : int
+ {
+ ///
+ /// The score is just a simple numerical value
+ ///
+ Numeric = 1,
+
+ ///
+ /// The score represents a time, in seconds
+ ///
+ TimeSeconds = 2,
+
+ ///
+ /// The score represents a time, in milliseconds
+ ///
+ TimeMilliSeconds = 3,
+ }
+}
\ No newline at end of file
diff --git a/Facepunch.Steamworks/Enum/LeaderboardSort.cs b/Facepunch.Steamworks/Enum/LeaderboardSort.cs
new file mode 100644
index 0000000..4826965
--- /dev/null
+++ b/Facepunch.Steamworks/Enum/LeaderboardSort.cs
@@ -0,0 +1,15 @@
+namespace Steamworks.Data
+{
+ public enum LeaderboardSort : int
+ {
+ ///
+ /// The top-score is the lowest number
+ ///
+ Ascending = 1,
+
+ ///
+ /// The top-score is the highest number
+ ///
+ Descending = 2,
+ }
+}
\ No newline at end of file
diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
index f3a20e8..576a3e8 100644
--- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
+++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs
@@ -323,11 +323,11 @@ namespace Steamworks
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
- private delegate SteamAPICall_t FindOrCreateLeaderboardDelegate( IntPtr self, string pchLeaderboardName, LeaderboardSortMethod eLeaderboardSortMethod, LeaderboardDisplayType eLeaderboardDisplayType );
+ private delegate SteamAPICall_t FindOrCreateLeaderboardDelegate( IntPtr self, string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType );
private FindOrCreateLeaderboardDelegate FindOrCreateLeaderboardDelegatePointer;
#endregion
- internal async Task FindOrCreateLeaderboard( string pchLeaderboardName, LeaderboardSortMethod eLeaderboardSortMethod, LeaderboardDisplayType eLeaderboardDisplayType )
+ internal async Task FindOrCreateLeaderboard( string pchLeaderboardName, LeaderboardSort eLeaderboardSortMethod, LeaderboardDisplay eLeaderboardDisplayType )
{
return await (new Result( FindOrCreateLeaderboardDelegatePointer( Self, pchLeaderboardName, eLeaderboardSortMethod, eLeaderboardDisplayType ) )).GetResult();
}
@@ -367,22 +367,22 @@ namespace Steamworks
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
- private delegate LeaderboardSortMethod GetLeaderboardSortMethodDelegate( IntPtr self, SteamLeaderboard_t hSteamLeaderboard );
+ private delegate LeaderboardSort GetLeaderboardSortMethodDelegate( IntPtr self, SteamLeaderboard_t hSteamLeaderboard );
private GetLeaderboardSortMethodDelegate GetLeaderboardSortMethodDelegatePointer;
#endregion
- internal LeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard )
+ internal LeaderboardSort GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard )
{
return GetLeaderboardSortMethodDelegatePointer( Self, hSteamLeaderboard );
}
#region FunctionMeta
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
- private delegate LeaderboardDisplayType GetLeaderboardDisplayTypeDelegate( IntPtr self, SteamLeaderboard_t hSteamLeaderboard );
+ private delegate LeaderboardDisplay GetLeaderboardDisplayTypeDelegate( IntPtr self, SteamLeaderboard_t hSteamLeaderboard );
private GetLeaderboardDisplayTypeDelegate GetLeaderboardDisplayTypeDelegatePointer;
#endregion
- internal LeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard )
+ internal LeaderboardDisplay GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard )
{
return GetLeaderboardDisplayTypeDelegatePointer( Self, hSteamLeaderboard );
}
diff --git a/Facepunch.Steamworks/Generated/SteamEnums.cs b/Facepunch.Steamworks/Generated/SteamEnums.cs
index 6784701..b5f3c26 100644
--- a/Facepunch.Steamworks/Generated/SteamEnums.cs
+++ b/Facepunch.Steamworks/Generated/SteamEnums.cs
@@ -904,24 +904,9 @@ namespace Steamworks
//
// ELeaderboardSortMethod
//
- internal enum LeaderboardSortMethod : int
- {
- None = 0,
- Ascending = 1,
- Descending = 2,
- }
-
//
// ELeaderboardDisplayType
//
- internal enum LeaderboardDisplayType : int
- {
- None = 0,
- Numeric = 1,
- TimeSeconds = 2,
- TimeMilliSeconds = 3,
- }
-
//
// ELeaderboardUploadScoreMethod
//
diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs
index b62247b..822ab3b 100644
--- a/Facepunch.Steamworks/SteamUserStats.cs
+++ b/Facepunch.Steamworks/SteamUserStats.cs
@@ -101,5 +101,33 @@ namespace Steamworks
{
return Internal.RequestCurrentStats();
}
+
+ ///
+ /// Gets a leaderboard by name, it will create it if it's not yet created.
+ /// Leaderboards created with this function will not automatically show up in the Steam Community.
+ /// You must manually set the Community Name field in the App Admin panel of the Steamworks website.
+ /// As such it's generally recommended to prefer creating the leaderboards in the App Admin panel on
+ /// the Steamworks website and using FindLeaderboard unless you're expected to have a large amount of
+ /// dynamically created leaderboards.
+ ///
+ public static async Task FindOrCreateLeaderboard( string name, LeaderboardSort sort, LeaderboardDisplay display )
+ {
+ var result = await Internal.FindOrCreateLeaderboard( name, sort, display );
+ if ( !result.HasValue || result.Value.LeaderboardFound == 0 )
+ return null;
+
+ return new Leaderboard { Id = result.Value.SteamLeaderboard };
+ }
+
+
+ public static async Task FindLeaderboard( string name )
+ {
+ var result = await Internal.FindLeaderboard( name );
+ if ( !result.HasValue || result.Value.LeaderboardFound == 0 )
+ return null;
+
+ return new Leaderboard { Id = result.Value.SteamLeaderboard };
+ }
+
}
}
\ No newline at end of file
diff --git a/Facepunch.Steamworks/Structs/Leaderboard.cs b/Facepunch.Steamworks/Structs/Leaderboard.cs
new file mode 100644
index 0000000..8e52548
--- /dev/null
+++ b/Facepunch.Steamworks/Structs/Leaderboard.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Steamworks.Data
+{
+ public struct Leaderboard
+ {
+ internal SteamLeaderboard_t Id;
+ }
+}
\ No newline at end of file
diff --git a/Generator/Cleanup.cs b/Generator/Cleanup.cs
index 54a454f..6d43299 100644
--- a/Generator/Cleanup.cs
+++ b/Generator/Cleanup.cs
@@ -18,9 +18,9 @@ public static class Cleanup
type = type.Replace( "FriendRelationship", "Relationship" );
type = type.Replace( "BeginAuthSessionResult", "BeginAuthResult" );
type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
-
-
-
+ type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
+ type = type.Replace( "LeaderboardSortMethod", "LeaderboardSort" );
+ type = type.Replace( "LeaderboardDisplayType", "LeaderboardDisplay" );
return type;
}
@@ -28,6 +28,8 @@ public static class Cleanup
public static bool ShouldCreate( string type )
{
if ( type == "SteamId" ) return false;
+ if ( type == "LeaderboardSort" ) return false;
+ if ( type == "LeaderboardDisplay" ) return false;
return true;
diff --git a/Generator/CodeWriter/Enums.cs b/Generator/CodeWriter/Enums.cs
index df1be96..cc5c6be 100644
--- a/Generator/CodeWriter/Enums.cs
+++ b/Generator/CodeWriter/Enums.cs
@@ -27,6 +27,9 @@ namespace Generator
name = Cleanup.ConvertType( name );
+ if ( !Cleanup.ShouldCreate( name ) )
+ continue;
+
StartBlock( $"{Cleanup.Expose( name )} enum {name} : int" );
{
//