diff --git a/Engine/source/gui/editor/guiInspector.cpp b/Engine/source/gui/editor/guiInspector.cpp index eb2b9d818..94bfc8d9c 100644 --- a/Engine/source/gui/editor/guiInspector.cpp +++ b/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); +} diff --git a/Engine/source/gui/editor/guiInspector.h b/Engine/source/gui/editor/guiInspector.h index bd1197bc7..0bbc40885 100644 --- a/Engine/source/gui/editor/guiInspector.h +++ b/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 diff --git a/Engine/source/gui/editor/inspector/datablockField.cpp b/Engine/source/gui/editor/inspector/datablockField.cpp index bd6962add..2ee7ee160 100644 --- a/Engine/source/gui/editor/inspector/datablockField.cpp +++ b/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); diff --git a/Engine/source/gui/editor/inspector/dynamicGroup.cpp b/Engine/source/gui/editor/inspector/dynamicGroup.cpp index 2f3de7f8d..83e37d848 100644 --- a/Engine/source/gui/editor/inspector/dynamicGroup.cpp +++ b/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(); diff --git a/Engine/source/gui/editor/inspector/group.cpp b/Engine/source/gui/editor/inspector/group.cpp index 180942949..64ed2b352 100644 --- a/Engine/source/gui/editor/inspector/group.cpp +++ b/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) diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui index 6fb643afe..960e20504 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui +++ b/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"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui index c5a201234..5c60d44b1 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui +++ b/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";