Tweak to the Component Fields to properly refresh the group.

This commit is contained in:
Areloch 2016-06-02 23:57:46 -05:00
parent 89672ea0ab
commit 6ec899620d
2 changed files with 44 additions and 49 deletions

View file

@ -616,11 +616,14 @@ void GuiInspector::refresh()
//Build the component field groups as the component describes it //Build the component field groups as the component describes it
Component* comp = dynamic_cast<Component*>(mTargets.first().getPointer()); Component* comp = dynamic_cast<Component*>(mTargets.first().getPointer());
if (comp->getComponentFieldCount() > 0)
{
GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this); GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this);
compGroup->registerObject(); compGroup->registerObject();
mGroups.push_back(compGroup); mGroups.push_back(compGroup);
addObject(compGroup); addObject(compGroup);
} }
}
#endif #endif
// Create the inspector groups for static fields. // Create the inspector groups for static fields.

View file

@ -76,21 +76,13 @@ bool GuiInspectorComponentGroup::inspectGroup()
if (!mParent || !mParent->getNumInspectObjects()) if (!mParent || !mParent->getNumInspectObjects())
return false; return false;
clearFields();
// to prevent crazy resizing, we'll just freeze our stack for a sec.. // to prevent crazy resizing, we'll just freeze our stack for a sec..
mStack->freeze(true); mStack->freeze(true);
mStack->clear();
bool bNoGroup = false; bool bNoGroup = false;
// Un-grouped fields are all sorted into the 'general' group
if (dStricmp(mCaption, "General") == 0)
bNoGroup = true;
// Just delete all fields and recreate them (like the dynamicGroup)
// because that makes creating controls for array fields a lot easier
clearFields();
bool bNewItems = false; bool bNewItems = false;
bool bMakingArray = false; bool bMakingArray = false;
GuiStackControl *pArrayStack = NULL; GuiStackControl *pArrayStack = NULL;
@ -116,10 +108,7 @@ bool GuiInspectorComponentGroup::inspectGroup()
fieldGui->init(mParent, this); fieldGui->init(mParent, this);
AbstractClassRep::Field *refField; AbstractClassRep::Field *refField;
//check statics
refField = const_cast<AbstractClassRep::Field *>(comp->findField(field->mFieldName));
if (!refField)
{
//check dynamics //check dynamics
SimFieldDictionary* fieldDictionary = comp->getFieldDictionary(); SimFieldDictionary* fieldDictionary = comp->getFieldDictionary();
SimFieldDictionaryIterator itr(fieldDictionary); SimFieldDictionaryIterator itr(fieldDictionary);
@ -145,10 +134,9 @@ bool GuiInspectorComponentGroup::inspectGroup()
f.getDataFn = &defaultProtectedGetFn; f.getDataFn = &defaultProtectedGetFn;
f.writeDataFn = &defaultProtectedWriteFn; f.writeDataFn = &defaultProtectedWriteFn;
if (!dStrcmp(field->mGroup, "")) f.pFieldDocs = field->mFieldDescription;
f.pGroupname = "Component";
else f.pGroupname = "Component Fields";
f.pGroupname = field->mGroup;
ConsoleBaseType* conType = ConsoleBaseType::getType(field->mFieldType); ConsoleBaseType* conType = ConsoleBaseType::getType(field->mFieldType);
AssertFatal(conType, "ConsoleObject::addField - invalid console type"); AssertFatal(conType, "ConsoleObject::addField - invalid console type");
@ -162,7 +150,6 @@ bool GuiInspectorComponentGroup::inspectGroup()
} }
++itr; ++itr;
} }
}
if (!refField) if (!refField)
continue; continue;
@ -216,6 +203,11 @@ ConsoleMethod(GuiInspectorComponentGroup, inspectGroup, bool, 2, 2, "Refreshes t
void GuiInspectorComponentGroup::clearFields() void GuiInspectorComponentGroup::clearFields()
{ {
// delete everything else
mStack->clear();
// clear the mChildren list.
mChildren.clear();
} }
SimFieldDictionary::Entry* GuiInspectorComponentGroup::findDynamicFieldInDictionary(StringTableEntry fieldName) SimFieldDictionary::Entry* GuiInspectorComponentGroup::findDynamicFieldInDictionary(StringTableEntry fieldName)