Ajout du projet Depths sur Git
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright Benoit Pelletier 2023 - 2025 All Rights Reserved.
|
||||
//
|
||||
// This software is available under different licenses depending on the source from which it was obtained:
|
||||
// - The Fab EULA (https://fab.com/eula) applies when obtained from the Fab marketplace.
|
||||
// - The CeCILL-C license (https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) applies when obtained from any other source.
|
||||
// Please refer to the accompanying LICENSE file for further details.
|
||||
|
||||
#include "DoorTypeFactory.h"
|
||||
#include "DoorType.h"
|
||||
#include "AssetTypeCategories.h"
|
||||
#include "ProceduralDungeonEditor.h"
|
||||
|
||||
UDoorTypeFactory::UDoorTypeFactory()
|
||||
{
|
||||
bCreateNew = true;
|
||||
bEditAfterNew = true;
|
||||
SupportedClass = UDoorType::StaticClass();
|
||||
}
|
||||
|
||||
uint32 UDoorTypeFactory::GetMenuCategories() const
|
||||
{
|
||||
FProceduralDungeonEditorModule& EditorModule = FModuleManager::LoadModuleChecked<FProceduralDungeonEditorModule>("ProceduralDungeonEditor");
|
||||
return EditorModule.GetAssetTypeCategory();
|
||||
}
|
||||
|
||||
UObject* UDoorTypeFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||
{
|
||||
UDoorType* DoorType = NewObject<UDoorType>(InParent, InClass, InName, Flags);
|
||||
return DoorType;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// Copyright Benoit Pelletier 2023 - 2025 All Rights Reserved.
|
||||
//
|
||||
// This software is available under different licenses depending on the source from which it was obtained:
|
||||
// - The Fab EULA (https://fab.com/eula) applies when obtained from the Fab marketplace.
|
||||
// - The CeCILL-C license (https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) applies when obtained from any other source.
|
||||
// Please refer to the accompanying LICENSE file for further details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Factories/Factory.h"
|
||||
#include "DoorTypeFactory.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UDoorTypeFactory : public UFactory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UDoorTypeFactory();
|
||||
|
||||
virtual uint32 GetMenuCategories() const override;
|
||||
virtual UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn);
|
||||
};
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
// Copyright Benoit Pelletier 2023 - 2025 All Rights Reserved.
|
||||
//
|
||||
// This software is available under different licenses depending on the source from which it was obtained:
|
||||
// - The Fab EULA (https://fab.com/eula) applies when obtained from the Fab marketplace.
|
||||
// - The CeCILL-C license (https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) applies when obtained from any other source.
|
||||
// Please refer to the accompanying LICENSE file for further details.
|
||||
|
||||
#include "RoomDataFactory.h"
|
||||
#include "RoomData.h"
|
||||
#include "AssetTypeCategories.h"
|
||||
#include "ProceduralDungeonEditor.h"
|
||||
#include "ClassViewerModule.h"
|
||||
#include "ClassViewerFilter.h"
|
||||
#include "Kismet2/SClassPickerDialog.h"
|
||||
#include "ProceduralDungeonEditorSettings.h"
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "RoomDataFactory"
|
||||
|
||||
// Copied and a little modified from the EditorFactories.cpp of UnrealEd module (not public)
|
||||
class FRoomDataClassFilter : public IClassViewerFilter
|
||||
{
|
||||
public:
|
||||
FRoomDataClassFilter()
|
||||
: DisallowedClassFlags(CLASS_Abstract | CLASS_Deprecated | CLASS_NewerVersionExists | CLASS_HideDropDown)
|
||||
{
|
||||
}
|
||||
|
||||
/** Disallowed class flags. */
|
||||
EClassFlags DisallowedClassFlags;
|
||||
|
||||
virtual bool IsClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const UClass* InClass, TSharedRef<FClassViewerFilterFuncs> InFilterFuncs) override
|
||||
{
|
||||
bool bAllowed = !InClass->HasAnyClassFlags(DisallowedClassFlags)
|
||||
&& InFilterFuncs->IfInChildOfClassesSet(ParentClasses, InClass) != EFilterReturn::Failed;
|
||||
|
||||
return bAllowed;
|
||||
}
|
||||
|
||||
virtual bool IsUnloadedClassAllowed(const FClassViewerInitializationOptions& InInitOptions, const TSharedRef<const IUnloadedBlueprintData> InUnloadedClassData, TSharedRef<FClassViewerFilterFuncs> InFilterFuncs) override
|
||||
{
|
||||
return !InUnloadedClassData->HasAnyClassFlags(DisallowedClassFlags)
|
||||
&& InFilterFuncs->IfInChildOfClassesSet(ParentClasses, InUnloadedClassData) != EFilterReturn::Failed;
|
||||
}
|
||||
|
||||
private:
|
||||
/** All children of these classes will be included unless filtered out by another setting. */
|
||||
static TSet<const UClass*> ParentClasses;
|
||||
};
|
||||
|
||||
TSet<const UClass*> FRoomDataClassFilter::ParentClasses {URoomData::StaticClass()};
|
||||
|
||||
URoomDataFactory::URoomDataFactory()
|
||||
{
|
||||
bCreateNew = true;
|
||||
bEditAfterNew = true;
|
||||
SupportedClass = URoomData::StaticClass();
|
||||
}
|
||||
|
||||
uint32 URoomDataFactory::GetMenuCategories() const
|
||||
{
|
||||
FProceduralDungeonEditorModule& EditorModule = FModuleManager::LoadModuleChecked<FProceduralDungeonEditorModule>("ProceduralDungeonEditor");
|
||||
return EditorModule.GetAssetTypeCategory();
|
||||
}
|
||||
|
||||
bool URoomDataFactory::ConfigureProperties()
|
||||
{
|
||||
// Get the default room data class from the editor settings
|
||||
const UProceduralDungeonEditorSettings* EditorSettings = GetDefault<UProceduralDungeonEditorSettings>();
|
||||
UClass* DefaultClass = EditorSettings->DefaultRoomDataClass.Get();
|
||||
if (!DefaultClass)
|
||||
DefaultClass = URoomData::StaticClass();
|
||||
|
||||
// TODO: want to show only RootClass and children with a plugin setting
|
||||
// However the SClassPickerDialog will always show all parent classes of the RootClass
|
||||
// (see SClassPickerDialog.cpp line 49)
|
||||
UClass* RootClass = URoomData::StaticClass();
|
||||
//if (EditorSettings->bShowOnlyDefaultAndChildren)
|
||||
// RootClass = DefaultClass;
|
||||
|
||||
// Bypass the class picker if there is no derived class of the default class
|
||||
if (EditorSettings->bUseDefaultIfNoChild)
|
||||
{
|
||||
TArray<UClass*> DerivedClasses;
|
||||
GetDerivedClasses(DefaultClass, DerivedClasses, false);
|
||||
if (DerivedClasses.Num() <= 0)
|
||||
{
|
||||
RoomDataClass = DefaultClass;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// nullptr the RoomDataClass so we can check for selection
|
||||
RoomDataClass = nullptr;
|
||||
|
||||
// Load the classviewer module to display a class picker
|
||||
FClassViewerModule& ClassViewerModule = FModuleManager::LoadModuleChecked<FClassViewerModule>("ClassViewer");
|
||||
|
||||
// The class viewer filter to show only RoomData class and its child classes
|
||||
TSharedPtr<FRoomDataClassFilter> Filter = MakeShareable(new FRoomDataClassFilter);
|
||||
|
||||
// Fill in options
|
||||
FClassViewerInitializationOptions Options;
|
||||
Options.Mode = EClassViewerMode::ClassPicker;
|
||||
Options.InitiallySelectedClass = DefaultClass;
|
||||
#if UE_VERSION_OLDER_THAN(5, 0, 0)
|
||||
Options.ClassFilter = Filter;
|
||||
#else
|
||||
Options.ClassFilters.Add(Filter.ToSharedRef());
|
||||
#endif
|
||||
|
||||
const FText TitleText = LOCTEXT("CreateRoomDataOptions", "Pick Room Data Class");
|
||||
UClass* ChosenClass = nullptr;
|
||||
const bool bPressedOk = SClassPickerDialog::PickClass(TitleText, Options, ChosenClass, RootClass);
|
||||
if (bPressedOk)
|
||||
{
|
||||
RoomDataClass = ChosenClass;
|
||||
}
|
||||
|
||||
return bPressedOk;
|
||||
}
|
||||
|
||||
UObject* URoomDataFactory::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
|
||||
{
|
||||
if (RoomDataClass != nullptr)
|
||||
{
|
||||
return NewObject<URoomData>(InParent, RoomDataClass, InName, Flags | RF_Transactional);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we have no data asset class, use the passed-in class instead
|
||||
check(InClass->IsChildOf(URoomData::StaticClass()));
|
||||
return NewObject<URoomData>(InParent, InClass, InName, Flags);
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// Copyright Benoit Pelletier 2023 - 2025 All Rights Reserved.
|
||||
//
|
||||
// This software is available under different licenses depending on the source from which it was obtained:
|
||||
// - The Fab EULA (https://fab.com/eula) applies when obtained from the Fab marketplace.
|
||||
// - The CeCILL-C license (https://cecill.info/licences/Licence_CeCILL-C_V1-en.html) applies when obtained from any other source.
|
||||
// Please refer to the accompanying LICENSE file for further details.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Factories/Factory.h"
|
||||
#include "RoomDataFactory.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class URoomDataFactory : public UFactory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
URoomDataFactory();
|
||||
|
||||
virtual uint32 GetMenuCategories() const override;
|
||||
virtual bool ConfigureProperties() override;
|
||||
virtual UObject* FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn);
|
||||
|
||||
protected:
|
||||
TSubclassOf<class URoomData> RoomDataClass;
|
||||
};
|
||||
Reference in New Issue
Block a user