diff -r d70a5b0d1190 -r 0481bd74267c project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java Sun Aug 12 22:37:57 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java Sun Aug 12 22:46:23 2012 +0200 @@ -22,26 +22,28 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; +import org.hedgewars.hedgeroid.Utils; import org.hedgewars.hedgeroid.EngineProtocol.PascalExports; import org.hedgewars.hedgeroid.frontlib.Flib; import org.hedgewars.hedgeroid.frontlib.Frontlib.TeamPtr; -import android.util.Log; +import android.content.Context; public final class Team { public static final String DIRECTORY_TEAMS = "teams"; - public static final int maxNumberOfHogs = PascalExports.HWgetMaxNumberOfHogs(); + public static final int HEDGEHOGS_PER_TEAM = Flib.INSTANCE.flib_get_hedgehogs_per_team(); public static final int maxNumberOfTeams = PascalExports.HWgetMaxNumberOfTeams(); public final String name, grave, flag, voice, fort; public final List hogs; public Team(String name, String grave, String flag, String voice, String fort, List hogs) { - if(hogs.size() != maxNumberOfHogs) { - throw new IllegalArgumentException("A team must consist of "+maxNumberOfHogs+" hogs."); + if(hogs.size() != HEDGEHOGS_PER_TEAM) { + throw new IllegalArgumentException("A team must consist of "+HEDGEHOGS_PER_TEAM+" hogs."); } this.name = name; this.grave = grave; @@ -52,7 +54,6 @@ } public void save(File f) throws IOException { - Log.d("Team", "saving to "+f.getAbsolutePath()); TeamPtr teamPtr = TeamPtr.createJavaOwned(this); if(Flib.INSTANCE.flib_team_to_ini(f.getAbsolutePath(), teamPtr) != 0) { throw new IOException("Error saving team "+name); @@ -69,11 +70,21 @@ return null; } } - + + public static File getTeamfileByName(Context c, String teamName) { + return new File(new File(c.getFilesDir(), DIRECTORY_TEAMS), Utils.replaceBadChars(teamName)+".hwt"); + } + @Override public String toString() { return "Team [name=" + name + ", grave=" + grave + ", flag=" + flag + ", voice=" + voice + ", fort=" + fort + ", hogs=" + hogs + "]"; } + + public static Comparator NAME_ORDER = new Comparator() { + public int compare(Team lhs, Team rhs) { + return lhs.name.compareToIgnoreCase(rhs.name); + } + }; }