}\r
\r
/** @param fileName the asset file name\r
+ * @return the asset */\r
+ public synchronized <T> T get (String fileName) {\r
+ Class<T> type = assetTypes.get(fileName);\r
+ ObjectMap<String, RefCountedContainer> assetsByType = assets.get(type);\r
+ if (assetsByType == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ RefCountedContainer assetContainer = assetsByType.get(fileName);\r
+ if (assetContainer == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ T asset = assetContainer.getObject(type);\r
+ if (asset == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ return asset;\r
+ }\r
+ /** @param fileName the asset file name\r
* @param type the asset type\r
* @return the asset */\r
public synchronized <T> T get (String fileName, Class<T> type) {\r
public synchronized Array<String> getDependencies(String fileName) {\r
return assetDependencies.get(fileName);\r
}\r
- \r
+ /** @return the type of a loaded asset. */\r
+ public synchronized Class getAssetType (String fileName) {\r
+ return assetTypes.get(fileName);\r
+ }\r
}\r
}\r
\r
/** @param fileName the asset file name\r
+ * @return the asset */\r
+ public synchronized <T> T get (String fileName) {\r
+ Class<T> type = assetTypes.get(fileName);\r
+ ObjectMap<String, RefCountedContainer> assetsByType = assets.get(type);\r
+ if (assetsByType == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ RefCountedContainer assetContainer = assetsByType.get(fileName);\r
+ if (assetContainer == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ T asset = assetContainer.getObject(type);\r
+ if (asset == null) throw new GdxRuntimeException("Asset not loaded: " + fileName);\r
+ return asset;\r
+ }\r
+\r
+ /** @param fileName the asset file name\r
* @param type the asset type\r
* @return the asset */\r
public synchronized <T> T get (String fileName, Class<T> type) {\r
}\r
\r
/** @return the file names of all loaded assets. */\r
- public synchronized Array<String> getAssetNames() {\r
+ public synchronized Array<String> getAssetNames () {\r
return assetTypes.keys().toArray();\r
}\r
+\r
/** @return the dependencies of an asset or null if the asset has no dependencies. */\r
- public synchronized Array<String> getDependencies(String fileName) {\r
+ public synchronized Array<String> getDependencies (String fileName) {\r
return assetDependencies.get(fileName);\r
}\r
\r
+ /** @return the type of a loaded asset. */\r
+ public synchronized Class getAssetType (String fileName) {\r
+ return assetTypes.get(fileName);\r
+ }\r
+\r
}\r