From 2cc9d616dd422e2c78b8ddf04aaf5b4e3f7ef723 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Fri, 7 Jun 2024 00:06:38 +0200 Subject: [PATCH] move hardware benchmarking settings to its own class --- .../GameFramework/SGGameUserSettings.cpp | 10 +-- .../SGSettings/SGGameUserSettingSettings.cpp | 13 +--- .../SGHardwareBenchmarkSettings.cpp | 54 ++++++++++++++++ .../SGSettings/SGGameUserSettingSettings.h | 16 ++--- .../SGSettings/SGHardwareBenchmarkSettings.h | 64 +++++++++++++++++++ 5 files changed, 132 insertions(+), 25 deletions(-) create mode 100644 Source/SenseGloveSettings/Private/SGSettings/SGHardwareBenchmarkSettings.cpp create mode 100644 Source/SenseGloveSettings/Public/SGSettings/SGHardwareBenchmarkSettings.h diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp index 4cae48cd..1f834796 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGGameUserSettings.cpp @@ -168,7 +168,9 @@ void USGGameUserSettings::SetEngineScalabilitySettings(ESGEngineScalabilitySetti return; } - const FSGGameUserSettingSettings& Settings{USGSettings::GetInstance()->GetGameUserSettings()}; + const FSGHardwareBenchmarkSettings& Settings{ + USGSettings::GetInstance()->GetGameUserSettings().HardwareBenchmarkSettings + }; if (IsDirty()) { @@ -199,9 +201,9 @@ void USGGameUserSettings::SetEngineScalabilitySettings(ESGEngineScalabilitySetti else { RunHardwareBenchmark( - Settings.HardwareBenchmarkWorkScale, - Settings.HardwareBenchmarkCPUMultiplier, - Settings.HardwareBenchmarkGPUMultiplier); + Settings.WorkScale, + Settings.CPUMultiplier, + Settings.GPUMultiplier); ApplyHardwareBenchmarkResults(); } diff --git a/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp b/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp index 6d93820e..79e1e33d 100644 --- a/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp +++ b/Source/SenseGloveSettings/Private/SGSettings/SGGameUserSettingSettings.cpp @@ -36,19 +36,12 @@ #include "SGSettings/SGGameUserSettingSettings.h" FSGGameUserSettingSettings::FSGGameUserSettingSettings() - : FSGGameUserSettingSettings( - 10.0f, - 1.0f, - 1.0f) + : HardwareBenchmarkSettings{} { } FSGGameUserSettingSettings::FSGGameUserSettingSettings( - const float InHardwareBenchmarkWorkScale, - const float InHardwareBenchmarkCPUMultiplier, - const float InHardwareBenchmarkGPUMultiplier) - : HardwareBenchmarkWorkScale(InHardwareBenchmarkWorkScale), - HardwareBenchmarkCPUMultiplier(InHardwareBenchmarkCPUMultiplier), - HardwareBenchmarkGPUMultiplier(InHardwareBenchmarkGPUMultiplier) + const FSGHardwareBenchmarkSettings& InHardwareBenchmarkSettings) + : HardwareBenchmarkSettings(InHardwareBenchmarkSettings) { } \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SGSettings/SGHardwareBenchmarkSettings.cpp b/Source/SenseGloveSettings/Private/SGSettings/SGHardwareBenchmarkSettings.cpp new file mode 100644 index 00000000..c16df7d0 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SGSettings/SGHardwareBenchmarkSettings.cpp @@ -0,0 +1,54 @@ +/** + * @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/SGHardwareBenchmarkSettings.h" + +FSGHardwareBenchmarkSettings::FSGHardwareBenchmarkSettings() + : FSGHardwareBenchmarkSettings( + 10.0f, + 1.0f, + 1.0f) +{ +} + +FSGHardwareBenchmarkSettings::FSGHardwareBenchmarkSettings( + const float InWorkScale, + const float InCPUMultiplier, + const float InGPUMultiplier) + : WorkScale(InWorkScale), + CPUMultiplier(InCPUMultiplier), + GPUMultiplier(InGPUMultiplier) +{ +} \ No newline at end of file diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h index afe8f961..df975021 100644 --- a/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h +++ b/Source/SenseGloveSettings/Public/SGSettings/SGGameUserSettingSettings.h @@ -37,6 +37,8 @@ #include "UObject/ObjectMacros.h" +#include "SGSettings/SGHardwareBenchmarkSettings.h" + #include "SGGameUserSettingSettings.generated.h" USTRUCT(BlueprintType) @@ -45,20 +47,12 @@ struct SENSEGLOVESETTINGS_API FSGGameUserSettingSettings GENERATED_USTRUCT_BODY() public: - 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; + UPROPERTY(Config, EditDefaultsOnly, Category = "Game User Setting") + FSGHardwareBenchmarkSettings HardwareBenchmarkSettings; public: FSGGameUserSettingSettings(); FSGGameUserSettingSettings( - float InHardwareBenchmarkWorkScale, - float InHardwareBenchmarkCPUMultiplier, - float InHardwareBenchmarkGPUMultiplier); + const FSGHardwareBenchmarkSettings& InHardwareBenchmarkSettings); }; \ No newline at end of file diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGHardwareBenchmarkSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGHardwareBenchmarkSettings.h new file mode 100644 index 00000000..ea84aeda --- /dev/null +++ b/Source/SenseGloveSettings/Public/SGSettings/SGHardwareBenchmarkSettings.h @@ -0,0 +1,64 @@ +/** + * @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 "SGHardwareBenchmarkSettings.generated.h" + +USTRUCT(BlueprintType) +struct SENSEGLOVESETTINGS_API FSGHardwareBenchmarkSettings +{ + GENERATED_USTRUCT_BODY() + +public: + UPROPERTY(Config, EditDefaultsOnly, Category = "Hardware Benchmark") + float WorkScale; + + UPROPERTY(Config, EditDefaultsOnly, Category = "Hardware Benchmark") + float CPUMultiplier; + + UPROPERTY(Config, EditDefaultsOnly, Category = "Hardware Benchmark") + float GPUMultiplier; + +public: + FSGHardwareBenchmarkSettings(); + + FSGHardwareBenchmarkSettings( + float InWorkScale, + float InCPUMultiplier, + float InGPUMultiplier); +}; \ No newline at end of file