第一次提交
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class GenericInventoryEditor : ModuleRules
|
||||
{
|
||||
public GenericInventoryEditor(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"GenericInventorySystem",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"UnrealEd",
|
||||
"AssetTools",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
|
||||
#include "Factories/GIS_AssetTypeActions.h"
|
||||
#include "GenericInventoryEditor.h"
|
||||
#include "GIS_CurrencyDefinition.h"
|
||||
#include "GIS_ItemCollection.h"
|
||||
#include "GIS_ItemDefinition.h"
|
||||
#include "GIS_ItemDefinitionSchema.h"
|
||||
#include "GIS_ItemMultiStackCollection.h"
|
||||
#include "GIS_ItemSlotCollection.h"
|
||||
|
||||
|
||||
uint32 FGIS_AssetTypeAction::GetCategories()
|
||||
{
|
||||
return FGenericInventoryEditorModule::GetAssetsCategory();
|
||||
}
|
||||
|
||||
FColor FGIS_AssetTypeAction::GetTypeColor() const
|
||||
{
|
||||
return FColor(114, 40, 199);
|
||||
}
|
||||
|
||||
#define IMPLEMENT_GIS_ASSET_ACTION(ActionName, NameText, DescText) \
|
||||
FText FGIS_AssetTypeAction_##ActionName::GetName() const \
|
||||
{ \
|
||||
return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_" #ActionName "_Name", NameText); \
|
||||
} \
|
||||
FText FGIS_AssetTypeAction_##ActionName::GetAssetDescription(const FAssetData& AssetData) const \
|
||||
{ \
|
||||
return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_" #ActionName "_Description", DescText); \
|
||||
} \
|
||||
UClass* FGIS_AssetTypeAction_##ActionName::GetSupportedClass() const \
|
||||
{ \
|
||||
return UGIS_##ActionName::StaticClass(); \
|
||||
}
|
||||
|
||||
IMPLEMENT_GIS_ASSET_ACTION(ItemDefinition, "Item Definition",
|
||||
"Data Asset that defines your item design.")
|
||||
IMPLEMENT_GIS_ASSET_ACTION(ItemDefinitionSchema, "Item Definition Schema",
|
||||
"Data Asset that defines the validation rules for item definition.")
|
||||
IMPLEMENT_GIS_ASSET_ACTION(ItemCollectionDefinition, "Item Collection Definition(Normal)",
|
||||
"Data Asset that defines the design for normal item collection.")
|
||||
IMPLEMENT_GIS_ASSET_ACTION(ItemSlotCollectionDefinition, "Item Collection Definition(Slot)",
|
||||
"Data Asset that defines the design for slot based item collection.")
|
||||
IMPLEMENT_GIS_ASSET_ACTION(ItemMultiStackCollectionDefinition, "Item Collection Definition(MultiStack)",
|
||||
"Data Asset that defines the design for multi stack based item collection.")
|
||||
IMPLEMENT_GIS_ASSET_ACTION(CurrencyDefinition, "CurrencyDefinition",
|
||||
"Data Asset that defines the in game currency.")
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
|
||||
#include "Factories/GIS_DataAssetsFactories.h"
|
||||
|
||||
#include "GIS_ItemCollection.h"
|
||||
#include "GIS_ItemDefinition.h"
|
||||
#include "GIS_ItemDefinitionSchema.h"
|
||||
#include "GIS_ItemMultiStackCollection.h"
|
||||
#include "GIS_ItemSlotCollection.h"
|
||||
|
||||
|
||||
#include UE_INLINE_GENERATED_CPP_BY_NAME(GIS_DataAssetsFactories)
|
||||
|
||||
UGIS_Factory::UGIS_Factory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
|
||||
{
|
||||
bEditAfterNew = true;
|
||||
bCreateNew = true;
|
||||
}
|
||||
|
||||
uint32 UGIS_Factory::GetMenuCategories() const
|
||||
{
|
||||
return Super::GetMenuCategories();
|
||||
}
|
||||
|
||||
const TArray<FText>& UGIS_Factory::GetMenuCategorySubMenus() const
|
||||
{
|
||||
return Super::GetMenuCategorySubMenus();
|
||||
}
|
||||
|
||||
#define IMPLEMENT_GIS_FACTORY(FactoryName) \
|
||||
UGIS_Factory_##FactoryName::UGIS_Factory_##FactoryName(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) \
|
||||
{ \
|
||||
SupportedClass = UGIS_##FactoryName::StaticClass(); \
|
||||
} \
|
||||
UObject* UGIS_Factory_##FactoryName::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) \
|
||||
{ \
|
||||
check(Class->IsChildOf(UGIS_##FactoryName::StaticClass())); \
|
||||
return NewObject<UGIS_##FactoryName>(InParent, Class, Name, Flags | RF_Transactional, Context); \
|
||||
}
|
||||
|
||||
IMPLEMENT_GIS_FACTORY(ItemDefinition)
|
||||
|
||||
IMPLEMENT_GIS_FACTORY(ItemDefinitionSchema)
|
||||
|
||||
IMPLEMENT_GIS_FACTORY(ItemCollectionDefinition)
|
||||
|
||||
IMPLEMENT_GIS_FACTORY(ItemSlotCollectionDefinition)
|
||||
|
||||
IMPLEMENT_GIS_FACTORY(ItemMultiStackCollectionDefinition)
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "GenericInventoryEditor.h"
|
||||
|
||||
#include "Factories/GIS_AssetTypeActions.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FGenericInventoryEditorModule"
|
||||
|
||||
TArray<TSharedPtr<IAssetTypeActions>> FGenericInventoryEditorModule::AssetTypeActions = {
|
||||
MakeShared<FGIS_AssetTypeAction_ItemDefinition>(),
|
||||
MakeShared<FGIS_AssetTypeAction_ItemDefinitionSchema>(),
|
||||
MakeShared<FGIS_AssetTypeAction_ItemCollectionDefinition>(),
|
||||
MakeShared<FGIS_AssetTypeAction_ItemSlotCollectionDefinition>(),
|
||||
MakeShared<FGIS_AssetTypeAction_ItemMultiStackCollectionDefinition>()
|
||||
|
||||
};
|
||||
|
||||
EAssetTypeCategories::Type FGenericInventoryEditorModule::AssetsCategory;
|
||||
|
||||
|
||||
void FGenericInventoryEditorModule::StartupModule()
|
||||
{
|
||||
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
|
||||
AssetsCategory = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("GenericInventorySystem")), LOCTEXT("GIS_AssetsCategory", "Generic Inventory System"));
|
||||
for (TSharedPtr<IAssetTypeActions>& Action : AssetTypeActions)
|
||||
{
|
||||
AssetTools.RegisterAssetTypeActions(Action.ToSharedRef());
|
||||
}
|
||||
}
|
||||
|
||||
void FGenericInventoryEditorModule::ShutdownModule()
|
||||
{
|
||||
if (const FAssetToolsModule* AssetTools = FModuleManager::GetModulePtr<FAssetToolsModule>("AssetTools"))
|
||||
{
|
||||
for (TSharedPtr<IAssetTypeActions>& Action : AssetTypeActions)
|
||||
{
|
||||
AssetTools->Get().UnregisterAssetTypeActions(Action.ToSharedRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FGenericInventoryEditorModule, GenericInventoryEditor)
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AssetTypeActions/AssetTypeActions_DataAsset.h"
|
||||
|
||||
class FGIS_AssetTypeAction : public FAssetTypeActions_DataAsset
|
||||
{
|
||||
public:
|
||||
virtual uint32 GetCategories() override;
|
||||
virtual FColor GetTypeColor() const override;
|
||||
};
|
||||
|
||||
#define DEFINE_GIS_ASSET_ACTION(ActionName) \
|
||||
class FGIS_AssetTypeAction_##ActionName final : public FGIS_AssetTypeAction \
|
||||
{ \
|
||||
public: \
|
||||
virtual FText GetName() const override; \
|
||||
virtual FText GetAssetDescription(const FAssetData& AssetData) const override; \
|
||||
virtual UClass* GetSupportedClass() const override; \
|
||||
};
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(ItemDefinition)
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(ItemDefinitionSchema)
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(ItemCollectionDefinition)
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(ItemSlotCollectionDefinition)
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(ItemMultiStackCollectionDefinition)
|
||||
|
||||
DEFINE_GIS_ASSET_ACTION(CurrencyDefinition)
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "Templates/SubclassOf.h"
|
||||
#include "Factories/Factory.h"
|
||||
#include "GIS_DataAssetsFactories.generated.h"
|
||||
|
||||
UCLASS(Abstract)
|
||||
class UGIS_Factory : public UFactory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory(const FObjectInitializer& ObjectInitializer);
|
||||
virtual uint32 GetMenuCategories() const override;
|
||||
virtual const TArray<FText>& GetMenuCategorySubMenus() const override;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UGIS_Factory_ItemDefinition : public UGIS_Factory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory_ItemDefinition(const FObjectInitializer& ObjectInitializer);
|
||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UGIS_Factory_ItemDefinitionSchema : public UGIS_Factory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory_ItemDefinitionSchema(const FObjectInitializer& ObjectInitializer);
|
||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UGIS_Factory_ItemCollectionDefinition : public UGIS_Factory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory_ItemCollectionDefinition(const FObjectInitializer& ObjectInitializer);
|
||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UGIS_Factory_ItemSlotCollectionDefinition : public UGIS_Factory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory_ItemSlotCollectionDefinition(const FObjectInitializer& ObjectInitializer);
|
||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class UGIS_Factory_ItemMultiStackCollectionDefinition : public UGIS_Factory
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGIS_Factory_ItemMultiStackCollectionDefinition(const FObjectInitializer& ObjectInitializer);
|
||||
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AssetTypeCategories.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class IAssetTypeActions;
|
||||
|
||||
class FGenericInventoryEditorModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
static EAssetTypeCategories::Type GetAssetsCategory()
|
||||
{
|
||||
return AssetsCategory;
|
||||
}
|
||||
|
||||
private:
|
||||
static TArray<TSharedPtr<IAssetTypeActions>> AssetTypeActions;
|
||||
static EAssetTypeCategories::Type AssetsCategory;
|
||||
};
|
||||
Reference in New Issue
Block a user