util.resourcemanager
Loads and provides access to resources of various types.
- abstract interface GenericResourceManager;
Common interface for resource managers.
Must be downcasted to get the resource manager itself (due to the template/virtual incompatibility).
- enum LoadStrategy;
Governs how the manager loads its resources.
- struct ResourceID(T);
ID for fast repeated access to a resource.
- this(string path);
Construct a ResourceIndex for a resource with specified virtual filesystem path.
- class ResourceManager(T): GenericResourceManager;
Concrete resource manager managing resources of type T.
- alias ResourceFilter;
Accepts a files range and returns files of this resource type.
- alias ResourceLoader;
Loads a resource from file. Returns true on successm false on failure.
- ResourceLoader resourceLoader_;
Resource loader used.
- this(VFSDir gameDir, ResourceLoader resourceLoader, string fileGlob);
Construct a ResourceLoader using a glob pattern to filter resources.
Parameters:VFSDir gameDir Game data directory to load resources from. ResourceLoader resourceLoader Delegate that loads a resource from file, and returns true on success, false on failure. The passed file might be NULL if the file was not found. This allows the delegate to load the backup resource (or just fail by returning false). string fileGlob Glob pattern determining which files to load. - this(VFSDir gameDir, ResourceLoader resourceLoader, ResourceFilter resourceFilter);
Construct a ResourceLoader using a delegate to filter resources.
Parameters:VFSDir gameDir Game data directory to load resources from. ResourceLoader resourceLoader Delegate that loads a resource from file, and returns true on success, false on failure. The passed file might be NULL if the file was not found. This allows the delegate to load the backup resource (or just fail by returning false). fileGlob Delegate taking a VFSFiles range and returning an array of files to load. - void loadStrategy(const LoadStrategy rhs);
Set the loading strategy to control resource loading.
- T* getResource(string path);
Get a resource which is in file with specified path.
Parameters:Returns:string path Path of the resource file. Pointer to the resource if found, null otherwise.- T* getResource(ref ResourceID!(T) id);
Get a resource with specified resource ID. This is faster when accessing a resource more than once.
Parameters:Returns:ResourceID!(T) id ID to use. Pointer to the resource if found, null otherwise.- void clear();
Delete all loaded resources.
- void preloadAll();
Preload all resources of this type found in the gameDir_.
- bool loaderWrapper(string name, out T result);
Wraps the loader delegate in a function usable by LazyArray.