summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WorldScriptManager.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/WorldScriptManager.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/WorldScriptManager.java')
-rw-r--r--NET/worlds/scape/WorldScriptManager.java192
1 files changed, 192 insertions, 0 deletions
diff --git a/NET/worlds/scape/WorldScriptManager.java b/NET/worlds/scape/WorldScriptManager.java
new file mode 100644
index 0000000..e0fbeba
--- /dev/null
+++ b/NET/worlds/scape/WorldScriptManager.java
@@ -0,0 +1,192 @@
+/* */ 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<String> v = this.currentScript.onShapeClick(shape, shape.getName());
+/* 145 */ if (v != null)
+/* */ {
+/* 147 */ PopupMenu m = new PopupMenu();
+/* 148 */ Enumeration<String> 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
+ */ \ No newline at end of file