/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.network.URL; /* */ import NET.worlds.scape.BGLoaded; /* */ import NET.worlds.scape.BackgroundLoader; /* */ import NET.worlds.scape.NoSuchPropertyException; /* */ import NET.worlds.scape.Pilot; /* */ import NET.worlds.scape.Property; /* */ import NET.worlds.scape.Restorer; /* */ import NET.worlds.scape.Room; /* */ import NET.worlds.scape.Saver; /* */ import NET.worlds.scape.SuperRoot; /* */ import NET.worlds.scape.TooNewException; /* */ import NET.worlds.scape.URLPropertyEditor; /* */ import java.io.IOException; /* */ import java.text.MessageFormat; /* */ import java.util.Enumeration; /* */ import java.util.Hashtable; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class Cursor /* */ extends SuperRoot /* */ implements BGLoaded /* */ { /* 44 */ private URL url = URL.make("system:DEFAULT_CURSOR"); /* */ /* */ /* */ /* */ private int hCursor; /* */ /* */ /* */ /* */ private static Cursor active; /* */ /* */ /* */ /* */ private static Hashtable sysCursors; /* */ /* */ /* */ private static int defaultCursor; /* */ /* */ /* */ /* */ private static URL addCursor(String javaName, String win32Name) /* */ { /* 65 */ URL url = URL.make("system:" + javaName); /* 66 */ sysCursors.put(url, win32Name); /* 67 */ return url; /* */ } /* */ /* */ static /* */ { /* 54 */ sysCursors = new Hashtable(); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 72 */ defaultCursor = retrieveSystemCursor(addCursor("DEFAULT_CURSOR", /* 73 */ "IDC_ARROW")); /* 74 */ assert (defaultCursor != 0); /* */ /* 76 */ addCursor("CROSSHAIR_CURSOR", "IDC_CROSS"); /* 77 */ addCursor("TEXT_CURSOR", "IDC_IBEAM"); /* 78 */ addCursor("WAIT_CURSOR", "IDC_WAIT"); /* 79 */ addCursor("NE_RESIZE_CURSOR", "IDC_SIZENESW"); /* 80 */ addCursor("SW_RESIZE_CURSOR", "IDC_SIZENESW"); /* 81 */ addCursor("NW_RESIZE_CURSOR", "IDC_SIZENWSE"); /* 82 */ addCursor("SE_RESIZE_CURSOR", "IDC_SIZENWSE"); /* 83 */ addCursor("N_RESIZE_CURSOR", "IDC_SIZENS"); /* 84 */ addCursor("S_RESIZE_CURSOR", "IDC_SIZENS"); /* 85 */ addCursor("W_RESIZE_CURSOR", "IDC_SIZEWE"); /* 86 */ addCursor("E_RESIZE_CURSOR", "IDC_SIZEWE"); /* 87 */ addCursor("HAND_CURSOR", "IDC_UPARROW"); /* 88 */ addCursor("MOVE_CURSOR", "IDC_SIZEALL"); /* 89 */ addCursor("CANNOT_CURSOR", "IDC_NO"); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Cursor(URL url) /* */ { /* 113 */ setURL(url); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void setURL(URL url) /* */ { /* 124 */ this.url = url; /* 125 */ if (!url.unalias().startsWith("system:")) { /* 126 */ BackgroundLoader.get(this, url); /* */ } else { /* 128 */ activate(); /* */ } /* */ } /* */ /* */ public static Cursor getActive() { /* 133 */ return active; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void activate() /* */ { /* 142 */ SuperRoot owner = getOwner(); /* */ /* 144 */ if ((owner != null) && (owner == Console.getActive())) { /* 145 */ int sysCurs = retrieveSystemCursor(this.url); /* */ /* 147 */ if (sysCurs != 0) { /* 148 */ Window.setCursor(sysCurs); /* 149 */ maybeDestroyCursor(); /* 150 */ this.hCursor = sysCurs; /* 151 */ } else if (this.hCursor != 0) { /* 152 */ Window.setCursor(this.hCursor); /* */ } /* */ /* 155 */ active = this; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void deactivate() /* */ { /* 165 */ if (active == this) /* */ { /* */ /* */ /* 169 */ active = null; /* */ } /* */ } /* */ /* */ /* */ /* */ public URL getURL() /* */ { /* 177 */ return this.url; /* */ } /* */ /* */ public static Enumeration getSysCursorURLs() /* */ { /* 182 */ return sysCursors.keys(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static int retrieveSystemCursor(URL url) /* */ { /* 208 */ int handle = 0; /* 209 */ Object c = sysCursors.get(url); /* 210 */ if (c != null) /* 211 */ if ((c instanceof String)) { /* 212 */ handle = loadSystemCursor((String)c); /* 213 */ sysCursors.put(url, new Integer(handle)); /* */ } else { /* 215 */ handle = ((Integer)c).intValue(); /* */ } /* 217 */ return handle; /* */ } /* */ /* */ private void maybeDestroyCursor() /* */ { /* 222 */ if (this.hCursor != 0) { /* 223 */ if (!sysCursors.contains(new Integer(this.hCursor))) /* 224 */ destroyCursor(this.hCursor); /* 225 */ this.hCursor = 0; /* */ } /* */ } /* */ /* */ /* */ public Object asyncBackgroundLoad(String localName, URL remoteName) /* */ { /* 232 */ deactivate(); /* 233 */ maybeDestroyCursor(); /* */ /* */ /* 236 */ if (localName == null) { /* 237 */ return null; /* */ } /* 239 */ if ((this.hCursor = loadCursor(localName)) != 0) /* 240 */ activate(); /* 241 */ return null; /* */ } /* */ /* */ public boolean syncBackgroundLoad(Object obj, URL remoteURL) { /* 245 */ if (this.hCursor == 0) { /* 246 */ Object[] arguments = { new String(this.url) }; /* 247 */ Console.println(MessageFormat.format( /* 248 */ Console.message("Load-cursor"), arguments)); /* */ } /* 250 */ return false; /* */ } /* */ /* */ public Room getBackgroundLoadRoom() { /* 254 */ SuperRoot owner = getOwner(); /* 255 */ if ((owner == null) || (!(owner instanceof Console))) { /* 256 */ return null; /* */ } /* 258 */ return ((Console)owner).getPilot().getRoom(); /* */ } /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 266 */ Object ret = null; /* */ /* 268 */ switch (index - offset) { /* */ case 0: /* 270 */ if (mode == 0) { /* 271 */ ret = URLPropertyEditor.make(new Property(this, index, "File"), /* 272 */ "cur;ani", getSysCursorURLs()); /* 273 */ } else if (mode == 1) { /* 274 */ ret = getURL(); /* 275 */ } else if (mode == 2) /* 276 */ setURL((URL)value); /* 277 */ break; /* */ /* */ default: /* 280 */ ret = super.properties(index, offset + 1, mode, value); /* */ } /* 282 */ return ret; /* */ } /* */ /* */ /* */ /* 287 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 291 */ s.saveVersion(1, classCookie); /* 292 */ super.saveState(s); /* */ /* 294 */ URL.save(s, this.url); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 299 */ switch (r.restoreVersion(classCookie)) { /* */ case 0: /* 301 */ r.restoreMaybeNull(); /* */ /* */ /* 304 */ String s = r.restoreString(); /* 305 */ if ((s.endsWith(".cur")) || (s.endsWith(".ani"))) { /* 306 */ setURL(URL.restore(r, s, null)); /* */ } else { /* 308 */ setURL(URL.make("system:" + this.url)); /* */ } /* 310 */ break; /* */ /* */ case 1: /* 313 */ super.restoreState(r); /* 314 */ setURL(URL.restore(r)); /* 315 */ break; /* */ /* */ default: /* 318 */ throw new TooNewException(); /* */ } /* */ } /* */ /* */ public Cursor() {} /* */ /* */ public static native int getSystemCursorWidth(); /* */ /* */ public static native int getSystemCursorHeight(); /* */ /* */ public static native int getSystemCursorDepth(); /* */ /* */ private static native int loadCursor(String paramString); /* */ /* */ private static native int loadSystemCursor(String paramString); /* */ /* */ private static native void destroyCursor(int paramInt); /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\Cursor.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */