From 7ef0e439d49627874f4b8d77aa209c1ea9a2ae7e Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Wed, 16 Jan 2013 20:52:11 +0000 Subject: [PATCH] SDK: - Make ProjectAssetManager return Assets from classpath for textures, sounds, j3m files etc. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10081 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/assets/ProjectAssetManager.java | 59 +++++++------------ 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java index ad68d39eb..707dcb343 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java @@ -299,55 +299,36 @@ public class ProjectAssetManager extends DesktopAssetManager { } public String[] getMaterials() { - FileObject assetsFolder = getAssetFolder(); - if (assetsFolder == null) { - return new String[]{}; - } - Enumeration assets = (Enumeration) assetsFolder.getChildren(true); - ArrayList list = new ArrayList(); - while (assets.hasMoreElements()) { - FileObject asset = assets.nextElement(); - if (asset.getExt().equalsIgnoreCase("j3m")) { - list.add(getRelativeAssetPath(asset.getPath())); - } - } - return list.toArray(new String[list.size()]); + return filesWithSuffix("j3m"); } public String[] getSounds() { - FileObject assetsFolder = getAssetFolder(); - if (assetsFolder == null) { - return new String[]{}; - } - Enumeration assets = (Enumeration) assetsFolder.getChildren(true); ArrayList list = new ArrayList(); - while (assets.hasMoreElements()) { - FileObject asset = assets.nextElement(); - if (asset.getExt().equalsIgnoreCase("wav") || asset.getExt().equalsIgnoreCase("ogg")) { - list.add(getRelativeAssetPath(asset.getPath())); - } - } + list.addAll(collectFilesWithSuffix("wav")); + list.addAll(collectFilesWithSuffix("ogg")); return list.toArray(new String[list.size()]); } public String[] getTextures() { - FileObject assetsFolder = getAssetFolder(); - if (assetsFolder == null) { - return new String[]{}; - } - Enumeration assets = (Enumeration) assetsFolder.getChildren(true); ArrayList list = new ArrayList(); - while (assets.hasMoreElements()) { - FileObject asset = assets.nextElement(); - if (asset.getExt().equalsIgnoreCase("jpg") || asset.getExt().equalsIgnoreCase("jpeg") || asset.getExt().equalsIgnoreCase("gif") || asset.getExt().equalsIgnoreCase("png") || asset.getExt().equalsIgnoreCase("dds") || asset.getExt().equalsIgnoreCase("pfm") || asset.getExt().equalsIgnoreCase("hdr") || asset.getExt().equalsIgnoreCase("tga")) { - list.add(getRelativeAssetPath(asset.getPath())); - } - } + list.addAll(collectFilesWithSuffix("jpg")); + list.addAll(collectFilesWithSuffix("jpeg")); + list.addAll(collectFilesWithSuffix("gif")); + list.addAll(collectFilesWithSuffix("png")); + list.addAll(collectFilesWithSuffix("dds")); + list.addAll(collectFilesWithSuffix("pfm")); + list.addAll(collectFilesWithSuffix("hdr")); + list.addAll(collectFilesWithSuffix("tga")); return list.toArray(new String[list.size()]); } public String[] getMatDefs() { - return collectFilesWithSuffix("j3md"); + return filesWithSuffix("j3md"); + } + + private String[] filesWithSuffix(String string){ + List list=collectFilesWithSuffix(string); + return list.toArray(new String[list.size()]); } /** @@ -356,8 +337,8 @@ public class ProjectAssetManager extends DesktopAssetManager { * @param suffix * @return */ - private String[] collectFilesWithSuffix(String suffix) { - Set list = new HashSet(); + private List collectFilesWithSuffix(String suffix) { + List list = new LinkedList(); FileObject assetsFolder = getAssetFolder(); if (assetsFolder != null) { Enumeration assets = (Enumeration) assetsFolder.getChildren(true); @@ -391,7 +372,7 @@ public class ProjectAssetManager extends DesktopAssetManager { } } - return list.toArray(new String[list.size()]); + return list; } public InputStream getResourceAsStream(String name) {