/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.network.URL; /* */ import java.io.IOException; /* */ import java.util.StringTokenizer; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ClickSensor /* */ extends Sensor /* */ implements MouseDownHandler, MouseUpHandler, BGLoaded /* */ { /* */ private static final int clickTime = 750; /* */ public static final int CENTER = 4; /* */ public static final int RIGHT = 2; /* */ public static final int LEFT = 1; /* */ public static final int ANY = 7; /* 73 */ protected long mouseDownTime = 0L; /* 74 */ protected int keyToCheck = 1; /* 75 */ protected boolean waitForUp = false; /* 76 */ protected URL config = null; /* */ /* */ transient int width; /* */ /* */ transient int height; /* */ transient Area[] configTable; /* */ /* */ public ClickSensor(Action a, char whichButton) /* */ { /* 85 */ this(a, whichButton); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public ClickSensor(Action a, int whichButton) /* */ { /* 97 */ this.keyToCheck = (whichButton & 0x7); /* 98 */ if (a != null) { /* 99 */ addAction(a); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public ClickSensor(Action a) /* */ { /* 108 */ this(a, 7); /* */ } /* */ /* */ /* */ /* */ public ClickSensor() {} /* */ /* */ /* */ public int getWhichButton() /* */ { /* 118 */ return this.keyToCheck; /* */ } /* */ /* */ public boolean getWaitForUp() { /* 122 */ return this.waitForUp; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void setWhichButton(int which) /* */ { /* 131 */ assert ((which >= 0) && (which <= 7)); /* 132 */ this.keyToCheck = which; /* */ } /* */ /* */ /* */ /* */ public void setWaitForUp(boolean wait) /* */ { /* 139 */ this.waitForUp = wait; /* */ } /* */ /* */ /* */ /* */ /* */ public boolean handle(MouseDownEvent e) /* */ { /* 147 */ if ((this.keyToCheck == 7) || ((e.key & this.keyToCheck) != 0)) { /* 148 */ if (this.waitForUp) { /* 149 */ this.mouseDownTime = System.currentTimeMillis(); /* */ } else /* 151 */ trigger(e); /* */ } /* 153 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ public boolean handle(MouseUpEvent e) /* */ { /* 161 */ if ((this.waitForUp) && /* 162 */ ((this.keyToCheck == 7) || ((e.key & this.keyToCheck) != 0)) && /* 163 */ (System.currentTimeMillis() - this.mouseDownTime < 750L)) { /* 164 */ trigger(e); /* */ } /* */ /* */ /* 168 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void triggerAction(String actionNamePrefix, Vector props, Event event) /* */ { /* 185 */ int len = this.actions.size(); /* 186 */ for (int i = 0; i < len; i++) { /* 187 */ Action a = (Action)this.actions.elementAt(i); /* */ /* 189 */ if (a.getName().regionMatches(0, actionNamePrefix, 0, actionNamePrefix.length())) /* */ { /* 191 */ len = props.size(); /* 192 */ for (i = 0; i < len; i += 2) { /* 193 */ String prop = (String)props.elementAt(i); /* 194 */ String val = (String)props.elementAt(i + 1); /* 195 */ SetPropertyAction.propHelper(2, val, prop, a); /* */ } /* */ /* 198 */ RunningActionHandler.trigger(a, getWorld(), event); /* 199 */ return; /* */ } /* */ } /* */ } /* */ /* */ /* */ public void trigger(Event event) /* */ { /* 207 */ if ((this.configTable != null) && ((getOwner() instanceof WObject))) { /* 208 */ WObject w = (WObject)getOwner(); /* 209 */ Transform t = w.getObjectToWorldMatrix().invert(); /* */ /* */ /* 212 */ Point3Temp p = Point3Temp.make(Camera.downAt).times(t); /* 213 */ p.x *= this.width; /* 214 */ p.z *= this.height; /* */ /* */ /* 217 */ for (int i = 0; i < this.configTable.length; i++) { /* 218 */ Area a = this.configTable[i]; /* 219 */ if ((p.x > a.x) && (p.z > a.y) && (p.x - a.x < a.w) && /* 220 */ (p.z - a.y < a.h)) /* */ { /* 222 */ triggerAction(a.actionNamePrefix, a.props, event); /* */ } /* */ } /* */ /* 226 */ t.recycle(); /* */ } else { /* 228 */ super.trigger(event); /* */ } /* */ } /* */ /* */ /* */ public Object asyncBackgroundLoad(String localName, URL remoteURL) /* */ { /* 235 */ return localName; /* */ } /* */ /* */ public boolean syncBackgroundLoad(Object obj, URL remoteURL) /* */ { /* 240 */ if (obj != null) /* 241 */ loadConfig((String)obj); /* 242 */ return false; /* */ } /* */ /* */ public Room getBackgroundLoadRoom() /* */ { /* 247 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static String getString(StringTokenizer st) /* */ { /* 256 */ String s = st.nextToken(); /* 257 */ if ((s.length() > 0) && (s.charAt(0) == '"')) { /* 258 */ StringBuffer sb = new StringBuffer(s.substring(1)); /* 259 */ while (sb.charAt(sb.length() - 1) != '"') { /* 260 */ sb.append(" "); /* 261 */ sb.append(st.nextToken()); /* */ } /* 263 */ sb.setLength(sb.length() - 1); /* 264 */ s = sb.toString(); /* */ } /* 266 */ return s; /* */ } /* */ /* */ /* Error */ /* */ public void loadConfig(String name) /* */ { /* */ // Byte code: /* */ // 0: aconst_null /* */ // 1: astore_2 /* */ // 2: aconst_null /* */ // 3: astore_3 /* */ // 4: iconst_1 /* */ // 5: istore 4 /* */ // 7: new 303 java/io/DataInputStream /* */ // 10: dup /* */ // 11: new 305 java/io/FileInputStream /* */ // 14: dup /* */ // 15: aload_1 /* */ // 16: invokespecial 307 java/io/FileInputStream: (Ljava/lang/String;)V /* */ // 19: invokespecial 308 java/io/DataInputStream: (Ljava/io/InputStream;)V /* */ // 22: astore_3 /* */ // 23: new 268 java/util/StringTokenizer /* */ // 26: dup /* */ // 27: aload_3 /* */ // 28: invokevirtual 311 java/io/DataInputStream:readLine ()Ljava/lang/String; /* */ // 31: invokespecial 314 java/util/StringTokenizer: (Ljava/lang/String;)V /* */ // 34: astore 5 /* */ // 36: aload 5 /* */ // 38: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 41: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 44: istore 6 /* */ // 46: aload_0 /* */ // 47: aload 5 /* */ // 49: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 52: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 55: putfield 214 NET/worlds/scape/ClickSensor:width I /* */ // 58: aload_0 /* */ // 59: aload 5 /* */ // 61: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 64: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 67: putfield 219 NET/worlds/scape/ClickSensor:height I /* */ // 70: iload 6 /* */ // 72: anewarray 222 NET/worlds/scape/ClickSensor$Area /* */ // 75: astore_2 /* */ // 76: iconst_0 /* */ // 77: istore 7 /* */ // 79: goto +147 -> 226 /* */ // 82: new 222 NET/worlds/scape/ClickSensor$Area /* */ // 85: dup /* */ // 86: aload_0 /* */ // 87: invokespecial 321 NET/worlds/scape/ClickSensor$Area: (LNET/worlds/scape/ClickSensor;)V /* */ // 90: astore 8 /* */ // 92: iinc 4 1 /* */ // 95: new 268 java/util/StringTokenizer /* */ // 98: dup /* */ // 99: aload_3 /* */ // 100: invokevirtual 311 java/io/DataInputStream:readLine ()Ljava/lang/String; /* */ // 103: invokespecial 314 java/util/StringTokenizer: (Ljava/lang/String;)V /* */ // 106: astore 5 /* */ // 108: aload 8 /* */ // 110: aload 5 /* */ // 112: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 115: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 118: putfield 221 NET/worlds/scape/ClickSensor$Area:x I /* */ // 121: aload 8 /* */ // 123: aload 5 /* */ // 125: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 128: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 131: putfield 225 NET/worlds/scape/ClickSensor$Area:y I /* */ // 134: aload 8 /* */ // 136: aload 5 /* */ // 138: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 141: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 144: putfield 228 NET/worlds/scape/ClickSensor$Area:w I /* */ // 147: aload 8 /* */ // 149: aload 5 /* */ // 151: invokevirtual 267 java/util/StringTokenizer:nextToken ()Ljava/lang/String; /* */ // 154: invokestatic 315 java/lang/Integer:parseInt (Ljava/lang/String;)I /* */ // 157: putfield 231 NET/worlds/scape/ClickSensor$Area:h I /* */ // 160: aload 8 /* */ // 162: aload 5 /* */ // 164: invokestatic 324 NET/worlds/scape/ClickSensor:getString (Ljava/util/StringTokenizer;)Ljava/lang/String; /* */ // 167: putfield 234 NET/worlds/scape/ClickSensor$Area:actionNamePrefix Ljava/lang/String; /* */ // 170: new 130 java/util/Vector /* */ // 173: dup /* */ // 174: invokespecial 326 java/util/Vector: ()V /* */ // 177: astore 9 /* */ // 179: goto +23 -> 202 /* */ // 182: aload 9 /* */ // 184: aload 5 /* */ // 186: invokestatic 324 NET/worlds/scape/ClickSensor:getString (Ljava/util/StringTokenizer;)Ljava/lang/String; /* */ // 189: invokevirtual 327 java/util/Vector:addElement (Ljava/lang/Object;)V /* */ // 192: aload 9 /* */ // 194: aload 5 /* */ // 196: invokestatic 324 NET/worlds/scape/ClickSensor:getString (Ljava/util/StringTokenizer;)Ljava/lang/String; /* */ // 199: invokevirtual 327 java/util/Vector:addElement (Ljava/lang/Object;)V /* */ // 202: aload 5 /* */ // 204: invokevirtual 331 java/util/StringTokenizer:hasMoreTokens ()Z /* */ // 207: ifne -25 -> 182 /* */ // 210: aload 8 /* */ // 212: aload 9 /* */ // 214: putfield 236 NET/worlds/scape/ClickSensor$Area:props Ljava/util/Vector; /* */ // 217: aload_2 /* */ // 218: iload 7 /* */ // 220: aload 8 /* */ // 222: aastore /* */ // 223: iinc 7 1 /* */ // 226: iload 7 /* */ // 228: iload 6 /* */ // 230: if_icmplt -148 -> 82 /* */ // 233: aload_0 /* */ // 234: aload_2 /* */ // 235: putfield 177 NET/worlds/scape/ClickSensor:configTable [LNET/worlds/scape/ClickSensor$Area; /* */ // 238: goto +95 -> 333 /* */ // 241: astore 5 /* */ // 243: iconst_2 /* */ // 244: anewarray 48 java/lang/Object /* */ // 247: dup /* */ // 248: iconst_0 /* */ // 249: new 143 java/lang/String /* */ // 252: dup /* */ // 253: aload_1 /* */ // 254: invokespecial 334 java/lang/String: (Ljava/lang/String;)V /* */ // 257: aastore /* */ // 258: dup /* */ // 259: iconst_1 /* */ // 260: new 143 java/lang/String /* */ // 263: dup /* */ // 264: new 335 java/lang/StringBuilder /* */ // 267: dup /* */ // 268: invokespecial 337 java/lang/StringBuilder: ()V /* */ // 271: iload 4 /* */ // 273: invokevirtual 338 java/lang/StringBuilder:append (I)Ljava/lang/StringBuilder; /* */ // 276: invokevirtual 341 java/lang/StringBuilder:toString ()Ljava/lang/String; /* */ // 279: invokespecial 334 java/lang/String: (Ljava/lang/String;)V /* */ // 282: aastore /* */ // 283: astore 6 /* */ // 285: ldc_w 342 /* */ // 288: invokestatic 344 NET/worlds/console/Console:message (Ljava/lang/String;)Ljava/lang/String; /* */ // 291: aload 6 /* */ // 293: invokestatic 350 java/text/MessageFormat:format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String; /* */ // 296: invokestatic 356 NET/worlds/console/Console:println (Ljava/lang/String;)V /* */ // 299: aload_3 /* */ // 300: ifnull +46 -> 346 /* */ // 303: aload_3 /* */ // 304: invokevirtual 359 java/io/DataInputStream:close ()V /* */ // 307: goto +39 -> 346 /* */ // 310: astore 11 /* */ // 312: goto +34 -> 346 /* */ // 315: astore 10 /* */ // 317: aload_3 /* */ // 318: ifnull +12 -> 330 /* */ // 321: aload_3 /* */ // 322: invokevirtual 359 java/io/DataInputStream:close ()V /* */ // 325: goto +5 -> 330 /* */ // 328: astore 11 /* */ // 330: aload 10 /* */ // 332: athrow /* */ // 333: aload_3 /* */ // 334: ifnull +12 -> 346 /* */ // 337: aload_3 /* */ // 338: invokevirtual 359 java/io/DataInputStream:close ()V /* */ // 341: goto +5 -> 346 /* */ // 344: astore 11 /* */ // 346: return /* */ // Line number table: /* */ // Java source line #273 -> byte code offset #0 /* */ // Java source line #275 -> byte code offset #2 /* */ // Java source line #276 -> byte code offset #4 /* */ // Java source line #278 -> byte code offset #7 /* */ // Java source line #279 -> byte code offset #23 /* */ // Java source line #280 -> byte code offset #36 /* */ // Java source line #281 -> byte code offset #46 /* */ // Java source line #282 -> byte code offset #58 /* */ // Java source line #284 -> byte code offset #70 /* */ // Java source line #286 -> byte code offset #76 /* */ // Java source line #287 -> byte code offset #82 /* */ // Java source line #289 -> byte code offset #92 /* */ // Java source line #290 -> byte code offset #95 /* */ // Java source line #291 -> byte code offset #108 /* */ // Java source line #292 -> byte code offset #121 /* */ // Java source line #293 -> byte code offset #134 /* */ // Java source line #294 -> byte code offset #147 /* */ // Java source line #296 -> byte code offset #160 /* */ // Java source line #297 -> byte code offset #170 /* */ // Java source line #298 -> byte code offset #179 /* */ // Java source line #299 -> byte code offset #182 /* */ // Java source line #300 -> byte code offset #192 /* */ // Java source line #298 -> byte code offset #202 /* */ // Java source line #302 -> byte code offset #210 /* */ // Java source line #303 -> byte code offset #217 /* */ // Java source line #286 -> byte code offset #223 /* */ // Java source line #305 -> byte code offset #233 /* */ // Java source line #306 -> byte code offset #238 /* */ // Java source line #307 -> byte code offset #243 /* */ // Java source line #309 -> byte code offset #285 /* */ // Java source line #308 -> byte code offset #293 /* */ // Java source line #312 -> byte code offset #299 /* */ // Java source line #313 -> byte code offset #303 /* */ // Java source line #314 -> byte code offset #307 /* */ // Java source line #310 -> byte code offset #315 /* */ // Java source line #312 -> byte code offset #317 /* */ // Java source line #313 -> byte code offset #321 /* */ // Java source line #314 -> byte code offset #325 /* */ // Java source line #316 -> byte code offset #330 /* */ // Java source line #312 -> byte code offset #333 /* */ // Java source line #313 -> byte code offset #337 /* */ // Java source line #314 -> byte code offset #341 /* */ // Java source line #317 -> byte code offset #346 /* */ // Local variable table: /* */ // start length slot name signature /* */ // 0 347 0 this ClickSensor /* */ // 0 347 1 name String /* */ // 1 234 2 result Area[] /* */ // 3 335 3 in java.io.DataInputStream /* */ // 5 267 4 line int /* */ // 34 169 5 st StringTokenizer /* */ // 241 3 5 e Exception /* */ // 44 185 6 numLines int /* */ // 283 9 6 arguments Object[] /* */ // 77 150 7 i int /* */ // 90 131 8 a Area /* */ // 177 36 9 props Vector /* */ // 315 16 10 localObject Object /* */ // 310 1 11 localIOException IOException /* */ // 328 1 11 localIOException1 IOException /* */ // 344 1 11 localIOException2 IOException /* */ // Exception table: /* */ // from to target type /* */ // 7 238 241 java/lang/Exception /* */ // 299 307 310 java/io/IOException /* */ // 7 299 315 finally /* */ // 317 325 328 java/io/IOException /* */ // 333 341 344 java/io/IOException /* */ } /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 328 */ Object ret = null; /* 329 */ switch (index - offset) { /* */ case 0: /* 331 */ if (mode == 0) { /* 332 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 333 */ "Left Button"), "No", "Yes"); /* 334 */ } else if (mode == 1) { /* 335 */ ret = new Boolean((this.keyToCheck & 0x1) != 0); /* 336 */ } else if (mode == 2) { /* 337 */ if (((Boolean)value).booleanValue()) { /* 338 */ this.keyToCheck |= 0x1; /* */ } else /* 340 */ this.keyToCheck &= 0xFFFFFFFE; /* */ } /* 342 */ break; /* */ case 1: /* 344 */ if (mode == 0) { /* 345 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 346 */ "Right Button"), "No", "Yes"); /* 347 */ } else if (mode == 1) { /* 348 */ ret = new Boolean((this.keyToCheck & 0x2) != 0); /* 349 */ } else if (mode == 2) { /* 350 */ if (((Boolean)value).booleanValue()) { /* 351 */ this.keyToCheck |= 0x2; /* */ } else /* 353 */ this.keyToCheck &= 0xFFFFFFFD; /* */ } /* 355 */ break; /* */ case 2: /* 357 */ if (mode == 0) { /* 358 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 359 */ "Center Button"), "No", "Yes"); /* 360 */ } else if (mode == 1) { /* 361 */ ret = new Boolean((this.keyToCheck & 0x4) != 0); /* 362 */ } else if (mode == 2) { /* 363 */ if (((Boolean)value).booleanValue()) { /* 364 */ this.keyToCheck |= 0x4; /* */ } else /* 366 */ this.keyToCheck &= 0xFFFFFFFB; /* */ } /* 368 */ break; /* */ case 3: /* 370 */ if (mode == 0) { /* 371 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 372 */ "Wait for up-click"), "Down", "Up"); /* 373 */ } else if (mode == 1) { /* 374 */ ret = new Boolean(this.waitForUp); /* 375 */ } else if (mode == 2) { /* 376 */ this.waitForUp = ((Boolean)value).booleanValue(); /* */ } /* 378 */ break; /* */ case 4: /* 380 */ if (mode == 0) { /* 381 */ ret = URLPropertyEditor.make(new Property(this, index, /* 382 */ "Config File").allowSetNull(), "clk"); /* 383 */ } else if (mode == 1) { /* 384 */ ret = this.config; /* 385 */ } else if (mode == 2) { /* 386 */ this.config = ((URL)value); /* 387 */ if (this.config != null) { /* 388 */ BackgroundLoader.get(this, this.config); /* */ } else /* 390 */ this.configTable = null; /* */ } /* 392 */ break; /* */ default: /* 394 */ ret = super.properties(index, offset + 5, mode, value); /* */ } /* */ /* 397 */ return ret; /* */ } /* */ /* */ /* */ /* */ /* 403 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 407 */ s.saveVersion(2, classCookie); /* 408 */ super.saveState(s); /* 409 */ s.saveInt(this.keyToCheck); /* 410 */ s.saveBoolean(this.waitForUp); /* 411 */ URL.save(s, this.config); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 416 */ switch (r.restoreVersion(classCookie)) { /* */ case 0: /* 418 */ super.restoreState(r); /* 419 */ this.keyToCheck = ((char)r.restoreInt()); /* 420 */ break; /* */ case 1: /* 422 */ super.restoreState(r); /* 423 */ this.keyToCheck = ((char)r.restoreInt()); /* 424 */ this.waitForUp = r.restoreBoolean(); /* 425 */ break; /* */ case 2: /* 427 */ super.restoreState(r); /* 428 */ this.keyToCheck = ((char)r.restoreInt()); /* 429 */ this.waitForUp = r.restoreBoolean(); /* 430 */ this.config = URL.restore(r); /* 431 */ break; /* */ default: /* 433 */ throw new TooNewException(); /* */ } /* 435 */ if (this.config == null) { /* 436 */ this.configTable = null; /* */ } else { /* 438 */ BackgroundLoader.get(this, this.config); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String toString() /* */ { /* 450 */ String rval = super.toString() + "["; /* 451 */ if ((this.keyToCheck & 0x1) != 0) { /* 452 */ rval = rval + "*"; /* */ } else /* 454 */ rval = rval + " "; /* 455 */ if ((this.keyToCheck & 0x4) != 0) { /* 456 */ rval = rval + "*"; /* */ } else /* 458 */ rval = rval + " "; /* 459 */ if ((this.keyToCheck & 0x2) != 0) { /* 460 */ rval = rval + "*"; /* */ } else /* 462 */ rval = rval + " "; /* 463 */ if (this.waitForUp) { /* 464 */ rval = rval + "u]"; /* */ } else /* 466 */ rval = rval + "d]"; /* 467 */ return rval; /* */ } /* */ /* */ class Area /* */ { /* */ int x; /* */ int y; /* */ int w; /* */ int h; /* */ String actionNamePrefix; /* */ Vector props; /* */ /* */ Area() {} /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ClickSensor.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */