// Copyright (c) 2026 CelestiaDominance. All rights reserved.

#include "BlueprintGraphThemeSelectorSettings.h"

#include "BlueprintGraphThemeSelectorModule.h"
#include "Modules/ModuleManager.h"

UBlueprintGraphThemeSelectorSettings::UBlueprintGraphThemeSelectorSettings()
    : ThemePreset(EBlueprintGraphVisualTheme::Default)
    , LowOpacityAmount(0.16f)
    , CustomNodeColor(FLinearColor(0.85f, 0.30f, 0.18f, 0.95f))
    , CustomWireColor(FLinearColor(0.18f, 0.85f, 0.92f, 0.95f))
    , CustomWireThickness(2.0f)
    , bUseCustomBackgroundImage(false)
    , BackgroundImageOpacity(0.45f)
    , BackgroundImageMovementMode(EBlueprintGraphBackgroundImageMovement::FollowGraph)
    , bHideGridWhenUsingCustomBackground(true)
{
}

#if WITH_EDITOR
void UBlueprintGraphThemeSelectorSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
    Super::PostEditChangeProperty(PropertyChangedEvent);

    SaveConfig();

    if (FModuleManager::Get().IsModuleLoaded(FBlueprintGraphThemeSelectorModule::GetModuleName()))
    {
        FBlueprintGraphThemeSelectorModule& Module = FModuleManager::GetModuleChecked<FBlueprintGraphThemeSelectorModule>(FBlueprintGraphThemeSelectorModule::GetModuleName());
        Module.ApplyThemeFromSettings();
    }
}
#endif
