MCPcopy Create free account
hub / github.com/boazy/TWEditorEnhanced / addSelectedItem

Method addSelectedItem

src/main/java/InventoryPanel.java:262–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

actionPerformedMethod · 0.95

Calls 11

getFieldListMethod · 0.95
getIntegerMethod · 0.95
cloneMethod · 0.95
setIntegerMethod · 0.95
getValueMethod · 0.95
getElementMethod · 0.95
addElementMethod · 0.95
getItemNameMethod · 0.95
insertItemMethod · 0.95
getTopLevelStructMethod · 0.80
setTitleMethod · 0.80

Tested by

no test coverage detected