| 133 | //----------------------------------------------------------------------------- |
| 134 | |
| 135 | GuiInspectorField* 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; |
no test coverage detected