ResourceCache.pkg 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. $#include "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. bool Exists(const String name) const;
  18. unsigned GetMemoryBudget(StringHash type) const;
  19. unsigned GetMemoryUse(StringHash type) const;
  20. unsigned GetTotalMemoryUse() const;
  21. String GetResourceFileName(const String name) const;
  22. bool GetAutoReloadResources() const;
  23. bool GetReturnFailedResources() const;
  24. bool GetSearchPackagesFirst() const;
  25. int GetFinishBackgroundResourcesMs() const;
  26. String GetPreferredResourceDir(const String path) const;
  27. String SanitateResourceName(const String name) const;
  28. String SanitateResourceDirName(const String name) const;
  29. tolua_readonly tolua_property__get_set unsigned totalMemoryUse;
  30. tolua_property__get_set bool autoReloadResources;
  31. tolua_property__get_set bool returnFailedResources;
  32. tolua_property__get_set bool searchPackagesFirst;
  33. tolua_readonly tolua_property__get_set unsigned numBackgroundLoadResources;
  34. tolua_property__get_set int finishBackgroundResourcesMs;
  35. };
  36. ResourceCache* GetCache();
  37. tolua_readonly tolua_property__get_set ResourceCache* cache;
  38. ${
  39. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_GetCache00
  40. static int tolua_ResourceLuaAPI_GetCache00(lua_State* tolua_S)
  41. {
  42. return ToluaGetSubsystem<ResourceCache>(tolua_S);
  43. }
  44. #define TOLUA_DISABLE_tolua_get_cache_ptr
  45. #define tolua_get_cache_ptr tolua_ResourceLuaAPI_GetCache00
  46. static File* ResourceCacheGetFile(ResourceCache* cache, const String& fileName)
  47. {
  48. SharedPtr<File> filePtr = cache->GetFile(fileName);
  49. if (!filePtr)
  50. return 0;
  51. File* file = filePtr.Get();
  52. filePtr.Detach();
  53. return file;
  54. }
  55. static bool ResourceCacheBackgroundLoadResource(ResourceCache* cache, StringHash type, const String& fileName, bool sendEventOnFailure)
  56. {
  57. return cache->BackgroundLoadResource(type, fileName, sendEventOnFailure);
  58. }
  59. $}