author | Wuzzy <Wuzzy2@mail.ru> |
Sat, 21 Oct 2017 18:38:28 +0200 | |
changeset 12734 | 4e0e59255856 |
parent 7586 | 33924ff4af50 |
permissions | -rw-r--r-- |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
1 |
/* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com> |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
4 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
5 |
* |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
7 |
* modify it under the terms of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
8 |
* as published by the Free Software Foundation; either version 2 |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
9 |
* of the License, or (at your option) any later version. |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
10 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
14 |
* GNU General Public License for more details. |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
15 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
17 |
* along with this program; if not, write to the Free Software |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
19 |
*/ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
20 |
|
6505 | 21 |
package org.hedgewars.hedgeroid.Datastructures; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
22 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
23 |
import java.io.File; |
7485 | 24 |
import java.io.FileNotFoundException; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
25 |
import java.util.ArrayList; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
26 |
import java.util.HashMap; |
6436
f1a42ba9cab2
Sort the weapons/schemes/styles and give make give them a default value
Xeli
parents:
6432
diff
changeset
|
27 |
import java.util.List; |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
28 |
import java.util.Map; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
29 |
|
6049
7bc38086d771
wops missed this one: removed a 'fix' eclipse put in there
Xeli
parents:
6047
diff
changeset
|
30 |
import org.hedgewars.hedgeroid.R; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
31 |
import org.hedgewars.hedgeroid.util.FileUtils; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
32 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
33 |
import android.content.Context; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
34 |
import android.graphics.Bitmap; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
35 |
import android.graphics.BitmapFactory; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
36 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
37 |
public class FrontendDataUtils { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
38 |
|
7485 | 39 |
/** |
40 |
* @throws FileNotFoundException if the sdcard isn't available or the Maps directory doesn't exist |
|
41 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
42 |
public static List<MapFile> getMaps(Context c) throws FileNotFoundException { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
43 |
File[] files = FileUtils.getFilesFromRelativeDir(c,"Maps"); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
44 |
List<MapFile> ret = new ArrayList<MapFile>(); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
45 |
|
7485 | 46 |
for(File f : files) { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
47 |
boolean isMission = FileUtils.hasFileWithSuffix(f, ".lua"); |
7485 | 48 |
ret.add(new MapFile(f.getName(), isMission)); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
49 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
50 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
51 |
return ret; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
52 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
53 |
|
7485 | 54 |
/** |
55 |
* Returns a list of all multiplayer scripts (game styles) |
|
56 |
* @throws FileNotFoundException if the sdcard isn't available or the Scripts/Multiplayer directory doesn't exist |
|
57 |
*/ |
|
58 |
public static List<String> getGameStyles(Context c) throws FileNotFoundException { |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
59 |
File[] files = FileUtils.getFilesFromRelativeDir(c, "Scripts/Multiplayer"); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
60 |
List<String> ret = new ArrayList<String>(); |
7485 | 61 |
/* |
62 |
* Caution: It is important that the "empty" style has this exact name, because |
|
63 |
* it will be interpreted as "don't load a script" by the frontlib, and also by |
|
64 |
* the QtFrontend in a netgame. This should probably be improved some time |
|
65 |
* (maybe TODO add a dummy script called "Normal" to the MP scripts?) |
|
66 |
*/ |
|
67 |
ret.add("Normal"); |
|
68 |
for(int i = 0; i < files.length; i++) { |
|
69 |
String name = files[i].getName(); |
|
70 |
if(name.endsWith(".lua")){ |
|
71 |
//replace _ by a space and removed the last four characters (.lua) |
|
72 |
ret.add(name.replace('_', ' ').substring(0, name.length()-4)); |
|
6436
f1a42ba9cab2
Sort the weapons/schemes/styles and give make give them a default value
Xeli
parents:
6432
diff
changeset
|
73 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
74 |
} |
7485 | 75 |
return ret; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
76 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
77 |
|
7485 | 78 |
/** |
79 |
* @throws FileNotFoundException if the sdcard isn't available or the Themes directory doesn't exist |
|
80 |
*/ |
|
81 |
public static List<String> getThemes(Context c) throws FileNotFoundException { |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
82 |
return FileUtils.getDirsWithFileSuffix(c, "Themes", "icon.png"); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
83 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
84 |
|
7485 | 85 |
/** |
86 |
* @throws FileNotFoundException if the sdcard isn't available or the Graphics/Graves directory doesn't exist |
|
87 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
88 |
public static List<Map<String, ?>> getGraves(Context c) throws FileNotFoundException { |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
89 |
File gravePath = FileUtils.getDataPathFile(c, "Graphics", "Graves"); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
90 |
List<String> names = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Graves", ".png", true); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
91 |
List<Map<String, ?>> data = new ArrayList<Map<String, ?>>(names.size()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
92 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
93 |
for(String s : names){ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
94 |
HashMap<String, Object> map = new HashMap<String, Object>(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
95 |
map.put("txt", s); |
7485 | 96 |
Bitmap b = BitmapFactory.decodeFile(new File(gravePath, s + ".png").getAbsolutePath()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
97 |
int width = b.getWidth(); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
98 |
if(b.getHeight() > width){ |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
99 |
// some pictures contain more 'frames' underneath each other, if so we only use the first frame |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
100 |
b = Bitmap.createBitmap(b, 0, 0, width, width); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
101 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
102 |
map.put("img", b); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
103 |
data.add(map); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
104 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
105 |
return data; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
106 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
107 |
|
7485 | 108 |
/** |
109 |
* @throws FileNotFoundException if the sdcard isn't available or the Graphics/Graves directory doesn't exist |
|
110 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
111 |
public static List<Map<String, ?>> getFlags(Context c) throws FileNotFoundException { |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
112 |
File flagsPath = FileUtils.getDataPathFile(c, "Graphics", "Flags"); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
113 |
List<String> names = FileUtils.getFileNamesFromDirWithSuffix(c, "Graphics/Flags", ".png", true); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
114 |
List<Map<String, ?>> data = new ArrayList<Map<String, ?>>(names.size()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
115 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
116 |
for(String s : names){ |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
117 |
Map<String, Object> map = new HashMap<String, Object>(); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
118 |
map.put("txt", s); |
7485 | 119 |
Bitmap b = BitmapFactory.decodeFile(new File(flagsPath, s + ".png").getAbsolutePath()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
120 |
map.put("img", b); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
121 |
data.add(map); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
122 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
123 |
return data; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
124 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
125 |
|
7485 | 126 |
/** |
127 |
* @throws FileNotFoundException if the sdcard isn't available or the Sounds/voices directory doesn't exist |
|
128 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
129 |
public static List<String> getVoices(Context c) throws FileNotFoundException { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
130 |
File[] files = FileUtils.getFilesFromRelativeDir(c, "Sounds/voices"); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
131 |
List<String> ret = new ArrayList<String>(); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
132 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
133 |
for(File f : files){ |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
134 |
if(f.isDirectory()) ret.add(f.getName()); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
135 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
136 |
return ret; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
137 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
138 |
|
7485 | 139 |
/** |
140 |
* @throws FileNotFoundException if the sdcard isn't available or the Forts directory doesn't exist |
|
141 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
142 |
public static List<String> getForts(Context c) throws FileNotFoundException { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
143 |
return FileUtils.getFileNamesFromDirWithSuffix(c,"Forts", "L.png", true); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
144 |
} |
7485 | 145 |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
146 |
public static List<Map<String, ?>> getTypes(Context c){ |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
147 |
List<Map<String, ?>> data = new ArrayList<Map<String, ?>>(6); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
148 |
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)}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
149 |
int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
150 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
151 |
for(int i = 0; i < levels.length; i++){ |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
152 |
Map<String, Object> map = new HashMap<String, Object>(); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
153 |
map.put("txt", levels[i]); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
154 |
map.put("img", images[i]); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
155 |
map.put("level", i); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
156 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
157 |
data.add(map); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
158 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
159 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
160 |
return data; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
161 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
162 |
|
7485 | 163 |
/** |
164 |
* @throws FileNotFoundException if the sdcard isn't available or the Graphics/Hats directory doesn't exist |
|
165 |
*/ |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
166 |
public static List<Map<String, ?>> getHats(Context c) throws FileNotFoundException { |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
167 |
List<String> files = FileUtils.getFileNamesFromDirWithSuffix(c,"Graphics/Hats", ".png", true); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
168 |
File hatsPath = FileUtils.getDataPathFile(c, "Graphics", "Hats"); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
169 |
int size = files.size(); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
170 |
List<Map<String, ?>> data = new ArrayList<Map<String, ?>>(size); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
171 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
172 |
for(String s : files){ |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
173 |
Map<String, Object> hashmap = new HashMap<String, Object>(); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
174 |
hashmap.put("txt", s); |
7485 | 175 |
Bitmap b = BitmapFactory.decodeFile(new File(hatsPath, s + ".png").getAbsolutePath()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
176 |
b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
177 |
hashmap.put("img", b); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
178 |
data.add(hashmap); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
179 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
180 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
181 |
return data; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
182 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
183 |
|
7485 | 184 |
public static List<Team> getTeams(Context c) { |
185 |
List<Team> ret = new ArrayList<Team>(); |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
7107
diff
changeset
|
186 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
7107
diff
changeset
|
187 |
File teamsDir = new File(c.getFilesDir(), Team.DIRECTORY_TEAMS); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
188 |
File[] teamFileNames = teamsDir.listFiles(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
189 |
if(teamFileNames != null){ |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
7107
diff
changeset
|
190 |
for(File file : teamFileNames){ |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
191 |
if(file.getName().endsWith(".hwt")) { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
192 |
Team team = Team.load(file); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
193 |
if(team != null){ |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
194 |
ret.add(team); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
195 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
196 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
197 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
198 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
199 |
return ret; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
200 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
201 |
} |