/* Copyright UNmisterIZE(Sebastien Durocher) 2025 All Rights Reserved.

Project: NoiseMapGenerator Plugin
File: NoiseMapGeneratorSettings.h
*/
#pragma once

#include "CoreMinimal.h"
#include "Engine/DeveloperSettings.h"
#include "NoiseMapGeneratorSettings.generated.h"

UENUM()
enum class ENoiseMode : uint8
{
    Perlin,
    FBM
};

UENUM()
enum class ENoiseOutputMode : uint8
{
    Grayscale,
    SplitFirst3Octaves
};

UENUM()
enum class ENoiseAlgorithm : uint8
{
    Perlin      UMETA(DisplayName="Perlin"),
    Worley      UMETA(DisplayName="Worley (Cellular)"),
    RidgedFBM   UMETA(DisplayName="Ridged FBM")
};


UCLASS(config=EditorPerProjectUserSettings, defaultconfig)
class UNoiseMapGeneratorSettings : public UDeveloperSettings
{
    GENERATED_BODY()

public:
    virtual FName GetCategoryName() const override { return TEXT("Plugins"); }
    virtual FText GetSectionText() const override { return FText::FromString(TEXT("Noise Map Generator")); }


    // Resolution
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="8", ClampMax="16384"))
    int32 Width = 1024;
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="8", ClampMax="16384"))
    int32 Height = 1024;

    // Tiling
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="1", ClampMax="64"))
    int32 TileRepeats = 1;
    
    // Noise parameters
    UPROPERTY(EditAnywhere, config, Category = "Noise")
    int32 Seed = 1337;

    // Used by FBM (ignored for Perlin-only grayscale) 
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="1", ClampMax="12"))
    int32 Octaves = 5;

    // features size 
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="0.001", ClampMax="2.0"))
    float Frequency = 0.5f;

    // Frequency multiplier per octave 
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="1.0", ClampMax="8.0"))
    float Lacunarity = 2.0f;

    // Amplitude multiplier per octave 
    UPROPERTY(EditAnywhere, config, Category = "Noise", meta=(ClampMin="0.0", ClampMax="1.0"))
    float Gain = 0.5f;

    // Normalize result to [0..1] (if off, uses 0.5*(v+1)) 
    UPROPERTY(EditAnywhere, config, Category = "Noise")
    bool bNormalize = true;

    // Perlin or FBM for grayscale output 
    UPROPERTY(EditAnywhere, config, Category = "Noise")
    ENoiseMode Mode = ENoiseMode::FBM;

    // Which base algorithm to use 
    UPROPERTY(EditAnywhere, config, Category = "Noise")
    ENoiseAlgorithm Algorithm = ENoiseAlgorithm::Perlin;

    // Grayscale or pack first 3 octaves into RGB 
    UPROPERTY(EditAnywhere, config, Category = "Noise")
    ENoiseOutputMode OutputMode = ENoiseOutputMode::Grayscale;
 
    // Save opt
    UPROPERTY(EditAnywhere, config, Category = "Save")
    FString OutputPath = TEXT("/Game/Noise");
    
    UPROPERTY(EditAnywhere, config, Category = "Save")
    FString BaseName = TEXT("T_Noise");
    
    UPROPERTY(EditAnywhere, config, Category = "Save")
    bool bOverwrite = false;

    //UPROPERTY(EditAnywhere, config, Category = "Save")
   // bool bGenerateMips = false;
};