4 protected ref ContainerWithCargo m_CargoGrid;
17 m_Body.Insert( m_Container );
21 WidgetEventHandler.GetInstance().RegisterOnChildAdd( m_MainWidget,
this,
"OnChildAdd" );
22 WidgetEventHandler.GetInstance().RegisterOnChildRemove( m_MainWidget,
this,
"OnChildRemove" );
25 RecomputeOpenedContainers();
32 m_ZombieEntity.GetOnItemAttached().Remove(ItemAttached);
33 m_ZombieEntity.GetOnItemDetached().Remove(ItemDetached);
37 void SetEntity(
EntityAI zombie_entity )
39 m_ZombieEntity = zombie_entity;
40 m_ZombieEntity.GetOnItemAttached().Insert(ItemAttached);
41 m_ZombieEntity.GetOnItemDetached().Insert(ItemDetached);
46 override void UpdateRadialIcon()
50 bool show_radial_icon;
51 show_radial_icon = IsHidden();
52 Widget rip = m_SlotIcon.GetRadialIconPanel();
53 Widget icon_open = m_SlotIcon.GetRadialIcon();
54 Widget icon_closed = m_SlotIcon.GetRadialIconClosed();
55 rip.Show( !m_ZombieEntity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) && m_ZombieEntity.CanDisplayCargo());
56 icon_open.Show( show_radial_icon );
57 icon_closed.Show( !show_radial_icon );
61 override bool IsItemWithQuantityActive()
67 bool IsContainerWithCargoActive()
69 return GetFocusedContainer().IsInherited( ContainerWithCargo );
72 bool IsItemWithAttachmentsActive()
74 return GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments );
77 bool IsZombieEquipmentActive()
79 return GetFocusedContainer() == m_Container;
82 bool IsItemWithContainerActive()
85 return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
88 bool IsEmptyItemActive()
90 return !GetFocusedItem();
93 override void ExpandCollapseContainer()
95 if( IsZombieEquipmentActive() )
98 ToggleContainer( item_preview.GetParent() );
102 override void OnDropReceivedFromHeader(
Widget w,
int x,
int y,
Widget receiver )
107 string name = w.GetName();
108 name.Replace(
"PanelWidget",
"Render" );
123 if( !item.GetInventory().CanRemoveEntity() )
126 if (m_ZombieEntity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ))
127 GetGame().GetPlayer().PredictiveTakeEntityToTargetCargo( m_ZombieEntity, item );
128 else if( m_ZombieEntity.GetInventory().CanAddEntityToInventory( item ) )
134 override void DraggingOverHeader(
Widget w,
int x,
int y,
Widget receiver)
137 string name = receiver.GetName();
138 name.Replace(
"PanelWidget",
"Render");
143 receiver_item = receiver_iw.GetItem();
149 name.Replace(
"PanelWidget",
"Render");
165 if(!item.GetInventory().CanRemoveEntity())
169 void OnDropReceivedFromGhostArea(
Widget w,
int x,
int y,
Widget receiver)
172 string name = receiver.GetName();
173 name.Replace(
"PanelWidget",
"Render");
178 receiver_item = receiver_iw.GetItem();
184 name.Replace(
"PanelWidget",
"Render" );
200 if(!item.GetInventory().CanRemoveEntity())
207 if(receiver_item.GetInventory().CanAddAttachment(item))
209 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
212 else if(receiver_item.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !receiver_item.GetInventory().HasEntityInCargo(item))
221 if(m_ZombieEntity.GetInventory().CanAddAttachment(item))
223 player.PredictiveTakeEntityToTargetAttachment(m_ZombieEntity, item);
225 else if(m_ZombieEntity.GetInventory().CanAddEntityToInventory(item))
242 m_CollapsibleHeader.SetName(
"#container_inventory" );
245 void ItemAttached(
EntityAI item,
string slot_name)
248 SlotsIcon icon = m_InventorySlots.Get( slot );
253 if( m_ShowedItems.Contains( item ) ==
false )
257 if( item.GetSlotsCountCorrect() > 0 )
259 ContainerWithCargoAndAttachments iwca =
new ContainerWithCargoAndAttachments(
this,
false );
260 iwca.SetEntity( item );
261 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetPanelWidget(),
this,
"ToggleContainer" );
263 icon.GetRadialIconPanel().Show(
true );
264 m_ShowedItems.Insert( item, iwca );
268 else if( item.GetInventory().GetCargo() )
270 ContainerWithCargo iwc =
new ContainerWithCargo(
this,
false );
271 iwc.SetEntity( item );
272 iwc.UpdateInterval();
273 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetPanelWidget(),
this,
"ToggleContainer" );
274 m_ShowedItems.Insert( item, iwc );
275 icon.GetRadialIconPanel().Show(
true);
282 string config =
"CfgVehicles " + item.GetType() +
" GUIInventoryAttachmentsProps";
285 bool show_radial_icon = ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 ) && !
GetGame().ConfigIsExisting( config );
286 Widget rip = icon.GetRadialIconPanel();
287 Widget icon_open = icon.GetRadialIcon();
288 Widget icon_closed = icon.GetRadialIconClosed();
289 rip.Show( show_radial_icon );
290 icon_open.Show( conta.IsOpened() );
291 icon_closed.Show( !conta.IsOpened() );
293 RecomputeOpenedContainers();
297 void ItemDetached(
EntityAI item,
string slot_name)
300 SlotsIcon icon = m_InventorySlots.Get( slot );
304 Container con = m_ShowedItems.Get( item );
308 RecomputeOpenedContainers();
309 GetMainWidget().Update();
311 m_ShowedItems.Remove( item );
317 in.UpdateConsoleToolbar();
321 override bool CanOpenCloseContainerEx(
EntityAI focusedEntity)
337 if (c && c.IsDisplayable())
346 void ToggleContainer(
Widget w)
353 item = icon.GetEntity();
364 RecomputeOpenedContainers();
367 void MouseClick(
Widget w,
int x,
int y,
int button)
373 selectedItem =
ItemBase.Cast(icon.GetEntity());
380 #ifdef DIAG_DEVELOPER
382 ShowActionMenu(selectedItem);
387 InspectItem(selectedItem);
391 if (
g_Game.IsLeftCtrlDown())
394 if (controlledPlayer.CanDropEntity(selectedItem))
396 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
397 selectedItem.SplitIntoStackMaxClient(
null, -1);
399 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
401 ItemManager.GetInstance().SetWidgetDraggable(w,
false);
409 SlotsIcon GetSlotsIcon(
int row,
int column )
411 return SlotsContainer.Cast( m_Container.Get( row ) ).GetSlotIcon( column );
414 void InitGhostSlots()
418 bool has_cargo = m_ZombieEntity.GetInventory().GetCargo() !=
null;
420 string config_path_ghosts_slots =
"CfgVehicles ZombieBase InventoryEquipment playerSlots";
422 GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
424 for (
int i = 0; i < player_ghosts_slots.Count(); i++ )
426 string slot_name = player_ghosts_slots.Get ( i );
427 string path =
"CfgSlots" +
" " + slot_name;
432 GetGame().ConfigGetText(
path +
" ghostIcon", icon_name );
437 if( row >= m_Container.Count() )
441 if( row < ( (player_ghosts_slots.Count() + 1 )/
ITEMS_IN_ROW ) )
444 AddSlotsContainer( ( player_ghosts_slots.Count() + 1 ) %
ITEMS_IN_ROW );
449 if ( row < ( player_ghosts_slots.Count() /
ITEMS_IN_ROW ) )
452 AddSlotsContainer( player_ghosts_slots.Count() %
ITEMS_IN_ROW );
457 icon = GetSlotsIcon( row, column );
459 icon.GetMainWidget().Show(
true );
462 WidgetEventHandler.GetInstance().RegisterOnDoubleClick( icon.GetPanelWidget(),
this,
"DoubleClick" );
465 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(),
this,
"OnDropReceivedFromGhostArea" );
466 WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(),
this,
"OnDropReceivedFromGhostArea" );
467 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetPanelWidget(),
this,
"DraggingOver" );
468 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetGhostSlot(),
this,
"DraggingOver" );
469 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetPanelWidget(),
this,
"DraggingOver" );
470 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetPanelWidget(),
this,
"MouseClick" );
475 GetGame().ConfigGetText(
path +
" name", slot_name );
477 icon.SetSlotID( slot_id );
478 icon.SetSlotDisplayName(
InventorySlots.GetSlotDisplayName(slot_id));
479 m_InventorySlots.Set( slot_id, icon );
482 ItemBase item =
ItemBase.Cast( m_ZombieEntity.GetInventory().FindAttachment( slot ) );
485 ItemAttached( item, slot_name );
489 if( m_ZombieEntity.GetInventory().GetCargo() )
493 if( row >= m_Container.Count() )
495 if( row < ( player_ghosts_slots.Count() + 1 /
ITEMS_IN_ROW ) )
498 AddSlotsContainer( ( player_ghosts_slots.Count() + 1 ) %
ITEMS_IN_ROW );
501 icon = GetSlotsIcon( row, column );
502 icon.GetMainWidget().Show(
true );
504 icon.GetGhostSlot().LoadImageFile( 0,
StaticGUIUtils.VerifyIconImageString(
StaticGUIUtils.IMAGESETGROUP_INVENTORY,m_ZombieEntity.ConfigGetString(
"GUIInventoryCargoIcon")) );
505 icon.SetSlotDisplayName( m_ZombieEntity.ConfigGetString(
"GUIInventoryCargoName") );
506 icon.GetRadialIconPanel().Show(
true );
507 icon.GetRadialIcon().Show(
true );
509 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetGhostSlot(),
this,
"ToggleContainer" );
510 m_CargoGrid =
new ContainerWithCargo(
this,
false );
511 m_CargoGrid.SetEntity( m_ZombieEntity );
512 m_CargoGrid.GetHeader().GetMainWidget().ClearFlags(
WidgetFlags.DRAGGABLE );
513 m_ShowedItems.Insert( m_ZombieEntity, m_CargoGrid );
514 icon.SetContainer(m_CargoGrid);
517 RecomputeOpenedContainers();
520 void AddSlotsContainer(
int row_count )
523 s_cont.SetColumnCount( row_count );
524 m_Container.Insert( s_cont );
527 Widget GetWidgetSlot(
int slot_number )
532 return m_Container.Get( row ).GetMainWidget().FindAnyWidget(
"Render" + column );
535 void DoubleClick(
Widget w,
int x,
int y,
int button)
546 string name = w.GetName();
547 name.Replace(
"PanelWidget",
"Render" );
564 if( player.GetInventory().HasInventoryReservation( item,
null ) || player.IsItemsToDelete() )
569 if( !item.GetInventory().CanRemoveEntity() )
572 if ( player.GetInventory().HasEntityInInventory( item ) &&
GetGame().
GetPlayer().GetHumanInventory().CanAddEntityInHands( item ) )
574 player.PredictiveTakeEntityToHands( item );
581 if( item.GetTargetQuantityMax(il.GetSlot()) < item.GetQuantity() )
582 item.SplitIntoStackMaxToInventoryLocationClient( il );
586 else if(
GetGame().
GetPlayer().GetHumanInventory().CanAddEntityInHands( item ) )
588 if( item.GetTargetQuantityMax() < item.GetQuantity() )
589 item.SplitIntoStackMaxHandsClient( player );
591 player.PredictiveTakeEntityToHands( item );
599 menu.RefreshQuickbar();
604 override void CollapseButtonOnMouseButtonDown(
Widget w)
606 super.CollapseButtonOnMouseButtonDown(w);
609 override bool SplitItem()
613 if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
615 return GetFocusedContainer().SplitItem();
621 override bool EquipItem()
625 if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
627 return GetFocusedContainer().EquipItem();
642 override bool TransferItem()
646 if (CanTakeToInventory())
651 if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
653 return GetFocusedContainer().TransferItem();
657 item = GetFocusedItem();
667 if (!GetFocusedContainer().IsInherited( ContainerWithCargo ) && !GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
669 item = GetFocusedItem();
681 override bool Select()
683 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
685 return GetFocusedContainer().Select();
690 EntityAI focused_item = GetFocusedItem();
692 if( !(selected_slot && selected_slot.IsOutOfReach() ) )
696 if( selected_item != focused_item)
698 if( selected_item.GetInventory().CanRemoveEntity() )
701 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
708 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
710 EntityAI item_in_hands =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
711 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
713 if(
GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
715 GetGame().GetPlayer().PredictiveSwapEntities( item_in_hands, focused_item );
725 if (
GetGame().
GetPlayer().NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.GetParent()) ||
GetGame().
GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(),
GetGame().
GetPlayer()) )
728 GetGame().GetPlayer().GetHumanInventory().ForceSwapEntities(
InventoryMode.JUNCTURE, focused_item, item_in_hands, il_hands_dst );
735 if(
GetGame().
GetPlayer().GetHumanInventory().CanAddEntityInHands( focused_item ) )
737 GetGame().GetPlayer().PredictiveTakeEntityToHands( focused_item );
748 override bool TransferItemToVicinity()
752 if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
754 return GetFocusedContainer().TransferItemToVicinity();
758 Man player =
GetGame().GetPlayer();
760 if( item && player.CanDropEntity( item ) )
762 if( item.GetTargetQuantityMax() < item.GetQuantity() )
763 item.SplitIntoStackMaxClient(
null, -1 );
765 player.PhysicalPredictiveDropItem( item );