commiting Source folder. Got forgotten in previous commits

This commit is contained in:
2026-04-09 21:44:44 +02:00
parent 4338efdb30
commit 563df1ffc8
91 changed files with 6756 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GMCSettings.h"
UGMCSettings::UGMCSettings()
{
}
UGMCSettings::~UGMCSettings()
{
}

View File

@@ -0,0 +1,135 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GWindow.h"
#include "GaeaSubsystem.h"
#include "WorldPartition/WorldPartitionSubsystem.h"
#include "PropertyEditorModule.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Layout/SScrollBox.h"
DEFINE_LOG_CATEGORY(GaeaWindow)
SMCWindow::SMCWindow()
{
}
SMCWindow::~SMCWindow()
{
}
SGaeaImportWindow::SGaeaImportWindow()
{
}
SGaeaImportWindow::~SGaeaImportWindow()
{
if (ImporterSettings)
{
ImporterSettings->RemoveFromRoot();
ImporterSettings = nullptr;
}
}
void SGaeaImportWindow::Construct(const FArguments& InArgs)
{
CreateDetailsView();
SWindow::Construct(SWindow::FArguments()
.Title(InArgs._Title)
.ClientSize(InArgs._ClientSize)
.SizingRule(InArgs._SizingRule)
);
this->SetContent(SNew(SVerticalBox)
+ SVerticalBox::Slot()
.FillHeight(1)
[
SNew(SScrollBox)
+ SScrollBox::Slot()
[
PropertyWidget.ToSharedRef()
]
]
+ SVerticalBox::Slot()
.AutoHeight()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Bottom)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.FillWidth(0.5)
[
SNew(SButton)
.Text(FText::FromString(("Import Heightmap")))
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
.ButtonColorAndOpacity(FLinearColor::Gray)
.OnClicked(this, &SGaeaImportWindow::OnImportClicked)
]
+ SHorizontalBox::Slot()
.FillWidth(0.5)
[
SNew(SButton)
.Text(FText::FromString(("Create Landscape")))
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
.IsEnabled_Lambda([this]() {return ImporterSettings != nullptr
&& !ImporterSettings->HeightMapFileName.IsEmpty()
&& (ImporterSettings->WeightmapFileNames.Num() == 0
|| ImporterSettings->LandscapeMaterialLayerNames.Num() == 0
|| ImporterSettings->WeightmapFileNames.Num() < ImporterSettings->LandscapeMaterialLayerNames.Num());})
.ButtonColorAndOpacity(FColor::Emerald)
.OnClicked(this, &SGaeaImportWindow::OnCreateLandscapeClicked)
]
]
);
}
void SGaeaImportWindow::CreateDetailsView()
{
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
FDetailsViewArgs Args;
Args.bAllowSearch = false;
Args.bHideSelectionTip = true;
Args.bShowScrollBar = true;
ImporterSettings = NewObject<UImporterPanelSettings>();
ImporterSettings->AddToRoot();
PropertyWidget = PropertyModule.CreateDetailView(Args);
PropertyWidget->SetObject(ImporterSettings);
ImporterSettings->Components = FIntPoint(8,8);
ImporterSettings->Resolution = FIntPoint(505,505);
ImporterSettings->TotalComponents = ImporterSettings->Components.X * ImporterSettings->Components.Y;
}
FReply SGaeaImportWindow::OnImportClicked() const
{
if (UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem())
{
check(ImporterSettings != nullptr); // check if Importer Settings is valid
Manager->ImportHeightmap(ImporterSettings->HeightMapFileName, ImporterSettings->jsonFileName, ImporterSettings->Scale, ImporterSettings->Location, ImporterSettings->WeightmapFileNames, ImporterSettings->StoredPath); // Set heightmap path, json path and scale
UE_LOG(GaeaWindow, Display, TEXT("Heightmap file path is: %s"), *ImporterSettings->HeightMapFileName); // Log the heightmap file path
UE_LOG(GaeaWindow, Display, TEXT("Json file path is: %s"), *ImporterSettings->jsonFileName); // Log the heightmap file path
UE_LOG(GaeaWindow, Display, TEXT("Scale value is: %s"), *ImporterSettings->Scale.ToString()); // Log the scale
return FReply::Handled();
}
return FReply::Handled();
}
FReply SGaeaImportWindow::OnCreateLandscapeClicked()
{
if (UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem())
{
Manager->CreateLandscapeActor(ImporterSettings);
return FReply::Handled();
}
return FReply::Handled();
}

