From c82530cecf722fc926bd438cea8ebda59397093c Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Thu, 8 Aug 2024 09:20:32 +0200 Subject: [PATCH] add the console commands SG_GetEngineScalabilitySettings and SG_SetEngineScalabilitySettings --- Handbook/src/SUMMARY.md | 4 ++ Handbook/src/appendix/changelog.md | 1 + Handbook/src/misc/console-commands/README.md | 44 +++++++++++++++++++ Handbook/src/overview/README.md | 6 +++ .../SenseGlove/Engine/SGGameInstance.cpp | 33 ++++++++++++++ .../Public/SenseGlove/Engine/SGGameInstance.h | 9 ++++ 6 files changed, 97 insertions(+) create mode 100644 Handbook/src/misc/console-commands/README.md diff --git a/Handbook/src/SUMMARY.md b/Handbook/src/SUMMARY.md index ed3707e0..3e859d6c 100644 --- a/Handbook/src/SUMMARY.md +++ b/Handbook/src/SUMMARY.md @@ -51,6 +51,10 @@ Welcom to the SenseGlove Unreal Engine Handbook! - [Touch](plugin-configuration/plugin-settings/virtual-hand/touch.md) - [Overriding Settings](plugin-configuration/overriding-settings/README.md) +# 💡 Miscellaneous + +- [SenseGlove Console Commands](misc/console-commands/README.md) + # 🛠️ Advanced Topics - [Safe Glove Access in Blueprint](advanced-topics/safe-glove-access-blueprint/README.md) diff --git a/Handbook/src/appendix/changelog.md b/Handbook/src/appendix/changelog.md index 73412a38..2ebc2ed7 100644 --- a/Handbook/src/appendix/changelog.md +++ b/Handbook/src/appendix/changelog.md @@ -61,6 +61,7 @@ This is a minor release focusing mainly on bringing OpenXR-compatible hand track - Introduced the FSGGameUserSettings for managing the Engine Scalability Settings through the SenseGlove plugin in order to change the graphics settings on the fly. - Added USGGameUserSettingsKismetLibrary in order to allow all the Engine Scalability Settings to be managed from the Blueprint side. - Added FSGGameUserSettingsSettings config struct. +- Added the SenseGlove console commands: SG_GetEngineScalabilitySettings() and SG_SetEngineScalabilitySettings(Scalability). - Added SGHardwareBenchmarkingSettings config struct. - Introduced ESGEngineScalabilitySettings enum. - Added FSGVirtualHandSettingsOverrides config struct used by the new settings override system. diff --git a/Handbook/src/misc/console-commands/README.md b/Handbook/src/misc/console-commands/README.md new file mode 100644 index 00000000..0203209a --- /dev/null +++ b/Handbook/src/misc/console-commands/README.md @@ -0,0 +1,44 @@ +# The SenseGlove Console Commands + +The SenseGlove Unreal Engine Plugin offers a variety of utility console commands to enhance your development experience. + +> [!IMPORTANT] +> To ensure the SenseGlove console commands are registered and recognized by +> Unreal Engine, set the default Game Instance class to `SGGameInstance` or a +> subclass of it. This can be done through: +> `Project Settings > Project > Maps & Modes > Game Instance > Game Instance Class`. +> Failing to do so will result in the error: `Command not recognized: SG_*` in +> the logs. For more details, refer to +> [SGGameInstance](../../setup-senseglove-default-classes/sggameinstance.md). + +## SGGameUserSettings Console Commands + +> [!CAUTION] +> Before running any of the following console commands, ensure that the default +> Game User Settings class is set to `SGGameUserSettings` or a subclass of it. +> This can be configured via: +> `Project Settings > Engine > General Settings > Default Classes > Advanced > Game User Settings Class`. +> Failure to set this correctly will cause your simulation or editor to crash +> upon calling any of the following console commands. For more information, +> refer to +> [SGGameUserSettings](../../setup-senseglove-default-classes/sggameusersettings.md). + +### SG_GetEngineScalabilitySettings + +This console command prints the current Engine Scalability Settings to the logs. + +### SG_SetEngineScalabilitySettings + +This console command sets the Engine Scalability Settings for both the current game and the editor. It accepts a `Scalability` parameter with the following valid values: + +- `Low` +- `Medium` +- `High` +- `Epic` +- `Cinematic` +- `Auto` + +> [!NOTE] +> The `Auto` option is used for benchmarking purposes. It will adjust the engine +> scalability settings to one of the other levels based on the benchmarking +> results. diff --git a/Handbook/src/overview/README.md b/Handbook/src/overview/README.md index 9cd75794..79aa121c 100644 --- a/Handbook/src/overview/README.md +++ b/Handbook/src/overview/README.md @@ -49,6 +49,12 @@ This section provides detailed information on configuring the plugin: - [Touch](../plugin-configuration/plugin-settings/virtual-hand/touch.md) - [Overriding Settings](../plugin-configuration/overriding-settings/) +## 💡 Miscellaneous + +Toipcs that do not fall under any specific category: + +- [SenseGlove Console Commands](../misc/console-commands/) + ## 🛠️ Advanced Topics For users familiar with the basics, this section explores advanced features of the plugin: diff --git a/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp b/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp index 5c083e25..73f49f5c 100644 --- a/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp @@ -40,6 +40,39 @@ #include "SenseGlove/GameFramework/SGGameUserSettings.h" #include "SGLog/SGLog.h" +void USGGameInstance::SG_GetEngineScalabilitySettings() +{ + const USGGameUserSettings* GameUserSettings{USGGameUserSettings::GetInstance()}; + ensureAlwaysMsgf(GameUserSettings, TEXT("Invalid GameUserSettings!")); + + static UEnum* EnumPtr{StaticEnum()}; + ensureAlwaysMsgf(EnumPtr, TEXT("Failed to find the ESGEngineScalabilitySettings enum!")); + + const ESGEngineScalabilitySettings Scalability = GameUserSettings->GetEngineScalabilitySettings(); + const FName ScalabilityName{ + EnumPtr->GetNameByValue(static_cast(Scalability)) + }; + + SGLOG("Get Engine Scalability Settings", ScalabilityName); +} + +void USGGameInstance::SG_SetEngineScalabilitySettings(const ESGEngineScalabilitySettings Scalability) +{ + USGGameUserSettings* GameUserSettings{USGGameUserSettings::GetInstance()}; + ensureAlwaysMsgf(GameUserSettings, TEXT("Invalid GameUserSettings!")); + + static UEnum* EnumPtr{StaticEnum()}; + ensureAlwaysMsgf(EnumPtr, TEXT("Failed to find the ESGEngineScalabilitySettings enum!")); + + GameUserSettings->SetEngineScalabilitySettings(Scalability); + + const FName ScalabilityName{ + EnumPtr->GetNameByValue(static_cast(Scalability)) + }; + + SGLOG("Set Engine Scalability Settings", ScalabilityName); +} + USGGameInstance::USGGameInstance(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { diff --git a/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h b/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h index f3c2646c..045ecccd 100644 --- a/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h +++ b/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h @@ -37,6 +37,8 @@ #include "Engine/GameInstance.h" +#include "SGTypes/SGTypes.h" + #include "SGGameInstance.generated.h" UCLASS(config=Game, Transient, BlueprintType, Blueprintable) @@ -44,6 +46,13 @@ class SENSEGLOVE_API USGGameInstance : public UGameInstance { GENERATED_UCLASS_BODY() +public: + UFUNCTION(Exec, Category = "Console Command") + static void SG_GetEngineScalabilitySettings(); + + UFUNCTION(Exec, Category = "Console Command") + static void SG_SetEngineScalabilitySettings(ESGEngineScalabilitySettings Scalability); + public: virtual void Init() override; virtual void Shutdown() override;