// Copyright Epic Games, Inc. All Rights Reserved.

#include "PortaInterface.h"
#include "PortaSettings.h"
#if WITH_EDITOR
#include "ISettingsModule.h"
#endif

DEFINE_LOG_CATEGORY(LogPorta);

#define LOCTEXT_NAMESPACE "FPortaInterfaceModule"

void FPortaInterfaceModule::StartupModule()
{
	// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
	//FEditorModeRegistry::Get().RegisterMode<FPortaInterfaceEdMode>(FPortaInterfaceEdMode::EM_PortaInterfaceEdModeId, LOCTEXT("PortaInterfaceEdModeName", "PortaInterfaceEdMode"), FSlateIcon(), true);

#if WITH_EDITOR
	if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
	{
		SettingsModule->RegisterSettings("Project", "Plugins", "PortaSettings",
			LOCTEXT("RuntimeSettingsName", "Porta"), LOCTEXT("RuntimeSettingsDescription", "Configure Porta settings"),
			GetMutableDefault<UPortaSettings>());
	}
#endif
}

void FPortaInterfaceModule::ShutdownModule()
{
	// This function may be called during shutdown to clean up your module.  For modules that support dynamic reloading,
	// we call this function before unloading the module.
	//FEditorModeRegistry::Get().UnregisterMode(FPortaInterfaceEdMode::EM_PortaInterfaceEdModeId);
#if WITH_EDITOR
	if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
	{
		SettingsModule->UnregisterSettings("Project", "Plugins", "PortaSettings");
	}
#endif
}

#undef LOCTEXT_NAMESPACE
	
IMPLEMENT_MODULE(FPortaInterfaceModule, PortaInterface)