24 import java.util.Collections; |
24 import java.util.Collections; |
25 import java.util.HashMap; |
25 import java.util.HashMap; |
26 import java.util.List; |
26 import java.util.List; |
27 |
27 |
28 import org.hedgewars.hedgeroid.R; |
28 import org.hedgewars.hedgeroid.R; |
|
29 import org.hedgewars.hedgeroid.StartGameActivity; |
29 import org.hedgewars.hedgeroid.Utils; |
30 import org.hedgewars.hedgeroid.Utils; |
30 import org.hedgewars.hedgeroid.Datastructures.Map.MapType; |
31 import org.hedgewars.hedgeroid.Datastructures.Map.MapType; |
31 |
32 |
32 import android.content.Context; |
33 import android.content.Context; |
33 import android.graphics.Bitmap; |
34 import android.graphics.Bitmap; |
34 import android.graphics.BitmapFactory; |
35 import android.graphics.BitmapFactory; |
35 import java.nio.ByteBuffer; |
|
36 |
36 |
37 public class FrontendDataUtils { |
37 public class FrontendDataUtils { |
38 |
38 |
39 |
39 |
40 public static ArrayList<Map> getMaps(Context c){ |
40 public static ArrayList<Map> getMaps(Context c){ |
71 List<String> list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); |
71 List<String> list = Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); |
72 Collections.sort(list); |
72 Collections.sort(list); |
73 return list; |
73 return list; |
74 } |
74 } |
75 |
75 |
76 public static List<Scheme> getSchemes(Context c){ |
|
77 List<Scheme> list = Scheme.getSchemes(c); |
|
78 Collections.sort(list); |
|
79 return list; |
|
80 } |
|
81 |
|
82 public static List<Weapon> getWeapons(Context c){ |
76 public static List<Weapon> getWeapons(Context c){ |
83 List<Weapon> list = Weapon.getWeapons(c); |
77 // TODO stub, re-implement |
84 Collections.sort(list); |
78 /*List<Weapon> list = Weapon.getWeapons(c); |
85 return list; |
79 Collections.sort(list);*/ |
|
80 return Collections.emptyList(); |
86 } |
81 } |
87 |
82 |
88 public static ArrayList<HashMap<String, ?>> getGraves(Context c){ |
83 public static ArrayList<HashMap<String, ?>> getGraves(Context c){ |
89 String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/"; |
84 String pathPrefix = Utils.getDataPath(c) + "Graphics/Graves/"; |
90 ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); |
85 ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); |
169 } |
164 } |
170 |
165 |
171 return data; |
166 return data; |
172 } |
167 } |
173 |
168 |
174 public static List<HashMap<String, Object>> getTeams(Context c){ |
169 public static List<TeamFile> getTeamFiles(Context c) { |
175 List<HashMap<String, Object>> ret = new ArrayList<HashMap<String, Object>>(); |
170 List<TeamFile> ret = new ArrayList<TeamFile>(); |
176 |
171 |
177 File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
172 File teamsDir = new File(c.getFilesDir(), Team.DIRECTORY_TEAMS); |
178 File[] teamFileNames = teamsDir.listFiles(); |
173 File[] teamFileNames = teamsDir.listFiles(); |
179 if(teamFileNames != null){ |
174 if(teamFileNames != null){ |
180 for(File s : teamFileNames){ |
175 for(File file : teamFileNames){ |
181 Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
176 Team team = Team.load(file); |
182 if(t != null){ |
177 if(team != null){ |
183 t.file = s.getName(); |
178 ret.add(new TeamFile(team, file)); |
184 ret.add(teamToMap(t)); |
|
185 } |
179 } |
186 } |
180 } |
187 } |
181 } |
188 return ret; |
182 return ret; |
189 } |
183 } |
190 |
184 |
191 public static HashMap<String, Object> teamToMap(Team t){ |
185 public static Scheme[] getSchemes(StartGameActivity startGameActivity) { |
192 HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
186 // TODO Auto-generated method stub |
193 hashmap.put("team", t); |
187 return null; |
194 hashmap.put("txt", t.name); |
|
195 hashmap.put("color", t.color); |
|
196 hashmap.put("count", t.hogCount); |
|
197 switch(t.levels[0]){ |
|
198 case 0: |
|
199 hashmap.put("img", R.drawable.human); |
|
200 break; |
|
201 case 1: |
|
202 hashmap.put("img", R.drawable.bot5); |
|
203 break; |
|
204 case 2: |
|
205 hashmap.put("img", R.drawable.bot4); |
|
206 break; |
|
207 case 3: |
|
208 hashmap.put("img", R.drawable.bot3); |
|
209 break; |
|
210 case 4: |
|
211 hashmap.put("img", R.drawable.bot2); |
|
212 break; |
|
213 default: |
|
214 case 5: |
|
215 hashmap.put("img", R.drawable.bot1); |
|
216 break; |
|
217 } |
|
218 return hashmap; |
|
219 } |
188 } |
220 } |
189 } |