diff --git a/CHANGELOG.md b/CHANGELOG.md index 65338723..35479677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This release is breaking ABI/API compatibility with the previous versions. - Segregated Android binaries for NDK r21e (UE 4.27 and 5.0) and r25b (UE 5.1, 5.2). - Fully functional and stable Linux development support. - Fully functional and stable Unreal Engine 5.2 preview support has been added. +- Added a Plugin's settings manager. ### Changed diff --git a/README.md b/README.md index 0495852d..6bd9ef6c 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ Source │ ├── SenseGloveLog (the internal log module) │ + ├── SenseGloveSettings (the plugin's settings manager) + │ ├── SenseGloveTypes (exposes various enums from the backend libraries and also types from the SenseGlove module) │ ├── SenseGloveUtils (the internal utility module) diff --git a/SenseGlove.uplugin b/SenseGlove.uplugin index 7ada9338..7cfe854b 100644 --- a/SenseGlove.uplugin +++ b/SenseGlove.uplugin @@ -160,6 +160,16 @@ "Win64" ] }, + { + "Name": "SenseGloveSettings", + "Type": "Runtime", + "LoadingPhase": "PreDefault", + "WhitelistPlatforms": [ + "Android", + "Linux", + "Win64" + ] + }, { "Name": "SenseGloveTypes", "Type": "Runtime", diff --git a/Source/SenseGloveSettings/Private/SGTypes/SGSettings.cpp b/Source/SenseGloveSettings/Private/SGTypes/SGSettings.cpp new file mode 100644 index 00000000..4a411519 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SGTypes/SGSettings.cpp @@ -0,0 +1,86 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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/SGSettings.h" + +struct USGSettings::FImpl +{ + /************************ + * Static methods + ************************/ + + /************************ + * Owner object + ************************/ + + USGSettings* Owner; + + /************************ + * Constructor / Destructor + ************************/ + + explicit FImpl(USGSettings* InOwner); + ~FImpl(); + + /************************ + * Default copy constructor & copy assignment operator + ************************/ + + FImpl(const FImpl& Rhs) = default; + FImpl& operator=(const FImpl& Rhs) = default; + + /************************ + * Methods + ************************/ +}; + +USGSettings::USGSettings(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer), + Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) +{ + PositionalTrackingHardware = ESGPositionalTrackingHardware::None; +} + +USGSettings::FImpl::FImpl(USGSettings* InOwner) + : Owner(InOwner) +{ +} + +USGSettings::FImpl::~FImpl() = default; + +void USGSettings::FImplDeleter::operator()(const FImpl* P) const +{ + delete P; +} \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SenseGloveSettings.cpp b/Source/SenseGloveSettings/Private/SenseGloveSettings.cpp new file mode 100644 index 00000000..6bc36fb3 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SenseGloveSettings.cpp @@ -0,0 +1,40 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 "SenseGloveSettings.h" +#include "Modules/ModuleManager.h" +#include "SenseGloveSettingsModule.h" + +IMPLEMENT_MODULE(FSenseGloveSettingsModule, SenseGloveSettings) diff --git a/Source/SenseGloveSettings/Private/SenseGloveSettings.h b/Source/SenseGloveSettings/Private/SenseGloveSettings.h new file mode 100644 index 00000000..d891aa2a --- /dev/null +++ b/Source/SenseGloveSettings/Private/SenseGloveSettings.h @@ -0,0 +1,38 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 "CoreMinimal.h" diff --git a/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.cpp b/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.cpp new file mode 100644 index 00000000..5d5bd9a3 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.cpp @@ -0,0 +1,102 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 "SenseGloveSettingsModule.h" + +#include "ISettingsModule.h" + +#include "SGLog/SGLog.h" +#include "SGSettings/SGSettings.h" + +#define LOCTEXT_NAMESPACE "FSenseGloveSettingsModule" + +void FSenseGloveSettingsModule::StartupModule() +{ + SGLOG("Starting up SenseGloveSettings module..."); + + SGLOG("Trying to get the Unreal Engine's Settings module..."); + + ISettingsModule* SettingModule{FModuleManager::GetModulePtr("Settings")}; + if (SettingModule) + { + SGLOG("Registering the SenseGlove settings manager through the Unreal Engine's Settings module..."); + + SettingModule->RegisterSettings( + "Project", "Plugins", "SenseGloveSettings", + LOCTEXT("RuntimeSettingsName", "SenseGlove"), + LOCTEXT("RuntimeSettingsDescription", "Configure the SenseGlove settings"), + GetMutableDefault() + ); + + SGLOG("Successfully registered the SenseGlove settings manager!"); + } + else + { + SGLOG_ERROR("Failed to get the Unreal Engine's Settings module!"); + } +} + +void FSenseGloveSettingsModule::PreUnloadCallback() +{ + SGLOG("Unloading SenseGloveSettings module..."); +} + +void FSenseGloveSettingsModule::PostLoadCallback() +{ + SGLOG("Loading of SenseGloveSettings module has succeeded!"); +} + +void FSenseGloveSettingsModule::ShutdownModule() +{ + SGLOG("Shutting down SenseGloveSettings module..."); + + SGLOG("Trying to get the Unreal Engine's Settings module..."); + + ISettingsModule* SettingModule{FModuleManager::GetModulePtr("Settings")}; + if (SettingModule) + { + SGLOG("Unregistering the SenseGlove settings manager through the Unreal Engine's Settings module..."); + + SettingModule->UnregisterSettings("Project", "Plugins", "SenseGloveSettings"); + + SGLOG("Successfully unregistered the SenseGlove settings manager!"); + } + else + { + SGLOG_ERROR("Failed to get the Unreal Engine's Settings module!"); + } +} + +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.h b/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.h new file mode 100644 index 00000000..b5b46630 --- /dev/null +++ b/Source/SenseGloveSettings/Private/SenseGloveSettingsModule.h @@ -0,0 +1,51 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 "Modules/ModuleInterface.h" + +#define LOCTEXT_NAMESPACE "SenseGloveSettings" + +class FSenseGloveSettingsModule : public IModuleInterface +{ +public: + virtual void StartupModule() override; + virtual void PreUnloadCallback() override; + virtual void PostLoadCallback() override; + virtual void ShutdownModule() override; +}; + +#undef LOCTEXT_NAMESPACE diff --git a/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h new file mode 100644 index 00000000..07a42f24 --- /dev/null +++ b/Source/SenseGloveSettings/Public/SGSettings/SGSettings.h @@ -0,0 +1,65 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 "Templates/UniquePtr.h" +#include "UObject/Object.h" +#include "UObject/ObjectMacros.h" + +#include "SGTypes/SGCoreTypes.h" + +#include "SGSettings.generated.h" + +UCLASS(config = SenseGloveSettings) +class SENSEGLOVESETTINGS_API USGSettings : public UObject +{ + GENERATED_UCLASS_BODY() + +private: + struct FImpl; + + struct FImplDeleter + { + void operator()(const FImpl* P) const; + }; + + TUniquePtr Pimpl; + FImplDeleter PimplDeleter; + +private: + UPROPERTY(Config, EditDefaultsOnly, Category = "Tracker") + ESGPositionalTrackingHardware PositionalTrackingHardware; +}; \ No newline at end of file diff --git a/Source/SenseGloveSettings/SenseGloveSettings.Build.cs b/Source/SenseGloveSettings/SenseGloveSettings.Build.cs new file mode 100644 index 00000000..fa21388c --- /dev/null +++ b/Source/SenseGloveSettings/SenseGloveSettings.Build.cs @@ -0,0 +1,61 @@ +/** + * @file + * + * @author Mamadou Babaei + * + * @section LICENSE + * + * (The MIT License) + * + * Copyright (c) 2020 - 2023 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 + * + * + */ + + +using System; +using UnrealBuildTool; + +public class SenseGloveSettings : ModuleRules +{ + public SenseGloveSettings(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicDependencyModuleNames.AddRange( + new string[] + { + "Core", + } + ); + + PrivateDependencyModuleNames.AddRange( + new string[] + { + "CoreUObject", + "SenseGloveLog", + "SenseGloveTypes", + } + ); + } +} \ No newline at end of file