some improvements for the settings module
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "SenseGloveSettingsModule.h"
|
||||
|
||||
#include "ISettingsModule.h"
|
||||
#include "ISettingsSection.h"
|
||||
|
||||
#include "SGLog/SGLog.h"
|
||||
#include "SGSettings/SGSettings.h"
|
||||
@@ -53,14 +54,25 @@ void FSenseGloveSettingsModule::StartupModule()
|
||||
{
|
||||
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<USGSettings>()
|
||||
);
|
||||
ISettingsSectionPtr SenseGloveSettingsSection{
|
||||
SettingModule->RegisterSettings(
|
||||
"Project", "Plugins", "SenseGloveSettings",
|
||||
LOCTEXT("RuntimeSettingsName", "SenseGlove"),
|
||||
LOCTEXT("RuntimeSettingsDescription", "Configure the SenseGlove settings"),
|
||||
GetMutableDefault<USGSettings>()
|
||||
)
|
||||
};
|
||||
|
||||
SGLOG("Successfully registered the SenseGlove settings manager!");
|
||||
if (SenseGloveSettingsSection.IsValid())
|
||||
{
|
||||
SenseGloveSettingsSection->OnModified().BindRaw(this, &FSenseGloveSettingsModule::OnSettingsSaved);
|
||||
|
||||
SGLOG("Successfully registered the SenseGlove settings manager!");
|
||||
}
|
||||
else
|
||||
{
|
||||
SGLOG_ERROR("Failed to register the SenseGlove settings manager!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -99,4 +111,21 @@ void FSenseGloveSettingsModule::ShutdownModule()
|
||||
}
|
||||
}
|
||||
|
||||
bool FSenseGloveSettingsModule::OnSettingsSaved() const
|
||||
{
|
||||
USGSettings* Settings = GetMutableDefault<USGSettings>();
|
||||
bool bResaveConfig = false;
|
||||
|
||||
/// TODO
|
||||
/// Validate settings here in case of invalid values.
|
||||
/// In that case, we have to set bResaveConfig to true.
|
||||
|
||||
if (bResaveConfig)
|
||||
{
|
||||
Settings->SaveConfig();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
Reference in New Issue
Block a user