summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/TextureDecoder.java
blob: b63be422bb3b18bb24baf39a1fd954f8faae1e92 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*     */ 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
/*     */ {
/*  36 */   protected static Hashtable<String, TextureDecoder> handlers = new Hashtable();
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static TextureDecoder defaultDecoder;
/*     */   
/*     */ 
/*     */ 
/*     */   private static String allExts;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   static
/*     */   {
/*  52 */     addHandler(defaultDecoder = new FileTextureDecoder());
/*  53 */     addHandler(new StandardTextureDecoder());
/*  54 */     addHandler(new ScapePicTextureDecoder());
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected abstract String getExts();
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   protected abstract Texture read(String paramString1, String paramString2);
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static void addHandler(TextureDecoder decoder)
/*     */   {
/*  72 */     StringTokenizer e = new StringTokenizer(decoder.getExts(), ";");
/*  73 */     while (e.hasMoreTokens()) {
/*  74 */       String ext = e.nextToken().toLowerCase();
/*  75 */       handlers.put(ext, decoder);
/*  76 */       if (allExts == null) {
/*  77 */         allExts = ext;
/*     */       } else {
/*  79 */         allExts = allExts + File.pathSeparator + ext;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public static String getAllExts() {
/*  85 */     return allExts;
/*     */   }
/*     */   
/*     */   public static String getJavaExts()
/*     */   {
/*  90 */     return new StandardTextureDecoder().getExts();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static Texture decode(URL url, String filename)
/*     */   {
/*  99 */     return decode(url, url.getAbsolute(), filename);
/*     */   }
/*     */   
/*     */ 
/*     */   public static Texture decode(URL url, String lookupName, String filename)
/*     */   {
/* 105 */     Texture tex = FileTexture.dictLookup(lookupName);
/* 106 */     if (tex != null) {
/* 107 */       return tex;
/*     */     }
/* 109 */     String urlName = url.getInternal();
/*     */     
/*     */ 
/* 112 */     int delim = urlName.lastIndexOf('.');
/* 113 */     int lastPath = urlName.lastIndexOf('/');
/* 114 */     lastPath = Math.max(lastPath, urlName.lastIndexOf('\\'));
/* 115 */     lastPath = Math.max(lastPath, urlName.lastIndexOf(':'));
/* 116 */     if (delim > lastPath) {
/* 117 */       String ext = urlName.substring(delim + 1).toLowerCase();
/* 118 */       TextureDecoder decoder = (TextureDecoder)handlers.get(ext);
/* 119 */       if (decoder != null) {
/* 120 */         Texture t = decoder.read(lookupName, filename);
/* 121 */         if (t.textureID != 0)
/* 122 */           return t;
/*     */       }
/*     */     }
/* 125 */     return null;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\TextureDecoder.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */