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

#pragma once

#include "CoreMinimal.h"
#include "Modules/ModuleInterface.h"
#include "Styling/SlateBrush.h"
#include "UObject/StrongObjectPtr.h"

class UTexture2D;

class FBlueprintGraphThemeSelectorModule final : public IModuleInterface
{
public:
    static FName GetModuleName();

    virtual void StartupModule() override;
    virtual void ShutdownModule() override;

    void ApplyThemeFromSettings() const;

private:
    void CaptureBaselinesIfNeeded() const;
    void RestoreGraphEditorBaselines(class UGraphEditorSettings* GraphEditorSettings) const;
    void RestoreEditorStyleBaselines(class UEditorStyleSettings* EditorStyleSettings) const;

    void RegisterSettings();
    void UnregisterSettings();
    bool HandleSettingsSaved();

    mutable bool bBaselinesCaptured = false;
    mutable TMap<FName, FLinearColor> GraphEditorColorBaselines;
    mutable TMap<FName, float> GraphEditorFloatBaselines;
    mutable FSlateBrush EditorStyleGraphBackgroundBaseline;
    mutable bool bEditorStyleUseGridBaseline = true;

    mutable TStrongObjectPtr<UTexture2D> CustomBackgroundTexture;
};
