diff --git a/tools/leveleditor/include/inspector.h b/tools/leveleditor/include/inspector.h index acb870d..5a5d3f5 100644 --- a/tools/leveleditor/include/inspector.h +++ b/tools/leveleditor/include/inspector.h @@ -7,6 +7,7 @@ struct Context; struct InfoComponent; struct TransformComponent; struct MeshComponent; +struct LightComponent; class Inspector : public QWidget { Q_OBJECT @@ -19,6 +20,7 @@ private: void addInfoInspector(InfoComponent* info); void addTransformInspector(TransformComponent* transform); void addMeshInspector(MeshComponent* mesh); + void addLightInspector(LightComponent* light); QVBoxLayout* layout = nullptr; diff --git a/tools/leveleditor/src/inspector.cpp b/tools/leveleditor/src/inspector.cpp index 180d453..1089835 100644 --- a/tools/leveleditor/src/inspector.cpp +++ b/tools/leveleditor/src/inspector.cpp @@ -3,12 +3,14 @@ #include #include #include +#include #include "context.h" #include "ecs.h" #include "worldmanager.h" #include "vec3edit.h" #include "collapsesection.h" +#include "coloredit.h" Inspector::Inspector(Context& context, QWidget* parent) : QWidget(parent), context(context) { setWindowTitle("Inspector"); @@ -49,6 +51,10 @@ void Inspector::rebuild() { MeshComponent* mesh = ECS::getComponent(entity); if(mesh) addMeshInspector(mesh); + + LightComponent* light = ECS::getComponent(entity); + if(light) + addLightInspector(light); } void Inspector::addInfoInspector(InfoComponent* info) { @@ -94,3 +100,32 @@ void Inspector::addMeshInspector(MeshComponent* mesh) { QGridLayout* layout = new QGridLayout(); section->setLayout(layout); } + +void Inspector::addLightInspector(LightComponent* light) { + CollapseSection* section = new CollapseSection("Light", true); + layout->addWidget(section); + sections.push_back(section); + + QGridLayout* layout = new QGridLayout(); + section->setLayout(layout); + + QLabel* typeLabel = new QLabel("Type"); + layout->addWidget(typeLabel); + + QComboBox* typeCombo = new QComboBox(); + typeCombo->addItem("Point"); + typeCombo->addItem("Directional"); + typeCombo->setCurrentIndex((int)light->type); + + connect(typeCombo, QOverload::of(&QComboBox::currentIndexChanged), [light](int index) { + light->type = (LightType)index; + }); + + layout->addWidget(typeCombo, 0, 1); + + QLabel* colorLabel = new QLabel("Color"); + layout->addWidget(colorLabel, 1, 0); + + ColorEdit* colorEdit = new ColorEdit(light->color); + layout->addWidget(colorEdit, 1, 1); +}