diff -r ed1d52c5aa94 -r 763d3961400b project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java Sat Aug 18 00:22:33 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/FrontendDataUtils.java Sat Aug 18 00:47:51 2012 +0200 @@ -22,12 +22,11 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import org.hedgewars.hedgeroid.R; -import org.hedgewars.hedgeroid.Utils; +import org.hedgewars.hedgeroid.util.FileUtils; import android.content.Context; import android.graphics.Bitmap; @@ -39,14 +38,13 @@ * @throws FileNotFoundException if the sdcard isn't available or the Maps directory doesn't exist */ public static ArrayList getMaps(Context c) throws FileNotFoundException { - File[] files = Utils.getFilesFromRelativeDir(c,"Maps"); + File[] files = FileUtils.getFilesFromRelativeDir(c,"Maps"); ArrayList ret = new ArrayList(); for(File f : files) { - boolean isMission = Utils.hasFileWithSuffix(f, ".lua"); + boolean isMission = FileUtils.hasFileWithSuffix(f, ".lua"); ret.add(new MapFile(f.getName(), isMission)); } - Collections.sort(ret, MapFile.MISSIONS_FIRST_NAME_ORDER); return ret; } @@ -56,7 +54,7 @@ * @throws FileNotFoundException if the sdcard isn't available or the Scripts/Multiplayer directory doesn't exist */ public static List getGameStyles(Context c) throws FileNotFoundException { - File[] files = Utils.getFilesFromRelativeDir(c, "Scripts/Multiplayer"); + File[] files = FileUtils.getFilesFromRelativeDir(c, "Scripts/Multiplayer"); ArrayList ret = new ArrayList(); /* * Caution: It is important that the "empty" style has this exact name, because @@ -72,7 +70,6 @@ ret.add(name.replace('_', ' ').substring(0, name.length()-4)); } } - Collections.sort(ret, String.CASE_INSENSITIVE_ORDER); return ret; } @@ -80,24 +77,15 @@ * @throws FileNotFoundException if the sdcard isn't available or the Themes directory doesn't exist */ public static List getThemes(Context c) throws FileNotFoundException { - List list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); - Collections.sort(list, String.CASE_INSENSITIVE_ORDER); - return list; - } - - public static List getWeaponsets(Context c) { - // TODO stub, re-implement - /*List list = Weapon.getWeapons(c); - Collections.sort(list);*/ - return Collections.emptyList(); + return FileUtils.getDirsWithFileSuffix(c, "Themes", "icon.png"); } /** * @throws FileNotFoundException if the sdcard isn't available or the Graphics/Graves directory doesn't exist */ public static ArrayList> getGraves(Context c) throws FileNotFoundException { - File gravePath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Graves"); - ArrayList names = Utils.getFileNamesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); + File gravePath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Graves"); + ArrayList names = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); ArrayList> data = new ArrayList>(names.size()); for(String s : names){ @@ -123,8 +111,8 @@ * @throws FileNotFoundException if the sdcard isn't available or the Graphics/Graves directory doesn't exist */ public static ArrayList> getFlags(Context c) throws FileNotFoundException { - File flagsPath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Flags"); - ArrayList names = Utils.getFileNamesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); + File flagsPath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Flags"); + ArrayList names = FileUtils.getFileNamesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); ArrayList> data = new ArrayList>(names.size()); for(String s : names){ @@ -141,7 +129,7 @@ * @throws FileNotFoundException if the sdcard isn't available or the Sounds/voices directory doesn't exist */ public static ArrayList getVoices(Context c) throws FileNotFoundException { - File[] files = Utils.getFilesFromRelativeDir(c, "Sounds/voices"); + File[] files = FileUtils.getFilesFromRelativeDir(c, "Sounds/voices"); ArrayList ret = new ArrayList(); for(File f : files){ @@ -154,10 +142,9 @@ * @throws FileNotFoundException if the sdcard isn't available or the Forts directory doesn't exist */ public static ArrayList getForts(Context c) throws FileNotFoundException { - return Utils.getFileNamesFromDirWithSuffix(c,"Forts", "L.png", true); + return FileUtils.getFileNamesFromDirWithSuffix(c,"Forts", "L.png", true); } - // TODO wat public static ArrayList> getTypes(Context c){ ArrayList> data = new ArrayList>(6); String[] levels = {c.getString(R.string.human), c.getString(R.string.bot5), c.getString(R.string.bot4), c.getString(R.string.bot3), c.getString(R.string.bot2), c.getString(R.string.bot1)}; @@ -167,6 +154,8 @@ HashMap map = new HashMap(); map.put("txt", levels[i]); map.put("img", images[i]); + map.put("level", i); + data.add(map); } @@ -177,8 +166,8 @@ * @throws FileNotFoundException if the sdcard isn't available or the Graphics/Hats directory doesn't exist */ public static ArrayList> getHats(Context c) throws FileNotFoundException { - ArrayList files = Utils.getFileNamesFromDirWithSuffix(c,"Graphics/Hats", ".png", true); - File hatsPath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Hats"); + ArrayList files = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Hats", ".png", true); + File hatsPath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Hats"); int size = files.size(); ArrayList> data = new ArrayList>(size); @@ -202,9 +191,11 @@ File[] teamFileNames = teamsDir.listFiles(); if(teamFileNames != null){ for(File file : teamFileNames){ - Team team = Team.load(file); - if(team != null){ - ret.add(team); + if(file.getName().endsWith(".hwt")) { + Team team = Team.load(file); + if(team != null){ + ret.add(team); + } } } }