mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-06-03 11:36:36 +00:00
remove requirement of element count in array
If we define an array field have every other field inside that array declared inherit its element count. Can be override with a .elements(N) if N is > 1.
This commit is contained in:
parent
33220cc988
commit
6829ac2dd0
2 changed files with 36 additions and 27 deletions
|
|
@ -356,12 +356,14 @@ static char* suppressSpaces(const char* in_pname)
|
|||
return replacebuf;
|
||||
}
|
||||
|
||||
static U32 sg_currentArrayElementCount = 1;
|
||||
|
||||
void ConsoleObject::registerField(const char* name, U32 type, dsize_t offset, const FieldDescriptor& desc)
|
||||
{
|
||||
AbstractClassRep::Field f;
|
||||
// Remove spaces.
|
||||
|
||||
|
||||
const bool isCollection = desc.isArrayBegin || desc.isArrayEnd || desc.isGroupBegin || desc.isGroupEnd;
|
||||
|
||||
if (isCollection)
|
||||
{
|
||||
char* pFieldNameBuf = suppressSpaces(name);
|
||||
|
|
@ -395,6 +397,7 @@ void ConsoleObject::registerField(const char* name, U32 type, dsize_t offset, co
|
|||
|
||||
f.pFieldname = StringTable->insert(pFieldNameBuf);
|
||||
f.pGroupname = StringTable->insert(name);
|
||||
f.elementCount = desc.elementCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -405,16 +408,24 @@ void ConsoleObject::registerField(const char* name, U32 type, dsize_t offset, co
|
|||
f.table = conType->getEnumTable();
|
||||
}
|
||||
|
||||
if (desc.isArrayBegin)
|
||||
sg_currentArrayElementCount = desc.elementCount;
|
||||
|
||||
if (desc.isArrayEnd)
|
||||
sg_currentArrayElementCount = 1;
|
||||
|
||||
if (desc.docs)
|
||||
f.pFieldDocs = desc.docs;
|
||||
|
||||
if (!isCollection)
|
||||
f.elementCount = desc.elementCount > 1 ? desc.elementCount : sg_currentArrayElementCount;
|
||||
|
||||
f.offset = desc._offset;
|
||||
f.validator = desc.validator;
|
||||
f.setDataFn = desc.setFn;
|
||||
f.getDataFn = desc.getFn;
|
||||
f.writeDataFn = desc.writeFn;
|
||||
f.visibilityFn = desc.visibilityFn;
|
||||
f.elementCount = desc.elementCount;
|
||||
f.groupExpand = desc.isExpanded;
|
||||
f.networkMask = desc.networkMask;
|
||||
f.flag = desc.flags;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue