- Started work on giving UComboActions their own automatically-recognised events in Blueprints, just like UInputAssets have in the EnhancedInput plugin.

- Also gave the data assets a factory class and organised them into the Input category to make them look like a proper Unreal asset.
This commit is contained in:
Jamie Greunbaum
2023-09-12 01:39:23 -04:00
parent 3e71bb31ae
commit 445895b77b
10 changed files with 789 additions and 88 deletions
@@ -15,11 +15,7 @@ public class ComboInputEditor : ModuleRules
PublicDependencyModuleNames.AddRange
(new string[]
{
"Core",
"CoreUObject",
"Engine",
"UnrealEd",
"AssetTools"
"ComboInput",
}
);
@@ -27,27 +23,15 @@ public class ComboInputEditor : ModuleRules
(
new string[]
{
"ComboInput",
"Core",
"CoreUObject",
"AssetTools",
"Slate",
"SlateCore",
"GraphEditor",
"PropertyEditor",
"EditorStyle",
"Kismet",
"KismetWidgets",
"ApplicationCore",
"ToolMenus",
"DeveloperSettings",
"Projects",
"BlueprintGraph",
"InputCore",
"MainFrame"
// ... add private dependencies that you statically link with here ...
}
);
if (Target.bBuildEditor)
{
PrivateDependencyModuleNames.Add("UnrealEd");
}
}
}
@@ -2,20 +2,130 @@
#include "ComboInputEditor.h"
#include "ComboInputAssets.h"
#include "ToolMenuSection.h"
#include "AssetTypeActions/AssetTypeActions_DataAsset.h"
#include "Interfaces/IPluginManager.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(ComboInputEditor)
#define LOCTEXT_NAMESPACE "FComboInputEditorModule"
EAssetTypeCategories::Type FComboInputEditorModule::ComboAssetsCategory;
class FAssetTypeActions_ComboAction : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboAction", "Combo Action"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboActionDesc", "An action that can be executed as part of a combo sequence. This is essentially a representation of an attack, and can be sent to the Animation Graph to play an attack animation and the like."); }
virtual UClass *GetSupportedClass() const override { return UComboAction::StaticClass(); }
};
class FAssetTypeActions_ComboSequenceNode : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboSequenceNode", "Combo Sequence Node"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboSequenceNodeDesc", "This represents a node in the combo graph, with each key in the ComboBranch being an input this node can react to, and each value containing the action to be executed next, and the node to activate after the action is complete."); }
virtual UClass *GetSupportedClass() const override { return UComboSequenceNode::StaticClass(); }
};
class FAssetTypeActions_ComboInputAsset : public FAssetTypeActions_DataAsset
{
public:
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboInputAsset", "Combo Input Asset"); }
virtual uint32 GetCategories() override { return FComboInputEditorModule::GetInputAssetsCategory(); }
virtual FColor GetTypeColor() const override { return FColor(255, 127, 255); }
virtual FText GetAssetDescription(const FAssetData &AssetData) const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_ComboInputAssetDesc", "This maps a sequence of button inputs from EnhancedInput to a combo action that can be used to execute a sequence of moves.This gets sent from the input buffer subsystem to the player controller's ComboManagerComponent, which executes the associated action in the current ComboSequenceNode."); }
virtual UClass *GetSupportedClass() const override { return UComboInputAsset::StaticClass(); }
};
UComboAction_Factory::UComboAction_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboAction::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboAction_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboActionClass != nullptr)
{
return NewObject<UComboAction>(InParent, this->ComboActionClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboAction::StaticClass()));
return NewObject<UComboAction>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
UComboSequenceNode_Factory::UComboSequenceNode_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboSequenceNode::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboSequenceNode_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboSequenceNodeClass != nullptr)
{
return NewObject<UComboSequenceNode>(InParent, this->ComboSequenceNodeClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboSequenceNode::StaticClass()));
return NewObject<UComboSequenceNode>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
UComboInputAsset_Factory::UComboInputAsset_Factory(const FObjectInitializer &ObjectInitializer)
: Super(ObjectInitializer)
{
SupportedClass = UComboInputAsset::StaticClass();
bEditAfterNew = true;
bCreateNew = true;
}
UObject *UComboInputAsset_Factory::FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn)
{
if (this->ComboInputAssetClass != nullptr)
{
return NewObject<UComboInputAsset>(InParent, this->ComboInputAssetClass, Name, Flags | RF_Transactional, Context);
}
else
{
check(Class->IsChildOf(UComboInputAsset::StaticClass()));
return NewObject<UComboInputAsset>(InParent, Class, Name, Flags | RF_Transactional, Context);
}
}
void FComboInputEditorModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
// Register combo action asset
IAssetTools &AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
FComboInputEditorModule::ComboAssetsCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("Input")), LOCTEXT("InputAssetsCategory", "Input"));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboAction));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboSequenceNode));
this->RegisterAssetTypeActions(AssetTools, MakeShareable(new FAssetTypeActions_ComboInputAsset));
}
void FComboInputEditorModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}
#undef LOCTEXT_NAMESPACE
@@ -3,68 +3,78 @@
#pragma once
#include "Modules/ModuleManager.h"
#include "EdGraphUtilities.h"
#include "IAssetTools.h"
// #include "Interfaces/IHttpRequest.h"
#include "IAssetTypeActions.h"
#include "Factories/Factory.h"
#include "ComboInputEditor.generated.h"
UCLASS()
class COMBOINPUTEDITOR_API UComboAction_Factory : public UFactory
{
GENERATED_BODY()
public:
UComboAction_Factory(const class FObjectInitializer &ObjectInitializer);
UPROPERTY(EditAnywhere, Category="Combo Input")
TSubclassOf<class UComboAction> ComboActionClass;
virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};
UCLASS()
class COMBOINPUTEDITOR_API UComboSequenceNode_Factory : public UFactory
{
GENERATED_BODY()
public:
UComboSequenceNode_Factory(const class FObjectInitializer &ObjectInitializer);
UPROPERTY(EditAnywhere, Category="Combo Input")
TSubclassOf<class UComboSequenceNode> ComboSequenceNodeClass;
virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};
UCLASS()
class COMBOINPUTEDITOR_API UComboInputAsset_Factory : public UFactory
{
GENERATED_BODY()
public:
UComboInputAsset_Factory(const class FObjectInitializer &ObjectInitializer);
UPROPERTY(EditAnywhere, Category="Combo Input")
TSubclassOf<class UComboInputAsset> ComboInputAssetClass;
virtual UObject *FactoryCreateNew(UClass *Class, UObject *InParent, FName Name, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override;
};
// class FHttpModule;
// class FSlateStyleSet;
class FComboInputEditorModule : public IModuleInterface
{
public:
public:
static FComboInputEditorModule &Get() { return FModuleManager::LoadModuleChecked<FComboInputEditorModule>("ComboInputEditor"); }
static bool IsAvailable() { return FModuleManager::Get().IsModuleLoaded("ComboInputEditor"); }
/**
* Singleton-like access to this module's interface. This is just for convenience!
* Beware of calling this during the shutdown phase, though. Your module might have been unloaded already.
*
* @return Returns singleton instance, loading the module on demand if needed
*/
static FComboInputEditorModule &Get()
{
return FModuleManager::LoadModuleChecked<FComboInputEditorModule>( "ComboInputEditor" );
}
/**
* Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true.
*
* @return True if the module is loaded and ready to use
*/
static bool IsAvailable()
{
return FModuleManager::Get().IsModuleLoaded("ComboInputEditor");
}
/* Called when the module is loaded */
virtual void StartupModule() override;
/* Called when the module is unloaded */
virtual void ShutdownModule() override;
private:
// void RegisterAssetTypeAction(IAssetTools& AssetTools, TSharedRef<IAssetTypeActions> Action);
// void OnGetResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
// UFUNCTION() void SendHTTPGet();
// void PluginButtonClicked();
// void RegisterMenus();
static EAssetTypeCategories::Type GetInputAssetsCategory() { return FComboInputEditorModule::ComboAssetsCategory; }
private:
// TSharedPtr<class FUICommandList> PluginCommands;
// TSharedPtr<FSlateStyleSet> DialogueTreeSet;
// TSharedPtr<class FMounteaDialogueGraphAssetAction> MounteaDialogueGraphAssetActions;
// TSharedPtr<class FMounteaDialogueAdditionalDataAssetAction> MounteaDialogueAdditionalDataAssetActions;
// TSharedPtr<class FMounteaDialogueDecoratorAssetAction> MounteaDialogueDecoratorAssetAction;
// TSharedPtr<struct FGraphPanelNodeFactory> GraphPanelNodeFactory_MounteaDialogueGraph;
// TArray< TSharedPtr<IAssetTypeActions> > CreatedAssetTypeActions;
void RegisterAssetTypeActions(IAssetTools &AssetTools, TSharedRef<IAssetTypeActions> Action)
{
AssetTools.RegisterAssetTypeActions(Action);
CreatedAssetTypeActions.Add(Action);
}
// EAssetTypeCategories::Type MounteaDialogueGraphAssetCategoryBit;
// FHttpModule* Http;
static EAssetTypeCategories::Type ComboAssetsCategory;
// TArray<FName> RegisteredCustomClassLayouts;
// TArray<FName> RegisteredCustomPropertyTypeLayout;
};
TArray<TSharedPtr<IAssetTypeActions>> CreatedAssetTypeActions;
};