summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/TextureDecoder.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/TextureDecoder.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/TextureDecoder.java')
-rw-r--r--NET/worlds/scape/TextureDecoder.java133
1 files changed, 133 insertions, 0 deletions
diff --git a/NET/worlds/scape/TextureDecoder.java b/NET/worlds/scape/TextureDecoder.java
new file mode 100644
index 0000000..b63be42
--- /dev/null
+++ b/NET/worlds/scape/TextureDecoder.java
@@ -0,0 +1,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
+ */ \ No newline at end of file