public class ResourceHandler extends EventHandler implements com.badlogic.gdx.utils.Disposable
| Constructor and Description |
|---|
ResourceHandler()
Creates a resource handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResource(ResourceType resourceType,
java.lang.String pathToFile)
Add a whole folder, which contains resources of the given type.
|
com.badlogic.gdx.graphics.g2d.BitmapFont |
createCachedFont(Resource freeTypeFont,
com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter)
Create or simply get a cached font.
|
com.badlogic.gdx.graphics.g2d.BitmapFont |
createFont(ResourceUnit freeTypeFont,
com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter)
Create a font with the help of font parameters.
|
boolean |
destroyCachedFont(com.badlogic.gdx.graphics.g2d.BitmapFont font)
Destroy a cached font.
|
void |
dispose() |
<T> T |
get(Resource res,
java.lang.Class<T> type)
Generic method to retrieve a previously loaded resource.
|
<T> T |
get(java.lang.String res,
java.lang.Class<T> type)
Generic method to retrieve a previously loaded resource.
|
com.badlogic.gdx.graphics.g2d.BitmapFont |
getFont(ResourceUnit fontUnit)
Returns font mapped to the given resource unit.
|
float |
getProgress() |
com.badlogic.gdx.graphics.g2d.TextureRegion |
getRegion(ResourceUnit region)
Returns region identified by the given resource unit.
|
java.lang.String |
getString(java.lang.String stringId)
Retrieves string mapped to the given id.
|
java.lang.String |
getXML(Resource xmlResource)
Returns loaded xml as string identified by a
Resource. |
java.lang.String |
getXML(java.lang.String xmlName)
Returns a whole xml file as string.
|
java.io.InputStream |
getXMLAsStream(Resource xmlResource) |
void |
increaseCachedFontReferenceCount(com.badlogic.gdx.graphics.g2d.BitmapFont font)
Increase the reference count of the given cached font or does nothing if the given font is not cached.
|
void |
loadLanguage(java.util.Locale lang)
Load available language.
|
void |
loadResource(Resource... resources)
Load given resources.
|
void |
loadResourceExcept(Resource[] resources,
Resource... excludeResources)
Load given resources except the defined exception.
|
void |
loadSkin(Resource res,
Resource atlas,
com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.Object> oMap)
Loads a skin with the specified oMap
|
void |
loadSkin(Resource res,
Resource atlas,
ResourceUnit fontUnit)
Loads akin with the specified fontUnit as attached object.
|
void |
scaleNinePatchesIn(Resource skinRes,
float scale)
Scales all ninpatches of the given skin by
scale. |
boolean |
update()
Makes the resource handler update his internal state.
|
void |
waitFor(Resource resource)
Waits for the given resource to be loaded.
|
void |
waitForAssets()
Waits for all loaded assets.
|
emitEvent, isRegistered, register, register, unregisterpublic void loadResource(Resource... resources)
resources - resources to be loadedpublic void loadResourceExcept(Resource[] resources, Resource... excludeResources)
resources - resources to be loadedexcludeResources - exceptionspublic void addResource(ResourceType resourceType, java.lang.String pathToFile)
resourceType - type of the resources in the folderpathToFile - path to the folderpublic void loadLanguage(java.util.Locale lang)
lang - new languagepublic java.lang.String getString(java.lang.String stringId)
loadLanguage(Locale).stringId - id of the stringpublic java.lang.String getXML(java.lang.String xmlName)
xmlName - name of the xml filepublic com.badlogic.gdx.graphics.g2d.TextureRegion getRegion(ResourceUnit region)
region - region mapped to the given unitpublic java.lang.String getXML(Resource xmlResource)
Resource.xmlResource - identifierpublic java.io.InputStream getXMLAsStream(Resource xmlResource)
public com.badlogic.gdx.graphics.g2d.BitmapFont createFont(ResourceUnit freeTypeFont, com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter)
freeTypeFont - unit the created font should get mapped toparameter - FreeTypeFontGenerator.FreeTypeFontParameterpublic void increaseCachedFontReferenceCount(com.badlogic.gdx.graphics.g2d.BitmapFont font)
font - cached font, created by createCachedFont(Resource, FreeTypeFontGenerator.FreeTypeFontParameter)public boolean destroyCachedFont(com.badlogic.gdx.graphics.g2d.BitmapFont font)
createCachedFont(Resource, FreeTypeFontGenerator.FreeTypeFontParameter).font - font generated by createCachedFontpublic com.badlogic.gdx.graphics.g2d.BitmapFont createCachedFont(Resource freeTypeFont, com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter parameter)
freeTypeFont - font generator resourceparameter - parameter to use for generationpublic com.badlogic.gdx.graphics.g2d.BitmapFont getFont(ResourceUnit fontUnit)
fontUnit - identifierpublic void loadSkin(Resource res, Resource atlas, ResourceUnit fontUnit)
res - resourceatlas - atlas of the skinfontUnit - font unitpublic void loadSkin(Resource res, Resource atlas, com.badlogic.gdx.utils.ObjectMap<java.lang.String,java.lang.Object> oMap)
res - resourcesatlas - atlas of the skinoMap - mappublic void scaleNinePatchesIn(Resource skinRes, float scale)
scale.skinRes - skinscale - scale-factorpublic <T> T get(Resource res, java.lang.Class<T> type)
T - for generic usageres - resource identifiertype - type of the resourcepublic <T> T get(java.lang.String res,
java.lang.Class<T> type)
T - for generic usageres - path to the resourcetype - type of the resourcepublic boolean update()
public float getProgress()
public void waitForAssets()
public void waitFor(Resource resource)
resource - resource to wait forpublic void dispose()
dispose in interface com.badlogic.gdx.utils.Disposable