Adds a new FieldDescriptor struct

Use the field descriptor struct to add fields instead of the overloads
Adds a visibility function to control whether a field is visible in the inspector

EG:
ADD_FIELD("soundFile", TypeAssetLooseFilePath, Offset(mSoundFile, SoundAsset))
            .doc("Path to the sound file.")
            .elements(SFXPlayList::SFXPlaylistSettings::NUM_SLOTS)
            .onSet(&_setSoundFile);

the grammar can change to make these easier to work with, review changes carefully
This commit is contained in:
marauder2k7 2026-05-03 15:50:44 +01:00
parent 92e32aa40a
commit e635344fba
8 changed files with 343 additions and 16 deletions

View file

@ -835,6 +835,8 @@ void GuiInspectorField::updateValue()
}
else
setValue( getData() );
mInspector->updateVisibility();
}
//-----------------------------------------------------------------------------

View file

@ -164,6 +164,7 @@ class GuiInspectorField : public GuiControl
///
StringTableEntry getArrayIndex() const { return mFieldArrayIndex; }
AbstractClassRep::Field* getField() const { return mField; }
/// Called from within setData to allow child classes
/// to perform their own verification.

View file

@ -79,6 +79,7 @@ GuiInspectorGroup::GuiInspectorGroup( const String& groupName,
mChildren.clear();
mMargin.set(0,0,4,0);
VECTOR_SET_ASSOCIATION(mArrayElements);
}
//-----------------------------------------------------------------------------
@ -229,6 +230,7 @@ void GuiInspectorGroup::clearFields()
// that we keep for our own convenience.
mArrayCtrls.clear();
mChildren.clear();
mArrayElements.clear();
}
//-----------------------------------------------------------------------------
@ -336,7 +338,7 @@ bool GuiInspectorGroup::inspectGroup()
GuiControlProfile* elementRolloutProfile = dynamic_cast<GuiControlProfile*>(Sim::findObject("GuiInspectorRolloutProfile0"));
char buf[256];
dSprintf(buf, 256, " [%i]", i);
dSprintf(buf, 256, " [%i/%i]", i, field->elementCount);
elementRollout->setControlProfile(elementRolloutProfile);
elementRollout->setCaption(buf);
@ -349,6 +351,8 @@ bool GuiInspectorGroup::inspectGroup()
elementRollout->instantCollapse();
arrayStack->addObject(elementRollout);
mArrayElements.push_back({ elementRollout, (S32)i, field });
}
pArrayRollout = arrayRollout;

View file

@ -44,6 +44,13 @@ private:
typedef GuiRolloutCtrl Parent;
public:
// Members
struct ArrayElementEntry
{
GuiRolloutCtrl* rollout;
S32 elementIndex;
const AbstractClassRep::Field* arrayField; // the StartArrayFieldType field
};
Vector<ArrayElementEntry> mArrayElements;
SimObjectPtr<GuiInspector> mParent;
Vector<GuiInspectorField*> mChildren;
GuiStackControl* mStack;