--- 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<MapFile> getMaps(Context c) throws FileNotFoundException {
- File[] files = Utils.getFilesFromRelativeDir(c,"Maps");
+ File[] files = FileUtils.getFilesFromRelativeDir(c,"Maps");
ArrayList<MapFile> ret = new ArrayList<MapFile>();
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<String> getGameStyles(Context c) throws FileNotFoundException {
- File[] files = Utils.getFilesFromRelativeDir(c, "Scripts/Multiplayer");
+ File[] files = FileUtils.getFilesFromRelativeDir(c, "Scripts/Multiplayer");
ArrayList<String> ret = new ArrayList<String>();
/*
* 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<String> getThemes(Context c) throws FileNotFoundException {
- List<String> list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png");
- Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
- return list;
- }
-
- public static List<Weaponset> getWeaponsets(Context c) {
- // TODO stub, re-implement
- /*List<Weapon> 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<HashMap<String, ?>> getGraves(Context c) throws FileNotFoundException {
- File gravePath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Graves");
- ArrayList<String> names = Utils.getFileNamesFromDirWithSuffix(c,"Graphics/Graves", ".png", true);
+ File gravePath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Graves");
+ ArrayList<String> names = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Graves", ".png", true);
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(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<HashMap<String, ?>> getFlags(Context c) throws FileNotFoundException {
- File flagsPath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Flags");
- ArrayList<String> names = Utils.getFileNamesFromDirWithSuffix(c, "Graphics/Flags", ".png", true);
+ File flagsPath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Flags");
+ ArrayList<String> names = FileUtils.getFileNamesFromDirWithSuffix(c, "Graphics/Flags", ".png", true);
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(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<String> getVoices(Context c) throws FileNotFoundException {
- File[] files = Utils.getFilesFromRelativeDir(c, "Sounds/voices");
+ File[] files = FileUtils.getFilesFromRelativeDir(c, "Sounds/voices");
ArrayList<String> ret = new ArrayList<String>();
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<String> 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<HashMap<String, ?>> getTypes(Context c){
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(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<String, Object> map = new HashMap<String, Object>();
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<HashMap<String, ?>> getHats(Context c) throws FileNotFoundException {
- ArrayList<String> files = Utils.getFileNamesFromDirWithSuffix(c,"Graphics/Hats", ".png", true);
- File hatsPath = new File(new File(Utils.getDataPathFile(c), "Graphics"), "Hats");
+ ArrayList<String> files = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Hats", ".png", true);
+ File hatsPath = new File(new File(FileUtils.getDataPathFile(c), "Graphics"), "Hats");
int size = files.size();
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(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);
+ }
}
}
}