/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.scape.FrameEvent; /* */ import NET.worlds.scape.InventoryAction; /* */ import NET.worlds.scape.InventoryItem; /* */ import NET.worlds.scape.InventoryManager; /* */ import NET.worlds.scape.Pilot; /* */ import java.awt.Container; /* */ import java.awt.Event; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class ActionsPart /* */ implements FramePart /* */ { /* 39 */ static int actionToPerform = -1; /* */ /* */ private Pilot curPilot; /* */ /* */ private Vector curAnimations; /* */ /* */ private int numPilotAnims; /* */ /* */ private static ActionsPart activePart; /* */ private static ActionDialog dialog; /* */ static boolean showDialog; /* */ /* */ public void present() /* */ { /* 53 */ showDialog = true; /* 54 */ this.curPilot = null; /* */ } /* */ /* */ /* */ /* */ public void activate(Console c, Container f, Console prev) {} /* */ /* */ /* */ /* */ public void deactivate() {} /* */ /* */ /* */ @Deprecated /* */ public boolean action(Event event, Object what) /* */ { /* 69 */ return false; /* */ } /* */ /* */ public static boolean listEquals(Vector a, Vector b) { /* 73 */ if ((a == null) || (b == null)) { /* 74 */ return (a == null ? 1 : 0) == (b == null ? 1 : 0); /* */ } /* 76 */ if (a.size() != b.size()) { /* 77 */ return false; /* */ } /* 79 */ int i = a.size(); /* 80 */ do { Object ao = a.elementAt(i); /* 81 */ Object bo = b.elementAt(i); /* 82 */ if ((ao != null) && (bo != null)) { /* 83 */ if (!ao.equals(bo)) /* 84 */ return false; /* 85 */ } else if ((ao != null) || (bo != null)) { /* 86 */ return false; /* */ } /* 79 */ i--; } while (i >= 0); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 89 */ return true; /* */ } /* */ /* */ public static void updateActionDialog() { /* 93 */ if ((activePart != null) && (dialog != null) && (showDialog) && /* 94 */ (dialog.isVisible())) /* 95 */ Main.register(new MainCallback() { /* */ public void mainCallback() { /* 97 */ ActionsPart.activePart.regenActionDialog(); /* 98 */ Main.unregister(this); /* */ } /* */ }); /* */ } /* */ /* */ public void regenActionDialog() { /* 104 */ Vector newAnimations = this.curPilot.getAnimationList(); /* 105 */ this.numPilotAnims = newAnimations.size(); /* */ /* */ /* 108 */ Vector specials = InventoryManager.getInventoryManager() /* 109 */ .getInventoryActionList(); /* 110 */ for (int i = 0; i < specials.size(); i++) { /* 111 */ InventoryAction act = (InventoryAction)specials.elementAt(i); /* 112 */ newAnimations.addElement(act.getItemName()); /* */ } /* */ /* 115 */ if (dialog != null) { /* 116 */ boolean showWas = showDialog; /* */ /* */ /* 119 */ if ((showWas) && (dialog.isVisible()) && /* 120 */ (listEquals(newAnimations, this.curAnimations))) { /* 121 */ return; /* */ } /* 123 */ dialog.done(true); /* 124 */ showDialog = showWas; /* */ } /* */ /* 127 */ this.curAnimations = newAnimations; /* 128 */ if (showDialog) /* 129 */ dialog = new ActionDialog(this.curAnimations); /* */ } /* */ /* */ public synchronized boolean handle(FrameEvent f) { /* 133 */ Pilot pilot = Pilot.getActive(); /* 134 */ if (pilot != this.curPilot) { /* 135 */ this.curPilot = pilot; /* 136 */ activePart = this; /* 137 */ regenActionDialog(); /* 138 */ } else if ((actionToPerform != -1) && /* 139 */ (actionToPerform < this.curAnimations.size())) { /* 140 */ String act = (String)this.curAnimations.elementAt(actionToPerform); /* 141 */ if (actionToPerform < this.numPilotAnims) { /* 142 */ pilot.animate(act); /* */ } else /* 144 */ InventoryManager.getInventoryManager().doInventoryAction(act); /* */ } /* 146 */ actionToPerform = -1; /* 147 */ return true; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\ActionsPart.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */