Skip to content

Commit 21a81c8

Browse files
committed
Working drag and drop entity to code editor
1 parent e9f7980 commit 21a81c8

4 files changed

Lines changed: 520 additions & 0 deletions

File tree

editor/util/ProjectUtils.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@
1010
#include "component/ButtonComponent.h"
1111
#include "component/ModelComponent.h"
1212
#include "component/Transform.h"
13+
#include "component/MeshComponent.h"
14+
#include "component/SkyComponent.h"
15+
#include "component/FogComponent.h"
16+
#include "component/LightComponent.h"
17+
#include "component/CameraComponent.h"
18+
#include "component/SpriteComponent.h"
19+
#include "component/PointsComponent.h"
20+
#include "component/LinesComponent.h"
21+
#include "component/TerrainComponent.h"
22+
#include "component/AudioComponent.h"
23+
#include "component/UIContainerComponent.h"
24+
#include "component/UIComponent.h"
25+
#include "component/TextComponent.h"
26+
#include "component/TextEditComponent.h"
27+
#include "component/ImageComponent.h"
28+
#include "component/PanelComponent.h"
29+
#include "component/ScrollbarComponent.h"
30+
#include "component/PolygonComponent.h"
31+
#include "component/Body2DComponent.h"
32+
#include "component/Body3DComponent.h"
33+
#include "component/Joint2DComponent.h"
34+
#include "component/Joint3DComponent.h"
1335

1436
#include "component/TilemapComponent.h"
1537
#include "command/type/MultiPropertyCmd.h"
@@ -1259,4 +1281,38 @@ editor::Command* editor::ProjectUtils::buildDeleteTileCmd(Project* project, uint
12591281

12601282
multiCmd->setNoMerge();
12611283
return multiCmd;
1284+
}
1285+
1286+
std::string editor::ProjectUtils::getEntityTypeName(Scene* scene, Entity entity) {
1287+
Signature signature = scene->getSignature(entity);
1288+
1289+
if (signature.test(scene->getComponentId<ModelComponent>())) return "Model";
1290+
if (signature.test(scene->getComponentId<BoneComponent>())) return "Bone";
1291+
if (signature.test(scene->getComponentId<TilemapComponent>())) return "Tilemap";
1292+
if (signature.test(scene->getComponentId<TerrainComponent>())) return "Terrain";
1293+
if (signature.test(scene->getComponentId<SpriteComponent>())) return "Sprite";
1294+
if (signature.test(scene->getComponentId<PointsComponent>())) return "Points";
1295+
if (signature.test(scene->getComponentId<LinesComponent>())) return "Lines";
1296+
if (signature.test(scene->getComponentId<PolygonComponent>())) return "Polygon";
1297+
if (signature.test(scene->getComponentId<MeshComponent>())) return "Mesh";
1298+
if (signature.test(scene->getComponentId<SkyComponent>())) return "SkyBox";
1299+
if (signature.test(scene->getComponentId<FogComponent>())) return "Fog";
1300+
if (signature.test(scene->getComponentId<AudioComponent>())) return "Audio";
1301+
if (signature.test(scene->getComponentId<ButtonComponent>())) return "Button";
1302+
if (signature.test(scene->getComponentId<TextEditComponent>())) return "TextEdit";
1303+
if (signature.test(scene->getComponentId<TextComponent>())) return "Text";
1304+
if (signature.test(scene->getComponentId<ImageComponent>())) return "Image";
1305+
if (signature.test(scene->getComponentId<PanelComponent>())) return "Panel";
1306+
if (signature.test(scene->getComponentId<ScrollbarComponent>())) return "Scrollbar";
1307+
if (signature.test(scene->getComponentId<UIContainerComponent>())) return "Container";
1308+
if (signature.test(scene->getComponentId<UIComponent>())) return "UILayout";
1309+
if (signature.test(scene->getComponentId<LightComponent>())) return "Light";
1310+
if (signature.test(scene->getComponentId<CameraComponent>())) return "Camera";
1311+
if (signature.test(scene->getComponentId<Body2DComponent>())) return "Body2D";
1312+
if (signature.test(scene->getComponentId<Body3DComponent>())) return "Body3D";
1313+
if (signature.test(scene->getComponentId<AnimationComponent>())) return "Animation";
1314+
if (signature.test(scene->getComponentId<ActionComponent>())) return "Action";
1315+
if (signature.test(scene->getComponentId<Transform>())) return "Object";
1316+
1317+
return "entity";
12621318
}

editor/util/ProjectUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class ProjectUtils {
4848

4949
static void collectEntities(const YAML::Node& entityNode, std::vector<Entity>& allEntities);
5050

51+
// Returns entity type name (e.g. "Mesh", "Camera", "Light") based on its components
52+
static std::string getEntityTypeName(Scene* scene, Entity entity);
53+
5154
// Fills a Texture with the editor built-in default skybox cubemap.
5255
static void setDefaultSkyTexture(Texture& outTexture);
5356

0 commit comments

Comments
 (0)