ShapeAsset.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SHAPE_ASSET_H_
  23. #include "ShapeAsset.h"
  24. #endif
  25. #ifndef _ASSET_MANAGER_H_
  26. #include "assets/assetManager.h"
  27. #endif
  28. #ifndef _CONSOLETYPES_H_
  29. #include "console/consoleTypes.h"
  30. #endif
  31. #ifndef _TAML_
  32. #include "persistence/taml/taml.h"
  33. #endif
  34. #ifndef _ASSET_PTR_H_
  35. #include "assets/assetPtr.h"
  36. #endif
  37. #include "core/resourceManager.h"
  38. // Debug Profiling.
  39. #include "platform/profiler.h"
  40. #include "T3D/assets/assetImporter.h"
  41. #ifdef TORQUE_TOOLS
  42. #include "ts/tsLastDetail.h"
  43. #endif
  44. StringTableEntry ShapeAsset::smNoShapeAssetFallback = NULL;
  45. //-----------------------------------------------------------------------------
  46. IMPLEMENT_CONOBJECT(ShapeAsset);
  47. ConsoleType(assetIdString, TypeShapeAssetPtr, String, ASSET_ID_FIELD_PREFIX)
  48. ConsoleGetType(TypeShapeAssetPtr)
  49. {
  50. // Fetch asset Id.
  51. //return *((StringTableEntry*)dptr);
  52. return (*((AssetPtr<ShapeAsset>*)dptr)).getAssetId();
  53. }
  54. ConsoleSetType(TypeShapeAssetPtr)
  55. {
  56. // Was a single argument specified?
  57. if (argc == 1)
  58. {
  59. // Yes, so fetch field value.
  60. const char* pFieldValue = argv[0];
  61. // Fetch asset Id.
  62. StringTableEntry* assetId = (StringTableEntry*)(dptr);
  63. // Update asset value.
  64. *assetId = StringTable->insert(pFieldValue);
  65. return;
  66. }
  67. // Warn.
  68. Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
  69. }
  70. //-----------------------------------------------------------------------------
  71. ConsoleType(assetIdString, TypeShapeAssetId, const char*, ASSET_ID_FIELD_PREFIX)
  72. ConsoleGetType(TypeShapeAssetId)
  73. {
  74. // Fetch asset Id.
  75. return *((const char**)(dptr));
  76. }
  77. ConsoleSetType(TypeShapeAssetId)
  78. {
  79. // Was a single argument specified?
  80. if (argc == 1)
  81. {
  82. // Yes, so fetch field value.
  83. *((const char**)dptr) = StringTable->insert(argv[0]);
  84. return;
  85. }
  86. // Warn.
  87. Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
  88. }
  89. //-----------------------------------------------------------------------------
  90. const String ShapeAsset::mErrCodeStrings[] =
  91. {
  92. "TooManyVerts",
  93. "TooManyBones",
  94. "MissingAnimatons",
  95. "UnKnown"
  96. };
  97. //-----------------------------------------------------------------------------
  98. ShapeAsset::ShapeAsset()
  99. {
  100. mFileName = StringTable->EmptyString();
  101. mConstructorFileName = StringTable->EmptyString();
  102. mFilePath = StringTable->EmptyString();
  103. mConstructorFilePath = StringTable->EmptyString();
  104. mLoadedState = AssetErrCode::NotLoaded;
  105. }
  106. //-----------------------------------------------------------------------------
  107. ShapeAsset::~ShapeAsset()
  108. {
  109. }
  110. //-----------------------------------------------------------------------------
  111. void ShapeAsset::consoleInit()
  112. {
  113. Parent::consoleInit();
  114. Con::addVariable("$Core::NoShapeAssetFallback", TypeString, &smNoShapeAssetFallback,
  115. "The assetId of the shape to display when the requested shape asset is missing.\n"
  116. "@ingroup GFX\n");
  117. smNoShapeAssetFallback = StringTable->insert(Con::getVariable("$Core::NoShapeAssetFallback"));
  118. }
  119. //-----------------------------------------------------------------------------
  120. void ShapeAsset::initPersistFields()
  121. {
  122. // Call parent.
  123. Parent::initPersistFields();
  124. addProtectedField("fileName", TypeAssetLooseFilePath, Offset(mFileName, ShapeAsset),
  125. &setShapeFile, &getShapeFile, "Path to the shape file we want to render");
  126. addProtectedField("constuctorFileName", TypeAssetLooseFilePath, Offset(mConstructorFileName, ShapeAsset),
  127. &setShapeConstructorFile, &getShapeConstructorFile, "Path to the shape file we want to render");
  128. }
  129. void ShapeAsset::setDataField(StringTableEntry slotName, StringTableEntry array, StringTableEntry value)
  130. {
  131. Parent::setDataField(slotName, array, value);
  132. //Now, if it's a material slot of some fashion, set it up
  133. StringTableEntry matSlotName = StringTable->insert("materialAsset");
  134. if (String(slotName).startsWith(matSlotName))
  135. {
  136. StringTableEntry matId = StringTable->insert(value);
  137. mMaterialAssetIds.push_back(matId);
  138. }
  139. }
  140. void ShapeAsset::initializeAsset()
  141. {
  142. // Call parent.
  143. Parent::initializeAsset();
  144. if (mFileName == StringTable->EmptyString())
  145. return;
  146. ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
  147. //Ensure our path is expando'd if it isn't already
  148. mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
  149. mConstructorFilePath = getOwned() ? expandAssetFilePath(mConstructorFilePath) : mConstructorFilePath;
  150. loadShape();
  151. }
  152. void ShapeAsset::setShapeFile(const char* pShapeFile)
  153. {
  154. // Sanity!
  155. AssertFatal(pShapeFile != NULL, "Cannot use a NULL shape file.");
  156. // Fetch image file.
  157. pShapeFile = StringTable->insert(pShapeFile, true);
  158. // Ignore no change,
  159. if (pShapeFile == mFileName)
  160. return;
  161. mFileName = getOwned() ? expandAssetFilePath(pShapeFile) : pShapeFile;
  162. // Refresh the asset.
  163. refreshAsset();
  164. }
  165. void ShapeAsset::setShapeConstructorFile(const char* pShapeConstructorFile)
  166. {
  167. // Sanity!
  168. AssertFatal(pShapeConstructorFile != NULL, "Cannot use a NULL shape constructor file.");
  169. // Fetch image file.
  170. pShapeConstructorFile = StringTable->insert(pShapeConstructorFile, true);
  171. // Ignore no change,
  172. if (pShapeConstructorFile == mConstructorFileName)
  173. return;
  174. mConstructorFileName = getOwned() ? expandAssetFilePath(pShapeConstructorFile) : pShapeConstructorFile;
  175. // Refresh the asset.
  176. refreshAsset();
  177. }
  178. void ShapeAsset::_onResourceChanged(const Torque::Path &path)
  179. {
  180. if (path != Torque::Path(mFilePath) )
  181. return;
  182. refreshAsset();
  183. loadShape();
  184. }
  185. bool ShapeAsset::loadShape()
  186. {
  187. mMaterialAssets.clear();
  188. mMaterialAssetIds.clear();
  189. //First, load any material, animation, etc assets we may be referencing in our asset
  190. // Find any asset dependencies.
  191. AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
  192. // Does the asset have any dependencies?
  193. if (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end())
  194. {
  195. // Iterate all dependencies.
  196. while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
  197. {
  198. StringTableEntry assetType = mpOwningAssetManager->getAssetType(assetDependenciesItr->value);
  199. if (assetType == StringTable->insert("MaterialAsset"))
  200. {
  201. mMaterialAssetIds.push_front(assetDependenciesItr->value);
  202. //Force the asset to become initialized if it hasn't been already
  203. AssetPtr<MaterialAsset> matAsset = assetDependenciesItr->value;
  204. mMaterialAssets.push_front(matAsset);
  205. }
  206. else if (assetType == StringTable->insert("ShapeAnimationAsset"))
  207. {
  208. mAnimationAssetIds.push_back(assetDependenciesItr->value);
  209. //Force the asset to become initialized if it hasn't been already
  210. AssetPtr<ShapeAnimationAsset> animAsset = assetDependenciesItr->value;
  211. mAnimationAssets.push_back(animAsset);
  212. }
  213. // Next dependency.
  214. assetDependenciesItr++;
  215. }
  216. }
  217. mShape = ResourceManager::get().load(mFilePath);
  218. if (!mShape)
  219. {
  220. Con::errorf("ShapeAsset::loadShape : failed to load shape file %s (%s)!", getAssetName(), mFilePath);
  221. mLoadedState = BadFileReference;
  222. return false; //if it failed to load, bail out
  223. }
  224. bool hasBlends = false;
  225. //Now that we've successfully loaded our shape and have any materials and animations loaded
  226. //we need to set up the animations we're using on our shape
  227. for (S32 i = mAnimationAssets.size()-1; i >= 0; --i)
  228. {
  229. String srcName = mAnimationAssets[i]->getAnimationName();
  230. String srcPath(mAnimationAssets[i]->getAnimationFilename());
  231. //SplitSequencePathAndName(srcPath, srcName);
  232. if (!mShape->addSequence(srcPath, srcName, srcName,
  233. mAnimationAssets[i]->getStartFrame(), mAnimationAssets[i]->getEndFrame(), mAnimationAssets[i]->getPadRotation(), mAnimationAssets[i]->getPadTransforms()))
  234. {
  235. mLoadedState = MissingAnimatons;
  236. return false;
  237. }
  238. if (mAnimationAssets[i]->isBlend())
  239. hasBlends = true;
  240. }
  241. //if any of our animations are blends, set those up now
  242. if (hasBlends)
  243. {
  244. for (U32 i=0; i < mAnimationAssets.size(); ++i)
  245. {
  246. if (mAnimationAssets[i]->isBlend() && mAnimationAssets[i]->getBlendAnimationName() != StringTable->EmptyString())
  247. {
  248. //gotta do a bit of logic here.
  249. //First, we need to make sure the anim asset we depend on for our blend is loaded
  250. AssetPtr<ShapeAnimationAsset> blendAnimAsset = mAnimationAssets[i]->getBlendAnimationName();
  251. if (blendAnimAsset.isNull())
  252. {
  253. Con::errorf("ShapeAsset::initializeAsset - Unable to acquire reference animation asset %s for asset %s to blend!", mAnimationAssets[i]->getBlendAnimationName(), mAnimationAssets[i]->getAssetName());
  254. {
  255. mLoadedState = MissingAnimatons;
  256. return false;
  257. }
  258. }
  259. String refAnimName = blendAnimAsset->getAnimationName();
  260. if (!mShape->setSequenceBlend(mAnimationAssets[i]->getAnimationName(), true, blendAnimAsset->getAnimationName(), mAnimationAssets[i]->getBlendFrame()))
  261. {
  262. Con::errorf("ShapeAnimationAsset::initializeAsset - Unable to set animation clip %s for asset %s to blend!", mAnimationAssets[i]->getAnimationName(), mAnimationAssets[i]->getAssetName());
  263. {
  264. mLoadedState = MissingAnimatons;
  265. return false;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. mChangeSignal.trigger();
  272. mLoadedState = Ok;
  273. return true;
  274. }
  275. //------------------------------------------------------------------------------
  276. //Utility function to 'fill out' bindings and resources with a matching asset if one exists
  277. U32 ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset)
  278. {
  279. AssetQuery query;
  280. S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, fileName);
  281. if (foundAssetcount == 0)
  282. {
  283. //Didn't work, so have us fall back to a placeholder asset
  284. shapeAsset->setAssetId(ShapeAsset::smNoShapeAssetFallback);
  285. if (shapeAsset->isNull())
  286. {
  287. //Well that's bad, loading the fallback failed.
  288. Con::warnf("ShapeAsset::getAssetByFilename - Finding of asset associated with file %s failed with no fallback asset", fileName);
  289. return AssetErrCode::Failed;
  290. }
  291. //handle noshape not being loaded itself
  292. if ((*shapeAsset)->mLoadedState == BadFileReference)
  293. {
  294. Con::warnf("ShapeAsset::getAssetByFilename - Finding of associated with file %s failed, and fallback asset reported error of Bad File Reference.", fileName);
  295. return AssetErrCode::BadFileReference;
  296. }
  297. Con::warnf("ShapeAsset::getAssetByFilename - Finding of associated with file %s failed, utilizing fallback asset", fileName);
  298. (*shapeAsset)->mLoadedState = AssetErrCode::UsingFallback;
  299. return AssetErrCode::UsingFallback;
  300. }
  301. else
  302. {
  303. //acquire and bind the asset, and return it out
  304. shapeAsset->setAssetId(query.mAssetList[0]);
  305. return (*shapeAsset)->mLoadedState;
  306. }
  307. }
  308. StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName)
  309. {
  310. if (fileName == StringTable->EmptyString())
  311. return StringTable->EmptyString();
  312. StringTableEntry shapeAssetId = ShapeAsset::smNoShapeAssetFallback;
  313. AssetQuery query;
  314. S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, fileName);
  315. if (foundAssetcount != 0)
  316. {
  317. //acquire and bind the asset, and return it out
  318. shapeAssetId = query.mAssetList[0];
  319. }
  320. return shapeAssetId;
  321. }
  322. U32 ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset)
  323. {
  324. (*shapeAsset) = assetId;
  325. if (shapeAsset->notNull())
  326. {
  327. return (*shapeAsset)->mLoadedState;
  328. }
  329. else
  330. {
  331. //Didn't work, so have us fall back to a placeholder asset
  332. shapeAsset->setAssetId(ShapeAsset::smNoShapeAssetFallback);
  333. if (shapeAsset->isNull())
  334. {
  335. //Well that's bad, loading the fallback failed.
  336. Con::warnf("ShapeAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId);
  337. return AssetErrCode::Failed;
  338. }
  339. //handle noshape not being loaded itself
  340. if ((*shapeAsset)->mLoadedState == BadFileReference)
  341. {
  342. Con::warnf("ShapeAsset::getAssetById - Finding of asset with id %s failed, and fallback asset reported error of Bad File Reference.", assetId);
  343. return AssetErrCode::BadFileReference;
  344. }
  345. Con::warnf("ShapeAsset::getAssetById - Finding of asset with id %s failed, utilizing fallback asset", assetId);
  346. (*shapeAsset)->mLoadedState = AssetErrCode::UsingFallback;
  347. return AssetErrCode::UsingFallback;
  348. }
  349. }
  350. //------------------------------------------------------------------------------
  351. void ShapeAsset::copyTo(SimObject* object)
  352. {
  353. // Call to parent.
  354. Parent::copyTo(object);
  355. }
  356. void ShapeAsset::onAssetRefresh(void)
  357. {
  358. if (mFileName == StringTable->EmptyString())
  359. return;
  360. // Update.
  361. if(!Platform::isFullPath(mFileName))
  362. mFilePath = getOwned() ? expandAssetFilePath(mFileName) : mFilePath;
  363. loadShape();
  364. }
  365. void ShapeAsset::SplitSequencePathAndName(String& srcPath, String& srcName)
  366. {
  367. srcName = "";
  368. // Determine if there is a sequence name at the end of the source string, and
  369. // if so, split the filename from the sequence name
  370. S32 split = srcPath.find(' ', 0, String::Right);
  371. S32 split2 = srcPath.find('\t', 0, String::Right);
  372. if ((split == String::NPos) || (split2 > split))
  373. split = split2;
  374. if (split != String::NPos)
  375. {
  376. split2 = split + 1;
  377. while ((srcPath[split2] != '\0') && dIsspace(srcPath[split2]))
  378. split2++;
  379. // now 'split' is at the end of the path, and 'split2' is at the start of the sequence name
  380. srcName = srcPath.substr(split2);
  381. srcPath = srcPath.erase(split, srcPath.length() - split);
  382. }
  383. }
  384. ShapeAnimationAsset* ShapeAsset::getAnimation(S32 index)
  385. {
  386. if (index < mAnimationAssets.size())
  387. {
  388. return mAnimationAssets[index];
  389. }
  390. return nullptr;
  391. }
  392. #ifdef TORQUE_TOOLS
  393. const char* ShapeAsset::generateCachedPreviewImage(S32 resolution)
  394. {
  395. if (!mShape)
  396. return "";
  397. TSLastDetail* dt = new TSLastDetail(mShape,
  398. mFilePath,
  399. 1,
  400. 0,
  401. 0,
  402. false,
  403. 0,
  404. resolution);
  405. dt->update();
  406. delete dt;
  407. return mFilePath;
  408. }
  409. #endif
  410. DefineEngineMethod(ShapeAsset, getMaterialCount, S32, (), ,
  411. "Gets the number of materials for this shape asset.\n"
  412. "@return Material count.\n")
  413. {
  414. return object->getMaterialCount();
  415. }
  416. DefineEngineMethod(ShapeAsset, getAnimationCount, S32, (), ,
  417. "Gets the number of animations for this shape asset.\n"
  418. "@return Animation count.\n")
  419. {
  420. return object->getAnimationCount();
  421. }
  422. DefineEngineMethod(ShapeAsset, getAnimation, ShapeAnimationAsset*, (S32 index), (0),
  423. "Gets a particular shape animation asset for this shape.\n"
  424. "@param animation asset index.\n"
  425. "@return Shape Animation Asset.\n")
  426. {
  427. return object->getAnimation(index);
  428. }
  429. DefineEngineMethod(ShapeAsset, getShapeFile, const char*, (), ,
  430. "Gets the shape's file path\n"
  431. "@return The filename of the shape file")
  432. {
  433. return object->getShapeFilePath();
  434. }
  435. DefineEngineMethod(ShapeAsset, getShapeConstructorFilePath, const char*, (), ,
  436. "Gets the shape's constructor file.\n"
  437. "@return The filename of the shape constructor file")
  438. {
  439. return object->getShapeConstructorFilePath();
  440. }
  441. DefineEngineMethod(ShapeAsset, getStatusString, String, (), , "get status string")\
  442. {
  443. return ShapeAsset::getAssetErrstrn(object->getStatus());
  444. }
  445. #ifdef TORQUE_TOOLS
  446. DefineEngineMethod(ShapeAsset, generateCachedPreviewImage, const char*, (S32 resolution), (256), "")
  447. {
  448. return object->generateCachedPreviewImage(resolution);
  449. }
  450. DefineEngineStaticMethod(ShapeAsset, getAssetIdByFilename, const char*, (const char* filePath), (""),
  451. "Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n"
  452. "@return The AssetId of the associated asset, if any.")
  453. {
  454. return ShapeAsset::getAssetIdByFilename(StringTable->insert(filePath));
  455. }
  456. #endif
  457. //-----------------------------------------------------------------------------
  458. // GuiInspectorTypeAssetId
  459. //-----------------------------------------------------------------------------
  460. #ifdef TORQUE_TOOLS
  461. IMPLEMENT_CONOBJECT(GuiInspectorTypeShapeAssetPtr);
  462. ConsoleDocClass(GuiInspectorTypeShapeAssetPtr,
  463. "@brief Inspector field type for Shapes\n\n"
  464. "Editor use only.\n\n"
  465. "@internal"
  466. );
  467. void GuiInspectorTypeShapeAssetPtr::consoleInit()
  468. {
  469. Parent::consoleInit();
  470. ConsoleBaseType::getType(TypeShapeAssetPtr)->setInspectorFieldType("GuiInspectorTypeShapeAssetPtr");
  471. }
  472. GuiControl* GuiInspectorTypeShapeAssetPtr::constructEditControl()
  473. {
  474. // Create base filename edit controls
  475. GuiControl *retCtrl = Parent::constructEditControl();
  476. if (retCtrl == NULL)
  477. return retCtrl;
  478. // Change filespec
  479. char szBuffer[512];
  480. dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ShapeAsset\", \"AssetBrowser.changeAsset\", %s, %s);",
  481. mInspector->getInspectObject()->getIdString(), mCaption);
  482. mBrowseButton->setField("Command", szBuffer);
  483. setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString());
  484. // Create "Open in ShapeEditor" button
  485. mShapeEdButton = new GuiBitmapButtonCtrl();
  486. dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.openShapeAssetId(%d.getText());", retCtrl->getId());
  487. mShapeEdButton->setField("Command", szBuffer);
  488. char bitmapName[512] = "ToolsModule:shape_editor_n_image";
  489. mShapeEdButton->setBitmap(StringTable->insert(bitmapName));
  490. mShapeEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
  491. mShapeEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
  492. mShapeEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
  493. mShapeEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Shape Editor");
  494. mShapeEdButton->registerObject();
  495. addObject(mShapeEdButton);
  496. return retCtrl;
  497. }
  498. bool GuiInspectorTypeShapeAssetPtr::updateRects()
  499. {
  500. S32 dividerPos, dividerMargin;
  501. mInspector->getDivider(dividerPos, dividerMargin);
  502. Point2I fieldExtent = getExtent();
  503. Point2I fieldPos = getPosition();
  504. mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
  505. mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
  506. bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
  507. if (mBrowseButton != NULL)
  508. {
  509. mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
  510. resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
  511. }
  512. if (mShapeEdButton != NULL)
  513. {
  514. RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
  515. resized |= mShapeEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
  516. }
  517. return resized;
  518. }
  519. IMPLEMENT_CONOBJECT(GuiInspectorTypeShapeAssetId);
  520. ConsoleDocClass(GuiInspectorTypeShapeAssetId,
  521. "@brief Inspector field type for Shapes\n\n"
  522. "Editor use only.\n\n"
  523. "@internal"
  524. );
  525. void GuiInspectorTypeShapeAssetId::consoleInit()
  526. {
  527. Parent::consoleInit();
  528. ConsoleBaseType::getType(TypeShapeAssetId)->setInspectorFieldType("GuiInspectorTypeShapeAssetId");
  529. }
  530. #endif