/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.ImageCanvas; /* */ import NET.worlds.console.PolledDialog; /* */ import NET.worlds.network.URL; /* */ import java.awt.Button; /* */ import java.awt.Color; /* */ import java.awt.Event; /* */ import java.awt.Font; /* */ import java.awt.Frame; /* */ import java.awt.GridBagConstraints; /* */ import java.awt.GridBagLayout; /* */ import java.awt.Label; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class InventoryDialog /* */ extends PolledDialog /* */ { /* */ private static final long serialVersionUID = 1L; /* */ private InventoryList rightWristItems_; /* */ private ImageCanvas rightWristIcon_; /* */ private InventoryList leftWristItems_; /* */ private ImageCanvas leftWristIcon_; /* */ private InventoryList headItems_; /* */ private ImageCanvas headIcon_; /* */ private InventoryList rightAnkleItems_; /* */ private ImageCanvas rightAnkleIcon_; /* */ private InventoryList leftAnkleItems_; /* */ private ImageCanvas leftAnkleIcon_; /* */ private Button okButton_; /* */ private Button cancelButton_; /* */ private Frame parent_; /* 58 */ private static final URL defaultImageURL = URL.make("home:..\\default.gif"); /* */ private static Object lastPosAndSize; /* */ /* */ public InventoryDialog(Frame frame) { /* 62 */ super(frame, null, Console.message("Inventory"), true); /* */ /* 64 */ InventoryManager im = InventoryManager.getInventoryManager(); /* 65 */ Vector equippableItems = im.getEquippableItems(); /* 66 */ Vector equippedItems = im.getEquippedItems(); /* 67 */ this.parent_ = frame; /* */ /* 69 */ this.rightWristItems_ = new InventoryList(); /* 70 */ this.leftWristItems_ = new InventoryList(); /* 71 */ this.headItems_ = new InventoryList(); /* 72 */ this.rightAnkleItems_ = new InventoryList(); /* 73 */ this.leftAnkleItems_ = new InventoryList(); /* */ /* 75 */ this.rightWristIcon_ = new ImageCanvas(defaultImageURL); /* 76 */ this.leftWristIcon_ = new ImageCanvas(defaultImageURL); /* 77 */ this.headIcon_ = new ImageCanvas(defaultImageURL); /* 78 */ this.leftAnkleIcon_ = new ImageCanvas(defaultImageURL); /* 79 */ this.rightAnkleIcon_ = new ImageCanvas(defaultImageURL); /* */ /* 81 */ this.okButton_ = new Button("Ok"); /* 82 */ this.cancelButton_ = new Button("Cancel"); /* */ /* */ /* 85 */ for (int i = 0; i < equippableItems.size(); i++) /* */ { /* 87 */ EquippableItem item = (EquippableItem)equippableItems.elementAt(i); /* */ /* 89 */ switch (item.getBodyLocation()) /* */ { /* */ case 8: /* 92 */ this.rightWristItems_.add(item); /* 93 */ break; /* */ case 13: /* 95 */ this.leftWristItems_.add(item); /* 96 */ break; /* */ case 4: /* 98 */ this.headItems_.add(item); /* 99 */ break; /* */ case 17: /* 101 */ this.rightAnkleItems_.add(item); /* 102 */ break; /* */ case 21: /* 104 */ this.leftAnkleItems_.add(item); /* */ } /* */ /* */ } /* */ /* */ /* */ /* */ /* 112 */ for (int i = 0; i < equippedItems.size(); i++) /* */ { /* 114 */ EquippableItem item = (EquippableItem)equippedItems.elementAt(i); /* */ /* 116 */ switch (item.getBodyLocation()) /* */ { /* */ case 8: /* 119 */ this.rightWristItems_.selectItem(item); /* 120 */ break; /* */ case 13: /* 122 */ this.leftWristItems_.selectItem(item); /* 123 */ break; /* */ case 4: /* 125 */ this.headItems_.selectItem(item); /* 126 */ break; /* */ case 17: /* 128 */ this.rightAnkleItems_.selectItem(item); /* 129 */ break; /* */ case 21: /* 131 */ this.leftAnkleItems_.selectItem(item); /* */ } /* */ /* */ } /* */ /* */ /* */ /* */ /* 139 */ ready(); /* */ } /* */ /* */ /* */ protected void build() /* */ { /* 145 */ setBackground(Color.cyan); /* 146 */ setForeground(Color.black); /* 147 */ GridBagLayout gbag = new GridBagLayout(); /* 148 */ setLayout(gbag); /* 149 */ GridBagConstraints c = new GridBagConstraints(); /* */ /* 151 */ Font f1 = /* 152 */ new Font(Console.message("ConsoleFont"), 1, 18); /* 153 */ Font f2 = /* 154 */ new Font(Console.message("ConsoleFont"), 0, 12); /* */ /* 156 */ Label invLabel = new Label("Inventory"); /* 157 */ c.gridx = 2; /* 158 */ c.gridy = 0; /* 159 */ c.weightx = 3.0D; /* 160 */ invLabel.setFont(f1); /* 161 */ add(gbag, invLabel, c); /* */ /* 163 */ Label rwLabel = new Label("Right Hand"); /* 164 */ c.gridx = 4; /* 165 */ c.gridy = 4; /* 166 */ c.weightx = 1.0D; /* 167 */ rwLabel.setFont(f2); /* */ /* 169 */ add(gbag, rwLabel, c); /* 170 */ c.gridy = 5; /* 171 */ c.weighty = 1.0D; /* 172 */ this.rightWristItems_.setFont(f2); /* 173 */ add(gbag, this.rightWristItems_, c); /* */ /* 175 */ c.gridx = 3; /* 176 */ c.gridy = 5; /* 177 */ c.weighty = 1.0D; /* 178 */ c.weightx = 1.0D; /* 179 */ add(gbag, this.rightWristIcon_, c); /* */ /* 181 */ Label lwLabel = new Label("Left Hand"); /* 182 */ c.gridx = 0; /* 183 */ c.gridy = 4; /* 184 */ c.weighty = 1.0D; /* 185 */ lwLabel.setFont(f2); /* 186 */ add(gbag, lwLabel, c); /* */ /* 188 */ c.gridy = 5; /* 189 */ c.weighty = 1.0D; /* 190 */ this.leftWristItems_.setFont(f2); /* 191 */ add(gbag, this.leftWristItems_, c); /* */ /* 193 */ c.gridx = 1; /* 194 */ c.gridy = 5; /* 195 */ c.weighty = 1.0D; /* 196 */ c.weightx = 1.0D; /* 197 */ add(gbag, this.leftWristIcon_, c); /* */ /* 199 */ Label headLabel = new Label("Head"); /* 200 */ c.gridx = 2; /* 201 */ c.gridy = 2; /* 202 */ c.weighty = 1.0D; /* 203 */ headLabel.setFont(f2); /* 204 */ add(gbag, headLabel, c); /* */ /* 206 */ c.gridy = 3; /* 207 */ c.weighty = 1.0D; /* 208 */ this.headItems_.setFont(f2); /* 209 */ add(gbag, this.headItems_, c); /* */ /* 211 */ c.gridx = 2; /* 212 */ c.gridy = 4; /* 213 */ c.weighty = 1.0D; /* 214 */ c.weightx = 1.0D; /* 215 */ add(gbag, this.headIcon_, c); /* */ /* 217 */ Label raLabel = new Label("Right Foot"); /* 218 */ c.gridx = 4; /* 219 */ c.gridy = 6; /* 220 */ c.weightx = 1.0D; /* 221 */ raLabel.setFont(f2); /* 222 */ add(gbag, raLabel, c); /* */ /* 224 */ c.gridy = 7; /* 225 */ c.weighty = 0.0D; /* 226 */ this.rightAnkleItems_.setFont(f2); /* 227 */ add(gbag, this.rightAnkleItems_, c); /* */ /* 229 */ c.gridx = 3; /* 230 */ c.gridy = 7; /* 231 */ c.weighty = 1.0D; /* 232 */ c.weightx = 1.0D; /* 233 */ add(gbag, this.rightAnkleIcon_, c); /* */ /* 235 */ Label laLabel = new Label("Left Foot"); /* 236 */ c.gridx = 0; /* 237 */ c.gridy = 6; /* 238 */ c.weighty = 1.0D; /* 239 */ laLabel.setFont(f2); /* 240 */ add(gbag, laLabel, c); /* */ /* 242 */ c.gridy = 7; /* 243 */ c.weighty = 0.0D; /* 244 */ this.leftAnkleItems_.setFont(f2); /* 245 */ add(gbag, this.leftAnkleItems_, c); /* */ /* 247 */ c.gridx = 1; /* 248 */ c.gridy = 7; /* 249 */ c.weighty = 1.0D; /* 250 */ c.weightx = 1.0D; /* 251 */ add(gbag, this.leftAnkleIcon_, c); /* */ /* 253 */ c.gridx = 0; /* 254 */ c.gridy = 10; /* 255 */ c.weightx = 2.0D; /* 256 */ c.weighty = 1.0D; /* 257 */ this.okButton_.setFont(f2); /* 258 */ add(gbag, this.okButton_, c); /* */ /* 260 */ c.gridx = 4; /* 261 */ c.gridy = 10; /* 262 */ this.cancelButton_.setFont(f2); /* 263 */ add(gbag, this.cancelButton_, c); /* */ /* 265 */ setSize(360, 300); /* */ } /* */ /* */ public synchronized boolean done(boolean confirmed) /* */ { /* 270 */ Vector equippedItems = new Vector(); /* */ /* */ EquippableItem eItem; /* */ /* 274 */ if ((eItem = this.rightWristItems_.getSelected()) != null) /* */ { /* 276 */ equippedItems.add(eItem); /* */ } /* */ /* 279 */ if ((eItem = this.leftWristItems_.getSelected()) != null) /* */ { /* 281 */ equippedItems.add(eItem); /* */ } /* */ /* 284 */ if ((eItem = this.headItems_.getSelected()) != null) /* */ { /* 286 */ equippedItems.add(eItem); /* */ } /* */ /* 289 */ if ((eItem = this.leftAnkleItems_.getSelected()) != null) /* */ { /* 291 */ equippedItems.add(eItem); /* */ } /* */ /* 294 */ if ((eItem = this.rightAnkleItems_.getSelected()) != null) /* */ { /* 296 */ equippedItems.add(eItem); /* */ } /* */ /* 299 */ if (confirmed) /* */ { /* 301 */ InventoryManager im = InventoryManager.getInventoryManager(); /* */ /* 303 */ im.setEquippedItems(equippedItems); /* */ } /* */ /* 306 */ return super.done(confirmed); /* */ } /* */ /* */ @Deprecated /* */ public boolean handleEvent(Event event) /* */ { /* 312 */ return super.handleEvent(event); /* */ } /* */ /* */ @Deprecated /* */ public boolean action(Event event, Object what) /* */ { /* 318 */ Object target = event.target; /* */ /* */ /* */ /* 322 */ URL imageURL = defaultImageURL; /* 323 */ if (target == this.leftWristItems_) /* */ { /* 325 */ InventoryItem item = this.leftWristItems_.getSelected(); /* */ /* 327 */ if (item != null) /* */ { /* 329 */ imageURL = item.getItemGraphicLocation(); /* */ } /* */ /* 332 */ setIcon(this.leftWristIcon_, imageURL); /* */ /* 334 */ return true; /* */ } /* 336 */ if (target == this.rightWristItems_) /* */ { /* 338 */ InventoryItem item = this.rightWristItems_.getSelected(); /* */ /* 340 */ if (item != null) /* */ { /* 342 */ imageURL = item.getItemGraphicLocation(); /* */ } /* */ /* 345 */ setIcon(this.rightWristIcon_, imageURL); /* */ /* 347 */ return true; /* */ } /* 349 */ if (target == this.headItems_) /* */ { /* 351 */ InventoryItem item = this.headItems_.getSelected(); /* */ /* 353 */ if (item != null) /* */ { /* 355 */ imageURL = item.getItemGraphicLocation(); /* */ } /* */ /* 358 */ setIcon(this.headIcon_, imageURL); /* */ /* 360 */ return true; /* */ } /* 362 */ if (target == this.leftAnkleItems_) /* */ { /* 364 */ InventoryItem item = this.leftAnkleItems_.getSelected(); /* */ /* 366 */ if (item != null) /* */ { /* 368 */ imageURL = item.getItemGraphicLocation(); /* */ } /* */ /* 371 */ setIcon(this.leftAnkleIcon_, imageURL); /* */ /* 373 */ return true; /* */ } /* 375 */ if (target == this.rightAnkleItems_) /* */ { /* 377 */ InventoryItem item = this.rightAnkleItems_.getSelected(); /* */ /* 379 */ if (item != null) /* */ { /* 381 */ imageURL = item.getItemGraphicLocation(); /* */ } /* */ /* 384 */ setIcon(this.rightAnkleIcon_, imageURL); /* */ /* 386 */ return true; /* */ } /* */ /* */ /* */ /* 391 */ if (target == this.okButton_) /* */ { /* 393 */ return done(true); /* */ } /* 395 */ if (target == this.cancelButton_) /* */ { /* 397 */ return done(false); /* */ } /* */ /* */ /* 401 */ return false; /* */ } /* */ /* */ private void setIcon(ImageCanvas ic, URL newLoc) /* */ { /* 406 */ ic.setNewImage(newLoc, getGraphics()); /* 407 */ repaint(); /* */ } /* */ /* */ /* 411 */ public void savePosAndSize(Object state) { lastPosAndSize = state; } /* 412 */ public Object restorePosAndSize() { return lastPosAndSize; } /* */ /* */ @Deprecated /* */ public boolean keyDown(Event event, int key) /* */ { /* 417 */ if (key == 27) /* 418 */ return done(false); /* 419 */ return super.keyDown(event, key); /* */ } /* */ /* */ /* */ /* */ protected synchronized void activeCallback() /* */ { /* 426 */ notify(); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\InventoryDialog.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */