| 7538 | //} |
| 7539 | |
| 7540 | void GenericGUIMenu::openGUI(int type, Item* effectItem, int effectBeatitude, int effectItemType, int usingSpellID) |
| 7541 | { |
| 7542 | this->closeGUI(); |
| 7543 | |
| 7544 | if ( !effectItem && usingSpellID != SPELL_NONE && effectItemType == SPELL_ITEM ) |
| 7545 | { |
| 7546 | for ( node_t* node = stats[gui_player]->inventory.first; node; node = node->next ) |
| 7547 | { |
| 7548 | Item* item = static_cast<Item*>(node->element); |
| 7549 | if ( !item ) |
| 7550 | { |
| 7551 | continue; |
| 7552 | } |
| 7553 | //Search player's inventory for the special spell item. |
| 7554 | if ( itemCategory(item) != SPELL_CAT ) |
| 7555 | { |
| 7556 | continue; |
| 7557 | } |
| 7558 | spell_t* spell = getSpellFromItem(gui_player, item, false); |
| 7559 | if ( spell && spell->ID == usingSpellID ) |
| 7560 | { |
| 7561 | effectItem = item; |
| 7562 | break; |
| 7563 | } |
| 7564 | } |
| 7565 | if ( !effectItem ) |
| 7566 | { |
| 7567 | return; |
| 7568 | } |
| 7569 | } |
| 7570 | |
| 7571 | if ( players[gui_player] && players[gui_player]->entity ) |
| 7572 | { |
| 7573 | if ( players[gui_player]->entity->isBlind() ) |
| 7574 | { |
| 7575 | messagePlayer(gui_player, MESSAGE_MISC, Language::get(892)); |
| 7576 | return; // I can't see! |
| 7577 | } |
| 7578 | } |
| 7579 | |
| 7580 | if ( players[gui_player]->inventoryUI.bCompactView ) |
| 7581 | { |
| 7582 | // if compact view, then we don't want the inventory slot being selected |
| 7583 | if ( players[gui_player]->inventoryUI.getSelectedSlotY() < 0 ) |
| 7584 | { |
| 7585 | players[gui_player]->inventoryUI.selectSlot(0, 0); |
| 7586 | } |
| 7587 | } |
| 7588 | players[gui_player]->openStatusScreen(GUI_MODE_INVENTORY, INVENTORY_MODE_ITEM); // Reset the GUI to the inventory. |
| 7589 | |
| 7590 | guiActive = true; |
| 7591 | itemEffectItemBeatitude = effectBeatitude; |
| 7592 | itemEffectItemType = effectItemType; |
| 7593 | guiType = static_cast<GUICurrentType>(type); |
| 7594 | if ( type == GUICurrentType::GUI_TYPE_ITEMFX ) |
| 7595 | { |
| 7596 | if ( items[effectItemType].category == SPELLBOOK ) |
| 7597 | { |
no test coverage detected