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