View File

@@ -0,0 +1,16 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GaeaCommands.h"
#include "InputCoreTypes.h"
#define LOCTEXT_NAMESPACE "FGaea"
void FGaeaCommands::RegisterCommands()
{
UI_COMMAND(OpenImporter, "Open Importer", "Opens the Landscape Importer Window", EUserInterfaceActionType::Button, FInputChord(EKeys::P, EModifierKey::Control | EModifierKey::Alt));
UI_COMMAND(DeleteSelectedWPLandscape, "Delete Selected WP Landscape", "Deletes a World Partitioned Landscape and its proxies", EUserInterfaceActionType::None, FInputChord(EKeys::V, EModifierKey::Control));
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,76 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GaeaEditorStyle.h"
#include "Interfaces/IPluginManager.h"
#include "Styling/CoreStyle.h"
#include "Styling/SlateStyleRegistry.h"
DEFINE_LOG_CATEGORY(GaeaEditorStyle)
TUniquePtr<FSlateStyleSet> FGaeaEditorStyle::StyleSet;
void FGaeaEditorStyle::Initialize()
{
if (StyleSet.IsValid())
{
// Only set up once
return;
}
// Create the style sheet
StyleSet = MakeUnique<FSlateStyleSet>(GetStyleSetName());
//const FString ContentDir = "All/Plugins/GaeaUnrealTools/Icons/";
/*static const FString ContentDir = IPluginManager::Get().FindPlugin(TEXT("GaeaUnrealTools"))->GetContentDir();
UE_LOG(LogTemp, Warning, TEXT("Content Directory is: %s"), *ContentDir);
// Construct the relative path to the image file
const FString IconPath = ContentDir + "/Icons/ImporterIcon.png";*/
FString PluginPath = FPaths::Combine(FPaths::ProjectPluginsDir(), TEXT("GaeaUnrealTools"));
if (!FPaths::DirectoryExists(PluginPath))
PluginPath = FPaths::Combine(FPaths::EnginePluginsDir(), TEXT("GaeaUnrealTools"));
if (FPaths::DirectoryExists(PluginPath))
{
// Plugin found, construct the resources path
const FString ResourcesPath = FPaths::Combine(PluginPath, TEXT("Resources"));
UE_LOG(GaeaEditorStyle, Display, TEXT("Resources Directory is: %s"), *ResourcesPath);
// Construct the relative path to the image file
const FString IconPath = ResourcesPath + "/ImporterIcon.png";
StyleSet->Set("ImporterIcon", new FSlateImageBrush(IconPath, FVector2D(40.0f, 40.0f)));
}
else
{
// Plugin not found
UE_LOG(GaeaEditorStyle, Warning, TEXT("GaeaUnrealTools plugin not found"));
}
// Register the style set
FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get());
}
void FGaeaEditorStyle::Shutdown()
{
// Unregister the style set
if (StyleSet.IsValid())
{
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get());
StyleSet.Reset();
}
}
FName FGaeaEditorStyle::GetStyleSetName()
{
static const FName StyleSetName(TEXT("GaeaEditorStyle"));
return StyleSetName;
}
FString FGaeaEditorStyle::RootToPluginContentDir(const FString& RelativePath, const TCHAR* Extension)
{
static const FString ContentDir = IPluginManager::Get().FindPlugin(TEXT("GaeaUnrealTools"))->GetContentDir();
return (ContentDir / RelativePath) + Extension;
}

View File

