/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.DefaultConsole; /* */ import NET.worlds.console.NoWebControlException; /* */ import NET.worlds.console.OkCancelDialog; /* */ import NET.worlds.console.WebControl; /* */ import NET.worlds.console.WebControlImp; /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.core.Std; /* */ import NET.worlds.network.CacheEntry; /* */ import NET.worlds.network.Galaxy; /* */ import NET.worlds.network.URL; /* */ import java.io.PrintStream; /* */ /* */ /* */ /* */ class WorldScriptToolkitImp /* */ extends WorldScriptToolkit /* */ { /* */ public int getTime() /* */ { /* 23 */ return Std.getSynchronizedTime(); /* */ } /* */ /* */ public void teleport(String destination, boolean showDlg) /* */ { /* 28 */ TeleportAction.teleport(destination, null, false, showDlg); /* */ } /* */ /* */ public float getPilotX() /* */ { /* 33 */ Pilot p = Pilot.getActive(); /* 34 */ if (p != null) /* 35 */ return p.getX(); /* 36 */ return 0.0F; /* */ } /* */ /* */ public float getPilotY() /* */ { /* 41 */ Pilot p = Pilot.getActive(); /* 42 */ if (p != null) /* 43 */ return p.getY(); /* 44 */ return 0.0F; /* */ } /* */ /* */ /* */ public float getPilotYaw() /* */ { /* 50 */ Pilot p = Pilot.getActive(); /* 51 */ if (p != null) /* 52 */ return 360.0F - p.getYaw(); /* 53 */ return 0.0F; /* */ } /* */ /* */ private SmoothDriver getSmoothDriver() /* */ { /* 58 */ Pilot p = Pilot.getActive(); /* 59 */ if ((p != null) && ((p instanceof HoloPilot))) /* */ { /* 61 */ HoloPilot hp = (HoloPilot)p; /* 62 */ return hp.getSmoothDriver(); /* */ } /* 64 */ return null; /* */ } /* */ /* */ public float getWalkFriction() /* */ { /* 69 */ SmoothDriver sd = getSmoothDriver(); /* 70 */ if (sd != null) /* */ { /* 72 */ return sd.getVelocityDamping(); /* */ } /* 74 */ return 0.0F; /* */ } /* */ /* */ public void setWalkFriction(float friction) /* */ { /* 79 */ SmoothDriver sd = getSmoothDriver(); /* 80 */ if (sd != null) /* */ { /* 82 */ sd.setVelocityDamping(friction); /* */ } /* */ } /* */ /* */ public void walkTo(float x, float y, float yaw, float velocity) /* */ { /* 88 */ Pilot p = Pilot.getActive(); /* 89 */ if ((p != null) && ((p instanceof HoloPilot))) /* */ { /* 91 */ HoloPilot hp = (HoloPilot)p; /* 92 */ hp.walkTo(new Point2(x, y), yaw, velocity); /* */ } /* */ } /* */ /* */ public void walkTo(float x, float y, float yaw) /* */ { /* 98 */ Pilot p = Pilot.getActive(); /* 99 */ if ((p != null) && ((p instanceof HoloPilot))) /* */ { /* 101 */ HoloPilot hp = (HoloPilot)p; /* 102 */ hp.walkTo(new Point2(x, y), yaw); /* */ } /* */ } /* */ /* */ /* */ /* */ public void walkTo(WorldScript script, float x, float y, float yaw, float velocity) /* */ { /* 110 */ Pilot p = Pilot.getActive(); /* 111 */ if ((p != null) && ((p instanceof HoloPilot))) /* */ { /* 113 */ HoloPilot hp = (HoloPilot)p; /* 114 */ hp.walkTo(new Point2(x, y), yaw, velocity); /* 115 */ hp.addCallback(script); /* */ } /* */ } /* */ /* */ public void showWebPage(String url) /* */ { /* 121 */ showWebPage(url, 100, 100); /* */ } /* */ /* */ public void showWebPage(String url, int percentW, int percentH) /* */ { /* 126 */ Console c = Console.getActive(); /* 127 */ if ((c != null) && ((c instanceof DefaultConsole))) /* */ { /* 129 */ DefaultConsole dc = (DefaultConsole)c; /* */ try { /* 131 */ WebControl wc = new WebControl(dc.getRender(), /* 132 */ percentW, percentH, true, false, /* 133 */ false); /* 134 */ wc.activate(); /* 135 */ wc.setURL(url); /* */ /* */ } /* */ catch (NoWebControlException e) /* */ { /* 140 */ new SendURLAction(url).doIt(); /* */ } /* */ } /* */ } /* */ /* */ public void showExternalWebPage(String url) /* */ { /* 147 */ new SendURLAction(url).doIt(); /* */ } /* */ /* */ public void showAdBanner(String url, int width, int height) /* */ { /* 152 */ Pilot p = Pilot.getActive(); /* 153 */ if (p != null) /* */ { /* 155 */ World w = p.getWorld(); /* 156 */ if (w != null) /* */ { /* 158 */ w.setHasAdBanner(true); /* 159 */ w.setBannerURL(url); /* 160 */ w.setBannerWidth(width); /* 161 */ w.setBannerHeight(height); /* 162 */ w.setupAdBanner(); /* */ } /* */ } /* */ } /* */ /* */ public Object playSound(String soundFile, int loop) /* */ { /* 169 */ Sound owner = new Sound(URL.make(soundFile)); /* 170 */ SoundPlayer autoSound = null; /* 171 */ if (soundFile.toLowerCase().endsWith(".wav")) /* */ { /* 173 */ autoSound = new WavSoundPlayer(owner); /* */ } /* */ else /* */ { /* 177 */ autoSound = new WMPSoundPlayer(owner); /* */ } /* 179 */ autoSound.start(loop); /* 180 */ return autoSound; /* */ } /* */ /* */ public boolean serviceSound(Object soundPlayer) /* */ { /* 185 */ if (!(soundPlayer instanceof SoundPlayer)) /* */ { /* 187 */ System.out.println("Error - invalid handle passed to serviceSound"); /* 188 */ return false; /* */ } /* */ /* 191 */ SoundPlayer sp = (SoundPlayer)soundPlayer; /* 192 */ return sp.getState() == 0; /* */ } /* */ /* */ public void stopSound(Object soundPlayer) /* */ { /* 197 */ if (!(soundPlayer instanceof SoundPlayer)) /* */ { /* 199 */ System.out.println("Error - invalid handle passed to stopSound"); /* 200 */ return; /* */ } /* */ /* 203 */ SoundPlayer autoSound = (SoundPlayer)soundPlayer; /* */ /* 205 */ autoSound.stop(); /* */ } /* */ /* */ public String expandURLMacros(String urlIn) /* */ { /* 210 */ return WebControlImp.processURL(urlIn); /* */ } /* */ /* */ public int getIniInt(String entry, int defaultVal) /* */ { /* 215 */ return IniFile.gamma().getIniInt(entry, defaultVal); /* */ } /* */ /* */ public String getIniString(String entry, String defaultVal) /* */ { /* 220 */ return IniFile.gamma().getIniString(entry, defaultVal); /* */ } /* */ /* */ public void setIniInt(String entry, int val) /* */ { /* 225 */ IniFile.gamma().setIniInt(entry, val); /* */ } /* */ /* */ public void setIniString(String entry, String val) /* */ { /* 230 */ IniFile.gamma().setIniString(entry, val); /* */ } /* */ /* */ public int getClientVersion() /* */ { /* 235 */ return Std.getVersion(); /* */ } /* */ /* */ public void messageBox(String text, String caption) /* */ { /* 240 */ Console c = Console.getActive(); /* 241 */ if (c == null) { return; /* */ } /* 243 */ new OkCancelDialog(Console.getFrame(), null, caption, /* 244 */ null, Console.message("OK"), text, true); /* */ } /* */ /* */ /* */ public Object yesNoDialog(String text, String caption, String yes, String no, WorldScript callback) /* */ { /* 250 */ Console c = Console.getActive(); /* 251 */ if (c == null) { return null; /* */ } /* 253 */ return new OkCancelDialog(Console.getFrame(), callback, caption, /* 254 */ no, yes, text); /* */ } /* */ /* */ public void printToChat(String text) /* */ { /* 259 */ Console c = Console.getActive(); /* 260 */ if (c == null) return; /* 261 */ Console.println(text); /* */ } /* */ /* */ public boolean watchVisibility(Object obj) /* */ { /* 266 */ if (obj == null) { /* 267 */ return false; /* */ } /* 269 */ if (!(obj instanceof WObject)) { /* 270 */ return false; /* */ } /* 272 */ WObject wobj = (WObject)obj; /* 273 */ Room r = wobj.getRoom(); /* */ /* 275 */ if (r == null) { /* 276 */ return false; /* */ } /* 278 */ r.addPrerenderHandler(wobj); /* */ /* 280 */ return true; /* */ } /* */ /* */ public int getVideoWallStatus(Object video) /* */ { /* 285 */ if ((video == null) || (!(video instanceof VideoWall))) { /* 286 */ return -1; /* */ } /* 288 */ VideoWall vw = (VideoWall)video; /* 289 */ return vw.getState(); /* */ } /* */ /* */ public boolean playVideo(Object video, int repeat) /* */ { /* 294 */ if ((video == null) || (!(video instanceof VideoWall))) { /* 295 */ return false; /* */ } /* 297 */ VideoWall vw = (VideoWall)video; /* 298 */ VideoSurface vs = vw.getVideoSurface(); /* 299 */ if (vs == null) { return false; /* */ } /* 301 */ vs.play(repeat); /* */ /* 303 */ return true; /* */ } /* */ /* */ public boolean stopVideo(Object video) /* */ { /* 308 */ if ((video == null) || (!(video instanceof VideoWall))) { /* 309 */ return false; /* */ } /* 311 */ VideoWall vw = (VideoWall)video; /* 312 */ VideoSurface vs = vw.getVideoSurface(); /* 313 */ if (vs == null) { return false; /* */ } /* 315 */ vs.stop(); /* */ /* 317 */ return true; /* */ } /* */ /* */ public boolean setVideoURL(Object video, String url, int width, int height) /* */ { /* 322 */ if ((video == null) || (!(video instanceof VideoWall))) { /* 323 */ return false; /* */ } /* 325 */ VideoWall vw = (VideoWall)video; /* 326 */ vw.changeURL(url, width, height); /* */ /* 328 */ return true; /* */ } /* */ /* */ public boolean setWebWallURL(Object webWall, String url) /* */ { /* 333 */ if ((webWall == null) || (!(webWall instanceof WebPageWall))) { /* 334 */ return false; /* */ } /* 336 */ WebPageWall wpw = (WebPageWall)webWall; /* 337 */ WebControlImp wci = wpw.getWebControlImp(); /* 338 */ if ((wci != null) && (url != null)) /* */ { /* 340 */ return wci.setURL(url); /* */ } /* */ /* 343 */ return false; /* */ } /* */ /* */ public boolean setWebWallURL(Object webWall, String url, String postData) /* */ { /* 348 */ if ((webWall == null) || (!(webWall instanceof WebPageWall))) { /* 349 */ return false; /* */ } /* 351 */ WebPageWall wpw = (WebPageWall)webWall; /* 352 */ WebControlImp wci = wpw.getWebControlImp(); /* 353 */ if ((wci != null) && (url != null)) /* */ { /* 355 */ return wci.setURL(url, postData); /* */ } /* */ /* 358 */ return false; /* */ } /* */ /* */ public boolean animateBot(Object obj, String action) { /* 362 */ if (!(obj instanceof PosableShape)) { /* 363 */ return false; /* */ } /* 365 */ PosableShape ps = (PosableShape)obj; /* 366 */ ps.animate(action); /* */ /* 368 */ return true; /* */ } /* */ /* */ public boolean setShapeURL(Object obj, String url) /* */ { /* 373 */ if (!(obj instanceof Shape)) { /* 374 */ return false; /* */ } /* 376 */ Shape s = (Shape)obj; /* 377 */ s.setURL(URL.make(url)); /* */ /* 379 */ return true; /* */ } /* */ /* */ public Object findObjectInRoom(String objectName) /* */ { /* 384 */ Room r = Pilot.getActive().getRoom(); /* 385 */ if (r != null) /* */ { /* 387 */ DeepEnumeration e = new DeepEnumeration(); /* 388 */ r.getChildren(e); /* 389 */ while (e.hasMoreElements()) /* */ { /* 391 */ SuperRoot wobj = (SuperRoot)e.nextElement(); /* 392 */ if (wobj.getName().equals(objectName)) /* */ { /* 394 */ return wobj; /* */ } /* */ } /* */ } /* 398 */ return null; /* */ } /* */ /* */ /* */ public void walkObjectTo(WorldScript script, Object obj, float x, float y, float yaw, float vel) /* */ { /* 404 */ if (!(obj instanceof WObject)) /* 405 */ return; /* 406 */ HandsOffDriver hod = new HandsOffDriver(); /* 407 */ hod.setDestPos(new Point2(x, y), yaw, vel); /* 408 */ hod.setTarget((Transform)obj); /* 409 */ hod.addCallback(script); /* 410 */ ((WObject)obj).addHandler(hod); /* */ } /* */ /* */ /* */ public void moveObjectTo(Object obj, float x, float y, float yaw) /* */ { /* 416 */ if (!(obj instanceof Transform)) /* 417 */ return; /* 418 */ Transform t = (Transform)obj; /* 419 */ t.moveTo(x, y, t.getZ()).yaw(yaw); /* */ } /* */ /* */ /* */ public void moveObjectTo(Object obj, float x, float y, float z, float yaw) /* */ { /* 425 */ if (!(obj instanceof Transform)) /* 426 */ return; /* 427 */ Transform t = (Transform)obj; /* 428 */ t.moveTo(x, y, z).yaw(yaw); /* */ } /* */ /* */ /* */ public void moveObjectTo(Object obj, float x, float y, float z, float yaw, float sc) /* */ { /* 434 */ if (!(obj instanceof Transform)) /* 435 */ return; /* 436 */ Transform t = (Transform)obj; /* 437 */ t.moveTo(x, y, z).yaw(yaw); /* 438 */ t.scale(sc); /* */ } /* */ /* */ /* */ public boolean isLoggedIn() /* */ { /* 444 */ Console c = Console.getActive(); /* 445 */ if (c != null) /* */ { /* 447 */ Galaxy g = c.getGalaxy(); /* 448 */ if (g != null) /* */ { /* 450 */ return g.getOnline(); /* */ } /* */ } /* 453 */ return false; /* */ } /* */ /* */ public int getConcurrentDownloads() /* */ { /* 458 */ return CacheEntry.getConcurrentDownloads(); /* */ } /* */ /* */ public boolean getIsVIP() /* */ { /* 463 */ Console c = Console.getActive(); /* 464 */ if (c != null) /* */ { /* 466 */ return c.getVIP(); /* */ } /* 468 */ return false; /* */ } /* */ /* */ /* */ public void setAdCube(boolean clickable, boolean usesGIF, String baseURL, String defaultURL) /* */ { /* 474 */ Pilot p = Pilot.getActive(); /* 475 */ if (p != null) /* */ { /* 477 */ World w = p.getWorld(); /* 478 */ if (w != null) /* */ { /* 480 */ w.setHasClickableAdCube(clickable); /* 481 */ w.setAdCubeFormatIsGif(usesGIF); /* 482 */ w.setAdCubeBaseURL(baseURL); /* 483 */ w.setDefaultAdCubeURL(defaultURL); /* */ } /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WorldScriptToolkitImp.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */