HAxis sos

This commit is contained in:
guus
2018-08-11 16:46:35 +02:00
commit 510654f8a1
480 changed files with 54126 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// A Hexagon Map with variable width and height.
//////////////////////////////////////////
#pragma once
#include "Engine/EngineTypes.h"
#include "HexMap.h"
#include "DynamicHexMap.generated.h"
USTRUCT()
struct FDynamicHexMap : public FHexMap
{
GENERATED_BODY()
protected:
//Returns true if x and y are valid positions on the hex map.
virtual bool IsPointValid( int32 a_x, int32 a_y ) override
{
bool result = !( a_x < 0 || a_x >= width || a_y < 0 || a_y >= height );
if ( result && IsOdd( a_x ) )
result = ( a_y < ( 15 ) );
return result;
}
public:
UPROPERTY( Category = Skill, EditAnywhere, meta = ( ClampMin = "1", ClampMax = "13", UIMin = "1", UIMax = "13" ) )
int32 width = 13;
UPROPERTY( Category = Skill, EditAnywhere, meta = ( ClampMin = "2", ClampMax = "16", UIMin = "2", UIMax = "16" ) )
int32 height = 16;
FDynamicHexMap()
{}
FDynamicHexMap( FDynamicHexMap& a_v )
{
for ( int i = 0; i < 13; i++ ) rawdata[i] = a_v.rawdata[i];
width = a_v.width;
height = a_v.height;
}
};

View File

@@ -0,0 +1,80 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// A Map of Hexagons with a static width and height.
//////////////////////////////////////////
#pragma once
#include "Engine/EngineTypes.h"
#include "HexMap.generated.h"
USTRUCT()
struct FHexMap
{
GENERATED_BODY()
protected:
//Get bit at position.
bool GetBit( uint16 a_byte, int32 a_pos )
{
return ( a_byte >> a_pos ) & 0x1;
}
//Set bit at position.
uint16 SetBit( uint16 a_byte, int32 a_pos, bool a_bit )
{
if ( a_bit )
a_byte |= 1 << a_pos;
else
a_byte &= ~( 1 << a_pos );
return a_byte;
}
//True if i is odd.
bool IsOdd( uint16 a_i )
{
return ( a_i % 2 != 0 );
}
//Returns true if x and y are valid positions on the map.
virtual bool IsPointValid( int32 a_x, int32 a_y )
{
bool result = !( a_x < 0 || a_x >= 13 || a_y < 0 || a_y >= 16 );
if ( result && IsOdd( a_x ) )
result = ( a_y < ( 15 ) );
return result;
}
public:
UPROPERTY()
uint16 rawdata[13];
//Get the state of a hex at given position. Returns false if position is not valid.
bool Get( int32 a_x, int32 a_y )
{
if ( !IsPointValid( a_x, a_y ) ) return false;
return GetBit( rawdata[a_x], a_y );
}
//Set the state of a hex at given position.
void Set( int32 a_x, int32 a_y, bool a_v )
{
if ( !IsPointValid( a_x, a_y ) ) return;
rawdata[a_x] = SetBit( rawdata[a_x], a_y, a_v );
}
//Invert the state of a hex at a given position.
void Invert( int32 a_x, int32 a_y )
{
if ( !IsPointValid( a_x, a_y ) ) return;
unsigned short mask = 1 << a_y;
rawdata[a_x] ^= mask;
}
FHexMap()
{}
FHexMap( FHexMap& a_v )
{
for ( int i = 0; i < 13; i++ ) rawdata[i] = a_v.rawdata[i];
}
virtual ~FHexMap() {}
};

View File

@@ -0,0 +1,28 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The base Skill Object.
//////////////////////////////////////////
#pragma once
#include "Engine/EngineTypes.h"
#include "DynamicHexMap.h"
#include "SkillObject.generated.h"
class USkillTreeObject;
UCLASS( BlueprintType, meta = (DisplayThumbnail = "true") )
class SKILLTREE_API USkillObject : public UObject
{
GENERATED_BODY()
public:
//A Dynamic Map of Hexagons.
UPROPERTY( Category = Skill, EditAnywhere )
FDynamicHexMap hexMap;
//Pointer to the parent Skill Tree.
UPROPERTY()
USkillTreeObject* skillTree;
};

View File

@@ -0,0 +1,25 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The base Skill Tree Object.
//////////////////////////////////////////
#pragma once
#include "Engine/EngineTypes.h"
#include "HexMap.h"
#include "SkillTreeObject.generated.h"
UCLASS( BlueprintType, meta = (DisplayThumbnail = "true") )
class SKILLTREE_API USkillTreeObject : public UObject
{
GENERATED_BODY()
public:
UPROPERTY()
FHexMap hexMap;
UPROPERTY( Category = SkillTree, EditAnywhere, AssetRegistrySearchable )
TArray<TSubclassOf<class USkillObject>> skills;
};

View File

@@ -0,0 +1,7 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreePrivatePCH.h"
#include "../Classes/SkillObject.h"

View File

@@ -0,0 +1,32 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreePrivatePCH.h"
#define LOCTEXT_NAMESPACE "SkillTree"
class FSkillTree : public ISkillTree
{
public:
/* IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/* End IModuleInterface implementation */
};
void FSkillTree::StartupModule()
{
// This code will execute after the module is loaded into memory (but after global variables are initialized, of course.)
}
void FSkillTree::ShutdownModule()
{
// This function may be called during shutdown to clean up the module. For modules that support dynamic reloading,
// this function gets called before unloading the module.
}
IMPLEMENT_MODULE( FSkillTree, SkillTree )
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,8 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreePrivatePCH.h"
#include "../Classes/SkillTreeObject.h"

View File

@@ -0,0 +1,11 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Module Pre Compiled Header.
//////////////////////////////////////////
#pragma once
#include "ISkillTree.h"

View File

@@ -0,0 +1,27 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Runtime Module Interface.
//////////////////////////////////////////
#pragma once
#include "ModuleManager.h"
class ISkillTree : public IModuleInterface
{
public:
//Function to Get the Singleton of this Module if it's loaded.
static inline ISkillTree& Get()
{
return FModuleManager::LoadModuleChecked< ISkillTree >( "SkillTree" );
}
//Function to check if the Module is loaded.
static inline bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded( "SkillTree" );
}
};

View File

@@ -0,0 +1,34 @@
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Runtime Module Settings.
//////////////////////////////////////////
namespace UnrealBuildTool.Rules
{
public class SkillTree : ModuleRules
{
public SkillTree(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(
new string[] {
"Core",
"CoreUObject",
"Engine"
}
);
PrivateDependencyModuleNames.AddRange(
new string[] {
"Slate",
"Renderer",
}
);
if (UEBuildConfiguration.bBuildEditor == true)
{
PrivateDependencyModuleNames.Add("UnrealEd");
}
}
}
}

View File

@@ -0,0 +1,21 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// Factory for making a Skill asset.
//////////////////////////////////////////
#pragma once
#include "SkillFactory.generated.h"
UCLASS()
class USkillFactory : public UFactory
{
GENERATED_UCLASS_BODY()
public:
// UFactory interface
virtual UObject* FactoryCreateNew( UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn ) override;
// End of UFactory interface
};

View File

@@ -0,0 +1,21 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// Factory for making a Skill Tree asset.
//////////////////////////////////////////
#pragma once
#include "SkillTreeFactory.generated.h"
UCLASS()
class USkillTreeFactory : public UFactory
{
GENERATED_UCLASS_BODY()
public:
// UFactory interface
virtual UObject* FactoryCreateNew( UClass* a_class, UObject* a_parent, FName a_name, EObjectFlags a_flags, UObject* a_context, FFeedbackContext* a_warn ) override;
// End of UFactory interface
};

View File

