project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/FrontendDataUtils.java
changeset 6436 f1a42ba9cab2
parent 6432 ffb18b44415d
child 6447 0bb16bc5c8b4
equal deleted inserted replaced
6435:356fbb672f84 6436:f1a42ba9cab2
    22 import java.io.File;
    22 import java.io.File;
    23 import java.util.ArrayList;
    23 import java.util.ArrayList;
    24 import java.util.Arrays;
    24 import java.util.Arrays;
    25 import java.util.Collections;
    25 import java.util.Collections;
    26 import java.util.HashMap;
    26 import java.util.HashMap;
       
    27 import java.util.List;
    27 
    28 
    28 import org.hedgewars.hedgeroid.R;
    29 import org.hedgewars.hedgeroid.R;
    29 import org.hedgewars.hedgeroid.Utils;
    30 import org.hedgewars.hedgeroid.Utils;
    30 import org.hedgewars.hedgeroid.EngineProtocol.Map.MapType;
    31 import org.hedgewars.hedgeroid.EngineProtocol.Map.MapType;
    31 
    32 
    50 		Collections.sort(ret);
    51 		Collections.sort(ret);
    51 
    52 
    52 		return ret;
    53 		return ret;
    53 	}
    54 	}
    54 
    55 
    55 	public static String[] getGameplay(Context c){
    56 	public static List<String> getGameplay(Context c){
    56 		String[] files = Utils.getFileNamesFromRelativeDir(c, "Scripts/Multiplayer");
    57 		String[] files = Utils.getFileNamesFromRelativeDir(c, "Scripts/Multiplayer");
    57 		int retCounter = 0;
    58 		ArrayList<String> ret = new ArrayList<String>();
    58 
    59 		
    59 		for(int i = 0; i < files.length; i++){
    60 		for(int i = 0; i < files.length; i++){
    60 			if(files[i].endsWith(".lua")){
    61 			if(files[i].endsWith(".lua")){
    61 				files[i] = files[i].replace('_', ' ').substring(0, files[i].length()-4); //replace _ by a space and removed the last four characters (.lua)
    62 				ret.add(files[i].replace('_', ' ').substring(0, files[i].length()-4)); //replace _ by a space and removed the last four characters (.lua)
    62 				retCounter++;
    63 			}
    63 			}else files[i] = null;
    64 		}
    64 		}
    65 		Collections.sort(ret);
    65 		String[] ret = new String[retCounter];
    66 
    66 		retCounter = 0;
    67 		ret.add(0,"None");
    67 		for(String s : files){
       
    68 			if(s != null) ret[retCounter++] = s;
       
    69 		}
       
    70 		Arrays.sort(ret);
       
    71 
       
    72 		return ret;	
    68 		return ret;	
    73 	}
    69 	}
    74 
    70 
    75 	public static String[] getThemes(Context c){
    71 	public static String[] getThemes(Context c){
    76 		return Utils.getDirsWithFileSuffix(c, "Themes", "icon.png");
    72 		return Utils.getDirsWithFileSuffix(c, "Themes", "icon.png");
    77 	}
    73 	}
    78 
    74 
    79 	public static ArrayList<Scheme> getSchemes(Context c){
    75 	public static List<Scheme> getSchemes(Context c){
    80 		return Scheme.getSchemes(c);
    76 		List<Scheme> list = Scheme.getSchemes(c);
    81 	}
    77 		Collections.sort(list);
    82 
    78 		return list;
    83 	public static ArrayList<Weapon> getWeapons(Context c){
    79 	}
    84 		return Weapon.getWeapons(c);
    80 
       
    81 	public static List<Weapon> getWeapons(Context c){
       
    82 		List<Weapon> list = Weapon.getWeapons(c);
       
    83 		Collections.sort(list);
       
    84 		return list;
    85 	}
    85 	}
    86 
    86 
    87 	public static ArrayList<HashMap<String, ?>> getGraves(Context c){
    87 	public static ArrayList<HashMap<String, ?>> getGraves(Context c){
    88 		String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/";
    88 		String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/";
    89 		ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true);
    89 		ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true);