assetImporter_ScriptBinding.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #pragma once
  2. #include "console/engineAPI.h"
  3. #include "assetImporter.h"
  4. //Console Functions
  5. DefineEngineMethod(AssetImportConfig, loadImportConfig, void, (Settings* configSettings, String configName), (nullAsType<Settings*>(), ""),
  6. "Loads the provided import config to the importer.\n"
  7. "@param configSettings A Settings object containing the import configs.\n"
  8. "@param configName The specific name of the config to be used.")
  9. {
  10. return object->loadImportConfig(configSettings, configName);
  11. }
  12. DefineEngineMethod(AssetImporter, setTargetPath, void, (String path), (""),
  13. "Sets the target path the importing assets will be put into.\n"
  14. "@param A string of the target path.")
  15. {
  16. return object->setTargetPath(path);
  17. }
  18. DefineEngineMethod(AssetImporter, resetImportSession, void, (bool forceResetSession), (false),
  19. "Resets the importer's import session. All existing import items, logs, etc will be cleared.")
  20. {
  21. return object->resetImportSession(forceResetSession);
  22. }
  23. DefineEngineMethod(AssetImporter, dumpActivityLog, void, (), ,
  24. "Dumps the import activity log. If the importer is set to, it will save to file, otherwise dump to console.")
  25. {
  26. return object->dumpActivityLog();
  27. }
  28. DefineEngineMethod(AssetImporter, getActivityLogLineCount, S32, (),,
  29. "Gets the number of lines in the import activity log.\n"
  30. "@return The number of lines in the import activity log.")
  31. {
  32. return object->getActivityLogLineCount();
  33. }
  34. DefineEngineMethod(AssetImporter, getActivityLogLine, String, (S32 index), (0),
  35. "Gets a specific line in the import activity log.\n"
  36. "@param index The index of the line to be returned.\n"
  37. "@return The string of the requested line of the activity log")
  38. {
  39. return object->getActivityLogLine(index);
  40. }
  41. DefineEngineMethod(AssetImporter, autoImportFile, String, (String path, String typeHint), ("", ""),
  42. "Run the full import process on a specific file.\n"
  43. "@return If import is successful, the assetId of the new asset. If it failed, an empty string.")
  44. {
  45. return object->autoImportFile(path, typeHint);
  46. }
  47. DefineEngineMethod(AssetImporter, addImportingFile, AssetImportObject*, (String path), (""),
  48. "Adds a filepath to the current importing session.\n"
  49. "@param path The path to the file to be imported.\n"
  50. "@return The AssetImportObject from the import session.")
  51. {
  52. return object->addImportingFile(path);
  53. }
  54. DefineEngineMethod(AssetImporter, addImportingAssetItem, void, (AssetImportObject* assetItem, AssetImportObject* parentItem), (nullAsType< AssetImportObject*>(), nullAsType< AssetImportObject*>()),
  55. "Adds an existing AssetImportObject to the current improting session.\n"
  56. "@param assetItem The AssetImportObject to be added to the import session.\n"
  57. "@param parentItem An AssetImportObject that to act as the parent of the item being added.")
  58. {
  59. return object->addImportingAssetItem(assetItem, parentItem);
  60. }
  61. DefineEngineMethod(AssetImporter, processImportingAssets, void, (), ,
  62. "Processes the importing assets.")
  63. {
  64. return object->processImportAssets();
  65. }
  66. DefineEngineMethod(AssetImporter, hasImportIssues, bool, (), ,
  67. "Validates the status of the importing items.\n"
  68. "@return False if there are no issues, true if there are importing issues")
  69. {
  70. return object->validateAssets();
  71. }
  72. DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
  73. "Runs the issue resolver to attempt to correct any simple issues, such as utilizing the config's settings to resolve collisions.")
  74. {
  75. object->resolveAssetItemIssues(assetItem);
  76. }
  77. DefineEngineMethod(AssetImporter, importAssets, void, (),,
  78. "Runs the actual import action on the items.")
  79. {
  80. object->importAssets();
  81. object->acquireAssets();
  82. }
  83. DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,
  84. "Gets the number of importing asset items.\n"
  85. "@return The number of importing asset items")
  86. {
  87. return object->getAssetItemCount();
  88. }
  89. DefineEngineMethod(AssetImporter, getAssetItem, AssetImportObject*, (S32 index), (0),
  90. "Gets a specific import asset item.\n"
  91. "@param index The index of the AssetImportObject to be returned.\n"
  92. "@return AssetImportObject")
  93. {
  94. return object->getAssetItem(index);
  95. }
  96. DefineEngineMethod(AssetImporter, getAssetItemChildCount, S32, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
  97. "Gets number of child items for a given importing asset item.\n"
  98. "@param assetItem The AssetImportObject to get the number of children of.\n"
  99. "@return The number of child items")
  100. {
  101. if (assetItem == nullptr)
  102. return 0;
  103. return object->getAssetItemChildCount(assetItem);
  104. }
  105. DefineEngineMethod(AssetImporter, getAssetItemChild, AssetImportObject*, (AssetImportObject* assetItem, S32 index), (nullAsType< AssetImportObject*>(), 0),
  106. "Gets a specific child item of a given importing asset item.\n"
  107. "@param assetItem The AssetImportObject to get the child from.\n"
  108. "@param index The index of the child to get.\n"
  109. "@return The child AssetImportObect")
  110. {
  111. if (assetItem == nullptr)
  112. return nullptr;
  113. return object->getAssetItemChild(assetItem, index);
  114. }
  115. DefineEngineMethod(AssetImporter, deleteImportingAsset, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()),
  116. "Deletes an importing AssetImportObject from the import session.\n"
  117. "@param assetItem The AssetImportObject to delete.")
  118. {
  119. return object->deleteImportingAsset(assetItem);
  120. }
  121. DefineEngineMethod(AssetImporter, setImportConfig, void, (AssetImportConfig* importConfig), (nullAsType< AssetImportConfig*>()),
  122. "Sets the import config to be used via a AssetImportConfig object.\n"
  123. "@param importConfig The AssetImportConfig object to use.")
  124. {
  125. return object->setImportConfig(importConfig);
  126. }