@@ -0,0 +1,47 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GaeaLandscapeComponent.h"
#include "Engine.h"
// Sets default values for this component's properties
UGaeaLandscapeComponent::UGaeaLandscapeComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = false;
bIsEditorOnly = true;
// ...
}
// Called when the game starts
void UGaeaLandscapeComponent::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UGaeaLandscapeComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UGaeaLandscapeComponent::DestroyComponent(bool bPromoteChildren)
{
if (GEngine)
{
// Display a message on the screen
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Attempted to delete the Gaea Landscape Component, but this operation is not allowed on landscapes created with the Gaea plugin."));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,262 @@
#include "GaeaUEToolsEditor.h"
#include "GaeaEditorStyle.h"
#include "EditorStyleSet.h"
#include "GaeaCommands.h"
#include "LevelEditor.h"
#include "Misc/CoreDelegates.h"
#include "Subsystems/EditorActorSubsystem.h"
#include "GaeaLandscapeComponent.h"
#include "Landscape.h"
#include "ToolMenus.h"
#include "WorldPartition/WorldPartitionSubsystem.h"
DEFINE_LOG_CATEGORY(GaeaUETools);
#define LOCTEXT_NAMESPACE "FGaeaUEToolsEditorModule"
void FGaeaUEToolsEditorModule::StartupModule()
{
FGaeaEditorStyle::Initialize();
FGaeaCommands::Register();
/*UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(
this, &FGaeaUEToolsEditorModule::RegisterMCWindow));*/ // Register Material Creator Callback
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(
this, &FGaeaUEToolsEditorModule::RegisterGaeaActorMenu));
/*UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(
this, &FGaeaUEToolsEditorModule::RegisterLandscapeActorMenu));*/
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(
this, &FGaeaUEToolsEditorModule::RegisterImporterWindow)); // Register Importer Callback
// Bind the commands
const FLevelEditorModule& LevelEditor = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
const TSharedRef<FUICommandList> Commands = LevelEditor.GetGlobalLevelEditorActions();
Commands->MapAction(
FGaeaCommands::Get().OpenImporter,
FExecuteAction::CreateLambda([this]()
{
UE_LOG(LogTemp, Log, TEXT("Opening Gaea Landscape Importer Window"));
if (UGaeaSubsystem* GSubsystem = UGaeaSubsystem::GetGaeaSubsystem())
{
//UE_LOG(LogTemp, Log, TEXT("Opened Gaea Landscape Importer Window."));
GSubsystem->SpawnGImporterWindow();
}
})
);
}
void FGaeaUEToolsEditorModule::ShutdownModule()
{
FGaeaEditorStyle::Shutdown();
FGaeaCommands::Unregister();
UToolMenus::UnregisterOwner(this); //Unregister menu entry
}
/*void FGaeaUEToolsEditorModule::RegisterMCWindow()
{
//Register owner for menu entry
FToolMenuOwnerScoped OwnerScoped(this);
//Set our menu entry name
constexpr TCHAR ParentMenuName[] = TEXT("ContentBrowser.Toolbar");
UToolMenu* GaeaToolBar = UToolMenus::Get()->ExtendMenu(ParentMenuName);
GaeaToolBar->StyleName = TEXT("GaeaToolbar");
//Find the section of the editor menu we want to add to
//FToolMenuSection& Section = GaeaToolBar->FindOrAddSection("Tools");
FToolMenuSection& Section = GaeaToolBar->AddSection(TEXT("Gaea Material Creator"), LOCTEXT("GaeaMaterialTools_Label", "GaeaMaterialTools"));
//Create and define our UI action
FToolUIAction OpenGaeaMaterialAction;
OpenGaeaMaterialAction.ExecuteAction = FToolMenuExecuteAction::CreateLambda([](const FToolMenuContext& InContext)
{
if ( UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem())
{
Manager->SpawnGMCWindow(); // Spawn Material Creator Window
}
}
);
//Create our custom toolbar entry
const FToolMenuEntry OpenGaeaLandscapeMaterialCreator = FToolMenuEntry::InitToolBarButton(
TEXT("OpenGaeaLandscapeMaterialCreator"),
OpenGaeaMaterialAction,
LOCTEXT("OpenGaeaLandscapeMaterialCreator_Label", "Gaea Landscape Material Creation"),
LOCTEXT("OpenGaeaLandscapeMaterialCreator_Label_Description", "Opens Gaea Material Creator"),
FSlateIcon(FAppStyle::Get().GetStyleSetName(), TEXT("ClassIcon.Material")))
;
//Add our custom menu entry to our previously selected menu section
Section.AddEntry(OpenGaeaLandscapeMaterialCreator);
}*/
void FGaeaUEToolsEditorModule::RegisterImporterWindow()
{
//Register owner for menu entry
FToolMenuOwnerScoped OwnerScoped(this);
//Set our menu entry name
constexpr TCHAR ParentMenuName[] = TEXT("LevelEditor.LevelEditorToolBar.User");
UToolMenu* GaeaToolBar = UToolMenus::Get()->ExtendMenu(ParentMenuName);
GaeaToolBar->StyleName = TEXT("GaeaToolbar");
//Find the section of the editor menu we want to add to
//FToolMenuSection& Section = GaeaToolBar->FindOrAddSection("User");
FToolMenuSection& Section = GaeaToolBar->AddSection(TEXT("Gaea Landscape Importer"), LOCTEXT("GaeaLandscapeImporter_Label", "GaeaImporterTools"));
//Create and define our UI action
FToolUIAction OpenGaeaImporter;
OpenGaeaImporter.ExecuteAction = FToolMenuExecuteAction::CreateLambda([](const FToolMenuContext& InContext)
{
if ( UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem())
{
Manager->SpawnGImporterWindow(); // Spawn Importer Window
}
}
);
//Create our custom toolbar entry - OLD. Does not work with editor shortcut key.
/*const FToolMenuEntry OpenGaeaLandscapeImporter = FToolMenuEntry::InitToolBarButton(
TEXT("OpenGaeaLandscapeImporter"),
OpenGaeaImporter,
LOCTEXT("OpenGaeaLandscapeImporter_Label", "Gaea Landscape Importer"),
LOCTEXT("OpenGaeaLandscapeImporter_Label_Description", "Opens Gaea Landscape Importer"),
//FSlateIcon(FAppStyle::Get().GetStyleSetName(), TEXT("ClassIcon.LandscapeComponent")));
FSlateIcon(FGaeaEditorStyle::GetStyleSetName(), TEXT("ImporterIcon"))
);*/
const FToolMenuEntry OpenGaeaLandscapeImporter = FToolMenuEntry::InitToolBarButton(
FGaeaCommands::Get().OpenImporter,
LOCTEXT("OpenGaeaLandscapeImporter_Label", "Gaea Landscape Importer"),
LOCTEXT("OpenGaeaLandscapeImporter_Label_Description", "Opens Gaea Landscape Importer"),
FSlateIcon(FGaeaEditorStyle::GetStyleSetName(), TEXT("ImporterIcon"))
);
//Add our custom menu entry to our previously selected menu section
Section.AddEntry(OpenGaeaLandscapeImporter);
}
void FGaeaUEToolsEditorModule::RegisterGaeaActorMenu()
{
// Register owner for menu entry
FToolMenuOwnerScoped OwnerScoped(this);
// Create menu entry button in a new sub-menu
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.ActorContextMenu");
Menu->AddDynamicSection("GaeaOptions", FNewToolMenuDelegate::CreateLambda([this](UToolMenu* InMenu)
{
// This delegate is called when it is time to create the menu section
UEditorActorSubsystem* ActorSubsystem = GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
if (ActorSubsystem)
{
const TArray<AActor*>& SelectedActors = ActorSubsystem->GetSelectedLevelActors();
if (SelectedActors.Num() > 0)
{
AActor* Actor = SelectedActors[0];
if (Actor && Actor->GetClass()->IsChildOf(ALandscape::StaticClass()))
{
if (UGaeaLandscapeComponent* GaeaComponent = Actor->FindComponentByClass<UGaeaLandscapeComponent>())
{
// If a Landscape is selected, then add an item to the section
FToolMenuSection& Section = InMenu->AddSection("GaeaOptionsSection",
FText::FromString("Gaea Options"),
FToolMenuInsert("ActorGeneral", EToolMenuInsertType::Before));
Section.AddSubMenu(
"GaeaLandscapeSubMenu",
FText::FromString("Gaea Landscape Actions"),
FText::FromString("Contains various actions for landscapes imported from Gaea"),
FNewMenuDelegate::CreateRaw(this, &FGaeaUEToolsEditorModule::GaeaActorActions),
false,
FSlateIcon(FGaeaEditorStyle::GetStyleSetName(), TEXT("ImporterIcon"))
);
}
}
}
}
}));
}
void FGaeaUEToolsEditorModule::GaeaActorActions(FMenuBuilder& MenuBuilder)
{
FUIAction ExecuteReimportGaeaLandscape(
FExecuteAction::CreateLambda([]() {
if (UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem())
{
UWorld* World = GEditor->GetEditorWorldContext().World();
if (World)
{
if (World->IsPartitionedWorld())
{
Manager->ReimportGaeaWPTerrain(); // Reimport for World Partition
}
else
{
Manager->ReimportGaeaTerrain(); // Reimport for standard landscape
}
} // ReimportTerrain
}
})
);
MenuBuilder.AddMenuEntry(
FText::FromString("Refresh Landscape in Place"),
FText::FromString("Clears current landscape actor internal data and fills with the associated heightmap/weightmaps"),
FSlateIcon(),
ExecuteReimportGaeaLandscape
);
}
void FGaeaUEToolsEditorModule::RegisterLandscapeActorMenu()
{
FToolMenuOwnerScoped OwnerScoped(this);
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorSceneOutliner.ContextMenu");
FToolMenuSection& Section = Menu->FindOrAddSection("ActorOptions");
Section.AddDynamicEntry("DeleteWPLandscapeEntry", FNewToolMenuSectionDelegate::CreateLambda([](FToolMenuSection& Section)
{
FToolMenuEntry Entry = FToolMenuEntry::InitMenuEntry(
"DeleteWPLandscapeEntry",
FText::FromString("Delete World Partitioned Landscape"),
FText::FromString("Deletes selected landscape and its proxies."),
FSlateIcon(FGaeaEditorStyle::GetStyleSetName(), "ImporterIcon"),
FUIAction(
FExecuteAction::CreateLambda([]()
{
if (UGaeaSubsystem* Subsystem = UGaeaSubsystem::GetGaeaSubsystem())
{
//Subsystem->DeleteWPLandscape();
}
}),
FCanExecuteAction::CreateLambda([]()
{
UEditorActorSubsystem* ActorSubsystem = GEditor->GetEditorSubsystem<UEditorActorSubsystem>();
const TArray<AActor*>& Selected = ActorSubsystem->GetSelectedLevelActors();
const UWorld* World = GEditor->GetEditorWorldContext().World();
const bool bWP = World->IsPartitionedWorld();
return Selected.Num() > 0 && Selected[0]->IsA<ALandscape>() && bWP;
})
)
);
Entry.InsertPosition = FToolMenuInsert("EditSubMenu", EToolMenuInsertType::After);
Section.AddEntry(Entry);
}));
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FGaeaUEToolsEditorModule, GaeaUEToolsEditor)

View File

@@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GaeaWindow.h"
SGaeaWindow::SGaeaWindow()
{
}
SGaeaWindow::~SGaeaWindow()
{
}

View File

@@ -0,0 +1,39 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ImporterPanelSettings.h"
#include "GaeaSubsystem.h"
UImporterPanelSettings::UImporterPanelSettings()
{
}
UImporterPanelSettings::~UImporterPanelSettings()
{
}
void UImporterPanelSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
if (PropertyName == GET_MEMBER_NAME_CHECKED(UImporterPanelSettings, WeightmapFileNames))
{
WeightmapFilePaths.Empty();
for(int i = 0; i < WeightmapFileNames.Num(); i++)
{
FString FullPath = FPaths::Combine(*StoredPath, *WeightmapFileNames[i]);
WeightmapFilePaths.Add(FullPath); // When WeightmapFileNames is reordered or changed, we mutate WeightmapFilePaths to generate the full paths. This is for UX benefits, and the paths will be used later with the actual layer system.
}
}
else if (PropertyName == GET_MEMBER_NAME_CHECKED(UImporterPanelSettings, LandscapeMaterial))
{
UGaeaSubsystem* Manager = UGaeaSubsystem::GetGaeaSubsystem();
TArray<UMaterialExpressionLandscapeLayerBlend*> BlendNodes = Manager->GetLandscapeLayerBlendNodes(LandscapeMaterial);
Manager->GetLandscapeLayerBlendNames(BlendNodes, LandscapeMaterialLayerNames);
}
Super::PostEditChangeProperty(PropertyChangedEvent);
}