diff --git a/src/xrGame/ui/UIActorMenu.cpp b/src/xrGame/ui/UIActorMenu.cpp index 74fc9feb1da..df5b8d862f3 100644 --- a/src/xrGame/ui/UIActorMenu.cpp +++ b/src/xrGame/ui/UIActorMenu.cpp @@ -475,23 +475,24 @@ void CUIActorMenu::highlight_item_slot(CUICellItem* cell_item) CEatableItem* eatable = smart_cast(item); CArtefact* artefact = smart_cast(item); - if (weapon) + u16 slot_id = item->BaseSlot(); + if (weapon && (slot_id == INV_SLOT_2 || slot_id == INV_SLOT_3)) { m_InvSlot2Highlight->Show(true); m_InvSlot3Highlight->Show(true); return; } - if (helmet) + if (helmet && slot_id == HELMET_SLOT) { m_HelmetSlotHighlight->Show(true); return; } - if (outfit) + if (outfit && slot_id == OUTFIT_SLOT) { m_OutfitSlotHighlight->Show(true); return; } - if (detector) + if (detector && slot_id == DETECTOR_SLOT) { m_DetectorSlotHighlight->Show(true); return; diff --git a/src/xrGame/ui/UIActorMenuInventory.cpp b/src/xrGame/ui/UIActorMenuInventory.cpp index 81d9ff80018..bbeb2b72abf 100644 --- a/src/xrGame/ui/UIActorMenuInventory.cpp +++ b/src/xrGame/ui/UIActorMenuInventory.cpp @@ -376,7 +376,7 @@ void CUIActorMenu::DetachAddon(LPCSTR addon_name, PIItem itm) void CUIActorMenu::InitCellForSlot(u16 slot_idx) { - VERIFY(KNIFE_SLOT <= slot_idx && slot_idx <= LAST_SLOT); + //VERIFY(KNIFE_SLOT <= slot_idx && slot_idx <= LAST_SLOT); PIItem item = m_pActorInvOwner->inventory().ItemFromSlot(slot_idx); if (!item) { @@ -414,6 +414,15 @@ void CUIActorMenu::InitInventoryContents(CUIDragDropListEx* pBagList) InitCellForSlot(GRENADE_SLOT); InitCellForSlot(HELMET_SLOT); + //Alundaio + if (!m_pActorInvOwner->inventory().SlotIsPersistent(KNIFE_SLOT)) + InitCellForSlot(KNIFE_SLOT); + if (!m_pActorInvOwner->inventory().SlotIsPersistent(BINOCULAR_SLOT)) + InitCellForSlot(BINOCULAR_SLOT); + if (!m_pActorInvOwner->inventory().SlotIsPersistent(ARTEFACT_SLOT)) + InitCellForSlot(ARTEFACT_SLOT); + //-Alundaio + curr_list = m_pInventoryBeltList; TIItemContainer::iterator itb = m_pActorInvOwner->inventory().m_belt.begin(); TIItemContainer::iterator ite = m_pActorInvOwner->inventory().m_belt.end(); @@ -494,11 +503,12 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id) { CUIDragDropListEx* new_owner = GetSlotList(slot_id); - if (slot_id == GRENADE_SLOT || !new_owner) + //Alundaio + /*if (slot_id == GRENADE_SLOT || !new_owner) { return true; // fake, sorry ((( } - else if (slot_id == OUTFIT_SLOT) + else*/ if (slot_id == OUTFIT_SLOT) { CCustomOutfit* pOutfit = smart_cast(iitem); if (pOutfit && !pOutfit->bIsHelmetAvaliable) @@ -546,15 +556,24 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id) PIItem _iitem = m_pActorInvOwner->inventory().ItemFromSlot(slot_id); CUIDragDropListEx* slot_list = GetSlotList(slot_id); - VERIFY(slot_list->ItemsCount() == 1); + if (!slot_list) + return false; - CUICellItem* slot_cell = slot_list->GetItemIdx(0); - VERIFY(slot_cell && ((PIItem)slot_cell->m_pData) == _iitem); + CUIDragDropListEx* invlist = GetListByType(iActorBag); + if (invlist != slot_list) + { + if (!slot_list->ItemsCount() == 1) + return false; - bool result = ToBag(slot_cell, false); - VERIFY(result); + CUICellItem* slot_cell = slot_list->GetItemIdx(0); + if (!(slot_cell && static_cast(slot_cell->m_pData) == _iitem)) + return false; - result = ToSlot(itm, false, slot_id); + if (ToBag(slot_cell, false) == false) + return false; + } + + bool result = ToSlot(itm, false, slot_id); if (b_own_item && result && slot_id == DETECTOR_SLOT) { CCustomDetector* det = smart_cast(iitem); @@ -685,6 +704,10 @@ CUIDragDropListEx* CUIActorMenu::GetSlotList(u16 slot_idx) case DETECTOR_SLOT: return m_pInventoryDetectorList; break; + case ARTEFACT_SLOT: + case BINOCULAR_SLOT: + case KNIFE_SLOT: + case GRENADE_SLOT: // fake if (m_currMenuMode == mmTrade) { @@ -849,7 +872,8 @@ void CUIActorMenu::PropertiesBoxForSlots(PIItem item, bool& b_show) bool bAlreadyDressed = false; u16 cur_slot = item->BaseSlot(); - if (!pOutfit && !pHelmet && cur_slot != NO_ACTIVE_SLOT && !inv.SlotIsPersistent(cur_slot) /*&& inv.CanPutInSlot(item, cur_slot)*/) + if (!pOutfit && !pHelmet && cur_slot != NO_ACTIVE_SLOT && !inv.SlotIsPersistent(cur_slot) && m_pActorInvOwner-> + inventory().ItemFromSlot(cur_slot) != item /*&& inv.CanPutInSlot(item, cur_slot)*/) { m_UIPropertiesBox->AddItem("st_move_to_slot", NULL, INVENTORY_TO_SLOT_ACTION); b_show = true; @@ -1414,15 +1438,13 @@ void CUIActorMenu::RefreshCurrentItemCell() { CUICellItem* parent = invlist->RemoveItem(ci, true); - if (parent->ChildsCount() > 0) + while (parent->ChildsCount()) { - while (parent->ChildsCount()) - { - CUICellItem* child = parent->PopChild(nullptr); - invlist->SetItem(child); - } + CUICellItem* child = parent->PopChild(nullptr); + invlist->SetItem(child); } - invlist->SetItem(parent); + + invlist->SetItem(parent, GetUICursor().GetCursorPosition()); } } } diff --git a/src/xrGame/ui/UIActorMenuTrade.cpp b/src/xrGame/ui/UIActorMenuTrade.cpp index a1b33c8e565..313f7870447 100644 --- a/src/xrGame/ui/UIActorMenuTrade.cpp +++ b/src/xrGame/ui/UIActorMenuTrade.cpp @@ -547,11 +547,11 @@ void CUIActorMenu::DonateCurrentItem(CUICellItem* cell_item) if (!item) return; - invlist->RemoveItem(cell_item, false); + CUICellItem* itm = invlist->RemoveItem(cell_item, false); m_partner_trade->TransferItem(item, true, true); - m_pTradePartnerList->SetItem(cell_item); + m_pTradePartnerList->SetItem(itm); SetCurrentItem(nullptr); UpdateItemsPlace(); diff --git a/src/xrGame/ui/UIDragDropListEx.cpp b/src/xrGame/ui/UIDragDropListEx.cpp index b0058e18884..0f243052799 100644 --- a/src/xrGame/ui/UIDragDropListEx.cpp +++ b/src/xrGame/ui/UIDragDropListEx.cpp @@ -4,6 +4,9 @@ #include "Common/object_broker.h" #include "UICellItem.h" #include "UICursor.h" +//Alundaio +#include "Inventory.h" +//-Alundaio CUIDragItem* CUIDragDropListEx::m_drag_item = NULL; @@ -479,6 +482,9 @@ bool CUICellContainer::AddSimilar(CUICellItem* itm) return false; CUICellItem* i = FindSimilar(itm); + if (i == nullptr) + return false; + R_ASSERT(i != itm); R_ASSERT(0 == itm->ChildsCount()); if (i) @@ -492,6 +498,7 @@ bool CUICellContainer::AddSimilar(CUICellItem* itm) CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm) { + // XXX: try to replace with range-based for for (auto it = m_ChildWndList.begin(); m_ChildWndList.end() != it; ++it) { #ifdef DEBUG @@ -499,7 +506,15 @@ CUICellItem* CUICellContainer::FindSimilar(CUICellItem* itm) #else CUICellItem* i = (CUICellItem*)(*it); #endif - R_ASSERT(i != itm); + //Alundaio: Don't stack equipped items + PIItem iitem = static_cast(i->m_pData); + if (iitem && iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(iitem->BaseSlot()) == iitem) + continue; + + if (i == itm) + continue; + + //R_ASSERT(i != itm); if (i->EqualTo(itm)) return i; } @@ -845,16 +860,22 @@ void CUICellContainer::Draw() if (!ui_cell.Empty()) { if (ui_cell.m_item->m_cur_mark) - { select_mode = 2; - } else if (ui_cell.m_item->m_selected) - { select_mode = 1; - } else if (ui_cell.m_item->m_select_armament) - { select_mode = 3; + else + { + //Alundaio: Highlight equipped items + PIItem iitem = static_cast(ui_cell.m_item->m_pData); + if (iitem) + { + u16 slot = iitem->BaseSlot(); + if (iitem->m_pInventory && iitem->m_pInventory->ItemFromSlot(slot) == iitem) + select_mode = 3; + } + //-Alundaio } }