ResourceCache.pkg 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. $#include "Resource/ResourceCache.h"
  2. class ResourceCache
  3. {
  4. void ReleaseAllResources(bool force = false);
  5. bool ReloadResource(Resource* resource);
  6. void ReloadResourceWithDependencies(const String fileName);
  7. void SetMemoryBudget(StringHash type, unsigned budget);
  8. void SetMemoryBudget(const String type, unsigned budget);
  9. void SetAutoReloadResources(bool enable);
  10. void SetReturnFailedResources(bool enable);
  11. void SetSearchPackagesFirst(bool value);
  12. void SetFinishBackgroundResourcesMs(int ms);
  13. tolua_outside File* ResourceCacheGetFile @ GetFile(const String name);
  14. Resource* GetResource(const String type, const String name, bool sendEventOnFailure = true);
  15. tolua_outside bool ResourceCacheBackgroundLoadResource @ BackgroundLoadResource(const String type, const String name, bool sendEventOnFailure = true);
  16. unsigned GetNumBackgroundLoadResources() const;
  17. const Vector<String>& GetResourceDirs() const;
  18. bool Exists(const String name) const;
  19. unsigned GetMemoryBudget(StringHash type) const;
  20. unsigned GetMemoryUse(StringHash type) const;
  21. unsigned GetTotalMemoryUse() const;
  22. String GetResourceFileName(const String name) const;
  23. bool GetAutoReloadResources() const;
  24. bool GetReturnFailedResources() const;
  25. bool GetSearchPackagesFirst() const;
  26. int GetFinishBackgroundResourcesMs() const;
  27. String GetPreferredResourceDir(const String path) const;
  28. String SanitateResourceName(const String name) const;
  29. String SanitateResourceDirName(const String name) const;
  30. tolua_readonly tolua_property__get_set unsigned totalMemoryUse;
  31. tolua_property__get_set bool autoReloadResources;
  32. tolua_property__get_set bool returnFailedResources;
  33. tolua_property__get_set bool searchPackagesFirst;
  34. tolua_readonly tolua_property__get_set unsigned numBackgroundLoadResources;
  35. tolua_readonly tolua_property__get_set Vector<String>& resourceDirs;
  36. tolua_property__get_set int finishBackgroundResourcesMs;
  37. };
  38. ResourceCache* GetCache();
  39. tolua_readonly tolua_property__get_set ResourceCache* cache;
  40. ${
  41. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_GetCache00
  42. static int tolua_ResourceLuaAPI_GetCache00(lua_State* tolua_S)
  43. {
  44. return ToluaGetSubsystem<ResourceCache>(tolua_S);
  45. }
  46. #define TOLUA_DISABLE_tolua_get_cache_ptr
  47. #define tolua_get_cache_ptr tolua_ResourceLuaAPI_GetCache00
  48. static File* ResourceCacheGetFile(ResourceCache* cache, const String& fileName)
  49. {
  50. SharedPtr<File> filePtr = cache->GetFile(fileName);
  51. if (!filePtr)
  52. return 0;
  53. File* file = filePtr.Get();
  54. filePtr.Detach();
  55. return file;
  56. }
  57. static bool ResourceCacheBackgroundLoadResource(ResourceCache* cache, StringHash type, const String& fileName, bool sendEventOnFailure)
  58. {
  59. return cache->BackgroundLoadResource(type, fileName, sendEventOnFailure);
  60. }
  61. $}