()
| 260 | } |
| 261 | |
| 262 | private void addSelectedItem() |
| 263 | throws DBException, IOException |
| 264 | { |
| 265 | int count = this.availField.getSelectionCount(); |
| 266 | if (count == 0) { |
| 267 | JOptionPane.showMessageDialog(this, "You must select an item to add", "No item selected", 0); |
| 268 | |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | TreePath treePath = this.availField.getSelectionPath(); |
| 273 | DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent(); |
| 274 | Object userObject = node.getUserObject(); |
| 275 | if (!(userObject instanceof ItemTemplate)) { |
| 276 | JOptionPane.showMessageDialog(this, "You must select an item to add", "No item selected", 0); |
| 277 | |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | ItemTemplate template = (ItemTemplate)userObject; |
| 282 | DBList templateList = template.getFieldList(); |
| 283 | int questItem = templateList.getInteger("QuestItem"); |
| 284 | int alchemyIngredient = templateList.getInteger("AlchIngredient"); |
| 285 | |
| 286 | int x = 0; int y = 0; |
| 287 | if (questItem == 0) { |
| 288 | boolean foundSlot = false; |
| 289 | // Normal inventory item slots (3 rows) |
| 290 | if (alchemyIngredient == 0) { |
| 291 | for (y = 0; y < 3; y++) { |
| 292 | for (x = 0; x < 14; x++) { |
| 293 | if (this.slots[y][x] == false) { |
| 294 | foundSlot = true; |
| 295 | break; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if (foundSlot) |
| 300 | break; |
| 301 | } |
| 302 | } else { |
| 303 | // Alchemy ingredients slots (3 rows) |
| 304 | for (y = 3; y < 6; y++) { |
| 305 | for (x = 0; x < 14; x++) { |
| 306 | if (this.slots[y][x] == false) { |
| 307 | foundSlot = true; |
| 308 | break; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if (foundSlot) { |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | if (!foundSlot) { |
| 318 | JOptionPane.showMessageDialog(this, "No inventory slot available", "Inventory is full", 0); |
| 319 |
no test coverage detected