resourceManager_ScriptBinding.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. /*! @defgroup ResourceManagerFunctions Resource Manager
  23. @ingroup TorqueScriptFunctions
  24. @{
  25. */
  26. #ifdef TORQUE_DEBUG
  27. /*! Use the dumpLoadedResources function to dump a listing of the currently in-use resources to the console. This will include such things as sound files, font files, etc.
  28. For this to work, the engine must have been compiled with TORQUE_DEBUG defined.
  29. @return No return value.
  30. @sa purgeResources
  31. */
  32. ConsoleFunctionWithDocs(dumpResources, ConsoleVoid, 2, 2, (onlyLoaded?))
  33. {
  34. const bool onlyLoaded = argc == 2 ? dAtob(argv[1]) : true;
  35. ResourceManager->dumpResources(onlyLoaded);
  36. }
  37. #endif
  38. /*! Add a path to the resource manager
  39. */
  40. ConsoleFunctionWithDocs(addResPath, ConsoleVoid, 2, 3, (path, [ignoreZips=false]?))
  41. {
  42. if( argc > 2 )
  43. ResourceManager->addPath(argv[1], dAtob(argv[2]));
  44. else
  45. ResourceManager->addPath(argv[1]);
  46. }
  47. /*! Remove a path from the resource manager. Path is an expression as in findFirstFile()
  48. */
  49. ConsoleFunctionWithDocs(removeResPath, ConsoleVoid, 2, 2, (pathExpression))
  50. {
  51. ResourceManager->removePath(argv[1]);
  52. }
  53. // Mod paths aren't used in tools applications.
  54. // See : addResPath/removeResPath console functions
  55. /*! Use the setModPaths function to set the current mod path to the value specified in path.
  56. @param path A string containing a semi-colon (;) separated list of game and mod paths.
  57. @return No return value.
  58. @sa getModPaths
  59. */
  60. ConsoleFunctionWithDocs( setModPaths, ConsoleVoid, 2, 2, ( path ))
  61. {
  62. char buf[512];
  63. dStrncpy(buf, argv[1], sizeof(buf) - 1);
  64. buf[511] = '\0';
  65. Vector<char *> paths;
  66. char* temp = dStrtok( buf, ";" );
  67. while ( temp )
  68. {
  69. if ( temp[0] )
  70. paths.push_back(temp);
  71. temp = dStrtok( NULL, ";" );
  72. }
  73. ResourceManager->setModPaths( paths.size(), (const char**) paths.address() );
  74. }
  75. /*! Use the getModPaths function to get the current mod path information.
  76. @return Returns a string equivalent to the complete current mod path, that is all pads that are visible to the file manager.
  77. @sa setModPaths
  78. */
  79. ConsoleFunctionWithDocs( getModPaths, ConsoleString, 1, 1, ())
  80. {
  81. return( ResourceManager->getModPaths() );
  82. }
  83. /*! Use the purgeResources function to purge all game resources.
  84. @return No return value.
  85. @sa clearTextureHolds, dumpResourceStats, dumpTextureStats, flushTextureCache
  86. */
  87. ConsoleFunctionWithDocs( purgeResources, ConsoleVoid, 1, 1, ())
  88. {
  89. ResourceManager->purge();
  90. }
  91. /*!
  92. @return Returns true if using Virtual File System
  93. */
  94. ConsoleFunctionWithDocs(isUsingVFS, ConsoleBool, 1, 1, ())
  95. {
  96. return ResourceManager->isUsingVFS();
  97. }
  98. /*! @} */ // group ResourceManagerFunctions