This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,163 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Source/VaTexAtlasEditorPlugin/Classes/VtaTextureAtlasAsset.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2016 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "VtaTextureAtlasDataModel.h" | ||
#include "VtaAsset.h" | ||
#include "VtaTextureAtlasAsset.generated.h" | ||
|
||
UCLASS(meta = (DisplayThumbnail = "true")) | ||
class VATEXATLASEDITORPLUGIN_API UVtaTextureAtlasAsset: public UObject | ||
{ | ||
GENERATED_BODY() | ||
public: | ||
UVtaTextureAtlasAsset(); | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
FString AtlasName; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
FString ImportPath; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
uint32 bIsMultipack : 1; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
TEnumAsByte<TextureCompressionSettings> TextureCompressionSetting; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
TMap<FString, FVtaDataFile> ImportedData; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
TMap< FString, class UTexture2D* > Textures; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
TMap< FString, FVtaAsset > Frames; | ||
|
||
UPROPERTY(VisibleAnywhere, Category = "Texture Atlas Asset") | ||
class UDataTable* DataTable; | ||
|
||
class UTexture2D* GetTexture(const FString& Name); | ||
FVtaAsset* GetFrame(const FString& Name); | ||
|
||
#if WITH_EDITORONLY_DATA | ||
// Import data for this | ||
UPROPERTY(VisibleAnywhere, Instanced, Category = ImportSettings) | ||
class UAssetImportData* AssetImportData; | ||
|
||
// UObject interface | ||
virtual void PostInitProperties() override; | ||
virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override; | ||
virtual void Serialize(FArchive& Ar) override; | ||
// End of UObject interface | ||
#endif | ||
}; |
24 changes: 24 additions & 0 deletions
24
Source/VaTexAtlasEditorPlugin/Classes/VtaTextureAtlasAssetActions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2016 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "AssetTypeActions_Base.h" | ||
|
||
/** | ||
* VtaTextureAtlasAsset actions | ||
*/ | ||
class VATEXATLASEDITORPLUGIN_API FVtaTextureAtlasAssetActions : public FAssetTypeActions_Base | ||
{ | ||
|
||
public: | ||
// IAssetTypeActions interface | ||
virtual FText GetName() const override; | ||
virtual FColor GetTypeColor() const override; | ||
virtual UClass* GetSupportedClass() const override; | ||
virtual bool HasActions(const TArray<UObject*>& InObjects) const override { return true; } | ||
virtual void GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder) override; | ||
virtual uint32 GetCategories() override; | ||
virtual bool IsImportedAsset() const override; | ||
virtual void GetResolvedSourceFilePaths(const TArray<UObject*>& TypeAssets, TArray<FString>& OutSourceFilePaths) const override; | ||
// End of IAssetTypeActions interface | ||
|
||
}; |
48 changes: 48 additions & 0 deletions
48
Source/VaTexAtlasEditorPlugin/Classes/VtaTextureAtlasAssetImportFactory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2016 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#pragma once | ||
#include "Factories/Factory.h" | ||
#include "EditorReimportHandler.h" | ||
#include "VtaAsset.h" | ||
#include "VtaTextureAtlasAssetImportFactory.generated.h" | ||
|
||
UCLASS() | ||
class VATEXATLASEDITORPLUGIN_API UVtaTextureAtlasAssetImportFactory final: public UFactory, public FReimportHandler | ||
{ | ||
GENERATED_BODY() | ||
|
||
public: | ||
UVtaTextureAtlasAssetImportFactory(); | ||
|
||
// Begin UFactory interface | ||
virtual bool FactoryCanImport(const FString& Filename) override; | ||
virtual FText GetToolTip() const override; | ||
virtual UObject* FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled) override; | ||
virtual void Cleanup() { CurrentAtlas = nullptr; } | ||
// End UFactory interface | ||
|
||
// Begin ReimportHandler interface | ||
virtual bool CanReimport(UObject* Obj, TArray<FString>& OutFilenames) override; | ||
virtual void SetReimportPaths(UObject* Obj, const TArray<FString>& NewReimportPaths) override; | ||
virtual EReimportResult::Type Reimport(UObject* Obj) override; | ||
virtual const UObject* GetFactoryObject() const override { return this; } | ||
// End ReimportHandler interface | ||
|
||
private: | ||
UPROPERTY(Transient) | ||
class UVtaTextureAtlasAsset* CurrentAtlas; | ||
|
||
static bool SplitMultipackAtlasName(const FString& Filename, FString& OutAtlasName, int32& OutIndex); | ||
|
||
static TSharedPtr<class FJsonObject> ParseJSON(const FString& FileName); | ||
static bool ImportAtlas(class UVtaTextureAtlasAsset* Atlas, FFeedbackContext* Warn); | ||
|
||
static UObject* CreateAsset(UClass* Class, const FString& TargetPath, const FString& Name, EObjectFlags Flags); | ||
static UObject* ImportAsset(const FString& SourceFilename, const FString& TargetPath); | ||
static UObject* FindAsset(UClass* AssetClass, const FString& Path, const FString& Name); | ||
|
||
static class UTexture2D* ProcessTexture(class UVtaTextureAtlasAsset* Atlas, const FString& TextureName); | ||
static FVtaAsset ProcessFrame(class UVtaTextureAtlasAsset* Atlas, class UTexture2D* AtlasTexture, const struct FVtaMeta& Meta, const struct FVtaFrame& Frame); | ||
|
||
static FString GetNormalizedFrameName(const FString& Name); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Source/VaTexAtlasEditorPlugin/Private/VtaTextureAtlasAssetActions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2016 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#include "VtaTextureAtlasAssetActions.h" | ||
#include "VtaTextureAtlasAsset.h" | ||
|
||
#include "EditorFramework/AssetImportData.h" | ||
|
||
#define LOCTEXT_NAMESPACE "VtaEditorPlugin" | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// FVtaTextureAtlasAssetActions | ||
|
||
FText FVtaTextureAtlasAssetActions::GetName() const | ||
{ | ||
return LOCTEXT("FVtaTextureAtlasAssetActions", "Texture Atlas Asset"); | ||
} | ||
|
||
FColor FVtaTextureAtlasAssetActions::GetTypeColor() const | ||
{ | ||
return FColor::Red; | ||
} | ||
|
||
UClass* FVtaTextureAtlasAssetActions::GetSupportedClass() const | ||
{ | ||
return UVtaTextureAtlasAsset::StaticClass(); | ||
} | ||
|
||
uint32 FVtaTextureAtlasAssetActions::GetCategories() | ||
{ | ||
return EAssetTypeCategories::Misc; | ||
} | ||
|
||
bool FVtaTextureAtlasAssetActions::IsImportedAsset() const | ||
{ | ||
return true; | ||
} | ||
|
||
void FVtaTextureAtlasAssetActions::GetResolvedSourceFilePaths(const TArray<UObject*>& TypeAssets, TArray<FString>& OutSourceFilePaths) const | ||
{ | ||
FAssetTypeActions_Base::GetResolvedSourceFilePaths(TypeAssets, OutSourceFilePaths); | ||
|
||
for (auto& Asset : TypeAssets) | ||
{ | ||
const auto TexttureAtlas = CastChecked<UVtaTextureAtlasAsset>(Asset); | ||
if (TexttureAtlas->AssetImportData) | ||
{ | ||
TexttureAtlas->AssetImportData->ExtractFilenames(OutSourceFilePaths); | ||
} | ||
} | ||
} | ||
|
||
void FVtaTextureAtlasAssetActions::GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder) | ||
{ | ||
|
||
} | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
|
||
#undef LOCTEXT_NAMESPACE |
Oops, something went wrong.