ShapeAsset.cpp 21 KB

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