blob: 42477dba0c7d656cd3e8dd4c52e0399895ca5497 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package NET.worlds.scape;
import NET.worlds.network.URL;
import java.io.File;
import java.util.Hashtable;
import java.util.StringTokenizer;
public abstract class TextureDecoder {
protected static Hashtable handlers = new Hashtable();
private static TextureDecoder defaultDecoder;
private static String allExts;
static {
addHandler(defaultDecoder = new FileTextureDecoder());
addHandler(new StandardTextureDecoder());
addHandler(new ScapePicTextureDecoder());
}
protected abstract String getExts();
protected abstract Texture read(String var1, String var2);
private static void addHandler(TextureDecoder decoder) {
StringTokenizer e = new StringTokenizer(decoder.getExts(), ";");
while (e.hasMoreTokens()) {
String ext = e.nextToken().toLowerCase();
handlers.put(ext, decoder);
if (allExts == null) {
allExts = ext;
} else {
allExts = allExts + File.pathSeparator + ext;
}
}
}
public static String getAllExts() {
return allExts;
}
public static String getJavaExts() {
return new StandardTextureDecoder().getExts();
}
public static Texture decode(URL url, String filename) {
return decode(url, url.getAbsolute(), filename);
}
public static Texture decode(URL url, String lookupName, String filename) {
Texture tex = FileTexture.dictLookup(lookupName);
if (tex != null) {
return tex;
} else {
String urlName = url.getInternal();
int delim = urlName.lastIndexOf(46);
int lastPath = urlName.lastIndexOf(47);
lastPath = Math.max(lastPath, urlName.lastIndexOf(92));
lastPath = Math.max(lastPath, urlName.lastIndexOf(58));
if (delim > lastPath) {
String ext = urlName.substring(delim + 1).toLowerCase();
TextureDecoder decoder = (TextureDecoder)handlers.get(ext);
if (decoder != null) {
Texture t = decoder.read(lookupName, filename);
if (t.textureID != 0) {
return t;
}
}
}
return null;
}
}
}
|