author | Xeli |
Wed, 10 Aug 2011 01:50:57 +0200 | |
branch | hedgeroid |
changeset 5534 | 7f3a391a66fb |
parent 5532 | 3d7ac2b3b703 |
child 5603 | 4e4a579a60af |
permissions | -rw-r--r-- |
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
1 |
package org.hedgewars.mobile.EngineProtocol; |
5433 | 2 |
|
3 |
import java.io.File; |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
4 |
import java.util.ArrayList; |
5433 | 5 |
import java.util.Arrays; |
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
6 |
import java.util.Collections; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
7 |
import java.util.HashMap; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
8 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
9 |
import org.hedgewars.mobile.R; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
10 |
import org.hedgewars.mobile.Utils; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
11 |
import org.hedgewars.mobile.EngineProtocol.Map.MapType; |
5433 | 12 |
|
13 |
import android.content.Context; |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
14 |
import android.graphics.Bitmap; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
15 |
import android.graphics.BitmapFactory; |
5433 | 16 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
17 |
public class FrontendDataUtils { |
5433 | 18 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
19 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
20 |
public static ArrayList<Map> getMaps(Context c){ |
5433 | 21 |
File[] files = Utils.getFilesFromRelativeDir(c,"Maps"); |
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
22 |
ArrayList<Map> ret = new ArrayList<Map>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
23 |
|
5433 | 24 |
for(File f : files){ |
25 |
if(Utils.hasFileWithSuffix(f, ".lua")){ |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
26 |
ret.add(new Map(f,MapType.TYPE_MISSION, c)); |
5433 | 27 |
}else{ |
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
28 |
ret.add(new Map(f, MapType.TYPE_DEFAULT,c)); |
5433 | 29 |
} |
30 |
} |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
31 |
Collections.sort(ret); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
32 |
|
5433 | 33 |
return ret; |
34 |
} |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
35 |
|
5433 | 36 |
public static String[] getGameplay(Context c){ |
37 |
String[] files = Utils.getFileNamesFromRelativeDir(c, "Scripts/Multiplayer"); |
|
38 |
int retCounter = 0; |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
39 |
|
5433 | 40 |
for(int i = 0; i < files.length; i++){ |
41 |
if(files[i].endsWith(".lua")){ |
|
42 |
files[i] = files[i].replace('_', ' ').substring(0, files[i].length()-4); //replace _ by a space and removed the last four characters (.lua) |
|
43 |
retCounter++; |
|
44 |
}else files[i] = null; |
|
45 |
} |
|
46 |
String[] ret = new String[retCounter]; |
|
47 |
retCounter = 0; |
|
48 |
for(String s : files){ |
|
49 |
if(s != null) ret[retCounter++] = s; |
|
50 |
} |
|
51 |
Arrays.sort(ret); |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
52 |
|
5433 | 53 |
return ret; |
54 |
} |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
55 |
|
5433 | 56 |
public static String[] getThemes(Context c){ |
57 |
return Utils.getDirsWithFileSuffix(c, "Themes", "icon.png"); |
|
58 |
} |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
59 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
60 |
public static ArrayList<Scheme> getSchemes(Context c){ |
5433 | 61 |
return Scheme.getSchemes(c); |
62 |
} |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
63 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
64 |
public static ArrayList<Weapon> getWeapons(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
65 |
return Weapon.getWeapons(c); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
66 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
67 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
68 |
public static ArrayList<HashMap<String, ?>> getGraves(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
69 |
String pathPrefix = Utils.getDownloadPath(c) + "Graphics/Graves/"; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
70 |
ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c, "Graphics/Graves", ".png", true); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
71 |
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(names.size()); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
72 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
73 |
for(String s : names){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
74 |
HashMap<String, Object> map = new HashMap<String, Object>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
75 |
map.put("txt", s); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
76 |
Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
77 |
int width = b.getWidth(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
78 |
if(b.getHeight() > width){//some pictures contain more 'frames' underneath each other, if so we only use the first frame |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
79 |
Bitmap tmp = Bitmap.createBitmap(b, 0, 0, width, width); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
80 |
b.recycle(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
81 |
b = tmp; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
82 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
83 |
map.put("img", b); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
84 |
data.add(map); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
85 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
86 |
return data; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
87 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
88 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
89 |
public static ArrayList<HashMap<String, ?>> getFlags(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
90 |
String pathPrefix = Utils.getDownloadPath(c) + "Graphics/Flags/"; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
91 |
ArrayList<String> names = Utils.getFilesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
92 |
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(names.size()); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
93 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
94 |
for(String s : names){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
95 |
HashMap<String, Object> map = new HashMap<String, Object>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
96 |
map.put("txt", s); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
97 |
Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
98 |
map.put("img", b); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
99 |
data.add(map); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
100 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
101 |
return data; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
102 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
103 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
104 |
public static ArrayList<String> getVoices(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
105 |
File[] files = Utils.getFilesFromRelativeDir(c, "Sounds/voices"); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
106 |
ArrayList<String> ret = new ArrayList<String>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
107 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
108 |
for(File f : files){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
109 |
if(f.isDirectory()) ret.add(f.getName()); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
110 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
111 |
return ret; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
112 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
113 |
|
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
114 |
public static ArrayList<String> getForts(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
115 |
return Utils.getFilesFromDirWithSuffix(c, "Forts", "L.png", true); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
116 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
117 |
public static ArrayList<HashMap<String, ?>> getTypes(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
118 |
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(6); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
119 |
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)}; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
120 |
int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
121 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
122 |
for(int i = 0; i < levels.length; i++){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
123 |
HashMap<String, Object> map = new HashMap<String, Object>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
124 |
map.put("txt", levels[i]); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
125 |
map.put("img", images[i]); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
126 |
data.add(map); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
127 |
} |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
128 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
129 |
return data; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
130 |
} |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
131 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
132 |
public static ArrayList<HashMap<String, ?>> getHats(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
133 |
ArrayList<String> files = Utils.getFilesFromDirWithSuffix(c, "Graphics/Hats", ".png", true); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
134 |
String pathPrefix = Utils.getDownloadPath(c) + "Graphics/Hats/"; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
135 |
int size = files.size(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
136 |
ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(size); |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
137 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
138 |
HashMap<String, Object> hashmap; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
139 |
for(String s : files){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
140 |
hashmap = new HashMap<String, Object>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
141 |
hashmap.put("txt", s); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
142 |
Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
143 |
b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
144 |
hashmap.put("img", b); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
145 |
data.add(hashmap); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
146 |
} |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
147 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
148 |
return data; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
149 |
} |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
150 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
151 |
public static ArrayList<HashMap<String, ?>> getTeams(Context c){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
152 |
ArrayList<HashMap<String, ?>> ret = new ArrayList<HashMap<String, ?>>(); |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
153 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
154 |
File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
155 |
File[] teamFileNames = teamsDir.listFiles(); |
5534 | 156 |
if(teamFileNames != null){ |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
157 |
for(File s : teamFileNames){ |
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
158 |
Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
159 |
if(t != null){ |
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
160 |
ret.add(teamToHashMap(t)); |
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
161 |
} |
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
162 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
163 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
164 |
return ret; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
165 |
} |
5532
3d7ac2b3b703
Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents:
5467
diff
changeset
|
166 |
|
5467
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
167 |
public static HashMap<String, Object> teamToHashMap(Team t){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
168 |
HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
169 |
hashmap.put("team", t); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
170 |
hashmap.put("txt", t.name); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
171 |
switch(t.levels[0]){ |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
172 |
case 0: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
173 |
hashmap.put("img", R.drawable.human); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
174 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
175 |
case 1: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
176 |
hashmap.put("img", R.drawable.bot5); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
177 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
178 |
case 2: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
179 |
hashmap.put("img", R.drawable.bot4); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
180 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
181 |
case 3: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
182 |
hashmap.put("img", R.drawable.bot3); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
183 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
184 |
case 4: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
185 |
hashmap.put("img", R.drawable.bot2); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
186 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
187 |
default: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
188 |
case 5: |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
189 |
hashmap.put("img", R.drawable.bot1); |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
190 |
break; |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
191 |
} |
88e25840f532
Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
5433
diff
changeset
|
192 |
return hashmap; |
5433 | 193 |
} |
194 |
} |