/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.DefaultConsole; /* */ import NET.worlds.console.Main; /* */ import NET.worlds.console.MainCallback; /* */ import NET.worlds.console.MainTerminalCallback; /* */ import NET.worlds.console.RenderCanvas; /* */ import java.awt.PopupMenu; /* */ import java.awt.event.ActionEvent; /* */ import java.awt.event.ActionListener; /* */ import java.io.PrintStream; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ public class WorldScriptManager /* */ implements ActionListener, MainCallback, MainTerminalCallback /* */ { /* 19 */ private static WorldScriptManager instance = new WorldScriptManager(); /* */ /* */ /* 22 */ private static WorldScriptLoader loader = new WorldScriptLoader(); /* */ /* 24 */ public static WorldScriptManager getInstance() { return instance; } /* */ /* */ private WorldScriptManager() /* */ { /* 28 */ this.currentScript = null; /* 29 */ Main.register(this); /* */ } /* */ /* */ public void terminalCallback() /* */ { /* 34 */ if (this.currentScript != null) { /* 35 */ this.currentScript.worldExit(); /* */ } /* 37 */ this.currentScript = null; /* */ /* 39 */ Main.unregister(this); /* */ } /* */ /* */ /* */ private WorldScript currentScript; /* */ private String lastRoom; /* */ public void worldEntered(String worldName) /* */ { /* 47 */ if (this.currentScript != null) { /* 48 */ this.currentScript.worldExit(); /* */ } /* 50 */ this.currentScript = null; /* */ /* 52 */ if (worldName == null) { /* 53 */ return; /* */ } /* 55 */ worldName = worldName.replace(' ', '_'); /* 56 */ worldName = worldName.replace('-', '_'); /* 57 */ worldName = worldName.replace('.', '_'); /* 58 */ worldName = worldName.replace('/', '_'); /* 59 */ worldName = worldName.replace('\\', '_'); /* */ /* */ try /* */ { /* 63 */ this.currentScript = /* 64 */ ((WorldScript)loader.loadClass("WorldScript" + worldName + ".class", true).newInstance()); /* */ } /* */ catch (Exception e) /* */ { /* 68 */ System.out.println("Exception constructing world script: " + e); /* */ } /* */ catch (Error e) /* */ { /* 72 */ System.out.println("Error constructing world script: " + e); /* */ } /* */ /* 75 */ if (this.currentScript != null) /* */ { /* */ /* 78 */ if (this.currentScript.getMinScriptVersion() > 15) /* */ { /* 80 */ System.out.println("Script requires newer client version. script is ver. " + /* 81 */ this.currentScript.getMinScriptVersion() + /* 82 */ " and client has ver. " + 15); /* 83 */ this.currentScript = null; /* */ } /* */ else /* */ { /* 87 */ this.currentScript.worldEnter(); /* */ } /* */ } /* */ } /* */ /* */ public void mainCallback() /* */ { /* 94 */ if (this.currentScript != null) { /* 95 */ this.currentScript.onEachFrame(); /* */ } /* */ } /* */ /* */ public void onPrerender(WObject obj, Camera cam) { /* 100 */ if (this.currentScript != null) /* */ { /* 102 */ Console c = Console.getActive(); /* 103 */ if (c == null) return; /* 104 */ if (!(c instanceof DefaultConsole)) /* 105 */ return; /* 106 */ DefaultConsole dc = (DefaultConsole)c; /* 107 */ RenderCanvas rc = dc.getRender(); /* 108 */ if (rc == null) { return; /* */ } /* 110 */ Camera renderCam = rc.getCamera(); /* 111 */ if (cam != renderCam) { return; /* */ } /* 113 */ Point3Temp p = obj.inCamSpace(cam); /* */ /* */ /* */ /* 117 */ boolean v = (p != null) && (p.z > 1.0F) && (p.x < p.z) && (-p.x < p.z); /* */ /* 119 */ this.currentScript.objectVisibilityNotification(obj, v); /* */ } /* */ } /* */ /* */ public void action(String message) /* */ { /* 125 */ if (this.currentScript != null) { /* 126 */ this.currentScript.onTriggerAction(message); /* */ } /* */ } /* */ /* */ public PopupMenu shapeClicked(Shape shape) { /* 131 */ if (this.currentScript != null) /* */ { /* 133 */ SuperRoot ultimateOwner = shape; /* 134 */ while (ultimateOwner.getOwner() != null) /* */ { /* 136 */ ultimateOwner = ultimateOwner.getOwner(); /* 137 */ if ((ultimateOwner instanceof PosableShape)) /* */ { /* 139 */ shape = (Shape)ultimateOwner; /* 140 */ break; /* */ } /* */ } /* */ /* 144 */ Vector v = this.currentScript.onShapeClick(shape, shape.getName()); /* 145 */ if (v != null) /* */ { /* 147 */ PopupMenu m = new PopupMenu(); /* 148 */ Enumeration e = v.elements(); /* 149 */ while (e.hasMoreElements()) /* */ { /* 151 */ m.add((String)e.nextElement()); /* */ } /* 153 */ return m; /* */ } /* */ } /* */ /* 157 */ return null; /* */ } /* */ /* */ public void actionPerformed(ActionEvent e) /* */ { /* 162 */ if (this.currentScript != null) { /* 163 */ this.currentScript.onMenuClick(e.getActionCommand(), e.getSource()); /* */ } /* */ } /* */ /* */ public void roomEntered(String roomName) { /* 168 */ if (this.currentScript == null) { /* 169 */ return; /* */ } /* 171 */ if (this.lastRoom != null) { /* 172 */ this.currentScript.roomExit(this.lastRoom); /* */ } /* 174 */ this.currentScript.roomEnter(roomName); /* */ /* 176 */ this.lastRoom = new String(roomName); /* */ } /* */ /* */ public void onConversation(String who, String what) /* */ { /* 181 */ if (this.currentScript == null) { /* 182 */ return; /* */ } /* 184 */ this.currentScript.onConversation(who, what); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WorldScriptManager.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */