Selaa lähdekoodia

Merge pull request #1215 from Areloch/InspectorFieldSearch

Adds ability to filter inspector fields
Brian Roberts 1 vuosi sitten
vanhempi
commit
5b9ec4e025

+ 16 - 1
Engine/source/gui/editor/guiInspector.cpp

@@ -54,6 +54,7 @@ GuiInspector::GuiInspector()
    mForcedArrayIndex(-1)
 {
    mPadding = 1;
+   mSearchText = StringTable->EmptyString();
 }
 
 //-----------------------------------------------------------------------------
@@ -79,7 +80,8 @@ void GuiInspector::initPersistFields()
          "If false the custom fields Name, Id, and Source Class will not be shown." );
 
       addField("forcedArrayIndex", TypeS32, Offset(mForcedArrayIndex, GuiInspector));
-         
+
+      addField("searchText", TypeString, Offset(mSearchText, GuiInspector), "A string that, if not blank, is used to filter shown fields");
    endGroup( "Inspector" );
 
    Parent::initPersistFields();
@@ -829,6 +831,12 @@ void GuiInspector::setForcedArrayIndex(S32 arrayIndex)
    refresh();
 }
 
+void GuiInspector::setSearchText(StringTableEntry searchText)
+{
+   mSearchText = searchText;
+   refresh();
+}
+
 //=============================================================================
 //    Console Methods.
 //=============================================================================
@@ -1000,3 +1008,10 @@ DefineEngineMethod(GuiInspector, setForcedArrayIndex, void, (S32 arrayIndex), (-
 {
    object->setForcedArrayIndex(arrayIndex);
 }
+
+DefineEngineMethod(GuiInspector, setSearchText, void, (const char* searchText), (""),
+   "Sets the searched text used to filter out displayed fields in the inspector."
+   "@param searchText The text to be used as a filter for field names. Leave as blank to clear search")
+{
+   object->setSearchText(searchText);
+}

+ 6 - 0
Engine/source/gui/editor/guiInspector.h

@@ -171,6 +171,10 @@ public:
 
    void setForcedArrayIndex(S32 arrayIndex);
 
+   StringTableEntry getSearchText() { return mSearchText; }
+
+   void setSearchText(StringTableEntry searchText);
+
 protected:
       
    typedef Vector< SimObjectPtr< SimObject > > TargetVector;
@@ -190,6 +194,8 @@ protected:
    String mGroupFilters;   
    bool mShowCustomFields;
    S32 mForcedArrayIndex;
+
+   StringTableEntry mSearchText;
 };
 
 #endif

+ 3 - 0
Engine/source/gui/editor/inspector/datablockField.cpp

@@ -175,6 +175,9 @@ GuiControl* GuiInspectorDatablockField::constructEditControl()
 
    //Add add button
    mAddButton = new GuiBitmapButtonCtrl();
+   if(mDesiredClass == NULL)
+      return retCtrl;
+
    dSprintf(szBuffer, sizeof(szBuffer), "DatablockEditorPlugin.createNewDatablockOfType(%s, %d.getText());", mDesiredClass->getClassName(), retCtrl->getId());
    mAddButton->setField("Command", szBuffer);
 

+ 6 - 0
Engine/source/gui/editor/inspector/dynamicGroup.cpp

@@ -123,6 +123,12 @@ bool GuiInspectorDynamicGroup::inspectGroup()
       SimFieldDictionary * fieldDictionary = target->getFieldDictionary();
       for(SimFieldDictionaryIterator ditr(fieldDictionary); *ditr; ++ditr)
       {
+         String searchText = mParent->getSearchText();
+         if (searchText != String::EmptyString) {
+            if (String((*ditr)->slotName).find(searchText, 0, String::NoCase | String::Left) == String::NPos)
+               continue;
+         }
+
          if( i == 0 )
          {
             flist.increment();

+ 6 - 0
Engine/source/gui/editor/inspector/group.cpp

@@ -288,6 +288,12 @@ bool GuiInspectorGroup::inspectGroup()
       if (field->flag.test(AbstractClassRep::FIELD_HideInInspectors))
          continue;
 
+      String searchText = mParent->getSearchText();
+      if (searchText != String::EmptyString) {
+         if (String(field->pFieldname).find(searchText, 0, String::NoCase | String::Left) == String::NPos)
+            continue;
+      }
+
       if ((bGrabItems == true || (bNoGroup == true && bGrabItems == false)) && itr->type != AbstractClassRep::DeprecatedFieldType)
       {
          if (bNoGroup == true && bGrabItems == true)

+ 34 - 4
Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui

@@ -967,6 +967,36 @@ $guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) {
                      tooltipprofile = "ToolsGuiToolTipProfile";
                      hovertime = "1000";
                      canSaveDynamicFields = "0";
+                     
+                     new GuiTextEditCtrl( GuiEditorInspectorFilter ) {
+                        position = "5 0";
+                        extent = "222 20";
+                        profile = "ToolsGuiTextEditProfile";
+                        horizSizing = "width";
+                        vertSizing = "bottom";
+                        placeholderText = "Filter...";
+                        validate = "GuiEditorInspectFields.setSearchText($ThisControl.getText());";
+                     };
+                     
+                     new GuiBitmapButtonCtrl() {
+                        bitmapAsset = "ToolsModule:clear_icon_n_image";
+                        groupNum = "-1";
+                        buttonType = "PushButton";
+                        useMouseEvents = "0";
+                        isContainer = "0";
+                        Profile = "ToolsGuiDefaultProfile";
+                        HorizSizing = "left";
+                        VertSizing = "bottom";
+                        position = "205 2";
+                        Extent = "17 17";
+                        MinExtent = "8 2";
+                        canSave = "1";
+                        Visible = "1";
+                        tooltipprofile = "ToolsGuiToolTipProfile";
+                        hovertime = "1000";
+                        canSaveDynamicFields = "0";
+                        command = "GuiEditorInspectorFilter.setText(\"\");GuiEditorInspectFields.setSearchText(\"\");";
+                     };
 
                      new GuiScrollCtrl() {
                         willFirstRespond = "1";
@@ -979,7 +1009,7 @@ $guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) {
                         mouseWheelScrollSpeed = "-1";
                         Margin = "0 0 0 0";
                         Padding = "0 0 0 0";
-                        AnchorTop = "1";
+                        AnchorTop = "0";
                         AnchorBottom = "0";
                         AnchorLeft = "1";
                         AnchorRight = "0";
@@ -987,8 +1017,8 @@ $guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) {
                         Profile = "GuiEditorScrollProfile";
                         HorizSizing = "width";
                         VertSizing = "height";
-                        position = "0 2";
-                        Extent = "223 341";
+                        position = "0 20";
+                        Extent = "223 321";
                         MinExtent = "8 2";
                         canSave = "1";
                         Visible = "1";
@@ -1011,7 +1041,7 @@ $guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) {
                            HorizSizing = "width";
                            VertSizing = "bottom";
                            position = "1 1";
-                           Extent = "221 24";
+                           Extent = "221 321";
                            MinExtent = "8 24";
                            canSave = "1";
                            Visible = "1";

+ 37 - 7
Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui

@@ -67,6 +67,36 @@ $guiContent = new GuiControl() {
          AnchorBottom = "0";
          AnchorLeft = "1";
          AnchorRight = "0";
+         
+         new GuiTextEditCtrl( EditorInspectorFilter ) {
+            position = "5 -4";
+            extent = "341 20";
+            profile = "ToolsGuiTextEditProfile";
+            horizSizing = "width";
+            vertSizing = "bottom";
+            placeholderText = "Filter...";
+            validate = "Inspector.setSearchText($ThisControl.getText());";
+         };
+         
+         new GuiBitmapButtonCtrl() {
+            bitmapAsset = "ToolsModule:clear_icon_n_image";
+            groupNum = "-1";
+            buttonType = "PushButton";
+            useMouseEvents = "0";
+            isContainer = "0";
+            Profile = "ToolsGuiDefaultProfile";
+            HorizSizing = "left";
+            VertSizing = "bottom";
+            position = "325 -2";
+            Extent = "17 17";
+            MinExtent = "8 2";
+            canSave = "1";
+            Visible = "1";
+            tooltipprofile = "ToolsGuiToolTipProfile";
+            hovertime = "1000";
+            canSaveDynamicFields = "0";
+            command = "EditorInspectorFilter.setText(\"\");Inspector.setSearchText(\"\");";
+         };
 
          new GuiScrollCtrl() {
             canSaveDynamicFields = "0";
@@ -74,20 +104,20 @@ $guiContent = new GuiControl() {
             isContainer = "1";
             Profile = "GuiEditorScrollProfile";
             HorizSizing = "width";
-            VertSizing = "height";
-            Position = "5 5";
-            Extent = "187 238";
+            VertSizing = "bottom";
+            Position = "5 20";
+            Extent = "343 941";
             MinExtent = "8 8";
             canSave = "1";
             Visible = "1";
             tooltipprofile = "ToolsGuiToolTipProfile";
             hovertime = "1000";
-            Docking = "Client";
+            Docking = "None";
             Margin = "0 0 0 0";
             Padding = "0 0 0 0";
-            AnchorTop = "1";
+            AnchorTop = "0";
             AnchorBottom = "0";
-            AnchorLeft = "1";
+            AnchorLeft = "0";
             AnchorRight = "0";
             willFirstRespond = "1";
             hScrollBar = "alwaysOff";
@@ -109,7 +139,7 @@ $guiContent = new GuiControl() {
                HorizSizing = "width";
                VertSizing = "bottom";
                Position = "0 0";
-               Extent = "202 309";
+               Extent = "343 941";
                MinExtent = "8 8";
                canSave = "1";
                Visible = "1";