@@ -0,0 +1,33 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SSkillTreeEditorViewportToolbar.h"
#include "SkillTreeEditorCommands.h"
#include "SEditorViewport.h"
#define LOCTEXT_NAMESPACE "SSkillTreeEditorViewportToolbar"
void SSkillTreeEditorViewportToolbar::Construct( const FArguments& a_args, TSharedPtr<class ICommonEditorViewportToolbarInfoProvider> a_infoProvider )
{
SCommonEditorViewportToolbarBase::Construct( SCommonEditorViewportToolbarBase::FArguments(), a_infoProvider );
}
TSharedRef<SWidget> SSkillTreeEditorViewportToolbar::GenerateShowMenu() const
{
GetInfoProvider().OnFloatingButtonClicked();
TSharedRef<SEditorViewport> viewportRef = GetInfoProvider().GetViewportWidget();
const bool shouldCloseWindowAfterMenuSelection = true;
FMenuBuilder showMenuBuilder( shouldCloseWindowAfterMenuSelection, viewportRef->GetCommandList() );
{
showMenuBuilder.AddMenuEntry( FSkillTreeEditorCommands::Get().setShowGrid );
}
return showMenuBuilder.MakeWidget();
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,23 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// In-viewport toolbar widgets used in the Skill Tree Editor.
//////////////////////////////////////////
#pragma once
#include "SCommonEditorViewportToolbarBase.h"
class SSkillTreeEditorViewportToolbar : public SCommonEditorViewportToolbarBase
{
public:
SLATE_BEGIN_ARGS( SSkillTreeEditorViewportToolbar ) {}
SLATE_END_ARGS()
void Construct( const FArguments& a_args, TSharedPtr<class ICommonEditorViewportToolbarInfoProvider> a_infoProvider );
// SCommonEditorViewportToolbarBase interface
virtual TSharedRef<SWidget> GenerateShowMenu() const override;
// End of SCommonEditorViewportToolbarBase
};

View File

@@ -0,0 +1,63 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillAsset.h"
#include "AssetToolsModule.h"
#include "Classes/SkillObject.h"
#include "Classes/SkillTreeObject.h"
#include "SkillTreeEditorViewport.h"
#define LOCTEXT_NAMESPACE "AssetTypeActions"
FSkillAsset::FSkillAsset( EAssetTypeCategories::Type a_assetCategory )
: m_assetCategory( a_assetCategory )
{
}
//Gets the name of the asset.
FText FSkillAsset::GetName() const
{
return LOCTEXT( "FSkillName", "Skill" );
}
//Gets the type color of the asset.
FColor FSkillAsset::GetTypeColor() const
{
return FColor::Cyan;
}
//Gets a pointer to the class this asset implements.
UClass* FSkillAsset::GetSupportedClass() const
{
return USkillObject::StaticClass();
}
//Gets the category of this asset.
uint32 FSkillAsset::GetCategories()
{
return m_assetCategory;
}
//Opens an editor with this asset.
void FSkillAsset::OpenAssetEditor( const TArray<UObject*>& a_objects, TSharedPtr<class IToolkitHost> a_editWithinLevelEditor )
{
const EToolkitMode::Type mode = a_editWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
for ( auto i = a_objects.CreateConstIterator(); i; ++i )
{
if ( USkillObject* skill = Cast<USkillObject>( *i ) )
{
USkillTreeObject* skillTree = skill->skillTree;
if( skillTree != NULL )
{
TSharedRef<FSkillTreeEditorViewport> newSkillTreeEditor( new FSkillTreeEditorViewport() );
newSkillTreeEditor->InitSkillTreeEditor( mode, a_editWithinLevelEditor, skillTree, skill );
}
}
}
};
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,29 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// Skill asset class for adding extra
// functionality to the Skill asset.
//////////////////////////////////////////
#pragma once
#include "EditorStyle.h"
#include "AssetTypeActions_Base.h"
class FSkillAsset : public FAssetTypeActions_Base
{
public:
FSkillAsset( EAssetTypeCategories::Type a_assetCategory );
// IAssetTypeActions interface
virtual FText GetName() const override;
virtual FColor GetTypeColor() const override;
virtual UClass* GetSupportedClass() const override;
virtual void OpenAssetEditor( const TArray<UObject*>& a_objects, TSharedPtr<class IToolkitHost> a_editWithinLevelEditor = TSharedPtr<IToolkitHost>() ) override;
virtual uint32 GetCategories() override;
// End of IAssetTypeActions interface
private:
EAssetTypeCategories::Type m_assetCategory;
};

View File

@@ -0,0 +1,29 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillFactory.h"
#include "SkillObject.h"
#include "AssetRegistryModule.h"
#include "PackageTools.h"
#define LOCTEXT_NAMESPACE "SkillTree"
USkillFactory::USkillFactory( const FObjectInitializer& ObjectInitializer )
: Super( ObjectInitializer )
{
bCreateNew = true;
bEditAfterNew = true;
SupportedClass = USkillObject::StaticClass();
}
UObject* USkillFactory::FactoryCreateNew( UClass* a_class, UObject* a_parent, FName a_name, EObjectFlags a_flags, UObject* a_context, FFeedbackContext* a_warn )
{
USkillObject* newSkill = NewObject<USkillObject>( a_parent, a_class, a_name, a_flags | RF_Transactional );
return newSkill;
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,58 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeAsset.h"
#include "AssetToolsModule.h"
#include "Classes/SkillTreeObject.h"
#include "SkillTreeEditorViewport.h"
#define LOCTEXT_NAMESPACE "AssetTypeActions"
FSkillTreeAsset::FSkillTreeAsset( EAssetTypeCategories::Type a_assetCategory )
: m_assetCategory( a_assetCategory )
{
}
//Gets the name of the asset.
FText FSkillTreeAsset::GetName() const
{
return LOCTEXT( "FSkillTreeName", "Skill Tree" );
}
//Gets the type color of the asset.
FColor FSkillTreeAsset::GetTypeColor() const
{
return FColor::Cyan;
}
//Gets a pointer to the class this asset implements.
UClass* FSkillTreeAsset::GetSupportedClass() const
{
return USkillTreeObject::StaticClass();
}
//Gets the category of this asset.
uint32 FSkillTreeAsset::GetCategories()
{
return m_assetCategory;
}
//Opens an editor with this asset.
void FSkillTreeAsset::OpenAssetEditor( const TArray<UObject*>& a_objects, TSharedPtr<class IToolkitHost> a_editWithinLevelEditor )
{
const EToolkitMode::Type mode = a_editWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
for ( auto i = a_objects.CreateConstIterator(); i; ++i )
{
if ( USkillTreeObject* skillTree = Cast<USkillTreeObject>( *i ) )
{
TSharedRef<FSkillTreeEditorViewport> newSkillTreeEditor( new FSkillTreeEditorViewport() );
newSkillTreeEditor->InitSkillTreeEditor( mode, a_editWithinLevelEditor, skillTree );
}
}
};
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,29 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// Skill Tree asset class for adding extra
// functionality to the Skill Tree asset.
//////////////////////////////////////////
#pragma once
#include "EditorStyle.h"
#include "AssetTypeActions_Base.h"
class FSkillTreeAsset : public FAssetTypeActions_Base
{
public:
FSkillTreeAsset( EAssetTypeCategories::Type a_assetCategory );
// IAssetTypeActions interface
virtual FText GetName() const override;
virtual FColor GetTypeColor() const override;
virtual UClass* GetSupportedClass() const override;
virtual void OpenAssetEditor( const TArray<UObject*>& a_objects, TSharedPtr<class IToolkitHost> a_editWithinLevelEditor = TSharedPtr<IToolkitHost>() ) override;
virtual uint32 GetCategories() override;
// End of IAssetTypeActions interface
private:
EAssetTypeCategories::Type m_assetCategory;
};

View File

@@ -0,0 +1,147 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeDetailsCustomization.h"
#include "PhysicsEngine/BodySetup.h"
#include "Editor/Documentation/Public/IDocumentation.h"
#include "PropertyRestriction.h"
#include "PropertyCustomizationHelpers.h"
#include "SkillTreeObject.h"
#include "SkillObject.h"
#define LOCTEXT_NAMESPACE "SkillTreeEditor"
/////////////////////////////////////////////////////
// FSkillTreeDetailsCustomization
// Makes a new instance of this detail layout class for a specific detail view requesting it.
TSharedRef<IDetailCustomization> FSkillTreeDetailsCustomization::MakeInstance()
{
return MakeInstanceForSkillTreeEditor( );
}
// Makes a new instance of this detail layout class for a specific detail view requesting it.
TSharedRef<IDetailCustomization> FSkillTreeDetailsCustomization::MakeInstanceForSkillTreeEditor( )
{
return MakeShareable( new FSkillTreeDetailsCustomization( ) );
}
FSkillTreeDetailsCustomization::FSkillTreeDetailsCustomization( )
{
}
FDetailWidgetRow& FSkillTreeDetailsCustomization::GenerateWarningRow( IDetailCategoryBuilder& a_warningCategory, bool a_experimental, const FText& a_warningText, const FText& a_tooltip, const FString& a_excerptLink, const FString& a_excerptName )
{
const FText searchString = a_warningText;
const FSlateBrush* warningIcon = FEditorStyle::GetBrush( a_experimental ? "PropertyEditor.ExperimentalClass" : "PropertyEditor.EarlyAccessClass" );
FDetailWidgetRow& warningRow = a_warningCategory.AddCustomRow( searchString )
.WholeRowContent()
[
SNew( SHorizontalBox )
.ToolTip( IDocumentation::Get()->CreateToolTip( a_tooltip, nullptr, a_excerptLink, a_excerptName ) )
.Visibility( EVisibility::Visible )
+ SHorizontalBox::Slot()
.VAlign( VAlign_Center )
.AutoWidth()
.Padding( 4.0f, 0.0f, 0.0f, 0.0f )
[SNew( SImage )
.Image( warningIcon )
]
+ SHorizontalBox::Slot()
.VAlign( VAlign_Center )
.AutoWidth()
.Padding( 4.0f, 0.0f, 0.0f, 0.0f )
[
SNew( STextBlock )
.Text( a_warningText )
.Font( IDetailLayoutBuilder::GetDetailFont() )
]
];
return warningRow;
}
void FSkillTreeDetailsCustomization::CustomizeDetails( IDetailLayoutBuilder& a_detailLayout )
{
IDetailCategoryBuilder& skillTreeCategory = a_detailLayout.EditCategory( "SkillTree", FText::GetEmpty(), ECategoryPriority::Important );
BuildSkillTreeSection( skillTreeCategory, a_detailLayout );
}
// Makes sure Skill Tree properties are near the top.
void FSkillTreeDetailsCustomization::BuildSkillTreeSection( IDetailCategoryBuilder& a_skillTreeCategory, IDetailLayoutBuilder& a_detailLayout )
{
a_skillTreeCategory.AddProperty( GET_MEMBER_NAME_CHECKED( USkillTreeObject, skills ) );
}
/////////////////////////////////////////////////////
// FSkillDetailsCustomization
// Makes a new instance of this detail layout class for a specific detail view requesting it.
TSharedRef<IDetailCustomization> FSkillDetailsCustomization::MakeInstance()
{
return MakeInstanceForSkillTreeEditor( );
}
// Makes a new instance of this detail layout class for a specific detail view requesting it.
TSharedRef<IDetailCustomization> FSkillDetailsCustomization::MakeInstanceForSkillTreeEditor( )
{
return MakeShareable( new FSkillDetailsCustomization( ) );
}
FSkillDetailsCustomization::FSkillDetailsCustomization( )
{
}
FDetailWidgetRow& FSkillDetailsCustomization::GenerateWarningRow( IDetailCategoryBuilder& a_warningCategory, bool a_experimental, const FText& a_warningText, const FText& a_tooltip, const FString& a_excerptLink, const FString& a_excerptName )
{
const FText searchString = a_warningText;
const FSlateBrush* warningIcon = FEditorStyle::GetBrush( a_experimental ? "PropertyEditor.ExperimentalClass" : "PropertyEditor.EarlyAccessClass" );
FDetailWidgetRow& warningRow = a_warningCategory.AddCustomRow( searchString )
.WholeRowContent()
[
SNew( SHorizontalBox )
.ToolTip( IDocumentation::Get()->CreateToolTip( a_tooltip, nullptr, a_excerptLink, a_excerptName ) )
.Visibility( EVisibility::Visible )
+ SHorizontalBox::Slot()
.VAlign( VAlign_Center )
.AutoWidth()
.Padding( 4.0f, 0.0f, 0.0f, 0.0f )
[SNew( SImage )
.Image( warningIcon )
]
+ SHorizontalBox::Slot()
.VAlign( VAlign_Center )
.AutoWidth()
.Padding( 4.0f, 0.0f, 0.0f, 0.0f )
[
SNew( STextBlock )
.Text( a_warningText )
.Font( IDetailLayoutBuilder::GetDetailFont() )
]
];
return warningRow;
}
void FSkillDetailsCustomization::CustomizeDetails( IDetailLayoutBuilder& a_detailLayout )
{
IDetailCategoryBuilder& skillCategory = a_detailLayout.EditCategory( "Skill", FText::GetEmpty(), ECategoryPriority::Important );
BuildSkillSection( skillCategory, a_detailLayout );
}
// Makes sure Skill properties are near the top.
void FSkillDetailsCustomization::BuildSkillSection( IDetailCategoryBuilder& a_skillCategory, IDetailLayoutBuilder& a_detailLayout )
{
a_skillCategory.AddProperty( GET_MEMBER_NAME_CHECKED( USkillObject, hexMap ) );
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,55 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#pragma once
#include "PropertyEditing.h"
#include "SkillTreeEditorViewportClient.h"
//////////////////////////////////////////
// The Skill Tree Details viewport.
//////////////////////////////////////////
class FSkillTreeDetailsCustomization : public IDetailCustomization
{
public:
static TSharedRef<IDetailCustomization> MakeInstance();
static TSharedRef<IDetailCustomization> MakeInstanceForSkillTreeEditor( );
// IDetailCustomization interface
virtual void CustomizeDetails( IDetailLayoutBuilder& DetailLayout ) override;
// End of IDetailCustomization interface
protected:
FSkillTreeDetailsCustomization( );
static FDetailWidgetRow& GenerateWarningRow( IDetailCategoryBuilder& a_warningCategory, bool a_experimental, const FText& a_warningText, const FText& a_tooltip, const FString& a_excerptLink, const FString& a_excerptName );
void BuildSkillTreeSection( IDetailCategoryBuilder& a_skillTreeCategory, IDetailLayoutBuilder& a_detailLayout );
};
//////////////////////////////////////////
// The Skill Details viewport.
//////////////////////////////////////////
class FSkillDetailsCustomization : public IDetailCustomization
{
public:
static TSharedRef<IDetailCustomization> MakeInstance();
static TSharedRef<IDetailCustomization> MakeInstanceForSkillTreeEditor( );
// IDetailCustomization interface
virtual void CustomizeDetails( IDetailLayoutBuilder& DetailLayout ) override;
// End of IDetailCustomization interface
protected:
FSkillDetailsCustomization( );
static FDetailWidgetRow& GenerateWarningRow( IDetailCategoryBuilder& a_warningCategory, bool a_experimental, const FText& a_warningText, const FText& a_tooltip, const FString& a_excerptLink, const FString& a_excerptName );
void BuildSkillSection( IDetailCategoryBuilder& a_skillCategory, IDetailLayoutBuilder& a_detailLayout );
};

View File

@@ -0,0 +1,9 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeEditMode.h"
const FEditorModeID FSkillTreeEditMode::EM_skillTree( TEXT( "SkillTreeEditMode" ) );

View File

@@ -0,0 +1,20 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor mode class.
//////////////////////////////////////////
#include "UnrealEd.h"
#include "EditorModeRegistry.h"
#pragma once
class FSkillTreeEditMode : public FEdMode
{
public:
//The ID of the Skill Tree Editor.
static const FEditorModeID EM_skillTree;
public:
FSkillTreeEditMode(){};
};

View File

@@ -0,0 +1,72 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "AssetToolsModule.h"
#include "ModuleManager.h"
#include "SkillTreeAsset.h"
#include "SkillAsset.h"
#include "SkillTreeEditMode.h"
#include "SkillTreeEditorCommands.h"
#define LOCTEXT_NAMESPACE "SkillTreeEditor"
EAssetTypeCategories::Type skillTreeAssetCategoryBit;
class FSkillTreeEditor : public ISkillTreeEditor
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
void RegisterAssetTypeAction( IAssetTools& a_assetTools, TSharedRef<IAssetTypeActions> a_action );
private:
TArray< TSharedPtr<IAssetTypeActions> > m_createdAssetTypeActions;
};
void FSkillTreeEditor::RegisterAssetTypeAction( IAssetTools& a_assetTools, TSharedRef<IAssetTypeActions> a_action )
{
a_assetTools.RegisterAssetTypeActions( a_action );
m_createdAssetTypeActions.Add( a_action );
}
void FSkillTreeEditor::StartupModule()
{
FSkillTreeEditorCommands::Register();
IAssetTools& assetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>( "AssetTools" ).Get();
//Register the category of the assets.
skillTreeAssetCategoryBit = assetTools.RegisterAdvancedAssetCategory( FName( TEXT( "SkillTree" ) ), LOCTEXT( "SkillTreeAssetCategory", "Skill Tree" ) );
//Register the asset to the category.
RegisterAssetTypeAction( assetTools, MakeShareable( new FSkillTreeAsset( skillTreeAssetCategoryBit ) ) );
FEditorModeRegistry::Get().RegisterMode<FSkillTreeEditMode>( FSkillTreeEditMode::EM_skillTree, LOCTEXT( "SkillTreeEditMode", "Skill Tree Editor" ), FSlateIcon(), false );
}
void FSkillTreeEditor::ShutdownModule()
{
FEditorModeRegistry::Get().UnregisterMode( FSkillTreeEditMode::EM_skillTree );
//Unregister all the assets.
if ( FModuleManager::Get().IsModuleLoaded( "AssetTools" ) )
{
IAssetTools& AssetTools = FModuleManager::GetModuleChecked<FAssetToolsModule>( "AssetTools" ).Get();
for ( int32 i = 0; i < m_createdAssetTypeActions.Num(); ++i )
{
AssetTools.UnregisterAssetTypeActions( m_createdAssetTypeActions[i].ToSharedRef() );
}
}
m_createdAssetTypeActions.Empty();
FSkillTreeEditorCommands::Unregister();
}
IMPLEMENT_MODULE( FSkillTreeEditor, SkillTreeEditor )
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,20 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeEditorCommands.h"
#define LOCTEXT_NAMESPACE ""
void FSkillTreeEditorCommands::RegisterCommands()
{
// Show toggles
UI_COMMAND( setShowGrid, "Grid", "Displays the viewport grid.", EUserInterfaceActionType::ToggleButton, FInputChord() );
// Editing modes
UI_COMMAND( enterViewMode, "View", "View the sprite.", EUserInterfaceActionType::ToggleButton, FInputChord() );
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,30 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor commands class.
//////////////////////////////////////////
#pragma once
class FSkillTreeEditorCommands : public TCommands<FSkillTreeEditorCommands>
{
public:
FSkillTreeEditorCommands()
: TCommands<FSkillTreeEditorCommands>(
TEXT( "SkillTreeEditor" ),
NSLOCTEXT( "Contexts", "SkillTreeEditor", "Skill Tree Editor" ),
NAME_None,
FName(TEXT("null"))
)
{
}
// TCommand<> interface
virtual void RegisterCommands() override;
// End of TCommand<> interface
//TODO: Remove?
TSharedPtr<FUICommandInfo> setShowGrid;
TSharedPtr<FUICommandInfo> enterViewMode;
};

View File

@@ -0,0 +1,13 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor Module Pre Compiled Header.
//////////////////////////////////////////
#pragma once
#include "UnrealEd.h"
#include "ISkillTreeEditor.h"

View File

@@ -0,0 +1,532 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeEditorViewport.h"
#include "SceneViewport.h"
#include "GraphEditor.h"
#include "SDockTab.h"
#include "SEditorViewport.h"
#include "SCommonEditorViewportToolbarBase.h"
#include "ISkillTree.h"
#include "SkillTreeEditorViewportClient.h"
#include "SSkillTreeEditorViewportToolbar.h"
#include "SkillTreeObject.h"
#include "SkillObject.h"
#include "WorkspaceMenuStructureModule.h"
#include "SkillTreeEditorCommands.h"
#include "SSingleObjectDetailsPanel.h"
#include "SkillTreeDetailsCustomization.h"
#define LOCTEXT_NAMESPACE "SkillTreeEditor"
const FName skillTreeEditorAppName = FName( TEXT( "SkillTreeEditorApp" ) );
// Tab identifiers.
struct FSkillTreeEditorTabs
{
static const FName skillTreeViewportID;
static const FName skillTreeDetailViewportID;
static const FName skillViewportID;
static const FName skillDetailViewportID;
};
const FName FSkillTreeEditorTabs::skillTreeViewportID( TEXT( "STViewport" ) );
const FName FSkillTreeEditorTabs::skillViewportID( TEXT( "SViewport" ) );
const FName FSkillTreeEditorTabs::skillTreeDetailViewportID( TEXT( "STDViewport" ) );
const FName FSkillTreeEditorTabs::skillDetailViewportID( TEXT( "SDViewport" ) );
//TODO: Make separate headers for these classes.
/////////////////////////////////////////////////////
// SSkillTreePropertiesTabBody
class SSkillTreePropertiesTabBody : public SSingleObjectDetailsPanel
{
public:
SLATE_BEGIN_ARGS( SSkillTreePropertiesTabBody ) {}
SLATE_END_ARGS()
private:
// Pointer back to owning skill tree editor instance.
TWeakPtr<class FSkillTreeEditorViewport> m_skillTreeEditorPtr;
public:
void Construct( const FArguments& a_args, TSharedPtr<FSkillTreeEditorViewport> a_skillTreeEditor )
{
m_skillTreeEditorPtr = a_skillTreeEditor;
SSingleObjectDetailsPanel::Construct( SSingleObjectDetailsPanel::FArguments().HostCommandList( a_skillTreeEditor->GetToolkitCommands() ), true, true );
FOnGetDetailCustomizationInstance customizeSkillTreeForEditor = FOnGetDetailCustomizationInstance::CreateStatic( &FSkillTreeDetailsCustomization::MakeInstanceForSkillTreeEditor );
PropertyView->RegisterInstancedCustomPropertyLayout( USkillTreeObject::StaticClass(), customizeSkillTreeForEditor );
}
// SSingleObjectDetailsPanel interface
virtual UObject* GetObjectToObserve() const override
{
return m_skillTreeEditorPtr.Pin()->GetSkillTreeBeingEdited();
}
virtual TSharedRef<SWidget> PopulateSlot( TSharedRef<SWidget> a_propertyEditorWidget ) override
{
return SNew( SVerticalBox )
+ SVerticalBox::Slot()
.FillHeight( 1 )
[
a_propertyEditorWidget
];
}
// End of SSingleObjectDetailsPanel interface
};
/////////////////////////////////////////////////////
// SSkillPropertiesTabBody
class SSkillPropertiesTabBody : public SSingleObjectDetailsPanel
{
public:
SLATE_BEGIN_ARGS( SSkillPropertiesTabBody ) {}
SLATE_END_ARGS()
private:
// Pointer back to owning sprite editor instance (the keeper of state)
TWeakPtr<class FSkillTreeEditorViewport> m_skillTreeEditorPtr;
public:
void Construct( const FArguments& InArgs, TSharedPtr<FSkillTreeEditorViewport> a_skillTreeEditor )
{
m_skillTreeEditorPtr = a_skillTreeEditor;
SSingleObjectDetailsPanel::Construct( SSingleObjectDetailsPanel::FArguments().HostCommandList( a_skillTreeEditor->GetToolkitCommands() ), true, true );
FOnGetDetailCustomizationInstance customizeSkillTreeForEditor = FOnGetDetailCustomizationInstance::CreateStatic( &FSkillDetailsCustomization::MakeInstanceForSkillTreeEditor );
PropertyView->RegisterInstancedCustomPropertyLayout( USkillObject::StaticClass(), customizeSkillTreeForEditor );
}
// SSingleObjectDetailsPanel interface
virtual UObject* GetObjectToObserve() const override
{
return m_skillTreeEditorPtr.Pin()->GetSkillBeingEdited();
}
virtual TSharedRef<SWidget> PopulateSlot( TSharedRef<SWidget> a_propertyEditorWidget ) override
{
return SNew( SVerticalBox )
+ SVerticalBox::Slot()
.FillHeight( 1 )
[
a_propertyEditorWidget
];
}
// End of SSingleObjectDetailsPanel interface
};
/////////////////////////////////////////////////////
// SSkillTreeEditorViewport
class SSkillTreeEditorViewport : public SEditorViewport, public ICommonEditorViewportToolbarInfoProvider
{
public:
SLATE_BEGIN_ARGS( SSkillTreeEditorViewport ) {}
SLATE_END_ARGS()
void Construct( const FArguments& a_args, TSharedPtr<FSkillTreeEditorViewport> a_spriteEditor );
// SEditorViewport interface
virtual void BindCommands() override;
virtual TSharedRef<FEditorViewportClient> MakeEditorViewportClient() override;
virtual TSharedPtr<SWidget> MakeViewportToolbar() override;
virtual EVisibility GetTransformToolbarVisibility() const override;
virtual void OnFloatingButtonClicked() override;
// End of SEditorViewport interface
// ICommonEditorViewportToolbarInfoProvider interface
virtual TSharedRef<class SEditorViewport> GetViewportWidget() override;
virtual TSharedPtr<FExtender> GetExtenders() const override;
// End of ICommonEditorViewportToolbarInfoProvider interface
void ActivateEditMode()
{
m_editorViewportClient->ActivateEditMode();
}
void IsSkill( bool a_state )
{
m_editorViewportClient->IsSkill( a_state );
}
private:
// Pointer back to owning Skill Tree editor instance (the keeper of state).
TWeakPtr<class FSkillTreeEditorViewport> m_skillTreeEditorPtr;
// Viewport client
TSharedPtr<FSkillTreeEditorViewportClient> m_editorViewportClient;
};
void SSkillTreeEditorViewport::Construct( const FArguments& a_args, TSharedPtr<FSkillTreeEditorViewport> a_skillTreeEditor )
{
m_skillTreeEditorPtr = a_skillTreeEditor;
SEditorViewport::Construct( SEditorViewport::FArguments() );
}
void SSkillTreeEditorViewport::BindCommands()
{
SEditorViewport::BindCommands();
const FSkillTreeEditorCommands& commands = FSkillTreeEditorCommands::Get();
TSharedRef<FSkillTreeEditorViewportClient> editorViewportClientRef = m_editorViewportClient.ToSharedRef();
// Show toggles
//TODO: Remove.
CommandList->MapAction(
commands.setShowGrid,
FExecuteAction::CreateSP( editorViewportClientRef, &FEditorViewportClient::SetShowGrid ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( editorViewportClientRef, &FEditorViewportClient::IsSetShowGridChecked ) );
// Editing modes
//TODO: Remove.
CommandList->MapAction(
commands.enterViewMode,
FExecuteAction::CreateSP( editorViewportClientRef, &FSkillTreeEditorViewportClient::EnterViewMode ),
FCanExecuteAction(),
FIsActionChecked::CreateSP( editorViewportClientRef, &FSkillTreeEditorViewportClient::IsInViewMode ) );
}
// Make a new client for the viewport.
TSharedRef<FEditorViewportClient> SSkillTreeEditorViewport::MakeEditorViewportClient()
{
m_editorViewportClient = MakeShareable( new FSkillTreeEditorViewportClient( m_skillTreeEditorPtr, SharedThis( this ) ) );
return m_editorViewportClient.ToSharedRef();
}
TSharedPtr<SWidget> SSkillTreeEditorViewport::MakeViewportToolbar()
{
return SNew( SSkillTreeEditorViewportToolbar, SharedThis( this ) );
}
EVisibility SSkillTreeEditorViewport::GetTransformToolbarVisibility() const
{
return EVisibility::Visible;
}
TSharedRef<class SEditorViewport> SSkillTreeEditorViewport::GetViewportWidget()
{
return SharedThis( this );
}
TSharedPtr<FExtender> SSkillTreeEditorViewport::GetExtenders() const
{
TSharedPtr<FExtender> Result( MakeShareable( new FExtender ) );
return Result;
}
//Needed to be implemented but not used.
void SSkillTreeEditorViewport::OnFloatingButtonClicked()
{
}
/////////////////////////////////////////////////////
// FSkillTreeEditorViewport
TSharedRef<SDockTab> FSkillTreeEditorViewport::SpawnTab_SKViewport( const FSpawnTabArgs& a_args )
{
return SNew( SDockTab )
.Label( LOCTEXT( "SKViewportTab_Title", "Skill Tree" ) )
[
SNew( SOverlay )
// The Skill Tree editor viewport
+ SOverlay::Slot()
[
m_skillTreeViewport.ToSharedRef()
]
// Bottom-right corner text indicating the preview nature of the viewport.
+ SOverlay::Slot()
.Padding( 10 )
.VAlign( VAlign_Bottom )
.HAlign( HAlign_Right )
[
SNew( STextBlock )
.Visibility( EVisibility::HitTestInvisible )
.TextStyle( FEditorStyle::Get(), "Graph.CornerText" )
.Text( LOCTEXT( "SKViewportTab_CornerText", "Edit Skill Tree" ) )
]
];
}
TSharedRef<SDockTab> FSkillTreeEditorViewport::SpawnTab_SViewport( const FSpawnTabArgs& a_args )
{
return SNew( SDockTab )
.Label( LOCTEXT( "SViewportTab_Title", "Skill" ) )
[
SNew( SOverlay )
// The sprite editor viewport
+ SOverlay::Slot()
[
m_skillViewport.ToSharedRef()
]
// Bottom-right corner text indicating the preview nature of the viewport.
+ SOverlay::Slot()
.Padding( 10 )
.VAlign( VAlign_Bottom )
.HAlign( HAlign_Right )
[
SNew( STextBlock )
.Visibility( EVisibility::HitTestInvisible )
.TextStyle( FEditorStyle::Get(), "Graph.CornerText" )
.Text( LOCTEXT("SViewportTab_CornerText", "Edit Skill") )
]
];
}
TSharedRef<SDockTab> FSkillTreeEditorViewport::SpawnTab_SKDViewport( const FSpawnTabArgs& a_args )
{
TSharedPtr<FSkillTreeEditorViewport> editorPtr = SharedThis( this );
// Spawn the tab
return SNew( SDockTab )
.Label( LOCTEXT( "SKDViewportTab_Title", "Skill Tree Details" ) )
[
SNew( SSkillTreePropertiesTabBody, editorPtr )
];
}
TSharedRef<SDockTab> FSkillTreeEditorViewport::SpawnTab_SDViewport( const FSpawnTabArgs& a_args )
{
TSharedPtr<FSkillTreeEditorViewport> editorPtr = SharedThis( this );
// Spawn the tab
return SNew( SDockTab )
.Label( LOCTEXT( "SDViewportTab_Title", "Skill Details" ) )
[
SNew( SSkillPropertiesTabBody, editorPtr )
];
}
void FSkillTreeEditorViewport::RegisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager )
{
WorkspaceMenuCategory = a_tabManager->AddLocalWorkspaceMenuCategory( LOCTEXT( "WorkspaceMenu_SpriteEditor", "Skill Tree Editor" ) );
auto workspaceMenuCategoryRef = WorkspaceMenuCategory.ToSharedRef();
FAssetEditorToolkit::RegisterTabSpawners( a_tabManager );
a_tabManager->RegisterTabSpawner( FSkillTreeEditorTabs::skillTreeViewportID, FOnSpawnTab::CreateSP( this, &FSkillTreeEditorViewport::SpawnTab_SKViewport ) )
.SetDisplayName( LOCTEXT( "SKViewportTab", "Skill Tree" ) )
.SetGroup( workspaceMenuCategoryRef )
.SetIcon( FSlateIcon( FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports" ) );
a_tabManager->RegisterTabSpawner( FSkillTreeEditorTabs::skillTreeDetailViewportID, FOnSpawnTab::CreateSP( this, &FSkillTreeEditorViewport::SpawnTab_SKDViewport ) )
.SetDisplayName( LOCTEXT( "SKDViewportTab", "Skill Tree Details" ) )
.SetGroup( workspaceMenuCategoryRef )
.SetIcon( FSlateIcon( FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports" ) );
a_tabManager->RegisterTabSpawner( FSkillTreeEditorTabs::skillViewportID, FOnSpawnTab::CreateSP( this, &FSkillTreeEditorViewport::SpawnTab_SViewport ) )
.SetDisplayName( LOCTEXT( "SViewportTab", "Skill" ) )
.SetGroup( workspaceMenuCategoryRef )
.SetIcon( FSlateIcon( FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports" ) );
a_tabManager->RegisterTabSpawner( FSkillTreeEditorTabs::skillDetailViewportID, FOnSpawnTab::CreateSP( this, &FSkillTreeEditorViewport::SpawnTab_SDViewport ) )
.SetDisplayName( LOCTEXT( "SDViewportTab", "Skill Details" ) )
.SetGroup( workspaceMenuCategoryRef )
.SetIcon( FSlateIcon( FEditorStyle::GetStyleSetName(), "LevelEditor.Tabs.Viewports" ) );
}
void FSkillTreeEditorViewport::UnregisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager )
{
FAssetEditorToolkit::UnregisterTabSpawners( a_tabManager );
a_tabManager->UnregisterTabSpawner( FSkillTreeEditorTabs::skillTreeViewportID );
a_tabManager->UnregisterTabSpawner( FSkillTreeEditorTabs::skillTreeDetailViewportID );
a_tabManager->UnregisterTabSpawner( FSkillTreeEditorTabs::skillViewportID );
a_tabManager->UnregisterTabSpawner( FSkillTreeEditorTabs::skillDetailViewportID );
}
FName FSkillTreeEditorViewport::GetToolkitFName() const
{
return FName( "SkillTreeEditor" );
}
void FSkillTreeEditorViewport::SetSkillBeingEdited( USkillObject* a_skill )
{
if ( (a_skill != m_skillBeingEdited) && (a_skill != nullptr) )
{
USkillObject* oldSkill = m_skillBeingEdited;
m_skillBeingEdited = a_skill;
//No longer needed.
/*
RemoveEditingObject( oldSkill );
AddEditingObject( a_skill );
*/
}
}
FText FSkillTreeEditorViewport::GetBaseToolkitName() const
{
return LOCTEXT( "SkillTreeEditorAppLabel", "Skill Tree" );
}
FText FSkillTreeEditorViewport::GetToolkitName() const
{
bool dirtyState = (m_skillTreeBeingEdited->GetOutermost()->IsDirty() || m_skillBeingEdited->GetOutermost()->IsDirty());
FFormatNamedArguments args;
args.Add( TEXT( "SkillTreeName" ), FText::FromString( m_skillTreeBeingEdited->GetName() ) );
args.Add( TEXT( "DirtyState" ), dirtyState ? FText::FromString( TEXT( "*" ) ) : FText::GetEmpty() );
return FText::Format( LOCTEXT( "SkillTreeEditorAppLabel", "{SkillTreeName}{DirtyState}" ), args );
}
FText FSkillTreeEditorViewport::GetToolkitToolTipText() const
{
return LOCTEXT( "SkillTreeToolTip", "Test tooltip text" );
}
FString FSkillTreeEditorViewport::GetWorldCentricTabPrefix() const
{
return TEXT( "SkillTreeEditor" );
}
FString FSkillTreeEditorViewport::GetDocumentationLink() const
{
return TEXT( "http://iamfromtheinternet.nl/wiki/index.php/Skill_Tree" );
}
FLinearColor FSkillTreeEditorViewport::GetWorldCentricTabColorScale() const
{
return FLinearColor::White;
}
void FSkillTreeEditorViewport::CreateModeToolbarWidgets( FToolBarBuilder& a_ignoredBuilder )
{
FToolBarBuilder toolbarBuilder( m_skillTreeViewport->GetCommandList(), FMultiBoxCustomization::None );
toolbarBuilder.AddToolBarButton( FSkillTreeEditorCommands::Get().enterViewMode );
AddToolbarWidget( toolbarBuilder.MakeWidget() );
}
void FSkillTreeEditorViewport::InitSkillTreeEditor( const EToolkitMode::Type a_mode, const TSharedPtr< class IToolkitHost >& a_toolkitHost, class USkillTreeObject* a_skillTree, class USkillObject* a_skill )
{
m_skillTreeBeingEdited = a_skillTree;
m_tmpSkills = m_skillTreeBeingEdited->skills;
if ( !a_skill )
{
m_skillBeingEdited = NewObject<USkillObject>();
m_skillBeingEdited->hexMap.width = 0;
m_skillBeingEdited->hexMap.height = 0;
}
else
{
m_skillBeingEdited = a_skill;
selectedY = m_tmpSkills.Find( TSubclassOf<USkillObject>((UClass*)m_skillBeingEdited) );
}
FSkillTreeEditorCommands::Register();
TSharedPtr<FSkillTreeEditorViewport> skillTreeEditorPtr = SharedThis( this );
m_skillTreeViewport = SNew( SSkillTreeEditorViewport, skillTreeEditorPtr );
m_skillViewport = SNew( SSkillTreeEditorViewport, skillTreeEditorPtr );
m_skillViewport->IsSkill( true );
const TSharedRef<FTabManager::FLayout> defaultLayout = FTabManager::NewLayout( "SkillTreeEditor_Layout_v2" )
->AddArea
(
FTabManager::NewPrimaryArea()
->SetOrientation( Orient_Vertical )
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient( 0.1f )
->SetHideTabWell( true )
->AddTab( GetToolbarTabId(), ETabState::OpenedTab )
)
->Split
(
FTabManager::NewSplitter()
->SetOrientation( Orient_Horizontal )
->SetSizeCoefficient( 0.9f )
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient( 0.35f )
->SetHideTabWell( true )
->AddTab( FSkillTreeEditorTabs::skillTreeViewportID, ETabState::OpenedTab )
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient( 0.15f )
->SetHideTabWell( true )
->AddTab( FSkillTreeEditorTabs::skillTreeDetailViewportID, ETabState::OpenedTab )
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient( 0.35f )
->SetHideTabWell( true )
->AddTab( FSkillTreeEditorTabs::skillViewportID, ETabState::OpenedTab )
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient( 0.15f )
->SetHideTabWell( true )
->AddTab( FSkillTreeEditorTabs::skillDetailViewportID, ETabState::OpenedTab )
)
)
);
// Initialize the asset editor
InitAssetEditor( a_mode, a_toolkitHost, skillTreeEditorAppName, defaultLayout, true, true, a_skillTree );
m_skillTreeViewport->ActivateEditMode();
m_skillViewport->ActivateEditMode();
// Extend things
RegenerateMenusAndToolbars();
}
void FSkillTreeEditorViewport::UpdateSkills()
{
if ( m_skillTreeBeingEdited->skills != m_tmpSkills )
{
for ( int i = 0; i < m_tmpSkills.Num(); i++ )
{
if ( m_tmpSkills[i] != NULL && !m_skillTreeBeingEdited->skills.Contains( m_tmpSkills[i] ) )
{
USkillObject* tmpSkill = (USkillObject*)*m_tmpSkills[i];//m_tmpSkills[i]->GetDefaultObject<USkillObject>();
if ( tmpSkill != NULL ) tmpSkill->skillTree = NULL;
}
}
for ( int i = 0; i < m_skillTreeBeingEdited->skills.Num(); i++ )
{
if ( m_skillTreeBeingEdited->skills[i] != NULL && !m_tmpSkills.Contains( m_skillTreeBeingEdited->skills[i] ) )
{
USkillObject* tmpSkill = (USkillObject*)*m_skillTreeBeingEdited->skills[i]; //m_skillTreeBeingEdited->skills[i]->GetDefaultObject<USkillObject>();
if ( tmpSkill != NULL ) tmpSkill->skillTree = m_skillTreeBeingEdited;
}
}
m_tmpSkills = m_skillTreeBeingEdited->skills;
}
}
void FSkillTreeEditorViewport::SaveAsset_Execute()
{
TArray< UPackage* > PackagesToSave;
PackagesToSave.Add( m_skillTreeBeingEdited->GetOutermost() );
PackagesToSave.Add( m_skillBeingEdited->GetOutermost() );
FEditorFileUtils::PromptForCheckoutAndSave( PackagesToSave, bCheckDirtyOnAssetSave, /*bPromptToSave=*/ false );
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,71 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor main class.
//////////////////////////////////////////
#pragma once
#include "Toolkits/AssetEditorToolkit.h"
#include "Toolkits/AssetEditorManager.h"
class SSkillTreeEditorViewport;
class USkillTreeObject;
class USkillObject;
class FSkillTreeEditorViewport : public FAssetEditorToolkit//, public FGCObject
{
public:
//The ID of the selected Skill.
int32 selectedY = -1;
// IToolkit interface
virtual void RegisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager ) override;
virtual void UnregisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager ) override;
// End of IToolkit interface
// FAssetEditorToolkit
virtual FName GetToolkitFName() const override;
virtual FText GetBaseToolkitName() const override;
virtual FText GetToolkitName() const override;
virtual FText GetToolkitToolTipText() const override;
virtual FLinearColor GetWorldCentricTabColorScale() const override;
virtual FString GetWorldCentricTabPrefix() const override;
virtual FString GetDocumentationLink() const override;
virtual void SaveAsset_Execute() override;
// End of FAssetEditorToolkit
//Set the Skill to Edit.
void SetSkillBeingEdited( USkillObject* a_skill );
//Get the Current Skill Tree that is being edited.
USkillTreeObject* GetSkillTreeBeingEdited() const { return m_skillTreeBeingEdited; };
//Get the Current Skill that is being edited.
USkillObject* GetSkillBeingEdited() const { return m_skillBeingEdited; };
void InitSkillTreeEditor( const EToolkitMode::Type a_mode, const TSharedPtr< class IToolkitHost >& a_toolkitHost, class USkillTreeObject* a_skillTree, class USkillObject* a_skill = NULL );
void UpdateSkills();
protected:
// A temporary list of Skills to check agains to see if new Skills have been added.
TArray<TSubclassOf<USkillObject>> m_tmpSkills;
// The pointer to the current Skill Tree.
USkillTreeObject* m_skillTreeBeingEdited;
// The pointer to the current Skill.
USkillObject* m_skillBeingEdited = NULL;
// The pointer to the Skill Tree Viewport.
TSharedPtr<SSkillTreeEditorViewport> m_skillTreeViewport;
// The pointer to the Skill Viewport.
TSharedPtr<SSkillTreeEditorViewport> m_skillViewport;
// Functions to spawn the Viewports and Details
TSharedRef<SDockTab> SpawnTab_SKViewport( const FSpawnTabArgs& a_args );
TSharedRef<SDockTab> SpawnTab_SViewport( const FSpawnTabArgs& a_args );
TSharedRef<SDockTab> SpawnTab_SKDViewport( const FSpawnTabArgs& a_args );
TSharedRef<SDockTab> SpawnTab_SDViewport( const FSpawnTabArgs& a_args );
// Creates the toolbar buttons.
void CreateModeToolbarWidgets( FToolBarBuilder& ToolbarBuilder );
};

View File

@@ -0,0 +1,333 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeEditorViewportClient.h"
#include "SceneViewport.h"
#include "PreviewScene.h"
#include "ScopedTransaction.h"
#include "Runtime/Engine/Public/ComponentReregisterContext.h"
#include "AssetToolsModule.h"
#include "AssetRegistryModule.h"
#include "CanvasTypes.h"
#include "CanvasItem.h"
#include "PhysicsEngine/BodySetup2D.h"
#include "SEditorViewport.h"
#include "SNotificationList.h"
#include "NotificationManager.h"
#include "SkillTreeFactory.h"
#include "SkillTreeObject.h"
#include "SkillObject.h"
#define LOCTEXT_NAMESPACE "SkillTreeEditor"
FSkillTreeEditorViewportClient::FSkillTreeEditorViewportClient( TWeakPtr<FSkillTreeEditorViewport> a_skillTreeEditor, TWeakPtr<class SEditorViewport> a_skillTreeEditorViewportPtr )
: FEditorViewportClient( new FAssetEditorModeManager(), nullptr, a_skillTreeEditorViewportPtr )
, m_skillTreeEditorPtr( a_skillTreeEditor )
, m_skillTreeEditorViewportPtr( a_skillTreeEditorViewportPtr )
{
check( m_skillTreeEditorPtr.IsValid() && m_skillTreeEditorViewportPtr.IsValid() );
// The tile map editor fully supports mode tools and isn't doing any incompatible stuff with the Widget
Widget->SetUsesEditorModeTools( ModeTools );
PreviewScene = &m_ownedPreviewScene;
((FAssetEditorModeManager*)ModeTools)->SetPreviewScene( PreviewScene );
SetRealtime( true );
DrawHelper.bDrawGrid = false;
EngineShowFlags.DisableAdvancedFeatures();
EngineShowFlags.CompositeEditorPrimitives = false; //REMINDER: Turned off.
}
void FSkillTreeEditorViewportClient::Draw( const FSceneView* a_view, FPrimitiveDrawInterface* a_drawInterface )
{
FEditorViewportClient::Draw( a_view, a_drawInterface );
}
void FSkillTreeEditorViewportClient::DrawCanvas( FViewport& a_viewport, FSceneView& a_view, FCanvas& a_canvas )
{
const bool isHitTesting = a_canvas.IsHitTesting();
if ( !isHitTesting )
{
a_canvas.SetHitProxy( nullptr );
}
if ( !m_skillTreeEditorPtr.IsValid() )
{
return;
}
m_screenSize = a_viewport.GetSizeXY();
USkillTreeObject* skillTree = m_skillTreeEditorPtr.Pin()->GetSkillTreeBeingEdited();
USkillObject* skill = m_skillTreeEditorPtr.Pin()->GetSkillBeingEdited();
int offsetY = -m_hexSize;
int height;
int maxY;
int width;
if ( m_state )
{
height = skill->hexMap.height;
if ( height % 2 != 0 ) offsetY = m_hexSize;
width = skill->hexMap.width;
maxY = height - 1;
}
else
{
height = 16;
width = 13;
maxY = 15;
}
FLinearColor enabledColor = FLinearColor( 0.43f, 0.43f, 0.43f );
FLinearColor disabledColor = FLinearColor( 0.10f, 0.10f, 0.10f );
for ( float x = 0; x < width; x++ )
{
maxY = (maxY == (height - 1) ? height : (height - 1));
offsetY = (offsetY == -m_hexSize ? 0 : -m_hexSize);
for ( int y = 0; y < maxY; y++ )
{
bool test;
if ( m_state )
{
test = skill->hexMap.Get( x, y );
}
else
{
test = skillTree->hexMap.Get( x, y );
}
FLinearColor hexColor = enabledColor;
if ( !test )
{
hexColor = disabledColor;
}
float X = (x - (((float)width) / 2.0f)) * m_hexSize * 2;
float Y = ((y - (maxY / 2)) * m_hexSize * 2) + offsetY;
FCanvasNGonItem hexagonBorder( FVector2D( ( m_screenSize.X / 2 ) + X, ( m_screenSize.Y / 2 ) + Y ), FVector2D( m_hexSize, m_hexSize ), 6, hexColor );
hexagonBorder.Draw( &a_canvas );
if ( m_state )
{
FCanvasTextItem TextItem( FVector2D( ( m_screenSize.X / 2 ) + X, ( m_screenSize.Y / 2 ) + Y ), FText::Format( LOCTEXT( "PositionStr", "{0},{1}" ), FText::AsNumber( x ), FText::AsNumber( y ) ), GEngine->GetSmallFont(), FLinearColor::White );
TextItem.EnableShadow( FLinearColor::Black );
TextItem.bCentreX = true;
TextItem.Draw( &a_canvas );
}
}
}
float hexmapWidth = ( m_screenSize.X / 2 ) + ( ( ( width - 1 ) - ( ( (float)width ) / 2.0f ) ) * m_hexSize * 2 );
hexmapWidth += m_hexSize;
int boxWidth = ( ( m_screenSize.X - hexmapWidth ) );
boxWidth = FMath::Clamp( boxWidth, 0, 150 );
if ( !m_state )
{
for ( int i = 0, y = 50; i < skillTree->skills.Num(); i++, y += 20 )
{
if ( !skillTree->skills[i] ) continue;
if ( m_hoverY == i || m_skillTreeEditorPtr.Pin()->selectedY == i )
{
int minboxX = m_screenSize.X - boxWidth;
int minboxY = y;
FCanvasBoxItem boxItem( FVector2D( minboxX, minboxY ), FVector2D( boxWidth, 20) );
if ( m_hoverY == i ) boxItem.SetColor( FLinearColor::Black );
if ( m_skillTreeEditorPtr.Pin()->selectedY == i ) boxItem.SetColor( FLinearColor::White );
boxItem.Draw( &a_canvas );
}
FFormatNamedArguments args;
args.Add( TEXT( "DirtyState" ), skillTree->skills[i]->GetOutermost()->IsDirty() ? FText::FromString( TEXT( "*" ) ) : FText::GetEmpty() );
args.Add( TEXT( "SkillName" ), FText::AsCultureInvariant( skillTree->skills[i]->GetName() ) );
const FText assetName = FText::Format( LOCTEXT( "SkillName", "{SkillName}{DirtyState}" ), args );
FCanvasTextItem TextItem( FVector2D( m_screenSize.X - ( ( m_screenSize.X - hexmapWidth ) / 2 ), y ), assetName, GEngine->GetSmallFont(), FLinearColor::White );
TextItem.EnableShadow( FLinearColor::Black );
TextItem.bCentreX = true;
TextItem.Draw( &a_canvas );
}
}
int minboxX = 0;
int minboxY = 50;
FCanvasTileItem enabledColorSquare( FVector2D( 0, 50 ), FVector2D( boxWidth, 20 ), enabledColor );
FCanvasTileItem disabledColorSquare( FVector2D( 0, 70 ), FVector2D( boxWidth, 20 ), disabledColor );
enabledColorSquare.Draw( &a_canvas );
disabledColorSquare.Draw( &a_canvas );
FCanvasTextItem enabledTextItem( FVector2D( boxWidth / 2, 50 ), FText::FromString( TEXT( "Solid" ) ), GEngine->GetSmallFont(), FLinearColor::White );
enabledTextItem.EnableShadow( FLinearColor::Black );
enabledTextItem.bCentreX = true;
enabledTextItem.Draw( &a_canvas );
FCanvasTextItem disabledTextItem( FVector2D( boxWidth / 2, 70 ), FText::FromString( TEXT( "Empty" ) ), GEngine->GetSmallFont(), FLinearColor::White );
disabledTextItem.EnableShadow( FLinearColor::Black );
disabledTextItem.bCentreX = true;
disabledTextItem.Draw( &a_canvas );
FEditorViewportClient::DrawCanvas( a_viewport, a_view, a_canvas );
}
void FSkillTreeEditorViewportClient::MouseMove( FViewport* a_viewport, int32 a_mouseX, int32 a_mouseY )
{
if ( m_state ) return;
USkillTreeObject* skillTree = m_skillTreeEditorPtr.Pin()->GetSkillTreeBeingEdited();
int width = 13;
float hexmapWidth = ( m_screenSize.X / 2 ) + ( ( ( width - 1 ) - ( ( (float)width ) / 2.0f ) ) * m_hexSize * 2 );
hexmapWidth += m_hexSize;
int minboxX = m_screenSize.X - ( ( m_screenSize.X - hexmapWidth ) );
int maxboxX = m_screenSize.X;
for ( int i = 0, y = 50; i < skillTree->skills.Num(); i++, y += 20 )
{
int minboxY = y;
int maxboxY = y + 20;
if ( !skillTree->skills[i] ) continue;
if ( a_mouseX >= minboxX && a_mouseX <= maxboxX && a_mouseY >= minboxY && a_mouseY <= maxboxY )
{
m_hoverY = i;
FEditorViewportClient::MouseMove( a_viewport, a_mouseX, a_mouseY );
return;
}
}
m_hoverY = -1;
FEditorViewportClient::MouseMove( a_viewport, a_mouseX, a_mouseY );
}
void FSkillTreeEditorViewportClient::InternalActivateNewMode( )
{
//m_currentMode = a_newMode;
Viewport->InvalidateHitProxy();
}
FLinearColor FSkillTreeEditorViewportClient::GetBackgroundColor() const
{
return FLinearColor( 0.20f, 0.22f, 0.22f );
}
void FSkillTreeEditorViewportClient::ActivateEditMode()
{
// Activate the skill tree edit mode
ModeTools->SetToolkitHost( m_skillTreeEditorPtr.Pin()->GetToolkitHost() );
ModeTools->ActivateDefaultMode();
}
void FSkillTreeEditorViewportClient::Tick( float a_deltaSeconds )
{
FEditorViewportClient::Tick( a_deltaSeconds );
m_skillTreeEditorPtr.Pin()->UpdateSkills();
if ( !GIntraFrameDebuggingGameThread )
{
m_ownedPreviewScene.GetWorld()->Tick( LEVELTICK_All, a_deltaSeconds );
}
}
void FSkillTreeEditorViewportClient::ProcessClick( FSceneView& a_view, HHitProxy* a_hitProxy, FKey a_key, EInputEvent a_event, uint32 a_hitX, uint32 a_hitY )
{
bool handled = false;
USkillTreeObject* skillTree = m_skillTreeEditorPtr.Pin()->GetSkillTreeBeingEdited();
USkillObject* skill = m_skillTreeEditorPtr.Pin()->GetSkillBeingEdited();
int offsetY = -m_hexSize;
int height;
int maxY;
int width;
if ( m_state )
{
height = skill->hexMap.height;
width = skill->hexMap.width;
if ( height % 2 != 0 ) offsetY = m_hexSize;
maxY = height-1;
}
else
{
height = 16;
width = 13;
maxY = 15;
}
FVector2D mpos( a_hitX, a_hitY );
for ( float x = 0; x < width; x++ )
{
maxY = (maxY == (height - 1) ? height : (height - 1));
offsetY = ( offsetY == -m_hexSize ? 0 : -m_hexSize );
for ( int y = 0; y < maxY; y++ )
{
float X = ( x - ( ( (float)width ) / 2.0f ) ) * m_hexSize * 2;
float Y = ( ( y - ( maxY / 2 ) ) * m_hexSize * 2 ) + offsetY;
FVector2D pos( ( m_screenSize.X / 2 ) + X, ( m_screenSize.Y / 2 ) + Y );
float dist = FVector2D::Distance( pos, mpos );
if ( dist <= m_hexSize )
{
if ( !m_state )
{
skillTree->hexMap.Invert( x, y );
skillTree->Modify();
skillTree->MarkPackageDirty();
skillTree->PostEditChange();
}
else
{
skill->hexMap.Invert( x, y );
skill->Modify();
skill->MarkPackageDirty();
skill->PostEditChange();
}
handled = true;
Invalidate();
break;
}
}
if ( handled )
{
break;
}
}
if ( !handled && !m_state )
{
float hexmapWidth = ( m_screenSize.X / 2 ) + ( ( ( width - 1 ) - ( ( (float)width ) / 2.0f ) ) * m_hexSize * 2 );
hexmapWidth += m_hexSize;
uint32 minboxX = m_screenSize.X - ( ( m_screenSize.X - hexmapWidth ) );
uint32 maxboxX = m_screenSize.X;
for ( int i = 0, y = 50; i < skillTree->skills.Num(); i++, y += 20 )
{
uint32 minboxY = y;
uint32 maxboxY = y + 20;
if ( !skillTree->skills[i] ) continue;
if ( a_hitX >= minboxX && a_hitX <= maxboxX && a_hitY >= minboxY && a_hitY <= maxboxY )
{
m_skillTreeEditorPtr.Pin()->selectedY = i;
handled = true;
USkillObject* tmpCast = skillTree->skills[i]->GetDefaultObject<USkillObject>();
if ( tmpCast != NULL ) m_skillTreeEditorPtr.Pin()->SetSkillBeingEdited( tmpCast );
}
}
}
if ( !handled )
{
FEditorViewportClient::ProcessClick( a_view, a_hitProxy, a_key, a_event, a_hitX, a_hitY );
}
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,78 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor main viewport.
// Can be used for editing a Skill Tree
// and a Skill.
//////////////////////////////////////////
#pragma once
#include "SkillTreeEditorViewport.h"
#include "SceneViewport.h"
#include "AssetEditorModeManager.h"
#include "PreviewScene.h"
#include "ScopedTransaction.h"
#include "AssetData.h"
#include "SkillTreeObject.h"
class FSkillTreeEditorViewportClient : public FEditorViewportClient
{
public:
FSkillTreeEditorViewportClient( TWeakPtr<FSkillTreeEditorViewport> a_skillTreeEditor, TWeakPtr<class SEditorViewport> a_skillTreeEditorViewportPtr );
// FViewportClient interface
virtual void Draw( const FSceneView* a_view, FPrimitiveDrawInterface* a_drawInterface ) override;
virtual void DrawCanvas( FViewport& a_viewport, FSceneView& a_view, FCanvas& a_canvas ) override;
virtual void Tick( float a_deltaSeconds ) override;
// End of FViewportClient interface
// FEditorViewportClient interface
virtual void ProcessClick( FSceneView& a_view, HHitProxy* a_hitProxy, FKey a_key, EInputEvent a_event, uint32 a_hitX, uint32 a_hitY ) override;
virtual void MouseMove( FViewport* a_viewport, int32 a_mouseX, int32 a_mouseY ) override;
virtual FLinearColor GetBackgroundColor() const override;
// End of FEditorViewportClient interface
//virtual void RequestFocusOnSelection( bool a_instant );
void EnterViewMode() { InternalActivateNewMode( ); }
bool IsInViewMode() const { return true; }
void UpdateRelatedSpritesList();
void ActivateEditMode();
// Set the current state of the Viewport.
void IsSkill( bool a_state )
{
m_state = a_state;
}
private:
// The ID of the current hovered Skill.
int32 m_hoverY = -1;
// The current state of the Viewport.
// True = Skill
// False = Skill Tree
bool m_state = false;
// The Viewport screen size.
FIntPoint m_screenSize;
// The preview scene.
FPreviewScene m_ownedPreviewScene;
// Skill Tree Editor that owns this viewport.
TWeakPtr<FSkillTreeEditorViewport> m_skillTreeEditorPtr;
// Pointer back to the Skill Tree viewport control that owns this.
TWeakPtr<class SEditorViewport> m_skillTreeEditorViewportPtr;
// The radius of the Hexagons.
float m_hexSize = 20;
void InternalActivateNewMode();
};

View File

@@ -0,0 +1,29 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
#include "SkillTreeEditorPrivatePCH.h"
#include "SkillTreeFactory.h"
#include "SkillTreeObject.h"
#include "AssetRegistryModule.h"
#include "PackageTools.h"
#define LOCTEXT_NAMESPACE "SkillTree"
USkillTreeFactory::USkillTreeFactory( const FObjectInitializer& ObjectInitializer )
: Super( ObjectInitializer )
{
bCreateNew = true;
bEditAfterNew = true;
SupportedClass = USkillTreeObject::StaticClass();
}
UObject* USkillTreeFactory::FactoryCreateNew( UClass* a_class, UObject* a_parent, FName a_name, EObjectFlags a_flags, UObject* a_context, FFeedbackContext* a_warn )
{
USkillTreeObject* newSkillTree = NewObject<USkillTreeObject>( a_parent, a_class, a_name, a_flags | RF_Transactional );
return newSkillTree;
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,27 @@
// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor Module Interface.
//////////////////////////////////////////
#pragma once
#include "ModuleManager.h"
class ISkillTreeEditor : public IModuleInterface
{
public:
//Function to Get the Singleton of this Module if it's loaded.
static inline ISkillTreeEditor& Get()
{
return FModuleManager::LoadModuleChecked< ISkillTreeEditor >( "SkillTreeEditor" );
}
//Function to check if the Module is loaded.
static inline bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded( "SkillTreeEditor" );
}
};

View File

@@ -0,0 +1,23 @@
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor Module Settings.
//////////////////////////////////////////
namespace UnrealBuildTool.Rules
{
public class SkillTreeEditor : ModuleRules
{
public SkillTreeEditor(TargetInfo Target)
{
PrivateIncludePaths.Add("SkillTreeEditor/Private");
PrivateIncludePathModuleNames.AddRange(new string[] { "AssetTools" });
PrivateDependencyModuleNames.AddRange(new string[] { "SkillTree", "Core", "CoreUObject", "Engine", "InputCore", "Slate", "UnrealEd", "SlateCore", "EditorStyle", "Kismet", "PropertyEditor", "KismetWidgets", "ContentBrowser", "WorkspaceMenuStructure", "EditorWidgets" });
DynamicallyLoadedModuleNames.AddRange(new string[] { "AssetTools" });
}
}
}