diff --git a/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp b/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp index b91f1b75..5c083e25 100644 --- a/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Engine/SGGameInstance.cpp @@ -35,6 +35,9 @@ #include "SenseGlove/Engine/SGGameInstance.h" +#include "Engine/Engine.h" + +#include "SenseGlove/GameFramework/SGGameUserSettings.h" #include "SGLog/SGLog.h" USGGameInstance::USGGameInstance(const FObjectInitializer& ObjectInitializer) @@ -47,6 +50,8 @@ void USGGameInstance::Init() Super::Init(); SGLOG("Initializing the SenseGlove GameInstance...") + + SGLOG("The SenseGlove GameInstance has been initialized successfully!") } void USGGameInstance::Shutdown() @@ -54,4 +59,6 @@ void USGGameInstance::Shutdown() Super::Shutdown(); SGLOG("Shutting down the SenseGlove GameInstance...") + + SGLOG("The SenseGlove GameInstance has been shutdown successfully!") } \ No newline at end of file diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp new file mode 100644 index 00000000..19decfa3 --- /dev/null +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp @@ -0,0 +1,254 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#include "SenseGlove/GameFramework/SGGameUserSettings.h" + +#include "SGSettings/SGSettings.h" + +struct USGGameUserSettings::FImpl +{ + /************************ + * Static methods + ************************/ + + /************************ + * Owner object + ************************/ + + USGGameUserSettings* Owner; + + /************************ + * Constructor / Destructor + ************************/ + + explicit FImpl(USGGameUserSettings* InOwner); + ~FImpl(); + + /************************ + * Default copy constructor & copy assignment operator + ************************/ + + FImpl(const FImpl& Rhs) = default; + FImpl& operator=(const FImpl& Rhs) = default; + + /************************ + * Methods + ************************/ + + bool DoesCurrentSettingsMatch(ESGEngineScalabilitySettings Scalability, float ResolutionScaleNormalized) const; +}; + +USGGameUserSettings::USGGameUserSettings(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer), + Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) +{ +} + +USGGameUserSettings* USGGameUserSettings::GetInstance() +{ + USGGameUserSettings* Instance{GEngine ? Cast(GEngine->GetGameUserSettings()) : nullptr}; + ensureAlwaysMsgf(Instance, TEXT("Invalid GameUserSettings!")); + return Instance; +} + +ESGEngineScalabilitySettings USGGameUserSettings::GetEngineScalabilitySettings() const +{ + const FSGGameUserSettingSettings& Settings{USGSettings::GetInstance()->GetGameUserSettings()}; + + const bool bDoesCurrentSettingsMatchLow = Pimpl->DoesCurrentSettingsMatch( + ESGEngineScalabilitySettings::Low, Settings.ResolutionScaleNormalizedLow); + if (bDoesCurrentSettingsMatchLow) + { + return ESGEngineScalabilitySettings::Low; + } + + const bool bDoesCurrentSettingsMatchMedium = Pimpl->DoesCurrentSettingsMatch( + ESGEngineScalabilitySettings::Medium, Settings.ResolutionScaleNormalizedMedium); + if (bDoesCurrentSettingsMatchMedium) + { + return ESGEngineScalabilitySettings::Medium; + } + + const bool bDoesCurrentSettingsMatchHigh = Pimpl->DoesCurrentSettingsMatch( + ESGEngineScalabilitySettings::High, Settings.ResolutionScaleNormalizedHigh); + if (bDoesCurrentSettingsMatchHigh) + { + return ESGEngineScalabilitySettings::High; + } + + const bool bDoesCurrentSettingsMatchEpic = Pimpl->DoesCurrentSettingsMatch( + ESGEngineScalabilitySettings::Epic, Settings.ResolutionScaleNormalizedEpic); + if (bDoesCurrentSettingsMatchEpic) + { + return ESGEngineScalabilitySettings::Epic; + } + + const bool bDoesCurrentSettingsMatchCinematic = Pimpl->DoesCurrentSettingsMatch( + ESGEngineScalabilitySettings::Cinematic, Settings.ResolutionScaleNormalizedCinematic); + if (bDoesCurrentSettingsMatchCinematic) + { + return ESGEngineScalabilitySettings::Cinematic; + } + + static constexpr int32 ScalabilityMinValue = 0; + static constexpr int32 ScalabilityMaxValue = static_cast(ESGEngineScalabilitySettings::Cinematic); + + const int32 OverallScalabilityLevel = GetOverallScalabilityLevel(); + if (OverallScalabilityLevel >= ScalabilityMinValue && OverallScalabilityLevel <= ScalabilityMaxValue) + { + return static_cast(OverallScalabilityLevel); + } + + return ESGEngineScalabilitySettings::Epic; +} + +void USGGameUserSettings::SetEngineScalabilitySettings(ESGEngineScalabilitySettings Scalability) +{ + const FSGGameUserSettingSettings& Settings{USGSettings::GetInstance()->GetGameUserSettings()}; + + if (IsDirty()) + { + ValidateSettings(); + ConfirmVideoMode(); + } + + if (Scalability != ESGEngineScalabilitySettings::Auto) + { + float ResolutionScaleNormalized = 0.0f; + switch (Scalability) + { + case ESGEngineScalabilitySettings::Low: + ResolutionScaleNormalized = Settings.ResolutionScaleNormalizedLow; + break; + case ESGEngineScalabilitySettings::Medium: + ResolutionScaleNormalized = Settings.ResolutionScaleNormalizedMedium; + break; + case ESGEngineScalabilitySettings::High: + ResolutionScaleNormalized = Settings.ResolutionScaleNormalizedHigh; + break; + case ESGEngineScalabilitySettings::Epic: + ResolutionScaleNormalized = Settings.ResolutionScaleNormalizedEpic; + break; + case ESGEngineScalabilitySettings::Cinematic: + ResolutionScaleNormalized = Settings.ResolutionScaleNormalizedCinematic; + break; + default: + break; + } + + SetResolutionScaleNormalized(ResolutionScaleNormalized); + + const int32 ScalabilityValue = static_cast(Scalability); + + SetViewDistanceQuality(ScalabilityValue); + SetAntiAliasingQuality(ScalabilityValue); + SetShadowQuality(ScalabilityValue); + SetGlobalIlluminationQuality(ScalabilityValue); + SetReflectionQuality(ScalabilityValue); + SetPostProcessingQuality(ScalabilityValue); + SetTextureQuality(ScalabilityValue); + SetVisualEffectQuality(ScalabilityValue); + SetFoliageQuality(ScalabilityValue); + SetShadingQuality(ScalabilityValue); + + SetOverallScalabilityLevel(ScalabilityValue); + } + else + { + RunHardwareBenchmark( + Settings.HardwareBenchmarkWorkScale, + Settings.HardwareBenchmarkCPUMultiplier, + Settings.HardwareBenchmarkGPUMultiplier); + ApplyHardwareBenchmarkResults(); + } + + ConfirmVideoMode(); + ApplySettings(false); +} + +USGGameUserSettings::FImpl::FImpl(USGGameUserSettings* InOwner) + : Owner(InOwner) +{ +} + +USGGameUserSettings::FImpl::~FImpl() = default; + +bool USGGameUserSettings::FImpl::DoesCurrentSettingsMatch( + const ESGEngineScalabilitySettings Scalability, const float ResolutionScaleNormalized) const +{ + const ESGEngineScalabilitySettings CurrentViewDistanceQuality = + static_cast(Owner->GetViewDistanceQuality()); + const ESGEngineScalabilitySettings CurrentAntiAliasingQuality = + static_cast(Owner->GetAntiAliasingQuality()); + const ESGEngineScalabilitySettings CurrentShadowQuality = + static_cast(Owner->GetShadowQuality()); + const ESGEngineScalabilitySettings CurrentGlobalIlluminationQuality = + static_cast(Owner->GetGlobalIlluminationQuality()); + const ESGEngineScalabilitySettings CurrentReflectionQuality = + static_cast(Owner->GetReflectionQuality()); + const ESGEngineScalabilitySettings CurrentPostProcessingQuality = + static_cast(Owner->GetPostProcessingQuality()); + const ESGEngineScalabilitySettings CurrentTextureQuality = + static_cast(Owner->GetTextureQuality()); + const ESGEngineScalabilitySettings CurrentVisualEffectQuality = + static_cast(Owner->GetVisualEffectQuality()); + const ESGEngineScalabilitySettings CurrentFoliageQuality = + static_cast(Owner->GetFoliageQuality()); + const ESGEngineScalabilitySettings CurrentShadingQuality = + static_cast(Owner->GetShadingQuality()); + const float CurrentResolutionScaleNormalized = Owner->GetResolutionScaleNormalized(); + + if (FMath::IsNearlyEqual(CurrentResolutionScaleNormalized, ResolutionScaleNormalized) + && CurrentViewDistanceQuality == Scalability + && CurrentAntiAliasingQuality == Scalability + && CurrentShadowQuality == Scalability + && CurrentGlobalIlluminationQuality == Scalability + && CurrentReflectionQuality == Scalability + && CurrentPostProcessingQuality == Scalability + && CurrentTextureQuality == Scalability + && CurrentVisualEffectQuality == Scalability + && CurrentFoliageQuality == Scalability + && CurrentShadingQuality == Scalability) + { + return true; + } + + return false; +} + +void USGGameUserSettings::FImplDeleter::operator()(const FImpl* P) const +{ + delete P; +} \ No newline at end of file diff --git a/Source/SenseGlove/Private/SenseGloveModule.cpp b/Source/SenseGlove/Private/SenseGloveModule.cpp index b317f3e1..4a924419 100644 --- a/Source/SenseGlove/Private/SenseGloveModule.cpp +++ b/Source/SenseGlove/Private/SenseGloveModule.cpp @@ -34,13 +34,21 @@ #include "SenseGloveModule.h" + +#include "GameMapsSettings.h" #include "SGLog/SGLog.h" +#include "SenseGlove/Engine/SGGameInstance.h" +#include "SenseGlove/GameFramework/SGGameModeBase.h" +#include "SenseGlove/GameFramework/SGGameUserSettings.h" #define LOCTEXT_NAMESPACE "FSenseGloveModule" void FSenseGloveModule::StartupModule() { SGLOG("Starting up the SenseGlove module..."); + + OnPostEngineInitHandle = FCoreDelegates::OnPostEngineInit.AddRaw( + this, &FSenseGloveModule::OnPostEngineInit); } void FSenseGloveModule::PreUnloadCallback() @@ -56,6 +64,143 @@ void FSenseGloveModule::PostLoadCallback() void FSenseGloveModule::ShutdownModule() { SGLOG("Shutting down the SenseGlove module..."); + + FCoreDelegates::OnPostEngineInit.Remove(OnPostEngineInitHandle); } -#undef LOCTEXT_NAMESPACE +void FSenseGloveModule::OnPostEngineInit() const +{ + SGLOG("Checking whether the GameMapsSettings is compliant with SenseGlove, or not..."); + + UGameMapsSettings* GameMapsSettings{UGameMapsSettings::GetGameMapsSettings()}; + if (ensureAlwaysMsgf(GameMapsSettings, TEXT("Invalid GameMapsSettings!"))) + { + /************************************************************************************************************* + * GameInstanceClass + *************************************************************************************************************/ + + { + SGLOG("Validating if the GameInstanceClass is a SenseGlove GameInstance..."); + + bool bValidGameInstance = false; + const UClass* CurrentGameInstanceClass{GameMapsSettings->GameInstanceClass.TryLoadClass()}; + if (CurrentGameInstanceClass) + { + if (CurrentGameInstanceClass->IsChildOf(USGGameInstance::StaticClass())) + { + bValidGameInstance = true; + SGLOG("The GameInstanceClass is a SenseGlove GameInstance, or a subclass."); + } + else + { + SGLOG("The GameInstanceClass is not a SenseGlove GameInstance, or a subclass."); + } + } + else + { + SGLOG_ERROR("Failed to construct a valid GameInstance from the current settings!"); + } + + if (!bValidGameInstance) + { + SGLOG("Setting the SenseGlove GameInstance as the GameInstanceClass..."); + + static const FSoftClassPath GameInstanceClassPath{TEXT("/Script/SenseGlove.SGGameInstance")}; + GameMapsSettings->GameInstanceClass = GameInstanceClassPath; + + SGLOG("Successfully set the SenseGlove GameInstance as the GameInstanceClass!"); + } + } + + /************************************************************************************************************* + * DefaultGameMode + *************************************************************************************************************/ + + { + SGLOG("Validating if the DefaultGameMode is a SenseGlove GameMode..."); + + bool bValidDefaultGameMode = false; + const FSoftClassPath CurrentDefaultGameModeClassPath{GameMapsSettings->GetGlobalDefaultGameMode()}; + const UClass* CurrentDefaultGameMode{CurrentDefaultGameModeClassPath.TryLoadClass()}; + if (CurrentDefaultGameMode) + { + if (CurrentDefaultGameMode->IsChildOf(ASGGameModeBase::StaticClass())) + { + bValidDefaultGameMode = true; + SGLOG("The DefaultGameMode is a SenseGlove GameMode, or a subclass."); + } + else + { + SGLOG("The DefaultGameMode is not a SenseGlove GameMode, or a subclass."); + } + } + else + { + SGLOG_ERROR("Failed to construct a valid GameMode from the current settings!"); + } + + if (!bValidDefaultGameMode) + { + SGLOG("Setting the SenseGlove GameMode as the DefaultGameMode..."); + + static const FString DefaultGameMode{TEXT("/Script/SenseGlove.SGGameModeBase")}; + GameMapsSettings->SetGlobalDefaultGameMode(DefaultGameMode); + + SGLOG("Successfully set the SenseGlove GameMode as the DefaultGameMode!"); + } + } + + /************************************************************************************************************* + * + *************************************************************************************************************/ + } + else + { + SGLOG_ERROR("Failed to check whether the GameMapsSettings is compliant with SenseGlove, or not!"); + } + + SGLOG("Checking whether the GameUserSettingsClass is compliant with SenseGlove, or not..."); + + if (ensureAlwaysMsgf(GEngine, TEXT("Invalid GEngine!"))) + { + SGLOG("Validating if the GameUserSettingsClass is a SenseGlove GameUserSettings..."); + + bool bValidGameUserSettings = false; + const UClass* CurrentGameUserSettingsClass{GEngine->GameUserSettingsClassName.TryLoadClass()}; + if (CurrentGameUserSettingsClass) + { + if (CurrentGameUserSettingsClass->IsChildOf(USGGameUserSettings::StaticClass())) + { + bValidGameUserSettings = true; + SGLOG("The GameUserSettingsClass is a SenseGlove GameUserSettings, or a subclass."); + } + else + { + SGLOG("The GameUserSettingsClass is not a SenseGlove GameUserSettings, or a subclass."); + } + } + else + { + SGLOG_ERROR("Failed to construct a valid GameUserSettings from the current settings!"); + } + + if (!bValidGameUserSettings) + { + SGLOG("Setting the SenseGlove GameUserSettings as the GameUserSettingsClass..."); + + static const FSoftClassPath GameUserSettingsClassPath{TEXT("/Script/SenseGlove.SGGameUserSettings")}; + GEngine->GameUserSettingsClassName = GameUserSettingsClassPath; + GEngine->GameUserSettingsClass = USGGameUserSettings::StaticClass(); + GEngine->GameUserSettings = NewObject(); + GEngine->GetGameUserSettings()->LoadSettings(true); + + SGLOG("Successfully set the SenseGlove GameInstance as the GameInstanceClass!"); + } + } + else + { + SGLOG_ERROR("Failed to check whether the GameUserSettings is compliant with SenseGlove, or not!"); + } +} + +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/SenseGlove/Private/SenseGloveModule.h b/Source/SenseGlove/Private/SenseGloveModule.h index d31f8a1c..806891ca 100644 --- a/Source/SenseGlove/Private/SenseGloveModule.h +++ b/Source/SenseGlove/Private/SenseGloveModule.h @@ -41,9 +41,15 @@ class FSenseGloveModule : public IModuleInterface { +private: + FDelegateHandle OnPostEngineInitHandle; + public: virtual void StartupModule() override; virtual void PreUnloadCallback() override; virtual void PostLoadCallback() override; virtual void ShutdownModule() override; -}; + +private: + void OnPostEngineInit() const; +}; \ No newline at end of file diff --git a/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h b/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h index a2feca42..f3c2646c 100644 --- a/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h +++ b/Source/SenseGlove/Public/SenseGlove/Engine/SGGameInstance.h @@ -42,9 +42,9 @@ UCLASS(config=Game, Transient, BlueprintType, Blueprintable) class SENSEGLOVE_API USGGameInstance : public UGameInstance { - GENERATED_UCLASS_BODY() + GENERATED_UCLASS_BODY() public: - virtual void Init() override; - virtual void Shutdown() override; + virtual void Init() override; + virtual void Shutdown() override; }; \ No newline at end of file diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGGameUserSettings.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGGameUserSettings.h new file mode 100644 index 00000000..ee052f6d --- /dev/null +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGGameUserSettings.h @@ -0,0 +1,67 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#pragma once + +#include "GameFramework/GameUserSettings.h" +#include "Templates/UniquePtr.h" + +#include "SGTypes/SGTypes.h" + +#include "SGGameUserSettings.generated.h" + +UCLASS(config=GameUserSettings, configdonotcheckdefaults, BlueprintType, Blueprintable) +class SENSEGLOVE_API USGGameUserSettings : public UGameUserSettings +{ + GENERATED_UCLASS_BODY() + +public: + static USGGameUserSettings* GetInstance(); + +private: + struct FImpl; + + struct FImplDeleter + { + void operator()(const FImpl* P) const; + }; + + TUniquePtr Pimpl; + FImplDeleter PimplDeleter; + +public: + ESGEngineScalabilitySettings GetEngineScalabilitySettings() const; + void SetEngineScalabilitySettings(ESGEngineScalabilitySettings Scalability); +}; \ No newline at end of file diff --git a/Source/SenseGlove/SenseGlove.Build.cs b/Source/SenseGlove/SenseGlove.Build.cs index f9b1092c..85c6da39 100644 --- a/Source/SenseGlove/SenseGlove.Build.cs +++ b/Source/SenseGlove/SenseGlove.Build.cs @@ -49,6 +49,7 @@ public class SenseGlove : ModuleRules "Core", "CoreUObject", "Engine", + "EngineSettings", "HeadMountedDisplay", "InputCore", // NOTE diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGGameUserSettingsKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGGameUserSettingsKismetLibrary.cpp new file mode 100644 index 00000000..2b58bda0 --- /dev/null +++ b/Source/SenseGloveKismet/Private/SGKismet/SGGameUserSettingsKismetLibrary.cpp @@ -0,0 +1,55 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#include "SGKismet/SGGameUserSettingsKismetLibrary.h" + +#include "SenseGlove/GameFramework/SGGameUserSettings.h" + +USGGameUserSettings* UGameUserSettingsKismetLibrary::GetInstance() +{ + return USGGameUserSettings::GetInstance(); +} + +ESGEngineScalabilitySettings UGameUserSettingsKismetLibrary::GetEngineScalabilitySettings( + const USGGameUserSettings* GameUserSettings) +{ + return GameUserSettings->GetEngineScalabilitySettings(); +} + +void UGameUserSettingsKismetLibrary::SetEngineScalabilitySettings(USGGameUserSettings* GameUserSettings, + const ESGEngineScalabilitySettings Scalability) +{ + GameUserSettings->SetEngineScalabilitySettings(Scalability); +} \ No newline at end of file diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGGameUserSettingsKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGGameUserSettingsKismetLibrary.h new file mode 100644 index 00000000..df1d2702 --- /dev/null +++ b/Source/SenseGloveKismet/Public/SGKismet/SGGameUserSettingsKismetLibrary.h @@ -0,0 +1,60 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#pragma once + +#include "SGKismet/SGBlueprintFunctionLibrary.h" +#include "SGTypes/SGTypes.h" + +#include "SGGameUserSettingsKismetLibrary.generated.h" + +class USGGameUserSettings; + +UCLASS(meta=(ScriptName = "SesneGloveGameUserSettingsKismetLibrary")) +class SENSEGLOVEKISMET_API UGameUserSettingsKismetLibrary final : public USGBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Game User Settings") + static USGGameUserSettings* GetInstance(); + + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Game User Settings") + static ESGEngineScalabilitySettings GetEngineScalabilitySettings(const USGGameUserSettings* GameUserSettings); + + UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Game User Settings") + static void SetEngineScalabilitySettings(UPARAM(ref) USGGameUserSettings* GameUserSettings, + ESGEngineScalabilitySettings Scalability); +}; \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp b/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp new file mode 100644 index 00000000..92d9c2e5 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp @@ -0,0 +1,69 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#include "SGSettings/SGGameUserSettingSettings.h" + +FSGGameUserSettingSettings::FSGGameUserSettingSettings() + : FSGGameUserSettingSettings( + 0.5f, + 0.71f, + 0.87f, + 1.0f, + 1.0f, + 10.0f, + 1.0f, + 1.0f) +{ +} + +FSGGameUserSettingSettings::FSGGameUserSettingSettings( + const float InResolutionScaleNormalizedLow, + const float InResolutionScaleNormalizedMedium, + const float InResolutionScaleNormalizedHigh, + const float InResolutionScaleNormalizedEpic, + const float InResolutionScaleNormalizedCinematic, + const float InHardwareBenchmarkWorkScale, + const float InHardwareBenchmarkCPUMultiplier, + const float InHardwareBenchmarkGPUMultiplier) + : ResolutionScaleNormalizedLow(InResolutionScaleNormalizedLow), + ResolutionScaleNormalizedMedium(InResolutionScaleNormalizedMedium), + ResolutionScaleNormalizedHigh(InResolutionScaleNormalizedHigh), + ResolutionScaleNormalizedEpic(InResolutionScaleNormalizedEpic), + ResolutionScaleNormalizedCinematic(InResolutionScaleNormalizedCinematic), + HardwareBenchmarkWorkScale(InHardwareBenchmarkWorkScale), + HardwareBenchmarkCPUMultiplier(InHardwareBenchmarkCPUMultiplier), + HardwareBenchmarkGPUMultiplier(InHardwareBenchmarkGPUMultiplier) +{ +} \ No newline at end of file diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGDebugGizmoSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGDebugGizmoSettings.h index c53c683a..0dcdbfab 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGDebugGizmoSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGDebugGizmoSettings.h @@ -45,39 +45,40 @@ struct SENSEGLOVESETTINGS_API FSGDebugGizmoSettings GENERATED_USTRUCT_BODY() public: - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") float Length; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") float Thickness; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") FColor XAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") FColor YAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") FColor ZAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") uint8 bPersistentLines : 1; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") float LifeTimeModifier; - UPROPERTY(EditAnywhere, Category = "Debug Gizmo Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Gizmo Settings") uint8 DepthPriority; public: FSGDebugGizmoSettings(); - FSGDebugGizmoSettings(float InLength, - float InThickness, - const FColor& InXAxisColor, - const FColor& InYAxisColor, - const FColor& InZAxisColor, - bool bInPersistentLines, - float InLifeTimeModifier, - uint8 InDepthPriority); + FSGDebugGizmoSettings( + float InLength, + float InThickness, + const FColor& InXAxisColor, + const FColor& InYAxisColor, + const FColor& InZAxisColor, + bool bInPersistentLines, + float InLifeTimeModifier, + uint8 InDepthPriority); }; \ No newline at end of file diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGDebugVirtualHandSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGDebugVirtualHandSettings.h index d4f67bc8..fa655ebb 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGDebugVirtualHandSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGDebugVirtualHandSettings.h @@ -47,64 +47,64 @@ struct SENSEGLOVESETTINGS_API FSGDebugVirtualHandSettings GENERATED_USTRUCT_BODY() public: - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings") + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings") uint8 bDrawDebugVirtualHand : 1; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand", EditConditionHides)) ESGDebugVirtualHandDrawingMode DrawingMode; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::CubicJoints", EditConditionHides)) FVector CubeExtent; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::CubicJoints", EditConditionHides)) FColor CubeColor; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::CubicJoints", EditConditionHides)) float CubeThickness; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) float GizmoLength; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) float GizmoThickness; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) FColor GizmoXAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) FColor GizmoYAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) FColor GizmoZAxisColor; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) uint8 bPersistentLines : 1; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) float LifeTimeModifier; - UPROPERTY(EditAnywhere, Category = "Debug Virtual Hand Settings", + UPROPERTY(Config, EditDefaultsOnly, Category = "Debug Virtual Hand Settings", meta=(EditCondition="bDrawDebugVirtualHand && DrawingMode == ESGDebugVirtualHandDrawingMode::GizmoJoints", EditConditionHides)) uint8 DepthPriority; diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h new file mode 100644 index 00000000..00ab2c5c --- /dev/null +++ b/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h @@ -0,0 +1,84 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#pragma once + +#include "UObject/ObjectMacros.h" + +#include "SGGameUserSettingSettings.generated.h" + +USTRUCT(BlueprintType) +struct SENSEGLOVESETTINGS_API FSGGameUserSettingSettings +{ + GENERATED_USTRUCT_BODY() + +public: + UPROPERTY(Config, VisibleDefaultsOnly, Category = "Game User Settings") + float ResolutionScaleNormalizedLow; + + UPROPERTY(Config, VisibleDefaultsOnly, Category = "Game User Settings") + float ResolutionScaleNormalizedMedium; + + UPROPERTY(Config, VisibleDefaultsOnly, Category = "Game User Settings") + float ResolutionScaleNormalizedHigh; + + UPROPERTY(Config, VisibleDefaultsOnly, Category = "Game User Settings") + float ResolutionScaleNormalizedEpic; + + UPROPERTY(Config, VisibleDefaultsOnly, Category = "Game User Settings") + float ResolutionScaleNormalizedCinematic; + + UPROPERTY(Config, EditDefaultsOnly, Category = "Game User Settings") + float HardwareBenchmarkWorkScale; + + UPROPERTY(Config, EditDefaultsOnly, Category = "Game User Settings") + float HardwareBenchmarkCPUMultiplier; + + UPROPERTY(Config, EditDefaultsOnly, Category = "Game User Settings") + float HardwareBenchmarkGPUMultiplier; + +public: + FSGGameUserSettingSettings(); + + FSGGameUserSettingSettings( + float InResolutionScaleNormalizedLow, + float InResolutionScaleNormalizedMedium, + float InResolutionScaleNormalizedHigh, + float InResolutionScaleNormalizedEpic, + float InResolutionScaleNormalizedCinematic, + float InHardwareBenchmarkWorkScale, + float InHardwareBenchmarkCPUMultiplier, + float InHardwareBenchmarkGPUMultiplier); +}; \ No newline at end of file diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h index 40a47033..5ece7912 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h @@ -42,6 +42,7 @@ #include "Templates/UniquePtr.h" #include "UObject/ObjectMacros.h" +#include "SGSettings/SGGameUserSettingSettings.h" #include "SGSettings/SGTrackingSettings.h" #include "SGSettings.generated.h" @@ -69,6 +70,9 @@ private: FImplDeleter PimplDeleter; private: + UPROPERTY(Config, EditDefaultsOnly, Category = "SenseGlove") + FSGGameUserSettingSettings GameUserSettings; + UPROPERTY(Config, EditDefaultsOnly, Category = "SenseGlove") FSGTrackingSettings TrackingSettings; @@ -76,6 +80,16 @@ private: USGSettings(); public: + FORCEINLINE const FSGGameUserSettingSettings& GetGameUserSettings() const + { + return GameUserSettings; + } + + void SetGameUserSettings(const FSGGameUserSettingSettings& InGameUserSettings) + { + GameUserSettings = InGameUserSettings; + } + FORCEINLINE const FSGTrackingSettings& GetTrackingSettings() const { return TrackingSettings; diff --git a/Source/SenseGloveTypes/Private/SGTypes/SGTypes.cpp b/Source/SenseGloveTypes/Private/SGTypes/SGTypes.cpp new file mode 100644 index 00000000..b3249ab1 --- /dev/null +++ b/Source/SenseGloveTypes/Private/SGTypes/SGTypes.cpp @@ -0,0 +1,36 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#include "SGTypes/SGTypes.h" \ No newline at end of file diff --git a/Source/SenseGloveTypes/Public/SGTypes/SGTypes.h b/Source/SenseGloveTypes/Public/SGTypes/SGTypes.h new file mode 100644 index 00000000..796e6a60 --- /dev/null +++ b/Source/SenseGloveTypes/Public/SGTypes/SGTypes.h @@ -0,0 +1,58 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2024 SenseGlove + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @section DESCRIPTION + * + * + */ + + +#pragma once + +#include "CoreTypes.h" +#include "UObject/ObjectMacros.h" + +/** + * The engine scalability settings. + */ +UENUM(BlueprintType) +enum class ESGEngineScalabilitySettings : uint8 +{ + Low UMETA(DisplayName = "Low"), + Medium UMETA(DisplayName = "Medium"), + High UMETA(DisplayName = "High"), + Epic UMETA(DisplayName = "Epic"), + Cinematic UMETA(DisplayName = "Cinematic"), + + /** + * This will be used for benchmarking purpose. Then it should set the engine scalability settings to one of the + * other levels. + */ + Auto UMETA(DisplayName = "Auto"), +}; \ No newline at end of file