// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Kismet/BlueprintFunctionLibrary.h" #if PLATFORM_WINDOWS #include "Windows/WindowsPlatformMisc.h" #elif PLATFORM_LINUX #include "Linux/LinuxPlatformMisc.h" #elif PLATFORM_MAC #include "Mac/MacPlatformMisc.h" #endif #include "GameFramework/GameUserSettings.h" #include "MBPFL.generated.h" #define BUG_REPORT_WEBHOOK_URL "YOURWEBHOOKURLHERE" #define MYGAME_VERSION "v1.0-pre-alpha" #define DEFAULT_ICON_URL "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" UENUM(BlueprintType) enum class EBugReportCategory : uint8 { Map, Weapon, Other }; UENUM(BlueprintType) enum class EBugReportPriority : uint8 { Crash, High, Med, Low }; USTRUCT() struct FDiscordMessageField { GENERATED_BODY() UPROPERTY() FString name; UPROPERTY() FString value; UPROPERTY() bool binline; }; USTRUCT() struct FDiscordMessageEmbedAuthor { GENERATED_BODY() UPROPERTY() FString name; UPROPERTY() FString url; UPROPERTY() FString icon_url; FDiscordMessageEmbedAuthor() : url("https://trdwll.com"), icon_url(DEFAULT_ICON_URL) {} }; USTRUCT() struct FDiscordMessageEmbedFooter { GENERATED_BODY() UPROPERTY() FString text; UPROPERTY() FString icon_url; FDiscordMessageEmbedFooter() : icon_url(DEFAULT_ICON_URL) {} }; USTRUCT() struct FDiscordMessageEmbed { GENERATED_BODY() UPROPERTY() FString title; UPROPERTY() FString description; UPROPERTY() uint32 color; UPROPERTY() TArray fields; UPROPERTY() FDiscordMessageEmbedAuthor author; UPROPERTY() FDiscordMessageEmbedFooter footer; UPROPERTY() FString timestamp; FDiscordMessageEmbed() : color(720640), timestamp(FDateTime::Now().ToIso8601()) {} uint32 GetColor(const EBugReportPriority Priority) { switch (Priority) { case EBugReportPriority::Crash: return 16711680; case EBugReportPriority::High: return 12389388; case EBugReportPriority::Med: return 16742912; default: case EBugReportPriority::Low: return 720640; } } }; USTRUCT() struct FDiscordMessage { GENERATED_BODY() UPROPERTY() FString username; UPROPERTY() FString avatar_url; UPROPERTY() FString content; UPROPERTY() TArray embeds; FDiscordMessage() : avatar_url(DEFAULT_ICON_URL) {} }; USTRUCT(BlueprintType) struct FBugReportUserData { GENERATED_BODY() UPROPERTY(BlueprintReadWrite) FString Author; UPROPERTY(BlueprintReadWrite) FVector Location; UPROPERTY(BlueprintReadWrite) FString MapName; UPROPERTY(BlueprintReadWrite) FString Message; }; /** * */ UCLASS() class DISCORDEXAMPLE_API UMBPFL : public UBlueprintFunctionLibrary { GENERATED_BODY() public: // Thanks to Rama for this method // GetEnumValueAsString("EEnumType", Value); template static FString GetEnumValueAsString(const FString& Name, TEnum Value) { const UEnum* enumPtr = FindObject(ANY_PACKAGE, *Name, true); if (!enumPtr) { return FString("Invalid"); } return enumPtr->GetNameByValue((int64)Value).ToString(); } UFUNCTION(BlueprintCallable, Category = "Discord") static void SubmitBugReport(const EBugReportCategory Category, const EBugReportPriority Priority, const FBugReportUserData& AuthorData, FString& ReportID, bool bIncludeSpecs = true); /** * Gets the number of RAM on the system */ UFUNCTION(BlueprintPure) static FORCEINLINE int32 GetTotalRAM() { const FPlatformMemoryConstants& MemoryConstants = FPlatformMemory::GetConstants(); return MemoryConstants.TotalPhysicalGB; } UFUNCTION(BlueprintPure) static FString GetGameResolution() { return *FString::Printf(TEXT("%dx%d"), UGameUserSettings::GetGameUserSettings()->GetScreenResolution().X, UGameUserSettings::GetGameUserSettings()->GetScreenResolution().Y); } /** * Gets the CPU Brand Name information. */ UFUNCTION(BlueprintPure) static FString GetCPUBrandName() { #if PLATFORM_WINDOWS return FWindowsPlatformMisc::GetCPUBrand(); #elif PLATFORM_LINUX return FLinuxPlatformMisc::GetCPUBrand(); #elif PLATFORM_MAC return FMacPlatformMisc::GetCPUBrand(); #endif } /** * Gets the CPU Vendor Name information. */ UFUNCTION(BlueprintPure) static FString GetCPUVendorName() { #if PLATFORM_WINDOWS return FWindowsPlatformMisc::GetCPUVendor(); #elif PLATFORM_LINUX return FLinuxPlatformMisc::GetCPUVendor(); #elif PLATFORM_MAC return FMacPlatformMisc::GetCPUVendor(); #endif } /** * Gets the GPU Brand Name information. */ UFUNCTION(BlueprintPure) static FString GetGPUBrandName() { #if PLATFORM_WINDOWS return FWindowsPlatformMisc::GetPrimaryGPUBrand(); #elif PLATFORM_LINUX return FLinuxPlatformMisc::GetPrimaryGPUBrand(); #elif PLATFORM_MAC return FMacPlatformMisc::GetPrimaryGPUBrand(); #endif } /** * Gets the GPU Driver information. */ UFUNCTION(BlueprintPure) static FORCEINLINE FString GetGPUDriverInfo() { return GRHIAdapterUserDriverVersion; } };