Facepunch.Steamworks/Generator/Cleanup.cs

212 lines
8.8 KiB
C#
Raw Permalink Normal View History

2019-04-16 13:45:44 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public static class Cleanup
2019-04-27 16:25:54 +03:00
{
2019-04-16 13:45:44 +03:00
public static string ConvertType( string type )
{
2020-02-22 23:16:04 +03:00
type = type.Replace( "class ", "" );
type = type.Replace( "struct ", "" );
type = type.Replace( "unsigned long long", "uint64" );
type = type.Replace( "unsigned int", "uint" );
type = type.Replace( "uint32", "uint" );
type = type.Replace( "int32_t", "int" );
type = type.Replace( "int64_t", "long" );
2021-09-24 16:24:00 +03:00
type = type.Replace( "uint16", "ushort" );
2020-02-22 23:16:04 +03:00
2019-04-16 13:45:44 +03:00
type = type.Replace( "CSteamID", "SteamId" );
type = type.Replace( "CGameID", "GameId" );
2019-04-16 14:17:24 +03:00
type = type.Replace( "AudioPlayback_Status", "MusicStatus" );
type = type.Replace( "AuthSessionResponse", "AuthResponse" );
type = type.Replace( "FriendRelationship", "Relationship" );
type = type.Replace( "BeginAuthSessionResult", "BeginAuthResult" );
2019-04-16 18:37:49 +03:00
type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
2019-04-17 10:40:58 +03:00
type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
2019-04-26 16:29:36 +03:00
type = type.Replace( "AppId_t", "AppId" );
2019-04-17 10:40:58 +03:00
type = type.Replace( "LeaderboardSortMethod", "LeaderboardSort" );
type = type.Replace( "LeaderboardDisplayType", "LeaderboardDisplay" );
2019-04-26 15:46:12 +03:00
type = type.Replace( "UGCMatchingUGCType", "UgcType" );
2019-04-29 12:41:40 +03:00
type = type.Replace( "SteamItemInstanceID_t", "InventoryItemId" );
type = type.Replace( "SteamItemDef_t", "InventoryDefId" );
type = type.Replace( "ChatRoomEnterResponse", "RoomEnter" );
2020-02-24 11:58:09 +03:00
type = type.Replace( "SteamNetworkPingLocation_t", "NetPingLocation" );
2020-02-22 23:16:04 +03:00
type = type.Replace( "SteamNetworkingConfigValue_t", "NetKeyValue" );
2019-05-02 17:57:57 +03:00
type = type.Replace( "SteamNetworkingConfigValue", "NetConfig" );
2020-02-22 23:16:04 +03:00
type = type.Replace( "SteamNetworkingConfigScope", "NetConfigScope" );
2019-05-02 17:57:57 +03:00
type = type.Replace( "SteamNetworkingConfigDataType", "NetConfigType" );
2020-02-24 11:58:09 +03:00
type = type.Replace( "FSteamNetworkingSocketsDebugOutput", "NetDebugFunc" );
type = type.Replace( "SteamNetworkingErrMsg", "NetErrorMessage" );
type = type.Replace( "SteamNetConnectionEnd", "NetConnectionEnd" );
2019-05-06 15:34:41 +03:00
type = type.Replace( "HSteamNetConnection", "Connection" );
2019-05-02 22:41:45 +03:00
type = type.Replace( "HSteamListenSocket", "Socket" );
2019-05-06 15:34:41 +03:00
type = type.Replace( "SteamNetworkingIPAddr", "NetAddress" );
type = type.Replace( "SteamNetworkingIdentity", "NetIdentity" );
2019-05-02 23:40:39 +03:00
type = type.Replace( "SteamNetConnectionInfo_t", "ConnectionInfo" );
type = type.Replace( "SteamNetworkingConnectionState", "ConnectionState" );
2019-05-06 15:26:37 +03:00
type = type.Replace( "SteamNetworkingMicroseconds", "long" );
type = type.Replace( "SteamNetworkingSocketsDebugOutputType", "NetDebugOutput" );
2019-05-06 15:38:37 +03:00
type = type.Replace( "SteamNetworkingGetConfigValueResult", "NetConfigResult" );
2019-06-19 18:18:12 +03:00
type = type.Replace( "SteamInputType", "InputType" );
2019-06-20 12:41:57 +03:00
type = type.Replace( "InputDigitalActionData_t", "DigitalState" );
type = type.Replace( "InputAnalogActionData_t", "AnalogState" );
type = type.Replace( "InputMotionData_t", "MotionState" );
2019-07-02 14:08:02 +03:00
type = type.Replace( "MatchMakingKeyValuePair_t", "MatchMakingKeyValuePair" );
2020-02-22 23:16:04 +03:00
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" );
2021-11-22 15:23:07 +03:00
type = type.Replace( "SteamNetConnectionRealTimeStatus_t", "ConnectionStatus" );
type = type.Replace( "SteamNetConnectionRealTimeLaneStatus_t", "ConnectionLaneStatus" );
2021-09-24 16:24:00 +03:00
type = type.Replace( "SteamInputGlyphSize", "GlyphSize" );
2021-09-24 16:36:48 +03:00
type = type.Replace( "FloatingGamepadTextInputMode", "TextInputMode" );
2024-12-16 19:49:31 +03:00
type = type.Replace( "TimelineEventHandle_t", "TimelineEventHandle" );
2020-02-22 23:16:04 +03:00
type = type.Replace( "::", "." );
if ( type == "EPersonaState" ) return "EFriendState";
if ( type == "PersonaState" ) return "FriendState";
2019-04-16 13:45:44 +03:00
return type;
}
public static bool ShouldCreate( string type )
{
if ( IsDeprecated( type ) ) return false;
2019-04-16 13:45:44 +03:00
if ( type == "SteamId" ) return false;
2019-04-17 10:40:58 +03:00
if ( type == "LeaderboardSort" ) return false;
if ( type == "LeaderboardDisplay" ) return false;
2019-04-26 16:29:36 +03:00
if ( type == "AppId" ) return false;
2019-06-20 12:41:57 +03:00
if ( type == "AnalogState" ) return false;
if ( type == "DigitalState" ) return false;
if ( type == "MotionState" ) return false;
2019-07-02 14:08:02 +03:00
if ( type == "MatchMakingKeyValuePair" ) return false;
2020-02-22 23:16:04 +03:00
if ( type == "Connection" ) return false;
if ( type == "Socket" ) return false;
if ( type == "SteamNetworkingMicroseconds" ) return false;
2020-02-24 11:58:09 +03:00
if ( type == "NetDebugFunc" ) return false;
2020-02-22 23:16:04 +03:00
if ( type == "NetMsg" ) return false;
if ( type == "SteamDatagramErrMsg" ) return false;
if ( type == "ConnectionInfo" ) return false;
if ( type == "SteamNetworkingIPAddr" ) return false;
if ( type == "NetAddress" ) return false;
if ( type == "NetIdentity" ) return false;
if ( type == "SteamNetworkingErrMsg" ) return false;
if ( type == "NetKeyValue" ) return false;
if ( type == "SteamIPAddress" ) return false;
2020-02-24 11:58:09 +03:00
if ( type == "NetPingLocation" ) return false;
2020-02-22 23:16:04 +03:00
if ( type == "CSteamID" ) return false;
if ( type == "CSteamAPIContext" ) return false;
if ( type == "CCallResult" ) return false;
if ( type == "CCallback" ) return false;
if ( type == "ValvePackingSentinel_t" ) return false;
if ( type == "CCallbackBase" ) return false;
if ( type == "CSteamGameServerAPIContext" ) return false;
2020-08-20 16:46:08 +03:00
if ( type == "ConnectionStatus") return false;
2021-11-22 15:23:07 +03:00
if ( type == "ConnectionLaneStatus" ) return false;
2021-09-24 16:24:00 +03:00
if ( type == "SteamInputActionEventCallbackPointer" ) return false;
if ( type.StartsWith( "FnSteam" ) ) return false;
2019-04-16 13:45:44 +03:00
return true;
}
2019-04-16 14:17:24 +03:00
internal static string Expose( string name )
{
if ( name == "FriendState" ) return "public";
if ( name == "MusicStatus" ) return "public";
if ( name == "ParentalFeature" ) return "public";
if ( name == "AuthResponse" ) return "public";
if ( name == "Relationship" ) return "public";
if ( name == "BeginAuthResult" ) return "public";
if ( name == "Universe" ) return "public";
if ( name == "NotificationPosition" ) return "public";
if ( name == "GamepadTextInputMode" ) return "public";
if ( name == "GamepadTextInputLineMode" ) return "public";
if ( name == "CheckFileSignature" ) return "public";
if ( name == "BroadcastUploadResult" ) return "public";
2019-04-16 18:37:49 +03:00
if ( name == "PublishedFileId" ) return "public";
if ( name == "Result" ) return "public";
2019-04-26 15:46:12 +03:00
if ( name == "UgcType" ) return "public";
2019-04-29 12:41:40 +03:00
if ( name == "InventoryItemId" ) return "public";
if ( name == "InventoryDefId" ) return "public";
2019-05-01 00:45:37 +03:00
if ( name == "P2PSend" ) return "public";
if ( name == "RoomEnter" ) return "public";
if ( name == "P2PSessionError" ) return "public";
2019-06-19 18:18:12 +03:00
if ( name == "InputType" ) return "public";
2019-06-20 12:41:57 +03:00
if ( name == "InputSourceMode" ) return "public";
2019-12-04 14:15:58 +03:00
if ( name == "UserHasLicenseForAppResult" ) return "public";
2020-02-24 11:58:09 +03:00
if ( name == "NetPingLocation" ) return "public";
2020-02-22 23:16:04 +03:00
if ( name == "ConnectionState" ) return "public";
if ( name == "SteamNetworkingAvailability" ) return "public";
2020-02-23 21:58:50 +03:00
if ( name == "SteamDeviceFormFactor" ) return "public";
2020-02-23 22:09:31 +03:00
if ( name == "DurationControlProgress" ) return "public";
2020-02-24 11:58:09 +03:00
if ( name == "NetConnectionEnd" ) return "public";
2020-02-24 13:14:31 +03:00
if ( name == "NetIdentity" ) return "public";
if ( name == "NetAddress" ) return "public";
if ( name == "NetDebugOutput" ) return "public";
2020-09-04 12:34:33 +03:00
if ( name == "ItemPreviewType" ) return "public";
2020-09-04 12:35:22 +03:00
if ( name == "OverlayToStoreFlag" ) return "public";
if ( name == "TextFilteringContext" ) return "public";
2021-09-24 16:24:00 +03:00
if ( name == "GlyphSize" ) return "public";
2021-09-24 16:36:48 +03:00
if ( name == "TextInputMode" ) return "public";
2024-12-16 19:49:31 +03:00
if ( name == "TimelineGameMode" ) return "public";
if ( name == "TimelineEventClipPriority" ) return "public";
if ( name == "TimelineEventHandle" ) return "public";
2019-04-16 14:17:24 +03:00
return "internal";
}
2019-04-27 16:25:54 +03:00
internal static bool IsDeprecated( string name )
{
2020-02-27 12:49:58 +03:00
if ( name.StartsWith( "PS3" ) ) return true;
if ( name == "SocketStatusCallback_t" ) return true;
if ( name == "SNetSocketConnectionType" ) return true;
if ( name == "SNetSocketState" ) return true;
2021-09-24 16:24:00 +03:00
2020-02-27 12:49:58 +03:00
2021-09-24 16:24:00 +03:00
if ( name.StartsWith( "ISteamInput." ) )
{
if ( name.Contains( "EnableActionEventCallbacks" ) ) return true;
if ( name.Contains( "DualSense" ) ) return true;
2021-09-24 16:24:00 +03:00
}
2019-04-27 16:25:54 +03:00
if ( name.StartsWith( "ISteamRemoteStorage." ) )
{
if ( name.Contains( "Publish" ) ) return true;
if ( name.Contains( "ResetFileRequestState" ) ) return true;
if ( name.Contains( "EnumerateUserSubscribedFiles" ) ) return true;
if ( name.Contains( "EnumerateUserSharedWorkshopFile" ) ) return true;
}
//
// In ISteamNetworking everything is deprecated apart from the p2p stuff
//
if ( name.StartsWith( "ISteamNetworking." ) )
{
if ( !name.Contains( "P2P" ))
return true;
}
if ( name == "ISteamUGC.RequestUGCDetails" ) return true;
2019-04-27 16:25:54 +03:00
return false;
2020-02-22 23:16:04 +03:00
}
//
// If we start with E[Capital] then strip the E
// (makes us more C# like)
//
internal static string CleanEnum( string name )
{
if ( name[0] != 'E' ) return name;
if ( !char.IsUpper( name[1] ) ) return name;
return name.Substring( 1 );
2019-04-27 16:25:54 +03:00
}
2019-04-16 13:45:44 +03:00
}