Skip to content

Commit 2854fe2

Browse files
committed
Initial commit
0 parents  commit 2854fe2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3353
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DerivedDataCache
2+
Intermediate
3+
Saved
4+
Binaries
5+
Deploy
6+
Build
7+
.DS_Store
8+
*.sdf
9+
*.opensdf
10+
*.v12.suo

AUTHORS

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
AUTHORS: Tree Architect Plugin for Unreal Engine 4
2+
==================================================
3+
4+
Ali Akbar <[email protected]>
5+

CHANGELOG

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CHANGELOG
2+
=========
3+
4+
Tree Architect
5+
--------------
6+
7+
Version 0.1.0
8+
* Initial Version

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tree Architect

Resources/Icon128.png

12.4 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//$ Copyright 2015-2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
#include "TreeArchitectEditorPrivatePCH.h"
3+
#include "TreeThemeAssetTypeAction.h"
4+
#include "TreeThemeAsset.h"
5+
6+
#include "AssetToolsModule.h"
7+
#include "ContentBrowserModule.h"
8+
#include "ThemeEditor/TreeThemeEditor.h"
9+
10+
#define LOCTEXT_NAMESPACE "AssetTypeActions"
11+
12+
//////////////////////////////////////////////////////////////////////////
13+
// FLAThemeAssetTypeAction
14+
15+
FText FLAThemeAssetTypeAction::GetName() const
16+
{
17+
return LOCTEXT("FLAThemeAssetTypeActionName", "Tree Theme");
18+
}
19+
20+
FColor FLAThemeAssetTypeAction::GetTypeColor() const
21+
{
22+
return FColor::Green;
23+
}
24+
25+
UClass* FLAThemeAssetTypeAction::GetSupportedClass() const
26+
{
27+
return UTreeThemeAsset::StaticClass();
28+
}
29+
30+
void FLAThemeAssetTypeAction::OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor)
31+
{
32+
const EToolkitMode::Type Mode = EditWithinLevelEditor.IsValid() ? EToolkitMode::WorldCentric : EToolkitMode::Standalone;
33+
for (auto ObjIt = InObjects.CreateConstIterator(); ObjIt; ++ObjIt)
34+
{
35+
UTreeThemeAsset* TreeTheme = Cast<UTreeThemeAsset>(*ObjIt);
36+
if (TreeTheme) {
37+
TSharedRef<FTreeThemeEditor> NewTreeEditor(new FTreeThemeEditor);
38+
NewTreeEditor->InitTreeThemeEditor(Mode, EditWithinLevelEditor, TreeTheme);
39+
}
40+
}
41+
}
42+
43+
uint32 FLAThemeAssetTypeAction::GetCategories()
44+
{
45+
return EAssetTypeCategories::Misc | EAssetTypeCategories::Basic;
46+
}
47+
48+
void FLAThemeAssetTypeAction::GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder)
49+
{
50+
}
51+
52+
//////////////////////////////////////////////////////////////////////////
53+
54+
#undef LOCTEXT_NAMESPACE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//$ Copyright 2015 Ali Akbar, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
3+
#pragma once
4+
5+
#include "AssetTypeActions_Base.h"
6+
7+
class TREEARCHITECTEDITOR_API FLAThemeAssetTypeAction : public FAssetTypeActions_Base
8+
{
9+
public:
10+
// IAssetTypeActions interface
11+
virtual FText GetName() const override;
12+
virtual FColor GetTypeColor() const override;
13+
virtual UClass* GetSupportedClass() const override;
14+
virtual bool HasActions(const TArray<UObject*>& InObjects) const override { return false; }
15+
virtual void GetActions(const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder) override;
16+
virtual void OpenAssetEditor(const TArray<UObject*>& InObjects, TSharedPtr<class IToolkitHost> EditWithinLevelEditor = TSharedPtr<IToolkitHost>()) override;
17+
virtual uint32 GetCategories() override;
18+
// End of IAssetTypeActions interface
19+
20+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//$ Copyright 2015 Ali Akbar, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
#include "TreeArchitectEditorPrivatePCH.h"
3+
#include "TreeThemeFactory.h"
4+
#include "TreeThemeAsset.h"
5+
6+
7+
UTreeThemeFactory::UTreeThemeFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
8+
SupportedClass = UTreeThemeAsset::StaticClass();
9+
bCreateNew = true;
10+
bEditAfterNew = true;
11+
}
12+
13+
bool UTreeThemeFactory::CanCreateNew() const {
14+
return true;
15+
}
16+
17+
UObject* UTreeThemeFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) {
18+
UTreeThemeAsset* NewAsset = NewObject<UTreeThemeAsset>(InParent, Class, Name, Flags | RF_Transactional);
19+
return NewAsset;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//$ Copyright 2015 Ali Akbar, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
3+
#pragma once
4+
#include "Engine/DataAsset.h"
5+
#include "TreeThemeFactory.generated.h"
6+
7+
UCLASS()
8+
class TREEARCHITECTEDITOR_API UTreeThemeFactory : public UFactory {
9+
GENERATED_UCLASS_BODY()
10+
11+
// UFactory interface
12+
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
13+
virtual bool CanCreateNew() const override;
14+
// End of UFactory interface
15+
};
16+
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
//$ Copyright 2015-2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
#include "TreeArchitectEditorPrivatePCH.h"
3+
#include "TreeArchitectStyle.h"
4+
#include "IPluginManager.h"
5+
6+
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style.RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
7+
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style.RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
8+
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style.RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
9+
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style.RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
10+
#define TTF_CORE_FONT( RelativePath, ... ) FSlateFontInfo( Style.RootToCoreContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
11+
#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style.RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
12+
#define OTF_CORE_FONT( RelativePath, ... ) FSlateFontInfo( Style.RootToCoreContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
13+
14+
#define PLUGIN_IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( FLAStyle::InContent( RelativePath, ".png" ), __VA_ARGS__ )
15+
16+
17+
TSharedPtr< FSlateStyleSet > FLAStyle::StyleInstance = nullptr;
18+
19+
FString FLAStyle::InContent(const FString& RelativePath, const ANSICHAR* Extension)
20+
{
21+
static FString ContentDir = IPluginManager::Get().FindPlugin(TEXT("TreeArchitect"))->GetContentDir();
22+
return (ContentDir / RelativePath) + Extension;
23+
}
24+
25+
void FLAStyle::Initialize()
26+
{
27+
if (!StyleInstance.IsValid())
28+
{
29+
StyleInstance = Create();
30+
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
31+
}
32+
}
33+
34+
void FLAStyle::Shutdown()
35+
{
36+
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
37+
ensure(StyleInstance.IsUnique());
38+
StyleInstance.Reset();
39+
}
40+
41+
FName FLAStyle::GetStyleSetName()
42+
{
43+
static FName StyleSetName(TEXT("CityArchitectStyle"));
44+
return StyleSetName;
45+
}
46+
47+
TSharedRef< class FSlateStyleSet > FLAStyle::Create()
48+
{
49+
TSharedRef<FSlateStyleSet> StyleRef = MakeShareable(new FSlateStyleSet(FLAStyle::GetStyleSetName()));
50+
StyleRef->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate"));
51+
StyleRef->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));
52+
FSlateStyleSet& Style = StyleRef.Get();
53+
54+
const FVector2D Icon16x16(16.0f, 16.0f);
55+
const FVector2D Icon20x20(20.0f, 20.0f);
56+
const FVector2D Icon40x40(40.0f, 40.0f);
57+
const FVector2D Icon48x48(48.0f, 48.0f);
58+
59+
60+
// Define some 'normal' styles, upon which other variations can be based
61+
const FSlateFontInfo NormalFont = TTF_CORE_FONT("Fonts/Roboto-Regular", 9);
62+
63+
FTextBlockStyle NormalText = FTextBlockStyle()
64+
.SetFont(TTF_CORE_FONT("Fonts/Roboto-Regular", 10))
65+
.SetColorAndOpacity(FSlateColor::UseForeground())
66+
.SetShadowOffset(FVector2D::ZeroVector)
67+
.SetShadowColorAndOpacity(FLinearColor::Black)
68+
.SetHighlightColor(FLinearColor(0.02f, 0.3f, 0.0f))
69+
.SetHighlightShape(BOX_BRUSH("Common/TextBlockHighlightShape", FMargin(3.f / 8.f)));
70+
71+
72+
// Generic styles
73+
{
74+
Style.Set("CityArchitect.TabIcon", new PLUGIN_IMAGE_BRUSH("Icons/icon_CityEd_40x", Icon40x40));
75+
Style.Set("CityArchitect.TabIcon.Small", new PLUGIN_IMAGE_BRUSH("Icons/icon_CityEd_40x", Icon40x40));
76+
77+
Style.Set("CityEditMode.SetCategoryFlowMap", new IMAGE_BRUSH("Icons/icon_meshpaint_40x", Icon20x20));
78+
Style.Set("CityEditMode.SetCategoryPopulation", new IMAGE_BRUSH("Icons/icon_ShowSkeletalMeshes_40x", Icon20x20));
79+
Style.Set("CityEditMode.SetCategoryLandWater", new IMAGE_BRUSH("Icons/icon_Placement_FilterProps_40x", Icon20x20));
80+
Style.Set("CityEditMode.SetCategoryParkForest", new IMAGE_BRUSH("Icons/icon_Mode_Foliage_40x", Icon20x20));
81+
Style.Set("CityEditMode.SetCategoryStreetGraph", new IMAGE_BRUSH("Icons/icon_TextureEd_CheckeredBackground_40x", Icon20x20));
82+
83+
}
84+
85+
Style.Set("CityEditMode.ActiveToolName.Text", FTextBlockStyle(NormalText)
86+
.SetFont(TTF_CORE_FONT("Fonts/Roboto-Bold", 11))
87+
.SetShadowOffset(FVector2D(1, 1))
88+
);
89+
90+
/*
91+
// Editor Mode Styles
92+
{
93+
Style.Set("CityArchitect.ModePaint", new IMAGE_PLUGIN_BRUSH("Icons/CityEditMode/icon_CityEdMode_Paint_40x", Icon40x40));
94+
Style.Set("CityArchitect.ModeRectangle", new IMAGE_PLUGIN_BRUSH("Icons/CityEditMode/icon_CityEdMode_Rectangle_40x", Icon40x40));
95+
Style.Set("CityArchitect.ModeBorder", new IMAGE_PLUGIN_BRUSH("Icons/CityEditMode/icon_CityEdMode_Border_40x", Icon40x40));
96+
Style.Set("CityArchitect.ModeSelect", new IMAGE_PLUGIN_BRUSH("Icons/CityEditMode/icon_CityEdMode_Select_40x", Icon40x40));
97+
}
98+
*/
99+
100+
return StyleRef;
101+
}
102+
103+
104+
105+
const ISlateStyle& FLAStyle::Get()
106+
{
107+
return *StyleInstance;
108+
}
109+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//$ Copyright 2015-2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
#pragma once
3+
#include "EditorStyleSet.h"
4+
5+
/**
6+
* Implements the visual style of Tree Architect plugin
7+
*/
8+
class TREEARCHITECTEDITOR_API FLAStyle : FEditorStyle
9+
{
10+
public:
11+
static void Initialize();
12+
13+
static void Shutdown();
14+
15+
/** @return The Slate style set for CityArchitect Editor */
16+
static const ISlateStyle& Get();
17+
18+
static FName GetStyleSetName();
19+
20+
private:
21+
static TSharedRef< class FSlateStyleSet > Create();
22+
static FString InContent(const FString& RelativePath, const ANSICHAR* Extension);
23+
24+
void SetupGeneralStyles();
25+
26+
private:
27+
static TSharedPtr< class FSlateStyleSet > StyleInstance;
28+
29+
};
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//$ Copyright 2015-2016, Code Respawn Technologies Pvt Ltd - All Rights Reserved $//
2+
#include "TreeArchitectEditorPrivatePCH.h"
3+
#include "TreeEditorCustomization.h"
4+
#include "PropertyEditing.h"
5+
#include "SNotificationList.h"
6+
#include "NotificationManager.h"
7+
#include "ContentBrowserModule.h"
8+
#include "IDetailsView.h"
9+
#include "ObjectTools.h"
10+
#include "TreeArchitect.h"
11+
#include "LevelEditor.h"
12+
#include "ILevelViewport.h"
13+
#include "EditorViewportClient.h"
14+
15+
16+
#define LOCTEXT_NAMESPACE "TreeArchitectEditorModule"
17+
18+
void ShowNotification(FText Text, SNotificationItem::ECompletionState State = SNotificationItem::CS_Fail) {
19+
FNotificationInfo Info(Text);
20+
Info.bFireAndForget = true;
21+
Info.FadeOutDuration = 1.0f;
22+
Info.ExpireDuration = 2.0f;
23+
24+
TWeakPtr<SNotificationItem> NotificationPtr = FSlateNotificationManager::Get().AddNotification(Info);
25+
if (NotificationPtr.IsValid())
26+
{
27+
NotificationPtr.Pin()->SetCompletionState(State);
28+
}
29+
}
30+
31+
void SwitchToRealtimeMode() {
32+
FEditorViewportClient* client = (FEditorViewportClient*)GEditor->GetActiveViewport()->GetClient();
33+
if (client) {
34+
bool bRealtime = client->IsRealtime();
35+
if (!bRealtime) {
36+
ShowNotification(NSLOCTEXT("TreeRealtimeMode", "TreeRealtimeMode", "Switched viewport to Realtime mode"), SNotificationItem::CS_None);
37+
client->SetRealtime(true);
38+
}
39+
}
40+
else {
41+
ShowNotification(NSLOCTEXT("ClientNotFound", "ClientNotFound", "Warning: Cannot find active viewport"));
42+
}
43+
44+
}
45+
46+
47+
template<typename T>
48+
T* GetActor(IDetailLayoutBuilder* DetailBuilder) {
49+
TArray<TWeakObjectPtr<UObject>> OutObjects;
50+
DetailBuilder->GetObjectsBeingCustomized(OutObjects);
51+
if (OutObjects.Num() > 0) {
52+
return Cast<T>(OutObjects[0].Get());
53+
}
54+
return nullptr;
55+
}
56+
57+
FVector GetLevelViewportLocation() {
58+
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>("LevelEditor");
59+
TSharedPtr< ILevelViewport > ViewportWindow = LevelEditorModule.GetFirstActiveViewport();
60+
if (ViewportWindow.IsValid())
61+
{
62+
FEditorViewportClient &Viewport = ViewportWindow->GetLevelViewportClient();
63+
return Viewport.GetViewLocation();
64+
}
65+
return FVector::ZeroVector;
66+
}
67+
68+
69+
void FTreeArchitectCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
70+
{
71+
IDetailCategoryBuilder& Category = DetailBuilder.EditCategory("Tree");
72+
73+
Category.AddCustomRow(LOCTEXT("TreeArchitectCommand_FilterBuildTree", "build tree"))
74+
.ValueContent()
75+
[
76+
SNew(SButton)
77+
.Text(LOCTEXT("TreeCommand_BuildTree", "Build Tree"))
78+
.OnClicked(FOnClicked::CreateStatic(&FTreeArchitectCustomization::BuildTree, &DetailBuilder))
79+
];
80+
}
81+
82+
TSharedRef<IDetailCustomization> FTreeArchitectCustomization::MakeInstance()
83+
{
84+
return MakeShareable(new FTreeArchitectCustomization);
85+
}
86+
87+
FReply FTreeArchitectCustomization::BuildTree(IDetailLayoutBuilder* DetailBuilder)
88+
{
89+
ATreeArchitect* Tree = GetActor<ATreeArchitect>(DetailBuilder);
90+
if (Tree) {
91+
//Tree->SetBuildLocation(GetLevelViewportLocation());
92+
Tree->Build();
93+
}
94+
95+
return FReply::Handled();
96+
}
97+
98+
#undef LOCTEXT_NAMESPACE

0 commit comments

Comments
 (0)