/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.scape.CDAudio; /* */ import java.awt.Dimension; /* */ import java.awt.Rectangle; /* */ import java.io.IOException; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class RealG2 /* */ implements Runnable, MainCallback, MainTerminalCallback /* */ { /* 51 */ private static RealG2 instance = new RealG2(); /* */ private Thread realThread; /* */ /* */ public class RG2Request /* */ { /* 56 */ private String url = null; /* 57 */ private Rectangle position = null; /* */ /* */ public RG2Request(String u, Rectangle r) { /* 60 */ this.url = u; /* 61 */ this.position = r; /* */ } /* */ /* */ public Rectangle getPosition() { /* 65 */ return this.position; /* */ } /* */ /* */ public String getURL() { /* 69 */ return this.url; /* */ } /* */ } /* */ /* */ /* */ /* */ /* 76 */ private Vector requestList = new Vector(2, 1); /* */ /* */ private boolean cancel; /* */ /* */ private RealG2() /* */ { /* 82 */ this.realThread = new Thread(this); /* 83 */ this.realThread.start(); /* */ } /* */ /* */ public static RealG2 get() { /* 87 */ return instance; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void run() /* */ { /* 98 */ boolean initerror = false; /* 99 */ this.cancel = false; /* 100 */ Main.register(this); /* */ /* 102 */ while (!this.cancel) { /* 103 */ if (!this.requestList.isEmpty()) /* 104 */ CDAudio.get().setEnabled(false); /* 105 */ while (!this.requestList.isEmpty()) { /* 106 */ startPlaying(); /* */ try { /* 108 */ initRealG2(); /* */ } catch (IOException ie) { /* 110 */ this.cancel = true; /* 111 */ initerror = true; /* */ } /* 113 */ while (!this.requestList.isEmpty()) { /* 114 */ RG2Request request = /* 115 */ (RG2Request)this.requestList.firstElement(); /* 116 */ this.requestList.removeElementAt(0); /* */ try { /* 118 */ browse(request.getURL(), request.getPosition()); /* */ } /* */ catch (IOException localIOException1) {} /* */ } /* 122 */ if (!initerror) /* 123 */ closeRealG2(); /* 124 */ stopPlaying(); /* 125 */ if (this.requestList.isEmpty()) /* 126 */ CDAudio.get().setEnabled(true); /* */ } /* 128 */ if (!this.cancel) /* 129 */ timedWait(15); /* */ } /* 131 */ Main.unregister(this); /* */ } /* */ /* */ private synchronized void timedWait(int secs) /* */ { /* 136 */ if (!this.cancel) { /* */ try { /* 138 */ wait(secs * 1000); /* */ } /* */ catch (InterruptedException localInterruptedException) {} /* */ } /* */ } /* */ /* */ /* */ /* 146 */ private boolean isPlaying = false; /* */ /* */ private synchronized void startPlaying() { /* 149 */ this.isPlaying = true; /* */ } /* */ /* */ private synchronized void stopPlaying() { /* 153 */ this.isPlaying = false; /* */ } /* */ /* */ public synchronized boolean playing() { /* 157 */ return this.isPlaying; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void pleaseStopNow() /* */ { /* 166 */ if (playing()) { /* 167 */ setPlayInterrupt(); /* 168 */ while (playing()) { /* */ try { /* 170 */ wait(500L); /* */ } /* */ catch (InterruptedException localInterruptedException) {} /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public void pleaseStop() /* */ { /* 182 */ setPlayInterrupt(); /* */ } /* */ /* */ public static boolean isInstalled() /* */ { /* 187 */ IniFile ini = new IniFile("RealPlayer"); /* 188 */ return ini.getIniInt("HasReal", 0) != 0; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void play(String urlin) /* */ throws IOException /* */ { /* 200 */ play(urlin, null); /* */ } /* */ /* */ /* */ /* */ public void play(String urlin, Rectangle placementin) /* */ throws IOException /* */ { /* 208 */ if (!isInstalled()) { /* 209 */ throw new IOException(); /* */ } /* 211 */ RG2Request r = new RG2Request(urlin, placementin); /* 212 */ this.requestList.addElement(r); /* 213 */ setPlayInterrupt(); /* 214 */ this.realThread.interrupt(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private Rectangle getAdPartPlacement() /* */ { /* 242 */ Rectangle placement = null; /* */ /* 244 */ Console c = Console.getActive(); /* 245 */ if (c != null) { /* 246 */ AdPart ap = null; /* 247 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 248 */ Object o = e.nextElement(); /* 249 */ if ((o instanceof AdPart)) { /* 250 */ ap = (AdPart)o; /* 251 */ break; /* */ } /* */ } /* 254 */ if (ap != null) { /* 255 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 256 */ new Dimension(ap.getWindow().fullWidth(), ap /* 257 */ .getWindow().fullHeight())); /* */ } /* */ } /* 260 */ return placement; /* */ } /* */ /* */ /* */ /* */ /* */ private Rectangle getMapPartPlacement() /* */ { /* 268 */ Rectangle placement = null; /* */ /* 270 */ Console c = Console.getActive(); /* 271 */ if (c != null) { /* 272 */ MapPart ap = null; /* 273 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 274 */ Object o = e.nextElement(); /* 275 */ if ((o instanceof MapPart)) { /* 276 */ ap = (MapPart)o; /* 277 */ break; /* */ } /* */ } /* 280 */ if (ap != null) { /* 281 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 282 */ ap.getSize()); /* */ } /* */ } /* 285 */ return placement; /* */ } /* */ /* */ /* */ /* */ /* */ public void browse(String url, Rectangle placement) /* */ throws IOException /* */ { /* 294 */ int x = -1; /* 295 */ int y = -1; /* 296 */ int w = -1; /* 297 */ int h = -1; /* */ /* 299 */ if (placement != null) { /* 300 */ x = placement.x; /* 301 */ y = placement.y; /* 302 */ w = placement.width; /* 303 */ h = placement.height; /* 304 */ } else if ((placement = getMapPartPlacement()) != null) { /* 305 */ x = placement.x - 18; /* 306 */ y = placement.y - 34; /* 307 */ w = placement.width; /* 308 */ h = placement.height; /* */ } /* */ try /* */ { /* 312 */ browse(url, x, y, w, h); /* */ } catch (IOException ioe) { /* 314 */ close(); /* 315 */ throw ioe; /* */ } /* */ } /* */ /* */ /* */ /* */ public void mainCallback() {} /* */ /* */ /* */ /* */ public void terminalCallback() /* */ { /* 327 */ close(); /* */ } /* */ /* */ /* */ /* */ public void close() /* */ { /* 334 */ this.cancel = true; /* 335 */ playInterrupt(); /* 336 */ this.realThread.interrupt(); /* */ } /* */ /* */ /* */ /* */ private static native void browse(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4) /* */ throws IOException; /* */ /* */ /* */ /* */ private static native void initRealG2() /* */ throws IOException; /* */ /* */ /* */ /* */ private static native void closeRealG2(); /* */ /* */ /* */ /* */ private static native void playInterrupt(); /* */ /* */ /* */ public synchronized void setPlayInterrupt() /* */ { /* 360 */ if (playing()) { /* 361 */ playInterrupt(); /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\RealG2.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */