Fixes the inspector/component editor to display the components attached to an entity correctly in the inspector.

This commit is contained in:
Areloch 2017-12-03 01:21:30 -06:00
parent 4f78143dc8
commit b5277e0f08
10 changed files with 513 additions and 44 deletions

View file

@ -32,6 +32,7 @@
#include "gui/editor/inspector/entityGroup.h"
#include "gui/editor/inspector/mountingGroup.h"
#include "gui/editor/inspector/componentGroup.h"
#include "T3D/components/component.h"
IMPLEMENT_CONOBJECT(GuiInspector);
@ -590,6 +591,13 @@ void GuiInspector::refresh()
//Entity inspector group
if (mTargets.first()->getClassRep()->isSubclassOf("Entity"))
{
//Put the GameObject group before everything that'd be gameobject-effecting, for orginazational purposes
GuiInspectorGroup *gameObject = new GuiInspectorGroup("GameObject", this);
gameObject->registerObject();
mGroups.push_back(gameObject);
addObject(gameObject);
GuiInspectorEntityGroup *components = new GuiInspectorEntityGroup("Components", this);
if (components != NULL)
{
@ -598,6 +606,29 @@ void GuiInspector::refresh()
addObject(components);
}
Entity* selectedEntity = dynamic_cast<Entity*>(mTargets.first().getObject());
U32 compCount = selectedEntity->getComponentCount();
//Now, add the component groups
for (U32 c = 0; c < compCount; ++c)
{
Component* comp = selectedEntity->getComponent(c);
String compName;
if (comp->getFriendlyName() != StringTable->EmptyString())
compName = comp->getFriendlyName();
else
compName = comp->getComponentName();
GuiInspectorGroup *compGroup = new GuiInspectorComponentGroup(compName, this, comp);
if (compGroup != NULL)
{
compGroup->registerObject();
mGroups.push_back(compGroup);
addObject(compGroup);
}
}
//Mounting group override
GuiInspectorGroup *mounting = new GuiInspectorMountingGroup("Mounting", this);
if (mounting != NULL)
@ -608,20 +639,6 @@ void GuiInspector::refresh()
}
}
if (mTargets.first()->getClassRep()->isSubclassOf("Component"))
{
//Build the component field groups as the component describes it
Component* comp = dynamic_cast<Component*>(mTargets.first().getPointer());
if (comp->getComponentFieldCount() > 0)
{
GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this);
compGroup->registerObject();
mGroups.push_back(compGroup);
addObject(compGroup);
}
}
// Create the inspector groups for static fields.
for( TargetVector::iterator iter = mTargets.begin(); iter != mTargets.end(); ++ iter )