193 lines
7.8 KiB
C#
Raw Permalink Normal View History

2019-04-16 11:45:44 +01: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 14:25:54 +01:00
{
2019-04-16 11:45:44 +01:00
public static string ConvertType( string type )
{
2020-02-22 20:16:04 +00: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" );
2020-02-22 20:16:04 +00:00
2019-04-16 11:45:44 +01:00
type = type.Replace( "CSteamID", "SteamId" );
type = type.Replace( "CGameID", "GameId" );
2019-04-16 12:17:24 +01: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 16:37:49 +01:00
type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
2019-04-17 08:40:58 +01:00
type = type.Replace( "PublishedFileId_t", "PublishedFileId" );
2019-04-26 14:29:36 +01:00
type = type.Replace( "AppId_t", "AppId" );
2019-04-17 08:40:58 +01:00
type = type.Replace( "LeaderboardSortMethod", "LeaderboardSort" );
type = type.Replace( "LeaderboardDisplayType", "LeaderboardDisplay" );
2019-04-26 13:46:12 +01:00
type = type.Replace( "UGCMatchingUGCType", "UgcType" );
2019-04-29 10:41:40 +01:00
type = type.Replace( "SteamItemInstanceID_t", "InventoryItemId" );
type = type.Replace( "SteamItemDef_t", "InventoryDefId" );
type = type.Replace( "ChatRoomEnterResponse", "RoomEnter" );
2020-02-24 08:58:09 +00:00
type = type.Replace( "SteamNetworkPingLocation_t", "NetPingLocation" );
2020-02-22 20:16:04 +00:00
type = type.Replace( "SteamNetworkingConfigValue_t", "NetKeyValue" );
2019-05-02 15:57:57 +01:00
type = type.Replace( "SteamNetworkingConfigValue", "NetConfig" );
2020-02-22 20:16:04 +00:00
type = type.Replace( "SteamNetworkingConfigScope", "NetConfigScope" );
2019-05-02 15:57:57 +01:00
type = type.Replace( "SteamNetworkingConfigDataType", "NetConfigType" );
2020-02-24 08:58:09 +00:00
type = type.Replace( "FSteamNetworkingSocketsDebugOutput", "NetDebugFunc" );
type = type.Replace( "SteamNetworkingErrMsg", "NetErrorMessage" );
type = type.Replace( "SteamNetConnectionEnd", "NetConnectionEnd" );
2019-05-06 13:34:41 +01:00
type = type.Replace( "HSteamNetConnection", "Connection" );
2019-05-02 20:41:45 +01:00
type = type.Replace( "HSteamListenSocket", "Socket" );
2019-05-06 13:34:41 +01:00
type = type.Replace( "SteamNetworkingIPAddr", "NetAddress" );
type = type.Replace( "SteamNetworkingIdentity", "NetIdentity" );
2019-05-02 21:40:39 +01:00
type = type.Replace( "SteamNetConnectionInfo_t", "ConnectionInfo" );
type = type.Replace( "SteamNetworkingConnectionState", "ConnectionState" );
2019-05-06 13:26:37 +01:00
type = type.Replace( "SteamNetworkingMicroseconds", "long" );
type = type.Replace( "SteamNetworkingSocketsDebugOutputType", "NetDebugOutput" );
2019-05-06 13:38:37 +01:00
type = type.Replace( "SteamNetworkingGetConfigValueResult", "NetConfigResult" );
2019-06-19 16:18:12 +01:00
type = type.Replace( "SteamInputType", "InputType" );
2019-06-20 10:41:57 +01:00
type = type.Replace( "InputDigitalActionData_t", "DigitalState" );
type = type.Replace( "InputAnalogActionData_t", "AnalogState" );
type = type.Replace( "InputMotionData_t", "MotionState" );
2019-07-02 12:08:02 +01:00
type = type.Replace( "MatchMakingKeyValuePair_t", "MatchMakingKeyValuePair" );
2020-02-22 20:16:04 +00:00
type = type.Replace( "ISteamNetworkingMessage", "NetMsg" );
type = type.Replace( "SteamNetworkingMessage_t", "NetMsg" );
type = type.Replace( "SteamIPAddress_t", "SteamIPAddress" );
2020-08-20 15:46:08 +02:00
type = type.Replace( "SteamNetworkingQuickConnectionStatus", "ConnectionStatus" );
2020-02-22 20:16:04 +00:00
type = type.Replace( "::", "." );
if ( type == "EPersonaState" ) return "EFriendState";
if ( type == "PersonaState" ) return "FriendState";
2019-04-16 11:45:44 +01:00
return type;
}
public static bool ShouldCreate( string type )
{
if ( IsDeprecated( type ) ) return false;
2019-04-16 11:45:44 +01:00
if ( type == "SteamId" ) return false;
2019-04-17 08:40:58 +01:00
if ( type == "LeaderboardSort" ) return false;
if ( type == "LeaderboardDisplay" ) return false;
2019-04-26 14:29:36 +01:00
if ( type == "AppId" ) return false;
2019-06-20 10:41:57 +01:00
if ( type == "AnalogState" ) return false;
if ( type == "DigitalState" ) return false;
if ( type == "MotionState" ) return false;
2019-07-02 12:08:02 +01:00
if ( type == "MatchMakingKeyValuePair" ) return false;
2020-02-22 20:16:04 +00:00
if ( type == "Connection" ) return false;
if ( type == "Socket" ) return false;
if ( type == "SteamNetworkingMicroseconds" ) return false;
2020-02-24 08:58:09 +00:00
if ( type == "NetDebugFunc" ) return false;
2020-02-22 20:16:04 +00: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 08:58:09 +00:00
if ( type == "NetPingLocation" ) return false;
2020-02-22 20:16:04 +00: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 15:46:08 +02:00
if ( type == "ConnectionStatus") return false;
if ( type.StartsWith( "FnSteam" ) ) return false;
2019-04-16 11:45:44 +01:00
return true;
}
2019-04-16 12:17:24 +01: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 16:37:49 +01:00
if ( name == "PublishedFileId" ) return "public";
if ( name == "Result" ) return "public";
2019-04-26 13:46:12 +01:00
if ( name == "UgcType" ) return "public";
2019-04-29 10:41:40 +01:00
if ( name == "InventoryItemId" ) return "public";
if ( name == "InventoryDefId" ) return "public";
2019-04-30 22:45:37 +01:00
if ( name == "P2PSend" ) return "public";
if ( name == "RoomEnter" ) return "public";
if ( name == "P2PSessionError" ) return "public";
2019-06-19 16:18:12 +01:00
if ( name == "InputType" ) return "public";
2019-06-20 10:41:57 +01:00
if ( name == "InputSourceMode" ) return "public";
2019-12-04 11:15:58 +00:00
if ( name == "UserHasLicenseForAppResult" ) return "public";
2020-02-24 08:58:09 +00:00
if ( name == "NetPingLocation" ) return "public";
2020-02-22 20:16:04 +00:00
if ( name == "ConnectionState" ) return "public";
if ( name == "SteamNetworkingAvailability" ) return "public";
2020-02-23 18:58:50 +00:00
if ( name == "SteamDeviceFormFactor" ) return "public";
2020-02-23 19:09:31 +00:00
if ( name == "DurationControlProgress" ) return "public";
2020-02-24 08:58:09 +00:00
if ( name == "NetConnectionEnd" ) return "public";
2020-02-24 10:14:31 +00:00
if ( name == "NetIdentity" ) return "public";
if ( name == "NetAddress" ) return "public";
if ( name == "NetDebugOutput" ) return "public";
2020-09-04 10:34:33 +01:00
if ( name == "ItemPreviewType" ) return "public";
2020-09-04 10:35:22 +01:00
if ( name == "OverlayToStoreFlag" ) return "public";
2019-04-16 12:17:24 +01:00
return "internal";
}
2019-04-27 14:25:54 +01:00
internal static bool IsDeprecated( string name )
{
2020-02-27 09:49:58 +00:00
if ( name.StartsWith( "PS3" ) ) return true;
if ( name == "SocketStatusCallback_t" ) return true;
if ( name == "SNetSocketConnectionType" ) return true;
if ( name == "SNetSocketState" ) return true;
2020-02-27 09:49:58 +00:00
2019-04-27 14:25:54 +01: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 14:25:54 +01:00
return false;
2020-02-22 20:16:04 +00: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 14:25:54 +01:00
}
2019-04-16 11:45:44 +01:00
}