Procházet zdrojové kódy

Hidden Field List for GuiInspector

The GuiInspector needed to be able to hide certain fields in certain contexts. For example, the Asset Manager doesn't show "Internal" assets which are used by the editors. As such, changing an asset to internal on accident would hide an asset forever. Other cases include when the editor would like to handle a field in a special way (like locked) or when changing a field is outside the scope to the editor.
Peter Robinson před 4 roky
rodič
revize
d98fb41512

+ 8 - 0
editor/AssetAdmin/AssetInspector.cs

@@ -86,10 +86,18 @@ function AssetInspector::onAdd(%this)
 
 function AssetInspector::loadImageAsset(%this, %imageAsset, %assetID)
 {
+	%this.inspector.clearHiddenFields();
+	%this.inspector.addHiddenField("hidden");
+	%this.inspector.addHiddenField("locked");
+	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.inspect(%imageAsset);
 }
 
 function AssetInspector::loadAnimationAsset(%this, %animationAsset, %assetID)
 {
+	%this.inspector.clearHiddenFields();
+	%this.inspector.addHiddenField("hidden");
+	%this.inspector.addHiddenField("locked");
+	%this.inspector.addHiddenField("AssetInternal");
 	%this.inspector.inspect(%animationAsset);
 }

+ 33 - 18
engine/source/gui/editor/guiInspector.cc

@@ -335,21 +335,21 @@ void GuiInspector::inspectObject( SimObject *object )
       addObject( dynGroup );
    }
 
-   // If the general group is still empty at this point, kill it.
+   // If any group is still empty at this point, kill it.
    for(S32 i=0; i<mGroups.size(); i++)
    {
-      if(mGroups[i] == general && general->mGrid->size() == 0)
+      if(mGroups[i]->mGrid->size() == 0)
       {
+		 mGroups[i]->deleteObject();
          mGroups.erase(i);
-         general->deleteObject();
-         resize(getPosition(), getExtent());
+		 i--;
       }
    }
+   resize(getPosition(), getExtent());
 
    // Don't steal first responder
    if( !currResponder.isNull() )
       guiCanvas->setFirstResponder( currResponder );
-
 }
 
 ConsoleMethod( GuiInspector, inspect, void, 3, 3, "(obj) Goes through the object's fields and autogenerates editor boxes\n"
@@ -394,6 +394,18 @@ ConsoleMethod( GuiInspector, setName, void, 3, 3, "(NewObjectName) Set object na
 {
    object->setName(argv[2]);
 }
+
+ConsoleMethod(GuiInspector, clearHiddenFields, void, 2, 2, "() Clears the list of hidden fields\n"
+	"@return No return value.")
+{
+	object->clearHiddenField();
+}
+
+ConsoleMethod(GuiInspector, addHiddenField, void, 3, 3, "() Adds a new field to the list of hidden fields\n"
+	"@return No return value.")
+{
+	object->addHiddenField(argv[2]);
+}
 #pragma endregion
 
 #pragma region GuiInspectorField
@@ -748,29 +760,26 @@ bool GuiInspectorGroup::inspectGroup()
       if( itr->type == AbstractClassRep::StartGroupFieldType )
       {
          // If we're dealing with general fields, always set grabItems to true (to skip them)
-         if( bNoGroup == true )
-            bGrabItems = true;
-         else if( itr->pGroupname != NULL && dStricmp( itr->pGroupname, mText ) == 0 )
+         if( bNoGroup == true || ( itr->pGroupname != NULL && dStricmp( itr->pGroupname, mText ) == 0 ))
             bGrabItems = true;
          continue;
       }
       else if ( itr->type == AbstractClassRep::EndGroupFieldType )
       {
          // If we're dealing with general fields, always set grabItems to false (to grab them)
-         if( bNoGroup == true )
-            bGrabItems = false;
-         else if( itr->pGroupname != NULL && dStricmp( itr->pGroupname, mText ) == 0 )
+         if( bNoGroup == true || ( itr->pGroupname != NULL && dStricmp( itr->pGroupname, mText ) == 0 ))
             bGrabItems = false;
          continue;
       }
 
-      if( ( bGrabItems == true || ( bNoGroup == true && bGrabItems == false ) ) && itr->type != AbstractClassRep::DepricatedFieldType )
-      {
-         if( bNoGroup == true && bGrabItems == true )
-            continue; 
-           // This is weird, but it should work for now. - JDD
-           // We are going to check to see if this item is an array
-           // if so, we're going to construct a field for each array element
+      if((bGrabItems == true || (bNoGroup == true && bGrabItems == false)) && itr->type != AbstractClassRep::DepricatedFieldType )
+      { 
+		  //We are inside a group and looking for items that don't have a group. Move on.
+		  if( bNoGroup == true && bGrabItems == true )
+				continue; 
+
+        // We are going to check to see if this item is an array
+        // if so, we're going to construct a field for each array element
          if( itr->elementCount > 1 )
          {
             for(S32 nI = 0; nI < itr->elementCount; nI++)
@@ -830,6 +839,12 @@ bool GuiInspectorGroup::inspectGroup()
 
             bNewItems = true;
 
+			//check the hidden field list
+			if (mInspector->hideField(itr->pFieldname))
+			{
+				continue;
+			}
+			//Time to create a new field
             field = constructField( itr->type );
             if( field == NULL )
                field = new GuiInspectorField( this, mTarget, itr );

+ 9 - 0
engine/source/gui/editor/guiInspector.h

@@ -66,6 +66,9 @@
 #include "gui/containers/guiPanelCtrl.h"
 #endif
 
+#include <string>
+#include <vector>
+#include <algorithm>
 
 // Forward Declare GuiInspectorGroup
 class GuiInspectorGroup;
@@ -78,6 +81,8 @@ class GuiInspector : public GuiChainCtrl
 {
 private:
    typedef GuiChainCtrl Parent;
+   vector<string> mHiddenFieldList;
+
 public:
    // Members
    Vector<GuiInspectorGroup*>    mGroups;
@@ -96,6 +101,9 @@ public:
    void setName( const char* newName );
    void clearGroups();
    bool findExistentGroup( StringTableEntry groupName );
+   inline bool hideField(const char* fieldName) { return std::find(mHiddenFieldList.begin(), mHiddenFieldList.end(), fieldName) != mHiddenFieldList.end(); };
+   inline void clearHiddenField() { mHiddenFieldList.clear(); };
+   inline void addHiddenField(const char* fieldName) { mHiddenFieldList.push_back(fieldName); };
 
    GuiControlProfile *mGroupPanelProfile;
    GuiControlProfile *mGroupGridProfile;
@@ -126,6 +134,7 @@ class GuiInspectorField : public GuiControl
 {
 private:
    typedef GuiControl Parent;
+
 public:
 
    // Members