MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / constructField

Method constructField

Engine/source/gui/editor/inspector/group.cpp:134–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132//-----------------------------------------------------------------------------
133
134GuiInspectorField* GuiInspectorGroup::constructField( S32 fieldType )
135{
136 // See if we can construct a field of this type
137 ConsoleBaseType *cbt = ConsoleBaseType::getType(fieldType);
138 if( !cbt )
139 return NULL;
140
141 // Alright, is it a datablock?
142 if(cbt->isDatablock())
143 {
144 // Default to GameBaseData
145 StringTableEntry typeClassName = cbt->getTypeClassName();
146
147 if( mParent->getNumInspectObjects() == 1 && !dStricmp(typeClassName, "GameBaseData") )
148 {
149 // Try and setup the classname based on the object type
150 char className[256];
151 dSprintf(className,256,"%sData", mParent->getInspectObject( 0 )->getClassName());
152 // Walk the ACR list and find a matching class if any.
153 AbstractClassRep *walk = AbstractClassRep::getClassList();
154 while(walk)
155 {
156 if(!dStricmp(walk->getClassName(), className))
157 break;
158
159 walk = walk->getNextClass();
160 }
161
162 // We found a valid class
163 if (walk)
164 typeClassName = walk->getClassName();
165
166 }
167
168
169 GuiInspectorDatablockField *dbFieldClass = new GuiInspectorDatablockField( typeClassName );
170
171 // return our new datablock field with correct datablock type enumeration info
172 return dbFieldClass;
173}
174
175 // Nope, not a datablock. So maybe it has a valid inspector field override we can use?
176 if(!cbt->getInspectorFieldType())
177 // Nothing, so bail.
178 return NULL;
179
180 // Otherwise try to make it!
181 ConsoleObject *co = create(cbt->getInspectorFieldType());
182 GuiInspectorField *gif = dynamic_cast<GuiInspectorField*>(co);
183
184 if(!gif)
185 {
186 // Wasn't appropriate type, bail.
187 delete co;
188 return NULL;
189 }
190
191 return gif;

Callers

nothing calls this directly

Calls 8

getTypeFunction · 0.85
dStricmpFunction · 0.85
dSprintfFunction · 0.85
getNextClassMethod · 0.80
getInspectorFieldTypeMethod · 0.80
isDatablockMethod · 0.45
getTypeClassNameMethod · 0.45
getClassNameMethod · 0.45

Tested by

no test coverage detected