Make remove component button functional'
This commit is contained in:
parent
a2893303ae
commit
51b5f96cc3
2 changed files with 25 additions and 1 deletions
|
@ -131,6 +131,16 @@ namespace ECS {
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static inline void removeComponent(const EntityID id) {
|
static inline void removeComponent(const EntityID id) {
|
||||||
delete transforms[id];
|
if constexpr(std::is_same<T, InfoComponent>::value) {
|
||||||
|
infos.erase(infos.find(id), infos.end());
|
||||||
|
} else if constexpr(std::is_same<T, TransformComponent>::value) {
|
||||||
|
transforms.erase(transforms.find(id), transforms.end());
|
||||||
|
} else if constexpr(std::is_same<T, MeshComponent>::value) {
|
||||||
|
meshes.erase(meshes.find(id), meshes.end());
|
||||||
|
} else if constexpr(std::is_same<T, LightComponent>::value) {
|
||||||
|
lights.erase(lights.find(id), lights.end());
|
||||||
|
} else if constexpr(std::is_same<T, CameraComponent>::value) {
|
||||||
|
cameras.erase(cameras.find(id), cameras.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -123,7 +123,14 @@ void Properties::addTransformSection(TransformComponent* transform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Properties::addMeshSection(MeshComponent* mesh) {
|
void Properties::addMeshSection(MeshComponent* mesh) {
|
||||||
|
const auto& entity = context.selectedEntities[0];
|
||||||
|
|
||||||
CollapseSection* section = new CollapseSection("Mesh", true);
|
CollapseSection* section = new CollapseSection("Mesh", true);
|
||||||
|
connect(section, &CollapseSection::closeRequested, [entity, this] {
|
||||||
|
ECS::removeComponent<MeshComponent>(entity);
|
||||||
|
|
||||||
|
emit context.entitiesChanged();
|
||||||
|
});
|
||||||
layout->addWidget(section);
|
layout->addWidget(section);
|
||||||
sections.push_back(section);
|
sections.push_back(section);
|
||||||
|
|
||||||
|
@ -132,7 +139,14 @@ void Properties::addMeshSection(MeshComponent* mesh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Properties::addLightSection(LightComponent* light) {
|
void Properties::addLightSection(LightComponent* light) {
|
||||||
|
const auto& entity = context.selectedEntities[0];
|
||||||
|
|
||||||
CollapseSection* section = new CollapseSection("Light", true);
|
CollapseSection* section = new CollapseSection("Light", true);
|
||||||
|
connect(section, &CollapseSection::closeRequested, [entity, this] {
|
||||||
|
ECS::removeComponent<LightComponent>(entity);
|
||||||
|
|
||||||
|
emit context.entitiesChanged();
|
||||||
|
});
|
||||||
layout->addWidget(section);
|
layout->addWidget(section);
|
||||||
sections.push_back(section);
|
sections.push_back(section);
|
||||||
|
|
||||||
|
|
Reference in a new issue