Bladeren bron

Tweak to the Component Fields to properly refresh the group.

Areloch 9 jaren geleden
bovenliggende
commit
6ec899620d
2 gewijzigde bestanden met toevoegingen van 44 en 49 verwijderingen
  1. 7 4
      Engine/source/gui/editor/guiInspector.cpp
  2. 37 45
      Engine/source/gui/editor/inspector/componentGroup.cpp

+ 7 - 4
Engine/source/gui/editor/guiInspector.cpp

@@ -616,10 +616,13 @@ 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());
 
 
-      GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this);
-      compGroup->registerObject();
-      mGroups.push_back(compGroup);
-      addObject(compGroup);
+      if (comp->getComponentFieldCount() > 0)
+      {
+         GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this);
+         compGroup->registerObject();
+         mGroups.push_back(compGroup);
+         addObject(compGroup);
+      }
    }
    }
 #endif
 #endif
 
 

+ 37 - 45
Engine/source/gui/editor/inspector/componentGroup.cpp

@@ -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,52 +108,47 @@ 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
-         SimFieldDictionary* fieldDictionary = comp->getFieldDictionary();
-         SimFieldDictionaryIterator itr(fieldDictionary);
 
 
-         while (*itr)
+      //check dynamics
+      SimFieldDictionary* fieldDictionary = comp->getFieldDictionary();
+      SimFieldDictionaryIterator itr(fieldDictionary);
+
+      while (*itr)
+      {
+         SimFieldDictionary::Entry* entry = *itr;
+         if (entry->slotName == field->mFieldName)
          {
          {
-            SimFieldDictionary::Entry* entry = *itr;
-            if (entry->slotName == field->mFieldName)
-            {
-               AbstractClassRep::Field f;
-               f.pFieldname = StringTable->insert(field->mFieldName);
+            AbstractClassRep::Field f;
+            f.pFieldname = StringTable->insert(field->mFieldName);
 
 
-               if (field->mFieldDescription)
-                  f.pFieldDocs = field->mFieldDescription;
+            if (field->mFieldDescription)
+               f.pFieldDocs = field->mFieldDescription;
 
 
-               f.type = field->mFieldType;
-               f.offset = -1;
-               f.elementCount = 1;
-               f.validator = NULL;
-               f.flag = 0; //change to be the component type
+            f.type = field->mFieldType;
+            f.offset = -1;
+            f.elementCount = 1;
+            f.validator = NULL;
+            f.flag = 0; //change to be the component type
 
 
-               f.setDataFn = &defaultProtectedSetFn;
-               f.getDataFn = &defaultProtectedGetFn;
-               f.writeDataFn = &defaultProtectedWriteFn;
+            f.setDataFn = &defaultProtectedSetFn;
+            f.getDataFn = &defaultProtectedGetFn;
+            f.writeDataFn = &defaultProtectedWriteFn;
 
 
-               if (!dStrcmp(field->mGroup, ""))
-                  f.pGroupname = "Component";
-               else
-                  f.pGroupname = field->mGroup;
+            f.pFieldDocs = field->mFieldDescription;
 
 
-               ConsoleBaseType* conType = ConsoleBaseType::getType(field->mFieldType);
-               AssertFatal(conType, "ConsoleObject::addField - invalid console type");
-               f.table = conType->getEnumTable();
+            f.pGroupname = "Component Fields";
 
 
-               tempFields.push_back(f);
+            ConsoleBaseType* conType = ConsoleBaseType::getType(field->mFieldType);
+            AssertFatal(conType, "ConsoleObject::addField - invalid console type");
+            f.table = conType->getEnumTable();
 
 
-               refField = &f;
+            tempFields.push_back(f);
 
 
-               break;
-            }
-            ++itr;
+            refField = &f;
+
+            break;
          }
          }
+         ++itr;
       }
       }
 
 
       if (!refField)
       if (!refField)
@@ -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)