ResourceCache.pkg 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 long long budget);
  8. void SetMemoryBudget(const String type, unsigned long long 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. Resource* GetExistingResource(const String type, const String name);
  16. tolua_outside bool ResourceCacheBackgroundLoadResource @ BackgroundLoadResource(const String type, const String name, bool sendEventOnFailure = true);
  17. unsigned GetNumBackgroundLoadResources() const;
  18. const Vector<String>& GetResourceDirs() const;
  19. bool Exists(const String name) const;
  20. unsigned long long GetMemoryBudget(StringHash type) const;
  21. unsigned long long GetMemoryUse(StringHash type) const;
  22. unsigned long long GetTotalMemoryUse() const;
  23. String GetResourceFileName(const String name) const;
  24. bool GetAutoReloadResources() const;
  25. bool GetReturnFailedResources() const;
  26. bool GetSearchPackagesFirst() const;
  27. int GetFinishBackgroundResourcesMs() const;
  28. String GetPreferredResourceDir(const String path) const;
  29. String SanitateResourceName(const String name) const;
  30. String SanitateResourceDirName(const String name) const;
  31. tolua_readonly tolua_property__get_set unsigned long long totalMemoryUse;
  32. tolua_property__get_set bool autoReloadResources;
  33. tolua_property__get_set bool returnFailedResources;
  34. tolua_property__get_set bool searchPackagesFirst;
  35. tolua_readonly tolua_property__get_set unsigned numBackgroundLoadResources;
  36. tolua_readonly tolua_property__get_set Vector<String>& resourceDirs;
  37. tolua_property__get_set int finishBackgroundResourcesMs;
  38. };
  39. ResourceCache* GetCache();
  40. tolua_readonly tolua_property__get_set ResourceCache* cache;
  41. ${
  42. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_GetCache00
  43. static int tolua_ResourceLuaAPI_GetCache00(lua_State* tolua_S)
  44. {
  45. return ToluaGetSubsystem<ResourceCache>(tolua_S);
  46. }
  47. #define TOLUA_DISABLE_tolua_get_cache_ptr
  48. #define tolua_get_cache_ptr tolua_ResourceLuaAPI_GetCache00
  49. static File* ResourceCacheGetFile(ResourceCache* cache, const String& fileName)
  50. {
  51. return cache->GetFile(fileName).Detach();
  52. }
  53. static bool ResourceCacheBackgroundLoadResource(ResourceCache* cache, StringHash type, const String& fileName, bool sendEventOnFailure)
  54. {
  55. return cache->BackgroundLoadResource(type, fileName, sendEventOnFailure);
  56. }
  57. $}