| 1638 | //target names/counts without polluting simObject. |
| 1639 | #ifdef TORQUE_TOOLS |
| 1640 | void TSStatic::onInspect(GuiInspector* inspector) |
| 1641 | { |
| 1642 | //if (mShapeAsset == nullptr) |
| 1643 | return; |
| 1644 | |
| 1645 | //Put the GameObject group before everything that'd be gameobject-effecting, for orginazational purposes |
| 1646 | GuiInspectorGroup* materialGroup = inspector->findExistentGroup(StringTable->insert("Materials")); |
| 1647 | if (!materialGroup) |
| 1648 | return; |
| 1649 | |
| 1650 | GuiControl* stack = dynamic_cast<GuiControl*>(materialGroup->findObjectByInternalName(StringTable->insert("Stack"))); |
| 1651 | |
| 1652 | //Do this on both the server and client |
| 1653 | TSMaterialList* matList = mShapeInstance->getMaterialList(); |
| 1654 | Vector<String> matListNames = matList->getMaterialNameList(); |
| 1655 | S32 materialCount = matListNames.size(); |
| 1656 | |
| 1657 | if (isServerObject()) |
| 1658 | { |
| 1659 | //next, get a listing of our materials in the shape, and build our field list for them |
| 1660 | char matFieldName[128]; |
| 1661 | |
| 1662 | for (U32 i = 0; i < materialCount; i++) |
| 1663 | { |
| 1664 | StringTableEntry materialname = StringTable->insert(mShapeInstance->getMaterialList()->getMaterialName(i).c_str()); |
| 1665 | |
| 1666 | AssetPtr<MaterialAsset> matAsset; |
| 1667 | if(MaterialAsset::getAssetByMaterialName(materialname, &matAsset) == MaterialAsset::Ok) |
| 1668 | { |
| 1669 | dSprintf(matFieldName, 128, "MaterialSlot%d", i); |
| 1670 | |
| 1671 | GuiInspectorField* fieldGui = materialGroup->constructField(TypeMaterialAssetPtr); |
| 1672 | fieldGui->init(inspector, materialGroup); |
| 1673 | |
| 1674 | fieldGui->setSpecialEditField(true); |
| 1675 | fieldGui->setTargetObject(this); |
| 1676 | |
| 1677 | StringTableEntry fldnm = StringTable->insert(matFieldName); |
| 1678 | |
| 1679 | fieldGui->setSpecialEditVariableName(fldnm); |
| 1680 | |
| 1681 | fieldGui->setInspectorField(NULL, fldnm); |
| 1682 | fieldGui->setDocs(""); |
| 1683 | |
| 1684 | if (fieldGui->registerObject()) |
| 1685 | { |
| 1686 | StringTableEntry fieldValue = matAsset->getAssetId(); |
| 1687 | |
| 1688 | GuiInspectorTypeMaterialAssetPtr* matFieldPtr = dynamic_cast<GuiInspectorTypeMaterialAssetPtr*>(fieldGui); |
| 1689 | matFieldPtr->setPreviewImage(fieldValue); |
| 1690 | |
| 1691 | //Check if we'd already actually changed it, and display the modified value |
| 1692 | for (U32 c = 0; c < mChangingMaterials.size(); c++) |
| 1693 | { |
| 1694 | if (mChangingMaterials[c].slot == i) |
| 1695 | { |
| 1696 | fieldValue = StringTable->insert(mChangingMaterials[i].assetId.c_str()); |
| 1697 | break; |