ResourceCache.pkg 2.1 KB

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