Adds ability to force the inspector to only show a set index of array'd fields. Mostly for specific editor tool use(like editing material's individual layers/stages)

This commit is contained in:
Areloch 2024-02-04 00:21:54 -06:00
parent 1ee85334b0
commit 4646d5eac3
4 changed files with 232 additions and 145 deletions

View file

@ -50,7 +50,8 @@ GuiInspector::GuiInspector()
mMovingDivider( false ),
mHLField( NULL ),
mShowCustomFields( true ),
mComponentGroupTargetId(-1)
mComponentGroupTargetId(-1),
mForcedArrayIndex(-1)
{
mPadding = 1;
}
@ -76,6 +77,8 @@ void GuiInspector::initPersistFields()
addField( "showCustomFields", TypeBool, Offset( mShowCustomFields, GuiInspector ),
"If false the custom fields Name, Id, and Source Class will not be shown." );
addField("forcedArrayIndex", TypeS32, Offset(mForcedArrayIndex, GuiInspector));
endGroup( "Inspector" );
@ -622,6 +625,7 @@ void GuiInspector::refresh()
if( !group && !isGroupFiltered( itr->pGroupname ) )
{
GuiInspectorGroup *newGroup = new GuiInspectorGroup( itr->pGroupname, this );
newGroup->setForcedArrayIndex(mForcedArrayIndex);
newGroup->registerObject();
if( !newGroup->getNumFields() )
@ -640,6 +644,10 @@ void GuiInspector::refresh()
addObject(newGroup);
}
}
else if(group)
{
group->setForcedArrayIndex(mForcedArrayIndex);
}
}
}
}
@ -815,6 +823,12 @@ void GuiInspector::removeInspectorGroup(StringTableEntry groupName)
removeObject(group);
}
void GuiInspector::setForcedArrayIndex(S32 arrayIndex)
{
mForcedArrayIndex = arrayIndex;
refresh();
}
//=============================================================================
// Console Methods.
//=============================================================================
@ -979,3 +993,10 @@ DefineEngineMethod(GuiInspector, removeGroup, void, (const char* groupName), ,
{
object->removeInspectorGroup(StringTable->insert(groupName));
}
DefineEngineMethod(GuiInspector, setForcedArrayIndex, void, (S32 arrayIndex), (-1),
"Sets the ForcedArrayIndex for the inspector. Used to force presentation of arrayed fields to only show a specific field index inside groups."
"@param arrayIndex The specific field index for arrayed fields to show. Use -1 or blank arg to go back to normal behavior.")
{
object->setForcedArrayIndex(arrayIndex);
}