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

Method constructField

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

Source from the content-addressed store, hash-verified

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

Callers 1

onInspectMethod · 0.45

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