mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Adds logic to be able to set a search string on an inspector that will be used to filter displayed fields.
Adds a textEdit filter box to the main world inspector that hooks into the primary inspector for said search functionality
This commit is contained in:
parent
59fc6d3d65
commit
d890c530f9
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in a new issue