summaryrefslogtreecommitdiff
path: root/NET/worlds/console/ActionsPart.java
blob: 393b69207e14423f10e369ecfe22228cca0983c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*     */ 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<String> 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<String> a, Vector<String> 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<String> newAnimations = this.curPilot.getAnimationList();
/* 105 */     this.numPilotAnims = newAnimations.size();
/*     */     
/*     */ 
/* 108 */     Vector<InventoryItem> 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
 */