Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "CodeGen",
"type": "debugpy",
"request": "launch",
"program": "./Steamworks.NET_CodeGen.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/CodeGen/"
}
]
}
17 changes: 17 additions & 0 deletions CodeGen/src/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,23 @@ def parse_func(f, interface, func):
if c:
g_Output.append("\t\t/// <para>" + c + "</para>")
g_Output.append("\t\t/// </summary>")

strAsyncType: str = None
strAsyncStruct: str = None

for attr in func.attributes:
if attr.name in ("STEAM_CALL_RESULT", "STEAM_CALL_BACK"):
if attr.name == "STEAM_CALL_RESULT":
strAsyncType = "CallResult"
elif attr.name == "STEAM_CALL_BACK":
strAsyncType = "Callback"
strAsyncStruct = attr.value


if strAsyncType is not None:
g_Output.append(f"\t\t[SteamHasAsync{strAsyncType}(typeof({strAsyncStruct}))]")


g_Output.append("\t\tpublic static " + wrapperreturntype + " " + func.name.rstrip("0") + "(" + wrapperargs + ") {")

g_Output.extend(functionBody)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2022 Riley Labrecque
// Please see the included LICENSE.txt for additional information.

// This file is automatically generated.
// Changes to this file will be reverted when you update Steamworks.NET

#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif

#if !DISABLESTEAMWORKS

namespace Steamworks {
/// <summary>
/// Inform invokers use <see cref="CallResult{T}"/> to receive async result.
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public sealed class SteamHasAsyncCallResultAttribute : System.Attribute {
private System.Type callbackType; // for vs project ignore suggestion IDE0044, I'm not sure if Unity supports readonly field

// See the attribute guidelines at
// http://go.microsoft.com/fwlink/?LinkId=85236

internal SteamHasAsyncCallResultAttribute(System.Type callbackType) {
this.callbackType = callbackType;
}

/// <summary>
/// Result type of the async operation.
/// </summary>
public System.Type CallbackType { get { return callbackType; } }
}

/// <summary>
/// Inform invokers use <see cref="Callback{T}"/> to receive async result.
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public sealed class SteamHasAsyncCallbackAttribute : System.Attribute {
private System.Type callbackType; // for vs project ignore suggestion IDE0044, I'm not sure if Unity supports readonly field

// See the attribute guidelines at
// http://go.microsoft.com/fwlink/?LinkId=85236

internal SteamHasAsyncCallbackAttribute(System.Type callbackType) {
this.callbackType = callbackType;
}

/// <summary>
/// Result type of the async operation.
/// </summary>
public System.Type CallbackType { get { return callbackType; } }
}
}

#endif // !DISABLESTEAMWORKS
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public static void RequestAllProofOfPurchaseKeys() {
NativeMethods.ISteamApps_RequestAllProofOfPurchaseKeys(CSteamAPIContext.GetSteamApps());
}

[SteamHasAsyncCallResult(typeof(FileDetailsResult_t))]
public static SteamAPICall_t GetFileDetails(string pszFileName) {
InteropHelp.TestIfAvailableClient();
using (var pszFileName2 = new InteropHelp.UTF8StringHandle(pszFileName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static string GetPersonaName() {
/// <para> If the name change fails to happen on the server, then an additional global PersonaStateChange_t will be posted</para>
/// <para> to change the name back, in addition to the SetPersonaNameResponse_t callback.</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(SetPersonaNameResponse_t))]
public static SteamAPICall_t SetPersonaName(string pchPersonaName) {
InteropHelp.TestIfAvailableClient();
using (var pchPersonaName2 = new InteropHelp.UTF8StringHandle(pchPersonaName)) {
Expand Down Expand Up @@ -215,6 +216,7 @@ public static bool GetClanActivityCounts(CSteamID steamIDClan, out int pnOnline,
/// <summary>
/// <para> for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(DownloadClanActivityCountsResult_t))]
public static SteamAPICall_t DownloadClanActivityCounts(CSteamID[] psteamIDClans, int cClansToRequest) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_DownloadClanActivityCounts(CSteamAPIContext.GetSteamFriends(), psteamIDClans, cClansToRequest);
Expand Down Expand Up @@ -365,6 +367,7 @@ public static bool RequestUserInformation(CSteamID steamIDUser, bool bRequireNam
/// <para> note that this won't download avatars automatically; if you get an officer,</para>
/// <para> and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(ClanOfficerListResponse_t))]
public static SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_RequestClanOfficerList(CSteamAPIContext.GetSteamFriends(), steamIDClan);
Expand Down Expand Up @@ -504,6 +507,7 @@ public static AppId_t GetFriendCoplayGame(CSteamID steamIDFriend) {
/// <para> the behavior is somewhat sophisticated, because the user may or may not be already in the group chat from outside the game or in the overlay</para>
/// <para> use ActivateGameOverlayToUser( "chat", steamIDClan ) to open the in-game overlay version of the chat</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(JoinClanChatRoomCompletionResult_t))]
public static SteamAPICall_t JoinClanChatRoom(CSteamID steamIDClan) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_JoinClanChatRoom(CSteamAPIContext.GetSteamFriends(), steamIDClan);
Expand Down Expand Up @@ -591,16 +595,19 @@ public static int GetFriendMessage(CSteamID steamIDFriend, int iMessageID, out s
/// <summary>
/// <para> following apis</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(FriendsGetFollowerCount_t))]
public static SteamAPICall_t GetFollowerCount(CSteamID steamID) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_GetFollowerCount(CSteamAPIContext.GetSteamFriends(), steamID);
}

[SteamHasAsyncCallResult(typeof(FriendsIsFollowing_t))]
public static SteamAPICall_t IsFollowing(CSteamID steamID) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_IsFollowing(CSteamAPIContext.GetSteamFriends(), steamID);
}

[SteamHasAsyncCallResult(typeof(FriendsEnumerateFollowingList_t))]
public static SteamAPICall_t EnumerateFollowingList(uint unStartIndex) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_EnumerateFollowingList(CSteamAPIContext.GetSteamFriends(), unStartIndex);
Expand Down Expand Up @@ -663,6 +670,7 @@ public static void ActivateGameOverlayInviteDialogConnectString(string pchConnec
/// <para> Steam Community items equipped by a user on their profile</para>
/// <para> You can register for EquippedProfileItemsChanged_t to know when a friend has changed their equipped profile items</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(EquippedProfileItems_t))]
public static SteamAPICall_t RequestEquippedProfileItems(CSteamID steamID) {
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_RequestEquippedProfileItems(CSteamAPIContext.GetSteamFriends(), steamID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ public static void GetGameplayStats() {
NativeMethods.ISteamGameServer_GetGameplayStats(CSteamGameServerAPIContext.GetSteamGameServer());
}

[SteamHasAsyncCallResult(typeof(GSReputation_t))]
public static SteamAPICall_t GetServerReputation() {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_GetServerReputation(CSteamGameServerAPIContext.GetSteamGameServer());
Expand Down Expand Up @@ -380,6 +381,7 @@ public static int GetNextOutgoingPacket(byte[] pOut, int cbMaxOut, out uint pNet
/// <para> Server clan association</para>
/// <para> associate this game server with this clan for the purposes of computing player compat</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(AssociateWithClanResult_t))]
public static SteamAPICall_t AssociateWithClan(CSteamID steamIDClan) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_AssociateWithClan(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDClan);
Expand All @@ -388,6 +390,7 @@ public static SteamAPICall_t AssociateWithClan(CSteamID steamIDClan) {
/// <summary>
/// <para> ask if any of the current players dont want to play with this new player - or vice versa</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(ComputeNewPlayerCompatibilityResult_t))]
public static SteamAPICall_t ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_ComputeNewPlayerCompatibility(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDNewPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public static bool GetItemDefinitionProperty(SteamItemDef_t iDefinition, string
/// <para> user. These are promo items of type "manual" that won't be granted automatically.</para>
/// <para> An example usage of this is an item that becomes available every week.</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(SteamInventoryEligiblePromoItemDefIDs_t))]
public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID steamID) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID);
Expand All @@ -360,6 +361,7 @@ public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItem
/// <para> Once the purchase has been authorized and completed by the user, the callback SteamInventoryResultReady_t</para>
/// <para> will be posted.</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(SteamInventoryStartPurchaseResult_t))]
public static SteamAPICall_t StartPurchase(SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_StartPurchase(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, punArrayQuantity, unArrayLength);
Expand All @@ -368,6 +370,7 @@ public static SteamAPICall_t StartPurchase(SteamItemDef_t[] pArrayItemDefs, uint
/// <summary>
/// <para> Request current prices for all applicable item definitions</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(SteamInventoryRequestPricesResult_t))]
public static SteamAPICall_t RequestPrices() {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestPrices(CSteamGameServerAPIContext.GetSteamInventory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static class SteamGameServerStats {
/// <para> these stats will only be auto-updated for clients playing on the server. For other</para>
/// <para> users you'll need to call RequestUserStats() again to refresh any data</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(GSStatsReceived_t))]
public static SteamAPICall_t RequestUserStats(CSteamID steamIDUser) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_RequestUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser);
Expand Down Expand Up @@ -100,6 +101,7 @@ public static bool ClearUserAchievement(CSteamID steamIDUser, string pchName) {
/// <para> or were out of date. In this case the server sends back updated values.</para>
/// <para> The stats should be re-iterated to keep in sync.</para>
/// </summary>
[SteamHasAsyncCallResult(typeof(GSStatsStored_t))]
public static SteamAPICall_t StoreUserStats(CSteamID steamIDUser) {
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_StoreUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser);
Expand Down
Loading