Class l2df.manager.resource
Resource manager.
Info:
- Copyright: Atom-TM 2019
- Author: Kasai
Functions
Manager:init([kwargs]) | Configure ResourceManager. |
Manager:add(resource[, temp=false]) | Saves the resource to the ResourceManager. |
Manager:addById(id, resource[, temp=false]) | Stores the resource in the ResourceManager using an unique identifier. |
Manager:remove(resource) | Removes the specified resource from the ResourceManager. |
Manager:removeById(id) | Removes the specified resource from the ResourceManager by its ID. |
Manager:clearTemp() | Removes all resources marked as temporary from the ResourceManager. |
Manager:getId(resource) | Gets the resource Id from the ResourceManager. |
Manager:get(id) | Returns a resource from the ResourceManager by its ID. |
Manager:load(filepath[, reload=false[, id[, temp=false]]]) | Adds a supported file type to the ResourceManager by loading it from a path. |
Manager:update() | Update event handler. |
Manager:loadAsync(filepath[, callback[, reload=false[, id[, temp=false]]]]) | Add new file to queue for async loading or return already loaded resource's ID. |
Manager:loadListAsync(files) | Async loading of multiple resources. |
Functions
Methods- Manager:init([kwargs])
-
Configure ResourceManager.
Parameters:
- kwargs table Keyword arguments. Not actually used. (optional)
Returns:
- Manager:add(resource[, temp=false])
-
Saves the resource to the ResourceManager.
Parameters:
- resource mixed Resource handler.
- temp boolean Set to true if the specified resource should be marked as temporary. (default false)
Returns:
- number or boolean id
- mixed resource
- Manager:addById(id, resource[, temp=false])
-
Stores the resource in the ResourceManager using an unique identifier.
Parameters:
- id number or string Unique identifier for accessing resource later.
- resource mixed Resource handler.
- temp boolean Set to true if the specified resource should be marked as temporary. (default false)
Returns:
- number, string or boolean id
- mixed resource
- Manager:remove(resource)
-
Removes the specified resource from the ResourceManager.
Parameters:
- resource mixed Resource handler.
Returns:
-
boolean
success
- Manager:removeById(id)
-
Removes the specified resource from the ResourceManager by its ID.
Parameters:
- id number or string Resource's unique identifier.
Returns:
-
boolean
success
- Manager:clearTemp()
- Removes all resources marked as temporary from the ResourceManager.
- Manager:getId(resource)
-
Gets the resource Id from the ResourceManager.
Parameters:
- resource mixed Resource handler.
Returns:
-
number or string
id
- Manager:get(id)
-
Returns a resource from the ResourceManager by its ID.
Parameters:
- id number or string Resource's unique identifier.
Returns:
- mixed resource Resource handler.
- boolean is the resource marked temporary
- Manager:load(filepath[, reload=false[, id[, temp=false]]])
-
Adds a supported file type to the ResourceManager by loading it from a path.
Parameters:
- filepath string Path to the resource file.
- reload boolean Set to true if you want to reload previously loaded resource. (default false)
-
id
number or string
Resource's unique identifier for accessing it later.
Defaults to
filepath
if not setted. (optional) - temp boolean Set to true if the specified resource should be marked as temporary. (default false)
Returns:
- mixed id
- mixed resource
- Manager:update()
- Update event handler. Checks async loaders and triggers callbacks if they are finished.
- Manager:loadAsync(filepath[, callback[, reload=false[, id[, temp=false]]]])
-
Add new file to queue for async loading or return already loaded resource's ID.
Parameters:
- filepath string Path to the resource file.
-
callback
function
Callback function which would be triggered on resource loading finished.
Arguments for that function are:
(id, number|string)
and(resource, mixed)
. (optional) - reload boolean Set to true if you want to reload previously loaded resource. (default false)
-
id
number or string
Resource's unique identifier for accessing it later.
Defaults to
filepath
if not setted. (optional) - temp boolean Set to true if the specified resource should be marked as temporary. (default false)
Returns:
-
number
- Manager:loadListAsync(files)
-
Async loading of multiple resources.
Parameters:
- files table
Returns:
- boolean
- number